Merge niosocketimpl-branch
authoralanb
Tue, 09 Apr 2019 11:48:54 +0100
branchniosocketimpl-branch
changeset 57312 36c96936c5bc
parent 57311 6d80c72b7484 (current diff)
parent 54471 f22759e92191 (diff)
child 57313 14b02c7b27b8
Merge
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/UnsafeAccess.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsafeAccess.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/UnsafeAccess.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/NodeCostDumpUtil.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/UnsafeAccess.java
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.word/src/org/graalvm/compiler/word/UnsafeAccess.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java
test/hotspot/jtreg/applications/ctw/modules/jdk_incubator_httpclient.java
test/hotspot/jtreg/applications/ctw/modules/jdk_packager.java
test/hotspot/jtreg/applications/ctw/modules/jdk_packager_services.java
test/hotspot/jtreg/runtime/noClassDefFoundMsg/NoClassDefFoundMsg.java
test/hotspot/jtreg/runtime/noClassDefFoundMsg/libNoClassDefFoundMsg.c
test/hotspot/jtreg/serviceability/dcmd/framework/TestJavaProcess.java
test/jdk/ProblemList.txt
test/jdk/sun/security/ssl/rsa/BrokenRSAPrivateCrtKey.java
test/langtools/jdk/javadoc/doclet/AccessFrameTitle/AccessFrameTitle.java
test/langtools/jdk/javadoc/doclet/AccessFrameTitle/p1/C1.java
test/langtools/jdk/javadoc/doclet/AccessFrameTitle/p2/C2.java
test/langtools/jdk/javadoc/doclet/PackagesHeader/PackagesHeader.java
test/langtools/jdk/javadoc/doclet/PackagesHeader/p1/C1.java
test/langtools/jdk/javadoc/doclet/PackagesHeader/p2/C2.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/TestClassDocCatalog.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyAnnotation.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyClass.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyEnum.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyError.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyException.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyInterface.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyAnnotation.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyClass.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyEnum.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyError.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyException.java
test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyInterface.java
test/langtools/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java
test/langtools/jdk/javadoc/doclet/testWindowTitle/TestWindowTitle.java
test/langtools/jdk/javadoc/doclet/testWindowTitle/p1/C1.java
test/langtools/jdk/javadoc/doclet/testWindowTitle/p2/C2.java
--- a/.hgtags	Mon Apr 08 10:47:35 2019 +0100
+++ b/.hgtags	Tue Apr 09 11:48:54 2019 +0100
@@ -551,3 +551,5 @@
 1d7aec80147a6d92b101a76aef92f3ddc88bedf4 jdk-13+12
 b67884871b5fff79c5ef3eb8ac74dd48d71ea9b1 jdk-12-ga
 83cace4142c8563b6a921787db02388e1bc48d01 jdk-13+13
+46cf212cdccaf4fb064d913b12004007d3322b67 jdk-13+14
+f855ec13aa2501ae184c8b3e0626a8cec9966116 jdk-13+15
--- a/make/Bundles.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/Bundles.gmk	Tue Apr 09 11:48:54 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
@@ -29,6 +29,7 @@
 include MakeBase.gmk
 
 PRODUCT_TARGETS :=
+LEGACY_TARGETS :=
 TEST_TARGETS :=
 DOCS_TARGETS :=
 
@@ -71,7 +72,7 @@
 
   $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME): $$($1_FILES)
 	$$(call MakeTargetDir)
-        # If any of the files contain a space in the file name, CacheFind
+        # 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.
 	$$(foreach d, $$($1_BASE_DIRS), \
@@ -146,24 +147,31 @@
 # correct base directories.
 ifeq ($(call isTargetOs, macosx)+$(DEBUG_LEVEL), true+release)
   JDK_IMAGE_DIR := $(JDK_MACOSX_BUNDLE_DIR)
+  JRE_IMAGE_DIR := $(JRE_MACOSX_BUNDLE_DIR)
   JDK_IMAGE_HOMEDIR := $(JDK_MACOSX_CONTENTS_DIR)/Home
+  JRE_IMAGE_HOMEDIR := $(JRE_MACOSX_CONTENTS_DIR)/Home
   JDK_BUNDLE_SUBDIR :=
+  JRE_BUNDLE_SUBDIR :=
 else
   JDK_IMAGE_HOMEDIR := $(JDK_IMAGE_DIR)
+  JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR)
   JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER)
+  JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)
   ifneq ($(DEBUG_LEVEL), release)
     JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL)
+    JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL)
   endif
 endif
 
 ################################################################################
 
-ifneq ($(filter product-bundles, $(MAKECMDGOALS)), )
-  $(eval $(call FillCacheFind, $(IMAGES_OUTPUTDIR)))
+ifneq ($(filter product-bundles legacy-bundles, $(MAKECMDGOALS)), )
 
   SYMBOLS_EXCLUDE_PATTERN := %.debuginfo %.diz %.pdb %.map
 
-  ALL_JDK_FILES := $(call CacheFind, $(JDK_IMAGE_DIR))
+  # There may be files with spaces in the names, so use ShellFindFiles
+  # explicitly.
+  ALL_JDK_FILES := $(call ShellFindFiles, $(JDK_IMAGE_DIR))
 
   # Create special filter rules when dealing with unzipped .dSYM directories on
   # macosx
@@ -194,10 +202,26 @@
               $(ALL_JDK_FILES) \
           ) \
       ) \
-      $(call CacheFind, $(SYMBOLS_IMAGE_DIR))
+      $(call FindFiles, $(SYMBOLS_IMAGE_DIR))
 
   TEST_DEMOS_BUNDLE_FILES := $(filter $(JDK_IMAGE_HOMEDIR)/demo/%, $(ALL_JDK_FILES))
 
+  ALL_JRE_FILES := $(call ShellFindFiles, $(JRE_IMAGE_DIR))
+
+  # Create special filter rules when dealing with unzipped .dSYM directories on
+  # macosx
+  ifeq ($(OPENJDK_TARGET_OS), macosx)
+    ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
+      JRE_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \
+          $(call containing, .dSYM/, $(patsubst $(JRE_IMAGE_DIR)/%, %, $(ALL_JRE_FILES))))
+    endif
+  endif
+
+  JRE_BUNDLE_FILES := $(filter-out \
+      $(JRE_SYMBOLS_EXCLUDE_PATTERN) \
+      $(SYMBOLS_EXCLUDE_PATTERN), \
+      $(ALL_JRE_FILES))
+
   $(eval $(call SetupBundleFile, BUILD_JDK_BUNDLE, \
       BUNDLE_NAME := $(JDK_BUNDLE_NAME), \
       FILES := $(JDK_BUNDLE_FILES), \
@@ -208,6 +232,15 @@
 
   PRODUCT_TARGETS += $(BUILD_JDK_BUNDLE)
 
+  $(eval $(call SetupBundleFile, BUILD_JRE_BUNDLE, \
+      BUNDLE_NAME := $(JRE_BUNDLE_NAME), \
+      FILES := $(JRE_BUNDLE_FILES), \
+      BASE_DIRS := $(JRE_IMAGE_DIR), \
+      SUBDIR := $(JRE_BUNDLE_SUBDIR), \
+  ))
+
+  LEGACY_TARGETS += $(BUILD_JRE_BUNDLE)
+
   $(eval $(call SetupBundleFile, BUILD_JDK_SYMBOLS_BUNDLE, \
       BUNDLE_NAME := $(JDK_SYMBOLS_BUNDLE_NAME), \
       FILES := $(JDK_SYMBOLS_BUNDLE_FILES), \
@@ -234,7 +267,7 @@
 ################################################################################
 
 ifneq ($(filter test-bundles, $(MAKECMDGOALS)), )
-  TEST_BUNDLE_FILES := $(call CacheFind, $(TEST_IMAGE_DIR))
+  TEST_BUNDLE_FILES := $(call FindFiles, $(TEST_IMAGE_DIR))
 
   $(eval $(call SetupBundleFile, BUILD_TEST_BUNDLE, \
       BUNDLE_NAME := $(TEST_BUNDLE_NAME), \
@@ -248,7 +281,7 @@
 ################################################################################
 
 ifneq ($(filter docs-bundles, $(MAKECMDGOALS)), )
-  DOCS_BUNDLE_FILES := $(call CacheFind, $(DOCS_IMAGE_DIR))
+  DOCS_BUNDLE_FILES := $(call FindFiles, $(DOCS_IMAGE_DIR))
 
   $(eval $(call SetupBundleFile, BUILD_DOCS_BUNDLE, \
       BUNDLE_NAME := $(DOCS_BUNDLE_NAME), \
@@ -263,7 +296,7 @@
 ################################################################################
 
 ifneq ($(filter jcov-bundles, $(MAKECMDGOALS)), )
-  JCOV_BUNDLE_FILES := $(call CacheFind, $(JCOV_IMAGE_DIR))
+  JCOV_BUNDLE_FILES := $(call FindFiles, $(JCOV_IMAGE_DIR))
 
   $(eval $(call SetupBundleFile, BUILD_JCOV_BUNDLE, \
       BUNDLE_NAME := $(JCOV_BUNDLE_NAME), \
@@ -283,6 +316,7 @@
 ################################################################################
 
 product-bundles: $(PRODUCT_TARGETS)
+legacy-bundles: $(LEGACY_TARGETS)
 test-bundles: $(TEST_TARGETS)
 docs-bundles: $(DOCS_TARGETS)
 jcov-bundles: $(JCOV_TARGETS)
--- a/make/CompileDemos.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/CompileDemos.gmk	Tue Apr 09 11:48:54 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
@@ -43,7 +43,7 @@
 # Prepare the find cache.
 DEMO_SRC_DIRS += $(TOPDIR)/src/demo
 
-$(eval $(call FillCacheFind, $(wildcard $(DEMO_SRC_DIRS))))
+$(call FillFindCache, $(DEMO_SRC_DIRS))
 
 # Append demo goals to this variable.
 TARGETS =
@@ -237,11 +237,11 @@
 ifeq ($(call isTargetOs, solaris), true)
   TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \
     $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \
-    $(call CacheFind, $(DEMO_SHARE_SRC)/nbproject))
+    $(call FindFiles, $(DEMO_SHARE_SRC)/nbproject))
 else
   TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \
     $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \
-    $(call CacheFind, $(DEMO_SHARE_SRC)/nbproject))
+    $(call FindFiles, $(DEMO_SHARE_SRC)/nbproject))
 endif
 
 ################################################################################
@@ -250,7 +250,7 @@
   $(eval $(call SetupCopyFiles, COPY_TO_TEST_IMAGE, \
       SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \
       DEST := $(TEST_IMAGE_DIR)/jdk/demos, \
-      FILES := $(call CacheFind, $(SUPPORT_OUTPUTDIR)/demos/image), \
+      FILES := $(call FindFiles, $(SUPPORT_OUTPUTDIR)/demos/image), \
   ))
 
   IMAGES_TARGETS := $(COPY_TO_TEST_IMAGE)
--- a/make/CompileJavaModules.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/CompileJavaModules.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -79,7 +79,7 @@
 
 ################################################################################
 
-java.desktop_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference,-accessibility \
+java.desktop_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference \
     '-Xdoclint/package:java.*,javax.*' -Xlint:exports \
     --doclint-format html4
 java.desktop_COPY += .gif .png .wav .txt .xml .css .pf
@@ -653,7 +653,7 @@
 
 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), )
   $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker: \
-      $(call CacheFind, $(IMPORT_MODULE_DIR))
+      $(call FindFiles, $(IMPORT_MODULE_DIR))
 	$(call MakeDir, $(@D))
         # Do not delete marker and build meta data files
 	$(RM) -r $(filter-out $(@D)/_%, $(wildcard $(@D)/*))
--- a/make/CopyImportModules.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/CopyImportModules.gmk	Tue Apr 09 11:48:54 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
@@ -35,7 +35,7 @@
 CMDS_DIR := $(wildcard $(addsuffix /$(MODULE), $(IMPORT_MODULES_CMDS)))
 CONF_DIR := $(wildcard $(addsuffix /$(MODULE), $(IMPORT_MODULES_CONF)))
 
-$(eval $(call FillCacheFind, $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR)))
+$(call FillFindCache, $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR))
 
 ifneq ($(LIBS_DIR), )
   ifeq ($(call isTargetOs, windows), true)
@@ -45,21 +45,21 @@
         SRC := $(LIBS_DIR), \
         DEST := $(JDK_OUTPUTDIR)/bin, \
         FILES := $(filter $(TO_BIN_FILTER), \
-            $(call CacheFind, $(LIBS_DIR))) \
+            $(call FindFiles, $(LIBS_DIR))) \
     ))
 
     $(eval $(call SetupCopyFiles, COPY_LIBS_TO_LIB, \
         SRC := $(LIBS_DIR), \
         DEST := $(JDK_OUTPUTDIR)/lib, \
         FILES := $(filter-out $(TO_BIN_FILTER), \
-            $(call CacheFind, $(LIBS_DIR))) \
+            $(call FindFiles, $(LIBS_DIR))) \
     ))
     TARGETS += $(COPY_LIBS_TO_BIN) $(COPY_LIBS_TO_LIB)
   else
     $(eval $(call SetupCopyFiles, COPY_LIBS, \
         SRC := $(LIBS_DIR), \
         DEST := $(JDK_OUTPUTDIR)/lib, \
-        FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), $(call CacheFind, $(LIBS_DIR))), \
+        FILES := $(filter %$(SHARED_LIBRARY_SUFFIX), $(call FindFiles, $(LIBS_DIR))), \
     ))
 
     # Use relative links if the import dir is inside the OUTPUTDIR, otherwise
@@ -75,7 +75,7 @@
     $(eval $(call SetupCopyFiles, LINK_LIBS, \
         SRC := $(LIBS_DIR), \
         DEST := $(JDK_OUTPUTDIR)/lib, \
-        FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(call CacheFind, $(LIBS_DIR))), \
+        FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(call FindFiles, $(LIBS_DIR))), \
         MACRO := $(LINK_MACRO), \
         LOG_ACTION := $(LOG_ACTION), \
     ))
@@ -87,7 +87,7 @@
   $(eval $(call SetupCopyFiles, COPY_CMDS, \
       SRC := $(CMDS_DIR), \
       DEST := $(JDK_OUTPUTDIR)/bin, \
-      FILES := $(call CacheFind, $(CMDS_DIR)), \
+      FILES := $(call FindFiles, $(CMDS_DIR)), \
   ))
   TARGETS += $(COPY_CMDS)
 endif
@@ -96,7 +96,7 @@
   $(eval $(call SetupCopyFiles, COPY_CONF, \
       SRC := $(CONF_DIR), \
       DEST := $(JDK_OUTPUTDIR)/lib, \
-      FILES := $(call CacheFind, $(CONF_DIR)), \
+      FILES := $(call FindFiles, $(CONF_DIR)), \
   ))
   TARGETS += $(COPY_CONF)
 endif
--- a/make/CreateBuildJdkCopy.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/CreateBuildJdkCopy.gmk	Tue Apr 09 11:48:54 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
@@ -39,7 +39,7 @@
 
 COPY_CLASSES_TARGET := $(BUILDJDK_OUTPUTDIR)/jdk/modules/java.base/_the.buildjdk-copy-marker
 
-$(COPY_CLASSES_TARGET): $(call CacheFind, $(wildcard \
+$(COPY_CLASSES_TARGET): $(call FindFiles, $(wildcard \
     $(addprefix $(JDK_OUTPUTDIR)/modules/, $(MODULES_TO_COPY))))
 	$(call LogInfo, Copying java modules to buildjdk: $(MODULES_TO_COPY))
 	$(RM) -r $(BUILDJDK_OUTPUTDIR)/jdk/modules
@@ -56,7 +56,7 @@
 $(eval $(call SetupCopyFiles, COPY_SUPPORT_HEADERS, \
     SRC := $(OUTPUTDIR), \
     DEST := $(BUILDJDK_OUTPUTDIR), \
-    FILES := $(call CacheFind, $(wildcard \
+    FILES := $(call FindFiles, $(wildcard \
         $(addprefix $(SUPPORT_OUTPUTDIR)/headers/, $(MODULES_TO_COPY)))), \
 ))
 
--- a/make/CreateJmods.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/CreateJmods.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -53,33 +53,33 @@
 MAN_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN))))
 
-$(eval $(call FillCacheFind, \
+$(call FillFindCache, \
     $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \
-))
+)
 
 ifneq ($(LIBS_DIR), )
   JMOD_FLAGS += --libs $(LIBS_DIR)
-  DEPS += $(call CacheFind, $(LIBS_DIR))
+  DEPS += $(call FindFiles, $(LIBS_DIR))
 endif
 ifneq ($(CMDS_DIR), )
   JMOD_FLAGS += --cmds $(CMDS_DIR)
-  DEPS += $(call CacheFind, $(CMDS_DIR))
+  DEPS += $(call FindFiles, $(CMDS_DIR))
 endif
 ifneq ($(CONF_DIR), )
   JMOD_FLAGS += --config $(CONF_DIR)
-  DEPS += $(call CacheFind, $(CONF_DIR))
+  DEPS += $(call FindFiles, $(CONF_DIR))
 endif
 ifneq ($(CLASSES_DIR), )
   JMOD_FLAGS += --class-path $(CLASSES_DIR)
-  DEPS += $(call CacheFind, $(CLASSES_DIR))
+  DEPS += $(call FindFiles, $(CLASSES_DIR))
 endif
 ifneq ($(INCLUDE_HEADERS_DIR), )
   JMOD_FLAGS += --header-files $(INCLUDE_HEADERS_DIR)
-  DEPS += $(call CacheFind, $(INCLUDE_HEADERS_DIR))
+  DEPS += $(call FindFiles, $(INCLUDE_HEADERS_DIR))
 endif
 ifneq ($(MAN_DIR), )
   JMOD_FLAGS += --man-pages $(MAN_DIR)
-  DEPS += $(call CacheFind, $(MAN_DIR))
+  DEPS += $(call FindFiles, $(MAN_DIR))
 endif
 
 # If a specific modules_legal dir exists for this module, only pick up files
@@ -93,7 +93,7 @@
     )
 
 LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES))
-DEPS += $(call CacheFind, $(LEGAL_NOTICES))
+DEPS += $(call FindFiles, $(LEGAL_NOTICES))
 
 JMOD_FLAGS += --legal-notices $(LEGAL_NOTICES_PATH)
 
@@ -147,7 +147,7 @@
 # the actual command. Filter that out using wildcard before adding to DEPS.
 DEPS += $(wildcard $(JMOD_CMD))
 ifeq ($(EXTERNAL_BUILDJDK), false)
-  DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
+  DEPS += $(call FindFiles, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
 endif
 
 # If creating interim versions of jmods, certain files need to be filtered out
--- a/make/Docs.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/Docs.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -337,7 +337,7 @@
       $$(SUPPORT_OUTPUTDIR)/docs/$1.vardeps)
 
   # Get a list of all files in all the source dirs for all included modules
-  $1_SOURCE_DEPS := $$(call CacheFind, $$(wildcard $$(foreach module, \
+  $1_SOURCE_DEPS := $$(call FindFiles, $$(wildcard $$(foreach module, \
       $$($1_ALL_MODULES), $$(call FindModuleSrcDirs, $$(module)))))
 
   $$(eval $$(call SetupExecute, javadoc_$1, \
@@ -484,7 +484,7 @@
 GLOBAL_SPECS_RESOURCES_DIR := $(TOPDIR)/make/data/docs-resources/
 $(eval $(call SetupCopyFiles, COPY_GLOBAL_RESOURCES, \
     SRC := $(GLOBAL_SPECS_RESOURCES_DIR), \
-    FILES := $(call CacheFind, $(GLOBAL_SPECS_RESOURCES_DIR)), \
+    FILES := $(call FindFiles, $(GLOBAL_SPECS_RESOURCES_DIR)), \
     DEST := $(DOCS_OUTPUTDIR), \
 ))
 JDK_INDEX_TARGETS += $(COPY_GLOBAL_RESOURCES)
@@ -509,10 +509,10 @@
 $(foreach m, $(ALL_MODULES), \
   $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
   $(foreach d, $(SPECS_$m), \
-    $(if $(filter $(COPY_SPEC_FILTER), $(call CacheFind, $d)), \
+    $(if $(filter $(COPY_SPEC_FILTER), $(call FindFiles, $d)), \
       $(eval $(call SetupCopyFiles, COPY_$m, \
           SRC := $d, \
-          FILES := $(filter $(COPY_SPEC_FILTER), $(call CacheFind, $d)), \
+          FILES := $(filter $(COPY_SPEC_FILTER), $(call FindFiles, $d)), \
           DEST := $(DOCS_OUTPUTDIR)/specs/, \
       )) \
       $(eval JDK_SPECS_TARGETS += $(COPY_$m)) \
@@ -529,11 +529,11 @@
   $(foreach m, $(ALL_MODULES), \
     $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
     $(foreach d, $(SPECS_$m), \
-      $(if $(filter %.md, $(call CacheFind, $d)), \
+      $(if $(filter %.md, $(call FindFiles, $d)), \
         $(eval $m_$d_NAME := SPECS_TO_HTML_$m_$(strip $(call RelativePath, $d, $(TOPDIR)))) \
         $(eval $(call SetupProcessMarkdown, $($m_$d_NAME), \
             SRC := $d, \
-            FILES := $(filter %.md, $(call CacheFind, $d)), \
+            FILES := $(filter %.md, $(call FindFiles, $d)), \
             DEST := $(DOCS_OUTPUTDIR)/specs/, \
             CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
         )) \
@@ -556,11 +556,11 @@
   $(foreach m, $(ALL_MODULES), \
     $(eval MAN_$m := $(call FindModuleManDirs, $m)) \
     $(foreach d, $(MAN_$m), \
-      $(if $(filter %.md, $(call CacheFind, $d)), \
+      $(if $(filter %.md, $(call FindFiles, $d)), \
         $(eval $m_$d_NAME := MAN_TO_HTML_$m_$(strip $(call RelativePath, $d, $(TOPDIR)))) \
         $(eval $(call SetupProcessMarkdown, $($m_$d_NAME), \
             SRC := $d, \
-            FILES := $(filter %.md, $(call CacheFind, $d)), \
+            FILES := $(filter %.md, $(call FindFiles, $d)), \
             DEST := $(DOCS_OUTPUTDIR)/specs/man, \
             FILTER := $(PANDOC_HTML_MANPAGE_FILTER), \
             CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
--- a/make/Images.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/Images.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -183,21 +183,14 @@
 
 ifeq ($(GCOV_ENABLED), true)
 
-  GCOV_FIND_EXPR := -type f -name "*.gcno"
-
-  $(eval $(call SetupCopyFiles,COPY_HOTSPOT_GCOV_GCNO, \
+  $(eval $(call SetupCopyFiles,COPY_GCOV_GCNO, \
       SRC := $(OUTPUTDIR), \
       DEST := $(SYMBOLS_IMAGE_DIR)/gcov, \
-      FILES := $(shell $(FIND) $(HOTSPOT_OUTPUTDIR) $(GCOV_FIND_EXPR))))
-
-  SYMBOLS_TARGETS += $(COPY_HOTSPOT_GCOV_GCNO)
+      FILES := $(call FindFiles, $(HOTSPOT_OUTPUTDIR) \
+          $(SUPPORT_OUTPUTDIR)/native, *.gcno) \
+  ))
 
-  $(eval $(call SetupCopyFiles,COPY_JDK_GCOV_GCNO, \
-      SRC := $(OUTPUTDIR), \
-      DEST := $(SYMBOLS_IMAGE_DIR)/gcov, \
-      FILES := $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/native $(GCOV_FIND_EXPR))))
-
-  SYMBOLS_TARGETS += $(COPY_JDK_GCOV_GCNO)
+  SYMBOLS_TARGETS += $(COPY_GCOV_GCNO)
 
 endif
 
@@ -230,10 +223,10 @@
   # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM
   # dirs.
   ifeq ($(call isTargetOs, macosx), true)
-    $(eval $(call FillCacheFind, \
-        $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs))
+    $(call FillFindCache, \
+        $(SUPPORT_OUTPUTDIR)/modules_cmds $(SUPPORT_OUTPUTDIR)/modules_libs)
     FindDebuginfoFiles = \
-        $(if $(wildcard $1), $(call containing, .dSYM/, $(call CacheFind, $1)))
+        $(if $(wildcard $1), $(call containing, .dSYM/, $(call FindFiles, $1)))
   endif
 endif
 
--- a/make/Init.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/Init.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -238,11 +238,13 @@
   ifeq ($(LOG_NOFILE), true)
     # Disable build log if LOG=[level,]nofile was given
     override BUILD_LOG_PIPE :=
+    override BUILD_LOG_PIPE_SIMPLE :=
   endif
 
   ifeq ($(filter dist-clean, $(SEQUENTIAL_TARGETS)), dist-clean)
     # We can't have a log file if we're about to remove it.
     override BUILD_LOG_PIPE :=
+    override BUILD_LOG_PIPE_SIMPLE :=
   endif
 
   ifeq ($(OUTPUT_SYNC_SUPPORTED), true)
@@ -277,7 +279,7 @@
         else
 	  $(ECHO) "Re-running configure using default settings"
         endif
-	( cd $(OUTPUTDIR) && PATH="$(ORIGINAL_PATH)" AUTOCONF="$(AUTOCONF)" \
+	( cd $(CONFIGURE_START_DIR) && PATH="$(ORIGINAL_PATH)" AUTOCONF="$(AUTOCONF)" \
 	    CUSTOM_ROOT="$(CUSTOM_ROOT)" \
 	    CUSTOM_CONFIG_DIR="$(CUSTOM_CONFIG_DIR)" \
 	    $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) )
@@ -303,7 +305,7 @@
   main: $(INIT_TARGETS)
         ifneq ($(SEQUENTIAL_TARGETS)$(PARALLEL_TARGETS), )
 	  $(call RotateLogFiles)
-	  $(PRINTF) "Building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE)
+	  $(PRINTF) "Building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE_SIMPLE)
           ifneq ($(SEQUENTIAL_TARGETS), )
             # Don't touch build output dir since we might be cleaning. That
             # means no log pipe.
@@ -325,7 +327,7 @@
 	            $(PARALLEL_TARGETS) $(COMPARE_BUILD_MAKE) $(BUILD_LOG_PIPE) || \
 	        ( exitcode=$$? && \
 	        $(PRINTF) "\nERROR: Build failed for $(TARGET_DESCRIPTION) (exit code $$exitcode) \n" \
-	            $(BUILD_LOG_PIPE) && \
+	            $(BUILD_LOG_PIPE_SIMPLE) && \
 	        cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -j 1 -f make/Init.gmk \
 	            HAS_SPEC=true on-failure ; \
 	        exit $$exitcode ) )
@@ -336,7 +338,7 @@
 	  if test -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error ; then \
 	    exit 1 ; \
 	  fi
-	  $(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE)
+	  $(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE_SIMPLE)
 	  $(call ReportProfileTimes)
         endif
 
--- a/make/InitSupport.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/InitSupport.gmk	Tue Apr 09 11:48:54 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
@@ -264,13 +264,9 @@
       endif
     endif
 
-    # The --no-print-directory is needed to make the call from
-    # FindTest.gmk to Test.gmk work with LOG=debug/trace. See
-    # JDK-8213736
     $$(main_targets_file):
 	@( cd $$(topdir) && \
-	$$(MAKE) $$(MAKE_LOG_FLAGS) -r -R --no-print-directory \
-	    -f $$(topdir)/make/Main.gmk \
+	$$(MAKE) $$(MAKE_LOG_FLAGS) -r -R -f $$(topdir)/make/Main.gmk \
 	    -I $$(topdir)/make/common SPEC=$(strip $2) NO_RECIPES=true \
 	    $$(MAKE_LOG_VARS) \
 	    create-main-targets-include )
@@ -300,6 +296,9 @@
   BUILD_PROFILE_LOG := $(OUTPUTDIR)/build-profile.log
 
   BUILD_LOG_PIPE := > >($(TEE) -a $(BUILD_LOG)) 2> >($(TEE) -a $(BUILD_LOG) >&2) && wait
+  # Use this for simple echo/printf commands that are never expected to print
+  # to stderr.
+  BUILD_LOG_PIPE_SIMPLE := | $(TEE) -a $(BUILD_LOG)
 
   ifneq ($(CUSTOM_ROOT), )
     topdir=$(CUSTOM_ROOT)
@@ -518,7 +517,7 @@
 	    "`$(LS) $(BUILDTIMESDIR)/build_time_diff_* | $(GREP) -v _TOTAL | \
 	    $(XARGS) $(CAT) | $(SORT) -k 2`" \
 	    "`$(CAT) $(BUILDTIMESDIR)/build_time_diff_TOTAL`" \
-	    $(BUILD_LOG_PIPE)
+	    $(BUILD_LOG_PIPE_SIMPLE)
   endef
 
   define ReportProfileTimes
@@ -528,7 +527,7 @@
         $(CAT) $(BUILD_PROFILE_LOG) && \
         $(ECHO) End $(notdir $(BUILD_PROFILE_LOG)); \
       } \
-      $(BUILD_LOG_PIPE)
+      $(BUILD_LOG_PIPE_SIMPLE)
     )
   endef
 
--- a/make/MacBundles.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/MacBundles.gmk	Tue Apr 09 11:48:54 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
@@ -52,13 +52,13 @@
   $(eval $(call SetupCopyFiles, COPY_JDK_IMAGE, \
       SRC := $(JDK_IMAGE_DIR), \
       DEST := $(JDK_MACOSX_CONTENTS_DIR)/Home, \
-      FILES := $(call CacheFind, $(JDK_IMAGE_DIR)), \
+      FILES := $(call FindFiles, $(JDK_IMAGE_DIR)), \
   ))
 
   $(eval $(call SetupCopyFiles, COPY_JRE_IMAGE, \
       SRC := $(JRE_IMAGE_DIR), \
       DEST := $(JRE_MACOSX_CONTENTS_DIR)/Home, \
-      FILES := $(call CacheFind, $(JRE_IMAGE_DIR)), \
+      FILES := $(call FindFiles, $(JRE_IMAGE_DIR)), \
   ))
 
   $(JDK_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib:
--- a/make/Main.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/Main.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -335,6 +335,7 @@
 bootcycle-images:
         ifneq ($(COMPILE_TYPE), cross)
 	  $(call LogWarn, Boot cycle build step 2: Building a new JDK image using previously built image)
+	  $(call MakeDir, $(OUTPUTDIR)/bootcycle-build)
 	  +$(MAKE) $(MAKE_ARGS) -f $(TOPDIR)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
 	      JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
         else
@@ -581,6 +582,9 @@
 product-bundles:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles)
 
+legacy-bundles:
+	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk legacy-bundles)
+
 test-bundles:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles)
 
@@ -592,7 +596,7 @@
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk jcov-bundles)
 endif
 
-ALL_TARGETS += product-bundles test-bundles docs-bundles jcov-bundles
+ALL_TARGETS += product-bundles legacy-bundles test-bundles docs-bundles jcov-bundles
 
 ################################################################################
 # Install targets
@@ -647,7 +651,6 @@
 
   # Declare dependencies between hotspot-<variant>* targets
   $(foreach v, $(JVM_VARIANTS), \
-      $(eval hotspot-$v: hotspot-$v-gensrc hotspot-$v-libs) \
       $(eval hotspot-$v-gensrc: java.base-copy) \
       $(eval hotspot-$v-libs: hotspot-$v-gensrc java.base-copy) \
   )
@@ -918,6 +921,8 @@
 
   product-bundles: product-images
 
+  legacy-bundles: legacy-images
+
   test-bundles: test-image
 
   docs-bundles: docs-image
@@ -938,6 +943,10 @@
 buildtools: buildtools-langtools interim-langtools interim-rmic \
     buildtools-jdk $(JVM_TOOLS_TARGETS)
 
+# Declare dependencies from hotspot-<variant> targets
+$(foreach v, $(JVM_VARIANTS), \
+  $(eval hotspot-$v: hotspot-$v-gensrc hotspot-$v-libs) \
+)
 hotspot: $(HOTSPOT_VARIANT_TARGETS)
 
 # Create targets hotspot-libs and hotspot-gensrc.
@@ -1020,6 +1029,9 @@
 # (and possibly other, more specific versions)
 product-images: jdk-image symbols-image exploded-image
 
+# This target builds the legacy images, e.g. the legacy JRE image
+legacy-images: legacy-jre-image
+
 # zip-security is actually a bundle, but for now it needs to be considered
 # an image until this can be cleaned up properly.
 product-images: zip-security
@@ -1036,6 +1048,8 @@
 
 ifeq ($(call isTargetOs, macosx), true)
   product-images: mac-jdk-bundle
+
+  legacy-images: mac-legacy-jre-bundle
 endif
 
 # This target builds the documentation image
@@ -1070,7 +1084,7 @@
     jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \
     exploded-image-base exploded-image \
     create-buildjdk docs-jdk-api docs-javase-api docs-reference-api docs-jdk \
-    docs-javase docs-reference docs-javadoc mac-bundles product-images \
+    docs-javase docs-reference docs-javadoc mac-bundles product-images legacy-images \
     docs-image test-image all-images \
     all-bundles
 
--- a/make/RunTestsPrebuilt.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/RunTestsPrebuilt.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -338,6 +338,12 @@
 
 run-test-prebuilt:
 	@$(RM) -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error
+        # The lazy initialization of the cache file in FindTests.gmk does not
+        # always work with RunTests.gmk. To guarantee that the jtreg test groups
+        # are always found and parsed, call FindTests.gmk stand alone once
+        # before calling RunTests.gmk.
+	@cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -f make/common/FindTests.gmk \
+	    SPEC=$(SPEC) FINDTESTS_STAND_ALONE=true
 	@cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -f make/RunTests.gmk run-test \
 	    TEST="$(TEST)"
 
--- a/make/ZipSource.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/ZipSource.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -87,6 +87,7 @@
       EXCLUDE_FILES := $(SRC_ZIP_EXCLUDE_FILES), \
       SUFFIXES := .java, \
       ZIP := $(SUPPORT_OUTPUTDIR)/src.zip, \
+      FOLLOW_SYMLINKS := true, \
   ))
 
   do-zip: $(BUILD_SRC_ZIP)
--- a/make/autoconf/basics.m4	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/autoconf/basics.m4	Tue Apr 09 11:48:54 2019 +0100
@@ -627,7 +627,7 @@
 AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
 [
   # Save the current directory this script was started from
-  CURDIR="$PWD"
+  CONFIGURE_START_DIR="$PWD"
 
   # We might need to rewrite ORIGINAL_PATH, if it includes "#", to quote them
   # for make. We couldn't do this when we retrieved ORIGINAL_PATH, since SED
@@ -653,9 +653,10 @@
   AC_MSG_CHECKING([for top-level directory])
   AC_MSG_RESULT([$TOPDIR])
   AC_SUBST(TOPDIR)
+  AC_SUBST(CONFIGURE_START_DIR)
 
   # We can only call BASIC_FIXUP_PATH after BASIC_CHECK_PATHS_WINDOWS.
-  BASIC_FIXUP_PATH(CURDIR)
+  BASIC_FIXUP_PATH(CONFIGURE_START_DIR)
   BASIC_FIXUP_PATH(TOPDIR)
 
   # Locate the directory of this script.
@@ -868,9 +869,10 @@
 
   # Test from where we are running configure, in or outside of src root.
   AC_MSG_CHECKING([where to store configuration])
-  if test "x$CURDIR" = "x$TOPDIR" || test "x$CURDIR" = "x$CUSTOM_ROOT" \
-      || test "x$CURDIR" = "x$TOPDIR/make/autoconf" \
-      || test "x$CURDIR" = "x$TOPDIR/make" ; then
+  if test "x$CONFIGURE_START_DIR" = "x$TOPDIR" \
+      || test "x$CONFIGURE_START_DIR" = "x$CUSTOM_ROOT" \
+      || test "x$CONFIGURE_START_DIR" = "x$TOPDIR/make/autoconf" \
+      || test "x$CONFIGURE_START_DIR" = "x$TOPDIR/make" ; then
     # We are running configure from the src root.
     # Create a default ./build/target-variant-debuglevel output root.
     if test "x${CONF_NAME}" = x; then
@@ -895,9 +897,9 @@
     # If configuration is situated in normal build directory, just use the build
     # directory name as configuration name, otherwise use the complete path.
     if test "x${CONF_NAME}" = x; then
-      CONF_NAME=`$ECHO $CURDIR | $SED -e "s!^${TOPDIR}/build/!!"`
+      CONF_NAME=`$ECHO $CONFIGURE_START_DIR | $SED -e "s!^${TOPDIR}/build/!!"`
     fi
-    OUTPUTDIR="$CURDIR"
+    OUTPUTDIR="$CONFIGURE_START_DIR"
     AC_MSG_RESULT([in current directory])
 
     # WARNING: This might be a bad thing to do. You need to be sure you want to
@@ -917,14 +919,14 @@
               -e 's/ //g' \
           | $TR -d '\n'`
       if test "x$filtered_files" != x; then
-        AC_MSG_NOTICE([Current directory is $CURDIR.])
+        AC_MSG_NOTICE([Current directory is $CONFIGURE_START_DIR.])
         AC_MSG_NOTICE([Since this is not the source root, configure will output the configuration here])
         AC_MSG_NOTICE([(as opposed to creating a configuration in <src_root>/build/<conf-name>).])
         AC_MSG_NOTICE([However, this directory is not empty. This is not allowed, since it could])
         AC_MSG_NOTICE([seriously mess up just about everything.])
         AC_MSG_NOTICE([Try 'cd $TOPDIR' and restart configure])
         AC_MSG_NOTICE([(or create a new empty directory and cd to it).])
-        AC_MSG_ERROR([Will not continue creating configuration in $CURDIR])
+        AC_MSG_ERROR([Will not continue creating configuration in $CONFIGURE_START_DIR])
       fi
     fi
   fi
--- a/make/autoconf/basics_windows.m4	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/autoconf/basics_windows.m4	Tue Apr 09 11:48:54 2019 +0100
@@ -551,7 +551,7 @@
     $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin
     cd $FIXPATH_DIR
     $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1
-    cd $CURDIR
+    cd $CONFIGURE_START_DIR
 
     if test ! -x $FIXPATH_BIN; then
       AC_MSG_RESULT([no])
@@ -574,7 +574,7 @@
     cd $FIXPATH_DIR
     $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \
         > $FIXPATH_DIR/fixpath2.log 2>&1
-    cd $CURDIR
+    cd $CONFIGURE_START_DIR
     if test ! -x $FIXPATH_DIR/fixpath2.exe; then
       AC_MSG_RESULT([no])
       cat $FIXPATH_DIR/fixpath2.log
--- a/make/autoconf/flags-other.m4	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/autoconf/flags-other.m4	Tue Apr 09 11:48:54 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
@@ -81,10 +81,10 @@
     RC_FLAGS="$RC_FLAGS \
         -D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
         -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
-        -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
+        -D\"JDK_COMPONENT=\$(JDK_RC_NAME) binary\" \
         -D\"JDK_VER=\$(VERSION_NUMBER)\" \
         -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
-        -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_FEATURE)\" \
+        -D\"JDK_NAME=\$(JDK_RC_NAME) \$(VERSION_FEATURE)\" \
         -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
 
     JVM_RCFLAGS="$JVM_RCFLAGS \
--- a/make/autoconf/jdk-version.m4	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/autoconf/jdk-version.m4	Tue Apr 09 11:48:54 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
@@ -69,6 +69,23 @@
   AC_SUBST(MACOSX_BUNDLE_NAME_BASE)
   AC_SUBST(MACOSX_BUNDLE_ID_BASE)
 
+  # Set the JDK RC name
+  AC_ARG_WITH(jdk-rc-name, [AS_HELP_STRING([--with-jdk-rc-name],
+      [Set JDK RC name. This is used for FileDescription and ProductName properties
+       of MS Windows binaries. @<:@not specified@:>@])])
+  if test "x$with_jdk_rc_name" = xyes; then
+    AC_MSG_ERROR([--with-jdk-rc-name must have a value])
+  elif [ ! [[ $with_jdk_rc_name =~ ^[[:print:]]*$ ]] ]; then
+    AC_MSG_ERROR([--with-jdk-rc-name contains non-printing characters: $with_jdk_rc_name])
+  elif test "x$with_jdk_rc_name" != x; then
+    # Set JDK_RC_NAME to a custom value if '--with-jdk-rc-name' was used and is not empty.
+    JDK_RC_NAME="$with_jdk_rc_name"
+  else
+    # Otherwise calculate from "version-numbers" included above.
+    JDK_RC_NAME="$PRODUCT_NAME $JDK_RC_PLATFORM_NAME"
+  fi
+  AC_SUBST(JDK_RC_NAME)
+
   # The vendor name, if any
   AC_ARG_WITH(vendor-name, [AS_HELP_STRING([--with-vendor-name],
       [Set vendor name. Among others, used to set the 'java.vendor'
@@ -460,6 +477,7 @@
   # We could define --with flags for these, if really needed
   VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR"
   VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR"
+  JDK_SOURCE_TARGET_VERSION="$DEFAULT_JDK_SOURCE_TARGET_VERSION"
 
   AC_MSG_CHECKING([for version string])
   AC_MSG_RESULT([$VERSION_STRING])
@@ -483,5 +501,5 @@
   AC_SUBST(VENDOR_VERSION_STRING)
   AC_SUBST(VERSION_CLASSFILE_MAJOR)
   AC_SUBST(VERSION_CLASSFILE_MINOR)
-
+  AC_SUBST(JDK_SOURCE_TARGET_VERSION)
 ])
--- a/make/autoconf/spec.gmk.in	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/autoconf/spec.gmk.in	Tue Apr 09 11:48:54 2019 +0100
@@ -32,6 +32,8 @@
 
 # The command line given to configure.
 CONFIGURE_COMMAND_LINE:=@CONFIGURE_COMMAND_LINE@
+# The current directory when configure was run
+CONFIGURE_START_DIR:=@CONFIGURE_START_DIR@
 
 # A self-referential reference to this file.
 SPEC:=@SPEC@
@@ -139,7 +141,6 @@
 # The top-level directory of the source repository
 TOPDIR:=@TOPDIR@
 
-
 IMPORT_MODULES_CLASSES:=@IMPORT_MODULES_CLASSES@
 IMPORT_MODULES_CMDS:=@IMPORT_MODULES_CMDS@
 IMPORT_MODULES_LIBS:=@IMPORT_MODULES_LIBS@
@@ -156,6 +157,7 @@
 PRODUCT_NAME:=@PRODUCT_NAME@
 PRODUCT_SUFFIX:=@PRODUCT_SUFFIX@
 JDK_RC_PLATFORM_NAME:=@JDK_RC_PLATFORM_NAME@
+JDK_RC_NAME:=@JDK_RC_NAME@
 COMPANY_NAME:=@COMPANY_NAME@
 HOTSPOT_VM_DISTRO:=@HOTSPOT_VM_DISTRO@
 MACOSX_BUNDLE_NAME_BASE=@MACOSX_BUNDLE_NAME_BASE@
@@ -208,6 +210,8 @@
 VERSION_CLASSFILE_MAJOR := @VERSION_CLASSFILE_MAJOR@
 VERSION_CLASSFILE_MINOR := @VERSION_CLASSFILE_MINOR@
 
+JDK_SOURCE_TARGET_VERSION := @JDK_SOURCE_TARGET_VERSION@
+
 # Convenience CFLAGS settings for passing version information into native programs.
 VERSION_CFLAGS := \
     -DVERSION_FEATURE=$(VERSION_FEATURE) \
@@ -904,6 +908,7 @@
   JDK_BUNDLE_EXTENSION := tar.gz
 endif
 JDK_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART).$(JDK_BUNDLE_EXTENSION)
+JRE_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART).$(JDK_BUNDLE_EXTENSION)
 JDK_SYMBOLS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
 TEST_DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests-demos$(DEBUG_PART).tar.gz
 TEST_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests$(DEBUG_PART).tar.gz
@@ -911,6 +916,7 @@
 JCOV_BUNDLE_NAME := jdk-jcov-$(BASE_NAME)_bin$(DEBUG_PART).$(JDK_BUNDLE_EXTENSION)
 
 JDK_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_BUNDLE_NAME)
+JRE_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(JRE_BUNDLE_NAME)
 JDK_SYMBOLS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(JDK_SYMBOLS_BUNDLE_NAME)
 TEST_DEMOS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(TEST_DEMOS_BUNDLE_NAME)
 TEST_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(TEST_BUNDLE_NAME)
--- a/make/autoconf/toolchain_windows.m4	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/autoconf/toolchain_windows.m4	Tue Apr 09 11:48:54 2019 +0100
@@ -472,7 +472,7 @@
       # Change directory so we don't need to mess with Windows paths in redirects.
       cd $VS_ENV_TMP_DIR
       $CMD /c extract-vs-env.bat | $CAT
-      cd $CURDIR
+      cd $CONFIGURE_START_DIR
 
       if test ! -s $VS_ENV_TMP_DIR/set-vs-env.sh; then
         AC_MSG_NOTICE([Could not succesfully extract the environment variables needed for the VS setup.])
--- a/make/autoconf/version-numbers	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/autoconf/version-numbers	Tue Apr 09 11:48:54 2019 +0100
@@ -36,6 +36,7 @@
 DEFAULT_VERSION_CLASSFILE_MAJOR=57  # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
 DEFAULT_VERSION_CLASSFILE_MINOR=0
 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="12 13"
+DEFAULT_JDK_SOURCE_TARGET_VERSION=13
 
 LAUNCHER_NAME=openjdk
 PRODUCT_NAME=OpenJDK
--- a/make/common/FindTests.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/FindTests.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -26,6 +26,16 @@
 ifndef _FIND_TESTS_GMK
 _FIND_TESTS_GMK := 1
 
+# This makefile can be called directly to just trigger generation of the cache
+# makefile. If so, SPEC and MakeBase.gmk need to be included.
+ifeq ($(FINDTESTS_STAND_ALONE), true)
+  include $(SPEC)
+  include MakeBase.gmk
+endif
+
+# Make sure this variable is not lazy evaled.
+ALL_NAMED_TESTS :=
+
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, common/FindTests.gmk))
 
@@ -35,31 +45,40 @@
 # JTREG_TESTROOTS might have been set by a custom extension
 JTREG_TESTROOTS += $(addprefix $(TOPDIR)/test/, hotspot/jtreg jdk langtools nashorn jaxp)
 
-################################################################################
-# Find the Jtreg test groups for the given component.
-#
-# Parameter 1 is the jtreg root dir. This name is used as variable prefix.
-#
-# After this macro has been evaluated, the following variables are defined for
-# the component:
-#   JTREG_TESTROOT - The path to the root of the test directory
-#   JTREG_GROUP_FILES - The file(s) containing the group definitions
-#   JTREG_TEST_GROUPS - The name of the test groups that the component defines
+# Extract the names of the Jtreg group files from the TEST.ROOT files. The
+# TEST.ROOT files being properties files can be interpreted as makefiles so
+# use include to get at the contents instead of expensive shell calls. We are
+# looking for the "groups" property in each file.
+JTREG_ROOT_FILES := $(addsuffix /TEST.ROOT, $(JTREG_TESTROOTS))
+JTREG_GROUP_FILES :=
+$(foreach root, $(JTREG_TESTROOTS), \
+  $(eval include $(root)/TEST.ROOT) \
+  $(eval $(root)_JTREG_GROUP_FILES := $$(addprefix $(root)/, $$(groups))) \
+  $(eval JTREG_GROUP_FILES += $$($(root)_JTREG_GROUP_FILES)) \
+)
+
+# Cache the expensive to calculate test names in a generated makefile.
+FIND_TESTS_CACHE_FILE := $(MAKESUPPORT_OUTPUTDIR)/find-tests.gmk
+
+# If this file is deemed outdated, it will automatically get regenerated
+# by this rule before being included below.
 #
-FindJtregGroups = $(NamedParamsMacroTemplate)
-define FindJtregGroupsBody
-  ifneq ($$(wildcard $1), )
-    $1_JTREG_GROUP_FILENAMES := $$(shell $$(SED) -n -e 's/\[\(.*\)\]/\1/g' \
-        -e 's/^groups\w*=//p' $1/TEST.ROOT)
-    $1_JTREG_GROUP_FILES := $$(addprefix $1/, $$($1_JTREG_GROUP_FILENAMES))
-    $1_JTREG_TEST_GROUPS := $$(strip $$(shell $$(SED) -n \
-        -e 's/\([^ ]*\)\w*=.*/\1/gp' $$(wildcard $$($1_JTREG_GROUP_FILES)) \
-        | $$(SORT) -u))
-  endif
-endef
+# When calling TestMake.gmk, override the log level to avoid any kind of debug
+# output being captured into the generated makefile.
+$(FIND_TESTS_CACHE_FILE): $(JTREG_ROOT_FILES) $(JTREG_GROUP_FILES)
+	$(call MakeTargetDir)
+	( $(foreach root, $(JTREG_TESTROOTS), \
+	    $(PRINTF) "\n$(root)_JTREG_TEST_GROUPS := " ; \
+	    $(SED) -n -e 's/^\#.*//g' -e 's/\([^ ]*\)\w*=.*/\1/gp' \
+	      $($(root)_JTREG_GROUP_FILES) \
+	      | $(SORT) -u | $(TR) '\n' ' ' ; \
+	  ) \
+	  $(PRINTF) "\nMAKE_TEST_TARGETS := " ; \
+	  $(MAKE) -s --no-print-directory $(MAKE_ARGS) LOG_LEVEL=warn \
+	      SPEC=$(SPEC) -f $(TOPDIR)/test/make/TestMake.gmk print-targets \
+	) > $@
 
-# Configure definitions for all available test components
-$(foreach root, $(JTREG_TESTROOTS), $(eval $(call FindJtregGroups, $(root))))
+-include $(FIND_TESTS_CACHE_FILE)
 
 # Create a list of all available Jtreg test groups in all components
 JTREG_TEST_GROUPS += $(sort $(foreach root, $(JTREG_TESTROOTS), \
@@ -69,18 +88,15 @@
 # ALL_NAMED_TESTS might have been set by a custom extension
 ALL_NAMED_TESTS += $(JTREG_TEST_GROUPS)
 
+# Add the make test targets
+ALL_NAMED_TESTS += $(addprefix make-, $(MAKE_TEST_TARGETS))
+
 # Add Gtest
 ALL_NAMED_TESTS += gtest
 
 # Add microbenchmarks
 ALL_NAMED_TESTS += micro
 
-# Find make test targets
-MAKE_TEST_TARGETS := $(shell $(MAKE) -s --no-print-directory $(MAKE_ARGS) \
-    SPEC=$(SPEC) -f $(TOPDIR)/test/make/TestMake.gmk print-targets)
-
-ALL_NAMED_TESTS += $(addprefix make-, $(MAKE_TEST_TARGETS))
-
 # Add special tests
 ALL_NAMED_TESTS += failure-handler make
 
--- a/make/common/JarArchive.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/JarArchive.gmk	Tue Apr 09 11:48:54 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
@@ -124,9 +124,9 @@
   ifeq ($$($1_DEPENDENCIES), )
     # Add all source roots to the find cache since we are likely going to run find
     # on these more than once. The cache will only be updated if necessary.
-    $$(eval $$(call FillCacheFind, $$($1_FIND_LIST)))
+    $$(call FillFindCache, $$($1_FIND_LIST))
     $1_DEPENDENCIES:=$$(filter $$(addprefix %,$$($1_SUFFIXES)), \
-        $$(call CacheFind,$$($1_SRCS)))
+        $$(call FindFiles,$$($1_SRCS)))
     ifneq (,$$($1_GREP_INCLUDE_PATTERNS))
       $1_DEPENDENCIES:=$$(filter $$(addsuffix %,$$($1_GREP_INCLUDE_PATTERNS)),$$($1_DEPENDENCIES))
     endif
@@ -137,7 +137,7 @@
     $1_DEPENDENCIES+=$$(wildcard $$(foreach src, $$($1_SRCS), \
         $$(addprefix $$(src)/, $$($1_EXTRA_FILES))) $$($1_EXTRA_FILES))
     ifeq (,$$($1_SKIP_METAINF))
-      $1_DEPENDENCIES+=$$(call CacheFind,$$(wildcard $$(addsuffix /META-INF,$$($1_SRCS))))
+      $1_DEPENDENCIES+=$$(call FindFiles,$$(wildcard $$(addsuffix /META-INF,$$($1_SRCS))))
     endif
   endif
   # The dependency list should never be empty
--- a/make/common/JavaCompilation.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/JavaCompilation.gmk	Tue Apr 09 11:48:54 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
@@ -222,13 +222,12 @@
     ) \
   )
   $$(call MakeDir,$$($1_BIN))
-  # Add all source roots to the find cache since we are likely going to run find
-  # on these more than once. The cache will only be updated if necessary.
-  $$(eval $$(call FillCacheFind, $$($1_SRC)))
-  # Find all files in the source trees. Preserve order of source roots so that
-  # the first version in case of multiple instances of the same file is selected.
-  # CacheFind does not preserve order so need to call it for each root.
-  $1_ALL_SRCS += $$($1_EXTRA_FILES) $$(foreach s, $$($1_SRC), $$(call CacheFind, $$s))
+  # Order src files according to the order of the src dirs. Correct odering is
+  # needed for correct overriding between different source roots.
+  $1_ALL_SRC_RAW := $$(call FindFiles, $$($1_SRC))
+  $1_ALL_SRCS := $$($1_EXTRA_FILES) \
+      $$(foreach d, $$($1_SRC), $$(filter $$d%, $$($1_ALL_SRC_RAW)))
+
   # Extract the java files.
   $1_SRCS := $$(filter %.java, $$($1_ALL_SRCS))
 
--- a/make/common/MakeBase.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/MakeBase.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -64,10 +64,12 @@
 
 endef
 
-# In GNU Make 4.0 and higher, there is a file function for writing to files.
+# Certain features only work in newer version of GNU Make. The build will still
+# function in 3.81, but will be less performant.
 ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION))))
   HAS_FILE_FUNCTION := true
   CORRECT_FUNCTION_IN_RECIPE_EVALUATION := true
+  RWILDCARD_WORKS := true
 endif
 
 
@@ -341,74 +343,116 @@
 
 ################################################################################
 
-ifneq ($(DISABLE_CACHE_FIND), true)
-  # In Cygwin, finds are very costly, both because of expensive forks and because
-  # of bad file system caching. Find is used extensively in $(shell) commands to
-  # find source files. This makes rerunning make with no or few changes rather
-  # expensive. To speed this up, these two macros are used to cache the results
-  # of simple find commands for reuse.
-  #
-  # Runs a find and stores both the directories where it was run and the results.
-  # This macro can be called multiple times to add to the cache. Only finds files
-  # with no filters.
-  #
-  # Files containing space will get spaces replaced with ? because GNU Make
-  # cannot handle lists of files with space in them. By using ?, make will match
-  # the wildcard to space in many situations so we don't need to replace back
-  # to space on every use. While not a complete solution it does allow some uses
-  # of CacheFind to function with spaces in file names, including for
-  # SetupCopyFiles.
-  #
-  # Needs to be called with $(eval )
-  #
-  # Even if the performance benifit is negligible on other platforms, keep the
-  # functionality active unless explicitly disabled to exercise it more.
-  #
-  # Initialize FIND_CACHE_DIRS with := to make it a non recursively-expanded variable
-  FIND_CACHE_DIRS :=
-  # Param 1 - Dirs to find in
-  # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
-  define FillCacheFind
-    # Filter out already cached dirs. The - is needed when FIND_CACHE_DIRS is empty
-    # since filter out will then return empty.
-    FIND_CACHE_NEW_DIRS := $$(filter-out $$(addsuffix /%,\
-        - $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS), $1)
-    ifneq ($$(FIND_CACHE_NEW_DIRS), )
-      # Remove any trailing slash from dirs in the cache dir list
-      FIND_CACHE_DIRS += $$(patsubst %/,%, $$(FIND_CACHE_NEW_DIRS))
-      FIND_CACHE := $$(sort $$(FIND_CACHE) \
-          $$(shell $(FIND) $$(wildcard $$(FIND_CACHE_NEW_DIRS)) \
-              \( -type f -o -type l \) $2 | $(TR) ' ' '?'))
-    endif
-  endef
+# Recursive wildcard function. Walks down directories recursively and matches
+# files with the search patterns. Patterns use standard file wildcards (* and
+# ?).
+#
+# $1 - Directories to start search in
+# $2 - Search patterns
+rwildcard = \
+    $(strip \
+        $(foreach d, \
+          $(patsubst %/,%,$(sort $(dir $(wildcard $(addsuffix /*/*, $(strip $1)))))), \
+          $(call rwildcard,$d,$2) \
+        ) \
+        $(call DoubleDollar, $(wildcard $(foreach p, $2, $(addsuffix /$(strip $p), $(strip $1))))) \
+    )
+
+# Find non directories using recursive wildcard function. This function may
+# be used directly when a small amount of directories is expected to be
+# searched and caching is not expected to be of use.
+#
+# $1 - Directory to start search in
+# $2 - Optional search patterns, defaults to '*'.
+WildcardFindFiles = \
+    $(sort $(strip \
+        $(eval WildcardFindFiles_result := $(call rwildcard,$(patsubst %/,%,$1),$(if $(strip $2),$2,*))) \
+        $(filter-out $(patsubst %/,%,$(sort $(dir $(WildcardFindFiles_result)))), \
+            $(WildcardFindFiles_result) \
+        ) \
+    ))
+
+# Find non directories using the find utility in the shell. Safe to call for
+# non existing directories, or directories containing wildcards.
+#
+# Files containing space will get spaces replaced with ? because GNU Make
+# cannot handle lists of files with space in them. By using ?, make will match
+# the wildcard to space in many situations so we don't need to replace back
+# to space on every use. While not a complete solution it does allow some uses
+# of FindFiles to function with spaces in file names, including for
+# SetupCopyFiles. Unfortunately this does not work for WildcardFindFiles so
+# if files with spaces are anticipated, use ShellFindFiles directly.
+#
+# $1 - Directories to start search in.
+# $2 - Optional search patterns, empty means find everything. Patterns use
+#      standard file wildcards (* and ?) and should not be quoted.
+# $3 - Optional options to find.
+ShellFindFiles = \
+    $(if $(wildcard $1), \
+      $(sort \
+          $(shell $(FIND) $3 $(patsubst %/,%,$(wildcard $1)) \( -type f -o -type l \) \
+              $(if $(strip $2), -a \( -name "$(firstword $2)" \
+              $(foreach p, $(filter-out $(firstword $2), $2), -o -name "$(p)") \)) \
+              | $(TR) ' ' '?' \
+          ) \
+      ) \
+    )
 
-  # Mimics find by looking in the cache if all of the directories have been cached.
-  # Otherwise reverts to shell find. This is safe to call on all platforms, even if
-  # cache is deactivated.
-  #
-  # $1 can be either a directory or a file. If it's a directory, make
-  # sure we have exactly one trailing slash before the wildcard.
-  # The extra - is needed when FIND_CACHE_DIRS is empty but should be harmless.
-  #
-  # Param 1 - Dirs to find in
-  # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
-  # Param 3 - (optional) options to find.
-  define CacheFind
-    $(if $(filter-out $(addsuffix /%,- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS),$1), \
-      $(if $(wildcard $1), $(shell $(FIND) $3 $(wildcard $1) \( -type f -o -type l \) $2 \
-          | $(TR) ' ' '?')), \
-      $(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(FIND_CACHE)))
-  endef
+# Find non directories using the method most likely to work best for the
+# current build host
+#
+# $1 - Directory to start search in
+# $2 - Optional search patterns, defaults to '*'.
+ifeq ($(OPENJDK_BUILD_OS)-$(RWILDCARD_WORKS), windows-true)
+  DirectFindFiles = $(WildcardFindFiles)
+else
+  DirectFindFiles = $(ShellFindFiles)
+endif
 
+# Finds files using a cache that is populated by FillFindCache below. If any of
+# the directories given have not been cached, DirectFindFiles is used for
+# everything. Caching is especially useful in Cygwin, where file finds are very
+# costly.
+#
+# $1 - Directories to start search in.
+# $2 - Optional search patterns. If used, no caching is done.
+CacheFindFiles_CACHED_DIRS :=
+CacheFindFiles_CACHED_FILES :=
+CacheFindFiles = \
+    $(if $2, \
+      $(call DirectFindFiles, $1, $2) \
+    , \
+      $(if $(filter-out $(addsuffix /%, $(CacheFindFiles_CACHED_DIRS)) \
+          $(CacheFindFiles_CACHED_DIRS), $1), \
+        $(call DirectFindFiles, $1) \
+      , \
+        $(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(CacheFindFiles_CACHED_FILES)) \
+      ) \
+    )
+
+# Explicitly adds files to the find cache used by CacheFindFiles.
+#
+# $1 - Directories to start search in
+FillFindCache = \
+    $(eval CacheFindFiles_NEW_DIRS := $$(filter-out $$(addsuffix /%,\
+        $$(CacheFindFiles_CACHED_DIRS)) $$(CacheFindFiles_CACHED_DIRS), $1)) \
+    $(if $(CacheFindFiles_NEW_DIRS), \
+      $(eval CacheFindFiles_CACHED_DIRS += $$(patsubst %/,%,$$(CacheFindFiles_NEW_DIRS))) \
+      $(eval CacheFindFiles_CACHED_FILES := $$(sort $$(CacheFindFiles_CACHED_FILES) \
+          $$(call DirectFindFiles, $$(CacheFindFiles_NEW_DIRS)))) \
+    )
+
+# Findfiles is the default macro that should be used to find files in the file
+# system. This function does not always support files with spaces in the names.
+# If files with spaces are anticipated, use ShellFindFiles directly.
+#
+# $1 - Directories to start search in.
+# $2 - Optional search patterns, empty means find everything. Patterns use
+#      standard file wildcards (* and ?) and should not be quoted.
+ifeq ($(DISABLE_CACHE_FIND), true)
+  FindFiles = $(DirectFindFiles)
 else
-  # If CacheFind is disabled, just run the find command.
-  # Param 1 - Dirs to find in
-  # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
-  define CacheFind
-    $(if $(wildcard $1, \
-      $(shell $(FIND) $(wildcard $1) \( -type f -o -type l \) $2 | $(TR) ' ' '?') \
-    )
-  endef
+  FindFiles = $(CacheFindFiles)
 endif
 
 ################################################################################
--- a/make/common/NativeCompilation.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/NativeCompilation.gmk	Tue Apr 09 11:48:54 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
@@ -231,8 +231,8 @@
 
   # Only continue if this object file hasn't been processed already. This lets
   # the first found source file override any other with the same name.
-  ifeq ($$(findstring $$($1_OBJ), $$($$($1_BASE)_OBJS_SO_FAR)), )
-    $$($1_BASE)_OBJS_SO_FAR += $$($1_OBJ)
+  ifeq ($$($1_OBJ_PROCESSED), )
+    $1_OBJ_PROCESSED := true
     # This is the definite source file to use for $1_FILENAME.
     $1_SRC_FILE := $$($1_FILE)
 
@@ -308,14 +308,18 @@
 
     ifeq ($$(filter %.s %.S, $$($1_FILENAME)), )
       # And this is the dependency file for this obj file.
-      $1_DEP := $$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_OBJ))
+      $1_DEPS_FILE := $$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_OBJ))
       # The dependency target file lists all dependencies as empty targets to
       # avoid make error "No rule to make target" for removed files
-      $1_DEP_TARGETS := $$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_OBJ))
+      $1_DEPS_TARGETS_FILE := $$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_OBJ))
 
-      # Include previously generated dependency information. (if it exists)
-      -include $$($1_DEP)
-      -include $$($1_DEP_TARGETS)
+      # Only try to load individual dependency information files if the global
+      # file hasn't been loaded (could happen if make was interrupted).
+      ifneq ($$($$($1_BASE)_DEPS_FILE_LOADED), true)
+        # Include previously generated dependency information. (if it exists)
+        -include $$($1_DEPS_FILE)
+        -include $$($1_DEPS_TARGETS_FILE)
+      endif
     endif
 
     ifneq ($$(strip $$($1_CFLAGS) $$($1_CXXFLAGS) $$($1_OPTIMIZATION)), )
@@ -340,16 +344,16 @@
             # object file in the generated deps files. Fixing it with sed. If
             # compiling assembly, don't try this.
 	    $$(call ExecuteWithLog, $$@, \
-	        $$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEP).tmp $$($1_COMPILE_OPTIONS))
-	    $(SED) 's|^$$(@F):|$$@:|' $$($1_DEP).tmp > $$($1_DEP)
+	        $$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEPS_FILE).tmp $$($1_COMPILE_OPTIONS))
+	    $(SED) 's|^$$(@F):|$$@:|' $$($1_DEPS_FILE).tmp > $$($1_DEPS_FILE)
           else
 	    $$(call ExecuteWithLog, $$@, \
-	        $$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEP) $$($1_COMPILE_OPTIONS))
+	        $$($1_COMPILER) $$($1_DEP_FLAG) $$($1_DEPS_FILE) $$($1_COMPILE_OPTIONS))
           endif
           # Create a dependency target file from the dependency file.
           # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
-          ifneq ($$($1_DEP), )
-	    $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEP) > $$($1_DEP_TARGETS)
+          ifneq ($$($1_DEPS_FILE), )
+	    $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEPS_FILE) > $$($1_DEPS_TARGETS_FILE)
           endif
         else
           # The Visual Studio compiler lacks a feature for generating make
@@ -363,10 +367,10 @@
 	      $$($1_COMPILER) -showIncludes $$($1_COMPILE_OPTIONS)) \
 	      | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \
 	          -e "^$$($1_FILENAME)$$$$" || test "$$$$?" = "1" ; \
-	  $(ECHO) $$@: \\ > $$($1_DEP) ; \
+	  $(ECHO) $$@: \\ > $$($1_DEPS_FILE) ; \
 	  $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_OBJ).log \
-	      | $(SORT) -u >> $$($1_DEP) ; \
-	  $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEP) > $$($1_DEP_TARGETS)
+	      | $(SORT) -u >> $$($1_DEPS_FILE) ; \
+	  $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_DEPS_FILE) > $$($1_DEPS_TARGETS_FILE)
         endif
   endif
 endef
@@ -486,6 +490,9 @@
   $1_NOSUFFIX := $$($1_PREFIX)$$($1_NAME)
   $1_SAFE_NAME := $$(strip $$(subst /,_, $1))
 
+# Need to make sure TARGET is first on list
+  $1 := $$($1_TARGET)
+
   # Setup the toolchain to be used
   $$(call SetIfEmpty, $1_TOOLCHAIN, TOOLCHAIN_DEFAULT)
   $$(call SetIfEmpty, $1_CC, $$($$($1_TOOLCHAIN)_CC))
@@ -505,7 +512,7 @@
   $$(foreach d, $$($1_SRC), $$(if $$(wildcard $$d), , \
       $$(error SRC specified to SetupNativeCompilation $1 contains missing directory $$d)))
 
-  $1_SRCS_RAW = $$(call CacheFind, $$($1_SRC))
+  $1_SRCS_RAW := $$(call FindFiles, $$($1_SRC))
   # Order src files according to the order of the src dirs
   $1_SRCS := $$(foreach d, $$($1_SRC), $$(filter $$d%, $$($1_SRCS_RAW)))
   $1_SRCS := $$(filter $$(NATIVE_SOURCE_EXTENSIONS), $$($1_SRCS))
@@ -719,20 +726,21 @@
           $1_PCH_FILE := $$($1_OBJECT_DIR)/precompiled/$$(notdir $$($1_PRECOMPILED_HEADER)).pch
           $1_USE_PCH_FLAGS := -include-pch $$($1_PCH_FILE)
         endif
-        $1_PCH_DEP := $$($1_PCH_FILE).d
-        $1_PCH_DEP_TARGETS := $$($1_PCH_FILE).d.targets
+        $1_PCH_DEPS_FILE := $$($1_PCH_FILE).d
+        $1_PCH_DEPS_TARGETS_FILE := $$($1_PCH_FILE).d.targets
 
-        -include $$($1_PCH_DEP)
-        -include $$($1_PCH_DEP_TARGETS)
+        -include $$($1_PCH_DEPS_FILE)
+        -include $$($1_PCH_DEPS_TARGETS_FILE)
 
         $1_PCH_COMMAND := $$($1_CC) $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $$($1_SYSROOT_CFLAGS) \
-            $$($1_OPT_CFLAGS) -x c++-header -c $(C_FLAG_DEPS) $$($1_PCH_DEP)
+            $$($1_OPT_CFLAGS) -x c++-header -c $(C_FLAG_DEPS) $$($1_PCH_DEPS_FILE)
 
         $$($1_PCH_FILE): $$($1_PRECOMPILED_HEADER) $$($1_COMPILE_VARDEPS_FILE)
 		$$(call LogInfo, Generating precompiled header)
 		$$(call MakeDir, $$(@D))
 		$$(call ExecuteWithLog, $$@, $$($1_PCH_COMMAND) $$< -o $$@)
-		$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_PCH_DEP) > $$($1_PCH_DEP_TARGETS)
+		$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_PCH_DEPS_FILE) \
+		    > $$($1_PCH_DEPS_TARGETS_FILE)
 
         $$($1_ALL_OBJS): $$($1_PCH_FILE)
 
@@ -748,6 +756,34 @@
     endif
   endif
 
+  # Create a rule to collect all the individual make dependency files into a
+  # single makefile.
+  $1_DEPS_FILE := $$($1_OBJECT_DIR)/$1.d
+
+  $$($1_DEPS_FILE): $$($1_ALL_OBJS)
+	$(RM) $$@
+        # CD into dir to reduce risk of hitting command length limits, which
+        # could otherwise happen if TOPDIR is a very long path.
+	$(CD) $$($1_OBJECT_DIR) && $(CAT) *.d > $$@.tmp
+	$(CD) $$($1_OBJECT_DIR) && $(CAT) *.d.targets | $(SORT) -u >> $$@.tmp
+        # After generating the file, which happens after all objects have been
+        # compiled, copy it to .old extension. On the next make invocation, this
+        # .old file will be included by make.
+	$(CP) $$@.tmp $$@.old
+	$(MV) $$@.tmp $$@
+
+  $1 += $$($1_DEPS_FILE)
+
+  # The include must be on the .old file, which represents the state from the
+  # previous invocation of make. The file being included must not have a rule
+  # defined for it as otherwise make will think it has to run the rule before
+  # being able to include the file, which would be wrong since we specifically
+  # need the file as it was generated by a previous make invocation.
+  ifneq ($$(wildcard $$($1_DEPS_FILE).old), )
+    $1_DEPS_FILE_LOADED := true
+    -include $$($1_DEPS_FILE).old
+  endif
+
   # Now call SetupCompileNativeFile for each source file we are going to compile.
   $$(foreach file, $$($1_SRCS), \
       $$(eval $$(call SetupCompileNativeFile, $1_$$(notdir $$(file)),\
@@ -774,10 +810,10 @@
   ifeq ($(call isTargetOs, windows), true)
     ifneq ($$($1_VERSIONINFO_RESOURCE), )
       $1_RES := $$($1_OBJECT_DIR)/$$($1_BASENAME).res
-      $1_RES_DEP := $$($1_RES).d
-      $1_RES_DEP_TARGETS := $$($1_RES).d.targets
-      -include $$($1_RES_DEP)
-      -include $$($1_RES_DEP_TARGETS)
+      $1_RES_DEPS_FILE := $$($1_RES).d
+      $1_RES_DEPS_TARGETS_FILE := $$($1_RES).d.targets
+      -include $$($1_RES_DEPS_FILE)
+      -include $$($1_RES_DEPS_TARGETS_FILE)
 
       $1_RES_VARDEPS := $$($1_RC) $$($1_RC_FLAGS)
       $1_RES_VARDEPS_FILE := $$(call DependOnVariable, $1_RES_VARDEPS, \
@@ -794,16 +830,18 @@
                 # For some unknown reason, in this case CL actually outputs the show
                 # includes to stderr so need to redirect it to hide the output from the
                 # main log.
-		$$(call ExecuteWithLog, $$($1_RES_DEP).obj, \
+		$$(call ExecuteWithLog, $$($1_RES_DEPS_FILE).obj, \
 		    $$($1_CC) $$(filter-out -l%, $$($1_RC_FLAGS)) \
 		        $$($1_SYSROOT_CFLAGS) -showIncludes -nologo -TC \
-		        $(CC_OUT_OPTION)$$($1_RES_DEP).obj -P -Fi$$($1_RES_DEP).pp \
+		        $(CC_OUT_OPTION)$$($1_RES_DEPS_FILE).obj -P -Fi$$($1_RES_DEPS_FILE).pp \
 		        $$($1_VERSIONINFO_RESOURCE)) 2>&1 \
 		    | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \
 		        -e "^$$(notdir $$($1_VERSIONINFO_RESOURCE))$$$$" || test "$$$$?" = "1" ; \
-		$(ECHO) $$($1_RES): \\ > $$($1_RES_DEP) ; \
-		$(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).obj.log >> $$($1_RES_DEP) ; \
-		$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEP) > $$($1_RES_DEP_TARGETS)
+		$(ECHO) $$($1_RES): \\ > $$($1_RES_DEPS_FILE) ; \
+		$(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEPS_FILE).obj.log \
+		    >> $$($1_RES_DEPS_FILE) ; \
+		$(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEPS_FILE) \
+		    > $$($1_RES_DEPS_TARGETS_FILE)
     endif
   endif
 
@@ -830,9 +868,6 @@
     $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
   endif
 
-  # Need to make sure TARGET is first on list
-  $1 := $$($1_TARGET)
-
   ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
     $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
   endif
--- a/make/common/RMICompilation.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/RMICompilation.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -35,6 +35,7 @@
 #   RUN_V11:=Set to run rmic with -v1.1
 #   RUN_V12:=Set to run rmic with -v1.2
 #   KEEP_GENERATED:=Set to keep generated sources around
+#   STUB_SOURCES_DIR:=Directory to put generated sources in
 SetupRMICompilation = $(NamedParamsMacroTemplate)
 define SetupRMICompilationBody
 
@@ -58,9 +59,16 @@
   $1_TIE_FILES := $$(addprefix $$($1_STUB_CLASSES_DIR)/org/omg/stub/,$$(addsuffix _Tie.class,$$($1_TIE_BASE_FILES)))
   $1_TIE_STDPKG_FILES := $$(addprefix $$($1_STUB_CLASSES_DIR)/,$$(addsuffix _Tie.class,$$($1_TIE_BASE_FILES)))
 
-  ifneq (,$$($1_KEEP_GENERATED))
+  ifneq ($$($1_KEEP_GENERATED), )
     $1_ARGS += -keepgenerated
-    $1_TARGETS += $$(subst .class,.java,$$($1_TARGETS))
+    $1_JAVA_TARGETS := $$(subst .class,.java,$$($1_TARGETS))
+    ifneq ($$($1_STUB_SOURCES_DIR), )
+      # This is where the java files are created by rmic
+      $1_JAVA_TARGETS_REL := $$(subst $$($1_STUB_CLASSES_DIR),, $$($1_JAVA_TARGETS))
+      # This is where the caller wants the java files
+      $1_JAVA_TARGETS := $$(addprefix $$($1_STUB_SOURCES_DIR), $$($1_JAVA_TARGETS_REL))
+    endif
+    $1_TARGETS += $$($1_JAVA_TARGETS)
   endif
 
   $1_DOLLAR_SAFE_CLASSES := $$(subst $$$$,\$$$$,$$($1_CLASSES))
@@ -72,11 +80,12 @@
 	$$(call MakeDir, $$($1_STUB_CLASSES_DIR))
 	$(RMIC) $$($1_ARGS) -classpath "$$($1_CLASSES_DIR)" \
 	    -d $$($1_STUB_CLASSES_DIR) $$($1_DOLLAR_SAFE_CLASSES); \
-	if [ "x$$($1_ARGS2)" != "x" ]; then \
-	  $(ECHO) $(LOG_INFO) Running rmic $$($1_ARGS2) for $$($1_DOLLAR_SAFE_CLASSES) && \
-	  $(RMIC) $$($1_ARGS2) -classpath "$$($1_CLASSES_DIR)" \
-	      -d $$($1_STUB_CLASSES_DIR) $$($1_DOLLAR_SAFE_CLASSES); \
-	fi; \
+	$$(if $$($1_STUB_SOURCES_DIR), \
+	  $$(foreach f, $$($1_JAVA_TARGETS_REL), \
+	    $(MKDIR) -p $$(dir $$($1_STUB_SOURCES_DIR)/$$f) ; \
+	    $(MV) $$($1_STUB_CLASSES_DIR)/$$f $$($1_STUB_SOURCES_DIR)/$$f ; \
+	  ) \
+	) \
 	$(TOUCH) $$@
 
 
--- a/make/common/SetupJavaCompilers.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/SetupJavaCompilers.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -33,6 +33,9 @@
 
 DISABLE_WARNINGS ?= -Xlint:all,-deprecation,-removal,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally
 
+JDK_SOURCE_TARGET_FLAGS := -source $(JDK_SOURCE_TARGET_VERSION) \
+    -target $(JDK_SOURCE_TARGET_VERSION)
+
 # If warnings needs to be non-fatal for testing purposes use a command like:
 # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
 JAVAC_WARNINGS ?= -Xlint:all -Werror
@@ -72,7 +75,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 13 -target 13 --doclint-format html5 \
+    FLAGS := $(JDK_SOURCE_TARGET_FLAGS) --doclint-format html5 \
         -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
@@ -82,7 +85,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 13 -target 13 \
+    FLAGS := $(JDK_SOURCE_TARGET_FLAGS) \
         -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
--- a/make/common/TestFilesCompilation.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/TestFilesCompilation.gmk	Tue Apr 09 11:48:54 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
@@ -77,8 +77,7 @@
 
   # Locate all files with the matching prefix
   $1_FILE_LIST := \
-      $$(shell $$(FIND) $$($1_SOURCE_DIRS) -type f \( -name "$$($1_PREFIX)*.c" \
-          -o -name "$$($1_PREFIX)*.cpp" \))
+      $$(call FindFiles, $$($1_SOURCE_DIRS), $$($1_PREFIX)*.c $$($1_PREFIX)*.cpp)
 
   $1_EXCLUDE_PATTERN := $$(addprefix %/, $$($1_EXCLUDE))
   $1_FILTERED_FILE_LIST := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_FILE_LIST))
--- a/make/common/TextFileProcessing.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/TextFileProcessing.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -103,7 +103,7 @@
           $$(error SOURCE_DIRS contains directory $$(src) outside \
               SOURCE_BASE_DIR $$($1_SOURCE_BASE_DIR) (in $1))))
     endif
-    $1_SOURCE_FILES := $$(sort $$(call CacheFind,$$($1_SOURCE_DIRS)))
+    $1_SOURCE_FILES := $$(sort $$(call FindFiles,$$($1_SOURCE_DIRS)))
     $1_EXCLUDE_FILES:=$$(foreach i,$$($1_SOURCE_DIRS),$$(addprefix $$i/,$$($1_EXCLUDE_FILES)))
     $1_INCLUDE_FILES:=$$(foreach i,$$($1_SOURCE_DIRS),$$(addprefix $$i/,$$($1_INCLUDE_FILES)))
     $1_SOURCE_FILES := $$(filter-out $$($1_EXCLUDE_FILES),$$($1_SOURCE_FILES))
--- a/make/common/Utils.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/Utils.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -70,8 +70,8 @@
 
 ################################################################################
 # Replace question marks with space in string. This macro needs to be called on
-# files from CacheFind in case any of them contains space in their file name,
-# since CacheFind replaces space with ?.
+# files from FindFiles in case any of them contains space in their file name,
+# since FindFiles replaces space with ?.
 # Param 1 - String to replace in
 DecodeSpace = \
     $(subst ?,$(SPACE),$(strip $1))
--- a/make/common/ZipArchive.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/common/ZipArchive.gmk	Tue Apr 09 11:48:54 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
@@ -48,6 +48,8 @@
 #                           src dir
 #   SUFFIXES
 #   EXTRA_DEPS
+#   FOLLOW_SYMLINKS - Set to explicitly follow symlinks. Affects performance of
+#                     finding files.
 #   ZIP_OPTIONS extra options to pass to zip
 SetupZipArchive = $(NamedParamsMacroTemplate)
 define SetupZipArchiveBody
@@ -62,9 +64,14 @@
     $1_FIND_LIST := $$($1_SRC)
   endif
 
-  # Find all files in the source tree. Follow symlinks in this find since that is
-  # what zip does.
-  $1_ALL_SRCS := $$(call not-containing,_the.,$$(call CacheFind,$$($1_FIND_LIST), , -L))
+  # Find all files in the source tree.
+  # If asked to, follow symlinks in this find since that is what zip does. To do
+  # this, we need to call ShellFindFiles directly.
+  ifeq ($$($1_FOLLOW_SYMLINKS), true)
+    $1_ALL_SRCS := $$(call not-containing,_the.,$$(call ShellFindFiles,$$($1_FIND_LIST), , -L))
+  else
+    $1_ALL_SRCS := $$(call not-containing,_the.,$$(call FindFiles,$$($1_FIND_LIST)))
+  endif
 
   # Filter on suffixes if set
   ifneq ($$($1_SUFFIXES),)
--- a/make/conf/jib-profiles.js	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/conf/jib-profiles.js	Tue Apr 09 11:48:54 2019 +0100
@@ -755,7 +755,11 @@
             profiles[cmpBaselineName] = clone(profiles[name + suffix]);
             // Only compare the images target. This should pressumably be expanded
             // to include more build targets when possible.
-            profiles[cmpBaselineName].default_make_targets = [ "images" ];
+            profiles[cmpBaselineName].default_make_targets = [ "images", "test-image" ];
+            if (name == "linux-x64") {
+                profiles[cmpBaselineName].default_make_targets
+                    = concat(profiles[cmpBaselineName].default_make_targets, "docs");
+            }
             profiles[cmpBaselineName].make_args = [ "COMPARE_BUILD=CONF=" ];
             // Do not inherit artifact definitions from base profile
             delete profiles[cmpBaselineName].artifacts;
--- a/make/copy/CopyCommon.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/copy/CopyCommon.gmk	Tue Apr 09 11:48:54 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
@@ -40,7 +40,7 @@
   $(eval $(call SetupCopyFiles, COPY_EXPORTED_INCLUDE, \
       SRC := $(INCLUDE_SOURCE_DIR), \
       DEST := $(INCLUDE_TARGET_DIR), \
-      FILES := $(filter %.h, $(call CacheFind, $(INCLUDE_SOURCE_DIR))), \
+      FILES := $(filter %.h, $(call FindFiles, $(INCLUDE_SOURCE_DIR))), \
   ))
 
   TARGETS += $(COPY_EXPORTED_INCLUDE)
@@ -56,7 +56,7 @@
   $(eval $(call SetupCopyFiles, COPY_EXPORTED_INCLUDE_OS, \
       SRC := $(INCLUDE_SOURCE_OS_DIR), \
       DEST := $(INCLUDE_TARGET_DIR)/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR), \
-      FILES := $(filter %.h, $(call CacheFind, $(INCLUDE_SOURCE_OS_DIR))), \
+      FILES := $(filter %.h, $(call FindFiles, $(INCLUDE_SOURCE_OS_DIR))), \
   ))
 
   TARGETS += $(COPY_EXPORTED_INCLUDE_OS)
--- a/make/data/cldr/common/main/ja.xml	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/data/cldr/common/main/ja.xml	Tue Apr 09 11:48:54 2019 +0100
@@ -3633,7 +3633,7 @@
 						<era type="233">大正</era>
 						<era type="234">昭和</era>
 						<era type="235">平成</era>
-						<era type="236">元号</era> <!-- NewEra -->
+						<era type="236">令和</era>
 					</eraAbbr>
 					<eraNarrow>
 						<era type="0">大化</era>
@@ -3872,7 +3872,7 @@
 						<era type="233">T</era>
 						<era type="234">S</era>
 						<era type="235">H</era>
-						<era type="236">N</era> <!-- NewEra -->
+						<era type="236">R</era>
 					</eraNarrow>
 				</eras>
 				<dateFormats>
--- a/make/data/cldr/common/main/root.xml	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/data/cldr/common/main/root.xml	Tue Apr 09 11:48:54 2019 +0100
@@ -2030,7 +2030,7 @@
 						<era type="233">Taishō</era>
 						<era type="234">Shōwa</era>
 						<era type="235">Heisei</era>
-						<era type="236">NewEra</era> <!-- NewEra -->
+						<era type="236">Reiwa</era>
 					</eraAbbr>
 					<eraNarrow>
 						<era type="0">Taika (645–650)</era>
@@ -2269,7 +2269,7 @@
 						<era type="233">T</era>
 						<era type="234">S</era>
 						<era type="235">H</era>
-						<era type="236">N</era> <!-- NewEra -->
+						<era type="236">R</era>
 					</eraNarrow>
 				</eras>
 				<dateFormats>
--- a/make/data/unicodedata/UnicodeData.txt	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/data/unicodedata/UnicodeData.txt	Tue Apr 09 11:48:54 2019 +0100
@@ -11836,7 +11836,7 @@
 32FC;CIRCLED KATAKANA WI;So;0;L;<circle> 30F0;;;;N;;;;;
 32FD;CIRCLED KATAKANA WE;So;0;L;<circle> 30F1;;;;N;;;;;
 32FE;CIRCLED KATAKANA WO;So;0;L;<circle> 30F2;;;;N;;;;;
-32FF;SQUARE ERA NAME NEWERA;So;0;L;<square> 5143 53F7;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME NEWERA;;;;
+32FF;SQUARE ERA NAME REIWA;So;0;L;<square> 4EE4 548C;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME REIWA;;;;
 3300;SQUARE APAATO;So;0;L;<square> 30A2 30D1 30FC 30C8;;;;N;SQUARED APAATO;;;;
 3301;SQUARE ARUHUA;So;0;L;<square> 30A2 30EB 30D5 30A1;;;;N;SQUARED ARUHUA;;;;
 3302;SQUARE ANPEA;So;0;L;<square> 30A2 30F3 30DA 30A2;;;;N;SQUARED ANPEA;;;;
--- a/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Tue Apr 09 11:48:54 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
@@ -65,7 +65,7 @@
 
 PROC_SRC_DIRS := $(patsubst %, $(SRC_DIR)/%/src, $(PROC_SRC_SUBDIRS))
 
-PROC_SRCS := $(filter %.java, $(call CacheFind, $(PROC_SRC_DIRS)))
+PROC_SRCS := $(filter %.java, $(call FindFiles, $(PROC_SRC_DIRS)))
 
 ALL_SRC_DIRS := $(SRC_DIR) $(wildcard $(SRC_DIR)/*/src)
 SOURCEPATH := $(call PathList, $(ALL_SRC_DIRS))
--- a/make/gensrc/Gensrc-jdk.internal.vm.compiler.management.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/gensrc/Gensrc-jdk.internal.vm.compiler.management.gmk	Tue Apr 09 11:48:54 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
@@ -39,7 +39,7 @@
 
 PROC_SRC_DIRS := $(patsubst %, $(SRC_DIR)/%/src, $(PROC_SRC_SUBDIRS))
 
-PROC_SRCS := $(filter %.java, $(call CacheFind, $(PROC_SRC_DIRS)))
+PROC_SRCS := $(filter %.java, $(call FindFiles, $(PROC_SRC_DIRS)))
 
 ALL_SRC_DIRS := $(SRC_DIR) $(wildcard $(SRC_DIR)/*/src)
 SOURCEPATH := $(call PathList, $(ALL_SRC_DIRS))
--- a/make/gensrc/GensrcCommonLangtools.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/gensrc/GensrcCommonLangtools.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -64,7 +64,7 @@
 define SetupCompileProperties
   # Lookup the properties that need to be compiled into resource bundles.
   PROPSOURCES := $2 \
-      $$(shell $(FIND) $(TOPDIR)/src/$(MODULE)/share/classes -name "*.properties")
+      $$(call FindFiles, $(TOPDIR)/src/$(MODULE)/share/classes, *.properties)
 
   # Filter out any excluded translations
   PROPSOURCES := $$(call FilterExcludedTranslations, $$(PROPSOURCES), .properties)
--- a/make/gensrc/GensrcLocaleData.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/gensrc/GensrcLocaleData.gmk	Tue Apr 09 11:48:54 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
@@ -28,16 +28,16 @@
 # into LocaleDataMetaInfo.java
 
 # First go look for all locale files
-LOCALE_FILES := $(shell $(FIND) \
+LOCALE_FILES := $(call FindFiles, \
     $(TOPDIR)/src/$(MODULE)/share/classes/sun/text/resources \
-    $(TOPDIR)/src/$(MODULE)/share/classes/sun/util/resources \
-    -name "FormatData_*.java" -o -name "FormatData_*.properties" -o \
-    -name "CollationData_*.java" -o -name "CollationData_*.properties" -o \
-    -name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \
-    -name "LocaleNames_*.java" -o -name "LocaleNames_*.properties" -o \
-    -name "CurrencyNames_*.java" -o -name "CurrencyNames_*.properties" -o \
-    -name "CalendarData_*.java" -o -name "CalendarData_*.properties" -o \
-    -name "BreakIteratorInfo_*.java" -o -name "BreakIteratorRules_*.java")
+    $(TOPDIR)/src/$(MODULE)/share/classes/sun/util/resources, \
+    FormatData_*.java FormatData_*.properties \
+    CollationData_*.java CollationData_*.properties \
+    TimeZoneNames_*.java TimeZoneNames_*.properties \
+    LocaleNames_*.java LocaleNames_*.properties \
+    CurrencyNames_*.java CurrencyNames_*.properties \
+    CalendarData_*.java CalendarData_*.properties \
+    BreakIteratorInfo_*.java BreakIteratorRules_*.java)
 
 # Then translate the locale files into for example: FormatData_sv
 LOCALE_RESOURCES := $(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES)))))
--- a/make/gensrc/GensrcProperties.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/gensrc/GensrcProperties.gmk	Tue Apr 09 11:48:54 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
@@ -68,7 +68,7 @@
   endif
 
   # Locate all properties files in the given source dirs.
-  $1_SRC_FILES := $$(filter %.properties, $$(call CacheFind, $$($1_SRC_DIRS)))
+  $1_SRC_FILES := $$(call FindFiles, $$($1_SRC_DIRS), *.properties)
 
   ifneq ($$($1_EXCLUDE), )
     $1_SRC_FILES := $$(filter-out $$($1_EXCLUDE), $$($1_SRC_FILES))
--- a/make/hotspot/lib/CompileJvm.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/hotspot/lib/CompileJvm.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -167,7 +167,7 @@
 JVM_STRIPFLAGS ?= $(STRIPFLAGS)
 
 # This source set is reused so save in cache.
-$(eval $(call FillCacheFind, $(JVM_SRC_DIRS)))
+$(call FillFindCache, $(JVM_SRC_DIRS))
 
 ################################################################################
 # Now set up the actual compilation of the main hotspot native library
--- a/make/hotspot/lib/JvmFeatures.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/hotspot/lib/JvmFeatures.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -172,8 +172,6 @@
 ifneq ($(call check-jvm-feature, shenandoahgc), true)
   JVM_CFLAGS_FEATURES += -DINCLUDE_SHENANDOAHGC=0
   JVM_EXCLUDE_PATTERNS += gc/shenandoah
-else
-  JVM_CFLAGS_FEATURES += -DSUPPORT_BARRIER_ON_PRIMITIVES -DSUPPORT_NOT_TO_SPACE_INVARIANT
 endif
 
 ifneq ($(call check-jvm-feature, jfr), true)
--- a/make/hotspot/lib/JvmOverrideFiles.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/hotspot/lib/JvmOverrideFiles.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -70,7 +70,7 @@
     # significantly reduce the GC pause time on 32 bit Linux/Unix platforms by
     # compiling without the PIC flag (-fPIC on linux).
     # See 6454213 for more details.
-    ALL_SRC := $(filter %.cpp, $(call CacheFind, $(TOPDIR)/src/hotspot/share))
+    ALL_SRC := $(call FindFiles, $(TOPDIR)/src/hotspot/share, *.cpp)
     NONPIC_FILTER := $(addsuffix %, $(addprefix $(TOPDIR)/src/hotspot/share/, \
         memory oops gc))
     # Due to what looks like a bug in the old build implementation of this, add a
--- a/make/lib/Lib-java.base.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/lib/Lib-java.base.gmk	Tue Apr 09 11:48:54 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
@@ -29,7 +29,7 @@
 $(eval $(call IncludeCustomExtension, lib/Lib-java.base.gmk))
 
 # Prepare the find cache.
-$(eval $(call FillCacheFind, $(wildcard $(TOPDIR)/src/java.base/*/native)))
+$(call FillFindCache, $(wildcard $(TOPDIR)/src/java.base/*/native))
 
 ################################################################################
 # Create all the core libraries
--- a/make/lib/Lib-java.desktop.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/lib/Lib-java.desktop.gmk	Tue Apr 09 11:48:54 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
@@ -29,7 +29,7 @@
 $(eval $(call IncludeCustomExtension, lib/Lib-java.desktop.gmk))
 
 # Prepare the find cache.
-$(eval $(call FillCacheFind, $(wildcard $(TOPDIR)/src/java.desktop/*/native)))
+$(call FillFindCache, $(wildcard $(TOPDIR)/src/java.desktop/*/native))
 
 ################################################################################
 # Create the AWT/2D libraries
--- a/make/rmic/Rmic-java.management.rmi.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/rmic/Rmic-java.management.rmi.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -40,23 +40,14 @@
 $(eval $(call SetupRMICompilation,RMI_GEN, \
     CLASSES := $(JMX_RMI_CLASSES), \
     CLASSES_DIR := $(CLASSES_DIR)/java.management.rmi, \
-    STUB_CLASSES_DIR := $(RMIC_GENSRC_DIR)/java.management.rmi, \
+    STUB_CLASSES_DIR := $(STUB_CLASSES_DIR)/java.management.rmi, \
     RUN_V12 := true, \
     KEEP_GENERATED := true, \
+    STUB_SOURCES_DIR := $(RMIC_GENSRC_DIR)/java.management.rmi, \
 ))
 
-# Find all classes generated and move them from the gensrc dir to the stub classes dir
-$(RMIC_GENSRC_DIR)/_classes.moved: $(RMI_GEN)
-	$(eval classfiles := $(shell $(FIND) $(RMIC_GENSRC_DIR) -name "*.class"))
-	$(foreach src, $(classfiles), \
-	    $(eval target := $(patsubst $(RMIC_GENSRC_DIR)/%, \
-	        $(STUB_CLASSES_DIR)/%, $(src))) \
-	    $(call MakeDir, $(dir $(target))) \
-	    $(MV) $(src) $(target) $(NEWLINE))
-	$(TOUCH) $@
-
 ##########################################################################################
 
-all: $(RMIC_GENSRC_DIR)/_classes.moved $(RMI_GEN)
+all: $(RMI_GEN)
 
 .PHONY: all
--- a/make/scripts/compare.sh	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/scripts/compare.sh	Tue Apr 09 11:48:54 2019 +0100
@@ -202,15 +202,20 @@
             $SED -e '/[<>].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d')
     fi
     if test "x$SUFFIX" = "xhtml"; then
-	# Some javadoc versions do not put quotes around font size
-	HTML_FILTER="$SED \
+        # Some javadoc versions do not put quotes around font size
+        HTML_FILTER="$SED \
             -e 's/<font size=-1>/<font size=\"-1\">/g'"
-	$CAT $THIS_FILE | eval "$HTML_FILTER" > $THIS_FILE.filtered
-	$CAT $OTHER_FILE | eval "$HTML_FILTER" > $OTHER_FILE.filtered
+        $CAT $THIS_FILE | eval "$HTML_FILTER" > $THIS_FILE.filtered
+        $CAT $OTHER_FILE | eval "$HTML_FILTER" > $OTHER_FILE.filtered
         TMP=$(LC_ALL=C $DIFF $OTHER_FILE.filtered $THIS_FILE.filtered | \
             $GREP '^[<>]' | \
             $SED -e '/[<>] <!-- Generated by javadoc .* on .* -->/d' \
-	         -e '/[<>] <meta name="date" content=".*">/d' )
+                 -e '/[<>] <meta name="date" content=".*">/d' )
+    fi
+    if test "$NAME" = "BenchmarkList"; then
+        $SORT $THIS_FILE > $THIS_FILE.sorted
+        $SORT $OTHER_FILE > $OTHER_FILE.sorted
+        TMP=$($DIFF $THIS_FILE.sorted $OTHER_FILE.sorted)
     fi
     if test -n "$TMP"; then
         echo Files $OTHER_FILE and $THIS_FILE differ
@@ -382,17 +387,19 @@
         ! -name "*.zip" ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \
         ! -name "modules" ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \
         ! -name "*.cpl" ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \
-        ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" ! -name "*.jmod" \
-        ! -name "*.obj" ! -name "*.o" ! -name "JavaControlPanelHelper" \
-        ! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \
-        ! -name "jspawnhelper" ! -name "JavawsLauncher" ! -name "*.a" \
-        ! -name "finish_installation" ! -name "Sparkle" ! -name "*.tar.gz" \
-        ! -name "classes.jsa" \
+        ! -name "*.lib" ! -name "*.war" ! -name "*.jmod" ! -name "*.exe" \
+        ! -name "*.obj" ! -name "*.o" ! -name "jspawnhelper" ! -name "*.a" \
+        ! -name "*.tar.gz" ! -name "classes.jsa" ! -name "gtestLauncher" \
+        ! -name "*.map" \
         | $GREP -v "./bin/"  | $SORT | $FILTER)
 
     echo Other files with binary differences...
     for f in $GENERAL_FILES
     do
+        # Skip all files in test/*/native
+        if [[ "$f" == */native/* ]]; then
+            continue
+        fi
         if [ -e $OTHER_DIR/$f ]; then
             SUFFIX="${f##*.}"
             if [ "$(basename $f)" = "release" ]; then
@@ -431,7 +438,7 @@
                 $CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE &
                 $CAT $THIS_DIR/$f  | eval "$HTML_FILTER" > $THIS_FILE &
                 wait
-            elif [[ "$f" = *"/lib/classlist" ]]; then
+            elif [[ "$f" = *"/lib/classlist" ]] || [ "$SUFFIX" = "jar_contents" ]; then
                 # The classlist files may have some lines in random order
                 OTHER_FILE=$WORK_DIR/$f.other
                 THIS_FILE=$WORK_DIR/$f.this
@@ -792,14 +799,14 @@
         export _NT_SYMBOL_PATH="$(echo $PDB_DIRS | tr ' ' ';')"
     fi
 
-    if [ -z "$SKIP_BIN_DIFF" ]; then
-        if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
+    if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
         # The files were bytewise identical.
-            if [ -n "$VERBOSE" ]; then
-                echo "        :           :         :         :          :          : $BIN_FILE"
-            fi
-            return 0
+        if [ -n "$VERBOSE" ]; then
+            echo "        :           :         :         :          :          : $BIN_FILE"
         fi
+        return 0
+    fi
+    if [ -z "$SKIP_BIN_DIFF" ]; then
         BIN_MSG=" diff "
         if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then
             DIFF_BIN=true
@@ -826,7 +833,8 @@
         DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE)
         DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE)
         SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM)
-        if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \
+        if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* || "$ACCEPTED_SMALL_SIZE_DIFF" = "true" ]] \
+            && [ "$DIFF_SIZE_REL" -gt 98 ] \
             && [ "$DIFF_SIZE_REL" -lt 102 ]; then
             SIZE_MSG="($SIZE_MSG)"
             DIFF_SIZE=
@@ -1440,13 +1448,8 @@
         echo
     fi
 
-
     # Find the common images to compare, prioritizing later build stages
-    if [ -d "$THIS/install/jdk" ] && [ -d "$OTHER/install/jdk" ]; then
-        THIS_JDK="$THIS/install/jdk"
-        OTHER_JDK="$OTHER/install/jdk"
-        echo "Selecting install images for JDK compare"
-    elif [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/images/jdk" ]; then
+    if [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/images/jdk" ]; then
         THIS_JDK="$THIS/images/jdk"
         OTHER_JDK="$OTHER/images/jdk"
         echo "Selecting normal images for JDK compare"
@@ -1475,63 +1478,22 @@
     echo "  $OTHER_JDK"
 
     if [ -d "$THIS/images/jdk-bundle" -o -d "$THIS/deploy/images/jdk-bundle" ] \
-	     && [ -d "$OTHER/images/jdk-bundle" -o -d "$OTHER/deploy/images/jdk-bundle" ]; then
-	if [ -d "$THIS/deploy/images/jdk-bundle" ]; then
+             && [ -d "$OTHER/images/jdk-bundle" -o -d "$OTHER/deploy/images/jdk-bundle" ]; then
+        if [ -d "$THIS/deploy/images/jdk-bundle" ]; then
             THIS_JDK_BUNDLE="$THIS/deploy/images/jdk-bundle"
-	else
+        else
             THIS_JDK_BUNDLE="$THIS/images/jdk-bundle"
-	fi
-	if [ -d "$OTHER/deploy/images/jdk-bundle" ]; then
+        fi
+        if [ -d "$OTHER/deploy/images/jdk-bundle" ]; then
             OTHER_JDK_BUNDLE="$OTHER/deploy/images/jdk-bundle"
-	else
+        else
             OTHER_JDK_BUNDLE="$OTHER/images/jdk-bundle"
-	fi
+        fi
         echo "Also comparing jdk macosx bundles"
         echo "  $THIS_JDK_BUNDLE"
         echo "  $OTHER_JDK_BUNDLE"
     fi
 
-    if [ -d "$THIS/deploy/bundles" -o -d "$THIS/deploy/images/bundles" ] \
-	     && [ -d "$OTHER/deploy/bundles" -o -d "$OTHER/deploy/images/bundles" ]; then
-	if [ -d "$THIS/deploy/images/bundles" ]; then
-            THIS_DEPLOY_BUNDLE_DIR="$THIS/deploy/images/bundles"
-	else
-            THIS_DEPLOY_BUNDLE_DIR="$THIS/deploy/bundles"
-	fi
-	if [ -d "$OTHER/deploy/images/bundles" ]; then
-            OTHER_DEPLOY_BUNDLE_DIR="$OTHER/deploy/images/bundles"
-	else
-            OTHER_DEPLOY_BUNDLE_DIR="$OTHER/deploy/bundles"
-	fi
-        echo "Also comparing deploy javadoc bundles"
-    fi
-
-    if [ -d "$THIS/images/JavaAppletPlugin.plugin" ] \
-	     && [ -d "$OTHER/images/JavaAppletPlugin.plugin" -o -d "$OTHER/deploy/images/JavaAppletPlugin.plugin" ]; then
-	if [ -d "$THIS/images/JavaAppletPlugin.plugin" ]; then
-            THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/images/JavaAppletPlugin.plugin"
-	else
-            THIS_DEPLOY_APPLET_PLUGIN_DIR="$THIS/deploy/images/JavaAppletPlugin.plugin"
-	fi
-	if [ -d "$OTHER/images/JavaAppletPlugin.plugin" ]; then
-            OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/images/JavaAppletPlugin.plugin"
-	else
-            OTHER_DEPLOY_APPLET_PLUGIN_DIR="$OTHER/deploy/images/JavaAppletPlugin.plugin"
-	fi
-        echo "Also comparing deploy applet image"
-        echo "  $THIS_DEPLOY_APPLET_PLUGIN_DIR"
-        echo "  $OTHER_DEPLOY_APPLET_PLUGIN_DIR"
-    fi
-
-    if [ -d "$THIS/install/sparkle/Sparkle.framework" ] \
-           && [ -d "$OTHER/install/sparkle/Sparkle.framework" ]; then
-        THIS_SPARKLE_DIR="$THIS/install/sparkle/Sparkle.framework"
-        OTHER_SPARKLE_DIR="$OTHER/install/sparkle/Sparkle.framework"
-        echo "Also comparing install sparkle framework"
-        echo "  $THIS_SPARKLE_DIR"
-        echo "  $OTHER_SPARKLE_DIR"
-    fi
-
     THIS_SEC_DIR="$THIS/images"
     OTHER_SEC_DIR="$OTHER/images"
     if [ -f "$THIS_SEC_DIR/sec-bin.zip" ] && [ -f "$OTHER_SEC_DIR/sec-bin.zip" ]; then
@@ -1557,6 +1519,14 @@
     else
         echo "WARNING! Docs haven't been built and won't be compared."
     fi
+
+    if [ -d "$THIS/images/test" ] && [ -d "$OTHER/images/test" ]; then
+        THIS_TEST="$THIS/images/test"
+        OTHER_TEST="$OTHER/images/test"
+        echo "Also comparing test image"
+    else
+        echo "WARNING! Test haven't been built and won't be compared."
+    fi
 fi
 
 ################################################################################
@@ -1582,22 +1552,16 @@
         echo -n "Docs "
         compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_dirs $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+        echo -n "Test "
+        compare_files $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_dirs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
         compare_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_dirs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-        echo -n "JavaAppletPlugin "
-        compare_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_dirs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-        echo -n "Sparkle.framework "
-        compare_files $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_LIBS" = "true" ]; then
@@ -1605,34 +1569,38 @@
         echo -n "JDK "
         compare_all_libs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        # Test native libs are never stripped so will not compare well.
+        SKIP_BIN_DIFF="true"
+        ACCEPTED_SMALL_SIZE_DIFF_bak="$ACCEPTED_SMALL_SIZE_DIFF"
+        if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
+            ACCEPTED_SMALL_SIZE_DIFF="true"
+        fi
+        compare_all_libs $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+        SKIP_BIN_DIFF="false"
+        ACCEPTED_SMALL_SIZE_DIFF="$ACCEPTED_SMALL_SIZE_DIFF_bak"
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_all_libs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_all_libs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_all_libs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_EXECS" = "true" ]; then
     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
+        echo -n "JDK "
         compare_all_execs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        # Test native executables are never stripped so will not compare well.
+        SKIP_BIN_DIFF="true"
+        compare_all_execs $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+        SKIP_BIN_DIFF="false"
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_all_execs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_all_execs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_all_execs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_GENERAL" = "true" ]; then
@@ -1648,23 +1616,24 @@
         echo -n "Docs "
         compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_general_files $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_general_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_general_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_general_files $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_ZIPS" = "true" ]; then
     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
+        echo -n "JDK "
         compare_all_zip_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_all_zip_files $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+    fi
     if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then
         if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then
             echo "sec-bin.zip..."
@@ -1686,24 +1655,20 @@
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_all_zip_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_BUNDLE_DIR" ] && [ -n "$OTHER_DEPLOY_BUNDLE_DIR" ]; then
-        compare_all_zip_files $THIS_DEPLOY_BUNDLE_DIR $OTHER_DEPLOY_BUNDLE_DIR $COMPARE_ROOT/deploy-bundle
-    fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        compare_all_zip_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
 fi
 
 if [ "$CMP_JARS" = "true" ]; then
     if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
+        echo -n "JDK "
         compare_all_jar_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_all_jar_files $THIS_TEST $OTHER_TEST $COMPARE_ROOT/test
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_all_jar_files $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        compare_all_jar_files $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
 fi
 
 if [ "$CMP_JMODS" = "true" ]; then
@@ -1723,14 +1688,6 @@
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_permissions $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_permissions $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_permissions $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 if [ "$CMP_TYPES" = "true" ]; then
@@ -1742,17 +1699,13 @@
         echo -n "JDK Bundle "
         compare_file_types $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle
     fi
+    if [ -n "$THIS_TEST" ] && [ -n "$OTHER_TEST" ]; then
+        echo -n "Test "
+        compare_file_types $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
+    fi
     if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
         compare_file_types $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
     fi
-    if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
-        echo -n "JavaAppletPlugin "
-        compare_file_types $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
-    fi
-    if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
-        echo -n "Sparkle.framework "
-        compare_file_types $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
-    fi
 fi
 
 echo
--- a/make/scripts/compare_exceptions.sh.incl	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/scripts/compare_exceptions.sh.incl	Tue Apr 09 11:48:54 2019 +0100
@@ -38,6 +38,7 @@
 if [ "$OPENJDK_TARGET_OS" = "linux" ]; then
   ACCEPTED_BIN_DIFF="
       ./lib/server/libjvm.so
+      ./hotspot/gtest/server/libjvm.so
       "
 elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
   SKIP_BIN_DIFF="true"
@@ -49,6 +50,7 @@
       ./lib/libunpack.so
       ./lib/server/libjvm.so
       ./bin/unpack200
+      ./hotspot/gtest/server/libjvm.so
       "
   KNOWN_DIS_DIFF="
       ./lib/libfontmanager.so
@@ -68,5 +70,6 @@
       ./lib/libosxapp.dylib
       ./lib/libosxui.dylib
       ./lib/server/libjvm.dylib
+      ./hotspot/gtest/server/libjvm.dylib
       "
 fi
--- a/make/test/JtregNativeJdk.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/make/test/JtregNativeJdk.gmk	Tue Apr 09 11:48:54 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
@@ -61,6 +61,7 @@
   BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := $(WIN_LIB_JAVA)
   WIN_LIB_JLI := $(SUPPORT_OUTPUTDIR)/native/java.base/libjli/jli.lib
   BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeJliLaunchTest := $(WIN_LIB_JLI)
+  BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeCallerAccessTest := jvm.lib
 else
   BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava
   BUILD_JDK_JTREG_LIBRARIES_LIBS_libDirectIO := -ljava
@@ -70,6 +71,7 @@
     BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava -lsocket -lnsl
   endif
   BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeJliLaunchTest := -ljli
+  BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeCallerAccessTest := -ljvm
 endif
 
 ifeq ($(call isTargetOs, macosx), true)
--- a/src/hotspot/cpu/aarch64/aarch64.ad	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/aarch64.ad	Tue Apr 09 11:48:54 2019 +0100
@@ -3445,7 +3445,7 @@
     // markOop of object (disp_hdr) with the stack pointer.
     __ mov(rscratch1, sp);
     __ sub(disp_hdr, disp_hdr, rscratch1);
-    __ mov(tmp, (address) (~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place));
+    __ mov(tmp, (address) (~(os::vm_page_size()-1) | (uintptr_t)markOopDesc::lock_mask_in_place));
     // If condition is true we are cont and hence we can store 0 as the
     // displaced header in the box, which indicates that it is a recursive lock.
     __ ands(tmp/*==0?*/, disp_hdr, tmp);   // Sets flags for result
--- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1211,8 +1211,8 @@
       /* The size bit is in bit 30, not 31 */
       sz = (operand_size)(sz == word ? 0b00:0b01);
     }
-    f(sz, 31, 30), f(0b001000, 29, 24), f(1, 23), f(a, 22), f(1, 21);
-    rf(Rs, 16), f(r, 15), f(0b11111, 14, 10), rf(Rn, 5), rf(Rt, 0);
+    f(sz, 31, 30), f(0b001000, 29, 24), f(not_pair ? 1 : 0, 23), f(a, 22), f(1, 21);
+    zrf(Rs, 16), f(r, 15), f(0b11111, 14, 10), srf(Rn, 5), zrf(Rt, 0);
   }
 
   // CAS
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -34,6 +34,7 @@
 #include "c1/c1_ValueStack.hpp"
 #include "ci/ciArrayKlass.hpp"
 #include "ci/ciInstance.hpp"
+#include "code/compiledIC.hpp"
 #include "gc/shared/barrierSet.hpp"
 #include "gc/shared/cardTableBarrierSet.hpp"
 #include "gc/shared/collectedHeap.hpp"
@@ -2063,11 +2064,10 @@
   int start = __ offset();
 
   __ relocate(static_stub_Relocation::spec(call_pc));
-  __ mov_metadata(rmethod, (Metadata*)NULL);
-  __ movptr(rscratch1, 0);
-  __ br(rscratch1);
-
-  assert(__ offset() - start <= call_stub_size(), "stub too big");
+  __ emit_static_call_stub();
+
+  assert(__ offset() - start + CompiledStaticCall::to_trampoline_stub_size()
+        <= call_stub_size(), "stub too big");
   __ end_a_stub();
 }
 
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -69,7 +69,9 @@
   void deoptimize_trap(CodeEmitInfo *info);
 
   enum {
-    _call_stub_size = 12 * NativeInstruction::instruction_size,
+    // call stub: CompiledStaticCall::to_interp_stub_size() +
+    //            CompiledStaticCall::to_trampoline_stub_size()
+    _call_stub_size = 13 * NativeInstruction::instruction_size,
     _call_aot_stub_size = 0,
     _exception_handler_size = DEBUG_ONLY(1*K) NOT_DEBUG(175),
     _deopt_handler_size = 7 * NativeInstruction::instruction_size
--- a/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -61,14 +61,14 @@
   // Don't create a Metadata reloc if we're generating immutable PIC.
   if (cbuf.immutable_PIC()) {
     __ movptr(rmethod, 0);
-  } else {
-    __ mov_metadata(rmethod, (Metadata*)NULL);
+    __ movptr(rscratch1, 0);
+    __ br(rscratch1);
+
+  } else
+#endif
+  {
+    __ emit_static_call_stub();
   }
-#else
-  __ mov_metadata(rmethod, (Metadata*)NULL);
-#endif
-  __ movptr(rscratch1, 0);
-  __ br(rscratch1);
 
   assert((__ offset() - offset) <= (int)to_interp_stub_size(), "stub too big");
   __ end_a_stub();
@@ -77,7 +77,8 @@
 #undef __
 
 int CompiledStaticCall::to_interp_stub_size() {
-  return 7 * NativeInstruction::instruction_size;
+  // isb; movk; movz; movz; movk; movz; movz; br
+  return 8 * NativeInstruction::instruction_size;
 }
 
 int CompiledStaticCall::to_trampoline_stub_size() {
@@ -159,7 +160,8 @@
   }
 
   // Creation also verifies the object.
-  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
+  NativeMovConstReg* method_holder
+    = nativeMovConstReg_at(stub + NativeInstruction::instruction_size);
 #ifndef PRODUCT
   NativeGeneralJump* jump = nativeGeneralJump_at(method_holder->next_instruction_address());
 
@@ -184,7 +186,8 @@
   assert(stub != NULL, "stub not found");
   assert(CompiledICLocker::is_safe(stub), "mt unsafe call");
   // Creation also verifies the object.
-  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
+  NativeMovConstReg* method_holder
+    = nativeMovConstReg_at(stub + NativeInstruction::instruction_size);
   method_holder->set_data(0);
 }
 
@@ -201,8 +204,9 @@
   address stub = find_stub(false /* is_aot */);
   assert(stub != NULL, "no stub found for static call");
   // Creation also verifies the object.
-  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
-  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
+  NativeMovConstReg* method_holder
+    = nativeMovConstReg_at(stub + NativeInstruction::instruction_size);
+  NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
 
   // Verify state.
   assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
--- a/src/hotspot/cpu/aarch64/frame_aarch64.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/frame_aarch64.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -559,7 +559,7 @@
 
   // validate constantPoolCache*
   ConstantPoolCache* cp = *interpreter_frame_cache_addr();
-  if (cp == NULL || !cp->is_metaspace_object()) return false;
+  if (MetaspaceObj::is_valid(cp) == false) return false;
 
   // validate locals
 
--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -40,13 +40,24 @@
 
 #define __ masm->
 
-address ShenandoahBarrierSetAssembler::_shenandoah_wb = NULL;
+address ShenandoahBarrierSetAssembler::_shenandoah_lrb = NULL;
 
 void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
                                                        Register addr, Register count, RegSet saved_regs) {
   if (is_oop) {
     bool dest_uninitialized = (decorators & IS_DEST_UNINITIALIZED) != 0;
-    if (!dest_uninitialized && !ShenandoahHeap::heap()->heuristics()->can_do_traversal_gc()) {
+    if (ShenandoahSATBBarrier && !dest_uninitialized && !ShenandoahHeap::heap()->heuristics()->can_do_traversal_gc()) {
+
+      Label done;
+
+      // Avoid calling runtime if count == 0
+      __ cbz(count, done);
+
+      // Is marking active?
+      Address gc_state(rthread, in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
+      __ ldrb(rscratch1, gc_state);
+      __ tbz(rscratch1, ShenandoahHeap::MARKING_BITPOS, done);
+
       __ push(saved_regs, sp);
       if (count == c_rarg0) {
         if (addr == c_rarg1) {
@@ -68,6 +79,7 @@
         __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_array_pre_oop_entry), 2);
       }
       __ pop(saved_regs, sp);
+      __ bind(done);
     }
   }
 }
@@ -75,6 +87,16 @@
 void ShenandoahBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
                                                        Register start, Register count, Register scratch, RegSet saved_regs) {
   if (is_oop) {
+      Label done;
+
+      // Avoid calling runtime if count == 0
+      __ cbz(count, done);
+
+      // Is updating references?
+      Address gc_state(rthread, in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
+      __ ldrb(rscratch1, gc_state);
+      __ tbz(rscratch1, ShenandoahHeap::UPDATEREFS_BITPOS, done);
+
     __ push(saved_regs, sp);
     assert_different_registers(start, count, scratch);
     assert_different_registers(c_rarg0, count);
@@ -82,6 +104,8 @@
     __ mov(c_rarg1, count);
     __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_array_post_entry), 2);
     __ pop(saved_regs, sp);
+
+    __ bind(done);
   }
 }
 
@@ -186,60 +210,31 @@
   __ bind(done);
 }
 
-void ShenandoahBarrierSetAssembler::read_barrier(MacroAssembler* masm, Register dst) {
-  if (ShenandoahReadBarrier) {
-    read_barrier_impl(masm, dst);
-  }
-}
-
-void ShenandoahBarrierSetAssembler::read_barrier_impl(MacroAssembler* masm, Register dst) {
-  assert(UseShenandoahGC && (ShenandoahReadBarrier || ShenandoahStoreValReadBarrier || ShenandoahCASBarrier), "should be enabled");
+void ShenandoahBarrierSetAssembler::resolve_forward_pointer(MacroAssembler* masm, Register dst) {
+  assert(ShenandoahLoadRefBarrier || ShenandoahCASBarrier, "Should be enabled");
   Label is_null;
   __ cbz(dst, is_null);
-  read_barrier_not_null_impl(masm, dst);
+  resolve_forward_pointer_not_null(masm, dst);
   __ bind(is_null);
 }
 
-void ShenandoahBarrierSetAssembler::read_barrier_not_null(MacroAssembler* masm, Register dst) {
-  if (ShenandoahReadBarrier) {
-    read_barrier_not_null_impl(masm, dst);
-  }
-}
-
-
-void ShenandoahBarrierSetAssembler::read_barrier_not_null_impl(MacroAssembler* masm, Register dst) {
-  assert(UseShenandoahGC && (ShenandoahReadBarrier || ShenandoahStoreValReadBarrier || ShenandoahCASBarrier), "should be enabled");
+// IMPORTANT: This must preserve all registers, even rscratch1 and rscratch2.
+void ShenandoahBarrierSetAssembler::resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst) {
+  assert(ShenandoahLoadRefBarrier || ShenandoahCASBarrier, "Should be enabled");
   __ ldr(dst, Address(dst, ShenandoahBrooksPointer::byte_offset()));
 }
 
-void ShenandoahBarrierSetAssembler::write_barrier(MacroAssembler* masm, Register dst) {
-  if (ShenandoahWriteBarrier) {
-    write_barrier_impl(masm, dst);
-  }
-}
-
-void ShenandoahBarrierSetAssembler::write_barrier_impl(MacroAssembler* masm, Register dst) {
-  assert(UseShenandoahGC && (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "Should be enabled");
-  assert(dst != rscratch1, "need rscratch1");
+void ShenandoahBarrierSetAssembler::load_reference_barrier_not_null(MacroAssembler* masm, Register dst, Register tmp) {
+  assert(ShenandoahLoadRefBarrier, "Should be enabled");
   assert(dst != rscratch2, "need rscratch2");
 
   Label done;
-
+  __ enter();
   Address gc_state(rthread, in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
-  __ ldrb(rscratch1, gc_state);
+  __ ldrb(rscratch2, gc_state);
 
   // Check for heap stability
-  __ mov(rscratch2, ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
-  __ tst(rscratch1, rscratch2);
-  __ br(Assembler::EQ, done);
-
-  // Heap is unstable, need to perform the read-barrier even if WB is inactive
-  __ ldr(dst, Address(dst, ShenandoahBrooksPointer::byte_offset()));
-
-  // Check for evacuation-in-progress and jump to WB slow-path if needed
-  __ mov(rscratch2, ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
-  __ tst(rscratch1, rscratch2);
-  __ br(Assembler::EQ, done);
+  __ tbz(rscratch2, ShenandoahHeap::HAS_FORWARDED_BITPOS, done);
 
   RegSet to_save = RegSet::of(r0);
   if (dst != r0) {
@@ -247,7 +242,7 @@
     __ mov(r0, dst);
   }
 
-  __ far_call(RuntimeAddress(CAST_FROM_FN_PTR(address, ShenandoahBarrierSetAssembler::shenandoah_wb())));
+  __ far_call(RuntimeAddress(CAST_FROM_FN_PTR(address, ShenandoahBarrierSetAssembler::shenandoah_lrb())));
 
   if (dst != r0) {
     __ mov(dst, r0);
@@ -255,14 +250,11 @@
   }
 
   __ bind(done);
+  __ leave();
 }
 
 void ShenandoahBarrierSetAssembler::storeval_barrier(MacroAssembler* masm, Register dst, Register tmp) {
   if (ShenandoahStoreValEnqueueBarrier) {
-    Label is_null;
-    __ cbz(dst, is_null);
-    write_barrier_impl(masm, dst);
-    __ bind(is_null);
     // Save possibly live regs.
     RegSet live_regs = RegSet::range(r0, r4) - dst;
     __ push(live_regs, sp);
@@ -274,44 +266,45 @@
     __ ldrd(v0, __ post(sp, 2 * wordSize));
     __ pop(live_regs, sp);
   }
-  if (ShenandoahStoreValReadBarrier) {
-    read_barrier_impl(masm, dst);
+}
+
+void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm, Register dst, Register tmp) {
+  if (ShenandoahLoadRefBarrier) {
+    Label is_null;
+    __ cbz(dst, is_null);
+    load_reference_barrier_not_null(masm, dst, tmp);
+    __ bind(is_null);
   }
 }
 
 void ShenandoahBarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                                             Register dst, Address src, Register tmp1, Register tmp_thread) {
   bool on_oop = type == T_OBJECT || type == T_ARRAY;
-  bool in_heap = (decorators & IN_HEAP) != 0;
   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;
 
-  if (in_heap) {
-    read_barrier_not_null(masm, src.base());
-  }
+  BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp_thread);
+  if (on_oop) {
+    load_reference_barrier(masm, dst, tmp1);
 
-  BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp_thread);
-  if (ShenandoahKeepAliveBarrier && on_oop && on_reference) {
-    __ enter();
-    satb_write_barrier_pre(masm /* masm */,
-                           noreg /* obj */,
-                           dst /* pre_val */,
-                           rthread /* thread */,
-                           tmp1 /* tmp */,
-                           true /* tosca_live */,
-                           true /* expand_call */);
-    __ leave();
+    if (ShenandoahKeepAliveBarrier && on_reference) {
+      __ enter();
+      satb_write_barrier_pre(masm /* masm */,
+                             noreg /* obj */,
+                             dst /* pre_val */,
+                             rthread /* thread */,
+                             tmp1 /* tmp */,
+                             true /* tosca_live */,
+                             true /* expand_call */);
+      __ leave();
+    }
   }
 }
 
 void ShenandoahBarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                                              Address dst, Register val, Register tmp1, Register tmp2) {
   bool on_oop = type == T_OBJECT || type == T_ARRAY;
-  bool in_heap = (decorators & IN_HEAP) != 0;
-  if (in_heap) {
-    write_barrier(masm, dst.base());
-  }
   if (!on_oop) {
     BarrierSetAssembler::store_at(masm, decorators, type, dst, val, tmp1, tmp2);
     return;
@@ -349,21 +342,6 @@
 
 }
 
-void ShenandoahBarrierSetAssembler::obj_equals(MacroAssembler* masm, Register op1, Register op2) {
-  __ cmp(op1, op2);
-  if (ShenandoahAcmpBarrier) {
-    Label done;
-    __ br(Assembler::EQ, done);
-    // The object may have been evacuated, but we won't see it without a
-    // membar here.
-    __ membar(Assembler::LoadStore| Assembler::LoadLoad);
-    read_barrier(masm, op1);
-    read_barrier(masm, op2);
-    __ cmp(op1, op2);
-    __ bind(done);
-  }
-}
-
 void ShenandoahBarrierSetAssembler::tlab_allocate(MacroAssembler* masm, Register obj,
                                                   Register var_size_in_bytes,
                                                   int con_size_in_bytes,
@@ -398,27 +376,6 @@
   }
 }
 
-void ShenandoahBarrierSetAssembler::resolve(MacroAssembler* masm, DecoratorSet decorators, Register obj) {
-  bool oop_not_null = (decorators & IS_NOT_NULL) != 0;
-  bool is_write = (decorators & ACCESS_WRITE) != 0;
-  if (is_write) {
-    if (oop_not_null) {
-      write_barrier(masm, obj);
-    } else {
-      Label done;
-      __ cbz(obj, done);
-      write_barrier(masm, obj);
-      __ bind(done);
-    }
-  } else {
-    if (oop_not_null) {
-      read_barrier_not_null(masm, obj);
-    } else {
-      read_barrier(masm, obj);
-    }
-  }
-}
-
 void ShenandoahBarrierSetAssembler::cmpxchg_oop(MacroAssembler* masm, Register addr, Register expected, Register new_val,
                                                 bool acquire, bool release, bool weak, bool is_cae,
                                                 Register result) {
@@ -457,8 +414,8 @@
     __ decode_heap_oop(tmp1, tmp1);
     __ decode_heap_oop(tmp2, tmp2);
   }
-  read_barrier_impl(masm, tmp1);
-  read_barrier_impl(masm, tmp2);
+  resolve_forward_pointer(masm, tmp1);
+  resolve_forward_pointer(masm, tmp2);
   __ cmp(tmp1, tmp2);
   // Retry with expected now being the value we just loaded from addr.
   __ br(Assembler::EQ, retry);
@@ -503,7 +460,7 @@
   __ b(*stub->continuation());
 }
 
-void ShenandoahBarrierSetAssembler::gen_write_barrier_stub(LIR_Assembler* ce, ShenandoahWriteBarrierStub* stub) {
+void ShenandoahBarrierSetAssembler::gen_load_reference_barrier_stub(LIR_Assembler* ce, ShenandoahLoadReferenceBarrierStub* stub) {
 
   Register obj = stub->obj()->as_register();
   Register res = stub->result()->as_register();
@@ -520,7 +477,7 @@
     __ cbz(res, done);
   }
 
-  write_barrier(ce->masm(), res);
+  load_reference_barrier_not_null(ce->masm(), res, rscratch1);
 
   __ bind(done);
   __ b(*stub->continuation());
@@ -580,14 +537,14 @@
 
 #endif // COMPILER1
 
-address ShenandoahBarrierSetAssembler::shenandoah_wb() {
-  assert(_shenandoah_wb != NULL, "need write barrier stub");
-  return _shenandoah_wb;
+address ShenandoahBarrierSetAssembler::shenandoah_lrb() {
+  assert(_shenandoah_lrb != NULL, "need load reference barrier stub");
+  return _shenandoah_lrb;
 }
 
 #define __ cgen->assembler()->
 
-// Shenandoah write barrier.
+// Shenandoah load reference barrier.
 //
 // Input:
 //   r0: OOP to evacuate.  Not null.
@@ -596,13 +553,13 @@
 //   r0: Pointer to evacuated OOP.
 //
 // Trash rscratch1, rscratch2.  Preserve everything else.
-address ShenandoahBarrierSetAssembler::generate_shenandoah_wb(StubCodeGenerator* cgen) {
+address ShenandoahBarrierSetAssembler::generate_shenandoah_lrb(StubCodeGenerator* cgen) {
 
   __ align(6);
-  StubCodeMark mark(cgen, "StubRoutines", "shenandoah_wb");
+  StubCodeMark mark(cgen, "StubRoutines", "shenandoah_lrb");
   address start = __ pc();
 
-  Label work;
+  Label work, done;
   __ mov(rscratch2, ShenandoahHeap::in_cset_fast_test_addr());
   __ lsr(rscratch1, r0, ShenandoahHeapRegion::region_size_bytes_shift_jint());
   __ ldrb(rscratch2, Address(rscratch2, rscratch1));
@@ -610,19 +567,23 @@
   __ ret(lr);
   __ bind(work);
 
-  Register obj = r0;
+  __ mov(rscratch2, r0);
+  resolve_forward_pointer_not_null(cgen->assembler(), r0);
+  __ cmp(rscratch2, r0);
+  __ br(Assembler::NE, done);
 
   __ enter(); // required for proper stackwalking of RuntimeStub frame
 
   __ push_call_clobbered_registers();
 
-  __ mov(lr, CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_JRT));
+  __ mov(lr, CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_JRT));
   __ blrt(lr, 1, 0, MacroAssembler::ret_type_integral);
-  __ mov(rscratch1, obj);
+  __ mov(rscratch1, r0);
   __ pop_call_clobbered_registers();
-  __ mov(obj, rscratch1);
+  __ mov(r0, rscratch1);
 
   __ leave(); // required for proper stackwalking of RuntimeStub frame
+  __ bind(done);
   __ ret(lr);
 
   return start;
@@ -631,12 +592,12 @@
 #undef __
 
 void ShenandoahBarrierSetAssembler::barrier_stubs_init() {
-  if (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier) {
+  if (ShenandoahLoadRefBarrier) {
     int stub_code_size = 2048;
     ResourceMark rm;
     BufferBlob* bb = BufferBlob::create("shenandoah_barrier_stubs", stub_code_size);
     CodeBuffer buf(bb);
     StubCodeGenerator cgen(&buf);
-    _shenandoah_wb = generate_shenandoah_wb(&cgen);
+    _shenandoah_lrb = generate_shenandoah_lrb(&cgen);
   }
 }
--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -29,7 +29,7 @@
 #ifdef COMPILER1
 class LIR_Assembler;
 class ShenandoahPreBarrierStub;
-class ShenandoahWriteBarrierStub;
+class ShenandoahLoadReferenceBarrierStub;
 class StubAssembler;
 class StubCodeGenerator;
 #endif
@@ -37,7 +37,7 @@
 class ShenandoahBarrierSetAssembler: public BarrierSetAssembler {
 private:
 
-  static address _shenandoah_wb;
+  static address _shenandoah_lrb;
 
   void satb_write_barrier_pre(MacroAssembler* masm,
                               Register obj,
@@ -54,24 +54,21 @@
                                     bool tosca_live,
                                     bool expand_call);
 
-  void read_barrier(MacroAssembler* masm, Register dst);
-  void read_barrier_impl(MacroAssembler* masm, Register dst);
-  void read_barrier_not_null(MacroAssembler* masm, Register dst);
-  void read_barrier_not_null_impl(MacroAssembler* masm, Register dst);
-  void write_barrier(MacroAssembler* masm, Register dst);
-  void write_barrier_impl(MacroAssembler* masm, Register dst);
-  void asm_acmp_barrier(MacroAssembler* masm, Register op1, Register op2);
+  void resolve_forward_pointer(MacroAssembler* masm, Register dst);
+  void resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst);
+  void load_reference_barrier(MacroAssembler* masm, Register dst, Register tmp);
+  void load_reference_barrier_not_null(MacroAssembler* masm, Register dst, Register tmp);
 
-  address generate_shenandoah_wb(StubCodeGenerator* cgen);
+  address generate_shenandoah_lrb(StubCodeGenerator* cgen);
 
 public:
-  static address shenandoah_wb();
+  static address shenandoah_lrb();
 
   void storeval_barrier(MacroAssembler* masm, Register dst, Register tmp);
 
 #ifdef COMPILER1
   void gen_pre_barrier_stub(LIR_Assembler* ce, ShenandoahPreBarrierStub* stub);
-  void gen_write_barrier_stub(LIR_Assembler* ce, ShenandoahWriteBarrierStub* stub);
+  void gen_load_reference_barrier_stub(LIR_Assembler* ce, ShenandoahLoadReferenceBarrierStub* stub);
   void generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm);
 #endif
 
@@ -83,8 +80,6 @@
                        Register dst, Address src, Register tmp1, Register tmp_thread);
   virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                         Address dst, Register val, Register tmp1, Register tmp2);
-  virtual void obj_equals(MacroAssembler* masm, Register src1, Register src2);
-  virtual void resolve(MacroAssembler* masm, DecoratorSet decorators, Register obj);
   virtual void tlab_allocate(MacroAssembler* masm, Register obj,
                              Register var_size_in_bytes,
                              int con_size_in_bytes,
--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetC1_aarch64.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetC1_aarch64.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -99,6 +99,7 @@
   __ xchg(access.resolved_addr(), value_opr, result, tmp);
 
   if (access.is_oop()) {
+    result = load_reference_barrier(access.gen(), result, access.access_emit_info(), true);
     if (ShenandoahSATBBarrier) {
       pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
                   result /* pre_val */);
--- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoah_aarch64.ad	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoah_aarch64.ad	Tue Apr 09 11:48:54 2019 +0100
@@ -45,18 +45,6 @@
   %}
 %}
 
-instruct shenandoahRB(iRegPNoSp dst, iRegP src, rFlagsReg cr) %{
-  match(Set dst (ShenandoahReadBarrier src));
-  format %{ "shenandoah_rb $dst,$src" %}
-  ins_encode %{
-    Register s = $src$$Register;
-    Register d = $dst$$Register;
-    __ ldr(d, Address(s, ShenandoahBrooksPointer::byte_offset()));
-  %}
-  ins_pipe(pipe_class_memory);
-%}
-
-
 instruct compareAndSwapP_shenandoah(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{
 
   match(Set res (ShenandoahCompareAndSwapP mem (Binary oldval newval)));
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -812,6 +812,18 @@
   return stub_start_addr;
 }
 
+void MacroAssembler::emit_static_call_stub() {
+  // CompiledDirectStaticCall::set_to_interpreted knows the
+  // exact layout of this stub.
+
+  isb();
+  mov_metadata(rmethod, (Metadata*)NULL);
+
+  // Jump to the entry point of the i2c stub.
+  movptr(rscratch1, 0);
+  br(rscratch1);
+}
+
 void MacroAssembler::c2bool(Register x) {
   // implements x == 0 ? 0 : 1
   // note: must only look at least-significant byte of x
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -607,6 +607,7 @@
   static int patch_narrow_klass(address insn_addr, narrowKlass n);
 
   address emit_trampoline_stub(int insts_call_instruction_offset, address target);
+  void emit_static_call_stub();
 
   // The following 4 methods return the offset of the appropriate move instruction
 
--- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -232,7 +232,11 @@
 //-------------------------------------------------------------------
 
 void NativeMovConstReg::verify() {
-  // make sure code pattern is actually mov reg64, imm64 instructions
+  if (! (nativeInstruction_at(instruction_address())->is_movz() ||
+        is_adrp_at(instruction_address()) ||
+        is_ldr_literal_at(instruction_address())) ) {
+    fatal("should be MOVZ or ADRP or LDR (literal)");
+  }
 }
 
 
--- a/src/hotspot/cpu/arm/frame_arm.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/arm/frame_arm.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -494,7 +494,7 @@
 
   // validate ConstantPoolCache*
   ConstantPoolCache* cp = *interpreter_frame_cache_addr();
-  if (cp == NULL || !cp->is_metaspace_object()) return false;
+  if (MetaspaceObj::is_valid(cp) == false) return false;
 
   // validate locals
 
--- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -27,6 +27,7 @@
 #include "asm/macroAssembler.inline.hpp"
 #include "gc/shared/barrierSetAssembler.hpp"
 #include "interpreter/interp_masm.hpp"
+#include "runtime/jniHandles.hpp"
 
 #define __ masm->
 
--- a/src/hotspot/cpu/sparc/frame_sparc.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/sparc/frame_sparc.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -665,7 +665,7 @@
 
   // validate ConstantPoolCache*
   ConstantPoolCache* cp = *interpreter_frame_cache_addr();
-  if (cp == NULL || !cp->is_metaspace_object()) return false;
+  if (MetaspaceObj::is_valid(cp) == false) return false;
 
   // validate locals
 
--- a/src/hotspot/cpu/x86/frame_x86.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/x86/frame_x86.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -546,7 +546,7 @@
 
   // validate ConstantPoolCache*
   ConstantPoolCache* cp = *interpreter_frame_cache_addr();
-  if (cp == NULL || !cp->is_metaspace_object()) return false;
+  if (MetaspaceObj::is_valid(cp) == false) return false;
 
   // validate locals
 
--- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -41,7 +41,7 @@
 
 #define __ masm->
 
-address ShenandoahBarrierSetAssembler::_shenandoah_wb = NULL;
+address ShenandoahBarrierSetAssembler::_shenandoah_lrb = NULL;
 
 void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                                                        Register src, Register dst, Register count) {
@@ -66,26 +66,22 @@
     }
 #endif
 
-    if (!dest_uninitialized && !ShenandoahHeap::heap()->heuristics()->can_do_traversal_gc()) {
+    if (ShenandoahSATBBarrier && !dest_uninitialized && !ShenandoahHeap::heap()->heuristics()->can_do_traversal_gc()) {
       Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
 #ifndef _LP64
       __ push(thread);
       __ get_thread(thread);
 #endif
 
-      Label filtered;
-      Address in_progress(thread, in_bytes(ShenandoahThreadLocalData::satb_mark_queue_active_offset()));
-      // Is marking active?
-      if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
-        __ cmpl(in_progress, 0);
-      } else {
-        assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
-        __ cmpb(in_progress, 0);
-      }
+      Label done;
+      // Short-circuit if count == 0.
+      __ testptr(count, count);
+      __ jcc(Assembler::zero, done);
 
-      NOT_LP64(__ pop(thread);)
-
-        __ jcc(Assembler::equal, filtered);
+      // Avoid runtime call when not marking.
+      Address gc_state(thread, in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
+      __ testb(gc_state, ShenandoahHeap::MARKING);
+      __ jcc(Assembler::zero, done);
 
       __ pusha();                      // push registers
 #ifdef _LP64
@@ -111,7 +107,8 @@
                       dst, count);
 #endif
       __ popa();
-      __ bind(filtered);
+      __ bind(done);
+      NOT_LP64(__ pop(thread);)
     }
   }
 
@@ -141,6 +138,22 @@
     }
 #endif
 
+    Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
+#ifndef _LP64
+    __ push(thread);
+    __ get_thread(thread);
+#endif
+
+    // Short-circuit if count == 0.
+    Label done;
+    __ testptr(count, count);
+    __ jcc(Assembler::zero, done);
+
+    // Skip runtime call if no forwarded objects.
+    Address gc_state(thread, in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
+    __ testb(gc_state, ShenandoahHeap::UPDATEREFS);
+    __ jcc(Assembler::zero, done);
+
     __ pusha();             // push registers (overkill)
 #ifdef _LP64
     if (c_rarg0 == count) { // On win64 c_rarg0 == rcx
@@ -158,6 +171,9 @@
                     dst, count);
 #endif
     __ popa();
+
+    __ bind(done);
+    NOT_LP64(__ pop(thread);)
   }
 }
 
@@ -296,41 +312,23 @@
   __ bind(done);
 }
 
-void ShenandoahBarrierSetAssembler::read_barrier(MacroAssembler* masm, Register dst) {
-  if (ShenandoahReadBarrier) {
-    read_barrier_impl(masm, dst);
-  }
-}
-
-void ShenandoahBarrierSetAssembler::read_barrier_impl(MacroAssembler* masm, Register dst) {
-  assert(UseShenandoahGC && (ShenandoahReadBarrier || ShenandoahStoreValReadBarrier || ShenandoahCASBarrier), "should be enabled");
+void ShenandoahBarrierSetAssembler::resolve_forward_pointer(MacroAssembler* masm, Register dst) {
+  assert(ShenandoahCASBarrier, "should be enabled");
   Label is_null;
   __ testptr(dst, dst);
   __ jcc(Assembler::zero, is_null);
-  read_barrier_not_null_impl(masm, dst);
+  resolve_forward_pointer_not_null(masm, dst);
   __ bind(is_null);
 }
 
-void ShenandoahBarrierSetAssembler::read_barrier_not_null(MacroAssembler* masm, Register dst) {
-  if (ShenandoahReadBarrier) {
-    read_barrier_not_null_impl(masm, dst);
-  }
-}
-
-void ShenandoahBarrierSetAssembler::read_barrier_not_null_impl(MacroAssembler* masm, Register dst) {
-  assert(UseShenandoahGC && (ShenandoahReadBarrier || ShenandoahStoreValReadBarrier || ShenandoahCASBarrier), "should be enabled");
+void ShenandoahBarrierSetAssembler::resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst) {
+  assert(ShenandoahCASBarrier || ShenandoahLoadRefBarrier, "should be enabled");
   __ movptr(dst, Address(dst, ShenandoahBrooksPointer::byte_offset()));
 }
 
 
-void ShenandoahBarrierSetAssembler::write_barrier(MacroAssembler* masm, Register dst) {
-  if (ShenandoahWriteBarrier) {
-    write_barrier_impl(masm, dst);
-  }
-}
-
-void ShenandoahBarrierSetAssembler::write_barrier_impl(MacroAssembler* masm, Register dst) {
-  assert(UseShenandoahGC && (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "Should be enabled");
+void ShenandoahBarrierSetAssembler::load_reference_barrier_not_null(MacroAssembler* masm, Register dst) {
+  assert(ShenandoahLoadRefBarrier, "Should be enabled");
 #ifdef _LP64
   Label done;
 
@@ -338,8 +336,8 @@
   __ testb(gc_state, ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
   __ jccb(Assembler::zero, done);
 
-  // Heap is unstable, need to perform the read-barrier even if WB is inactive
-  read_barrier_not_null(masm, dst);
+  // Heap is unstable, need to perform the resolve even if LRB is inactive
+  resolve_forward_pointer_not_null(masm, dst);
 
   __ testb(gc_state, ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
   __ jccb(Assembler::zero, done);
@@ -348,7 +346,7 @@
      __ xchgptr(dst, rax); // Move obj into rax and save rax into obj.
    }
 
-   __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, ShenandoahBarrierSetAssembler::shenandoah_wb())));
+   __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, ShenandoahBarrierSetAssembler::shenandoah_lrb())));
 
    if (dst != rax) {
      __ xchgptr(rax, dst); // Swap back obj with rax.
@@ -361,24 +359,18 @@
 }
 
 void ShenandoahBarrierSetAssembler::storeval_barrier(MacroAssembler* masm, Register dst, Register tmp) {
-  if (ShenandoahStoreValReadBarrier || ShenandoahStoreValEnqueueBarrier) {
+  if (ShenandoahStoreValEnqueueBarrier) {
     storeval_barrier_impl(masm, dst, tmp);
   }
 }
 
 void ShenandoahBarrierSetAssembler::storeval_barrier_impl(MacroAssembler* masm, Register dst, Register tmp) {
-  assert(UseShenandoahGC && (ShenandoahStoreValReadBarrier || ShenandoahStoreValEnqueueBarrier), "should be enabled");
+  assert(ShenandoahStoreValEnqueueBarrier, "should be enabled");
 
   if (dst == noreg) return;
 
 #ifdef _LP64
   if (ShenandoahStoreValEnqueueBarrier) {
-    Label is_null;
-    __ testptr(dst, dst);
-    __ jcc(Assembler::zero, is_null);
-    write_barrier_impl(masm, dst);
-    __ bind(is_null);
-
     // The set of registers to be saved+restored is the same as in the write-barrier above.
     // Those are the commonly used registers in the interpreter.
     __ pusha();
@@ -392,50 +384,54 @@
     //__ pop_callee_saved_registers();
     __ popa();
   }
-  if (ShenandoahStoreValReadBarrier) {
-    read_barrier_impl(masm, dst);
-  }
 #else
   Unimplemented();
 #endif
 }
 
+void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm, Register dst) {
+  if (ShenandoahLoadRefBarrier) {
+    Label done;
+    __ testptr(dst, dst);
+    __ jcc(Assembler::zero, done);
+    load_reference_barrier_not_null(masm, dst);
+    __ bind(done);
+  }
+}
+
 void ShenandoahBarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
              Register dst, Address src, Register tmp1, Register tmp_thread) {
   bool on_oop = type == T_OBJECT || type == T_ARRAY;
-  bool in_heap = (decorators & IN_HEAP) != 0;
   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;
-  if (in_heap) {
-    read_barrier_not_null(masm, src.base());
-  }
-  BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp_thread);
-  if (ShenandoahKeepAliveBarrier && on_oop && on_reference) {
-    const Register thread = NOT_LP64(tmp_thread) LP64_ONLY(r15_thread);
-    NOT_LP64(__ get_thread(thread));
+   BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp_thread);
+  if (on_oop) {
+    load_reference_barrier(masm, dst);
 
-    // Generate the SATB pre-barrier code to log the value of
-    // the referent field in an SATB buffer.
-    shenandoah_write_barrier_pre(masm /* masm */,
-                                 noreg /* obj */,
-                                 dst /* pre_val */,
-                                 thread /* thread */,
-                                 tmp1 /* tmp */,
-                                 true /* tosca_live */,
-                                 true /* expand_call */);
+    if (ShenandoahKeepAliveBarrier && on_reference) {
+      const Register thread = NOT_LP64(tmp_thread) LP64_ONLY(r15_thread);
+      NOT_LP64(__ get_thread(thread));
+      // Generate the SATB pre-barrier code to log the value of
+      // the referent field in an SATB buffer.
+      shenandoah_write_barrier_pre(masm /* masm */,
+                                   noreg /* obj */,
+                                   dst /* pre_val */,
+                                   thread /* thread */,
+                                   tmp1 /* tmp */,
+                                   true /* tosca_live */,
+                                   true /* expand_call */);
+    }
   }
 }
 
 void ShenandoahBarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
               Address dst, Register val, Register tmp1, Register tmp2) {
 
+  bool on_oop = type == T_OBJECT || type == T_ARRAY;
   bool in_heap = (decorators & IN_HEAP) != 0;
   bool as_normal = (decorators & AS_NORMAL) != 0;
-  if (in_heap) {
-    write_barrier(masm, dst.base());
-  }
-  if (type == T_OBJECT || type == T_ARRAY) {
+  if (on_oop && in_heap) {
     bool needs_pre_barrier = as_normal;
 
     Register tmp3 = LP64_ONLY(r8) NOT_LP64(rsi);
@@ -478,44 +474,6 @@
   }
 }
 
-#ifndef _LP64
-void ShenandoahBarrierSetAssembler::obj_equals(MacroAssembler* masm,
-                                               Address obj1, jobject obj2) {
-  Unimplemented();
-}
-
-void ShenandoahBarrierSetAssembler::obj_equals(MacroAssembler* masm,
-                                               Register obj1, jobject obj2) {
-  Unimplemented();
-}
-#endif
-
-
-void ShenandoahBarrierSetAssembler::obj_equals(MacroAssembler* masm, Register op1, Register op2) {
-  __ cmpptr(op1, op2);
-  if (ShenandoahAcmpBarrier) {
-    Label done;
-    __ jccb(Assembler::equal, done);
-    read_barrier(masm, op1);
-    read_barrier(masm, op2);
-    __ cmpptr(op1, op2);
-    __ bind(done);
-  }
-}
-
-void ShenandoahBarrierSetAssembler::obj_equals(MacroAssembler* masm, Register src1, Address src2) {
-  __ cmpptr(src1, src2);
-  if (ShenandoahAcmpBarrier) {
-    Label done;
-    __ jccb(Assembler::equal, done);
-    __ movptr(rscratch2, src2);
-    read_barrier(masm, src1);
-    read_barrier(masm, rscratch2);
-    __ cmpptr(src1, rscratch2);
-    __ bind(done);
-  }
-}
-
 void ShenandoahBarrierSetAssembler::tlab_allocate(MacroAssembler* masm,
                                                   Register thread, Register obj,
                                                   Register var_size_in_bytes,
@@ -565,28 +523,6 @@
   __ verify_tlab();
 }
 
-void ShenandoahBarrierSetAssembler::resolve(MacroAssembler* masm, DecoratorSet decorators, Register obj) {
-  bool oop_not_null = (decorators & IS_NOT_NULL) != 0;
-  bool is_write = (decorators & ACCESS_WRITE) != 0;
-  if (is_write) {
-    if (oop_not_null) {
-      write_barrier(masm, obj);
-    } else {
-      Label done;
-      __ testptr(obj, obj);
-      __ jcc(Assembler::zero, done);
-      write_barrier(masm, obj);
-      __ bind(done);
-    }
-  } else {
-    if (oop_not_null) {
-      read_barrier_not_null(masm, obj);
-    } else {
-      read_barrier(masm, obj);
-    }
-  }
-}
-
 // Special Shenandoah CAS implementation that handles false negatives
 // due to concurrent evacuation.
 #ifndef _LP64
@@ -625,14 +561,14 @@
   // 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 read both
-  // oldval and the value from memory through the read barriers -- this will give
-  // both to-space pointers. If they mismatch, then it was a legitimate failure.
+  // 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.
+  // If they mismatch, then it was a legitimate failure.
   //
   if (UseCompressedOops) {
     __ decode_heap_oop(tmp1);
   }
-  read_barrier_impl(masm, tmp1);
+  resolve_forward_pointer(masm, tmp1);
 
   if (UseCompressedOops) {
     __ movl(tmp2, oldval);
@@ -640,7 +576,7 @@
   } else {
     __ movptr(tmp2, oldval);
   }
-  read_barrier_impl(masm, tmp2);
+  resolve_forward_pointer(masm, tmp2);
 
   __ cmpptr(tmp1, tmp2);
   __ jcc(Assembler::notEqual, done, true);
@@ -649,8 +585,8 @@
   //
   // 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 re-reading the failure
-  // witness through the read barrier.
+  // on retry, and so need to do this in loop, always resolving the failure
+  // witness.
   __ bind(retry);
   if (os::is_MP()) __ lock();
   if (UseCompressedOops) {
@@ -666,7 +602,7 @@
   } else {
     __ movptr(tmp2, oldval);
   }
-  read_barrier_impl(masm, tmp2);
+  resolve_forward_pointer(masm, tmp2);
 
   __ cmpptr(tmp1, tmp2);
   __ jcc(Assembler::equal, retry, true);
@@ -814,7 +750,7 @@
 
 }
 
-void ShenandoahBarrierSetAssembler::gen_write_barrier_stub(LIR_Assembler* ce, ShenandoahWriteBarrierStub* stub) {
+void ShenandoahBarrierSetAssembler::gen_load_reference_barrier_stub(LIR_Assembler* ce, ShenandoahLoadReferenceBarrierStub* stub) {
   __ bind(*stub->entry());
 
   Label done;
@@ -831,7 +767,7 @@
     __ jcc(Assembler::zero, done);
   }
 
-  write_barrier(ce->masm(), res);
+  load_reference_barrier_not_null(ce->masm(), res);
 
   __ bind(done);
   __ jmp(*stub->continuation());
@@ -901,16 +837,16 @@
 
 #endif // COMPILER1
 
-address ShenandoahBarrierSetAssembler::shenandoah_wb() {
-  assert(_shenandoah_wb != NULL, "need write barrier stub");
-  return _shenandoah_wb;
+address ShenandoahBarrierSetAssembler::shenandoah_lrb() {
+  assert(_shenandoah_lrb != NULL, "need load reference barrier stub");
+  return _shenandoah_lrb;
 }
 
 #define __ cgen->assembler()->
 
-address ShenandoahBarrierSetAssembler::generate_shenandoah_wb(StubCodeGenerator* cgen) {
+address ShenandoahBarrierSetAssembler::generate_shenandoah_lrb(StubCodeGenerator* cgen) {
   __ align(CodeEntryAlignment);
-  StubCodeMark mark(cgen, "StubRoutines", "shenandoah_wb");
+  StubCodeMark mark(cgen, "StubRoutines", "shenandoah_lrb");
   address start = __ pc();
 
 #ifdef _LP64
@@ -958,7 +894,7 @@
   __ push(r15);
   save_vector_registers(cgen->assembler());
   __ movptr(rdi, rax);
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_JRT), rdi);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_JRT), rdi);
   restore_vector_registers(cgen->assembler());
   __ pop(r15);
   __ pop(r14);
@@ -985,12 +921,12 @@
 #undef __
 
 void ShenandoahBarrierSetAssembler::barrier_stubs_init() {
-  if (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier) {
+  if (ShenandoahLoadRefBarrier) {
     int stub_code_size = 4096;
     ResourceMark rm;
     BufferBlob* bb = BufferBlob::create("shenandoah_barrier_stubs", stub_code_size);
     CodeBuffer buf(bb);
     StubCodeGenerator cgen(&buf);
-    _shenandoah_wb = generate_shenandoah_wb(&cgen);
+    _shenandoah_lrb = generate_shenandoah_lrb(&cgen);
   }
 }
--- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -29,7 +29,7 @@
 #ifdef COMPILER1
 class LIR_Assembler;
 class ShenandoahPreBarrierStub;
-class ShenandoahWriteBarrierStub;
+class ShenandoahLoadReferenceBarrierStub;
 class StubAssembler;
 class StubCodeGenerator;
 #endif
@@ -37,7 +37,7 @@
 class ShenandoahBarrierSetAssembler: public BarrierSetAssembler {
 private:
 
-  static address _shenandoah_wb;
+  static address _shenandoah_lrb;
 
   void satb_write_barrier_pre(MacroAssembler* masm,
                               Register obj,
@@ -55,32 +55,30 @@
                                     bool tosca_live,
                                     bool expand_call);
 
-  void read_barrier(MacroAssembler* masm, Register dst);
-  void read_barrier_impl(MacroAssembler* masm, Register dst);
+  void resolve_forward_pointer(MacroAssembler* masm, Register dst);
+  void resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst);
 
-  void read_barrier_not_null(MacroAssembler* masm, Register dst);
-  void read_barrier_not_null_impl(MacroAssembler* masm, Register dst);
-
-  void write_barrier(MacroAssembler* masm, Register dst);
-  void write_barrier_impl(MacroAssembler* masm, Register dst);
+  void load_reference_barrier_not_null(MacroAssembler* masm, Register dst);
 
   void storeval_barrier_impl(MacroAssembler* masm, Register dst, Register tmp);
 
-  address generate_shenandoah_wb(StubCodeGenerator* cgen);
+  address generate_shenandoah_lrb(StubCodeGenerator* cgen);
 
   void save_vector_registers(MacroAssembler* masm);
   void restore_vector_registers(MacroAssembler* masm);
 
 public:
-  static address shenandoah_wb();
+  static address shenandoah_lrb();
 
   void storeval_barrier(MacroAssembler* masm, Register dst, Register tmp);
 #ifdef COMPILER1
   void gen_pre_barrier_stub(LIR_Assembler* ce, ShenandoahPreBarrierStub* stub);
-  void gen_write_barrier_stub(LIR_Assembler* ce, ShenandoahWriteBarrierStub* stub);
+  void gen_load_reference_barrier_stub(LIR_Assembler* ce, ShenandoahLoadReferenceBarrierStub* stub);
   void generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm);
 #endif
 
+  void load_reference_barrier(MacroAssembler* masm, Register dst);
+
   void cmpxchg_oop(MacroAssembler* masm,
                    Register res, Address addr, Register oldval, Register newval,
                    bool exchange, Register tmp1, Register tmp2);
@@ -93,16 +91,6 @@
   virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
                         Address dst, Register val, Register tmp1, Register tmp2);
 
-#ifndef _LP64
-  virtual void obj_equals(MacroAssembler* masm,
-                          Address obj1, jobject obj2);
-  virtual void obj_equals(MacroAssembler* masm,
-                          Register obj1, jobject obj2);
-#endif
-
-  virtual void obj_equals(MacroAssembler* masm, Register src1, Register src2);
-  virtual void obj_equals(MacroAssembler* masm, Register src1, Address src2);
-
   virtual void tlab_allocate(MacroAssembler* masm,
                              Register thread, Register obj,
                              Register var_size_in_bytes,
@@ -110,8 +98,6 @@
                              Register t1, Register t2,
                              Label& slow_case);
 
-  virtual void resolve(MacroAssembler* masm, DecoratorSet decorators, Register obj);
-
   virtual void barrier_stubs_init();
 
 };
--- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetC1_x86.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetC1_x86.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -107,6 +107,7 @@
   __ xchg(access.resolved_addr(), result, result, LIR_OprFact::illegalOpr);
 
   if (access.is_oop()) {
+    result = load_reference_barrier(access.gen(), result, access.access_emit_info(), true);
     if (ShenandoahSATBBarrier) {
       pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
                   result /* pre_val */);
--- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoah_x86_64.ad	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoah_x86_64.ad	Tue Apr 09 11:48:54 2019 +0100
@@ -23,47 +23,7 @@
 
 source_hpp %{
 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
-%}
-
-instruct shenandoahRB(rRegP dst, rRegP src, rFlagsReg cr) %{
-  match(Set dst (ShenandoahReadBarrier src));
-  effect(DEF dst, USE src);
-  ins_cost(125); // XXX
-  format %{ "shenandoah_rb $dst, $src" %}
-  ins_encode %{
-    Register d = $dst$$Register;
-    Register s = $src$$Register;
-    __ movptr(d, Address(s, ShenandoahBrooksPointer::byte_offset()));
-  %}
-  ins_pipe(ialu_reg_mem);
-%}
-
-instruct shenandoahRBNarrow(rRegP dst, rRegN src) %{
-  predicate(UseCompressedOops && (Universe::narrow_oop_shift() == 0));
-  match(Set dst (ShenandoahReadBarrier (DecodeN src)));
-  effect(DEF dst, USE src);
-  ins_cost(125); // XXX
-  format %{ "shenandoah_rb $dst, $src" %}
-  ins_encode %{
-    Register d = $dst$$Register;
-    Register s = $src$$Register;
-    __ movptr(d, Address(r12, s, Address::times_1, ShenandoahBrooksPointer::byte_offset()));
-  %}
-  ins_pipe(ialu_reg_mem);
-%}
-
-instruct shenandoahRBNarrowShift(rRegP dst, rRegN src) %{
-  predicate(UseCompressedOops && (Universe::narrow_oop_shift() == Address::times_8));
-  match(Set dst (ShenandoahReadBarrier (DecodeN src)));
-  effect(DEF dst, USE src);
-  ins_cost(125); // XXX
-  format %{ "shenandoah_rb $dst, $src" %}
-  ins_encode %{
-    Register d = $dst$$Register;
-    Register s = $src$$Register;
-    __ movptr(d, Address(r12, s, Address::times_8, ShenandoahBrooksPointer::byte_offset()));
-  %}
-  ins_pipe(ialu_reg_mem);
+#include "gc/shenandoah/c2/shenandoahSupport.hpp"
 %}
 
 instruct compareAndSwapP_shenandoah(rRegI res,
--- a/src/hotspot/cpu/x86/x86_32.ad	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/cpu/x86/x86_32.ad	Tue Apr 09 11:48:54 2019 +0100
@@ -1309,7 +1309,7 @@
 }
 
 uint MachSpillCopyNode::size(PhaseRegAlloc *ra_) const {
-  return implementation( NULL, ra_, true, NULL );
+  return MachNode::size(ra_);
 }
 
 
--- a/src/hotspot/os/aix/os_perf_aix.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os/aix/os_perf_aix.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -336,20 +336,8 @@
 
   fclose(fh);
   if (n < expected_assign_count || logical_cpu != which_logical_cpu) {
-#ifdef DEBUG_LINUX_PROC_STAT
-    vm_fprintf(stderr, "[stat] read failed");
-#endif
     return OS_ERR;
   }
-
-#ifdef DEBUG_LINUX_PROC_STAT
-  vm_fprintf(stderr, "[stat] read "
-          UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " "
-          UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " \n",
-          userTicks, niceTicks, systemTicks, idleTicks,
-          iowTicks, irqTicks, sirqTicks);
-#endif
-
   pticks->used       = userTicks + niceTicks;
   pticks->usedKernel = systemTicks + irqTicks + sirqTicks;
   pticks->total      = userTicks + niceTicks + systemTicks + idleTicks +
--- a/src/hotspot/os/bsd/os_bsd.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1598,6 +1598,8 @@
 }
 
 void os::print_memory_info(outputStream* st) {
+  xsw_usage swap_usage;
+  size_t size = sizeof(swap_usage);
 
   st->print("Memory:");
   st->print(" %dk page", os::vm_page_size()>>10);
@@ -1606,6 +1608,16 @@
             os::physical_memory() >> 10);
   st->print("(" UINT64_FORMAT "k free)",
             os::available_memory() >> 10);
+
+  if((sysctlbyname("vm.swapusage", &swap_usage, &size, NULL, 0) == 0) || (errno == ENOMEM)) {
+    if (size >= offset_of(xsw_usage, xsu_used)) {
+      st->print(", swap " UINT64_FORMAT "k",
+                ((julong) swap_usage.xsu_total) >> 10);
+      st->print("(" UINT64_FORMAT "k free)",
+                ((julong) swap_usage.xsu_avail) >> 10);
+    }
+  }
+
   st->cr();
 }
 
--- a/src/hotspot/os/linux/os_linux.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os/linux/os_linux.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -227,6 +227,82 @@
   return phys_mem;
 }
 
+static uint64_t initial_total_ticks = 0;
+static uint64_t initial_steal_ticks = 0;
+static bool     has_initial_tick_info = false;
+
+static void next_line(FILE *f) {
+  int c;
+  do {
+    c = fgetc(f);
+  } while (c != '\n' && c != EOF);
+}
+
+bool os::Linux::get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu) {
+  FILE*         fh;
+  uint64_t      userTicks, niceTicks, systemTicks, idleTicks;
+  // since at least kernel 2.6 : iowait: time waiting for I/O to complete
+  // irq: time  servicing interrupts; softirq: time servicing softirqs
+  uint64_t      iowTicks = 0, irqTicks = 0, sirqTicks= 0;
+  // steal (since kernel 2.6.11): time spent in other OS when running in a virtualized environment
+  uint64_t      stealTicks = 0;
+  // guest (since kernel 2.6.24): time spent running a virtual CPU for guest OS under the
+  // control of the Linux kernel
+  uint64_t      guestNiceTicks = 0;
+  int           logical_cpu = -1;
+  const int     required_tickinfo_count = (which_logical_cpu == -1) ? 4 : 5;
+  int           n;
+
+  memset(pticks, 0, sizeof(CPUPerfTicks));
+
+  if ((fh = fopen("/proc/stat", "r")) == NULL) {
+    return false;
+  }
+
+  if (which_logical_cpu == -1) {
+    n = fscanf(fh, "cpu " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " "
+            UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " "
+            UINT64_FORMAT " " UINT64_FORMAT " ",
+            &userTicks, &niceTicks, &systemTicks, &idleTicks,
+            &iowTicks, &irqTicks, &sirqTicks,
+            &stealTicks, &guestNiceTicks);
+  } else {
+    // Move to next line
+    next_line(fh);
+
+    // find the line for requested cpu faster to just iterate linefeeds?
+    for (int i = 0; i < which_logical_cpu; i++) {
+      next_line(fh);
+    }
+
+    n = fscanf(fh, "cpu%u " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " "
+               UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " "
+               UINT64_FORMAT " " UINT64_FORMAT " ",
+               &logical_cpu, &userTicks, &niceTicks,
+               &systemTicks, &idleTicks, &iowTicks, &irqTicks, &sirqTicks,
+               &stealTicks, &guestNiceTicks);
+  }
+
+  fclose(fh);
+  if (n < required_tickinfo_count || logical_cpu != which_logical_cpu) {
+    return false;
+  }
+  pticks->used       = userTicks + niceTicks;
+  pticks->usedKernel = systemTicks + irqTicks + sirqTicks;
+  pticks->total      = userTicks + niceTicks + systemTicks + idleTicks +
+                       iowTicks + irqTicks + sirqTicks + stealTicks + guestNiceTicks;
+
+  if (n > required_tickinfo_count + 3) {
+    pticks->steal = stealTicks;
+    pticks->has_steal_ticks = true;
+  } else {
+    pticks->steal = 0;
+    pticks->has_steal_ticks = false;
+  }
+
+  return true;
+}
+
 // Return true if user is running as root.
 
 bool os::have_special_privileges() {
@@ -1977,6 +2053,8 @@
   os::Linux::print_container_info(st);
 
   os::Linux::print_virtualization_info(st);
+
+  os::Linux::print_steal_info(st);
 }
 
 // Try to identify popular distros.
@@ -2265,6 +2343,24 @@
 #endif
 }
 
+void os::Linux::print_steal_info(outputStream* st) {
+  if (has_initial_tick_info) {
+    CPUPerfTicks pticks;
+    bool res = os::Linux::get_tick_information(&pticks, -1);
+
+    if (res && pticks.has_steal_ticks) {
+      uint64_t steal_ticks_difference = pticks.steal - initial_steal_ticks;
+      uint64_t total_ticks_difference = pticks.total - initial_total_ticks;
+      double steal_ticks_perc = 0.0;
+      if (total_ticks_difference != 0) {
+        steal_ticks_perc = (double) steal_ticks_difference / total_ticks_difference;
+      }
+      st->print_cr("Steal ticks since vm start: " UINT64_FORMAT, steal_ticks_difference);
+      st->print_cr("Steal ticks percentage since vm start:%7.3f", steal_ticks_perc);
+    }
+  }
+}
+
 void os::print_memory_info(outputStream* st) {
 
   st->print("Memory:");
@@ -4989,6 +5085,15 @@
 
   Linux::initialize_os_info();
 
+  os::Linux::CPUPerfTicks pticks;
+  bool res = os::Linux::get_tick_information(&pticks, -1);
+
+  if (res && pticks.has_steal_ticks) {
+    has_initial_tick_info = true;
+    initial_total_ticks = pticks.total;
+    initial_steal_ticks = pticks.steal;
+  }
+
   // _main_thread points to the thread that created/loaded the JVM.
   Linux::_main_thread = pthread_self();
 
--- a/src/hotspot/os/linux/os_linux.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os/linux/os_linux.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -109,12 +109,23 @@
   static void print_full_memory_info(outputStream* st);
   static void print_container_info(outputStream* st);
   static void print_virtualization_info(outputStream* st);
+  static void print_steal_info(outputStream* st);
   static void print_distro_info(outputStream* st);
   static void print_libversion_info(outputStream* st);
   static void print_proc_sys_info(outputStream* st);
   static void print_ld_preload_file(outputStream* st);
 
  public:
+  struct CPUPerfTicks {
+    uint64_t used;
+    uint64_t usedKernel;
+    uint64_t total;
+    uint64_t steal;
+    bool     has_steal_ticks;
+  };
+
+  // which_logical_cpu=-1 returns accumulated ticks for all cpus.
+  static bool get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu);
   static bool _stack_is_executable;
   static void *dlopen_helper(const char *name, char *ebuf, int ebuflen);
   static void *dll_load_in_vmthread(const char *name, char *ebuf, int ebuflen);
--- a/src/hotspot/os/linux/os_perf_linux.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os/linux/os_perf_linux.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -206,13 +206,6 @@
 #  define _SCANFMT_
 #endif
 
-
-struct CPUPerfTicks {
-  uint64_t  used;
-  uint64_t  usedKernel;
-  uint64_t  total;
-};
-
 typedef enum {
   CPU_LOAD_VM_ONLY,
   CPU_LOAD_GLOBAL,
@@ -227,8 +220,8 @@
 
 struct CPUPerfCounters {
   int   nProcs;
-  CPUPerfTicks jvmTicks;
-  CPUPerfTicks* cpus;
+  os::Linux::CPUPerfTicks jvmTicks;
+  os::Linux::CPUPerfTicks* cpus;
 };
 
 static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters, double* pkernelLoad, CpuLoadTarget target);
@@ -287,80 +280,6 @@
   return f;
 }
 
-static void
-next_line(FILE *f) {
-  int c;
-  do {
-    c = fgetc(f);
-  } while (c != '\n' && c != EOF);
-}
-
-/**
- * Return the total number of ticks since the system was booted.
- * If the usedTicks parameter is not NULL, it will be filled with
- * the number of ticks spent on actual processes (user, system or
- * nice processes) since system boot. Note that this is the total number
- * of "executed" ticks on _all_ CPU:s, that is on a n-way system it is
- * n times the number of ticks that has passed in clock time.
- *
- * Returns a negative value if the reading of the ticks failed.
- */
-static OSReturn get_total_ticks(int which_logical_cpu, CPUPerfTicks* pticks) {
-  FILE*         fh;
-  uint64_t      userTicks, niceTicks, systemTicks, idleTicks;
-  uint64_t      iowTicks = 0, irqTicks = 0, sirqTicks= 0;
-  int           logical_cpu = -1;
-  const int     expected_assign_count = (-1 == which_logical_cpu) ? 4 : 5;
-  int           n;
-
-  if ((fh = open_statfile()) == NULL) {
-    return OS_ERR;
-  }
-  if (-1 == which_logical_cpu) {
-    n = fscanf(fh, "cpu " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " "
-            UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT,
-            &userTicks, &niceTicks, &systemTicks, &idleTicks,
-            &iowTicks, &irqTicks, &sirqTicks);
-  } else {
-    // Move to next line
-    next_line(fh);
-
-    // find the line for requested cpu faster to just iterate linefeeds?
-    for (int i = 0; i < which_logical_cpu; i++) {
-      next_line(fh);
-    }
-
-    n = fscanf(fh, "cpu%u " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " "
-               UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT,
-               &logical_cpu, &userTicks, &niceTicks,
-               &systemTicks, &idleTicks, &iowTicks, &irqTicks, &sirqTicks);
-  }
-
-  fclose(fh);
-  if (n < expected_assign_count || logical_cpu != which_logical_cpu) {
-#ifdef DEBUG_LINUX_PROC_STAT
-    vm_fprintf(stderr, "[stat] read failed");
-#endif
-    return OS_ERR;
-  }
-
-#ifdef DEBUG_LINUX_PROC_STAT
-  vm_fprintf(stderr, "[stat] read "
-          UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " "
-          UINT64_FORMAT " " UINT64_FORMAT " " UINT64_FORMAT " \n",
-          userTicks, niceTicks, systemTicks, idleTicks,
-          iowTicks, irqTicks, sirqTicks);
-#endif
-
-  pticks->used       = userTicks + niceTicks;
-  pticks->usedKernel = systemTicks + irqTicks + sirqTicks;
-  pticks->total      = userTicks + niceTicks + systemTicks + idleTicks +
-                       iowTicks + irqTicks + sirqTicks;
-
-  return OS_OK;
-}
-
-
 static int get_systemtype(void) {
   static int procEntriesType = UNDETECTED;
   DIR *taskDir;
@@ -391,7 +310,7 @@
  * Return the number of ticks spent in any of the processes belonging
  * to the JVM on any CPU.
  */
-static OSReturn get_jvm_ticks(CPUPerfTicks* pticks) {
+static OSReturn get_jvm_ticks(os::Linux::CPUPerfTicks* pticks) {
   uint64_t userTicks;
   uint64_t systemTicks;
 
@@ -404,7 +323,7 @@
   }
 
   // get the total
-  if (get_total_ticks(-1, pticks) != OS_OK) {
+  if (! os::Linux::get_tick_information(pticks, -1)) {
     return OS_ERR;
   }
 
@@ -423,8 +342,8 @@
  */
 static double get_cpu_load(int which_logical_cpu, CPUPerfCounters* counters, double* pkernelLoad, CpuLoadTarget target) {
   uint64_t udiff, kdiff, tdiff;
-  CPUPerfTicks* pticks;
-  CPUPerfTicks  tmp;
+  os::Linux::CPUPerfTicks* pticks;
+  os::Linux::CPUPerfTicks  tmp;
   double user_load;
 
   *pkernelLoad = 0.0;
@@ -443,7 +362,7 @@
     if (get_jvm_ticks(pticks) != OS_OK) {
       return -1.0;
     }
-  } else if (get_total_ticks(which_logical_cpu, pticks) != OS_OK) {
+  } else if (! os::Linux::get_tick_information(pticks, which_logical_cpu)) {
     return -1.0;
   }
 
@@ -584,19 +503,19 @@
 }
 
 bool CPUPerformanceInterface::CPUPerformance::initialize() {
-  size_t tick_array_size = (_counters.nProcs +1) * sizeof(CPUPerfTicks);
-  _counters.cpus = (CPUPerfTicks*)NEW_C_HEAP_ARRAY(char, tick_array_size, mtInternal);
+  size_t tick_array_size = (_counters.nProcs +1) * sizeof(os::Linux::CPUPerfTicks);
+  _counters.cpus = (os::Linux::CPUPerfTicks*)NEW_C_HEAP_ARRAY(char, tick_array_size, mtInternal);
   if (NULL == _counters.cpus) {
     return false;
   }
   memset(_counters.cpus, 0, tick_array_size);
 
   // For the CPU load total
-  get_total_ticks(-1, &_counters.cpus[_counters.nProcs]);
+  os::Linux::get_tick_information(&_counters.cpus[_counters.nProcs], -1);
 
   // For each CPU
   for (int i = 0; i < _counters.nProcs; i++) {
-    get_total_ticks(i, &_counters.cpus[i]);
+    os::Linux::get_tick_information(&_counters.cpus[i], i);
   }
   // For JVM load
   get_jvm_ticks(&_counters.jvmTicks);
--- a/src/hotspot/os_cpu/aix_ppc/orderAccess_aix_ppc.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/aix_ppc/orderAccess_aix_ppc.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -77,6 +77,8 @@
 inline void OrderAccess::acquire()    { inlasm_lwsync(); }
 inline void OrderAccess::release()    { inlasm_lwsync(); }
 inline void OrderAccess::fence()      { inlasm_sync();   }
+inline void OrderAccess::cross_modify_fence()
+                                      { inlasm_isync();  }
 
 template<size_t byte_size>
 struct OrderAccess::PlatformOrderedLoad<byte_size, X_ACQUIRE>
--- a/src/hotspot/os_cpu/bsd_x86/orderAccess_bsd_x86.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/bsd_x86/orderAccess_bsd_x86.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -59,6 +59,11 @@
   compiler_barrier();
 }
 
+inline void OrderAccess::cross_modify_fence() {
+  int idx = 0;
+  __asm__ volatile ("cpuid " : "+a" (idx) : : "ebx", "ecx", "edx", "memory");
+}
+
 template<>
 struct OrderAccess::PlatformOrderedStore<1, RELEASE_X_FENCE>
 {
--- a/src/hotspot/os_cpu/bsd_zero/orderAccess_bsd_zero.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/bsd_zero/orderAccess_bsd_zero.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -73,5 +73,6 @@
 inline void OrderAccess::acquire()    { LIGHT_MEM_BARRIER; }
 inline void OrderAccess::release()    { LIGHT_MEM_BARRIER; }
 inline void OrderAccess::fence()      { FULL_MEM_BARRIER;  }
+inline void OrderAccess::cross_modify_fence()            { }
 
 #endif // OS_CPU_BSD_ZERO_ORDERACCESS_BSD_ZERO_HPP
--- a/src/hotspot/os_cpu/linux_aarch64/orderAccess_linux_aarch64.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_aarch64/orderAccess_linux_aarch64.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -49,6 +49,8 @@
   FULL_MEM_BARRIER;
 }
 
+inline void OrderAccess::cross_modify_fence() { }
+
 template<size_t byte_size>
 struct OrderAccess::PlatformOrderedLoad<byte_size, X_ACQUIRE>
 {
--- a/src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_arm/orderAccess_linux_arm.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -101,5 +101,6 @@
 inline void OrderAccess::storeload()  { dmb_sy(); }
 inline void OrderAccess::release()    { dmb_sy(); }
 inline void OrderAccess::fence()      { dmb_sy(); }
+inline void OrderAccess::cross_modify_fence()   { }
 
 #endif // OS_CPU_LINUX_ARM_ORDERACCESS_LINUX_ARM_HPP
--- a/src/hotspot/os_cpu/linux_ppc/orderAccess_linux_ppc.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_ppc/orderAccess_linux_ppc.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -79,7 +79,8 @@
 inline void   OrderAccess::acquire()    { inlasm_lwsync(); }
 inline void   OrderAccess::release()    { inlasm_lwsync(); }
 inline void   OrderAccess::fence()      { inlasm_sync();   }
-
+inline void   OrderAccess::cross_modify_fence()
+                                        { inlasm_isync();  }
 
 template<size_t byte_size>
 struct OrderAccess::PlatformOrderedLoad<byte_size, X_ACQUIRE>
--- a/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -66,7 +66,7 @@
 
     if (ret_frame.is_interpreted_frame()) {
        frame::ijava_state* istate = ret_frame.get_ijava_state();
-       if (!((Method*)(istate->method))->is_metaspace_object()) {
+       if (MetaspaceObj::is_valid((Method*)(istate->method)) == false) {
          return false;
        }
        uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/];
--- a/src/hotspot/os_cpu/linux_s390/orderAccess_linux_s390.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_s390/orderAccess_linux_s390.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -74,6 +74,7 @@
 inline void OrderAccess::acquire()    { inlasm_zarch_acquire(); }
 inline void OrderAccess::release()    { inlasm_zarch_release(); }
 inline void OrderAccess::fence()      { inlasm_zarch_sync(); }
+inline void OrderAccess::cross_modify_fence() { inlasm_zarch_sync(); }
 
 template<size_t byte_size>
 struct OrderAccess::PlatformOrderedLoad<byte_size, X_ACQUIRE>
--- a/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_s390/thread_linux_s390.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -63,7 +63,8 @@
 
     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()) || !((Method*)(istate->method))->is_metaspace_object()) {
+       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*/];
--- a/src/hotspot/os_cpu/linux_sparc/orderAccess_linux_sparc.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_sparc/orderAccess_linux_sparc.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -48,4 +48,6 @@
   __asm__ volatile ("membar  #StoreLoad" : : : "memory");
 }
 
+inline void OrderAccess::cross_modify_fence() { }
+
 #endif // OS_CPU_LINUX_SPARC_ORDERACCESS_LINUX_SPARC_HPP
--- a/src/hotspot/os_cpu/linux_x86/orderAccess_linux_x86.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_x86/orderAccess_linux_x86.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -55,6 +55,11 @@
   compiler_barrier();
 }
 
+inline void OrderAccess::cross_modify_fence() {
+  int idx = 0;
+  __asm__ volatile ("cpuid " : "+a" (idx) : : "ebx", "ecx", "edx", "memory");
+}
+
 template<>
 struct OrderAccess::PlatformOrderedStore<1, RELEASE_X_FENCE>
 {
--- a/src/hotspot/os_cpu/linux_zero/orderAccess_linux_zero.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/linux_zero/orderAccess_linux_zero.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -82,5 +82,6 @@
 inline void OrderAccess::release()    { LIGHT_MEM_BARRIER; }
 
 inline void OrderAccess::fence()      { FULL_MEM_BARRIER;  }
+inline void OrderAccess::cross_modify_fence()            { }
 
 #endif // OS_CPU_LINUX_ZERO_ORDERACCESS_LINUX_ZERO_HPP
--- a/src/hotspot/os_cpu/solaris_sparc/orderAccess_solaris_sparc.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/solaris_sparc/orderAccess_solaris_sparc.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -51,4 +51,6 @@
   __asm__ volatile ("membar  #StoreLoad" : : : "memory");
 }
 
+inline void OrderAccess::cross_modify_fence() { }
+
 #endif // OS_CPU_SOLARIS_SPARC_ORDERACCESS_SOLARIS_SPARC_HPP
--- a/src/hotspot/os_cpu/solaris_x86/orderAccess_solaris_x86.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/solaris_x86/orderAccess_solaris_x86.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -54,4 +54,9 @@
   compiler_barrier();
 }
 
+inline void OrderAccess::cross_modify_fence() {
+  int idx = 0;
+  __asm__ volatile ("cpuid " : "+a" (idx) : : "ebx", "ecx", "edx", "memory");
+}
+
 #endif // OS_CPU_SOLARIS_X86_ORDERACCESS_SOLARIS_X86_HPP
--- a/src/hotspot/os_cpu/windows_x86/orderAccess_windows_x86.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/windows_x86/orderAccess_windows_x86.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -69,6 +69,11 @@
   compiler_barrier();
 }
 
+inline void OrderAccess::cross_modify_fence() {
+  int regs[4];
+  __cpuid(regs, 0);
+}
+
 #ifndef AMD64
 template<>
 struct OrderAccess::PlatformOrderedStore<1, RELEASE_X_FENCE>
--- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -465,6 +465,9 @@
 }
 
 #ifndef AMD64
+// Ignore "C4172: returning address of local variable or temporary" on 32bit
+PRAGMA_DIAG_PUSH
+PRAGMA_DISABLE_MSVC_WARNING(4172)
 // Returns an estimate of the current stack pointer. Result must be guaranteed
 // to point into the calling threads stack, and be no lower than the current
 // stack pointer.
@@ -473,6 +476,7 @@
   address sp = (address)&dummy;
   return sp;
 }
+PRAGMA_DIAG_POP
 #else
 // Returns the current stack pointer. Accurate value needed for
 // os::verify_stack_alignment().
--- a/src/hotspot/share/adlc/formssel.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/adlc/formssel.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -777,8 +777,7 @@
        !strcmp(_matrule->_rChild->_opType,"CompareAndExchangeP") ||
        !strcmp(_matrule->_rChild->_opType,"CompareAndExchangeN") ||
        !strcmp(_matrule->_rChild->_opType,"ShenandoahCompareAndExchangeP") ||
-       !strcmp(_matrule->_rChild->_opType,"ShenandoahCompareAndExchangeN") ||
-       !strcmp(_matrule->_rChild->_opType,"ShenandoahReadBarrier")))  return true;
+       !strcmp(_matrule->_rChild->_opType,"ShenandoahCompareAndExchangeN"))) return true;
   else if ( is_ideal_load() == Form::idealP )                return true;
   else if ( is_ideal_store() != Form::none  )                return true;
 
@@ -3506,7 +3505,6 @@
     "ClearArray",
     "GetAndSetB", "GetAndSetS", "GetAndAddI", "GetAndSetI", "GetAndSetP",
     "GetAndAddB", "GetAndAddS", "GetAndAddL", "GetAndSetL", "GetAndSetN",
-    "ShenandoahReadBarrier",
     "LoadBarrierSlowReg", "LoadBarrierWeakSlowReg"
   };
   int cnt = sizeof(needs_ideal_memory_list)/sizeof(char*);
--- a/src/hotspot/share/aot/aotCompiledMethod.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/aot/aotCompiledMethod.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -206,8 +206,6 @@
   // AOT compiled methods do not get into zombie state
   virtual bool can_convert_to_zombie() { return false; }
 
-  // Evol dependent methods already marked.
-  virtual bool is_evol_dependent() { return false; }
   virtual bool is_dependent_on_method(Method* dependee) { return true; }
 
   virtual void clear_inline_caches();
--- a/src/hotspot/share/ci/ciReplay.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/ci/ciReplay.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -40,6 +40,7 @@
 #include "runtime/handles.inline.hpp"
 #include "utilities/copy.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/utf8.hpp"
 
 #ifndef PRODUCT
 
--- a/src/hotspot/share/classfile/classFileParser.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -32,6 +32,7 @@
 #include "classfile/dictionary.hpp"
 #include "classfile/javaClasses.inline.hpp"
 #include "classfile/moduleEntry.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/verificationType.hpp"
@@ -77,6 +78,8 @@
 #include "utilities/macros.hpp"
 #include "utilities/ostream.hpp"
 #include "utilities/resourceHash.hpp"
+#include "utilities/utf8.hpp"
+
 #if INCLUDE_CDS
 #include "classfile/systemDictionaryShared.hpp"
 #endif
@@ -312,7 +315,7 @@
           const char* const str = java_lang_String::as_utf8_string(patch());
           // (could use java_lang_String::as_symbol instead, but might as well batch them)
           utf8_buffer = (const u1*) str;
-          utf8_length = (int) strlen(str);
+          utf8_length = (u2) strlen(str);
         }
 
         unsigned int hash;
--- a/src/hotspot/share/classfile/classLoader.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/classLoader.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -396,6 +396,10 @@
   }
 }
 
+ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) {
+  return open_stream_for_loader(name, ClassLoaderData::the_null_class_loader_data(), THREAD);
+}
+
 // For a class in a named module, look it up in the jimage file using this syntax:
 //    /<module-name>/<package-name>/<base-class>
 //
@@ -403,7 +407,7 @@
 //     1. There are no unnamed modules in the jimage file.
 //     2. A package is in at most one module in the jimage file.
 //
-ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) {
+ClassFileStream* ClassPathImageEntry::open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS) {
   jlong size;
   JImageLocationRef location = (*JImageFindResource)(_jimage, "", get_jimage_version_string(), name, &size);
 
@@ -414,20 +418,8 @@
     if (pkg_name != NULL) {
       if (!Universe::is_module_initialized()) {
         location = (*JImageFindResource)(_jimage, JAVA_BASE_NAME, get_jimage_version_string(), name, &size);
-#if INCLUDE_CDS
-        // CDS uses the boot class loader to load classes whose packages are in
-        // modules defined for other class loaders.  So, for now, get their module
-        // names from the "modules" jimage file.
-        if (DumpSharedSpaces && location == 0) {
-          const char* module_name = (*JImagePackageToModule)(_jimage, pkg_name);
-          if (module_name != NULL) {
-            location = (*JImageFindResource)(_jimage, module_name, get_jimage_version_string(), name, &size);
-          }
-        }
-#endif
-
       } else {
-        PackageEntry* package_entry = ClassLoader::get_package_entry(name, ClassLoaderData::the_null_class_loader_data(), CHECK_NULL);
+        PackageEntry* package_entry = ClassLoader::get_package_entry(name, loader_data, CHECK_NULL);
         if (package_entry != NULL) {
           ResourceMark rm;
           // Get the module name
--- a/src/hotspot/share/classfile/classLoader.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/classLoader.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -61,6 +61,10 @@
   // Attempt to locate file_name through this class path entry.
   // Returns a class file parsing stream if successfull.
   virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0;
+  // Open the stream for a specific class loader
+  virtual ClassFileStream* open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS) {
+    return open_stream(name, THREAD);
+  }
 };
 
 class ClassPathDirEntry: public ClassPathEntry {
@@ -125,6 +129,7 @@
   ClassPathImageEntry(JImageFile* jimage, const char* name);
   virtual ~ClassPathImageEntry();
   ClassFileStream* open_stream(const char* name, TRAPS);
+  ClassFileStream* open_stream_for_loader(const char* name, ClassLoaderData* loader_data, TRAPS);
 };
 
 // ModuleClassPathList contains a linked list of ClassPathEntry's
--- a/src/hotspot/share/classfile/classLoaderData.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Tue Apr 09 11:48:54 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
@@ -288,7 +288,7 @@
 // it is being defined, therefore _keep_alive is not volatile or atomic.
 void ClassLoaderData::inc_keep_alive() {
   if (is_unsafe_anonymous()) {
-    assert(_keep_alive >= 0, "Invalid keep alive increment count");
+    assert(_keep_alive > 0, "Invalid keep alive increment count");
     _keep_alive++;
   }
 }
--- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -163,7 +163,7 @@
   // TODO: have redefinition clean old methods out of the code cache.  They still exist in some places.
   bool walk_all_metadata = InstanceKlass::has_previous_versions_and_reset();
 
-  MetadataOnStackMark md_on_stack(walk_all_metadata);
+  MetadataOnStackMark md_on_stack(walk_all_metadata, /*redefinition_walk*/false);
   clean_deallocate_lists(walk_all_metadata);
 }
 
--- a/src/hotspot/share/classfile/javaClasses.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -65,6 +65,7 @@
 #include "runtime/vframe.inline.hpp"
 #include "utilities/align.hpp"
 #include "utilities/preserveException.hpp"
+#include "utilities/utf8.hpp"
 #if INCLUDE_JVMCI
 #include "jvmci/jvmciJavaClasses.hpp"
 #endif
@@ -217,7 +218,7 @@
 
 void java_lang_String::set_compact_strings(bool value) {
   CompactStringsFixup fix(value);
-  InstanceKlass::cast(SystemDictionary::String_klass())->do_local_static_fields(&fix);
+  SystemDictionary::String_klass()->do_local_static_fields(&fix);
 }
 
 Handle java_lang_String::basic_create(int length, bool is_latin1, TRAPS) {
@@ -3990,6 +3991,48 @@
 int java_lang_System::out_offset_in_bytes() { return static_out_offset; }
 int java_lang_System::err_offset_in_bytes() { return static_err_offset; }
 
+// Support for jdk_internal_misc_UnsafeConstants
+//
+class UnsafeConstantsFixup : public FieldClosure {
+private:
+  int _address_size;
+  int _page_size;
+  bool _big_endian;
+  bool _use_unaligned_access;
+public:
+  UnsafeConstantsFixup() {
+    // round up values for all static final fields
+    _address_size = sizeof(void*);
+    _page_size = os::vm_page_size();
+    _big_endian = LITTLE_ENDIAN_ONLY(false) BIG_ENDIAN_ONLY(true);
+    _use_unaligned_access = UseUnalignedAccesses;
+  }
+
+  void do_field(fieldDescriptor* fd) {
+    oop mirror = fd->field_holder()->java_mirror();
+    assert(mirror != NULL, "UnsafeConstants must have mirror already");
+    assert(fd->field_holder() == SystemDictionary::UnsafeConstants_klass(), "Should be UnsafeConstants");
+    assert(fd->is_final(), "fields of UnsafeConstants must be final");
+    assert(fd->is_static(), "fields of UnsafeConstants must be static");
+    if (fd->name() == vmSymbols::address_size_name()) {
+      mirror->int_field_put(fd->offset(), _address_size);
+    } else if (fd->name() == vmSymbols::page_size_name()) {
+      mirror->int_field_put(fd->offset(), _page_size);
+    } else if (fd->name() == vmSymbols::big_endian_name()) {
+      mirror->bool_field_put(fd->offset(), _big_endian);
+    } else if (fd->name() == vmSymbols::use_unaligned_access_name()) {
+      mirror->bool_field_put(fd->offset(), _use_unaligned_access);
+    } else {
+      assert(false, "unexpected UnsafeConstants field");
+    }
+  }
+};
+
+void jdk_internal_misc_UnsafeConstants::set_unsafe_constants() {
+  UnsafeConstantsFixup fixup;
+  SystemDictionary::UnsafeConstants_klass()->do_local_static_fields(&fixup);
+}
+
 int java_lang_Class::_klass_offset;
 int java_lang_Class::_array_klass_offset;
 int java_lang_Class::_oop_size_offset;
--- a/src/hotspot/share/classfile/javaClasses.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/javaClasses.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -29,7 +29,6 @@
 #include "jvmtifiles/jvmti.h"
 #include "oops/oop.hpp"
 #include "runtime/os.hpp"
-#include "utilities/utf8.hpp"
 
 // Interface for manipulating the basic Java classes.
 //
@@ -82,6 +81,7 @@
   f(java_lang_StackFrameInfo) \
   f(java_lang_LiveStackFrameInfo) \
   f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \
+  f(jdk_internal_misc_UnsafeConstants) \
   //end
 
 #define BASIC_JAVA_CLASSES_DO(f) \
@@ -1484,6 +1484,15 @@
   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 };
 
+ // Interface to jdk.internal.misc.UnsafeConsants
+
+class jdk_internal_misc_UnsafeConstants : AllStatic {
+ public:
+  static void set_unsafe_constants();
+  static void compute_offsets() { }
+  static void serialize_offsets(SerializeClosure* f) { }
+};
+
 // Use to declare fields that need to be injected into Java classes
 // for the JVM to use.  The name_index and signature_index are
 // declared in vmSymbols.  The may_be_java flag is used to declare
--- a/src/hotspot/share/classfile/klassFactory.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/klassFactory.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -58,7 +58,7 @@
     // Post the CFLH
     JvmtiCachedClassFileData* cached_class_file = NULL;
     if (cfs == NULL) {
-      cfs = FileMapInfo::open_stream_for_jvmti(ik, CHECK_NULL);
+      cfs = FileMapInfo::open_stream_for_jvmti(ik, class_loader, CHECK_NULL);
     }
     unsigned char* ptr = (unsigned char*)cfs->buffer();
     unsigned char* end_ptr = ptr + cfs->length();
--- a/src/hotspot/share/classfile/metadataOnStackMark.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/metadataOnStackMark.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -50,18 +50,25 @@
 // it.  Class unloading only deletes in-error class files, methods created by
 // the relocator and dummy constant pools.  None of these appear anywhere except
 // in metadata Handles.
-MetadataOnStackMark::MetadataOnStackMark(bool redefinition_walk) {
+MetadataOnStackMark::MetadataOnStackMark(bool walk_all_metadata, bool redefinition_walk) {
   assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
   assert(_used_buffers == NULL, "sanity check");
   assert(!_is_active, "MetadataOnStackMarks do not nest");
+  assert(!redefinition_walk || walk_all_metadata,
+         "walk_all_metadata must be true for redefinition_walk");
   NOT_PRODUCT(_is_active = true;)
 
   Threads::metadata_handles_do(Metadata::mark_on_stack);
 
-  if (redefinition_walk) {
+  if (walk_all_metadata) {
     MetadataOnStackClosure md_on_stack;
     Threads::metadata_do(&md_on_stack);
-    CodeCache::metadata_do(&md_on_stack);
+    if (redefinition_walk) {
+      // We have to walk the whole code cache during redefinition.
+      CodeCache::metadata_do(&md_on_stack);
+    } else {
+      CodeCache::old_nmethods_do(&md_on_stack);
+    }
     CompileBroker::mark_on_stack();
     JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack);
     ThreadService::metadata_do(Metadata::mark_on_stack);
--- a/src/hotspot/share/classfile/metadataOnStackMark.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/metadataOnStackMark.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -48,7 +48,7 @@
   static void retire_buffer(MetadataOnStackBuffer* buffer);
 
  public:
-  MetadataOnStackMark(bool redefinition_walk);
+  MetadataOnStackMark(bool walk_all_metadata, bool redefinition_walk);
    ~MetadataOnStackMark();
 
   static void record(Metadata* m);
--- a/src/hotspot/share/classfile/moduleEntry.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/moduleEntry.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "jni.h"
+#include "classfile/classLoader.hpp"
 #include "classfile/classLoaderData.inline.hpp"
 #include "classfile/javaClasses.inline.hpp"
 #include "classfile/moduleEntry.hpp"
--- a/src/hotspot/share/classfile/protectionDomainCache.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/protectionDomainCache.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -45,7 +45,7 @@
 }
 
 ProtectionDomainCacheTable::ProtectionDomainCacheTable(int table_size)
-  : Hashtable<ClassLoaderWeakHandle, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
+  : Hashtable<WeakHandle<vm_class_loader_data>, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
 {   _dead_entries = false;
     _total_oops_removed = 0;
 }
@@ -180,8 +180,8 @@
     protection_domain->print_value_on(&ls);
     ls.cr();
   }
-  ClassLoaderWeakHandle w = ClassLoaderWeakHandle::create(protection_domain);
+  WeakHandle<vm_class_loader_data> w = WeakHandle<vm_class_loader_data>::create(protection_domain);
   ProtectionDomainCacheEntry* p = new_entry(hash, w);
-  Hashtable<ClassLoaderWeakHandle, mtClass>::add_entry(index, p);
+  Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::add_entry(index, p);
   return p;
 }
--- a/src/hotspot/share/classfile/protectionDomainCache.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/protectionDomainCache.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -35,18 +35,18 @@
 // to dictionary.hpp pd_set for more information about how protection domain entries
 // are used.
 // This table is walked during GC, rather than the class loader data graph dictionaries.
-class ProtectionDomainCacheEntry : public HashtableEntry<ClassLoaderWeakHandle, mtClass> {
+class ProtectionDomainCacheEntry : public HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass> {
   friend class VMStructs;
  public:
   oop object();
   oop object_no_keepalive();
 
   ProtectionDomainCacheEntry* next() {
-    return (ProtectionDomainCacheEntry*)HashtableEntry<ClassLoaderWeakHandle, mtClass>::next();
+    return (ProtectionDomainCacheEntry*)HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass>::next();
   }
 
   ProtectionDomainCacheEntry** next_addr() {
-    return (ProtectionDomainCacheEntry**)HashtableEntry<ClassLoaderWeakHandle, mtClass>::next_addr();
+    return (ProtectionDomainCacheEntry**)HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass>::next_addr();
   }
 
   void verify();
@@ -61,21 +61,21 @@
 // we only need to iterate over this set.
 // The amount of different protection domains used is typically magnitudes smaller
 // than the number of system dictionary entries (loaded classes).
-class ProtectionDomainCacheTable : public Hashtable<ClassLoaderWeakHandle, mtClass> {
+class ProtectionDomainCacheTable : public Hashtable<WeakHandle<vm_class_loader_data>, mtClass> {
   friend class VMStructs;
 private:
   ProtectionDomainCacheEntry* bucket(int i) const {
-    return (ProtectionDomainCacheEntry*) Hashtable<ClassLoaderWeakHandle, mtClass>::bucket(i);
+    return (ProtectionDomainCacheEntry*) Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::bucket(i);
   }
 
   // The following method is not MT-safe and must be done under lock.
   ProtectionDomainCacheEntry** bucket_addr(int i) {
-    return (ProtectionDomainCacheEntry**) Hashtable<ClassLoaderWeakHandle, mtClass>::bucket_addr(i);
+    return (ProtectionDomainCacheEntry**) Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::bucket_addr(i);
   }
 
-  ProtectionDomainCacheEntry* new_entry(unsigned int hash, ClassLoaderWeakHandle protection_domain) {
+  ProtectionDomainCacheEntry* new_entry(unsigned int hash, WeakHandle<vm_class_loader_data> protection_domain) {
     ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*)
-      Hashtable<ClassLoaderWeakHandle, mtClass>::new_entry(hash, protection_domain);
+      Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::new_entry(hash, protection_domain);
     return entry;
   }
 
--- a/src/hotspot/share/classfile/stringTable.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/stringTable.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -52,6 +52,7 @@
 #include "utilities/concurrentHashTable.inline.hpp"
 #include "utilities/concurrentHashTableTasks.inline.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/utf8.hpp"
 
 // We prefer short chains of avg 2
 const double PREF_AVG_LIST_LEN = 2.0;
@@ -760,10 +761,6 @@
       return true;
     }
     unsigned int hash = java_lang_String::hash_code(s);
-    if (hash == 0) {
-      // We do not archive Strings with a 0 hashcode because ......
-      return true;
-    }
 
     java_lang_String::set_hash(s, hash);
     oop new_s = StringTable::create_archived_string(s, Thread::current());
--- a/src/hotspot/share/classfile/symbolTable.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/symbolTable.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -38,6 +38,7 @@
 #include "services/diagnosticCommand.hpp"
 #include "utilities/concurrentHashTable.inline.hpp"
 #include "utilities/concurrentHashTableTasks.inline.hpp"
+#include "utilities/utf8.hpp"
 
 // We used to not resize at all, so let's be conservative
 // and not set it too short before we decide to resize,
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -25,11 +25,12 @@
 #ifndef SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP
 #define SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP
 
-#include "classfile/classLoader.hpp"
+#include "classfile/classLoaderData.hpp"
 #include "jvmci/systemDictionary_jvmci.hpp"
 #include "oops/objArrayOop.hpp"
 #include "oops/symbol.hpp"
 #include "runtime/java.hpp"
+#include "runtime/mutexLocker.hpp"
 #include "runtime/reflectionUtils.hpp"
 #include "runtime/signature.hpp"
 #include "utilities/hashtable.hpp"
@@ -176,6 +177,7 @@
   do_klass(AssertionStatusDirectives_klass,             java_lang_AssertionStatusDirectives                   ) \
   do_klass(StringBuffer_klass,                          java_lang_StringBuffer                                ) \
   do_klass(StringBuilder_klass,                         java_lang_StringBuilder                               ) \
+  do_klass(UnsafeConstants_klass,                       jdk_internal_misc_UnsafeConstants                     ) \
   do_klass(internal_Unsafe_klass,                       jdk_internal_misc_Unsafe                              ) \
   do_klass(module_Modules_klass,                        jdk_internal_module_Modules                           ) \
                                                                                                                 \
--- a/src/hotspot/share/classfile/systemDictionaryShared.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/systemDictionaryShared.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -27,6 +27,7 @@
 
 #include "oops/klass.hpp"
 #include "classfile/dictionary.hpp"
+#include "classfile/packageEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "memory/filemap.hpp"
 
--- a/src/hotspot/share/classfile/verifier.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/verifier.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "jvm.h"
 #include "classfile/classFileStream.hpp"
+#include "classfile/classLoader.hpp"
 #include "classfile/javaClasses.hpp"
 #include "classfile/stackMapTable.hpp"
 #include "classfile/stackMapFrame.hpp"
@@ -2059,7 +2060,9 @@
   ss.vprint(msg, va);
   va_end(va);
   if (!_method.is_null()) {
-    ss.print(" in method %s", _method->name_and_sig_as_C_string());
+    ss.print(" in method '");
+    _method->print_external_name(&ss);
+    ss.print("'");
   }
   _message = ss.as_string();
 }
--- a/src/hotspot/share/classfile/vmSymbols.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/classfile/vmSymbols.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -25,7 +25,6 @@
 #ifndef SHARE_CLASSFILE_VMSYMBOLS_HPP
 #define SHARE_CLASSFILE_VMSYMBOLS_HPP
 
-#include "classfile/moduleEntry.hpp"
 #include "jfr/support/jfrIntrinsics.hpp"
 #include "jvmci/vmSymbols_jvmci.hpp"
 #include "memory/iterator.hpp"
@@ -52,7 +51,7 @@
 
 #define VM_SYMBOLS_DO(template, do_alias)                                                         \
   /* commonly used class, package, module names */                                                \
-  template(java_base,                                 JAVA_BASE_NAME)                             \
+  template(java_base,                                 "java.base")                                \
   template(java_lang_System,                          "java/lang/System")                         \
   template(java_lang_Object,                          "java/lang/Object")                         \
   template(java_lang_Class,                           "java/lang/Class")                          \
@@ -447,6 +446,10 @@
   template(module_entry_name,                         "module_entry")                             \
   template(resolved_references_name,                  "<resolved_references>")                    \
   template(init_lock_name,                            "<init_lock>")                              \
+  template(address_size_name,                         "ADDRESS_SIZE0")                            \
+  template(page_size_name,                            "PAGE_SIZE")                                \
+  template(big_endian_name,                           "BIG_ENDIAN")                               \
+  template(use_unaligned_access_name,                 "UNALIGNED_ACCESS")                         \
                                                                                                   \
   /* name symbols needed by intrinsics */                                                         \
   VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, template, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE) \
@@ -1071,6 +1074,9 @@
   do_intrinsic(_updateByteBufferAdler32,  java_util_zip_Adler32,  updateByteBuffer_A_name,  updateByteBuffer_signature,  F_SN) \
    do_name(     updateByteBuffer_A_name,                          "updateByteBuffer")                                   \
                                                                                                                         \
+  /* support for UnsafeConstants */                                                                                     \
+  do_class(jdk_internal_misc_UnsafeConstants,      "jdk/internal/misc/UnsafeConstants")                                 \
+                                                                                                                        \
   /* support for Unsafe */                                                                                              \
   do_class(jdk_internal_misc_Unsafe,               "jdk/internal/misc/Unsafe")                                          \
                                                                                                                         \
--- a/src/hotspot/share/code/codeCache.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/code/codeCache.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -780,13 +780,14 @@
 CodeCache::UnloadingScope::UnloadingScope(BoolObjectClosure* is_alive)
   : _is_unloading_behaviour(is_alive)
 {
+  _saved_behaviour = IsUnloadingBehaviour::current();
   IsUnloadingBehaviour::set_current(&_is_unloading_behaviour);
   increment_unloading_cycle();
   DependencyContext::cleaning_start();
 }
 
 CodeCache::UnloadingScope::~UnloadingScope() {
-  IsUnloadingBehaviour::set_current(NULL);
+  IsUnloadingBehaviour::set_current(_saved_behaviour);
   DependencyContext::cleaning_end();
 }
 
@@ -1032,43 +1033,77 @@
 #endif
 }
 
+#ifdef INCLUDE_JVMTI
+// RedefineClasses support for unloading nmethods that are dependent on "old" methods.
+// We don't really expect this table to grow very large.  If it does, it can become a hashtable.
+static GrowableArray<CompiledMethod*>* old_compiled_method_table = NULL;
+
+static void add_to_old_table(CompiledMethod* c) {
+  if (old_compiled_method_table == NULL) {
+    old_compiled_method_table = new (ResourceObj::C_HEAP, mtCode) GrowableArray<CompiledMethod*>(100, true);
+  }
+  old_compiled_method_table->push(c);
+}
+
+static void reset_old_method_table() {
+  if (old_compiled_method_table != NULL) {
+    delete old_compiled_method_table;
+    old_compiled_method_table = NULL;
+  }
+}
+
+// Remove this method when zombied or unloaded.
+void CodeCache::unregister_old_nmethod(CompiledMethod* c) {
+  assert_locked_or_safepoint(CodeCache_lock);
+  if (old_compiled_method_table != NULL) {
+    int index = old_compiled_method_table->find(c);
+    if (index != -1) {
+      old_compiled_method_table->delete_at(index);
+    }
+  }
+}
+
+void CodeCache::old_nmethods_do(MetadataClosure* f) {
+  // Walk old method table and mark those on stack.
+  int length = 0;
+  if (old_compiled_method_table != NULL) {
+    length = old_compiled_method_table->length();
+    for (int i = 0; i < length; i++) {
+      old_compiled_method_table->at(i)->metadata_do(f);
+    }
+  }
+  log_debug(redefine, class, nmethod)("Walked %d nmethods for mark_on_stack", length);
+}
+
 // Just marks the methods in this class as needing deoptimization
 void CodeCache::mark_for_evol_deoptimization(InstanceKlass* dependee) {
-  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-
-  // Deoptimize all methods of the evolving class itself
-  Array<Method*>* old_methods = dependee->methods();
-  for (int i = 0; i < old_methods->length(); i++) {
-    ResourceMark rm;
-    Method* old_method = old_methods->at(i);
-    CompiledMethod* nm = old_method->code();
-    if (nm != NULL) {
-      nm->mark_for_deoptimization();
-    }
-  }
+  assert(SafepointSynchronize::is_at_safepoint(), "Can only do this at a safepoint!");
 
   // Mark dependent AOT nmethods, which are only found via the class redefined.
+  // TODO: add dependencies to aotCompiledMethod's metadata section so this isn't
+  // needed.
   AOTLoader::mark_evol_dependent_methods(dependee);
 }
 
+
 // Walk compiled methods and mark dependent methods for deoptimization.
 int CodeCache::mark_dependents_for_evol_deoptimization() {
+  assert(SafepointSynchronize::is_at_safepoint(), "Can only do this at a safepoint!");
+  // Each redefinition creates a new set of nmethods that have references to "old" Methods
+  // So delete old method table and create a new one.
+  reset_old_method_table();
+
   int number_of_marked_CodeBlobs = 0;
   CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading);
   while(iter.next()) {
     CompiledMethod* nm = iter.method();
-    if (nm->is_marked_for_deoptimization()) {
-      // ...Already marked in the previous pass; count it here.
-      // Also counts AOT compiled methods, already marked.
+    // Walk all alive nmethods to check for old Methods.
+    // This includes methods whose inline caches point to old methods, so
+    // inline cache clearing is unnecessary.
+    if (nm->has_evol_metadata()) {
+      nm->mark_for_deoptimization();
+      add_to_old_table(nm);
       number_of_marked_CodeBlobs++;
-    } else if (nm->has_evol_metadata()) {
-      ResourceMark rm;
-      nm->mark_for_deoptimization();
-      number_of_marked_CodeBlobs++;
-    } else {
-      // Inline caches that refer to an nmethod are deoptimized already, because
-      // the Method* is walked in the metadata section of the nmethod.
-      assert(!nm->is_evol_dependent(), "should no longer be necessary");
     }
   }
 
@@ -1077,6 +1112,46 @@
   return number_of_marked_CodeBlobs;
 }
 
+void CodeCache::mark_all_nmethods_for_evol_deoptimization() {
+  assert(SafepointSynchronize::is_at_safepoint(), "Can only do this at a safepoint!");
+  CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading);
+  while(iter.next()) {
+    CompiledMethod* nm = iter.method();
+    if (!nm->method()->is_method_handle_intrinsic()) {
+      nm->mark_for_deoptimization();
+      if (nm->has_evol_metadata()) {
+        add_to_old_table(nm);
+      }
+    }
+  }
+}
+
+// Flushes compiled methods dependent on redefined classes, that have already been
+// marked for deoptimization.
+void CodeCache::flush_evol_dependents() {
+  assert(SafepointSynchronize::is_at_safepoint(), "Can only do this at a safepoint!");
+
+  // CodeCache can only be updated by a thread_in_VM and they will all be
+  // stopped during the safepoint so CodeCache will be safe to update without
+  // holding the CodeCache_lock.
+
+  // At least one nmethod has been marked for deoptimization
+
+  // All this already happens inside a VM_Operation, so we'll do all the work here.
+  // Stuff copied from VM_Deoptimize and modified slightly.
+
+  // We do not want any GCs to happen while we are in the middle of this VM operation
+  ResourceMark rm;
+  DeoptimizationMarker dm;
+
+  // Deoptimize all activations depending on marked nmethods
+  Deoptimization::deoptimize_dependents();
+
+  // Make the dependent methods not entrant
+  make_marked_nmethods_not_entrant();
+}
+#endif // INCLUDE_JVMTI
+
 // Deoptimize all methods
 void CodeCache::mark_all_nmethods_for_deoptimization() {
   MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
@@ -1137,32 +1212,6 @@
   }
 }
 
-// Flushes compiled methods dependent on redefined classes, that have already been
-// marked for deoptimization.
-void CodeCache::flush_evol_dependents() {
-  // --- Compile_lock is not held. However we are at a safepoint.
-  assert_locked_or_safepoint(Compile_lock);
-
-  // CodeCache can only be updated by a thread_in_VM and they will all be
-  // stopped during the safepoint so CodeCache will be safe to update without
-  // holding the CodeCache_lock.
-
-  // At least one nmethod has been marked for deoptimization
-
-  // All this already happens inside a VM_Operation, so we'll do all the work here.
-  // Stuff copied from VM_Deoptimize and modified slightly.
-
-  // We do not want any GCs to happen while we are in the middle of this VM operation
-  ResourceMark rm;
-  DeoptimizationMarker dm;
-
-  // Deoptimize all activations depending on marked nmethods
-  Deoptimization::deoptimize_dependents();
-
-  // Make the dependent methods not entrant
-  make_marked_nmethods_not_entrant();
-}
-
 // Flushes compiled methods dependent on dependee
 void CodeCache::flush_dependents_on_method(const methodHandle& m_h) {
   // --- Compile_lock is not held. However we are at a safepoint.
--- a/src/hotspot/share/code/codeCache.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/code/codeCache.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -170,6 +170,7 @@
   // "unloading_occurred" controls whether metadata should be cleaned because of class unloading.
   class UnloadingScope: StackObj {
     ClosureIsUnloadingBehaviour _is_unloading_behaviour;
+    IsUnloadingBehaviour*       _saved_behaviour;
 
   public:
     UnloadingScope(BoolObjectClosure* is_alive);
@@ -270,10 +271,16 @@
 
   // Flushing and deoptimization
   static void flush_dependents_on(InstanceKlass* dependee);
+
+  // RedefineClasses support
   // Flushing and deoptimization in case of evolution
   static void mark_for_evol_deoptimization(InstanceKlass* dependee);
   static int  mark_dependents_for_evol_deoptimization();
+  static void mark_all_nmethods_for_evol_deoptimization();
   static void flush_evol_dependents();
+  static void old_nmethods_do(MetadataClosure* f);
+  static void unregister_old_nmethod(CompiledMethod* c);
+
   // Support for fullspeed debugging
   static void flush_dependents_on_method(const methodHandle& dependee);
 
--- a/src/hotspot/share/code/compiledMethod.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/code/compiledMethod.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -368,7 +368,6 @@
   int  verify_icholder_relocations();
   void verify_oop_relocations();
 
-  virtual bool is_evol_dependent() = 0;
   bool has_evol_metadata();
 
   // Fast breakpoint support. Tells if this compiled method is
--- a/src/hotspot/share/code/nmethod.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/code/nmethod.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1106,6 +1106,7 @@
     MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : CodeCache_lock,
                      Mutex::_no_safepoint_check_flag);
     Universe::heap()->unregister_nmethod(this);
+    CodeCache::unregister_old_nmethod(this);
   }
 
   // Clear the method of this dead nmethod
@@ -1291,6 +1292,7 @@
       MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
       if (nmethod_needs_unregister) {
         Universe::heap()->unregister_nmethod(this);
+        CodeCache::unregister_old_nmethod(this);
       }
       flush_dependencies(/*delete_immediately*/true);
     }
@@ -1988,32 +1990,6 @@
   return found_check;
 }
 
-bool nmethod::is_evol_dependent() {
-  for (Dependencies::DepStream deps(this); deps.next(); ) {
-    if (deps.type() == Dependencies::evol_method) {
-      Method* method = deps.method_argument(0);
-      if (method->is_old()) {
-        if (log_is_enabled(Debug, redefine, class, nmethod)) {
-          ResourceMark rm;
-          log_debug(redefine, class, nmethod)
-            ("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on method %s.%s(%s)",
-             _method->method_holder()->external_name(),
-             _method->name()->as_C_string(),
-             _method->signature()->as_C_string(),
-             compile_id(),
-             method->method_holder()->external_name(),
-             method->name()->as_C_string(),
-             method->signature()->as_C_string());
-        }
-        if (TraceDependencies || LogCompilation)
-          deps.log_dependency(method->method_holder());
-        return true;
-      }
-    }
-  }
-  return false;
-}
-
 // Called from mark_for_deoptimization, when dependee is invalidated.
 bool nmethod::is_dependent_on_method(Method* dependee) {
   for (Dependencies::DepStream deps(this); deps.next(); ) {
--- a/src/hotspot/share/code/nmethod.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/code/nmethod.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -565,11 +565,6 @@
   // and the changes have invalidated it
   bool check_dependency_on(DepChange& changes);
 
-  // Evolution support. Tells if this compiled method is dependent on any of
-  // redefined methods, such that if m() is replaced,
-  // this compiled method will have to be deoptimized.
-  bool is_evol_dependent();
-
   // Fast breakpoint support. Tells if this compiled method is
   // dependent on the given method. Returns true if this nmethod
   // corresponds to the given method as well.
--- a/src/hotspot/share/compiler/compilerOracle.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/compiler/compilerOracle.cpp	Tue Apr 09 11:48:54 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
@@ -738,30 +738,6 @@
   parse_line(token);
 }
 
-void CompilerOracle::append_comment_to_file(const char* message) {
-  assert(has_command_file(), "command file must be specified");
-  fileStream stream(fopen(cc_file(), "at"));
-  stream.print("# ");
-  for (int index = 0; message[index] != '\0'; index++) {
-    stream.put(message[index]);
-    if (message[index] == '\n') stream.print("# ");
-  }
-  stream.cr();
-}
-
-void CompilerOracle::append_exclude_to_file(const methodHandle& method) {
-  assert(has_command_file(), "command file must be specified");
-  fileStream stream(fopen(cc_file(), "at"));
-  stream.print("exclude ");
-  method->method_holder()->name()->print_symbol_on(&stream);
-  stream.print(".");
-  method->name()->print_symbol_on(&stream);
-  method->signature()->print_symbol_on(&stream);
-  stream.cr();
-  stream.cr();
-}
-
-
 void compilerOracle_init() {
   CompilerOracle::parse_from_string(CompileCommand, CompilerOracle::parse_from_line);
   CompilerOracle::parse_from_string(CompileOnly, CompilerOracle::parse_compile_only);
--- a/src/hotspot/share/compiler/compilerOracle.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/compiler/compilerOracle.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -83,10 +83,6 @@
   static void parse_from_line(char* line);
   static void parse_compile_only(char * line);
 
-  // For updating the oracle file
-  static void append_comment_to_file(const char* message);
-  static void append_exclude_to_file(const methodHandle& method);
-
   // Tells whether there are any methods to print for print_method_statistics()
   static bool should_print_methods();
 };
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -24,8 +24,6 @@
 
 #include "precompiled.hpp"
 #include "classfile/classLoaderDataGraph.hpp"
-#include "classfile/stringTable.hpp"
-#include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "code/codeCache.hpp"
 #include "gc/cms/cmsCollectorPolicy.hpp"
@@ -54,7 +52,6 @@
 #include "gc/shared/genCollectedHeap.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "gc/shared/isGCActiveMark.hpp"
-#include "gc/shared/oopStorageParState.hpp"
 #include "gc/shared/owstTaskTerminator.hpp"
 #include "gc/shared/referencePolicy.hpp"
 #include "gc/shared/referenceProcessorPhaseTimes.hpp"
@@ -2771,12 +2768,10 @@
  protected:
   CMSCollector*     _collector;
   uint              _n_workers;
-  OopStorage::ParState<false, false> _par_state_string;
   CMSParMarkTask(const char* name, CMSCollector* collector, uint n_workers) :
       AbstractGangTask(name),
       _collector(collector),
-      _n_workers(n_workers),
-      _par_state_string(StringTable::weak_storage()) {}
+      _n_workers(n_workers) {}
   // Work method in support of parallel rescan ... of young gen spaces
   void do_young_space_rescan(OopsInGenClosure* cl,
                              ContiguousSpace* space,
--- a/src/hotspot/share/gc/cms/parNewGeneration.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/cms/parNewGeneration.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -582,8 +582,7 @@
     _young_gen(young_gen), _old_gen(old_gen),
     _young_old_boundary(young_old_boundary),
     _state_set(state_set),
-    _strong_roots_scope(strong_roots_scope),
-    _par_state_string(StringTable::weak_storage())
+    _strong_roots_scope(strong_roots_scope)
 {}
 
 void ParNewGenTask::work(uint worker_id) {
--- a/src/hotspot/share/gc/cms/parNewGeneration.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/cms/parNewGeneration.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -235,7 +235,6 @@
   HeapWord*                    _young_old_boundary;
   class ParScanThreadStateSet* _state_set;
   StrongRootsScope*            _strong_roots_scope;
-  OopStorage::ParState<false, false> _par_state_string;
 
 public:
   ParNewGenTask(ParNewGeneration*      young_gen,
--- a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -129,6 +129,12 @@
   virtual void print_gc_threads_on(outputStream* st) const {}
   virtual void gc_threads_do(ThreadClosure* tc) const {}
 
+  // No nmethod handling
+  virtual void register_nmethod(nmethod* nm) {}
+  virtual void unregister_nmethod(nmethod* nm) {}
+  virtual void flush_nmethod(nmethod* nm) {}
+  virtual void verify_nmethod(nmethod* nm) {}
+
   // No heap verification
   virtual void prepare_for_verify() {}
   virtual void verify(VerifyOption option) {}
--- a/src/hotspot/share/gc/g1/g1BarrierSet.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1BarrierSet.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -148,24 +148,7 @@
 
   // If we are creating the thread during a marking cycle, we should
   // set the active field of the SATB queue to true.  That involves
-  // copying the global is_active value to this thread's queue, which
-  // is done without any direct synchronization here.
-  //
-  // The activation and deactivation of the SATB queues occurs at the
-  // beginning / end of a marking cycle, and is done during
-  // safepoints.  This function is called just before a thread is
-  // added to its corresponding threads list (for Java or non-Java
-  // threads, respectively).
-  //
-  // For Java threads, that's done while holding the Threads_lock,
-  // which ensures we're not at a safepoint, so reading the global
-  // is_active state is synchronized against update.
-  assert(!thread->is_Java_thread() || !SafepointSynchronize::is_at_safepoint(),
-         "Should not be at a safepoint");
-  // For non-Java threads, thread creation (and list addition) may,
-  // and indeed usually does, occur during a safepoint.  But such
-  // creation isn't concurrent with updating the global SATB active
-  // state.
+  // copying the global is_active value to this thread's queue.
   bool is_satb_active = _satb_mark_queue_set.is_active();
   G1ThreadLocalData::satb_mark_queue(thread).set_active(is_satb_active);
 }
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -154,6 +154,11 @@
   reset_from_card_cache(start_idx, num_regions);
 }
 
+Tickspan G1CollectedHeap::run_task(AbstractGangTask* task) {
+  Ticks start = Ticks::now();
+  workers()->run_task(task, workers()->active_workers());
+  return Ticks::now() - start;
+}
 
 HeapRegion* G1CollectedHeap::new_heap_region(uint hrs_index,
                                              MemRegion mr) {
@@ -1575,7 +1580,10 @@
     //    And ReservedSpace calls it 'special'. If we failed to set 'special',
     //    we reserved memory without large page.
     if (os::can_commit_large_page_memory() || rs.special()) {
-      page_size = rs.alignment();
+      // An alignment at ReservedSpace comes from preferred page size or
+      // heap alignment, and if the alignment came from heap alignment, it could be
+      // larger than large pages size. So need to cap with the large page size.
+      page_size = MIN2(rs.alignment(), os::large_page_size());
     }
   }
 
@@ -2239,12 +2247,12 @@
   _hrm->par_iterate(cl, hrclaimer, 0);
 }
 
-void G1CollectedHeap::collection_set_iterate(HeapRegionClosure* cl) {
+void G1CollectedHeap::collection_set_iterate_all(HeapRegionClosure* cl) {
   _collection_set.iterate(cl);
 }
 
-void G1CollectedHeap::collection_set_iterate_from(HeapRegionClosure *cl, uint worker_id) {
-  _collection_set.iterate_from(cl, worker_id, workers()->active_workers());
+void G1CollectedHeap::collection_set_iterate_increment_from(HeapRegionClosure *cl, uint worker_id) {
+  _collection_set.iterate_incremental_part_from(cl, worker_id, workers()->active_workers());
 }
 
 HeapWord* G1CollectedHeap::block_start(const void* addr) const {
@@ -2481,7 +2489,7 @@
 
 void G1CollectedHeap::print_cset_rsets() {
   PrintRSetsClosure cl("Printing CSet RSets");
-  collection_set_iterate(&cl);
+  collection_set_iterate_all(&cl);
 }
 
 void G1CollectedHeap::print_all_rsets() {
@@ -2492,8 +2500,8 @@
 
 G1HeapSummary G1CollectedHeap::create_g1_heap_summary() {
 
-  size_t eden_used_bytes = heap()->eden_regions_count() * HeapRegion::GrainBytes;
-  size_t survivor_used_bytes = heap()->survivor_regions_count() * HeapRegion::GrainBytes;
+  size_t eden_used_bytes = _eden.used_bytes();
+  size_t survivor_used_bytes = _survivor.used_bytes();
   size_t heap_used = Heap_lock->owned_by_self() ? used() : used_unlocked();
 
   size_t eden_capacity_bytes =
@@ -2728,7 +2736,7 @@
           // The remembered set might contain references to already freed
           // regions. Filter out such entries to avoid failing card table
           // verification.
-          if (g1h->is_in_closed_subset(ct->addr_for(card_ptr))) {
+          if (g1h->is_in(ct->addr_for(card_ptr))) {
             if (*card_ptr != G1CardTable::dirty_card_val()) {
               *card_ptr = G1CardTable::dirty_card_val();
               _dcq.enqueue(card_ptr);
@@ -2877,15 +2885,18 @@
   phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
 }
 
-void G1CollectedHeap::calculate_collection_set(G1EvacuationInfo& evacuation_info, double target_pause_time_ms){
-  policy()->finalize_collection_set(target_pause_time_ms, &_survivor);
-  evacuation_info.set_collectionset_regions(collection_set()->region_length());
+void G1CollectedHeap::calculate_collection_set(G1EvacuationInfo& evacuation_info, double target_pause_time_ms) {
+
+  _collection_set.finalize_initial_collection_set(target_pause_time_ms, &_survivor);
+  evacuation_info.set_collectionset_regions(collection_set()->region_length() +
+                                            collection_set()->optional_region_length());
 
   _cm->verify_no_collection_set_oops();
 
   if (_hr_printer.is_active()) {
     G1PrintCollectionSetClosure cl(&_hr_printer);
     _collection_set.iterate(&cl);
+    _collection_set.iterate_optional(&cl);
   }
 }
 
@@ -3057,9 +3068,10 @@
         pre_evacuate_collection_set(evacuation_info);
 
         // Actually do the work...
-        evacuate_collection_set(&per_thread_states);
-        evacuate_optional_collection_set(&per_thread_states);
-
+        evacuate_initial_collection_set(&per_thread_states);
+        if (_collection_set.optional_region_length() != 0) {
+          evacuate_optional_collection_set(&per_thread_states);
+        }
         post_evacuate_collection_set(evacuation_info, &per_thread_states);
 
         start_new_collection_set();
@@ -3085,7 +3097,8 @@
 
         double sample_end_time_sec = os::elapsedTime();
         double pause_time_ms = (sample_end_time_sec - sample_start_time_sec) * MILLIUNITS;
-        size_t total_cards_scanned = phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ScanRSScannedCards);
+        size_t total_cards_scanned = phase_times()->sum_thread_work_items(G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ScanRSScannedCards) +
+                                     phase_times()->sum_thread_work_items(G1GCPhaseTimes::OptScanRS, G1GCPhaseTimes::ScanRSScannedCards);
         policy()->record_collection_pause_end(pause_time_ms, total_cards_scanned, heap_used_bytes_before_gc);
       }
 
@@ -3189,86 +3202,6 @@
   } while (!offer_termination());
 }
 
-class G1ParTask : public AbstractGangTask {
-protected:
-  G1CollectedHeap*         _g1h;
-  G1ParScanThreadStateSet* _pss;
-  RefToScanQueueSet*       _queues;
-  G1RootProcessor*         _root_processor;
-  TaskTerminator           _terminator;
-  uint                     _n_workers;
-
-public:
-  G1ParTask(G1CollectedHeap* g1h, G1ParScanThreadStateSet* per_thread_states, RefToScanQueueSet *task_queues, G1RootProcessor* root_processor, uint n_workers)
-    : AbstractGangTask("G1 collection"),
-      _g1h(g1h),
-      _pss(per_thread_states),
-      _queues(task_queues),
-      _root_processor(root_processor),
-      _terminator(n_workers, _queues),
-      _n_workers(n_workers)
-  {}
-
-  void work(uint worker_id) {
-    if (worker_id >= _n_workers) return;  // no work needed this round
-
-    double start_sec = os::elapsedTime();
-    _g1h->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, start_sec);
-
-    {
-      ResourceMark rm;
-      HandleMark   hm;
-
-      ReferenceProcessor*             rp = _g1h->ref_processor_stw();
-
-      G1ParScanThreadState*           pss = _pss->state_for_worker(worker_id);
-      pss->set_ref_discoverer(rp);
-
-      double start_strong_roots_sec = os::elapsedTime();
-
-      _root_processor->evacuate_roots(pss, worker_id);
-
-      _g1h->rem_set()->oops_into_collection_set_do(pss, worker_id);
-
-      double strong_roots_sec = os::elapsedTime() - start_strong_roots_sec;
-
-      double term_sec = 0.0;
-      size_t evac_term_attempts = 0;
-      {
-        double start = os::elapsedTime();
-        G1ParEvacuateFollowersClosure evac(_g1h, pss, _queues, _terminator.terminator(), G1GCPhaseTimes::ObjCopy);
-        evac.do_void();
-
-        evac_term_attempts = evac.term_attempts();
-        term_sec = evac.term_time();
-        double elapsed_sec = os::elapsedTime() - start;
-
-        G1GCPhaseTimes* p = _g1h->phase_times();
-        p->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_id, elapsed_sec - term_sec);
-
-        p->record_or_add_thread_work_item(G1GCPhaseTimes::ObjCopy,
-                                          worker_id,
-                                          pss->lab_waste_words() * HeapWordSize,
-                                          G1GCPhaseTimes::ObjCopyLABWaste);
-        p->record_or_add_thread_work_item(G1GCPhaseTimes::ObjCopy,
-                                          worker_id,
-                                          pss->lab_undo_waste_words() * HeapWordSize,
-                                          G1GCPhaseTimes::ObjCopyLABUndoWaste);
-
-        p->record_time_secs(G1GCPhaseTimes::Termination, worker_id, term_sec);
-        p->record_thread_work_item(G1GCPhaseTimes::Termination, worker_id, evac_term_attempts);
-      }
-
-      assert(pss->queue_is_empty(), "should be empty");
-
-      // Close the inner scope so that the ResourceMark and HandleMark
-      // destructors are executed here and are included as part of the
-      // "GC Worker Time".
-    }
-    _g1h->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerEnd, worker_id, os::elapsedTime());
-  }
-};
-
 void G1CollectedHeap::complete_cleaning(BoolObjectClosure* is_alive,
                                         bool class_unloading_occurred) {
   uint num_workers = workers()->active_workers();
@@ -3672,176 +3605,196 @@
     double recorded_clear_claimed_marks_time_ms = (os::elapsedTime() - start_clear_claimed_marks) * 1000.0;
     phase_times()->record_clear_claimed_marks_time_ms(recorded_clear_claimed_marks_time_ms);
   }
-}
-
-void G1CollectedHeap::evacuate_collection_set(G1ParScanThreadStateSet* per_thread_states) {
+
   // Should G1EvacuationFailureALot be in effect for this GC?
   NOT_PRODUCT(set_evacuation_failure_alot_for_current_gc();)
 
   assert(dirty_card_queue_set().completed_buffers_num() == 0, "Should be empty");
-
-  double start_par_time_sec = os::elapsedTime();
-  double end_par_time_sec;
-
-  {
-    const uint n_workers = workers()->active_workers();
-    G1RootProcessor root_processor(this, n_workers);
-    G1ParTask g1_par_task(this, per_thread_states, _task_queues, &root_processor, n_workers);
-
-    workers()->run_task(&g1_par_task);
-    end_par_time_sec = os::elapsedTime();
-
-    // Closing the inner scope will execute the destructor
-    // for the G1RootProcessor object. We record the current
-    // elapsed time before closing the scope so that time
-    // taken for the destructor is NOT included in the
-    // reported parallel time.
-  }
-
-  double par_time_ms = (end_par_time_sec - start_par_time_sec) * 1000.0;
-  phase_times()->record_par_time(par_time_ms);
-
-  double code_root_fixup_time_ms =
-        (os::elapsedTime() - end_par_time_sec) * 1000.0;
-  phase_times()->record_code_root_fixup_time(code_root_fixup_time_ms);
 }
 
-class G1EvacuateOptionalRegionTask : public AbstractGangTask {
+class G1EvacuateRegionsBaseTask : public AbstractGangTask {
+protected:
   G1CollectedHeap* _g1h;
   G1ParScanThreadStateSet* _per_thread_states;
-  G1OptionalCSet* _optional;
-  RefToScanQueueSet* _queues;
-  ParallelTaskTerminator _terminator;
-
-  Tickspan trim_ticks(G1ParScanThreadState* pss) {
-    Tickspan copy_time = pss->trim_ticks();
-    pss->reset_trim_ticks();
-    return copy_time;
+  RefToScanQueueSet* _task_queues;
+  TaskTerminator _terminator;
+  uint _num_workers;
+
+  void evacuate_live_objects(G1ParScanThreadState* pss,
+                             uint worker_id,
+                             G1GCPhaseTimes::GCParPhases objcopy_phase,
+                             G1GCPhaseTimes::GCParPhases termination_phase) {
+    G1GCPhaseTimes* p = _g1h->phase_times();
+
+    Ticks start = Ticks::now();
+    G1ParEvacuateFollowersClosure cl(_g1h, pss, _task_queues, _terminator.terminator(), objcopy_phase);
+    cl.do_void();
+
+    assert(pss->queue_is_empty(), "should be empty");
+
+    Tickspan evac_time = (Ticks::now() - start);
+    p->record_or_add_time_secs(objcopy_phase, worker_id, evac_time.seconds() - cl.term_time());
+
+    p->record_or_add_thread_work_item(objcopy_phase, worker_id, pss->lab_waste_words() * HeapWordSize, G1GCPhaseTimes::ObjCopyLABWaste);
+    p->record_or_add_thread_work_item(objcopy_phase, worker_id, pss->lab_undo_waste_words() * HeapWordSize, G1GCPhaseTimes::ObjCopyLABUndoWaste);
+
+    if (termination_phase == G1GCPhaseTimes::Termination) {
+      p->record_time_secs(termination_phase, worker_id, cl.term_time());
+      p->record_thread_work_item(termination_phase, worker_id, cl.term_attempts());
+    } else {
+      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) { }
+
+  virtual void end_work(uint worker_id) { }
+
+  virtual void scan_roots(G1ParScanThreadState* pss, uint worker_id) = 0;
+
+  virtual void evacuate_live_objects(G1ParScanThreadState* pss, uint worker_id) = 0;
+
+public:
+  G1EvacuateRegionsBaseTask(const char* name, G1ParScanThreadStateSet* per_thread_states, RefToScanQueueSet* task_queues, uint num_workers) :
+    AbstractGangTask(name),
+    _g1h(G1CollectedHeap::heap()),
+    _per_thread_states(per_thread_states),
+    _task_queues(task_queues),
+    _terminator(num_workers, _task_queues),
+    _num_workers(num_workers)
+  { }
+
+  void work(uint worker_id) {
+    start_work(worker_id);
+
+    {
+      ResourceMark rm;
+      HandleMark   hm;
+
+      G1ParScanThreadState* pss = _per_thread_states->state_for_worker(worker_id);
+      pss->set_ref_discoverer(_g1h->ref_processor_stw());
+
+      scan_roots(pss, worker_id);
+      evacuate_live_objects(pss, worker_id);
+    }
+
+    end_work(worker_id);
+  }
+};
+
+class G1EvacuateRegionsTask : public G1EvacuateRegionsBaseTask {
+  G1RootProcessor* _root_processor;
+
   void scan_roots(G1ParScanThreadState* pss, uint worker_id) {
-    G1EvacuationRootClosures* root_cls = pss->closures();
-    G1ScanObjsDuringScanRSClosure obj_cl(_g1h, pss);
-
-    size_t scanned = 0;
-    size_t claimed = 0;
-    size_t skipped = 0;
-    size_t used_memory = 0;
-
-    Ticks    start = Ticks::now();
-    Tickspan copy_time;
-
-    for (uint i = _optional->current_index(); i < _optional->current_limit(); i++) {
-      HeapRegion* hr = _optional->region_at(i);
-      G1ScanRSForOptionalClosure scan_opt_cl(&obj_cl);
-      pss->oops_into_optional_region(hr)->oops_do(&scan_opt_cl, root_cls->raw_strong_oops());
-      copy_time += trim_ticks(pss);
-
-      G1ScanRSForRegionClosure scan_rs_cl(_g1h->rem_set()->scan_state(), &obj_cl, pss, G1GCPhaseTimes::OptScanRS, worker_id);
-      scan_rs_cl.do_heap_region(hr);
-      copy_time += trim_ticks(pss);
-      scanned += scan_rs_cl.cards_scanned();
-      claimed += scan_rs_cl.cards_claimed();
-      skipped += scan_rs_cl.cards_skipped();
-
-      // Chunk lists for this region is no longer needed.
-      used_memory += pss->oops_into_optional_region(hr)->used_memory();
-    }
-
-    Tickspan scan_time = (Ticks::now() - start) - copy_time;
-    G1GCPhaseTimes* p = _g1h->phase_times();
-    p->record_or_add_time_secs(G1GCPhaseTimes::OptScanRS, worker_id, scan_time.seconds());
-    p->record_or_add_time_secs(G1GCPhaseTimes::OptObjCopy, worker_id, copy_time.seconds());
-
-    p->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_id, scanned, G1GCPhaseTimes::OptCSetScannedCards);
-    p->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_id, claimed, G1GCPhaseTimes::OptCSetClaimedCards);
-    p->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_id, skipped, G1GCPhaseTimes::OptCSetSkippedCards);
-    p->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_id, used_memory, G1GCPhaseTimes::OptCSetUsedMemory);
+    _root_processor->evacuate_roots(pss, worker_id);
+    _g1h->rem_set()->update_rem_set(pss, worker_id);
+    _g1h->rem_set()->scan_rem_set(pss, worker_id, G1GCPhaseTimes::ScanRS, G1GCPhaseTimes::ObjCopy, G1GCPhaseTimes::CodeRoots);
   }
 
   void evacuate_live_objects(G1ParScanThreadState* pss, uint worker_id) {
-    Ticks start = Ticks::now();
-    G1ParEvacuateFollowersClosure cl(_g1h, pss, _queues, &_terminator, G1GCPhaseTimes::OptObjCopy);
-    cl.do_void();
-
-    Tickspan evac_time = (Ticks::now() - start);
-    G1GCPhaseTimes* p = _g1h->phase_times();
-    p->record_or_add_time_secs(G1GCPhaseTimes::OptObjCopy, worker_id, evac_time.seconds());
-    assert(pss->trim_ticks().seconds() == 0.0, "Unexpected partial trimming done during optional evacuation");
+    G1EvacuateRegionsBaseTask::evacuate_live_objects(pss, worker_id, G1GCPhaseTimes::ObjCopy, G1GCPhaseTimes::Termination);
+  }
+
+  void start_work(uint worker_id) {
+    _g1h->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, Ticks::now().seconds());
+  }
+
+  void end_work(uint worker_id) {
+    _g1h->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerEnd, worker_id, Ticks::now().seconds());
   }
 
- public:
-  G1EvacuateOptionalRegionTask(G1CollectedHeap* g1h,
-                               G1ParScanThreadStateSet* per_thread_states,
-                               G1OptionalCSet* cset,
-                               RefToScanQueueSet* queues,
-                               uint n_workers) :
-    AbstractGangTask("G1 Evacuation Optional Region Task"),
-    _g1h(g1h),
-    _per_thread_states(per_thread_states),
-    _optional(cset),
-    _queues(queues),
-    _terminator(n_workers, _queues) {
+public:
+  G1EvacuateRegionsTask(G1CollectedHeap* g1h,
+                        G1ParScanThreadStateSet* per_thread_states,
+                        RefToScanQueueSet* task_queues,
+                        G1RootProcessor* root_processor,
+                        uint num_workers) :
+    G1EvacuateRegionsBaseTask("G1 Evacuate Regions", per_thread_states, task_queues, num_workers),
+    _root_processor(root_processor)
+  { }
+};
+
+void G1CollectedHeap::evacuate_initial_collection_set(G1ParScanThreadStateSet* per_thread_states) {
+  Tickspan task_time;
+  const uint num_workers = workers()->active_workers();
+
+  Ticks start_processing = Ticks::now();
+  {
+    G1RootProcessor root_processor(this, num_workers);
+    G1EvacuateRegionsTask g1_par_task(this, per_thread_states, _task_queues, &root_processor, num_workers);
+    task_time = run_task(&g1_par_task);
+    // Closing the inner scope will execute the destructor for the G1RootProcessor object.
+    // To extract its code root fixup time we measure total time of this scope and
+    // subtract from the time the WorkGang task took.
   }
-
-  void work(uint worker_id) {
-    ResourceMark rm;
-    HandleMark  hm;
-
-    G1ParScanThreadState* pss = _per_thread_states->state_for_worker(worker_id);
-    pss->set_ref_discoverer(_g1h->ref_processor_stw());
-
-    scan_roots(pss, worker_id);
-    evacuate_live_objects(pss, worker_id);
+  Tickspan total_processing = Ticks::now() - start_processing;
+
+  G1GCPhaseTimes* p = phase_times();
+  p->record_initial_evac_time(task_time.seconds() * 1000.0);
+  p->record_or_add_code_root_fixup_time((total_processing - task_time).seconds() * 1000.0);
+}
+
+class G1EvacuateOptionalRegionsTask : public G1EvacuateRegionsBaseTask {
+
+  void scan_roots(G1ParScanThreadState* pss, uint worker_id) {
+    _g1h->rem_set()->scan_rem_set(pss, worker_id, G1GCPhaseTimes::OptScanRS, G1GCPhaseTimes::OptObjCopy, G1GCPhaseTimes::OptCodeRoots);
+  }
+
+  void evacuate_live_objects(G1ParScanThreadState* pss, uint worker_id) {
+    G1EvacuateRegionsBaseTask::evacuate_live_objects(pss, worker_id, G1GCPhaseTimes::OptObjCopy, G1GCPhaseTimes::OptTermination);
+  }
+
+public:
+  G1EvacuateOptionalRegionsTask(G1ParScanThreadStateSet* per_thread_states,
+                                RefToScanQueueSet* queues,
+                                uint num_workers) :
+    G1EvacuateRegionsBaseTask("G1 Evacuate Optional Regions", per_thread_states, queues, num_workers) {
   }
 };
 
-void G1CollectedHeap::evacuate_optional_regions(G1ParScanThreadStateSet* per_thread_states, G1OptionalCSet* ocset) {
-  class G1MarkScope : public MarkScope {};
-  G1MarkScope code_mark_scope;
-
-  G1EvacuateOptionalRegionTask task(this, per_thread_states, ocset, _task_queues, workers()->active_workers());
-  workers()->run_task(&task);
+void G1CollectedHeap::evacuate_next_optional_regions(G1ParScanThreadStateSet* per_thread_states) {
+  class G1MarkScope : public MarkScope { };
+
+  Tickspan task_time;
+
+  Ticks start_processing = Ticks::now();
+  {
+    G1MarkScope code_mark_scope;
+    G1EvacuateOptionalRegionsTask task(per_thread_states, _task_queues, workers()->active_workers());
+    task_time = run_task(&task);
+    // See comment in evacuate_collection_set() for the reason of the scope.
+  }
+  Tickspan total_processing = Ticks::now() - start_processing;
+
+  G1GCPhaseTimes* p = phase_times();
+  p->record_or_add_code_root_fixup_time((total_processing - task_time).seconds() * 1000.0);
 }
 
 void G1CollectedHeap::evacuate_optional_collection_set(G1ParScanThreadStateSet* per_thread_states) {
-  G1OptionalCSet optional_cset(&_collection_set, per_thread_states);
-  if (optional_cset.is_empty()) {
-    return;
-  }
-
-  if (evacuation_failed()) {
-    return;
-  }
-
   const double gc_start_time_ms = phase_times()->cur_collection_start_sec() * 1000.0;
 
-  double start_time_sec = os::elapsedTime();
-
-  do {
+  Ticks start = Ticks::now();
+
+  while (!evacuation_failed() && _collection_set.optional_region_length() > 0) {
+
     double time_used_ms = os::elapsedTime() * 1000.0 - gc_start_time_ms;
     double time_left_ms = MaxGCPauseMillis - time_used_ms;
 
-    if (time_left_ms < 0) {
-      log_trace(gc, ergo, cset)("Skipping %u optional regions, pause time exceeded %.3fms", optional_cset.size(), time_used_ms);
-      break;
-    }
-
-    optional_cset.prepare_evacuation(time_left_ms * _policy->optional_evacuation_fraction());
-    if (optional_cset.prepare_failed()) {
-      log_trace(gc, ergo, cset)("Skipping %u optional regions, no regions can be evacuated in %.3fms", optional_cset.size(), time_left_ms);
+    if (time_left_ms < 0 ||
+        !_collection_set.finalize_optional_for_evacuation(time_left_ms * policy()->optional_evacuation_fraction())) {
+      log_trace(gc, ergo, cset)("Skipping evacuation of %u optional regions, no more regions can be evacuated in %.3fms",
+                                _collection_set.optional_region_length(), time_left_ms);
       break;
     }
 
-    evacuate_optional_regions(per_thread_states, &optional_cset);
-
-    optional_cset.complete_evacuation();
-    if (optional_cset.evacuation_failed()) {
-      break;
-    }
-  } while (!optional_cset.is_empty());
-
-  phase_times()->record_optional_evacuation((os::elapsedTime() - start_time_sec) * 1000.0);
+    evacuate_next_optional_regions(per_thread_states);
+  }
+
+  _collection_set.abandon_optional_collection_set(per_thread_states);
+
+  phase_times()->record_or_add_optional_evac_time((Ticks::now() - start).seconds() * 1000.0);
 }
 
 void G1CollectedHeap::post_evacuate_collection_set(G1EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) {
@@ -4256,15 +4209,14 @@
   double free_cset_start_time = os::elapsedTime();
 
   {
-    uint const num_chunks = MAX2(_collection_set.region_length() / G1FreeCollectionSetTask::chunk_size(), 1U);
+    uint const num_regions = _collection_set.region_length();
+    uint const num_chunks = MAX2(num_regions / G1FreeCollectionSetTask::chunk_size(), 1U);
     uint const num_workers = MIN2(workers()->active_workers(), num_chunks);
 
     G1FreeCollectionSetTask cl(collection_set, &evacuation_info, surviving_young_words);
 
     log_debug(gc, ergo)("Running %s using %u workers for collection set length %u",
-                        cl.name(),
-                        num_workers,
-                        _collection_set.region_length());
+                        cl.name(), num_workers, num_regions);
     workers()->run_task(&cl, num_workers);
   }
   phase_times()->record_total_free_cset_time_ms((os::elapsedTime() - free_cset_start_time) * 1000.0);
@@ -4433,7 +4385,7 @@
 
 void G1CollectedHeap::abandon_collection_set(G1CollectionSet* collection_set) {
   G1AbandonCollectionSetClosure cl;
-  collection_set->iterate(&cl);
+  collection_set_iterate_all(&cl);
 
   collection_set->clear();
   collection_set->stop_incremental_building();
@@ -4605,11 +4557,6 @@
          used(), recalculate_used());
 }
 
-bool G1CollectedHeap::is_in_closed_subset(const void* p) const {
-  HeapRegion* hr = heap_region_containing(p);
-  return hr->is_in(p);
-}
-
 // Methods for the mutator alloc region
 
 HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size,
@@ -4638,7 +4585,9 @@
 
   collection_set()->add_eden_region(alloc_region);
   increase_used(allocated_bytes);
+  _eden.add_used_bytes(allocated_bytes);
   _hr_printer.retire(alloc_region);
+
   // We update the eden sizes here, when the region is retired,
   // instead of when it's allocated, since this is the point that its
   // used space has been recorded in _summary_bytes_used.
@@ -4695,6 +4644,9 @@
   policy()->record_bytes_copied_during_gc(allocated_bytes);
   if (dest.is_old()) {
     old_set_add(alloc_region);
+  } else {
+    assert(dest.is_young(), "Retiring alloc region should be young(%d)", dest.value());
+    _survivor.add_used_bytes(allocated_bytes);
   }
 
   bool const during_im = collector_state()->in_initial_mark_gc();
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -143,9 +143,8 @@
   // Closures used in implementation.
   friend class G1ParScanThreadState;
   friend class G1ParScanThreadStateSet;
-  friend class G1ParTask;
+  friend class G1EvacuateRegionsTask;
   friend class G1PLABAllocator;
-  friend class G1PrepareCompactClosure;
 
   // Other related classes.
   friend class HeapRegionClaimer;
@@ -206,7 +205,7 @@
 
   // Outside of GC pauses, the number of bytes used in all regions other
   // than the current allocation region(s).
-  size_t _summary_bytes_used;
+  volatile size_t _summary_bytes_used;
 
   void increase_used(size_t bytes);
   void decrease_used(size_t bytes);
@@ -519,6 +518,10 @@
 
   WorkGang* workers() const { return _workers; }
 
+  // Runs the given AbstractGangTask with the current active workers, returning the
+  // total time taken.
+  Tickspan run_task(AbstractGangTask* task);
+
   G1Allocator* allocator() {
     return _allocator;
   }
@@ -738,11 +741,14 @@
 
   void calculate_collection_set(G1EvacuationInfo& evacuation_info, double target_pause_time_ms);
 
-  // Actually do the work of evacuating the collection set.
-  void evacuate_collection_set(G1ParScanThreadStateSet* per_thread_states);
+  // Actually do the work of evacuating the parts of the collection set.
+  void evacuate_initial_collection_set(G1ParScanThreadStateSet* per_thread_states);
   void evacuate_optional_collection_set(G1ParScanThreadStateSet* per_thread_states);
-  void evacuate_optional_regions(G1ParScanThreadStateSet* per_thread_states, G1OptionalCSet* ocset);
+private:
+  // Evacuate the next set of optional regions.
+  void evacuate_next_optional_regions(G1ParScanThreadStateSet* per_thread_states);
 
+public:
   void pre_evacuate_collection_set(G1EvacuationInfo& evacuation_info);
   void post_evacuate_collection_set(G1EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* pss);
 
@@ -1119,8 +1125,6 @@
     return _hrm->reserved();
   }
 
-  virtual bool is_in_closed_subset(const void* p) const;
-
   G1HotCardCache* g1_hot_card_cache() const { return _hot_card_cache; }
 
   G1CardTable* card_table() const {
@@ -1167,14 +1171,14 @@
   void heap_region_par_iterate_from_start(HeapRegionClosure* cl,
                                           HeapRegionClaimer* hrclaimer) const;
 
-  // Iterate over the regions (if any) in the current collection set.
-  void collection_set_iterate(HeapRegionClosure* blk);
+  // Iterate over all regions currently in the current collection set.
+  void collection_set_iterate_all(HeapRegionClosure* blk);
 
-  // Iterate over the regions (if any) in the current collection set. Starts the
-  // iteration over the entire collection set so that the start regions of a given
-  // worker id over the set active_workers are evenly spread across the set of
-  // collection set regions.
-  void collection_set_iterate_from(HeapRegionClosure *blk, uint worker_id);
+  // Iterate over the regions in the current increment of the collection set.
+  // Starts the iteration so that the start regions of a given worker id over the
+  // set active_workers are evenly spread across the set of collection set regions
+  // to be iterated.
+  void collection_set_iterate_increment_from(HeapRegionClosure *blk, uint worker_id);
 
   // Returns the HeapRegion that contains addr. addr must not be NULL.
   template <class T>
@@ -1254,6 +1258,8 @@
 
   uint eden_regions_count() const { return _eden.length(); }
   uint survivor_regions_count() const { return _survivor.length(); }
+  size_t eden_regions_used_bytes() const { return _eden.used_bytes(); }
+  size_t survivor_regions_used_bytes() const { return _survivor.used_bytes(); }
   uint young_regions_count() const { return _eden.length() + _survivor.length(); }
   uint old_regions_count() const { return _old_set.length(); }
   uint archive_regions_count() const { return _archive_set.length(); }
@@ -1322,6 +1328,12 @@
   // Unregister the given nmethod from the G1 heap.
   virtual void unregister_nmethod(nmethod* nm);
 
+  // No nmethod flushing needed.
+  virtual void flush_nmethod(nmethod* nm) {}
+
+  // No nmethod verification implemented.
+  virtual void verify_nmethod(nmethod* nm) {}
+
   // Free up superfluous code root memory.
   void purge_code_root_memory();
 
@@ -1416,7 +1428,7 @@
   size_t _term_attempts;
 
   void start_term_time() { _term_attempts++; _start_term = os::elapsedTime(); }
-  void end_term_time() { _term_time += os::elapsedTime() - _start_term; }
+  void end_term_time() { _term_time += (os::elapsedTime() - _start_term); }
 protected:
   G1CollectedHeap*              _g1h;
   G1ParScanThreadState*         _par_scan_state;
--- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -59,12 +59,11 @@
   _collection_set_regions(NULL),
   _collection_set_cur_length(0),
   _collection_set_max_length(0),
-  _optional_regions(NULL),
-  _optional_region_length(0),
-  _optional_region_max_length(0),
+  _num_optional_regions(0),
   _bytes_used_before(0),
   _recorded_rs_lengths(0),
   _inc_build_state(Inactive),
+  _inc_part_start(0),
   _inc_bytes_used_before(0),
   _inc_recorded_rs_lengths(0),
   _inc_recorded_rs_lengths_diffs(0),
@@ -90,8 +89,8 @@
   assert((size_t) young_region_length() == _collection_set_cur_length,
          "Young region length %u should match collection set length " SIZE_FORMAT, young_region_length(), _collection_set_cur_length);
 
-  _old_region_length      = 0;
-  _optional_region_length = 0;
+  _old_region_length = 0;
+  free_optional_regions();
 }
 
 void G1CollectionSet::initialize(uint max_region_length) {
@@ -100,21 +99,8 @@
   _collection_set_regions = NEW_C_HEAP_ARRAY(uint, max_region_length, mtGC);
 }
 
-void G1CollectionSet::initialize_optional(uint max_length) {
-  assert(_optional_regions == NULL, "Already initialized");
-  assert(_optional_region_length == 0, "Already initialized");
-  assert(_optional_region_max_length == 0, "Already initialized");
-  _optional_region_max_length = max_length;
-  _optional_regions = NEW_C_HEAP_ARRAY(HeapRegion*, _optional_region_max_length, mtGC);
-}
-
 void G1CollectionSet::free_optional_regions() {
-  _optional_region_length = 0;
-  _optional_region_max_length = 0;
-  if (_optional_regions != NULL) {
-    FREE_C_HEAP_ARRAY(HeapRegion*, _optional_regions);
-    _optional_regions = NULL;
-  }
+  _num_optional_regions = 0;
 }
 
 void G1CollectionSet::clear_candidates() {
@@ -130,39 +116,32 @@
 void G1CollectionSet::add_old_region(HeapRegion* hr) {
   assert_at_safepoint_on_vm_thread();
 
-  assert(_inc_build_state == Active || hr->index_in_opt_cset() != G1OptionalCSet::InvalidCSetIndex,
+  assert(_inc_build_state == Active,
          "Precondition, actively building cset or adding optional later on");
   assert(hr->is_old(), "the region should be old");
 
-  assert(!hr->in_collection_set(), "should not already be in the CSet");
+  assert(!hr->in_collection_set(), "should not already be in the collection set");
   _g1h->register_old_region_with_cset(hr);
 
   _collection_set_regions[_collection_set_cur_length++] = hr->hrm_index();
   assert(_collection_set_cur_length <= _collection_set_max_length, "Collection set now larger than maximum size.");
 
   _bytes_used_before += hr->used();
-  size_t rs_length = hr->rem_set()->occupied();
-  _recorded_rs_lengths += rs_length;
-  _old_region_length += 1;
+  _recorded_rs_lengths += hr->rem_set()->occupied();
+  _old_region_length++;
 
-  log_trace(gc, cset)("Added old region %d to collection set", hr->hrm_index());
+  _g1h->old_set_remove(hr);
 }
 
 void G1CollectionSet::add_optional_region(HeapRegion* hr) {
-  assert(!optional_is_full(), "Precondition, must have room left for this region");
   assert(hr->is_old(), "the region should be old");
   assert(!hr->in_collection_set(), "should not already be in the CSet");
 
   _g1h->register_optional_region_with_cset(hr);
 
-  _optional_regions[_optional_region_length] = hr;
-  uint index = _optional_region_length++;
-  hr->set_index_in_opt_cset(index);
-
-  log_trace(gc, cset)("Added region %d to optional collection set (%u)", hr->hrm_index(), _optional_region_length);
+  hr->set_index_in_opt_cset(_num_optional_regions++);
 }
 
-// Initialize the per-collection-set information
 void G1CollectionSet::start_incremental_building() {
   assert(_collection_set_cur_length == 0, "Collection set must be empty before starting a new collection set.");
   assert(_inc_build_state == Inactive, "Precondition");
@@ -173,7 +152,8 @@
   _inc_recorded_rs_lengths_diffs = 0;
   _inc_predicted_elapsed_time_ms = 0.0;
   _inc_predicted_elapsed_time_ms_diffs = 0.0;
-  _inc_build_state = Active;
+
+  update_incremental_marker();
 }
 
 void G1CollectionSet::finalize_incremental_building() {
@@ -211,29 +191,48 @@
 void G1CollectionSet::clear() {
   assert_at_safepoint_on_vm_thread();
   _collection_set_cur_length = 0;
-  _optional_region_length = 0;
 }
 
 void G1CollectionSet::iterate(HeapRegionClosure* cl) const {
-  iterate_from(cl, 0, 1);
-}
-
-void G1CollectionSet::iterate_from(HeapRegionClosure* cl, uint worker_id, uint total_workers) const {
   size_t len = _collection_set_cur_length;
   OrderAccess::loadload();
-  if (len == 0) {
-    return;
-  }
-  size_t start_pos = (worker_id * len) / total_workers;
-  size_t cur_pos = start_pos;
 
-  do {
-    HeapRegion* r = _g1h->region_at(_collection_set_regions[cur_pos]);
+  for (uint i = 0; i < len; i++) {
+    HeapRegion* r = _g1h->region_at(_collection_set_regions[i]);
     bool result = cl->do_heap_region(r);
     if (result) {
       cl->set_incomplete();
       return;
     }
+  }
+}
+
+void G1CollectionSet::iterate_optional(HeapRegionClosure* cl) const {
+  assert_at_safepoint();
+
+  for (uint i = 0; i < _num_optional_regions; i++) {
+    HeapRegion* r = _candidates->at(i);
+    bool result = cl->do_heap_region(r);
+    guarantee(!result, "Must not cancel iteration");
+  }
+}
+
+void G1CollectionSet::iterate_incremental_part_from(HeapRegionClosure* cl, uint worker_id, uint total_workers) const {
+  assert_at_safepoint();
+
+  size_t len = _collection_set_cur_length - _inc_part_start;
+  if (len == 0) {
+    return;
+  }
+
+  size_t start_pos = (worker_id * len) / total_workers;
+  size_t cur_pos = start_pos;
+
+  do {
+    HeapRegion* r = _g1h->region_at(_collection_set_regions[cur_pos + _inc_part_start]);
+    bool result = cl->do_heap_region(r);
+    guarantee(!result, "Must not cancel iteration");
+
     cur_pos++;
     if (cur_pos == len) {
       cur_pos = 0;
@@ -440,30 +439,6 @@
   return time_remaining_ms;
 }
 
-void G1CollectionSet::add_as_old(HeapRegion* hr) {
-  candidates()->pop_front(); // already have region via peek()
-  _g1h->old_set_remove(hr);
-  add_old_region(hr);
-}
-
-void G1CollectionSet::add_as_optional(HeapRegion* hr) {
-  assert(_optional_regions != NULL, "Must not be called before array is allocated");
-  candidates()->pop_front(); // already have region via peek()
-  _g1h->old_set_remove(hr);
-  add_optional_region(hr);
-}
-
-bool G1CollectionSet::optional_is_full() {
-  assert(_optional_region_length <= _optional_region_max_length, "Invariant");
-  return _optional_region_length == _optional_region_max_length;
-}
-
-void G1CollectionSet::clear_optional_region(const HeapRegion* hr) {
-  assert(_optional_regions != NULL, "Must not be called before array is allocated");
-  uint index = hr->index_in_opt_cset();
-  _optional_regions[index] = NULL;
-}
-
 static int compare_region_idx(const uint a, const uint b) {
   if (a > b) {
     return 1;
@@ -476,87 +451,25 @@
 
 void G1CollectionSet::finalize_old_part(double time_remaining_ms) {
   double non_young_start_time_sec = os::elapsedTime();
-  double predicted_old_time_ms = 0.0;
-  double predicted_optional_time_ms = 0.0;
-  double optional_threshold_ms = time_remaining_ms * _policy->optional_prediction_fraction();
-  uint expensive_region_num = 0;
 
   if (collector_state()->in_mixed_phase()) {
     candidates()->verify();
-    const uint min_old_cset_length = _policy->calc_min_old_cset_length();
-    const uint max_old_cset_length = MAX2(min_old_cset_length, _policy->calc_max_old_cset_length());
-    bool check_time_remaining = _policy->adaptive_young_list_length();
 
-    initialize_optional(max_old_cset_length - min_old_cset_length);
-    log_debug(gc, ergo, cset)("Start adding old regions for mixed gc. min %u regions, max %u regions, "
-                              "time remaining %1.2fms, optional threshold %1.2fms",
-                              min_old_cset_length, max_old_cset_length, time_remaining_ms, optional_threshold_ms);
-
-    HeapRegion* hr = candidates()->peek_front();
-    while (hr != NULL) {
-      if (old_region_length() + optional_region_length() >= max_old_cset_length) {
-        // Added maximum number of old regions to the CSet.
-        log_debug(gc, ergo, cset)("Finish adding old regions to CSet (old CSet region num reached max). "
-                                  "old %u regions, optional %u regions",
-                                  old_region_length(), optional_region_length());
-        break;
-      }
-
-      // Stop adding regions if the remaining reclaimable space is
-      // not above G1HeapWastePercent.
-      size_t reclaimable_bytes = candidates()->remaining_reclaimable_bytes();
-      double reclaimable_percent = _policy->reclaimable_bytes_percent(reclaimable_bytes);
-      double threshold = (double) G1HeapWastePercent;
-      if (reclaimable_percent <= threshold) {
-        // We've added enough old regions that the amount of uncollected
-        // reclaimable space is at or below the waste threshold. Stop
-        // adding old regions to the CSet.
-        log_debug(gc, ergo, cset)("Finish adding old regions to CSet (reclaimable percentage not over threshold). "
-                                  "reclaimable: " SIZE_FORMAT "%s (%1.2f%%) threshold: " UINTX_FORMAT "%%",
-                                  byte_size_in_proper_unit(reclaimable_bytes), proper_unit_for_byte_size(reclaimable_bytes),
-                                  reclaimable_percent, G1HeapWastePercent);
-        break;
-      }
+    uint num_initial_old_regions;
+    uint num_optional_old_regions;
 
-      double predicted_time_ms = predict_region_elapsed_time_ms(hr);
-      time_remaining_ms = MAX2(time_remaining_ms - predicted_time_ms, 0.0);
-      // Add regions to old set until we reach minimum amount
-      if (old_region_length() < min_old_cset_length) {
-        predicted_old_time_ms += predicted_time_ms;
-        add_as_old(hr);
-        // Record the number of regions added when no time remaining
-        if (time_remaining_ms == 0.0) {
-          expensive_region_num++;
-        }
-      } else {
-        // In the non-auto-tuning case, we'll finish adding regions
-        // to the CSet if we reach the minimum.
-        if (!check_time_remaining) {
-          log_debug(gc, ergo, cset)("Finish adding old regions to CSet (old CSet region num reached min).");
-          break;
-        }
-        // Keep adding regions to old set until we reach optional threshold
-        if (time_remaining_ms > optional_threshold_ms) {
-          predicted_old_time_ms += predicted_time_ms;
-          add_as_old(hr);
-        } else if (time_remaining_ms > 0) {
-          // Keep adding optional regions until time is up
-          if (!optional_is_full()) {
-            predicted_optional_time_ms += predicted_time_ms;
-            add_as_optional(hr);
-          } else {
-            log_debug(gc, ergo, cset)("Finish adding old regions to CSet (optional set full).");
-            break;
-          }
-        } else {
-          log_debug(gc, ergo, cset)("Finish adding old regions to CSet (predicted time is too high).");
-          break;
-        }
-      }
-      hr = candidates()->peek_front();
-    }
-    if (hr == NULL) {
-      log_debug(gc, ergo, cset)("Finish adding old regions to CSet (candidate old regions not available)");
+    _policy->calculate_old_collection_set_regions(candidates(),
+                                                  time_remaining_ms,
+                                                  num_initial_old_regions,
+                                                  num_optional_old_regions);
+
+    // Prepare initial old regions.
+    move_candidates_to_collection_set(num_initial_old_regions);
+
+    // Prepare optional old regions for evacuation.
+    uint candidate_idx = candidates()->cur_idx();
+    for (uint i = 0; i < num_optional_old_regions; i++) {
+      add_optional_region(candidates()->at(candidate_idx + i));
     }
 
     candidates()->verify();
@@ -564,99 +477,59 @@
 
   stop_incremental_building();
 
-  log_debug(gc, ergo, cset)("Finish choosing CSet regions old: %u, optional: %u, "
-                            "predicted old time: %1.2fms, predicted optional time: %1.2fms, time remaining: %1.2f",
-                            old_region_length(), optional_region_length(),
-                            predicted_old_time_ms, predicted_optional_time_ms, time_remaining_ms);
-  if (expensive_region_num > 0) {
-    log_debug(gc, ergo, cset)("CSet contains %u old regions that were added although the predicted time was too high.",
-                              expensive_region_num);
-  }
-
   double non_young_end_time_sec = os::elapsedTime();
   phase_times()->record_non_young_cset_choice_time_ms((non_young_end_time_sec - non_young_start_time_sec) * 1000.0);
 
   QuickSort::sort(_collection_set_regions, _collection_set_cur_length, compare_region_idx, true);
 }
 
-HeapRegion* G1OptionalCSet::region_at(uint index) {
-  return _cset->optional_region_at(index);
+void G1CollectionSet::move_candidates_to_collection_set(uint num_old_candidate_regions) {
+  if (num_old_candidate_regions == 0) {
+    return;
+  }
+  uint candidate_idx = candidates()->cur_idx();
+  for (uint i = 0; i < num_old_candidate_regions; i++) {
+    HeapRegion* r = candidates()->at(candidate_idx + i);
+    // This potentially optional candidate region is going to be an actual collection
+    // set region. Clear cset marker.
+    _g1h->clear_in_cset(r);
+    add_old_region(r);
+  }
+  candidates()->remove(num_old_candidate_regions);
+
+  candidates()->verify();
 }
 
-void G1OptionalCSet::prepare_evacuation(double time_limit) {
-  assert(_current_index == _current_limit, "Before prepare no regions should be ready for evac");
-
-  uint prepared_regions = 0;
-  double prediction_ms = 0;
-
-  _prepare_failed = true;
-  for (uint i = _current_index; i < _cset->optional_region_length(); i++) {
-    HeapRegion* hr = region_at(i);
-    prediction_ms += _cset->predict_region_elapsed_time_ms(hr);
-    if (prediction_ms > time_limit) {
-      log_debug(gc, cset)("Prepared %u regions for optional evacuation. Predicted time: %.3fms", prepared_regions, prediction_ms);
-      return;
-    }
-
-    // This region will be included in the next optional evacuation.
-    prepare_to_evacuate_optional_region(hr);
-    prepared_regions++;
-    _current_limit++;
-    _prepare_failed = false;
-  }
-
-  log_debug(gc, cset)("Prepared all %u regions for optional evacuation. Predicted time: %.3fms",
-                      prepared_regions, prediction_ms);
-}
-
-bool G1OptionalCSet::prepare_failed() {
-  return _prepare_failed;
+void G1CollectionSet::finalize_initial_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) {
+  double time_remaining_ms = finalize_young_part(target_pause_time_ms, survivor);
+  finalize_old_part(time_remaining_ms);
 }
 
-void G1OptionalCSet::complete_evacuation() {
-  _evacuation_failed = false;
-  for (uint i = _current_index; i < _current_limit; i++) {
-    HeapRegion* hr = region_at(i);
-    _cset->clear_optional_region(hr);
-    if (hr->evacuation_failed()){
-      _evacuation_failed = true;
-    }
-  }
-  _current_index = _current_limit;
-}
+bool G1CollectionSet::finalize_optional_for_evacuation(double remaining_pause_time) {
+  update_incremental_marker();
 
-bool G1OptionalCSet::evacuation_failed() {
-  return _evacuation_failed;
+  uint num_selected_regions;
+  _policy->calculate_optional_collection_set_regions(candidates(),
+                                                     _num_optional_regions,
+                                                     remaining_pause_time,
+                                                     num_selected_regions);
+
+  move_candidates_to_collection_set(num_selected_regions);
+
+  _num_optional_regions -= num_selected_regions;
+
+  stop_incremental_building();
+  return num_selected_regions > 0;
 }
 
-G1OptionalCSet::~G1OptionalCSet() {
-  G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  while (!is_empty()) {
-    // We want to return regions not evacuated to the collection set candidates
-    // in reverse order to maintain the old order.
-    HeapRegion* hr = _cset->remove_last_optional_region();
-    assert(hr != NULL, "Should be valid region left");
-    _pset->record_unused_optional_region(hr);
-    g1h->old_set_add(hr);
-    g1h->clear_in_cset(hr);
-    hr->set_index_in_opt_cset(InvalidCSetIndex);
-    _cset->candidates()->push_front(hr);
+void G1CollectionSet::abandon_optional_collection_set(G1ParScanThreadStateSet* pss) {
+  for (uint i = 0; i < _num_optional_regions; i++) {
+    HeapRegion* r = candidates()->at(candidates()->cur_idx() + i);
+    pss->record_unused_optional_region(r);
+    _g1h->clear_in_cset(r);
+    r->clear_index_in_opt_cset();
   }
-  _cset->free_optional_regions();
-}
-
-uint G1OptionalCSet::size() {
-  return _cset->optional_region_length() - _current_index;
-}
-
-bool G1OptionalCSet::is_empty() {
-  return size() == 0;
-}
-
-void G1OptionalCSet::prepare_to_evacuate_optional_region(HeapRegion* hr) {
-  log_trace(gc, cset)("Adding region %u for optional evacuation", hr->hrm_index());
-  G1CollectedHeap::heap()->clear_in_cset(hr);
-  _cset->add_old_region(hr);
+  free_optional_regions();
 }
 
 #ifdef ASSERT
--- a/src/hotspot/share/gc/g1/g1CollectionSet.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectionSet.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -38,11 +38,101 @@
 class HeapRegion;
 class HeapRegionClosure;
 
+// The collection set.
+//
+// The set of regions that are evacuated during an evacuation pause.
+//
+// At the end of a collection, before freeing the collection set, this set
+// contains all regions that were evacuated during this collection:
+//
+// - survivor regions from the last collection (if any)
+// - eden regions allocated by the mutator
+// - old gen regions evacuated during mixed gc
+//
+// This set is built incrementally at mutator time as regions are retired, and
+// if this had been a mixed gc, some additional (during gc) incrementally added
+// old regions from the collection set candidates built during the concurrent
+// cycle.
+//
+// A more detailed overview of how the collection set changes over time follows:
+//
+// 0) at the end of GC the survivor regions are added to this collection set.
+// 1) the mutator incrementally adds eden regions as they retire
+//
+// ----- gc starts
+//
+// 2) prepare (finalize) young regions of the collection set for collection
+//    - relabel the survivors as eden
+//    - finish up the incremental building that happened at mutator time
+//
+// iff this is a young-only collection:
+//
+// a3) evacuate the current collection set in one "initial evacuation" phase
+//
+// iff this is a mixed collection:
+//
+// b3) calculate the set of old gen regions we may be able to collect in this
+//     collection from the list of collection set candidates.
+//     - one part is added to the current collection set
+//     - the remainder regions are labeled as optional, and NOT yet added to the
+//     collection set.
+// b4) evacuate the current collection set in the "initial evacuation" phase
+// b5) evacuate the optional regions in the "optional evacuation" phase. This is
+//     done in increments (or rounds).
+//     b5-1) add a few of the optional regions to the current collection set
+//     b5-2) evacuate only these newly added optional regions. For this mechanism we
+//     reuse the incremental collection set building infrastructure (used also at
+//     mutator time).
+//     b5-3) repeat from b5-1 until the policy determines we are done
+//
+// all collections
+//
+// 6) free the collection set (contains all regions now; empties collection set
+//    afterwards)
+// 7) add survivors to this collection set
+//
+// ----- gc ends
+//
+// goto 1)
+//
+// Examples of how the collection set might look over time:
+//
+// Legend:
+// S = survivor, E = eden, O = old.
+// |xxxx| = increment (with increment markers), containing four regions
+//
+// |SSSS|                         ... after step 0), with four survivor regions
+// |SSSSEE|                       ... at step 1), after retiring two eden regions
+// |SSSSEEEE|                     ... after step 1), after retiring four eden regions
+// |EEEEEEEE|                     ... after step 2)
+//
+// iff this is a young-only collection
+//
+// EEEEEEEE||                      ... after step a3), after initial evacuation phase
+// ||                              ... after step 6)
+// |SS|                            ... after step 7), with two survivor regions
+//
+// iff this is a mixed collection
+//
+// |EEEEEEEEOOOO|                  ... after step b3), added four regions to be
+//                                     evacuated in the "initial evacuation" phase
+// EEEEEEEEOOOO||                  ... after step b4), incremental part is empty
+//                                     after evacuation
+// EEEEEEEEOOOO|OO|                ... after step b5.1), added two regions to be
+//                                     evacuated in the first round of the
+//                                     "optional evacuation" phase
+// EEEEEEEEOOOOOO|O|               ... after step b5.1), added one region to be
+//                                     evacuated in the second round of the
+//                                     "optional evacuation" phase
+// EEEEEEEEOOOOOOO||               ... after step b5), the complete collection set.
+// ||                              ... after step b6)
+// |SSS|                           ... after step 7), with three survivor regions
+//
 class G1CollectionSet {
   G1CollectedHeap* _g1h;
   G1Policy* _policy;
 
-  // All old gen collection set candidate regions for the current mixed gc phase.
+  // All old gen collection set candidate regions for the current mixed phase.
   G1CollectionSetCandidates* _candidates;
 
   uint _eden_region_length;
@@ -51,7 +141,7 @@
 
   // The actual collection set as a set of region indices.
   // All entries in _collection_set_regions below _collection_set_cur_length are
-  // assumed to be valid entries.
+  // assumed to be part of the collection set.
   // We assume that at any time there is at most only one writer and (one or more)
   // concurrent readers. This means we are good with using storestore and loadload
   // barriers on the writer and reader respectively only.
@@ -59,31 +149,33 @@
   volatile size_t _collection_set_cur_length;
   size_t _collection_set_max_length;
 
-  // When doing mixed collections we can add old regions to the collection, which
-  // can be collected if there is enough time. We call these optional regions and
-  // the pointer to these regions are stored in the array below.
-  HeapRegion** _optional_regions;
-  uint _optional_region_length;
-  uint _optional_region_max_length;
+  // When doing mixed collections we can add old regions to the collection set, which
+  // will be collected only if there is enough time. We call these optional regions.
+  // This member records the current number of regions that are of that type that
+  // correspond to the first x entries in the collection set candidates.
+  uint _num_optional_regions;
 
   // The number of bytes in the collection set before the pause. Set from
   // the incrementally built collection set at the start of an evacuation
-  // pause, and incremented in finalize_old_part() when adding old regions
-  // (if any) to the collection set.
+  // pause, and updated as more regions are added to the collection set.
   size_t _bytes_used_before;
 
+  // The number of cards in the remembered set in the collection set. Set from
+  // the incrementally built collection set at the start of an evacuation
+  // pause, and updated as more regions are added to the collection set.
   size_t _recorded_rs_lengths;
 
-  // The associated information that is maintained while the incremental
-  // collection set is being built with young regions. Used to populate
-  // the recorded info for the evacuation pause.
-
   enum CSetBuildType {
     Active,             // We are actively building the collection set
     Inactive            // We are not actively building the collection set
   };
 
   CSetBuildType _inc_build_state;
+  size_t _inc_part_start;
+
+  // The associated information that is maintained while the incremental
+  // collection set is being built with *young* regions. Used to populate
+  // the recorded info for the evacuation pause.
 
   // The number of bytes in the incrementally built collection set.
   // Used to set _collection_set_bytes_used_before at the start of
@@ -113,22 +205,44 @@
   // See the comment for _inc_recorded_rs_lengths_diffs.
   double _inc_predicted_elapsed_time_ms_diffs;
 
+  void set_recorded_rs_lengths(size_t rs_lengths);
+
   G1CollectorState* collector_state();
   G1GCPhaseTimes* phase_times();
 
   void verify_young_cset_indices() const NOT_DEBUG_RETURN;
-  void add_as_optional(HeapRegion* hr);
-  void add_as_old(HeapRegion* hr);
-  bool optional_is_full();
+
+  double predict_region_elapsed_time_ms(HeapRegion* hr);
+
+  // Update the incremental collection set information when adding a region.
+  void add_young_region_common(HeapRegion* hr);
+
+  // Add old region "hr" to the collection set.
+  void add_old_region(HeapRegion* hr);
+  void free_optional_regions();
+
+  // Add old region "hr" to optional collection set.
+  void add_optional_region(HeapRegion* hr);
 
+  void move_candidates_to_collection_set(uint num_regions);
+
+  // Finalize the young part of the initial collection set. Relabel survivor regions
+  // as Eden and calculate a prediction on how long the evacuation of all young regions
+  // will take.
+  double finalize_young_part(double target_pause_time_ms, G1SurvivorRegions* survivors);
+  // Perform any final calculations on the incremental collection set fields before we
+  // can use them.
+  void finalize_incremental_building();
+
+  // Select the old regions of the initial collection set and determine how many optional
+  // regions we might be able to evacuate in this pause.
+  void finalize_old_part(double time_remaining_ms);
 public:
   G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy);
   ~G1CollectionSet();
 
   // Initializes the collection set giving the maximum possible length of the collection set.
   void initialize(uint max_region_length);
-  void initialize_optional(uint max_length);
-  void free_optional_regions();
 
   void clear_candidates();
 
@@ -141,8 +255,6 @@
   void init_region_lengths(uint eden_cset_region_length,
                            uint survivor_cset_region_length);
 
-  void set_recorded_rs_lengths(size_t rs_lengths);
-
   uint region_length() const       { return young_region_length() +
                                             old_region_length(); }
   uint young_region_length() const { return eden_region_length() +
@@ -151,32 +263,29 @@
   uint eden_region_length() const     { return _eden_region_length;     }
   uint survivor_region_length() const { return _survivor_region_length; }
   uint old_region_length() const      { return _old_region_length;      }
-  uint optional_region_length() const { return _optional_region_length; }
+  uint optional_region_length() const { return _num_optional_regions; }
+
+  // Reset the contents of the collection set.
+  void clear();
 
   // Incremental collection set support
 
   // Initialize incremental collection set info.
   void start_incremental_building();
-
-  // Perform any final calculations on the incremental collection set fields
-  // before we can use them.
-  void finalize_incremental_building();
+  // Start a new collection set increment.
+  void update_incremental_marker() { _inc_build_state = Active; _inc_part_start = _collection_set_cur_length; }
+  // Stop adding regions to the current collection set increment.
+  void stop_incremental_building() { _inc_build_state = Inactive; }
 
-  // Reset the contents of the collection set.
-  void clear();
+  // Iterate over the current collection set increment applying the given HeapRegionClosure
+  // from a starting position determined by the given worker id.
+  void iterate_incremental_part_from(HeapRegionClosure* cl, uint worker_id, uint total_workers) const;
 
-  // Iterate over the collection set, applying the given HeapRegionClosure on all of them.
-  // If may_be_aborted is true, iteration may be aborted using the return value of the
-  // called closure method.
+  // Iterate over the entire collection set (all increments calculated so far), applying
+  // the given HeapRegionClosure on all of them.
   void iterate(HeapRegionClosure* cl) const;
 
-  // Iterate over the collection set, applying the given HeapRegionClosure on all of them,
-  // trying to optimally spread out starting position of total_workers workers given the
-  // caller's worker_id.
-  void iterate_from(HeapRegionClosure* cl, uint worker_id, uint total_workers) const;
-
-  // Stop adding regions to the incremental collection set.
-  void stop_incremental_building() { _inc_build_state = Inactive; }
+  void iterate_optional(HeapRegionClosure* cl) const;
 
   size_t recorded_rs_lengths() { return _recorded_rs_lengths; }
 
@@ -188,16 +297,14 @@
     _bytes_used_before = 0;
   }
 
-  // Choose a new collection set.  Marks the chosen regions as being
-  // "in_collection_set".
-  double finalize_young_part(double target_pause_time_ms, G1SurvivorRegions* survivors);
-  void finalize_old_part(double time_remaining_ms);
-
-  // Add old region "hr" to the collection set.
-  void add_old_region(HeapRegion* hr);
-
-  // Add old region "hr" to optional collection set.
-  void add_optional_region(HeapRegion* hr);
+  // Finalize the initial collection set consisting of all young regions potentially a
+  // few old gen regions.
+  void finalize_initial_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor);
+  // Finalize the next collection set from the set of available optional old gen regions.
+  bool finalize_optional_for_evacuation(double remaining_pause_time);
+  // Abandon (clean up) optional collection set regions that were not evacuated in this
+  // pause.
+  void abandon_optional_collection_set(G1ParScanThreadStateSet* pss);
 
   // Update information about hr in the aggregated information for
   // the incrementally built collection set.
@@ -214,73 +321,6 @@
 
   void print(outputStream* st);
 #endif // !PRODUCT
-
-  double predict_region_elapsed_time_ms(HeapRegion* hr);
-
-  void clear_optional_region(const HeapRegion* hr);
-
-  HeapRegion* optional_region_at(uint i) const {
-    assert(_optional_regions != NULL, "Not yet initialized");
-    assert(i < _optional_region_length, "index %u out of bounds (%u)", i, _optional_region_length);
-    return _optional_regions[i];
-  }
-
-  HeapRegion* remove_last_optional_region() {
-    assert(_optional_regions != NULL, "Not yet initialized");
-    assert(_optional_region_length != 0, "No region to remove");
-    _optional_region_length--;
-    HeapRegion* removed = _optional_regions[_optional_region_length];
-    _optional_regions[_optional_region_length] = NULL;
-    return removed;
-  }
-
-private:
-  // Update the incremental collection set information when adding a region.
-  void add_young_region_common(HeapRegion* hr);
-};
-
-// Helper class to manage the optional regions in a Mixed collection.
-class G1OptionalCSet : public StackObj {
-private:
-  G1CollectionSet* _cset;
-  G1ParScanThreadStateSet* _pset;
-  uint _current_index;
-  uint _current_limit;
-  bool _prepare_failed;
-  bool _evacuation_failed;
-
-  void prepare_to_evacuate_optional_region(HeapRegion* hr);
-
-public:
-  static const uint InvalidCSetIndex = UINT_MAX;
-
-  G1OptionalCSet(G1CollectionSet* cset, G1ParScanThreadStateSet* pset) :
-    _cset(cset),
-    _pset(pset),
-    _current_index(0),
-    _current_limit(0),
-    _prepare_failed(false),
-    _evacuation_failed(false) { }
-  // The destructor returns regions to the collection set candidates set and
-  // frees the optional structure in the collection set.
-  ~G1OptionalCSet();
-
-  uint current_index() { return _current_index; }
-  uint current_limit() { return _current_limit; }
-
-  uint size();
-  bool is_empty();
-
-  HeapRegion* region_at(uint index);
-
-  // Prepare a set of regions for optional evacuation.
-  void prepare_evacuation(double time_left_ms);
-  bool prepare_failed();
-
-  // Complete the evacuation of the previously prepared
-  // regions by updating their state and check for failures.
-  void complete_evacuation();
-  bool evacuation_failed();
 };
 
 #endif // SHARE_GC_G1_G1COLLECTIONSET_HPP
--- a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -27,26 +27,12 @@
 #include "gc/g1/g1CollectionSetChooser.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 
-HeapRegion* G1CollectionSetCandidates::pop_front() {
-  assert(_front_idx < _num_regions, "pre-condition");
-  HeapRegion* hr = _regions[_front_idx];
-  assert(hr != NULL, "pre-condition");
-  _regions[_front_idx] = NULL;
-  assert(hr->reclaimable_bytes() <= _remaining_reclaimable_bytes,
-         "Remaining reclaimable bytes inconsistent "
-         "from region: " SIZE_FORMAT " remaining: " SIZE_FORMAT,
-         hr->reclaimable_bytes(), _remaining_reclaimable_bytes);
-  _remaining_reclaimable_bytes -= hr->reclaimable_bytes();
-  _front_idx++;
-  return hr;
-}
-
-void G1CollectionSetCandidates::push_front(HeapRegion* hr) {
-  assert(hr != NULL, "Can't put back a NULL region");
-  assert(_front_idx >= 1, "Too many regions have been put back.");
-  _front_idx--;
-  _regions[_front_idx] = hr;
-  _remaining_reclaimable_bytes += hr->reclaimable_bytes();
+void G1CollectionSetCandidates::remove(uint num_regions) {
+  assert(num_regions <= num_remaining(), "Trying to remove more regions (%u) than available (%u)", num_regions, num_remaining());
+  for (uint i = 0; i < num_regions; i++) {
+    _remaining_reclaimable_bytes -= at(_front_idx)->reclaimable_bytes();
+    _front_idx++;
+  }
 }
 
 void G1CollectionSetCandidates::iterate(HeapRegionClosure* cl) {
@@ -62,13 +48,8 @@
 #ifndef PRODUCT
 void G1CollectionSetCandidates::verify() const {
   guarantee(_front_idx <= _num_regions, "Index: %u Num_regions: %u", _front_idx, _num_regions);
-  uint idx = 0;
+  uint idx = _front_idx;
   size_t sum_of_reclaimable_bytes = 0;
-  while (idx < _front_idx) {
-    guarantee(_regions[idx] == NULL, "All entries before _front_idx %u should be NULL, but %u is not",
-              _front_idx, idx);
-    idx++;
-  }
   HeapRegion *prev = NULL;
   for (; idx < _num_regions; idx++) {
     HeapRegion *cur = _regions[idx];
--- a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -63,22 +63,18 @@
   // Returns the total number of collection set candidate old regions added.
   uint num_regions() { return _num_regions; }
 
-  // Return the candidate region at the cursor position to be considered for collection without
-  // removing it.
-  HeapRegion* peek_front() {
+  uint cur_idx() const { return _front_idx; }
+
+  HeapRegion* at(uint idx) const {
     HeapRegion* res = NULL;
-    if (_front_idx < _num_regions) {
-      res = _regions[_front_idx];
-      assert(res != NULL, "Unexpected NULL HeapRegion at index %u", _front_idx);
+    if (idx < _num_regions) {
+      res = _regions[idx];
+      assert(res != NULL, "Unexpected NULL HeapRegion at index %u", idx);
     }
     return res;
   }
 
-  // Remove the given region from the candidates set and move the cursor to the next one.
-  HeapRegion* pop_front();
-
-  // Add the given HeapRegion to the front of the collection set candidate set again.
-  void push_front(HeapRegion* hr);
+  void remove(uint num_regions);
 
   // Iterate over all remaining collection set candidate regions.
   void iterate(HeapRegionClosure* cl);
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1766,17 +1766,17 @@
   G1CMSATBBufferClosure _cm_satb_cl;
   G1CMOopClosure _cm_cl;
   MarkingCodeBlobClosure _code_cl;
-  int _thread_parity;
+  uintx _claim_token;
 
  public:
   G1RemarkThreadsClosure(G1CollectedHeap* g1h, G1CMTask* task) :
     _cm_satb_cl(task, g1h),
     _cm_cl(g1h, task),
     _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations),
-    _thread_parity(Threads::thread_claim_parity()) {}
+    _claim_token(Threads::thread_claim_token()) {}
 
   void do_thread(Thread* thread) {
-    if (thread->claim_oops_do(true, _thread_parity)) {
+    if (thread->claim_threads_do(true, _claim_token)) {
       SATBMarkQueue& queue = G1ThreadLocalData::satb_mark_queue(thread);
       queue.apply_closure_and_empty(&_cm_satb_cl);
       if (thread->is_Java_thread()) {
@@ -1940,9 +1940,10 @@
     guarantee(oopDesc::is_oop(task_entry.obj()),
               "Non-oop " PTR_FORMAT ", phase: %s, info: %d",
               p2i(task_entry.obj()), _phase, _info);
-    guarantee(!_g1h->is_in_cset(task_entry.obj()),
-              "obj: " PTR_FORMAT " in CSet, phase: %s, info: %d",
-              p2i(task_entry.obj()), _phase, _info);
+    HeapRegion* r = _g1h->heap_region_containing(task_entry.obj());
+    guarantee(!(r->in_collection_set() || r->has_index_in_opt_cset()),
+              "obj " PTR_FORMAT " from %s (%d) in region %u in (optional) collection set",
+              p2i(task_entry.obj()), _phase, _info, r->hrm_index());
   }
 };
 
@@ -1979,11 +1980,11 @@
     HeapWord* task_finger = task->finger();
     if (task_finger != NULL && task_finger < _heap.end()) {
       // See above note on the global finger verification.
-      HeapRegion* task_hr = _g1h->heap_region_containing(task_finger);
-      guarantee(task_hr == NULL || task_finger == task_hr->bottom() ||
-                !task_hr->in_collection_set(),
+      HeapRegion* r = _g1h->heap_region_containing(task_finger);
+      guarantee(r == NULL || task_finger == r->bottom() ||
+                !r->in_collection_set() || !r->has_index_in_opt_cset(),
                 "task finger: " PTR_FORMAT " region: " HR_FORMAT,
-                p2i(task_finger), HR_FORMAT_PARAMS(task_hr));
+                p2i(task_finger), HR_FORMAT_PARAMS(r));
     }
   }
 }
--- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -127,7 +127,7 @@
 }
 
 void G1ConcurrentMarkThread::delay_to_keep_mmu(G1Policy* g1_policy, bool remark) {
-  if (g1_policy->adaptive_young_list_length()) {
+  if (g1_policy->use_adaptive_young_list_length()) {
     jlong sleep_time_ms = mmu_sleep_time(g1_policy, remark);
     if (!_cm->has_aborted() && sleep_time_ms > 0) {
       os::sleep(this, sleep_time_ms, false);
--- a/src/hotspot/share/gc/g1/g1EdenRegions.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1EdenRegions.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -31,19 +31,28 @@
 
 class G1EdenRegions {
 private:
-  int _length;
+  int    _length;
+  // Sum of used bytes from all retired eden regions.
+  // I.e. updated when mutator regions are retired.
+  volatile size_t _used_bytes;
 
 public:
-  G1EdenRegions() : _length(0) {}
+  G1EdenRegions() : _length(0), _used_bytes(0) { }
 
   void add(HeapRegion* hr) {
     assert(!hr->is_eden(), "should not already be set");
     _length++;
   }
 
-  void clear() { _length = 0; }
+  void clear() { _length = 0; _used_bytes = 0; }
 
   uint length() const { return _length; }
+
+  size_t used_bytes() const { return _used_bytes; }
+
+  void add_used_bytes(size_t used_bytes) {
+    _used_bytes += used_bytes;
+  }
 };
 
 #endif // SHARE_GC_G1_G1EDENREGIONS_HPP
--- a/src/hotspot/share/gc/g1/g1EvacFailure.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1EvacFailure.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -228,6 +228,8 @@
 
     if (_hrclaimer->claim_region(hr->hrm_index())) {
       if (hr->evacuation_failed()) {
+        hr->clear_index_in_opt_cset();
+
         bool during_initial_mark = _g1h->collector_state()->in_initial_mark_gc();
         bool during_conc_mark = _g1h->collector_state()->mark_or_rebuild_in_progress();
 
@@ -257,5 +259,5 @@
 void G1ParRemoveSelfForwardPtrsTask::work(uint worker_id) {
   RemoveSelfForwardPtrHRClosure rsfp_cl(worker_id, &_hrclaimer);
 
-  _g1h->collection_set_iterate_from(&rsfp_cl, worker_id);
+  _g1h->collection_set_iterate_increment_from(&rsfp_cl, worker_id);
 }
--- a/src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -61,7 +61,7 @@
     _cc++;
     oop obj = CompressedOops::decode_not_null(heap_oop);
     bool failed = false;
-    if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _verify_option)) {
+    if (!_g1h->is_in(obj) || _g1h->is_obj_dead_cond(obj, _verify_option)) {
       MutexLockerEx x(ParGCRareEvent_lock,
           Mutex::_no_safepoint_check_flag);
       LogStreamHandle(Error, gc, verify) yy;
@@ -69,7 +69,7 @@
         yy.cr();
         yy.print_cr("----------");
       }
-      if (!_g1h->is_in_closed_subset(obj)) {
+      if (!_g1h->is_in(obj)) {
         HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
         yy.print_cr("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
                     p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -76,10 +76,12 @@
   }
   _gc_par_phases[ScanRS] = new WorkerDataArray<double>(max_gc_threads, "Scan RS (ms):");
   _gc_par_phases[OptScanRS] = new WorkerDataArray<double>(max_gc_threads, "Optional Scan RS (ms):");
-  _gc_par_phases[CodeRoots] = new WorkerDataArray<double>(max_gc_threads, "Code Root Scanning (ms):");
+  _gc_par_phases[CodeRoots] = new WorkerDataArray<double>(max_gc_threads, "Code Root Scan (ms):");
+  _gc_par_phases[OptCodeRoots] = new WorkerDataArray<double>(max_gc_threads, "Optional Code Root Scan (ms):");
   _gc_par_phases[ObjCopy] = new WorkerDataArray<double>(max_gc_threads, "Object Copy (ms):");
   _gc_par_phases[OptObjCopy] = new WorkerDataArray<double>(max_gc_threads, "Optional Object Copy (ms):");
   _gc_par_phases[Termination] = new WorkerDataArray<double>(max_gc_threads, "Termination (ms):");
+  _gc_par_phases[OptTermination] = new WorkerDataArray<double>(max_gc_threads, "Optional Termination (ms):");
   _gc_par_phases[GCWorkerTotal] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Total (ms):");
   _gc_par_phases[GCWorkerEnd] = new WorkerDataArray<double>(max_gc_threads, "GC Worker End (ms):");
   _gc_par_phases[Other] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Other (ms):");
@@ -91,14 +93,16 @@
   _scan_rs_skipped_cards = new WorkerDataArray<size_t>(max_gc_threads, "Skipped Cards:");
   _gc_par_phases[ScanRS]->link_thread_work_items(_scan_rs_skipped_cards, ScanRSSkippedCards);
 
-  _opt_cset_scanned_cards = new WorkerDataArray<size_t>(max_gc_threads, "Scanned Cards:");
-  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_cset_scanned_cards, OptCSetScannedCards);
-  _opt_cset_claimed_cards = new WorkerDataArray<size_t>(max_gc_threads, "Claimed Cards:");
-  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_cset_claimed_cards, OptCSetClaimedCards);
-  _opt_cset_skipped_cards = new WorkerDataArray<size_t>(max_gc_threads, "Skipped Cards:");
-  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_cset_skipped_cards, OptCSetSkippedCards);
-  _opt_cset_used_memory = new WorkerDataArray<size_t>(max_gc_threads, "Used Memory:");
-  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_cset_used_memory, OptCSetUsedMemory);
+  _opt_scan_rs_scanned_cards = new WorkerDataArray<size_t>(max_gc_threads, "Scanned Cards:");
+  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_scan_rs_scanned_cards, ScanRSScannedCards);
+  _opt_scan_rs_claimed_cards = new WorkerDataArray<size_t>(max_gc_threads, "Claimed Cards:");
+  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_scan_rs_claimed_cards, ScanRSClaimedCards);
+  _opt_scan_rs_skipped_cards = new WorkerDataArray<size_t>(max_gc_threads, "Skipped Cards:");
+  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_scan_rs_skipped_cards, ScanRSSkippedCards);
+  _opt_scan_rs_scanned_opt_refs = new WorkerDataArray<size_t>(max_gc_threads, "Scanned Refs:");
+  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_scan_rs_scanned_opt_refs, ScanRSScannedOptRefs);
+  _opt_scan_rs_used_memory = new WorkerDataArray<size_t>(max_gc_threads, "Used Memory:");
+  _gc_par_phases[OptScanRS]->link_thread_work_items(_opt_scan_rs_used_memory, ScanRSUsedMemory);
 
   _update_rs_processed_buffers = new WorkerDataArray<size_t>(max_gc_threads, "Processed Buffers:");
   _gc_par_phases[UpdateRS]->link_thread_work_items(_update_rs_processed_buffers, UpdateRSProcessedBuffers);
@@ -112,9 +116,17 @@
   _obj_copy_lab_undo_waste = new WorkerDataArray<size_t>(max_gc_threads, "LAB Undo Waste");
   _gc_par_phases[ObjCopy]->link_thread_work_items(_obj_copy_lab_undo_waste, ObjCopyLABUndoWaste);
 
+  _opt_obj_copy_lab_waste = new WorkerDataArray<size_t>(max_gc_threads, "LAB Waste");
+  _gc_par_phases[OptObjCopy]->link_thread_work_items(_obj_copy_lab_waste, ObjCopyLABWaste);
+  _opt_obj_copy_lab_undo_waste  = new WorkerDataArray<size_t>(max_gc_threads, "LAB Undo Waste");
+  _gc_par_phases[OptObjCopy]->link_thread_work_items(_obj_copy_lab_undo_waste, ObjCopyLABUndoWaste);
+
   _termination_attempts = new WorkerDataArray<size_t>(max_gc_threads, "Termination Attempts:");
   _gc_par_phases[Termination]->link_thread_work_items(_termination_attempts);
 
+  _opt_termination_attempts = new WorkerDataArray<size_t>(max_gc_threads, "Optional Termination Attempts:");
+  _gc_par_phases[OptTermination]->link_thread_work_items(_opt_termination_attempts);
+
   if (UseStringDeduplication) {
     _gc_par_phases[StringDedupQueueFixup] = new WorkerDataArray<double>(max_gc_threads, "Queue Fixup (ms):");
     _gc_par_phases[StringDedupTableFixup] = new WorkerDataArray<double>(max_gc_threads, "Table Fixup (ms):");
@@ -134,7 +146,7 @@
 }
 
 void G1GCPhaseTimes::reset() {
-  _cur_collection_par_time_ms = 0.0;
+  _cur_collection_initial_evac_time_ms = 0.0;
   _cur_optional_evac_ms = 0.0;
   _cur_collection_code_root_fixup_time_ms = 0.0;
   _cur_strong_code_root_purge_time_ms = 0.0;
@@ -251,6 +263,10 @@
   }
 }
 
+double G1GCPhaseTimes::get_time_secs(GCParPhases phase, uint worker_i) {
+  return _gc_par_phases[phase]->get(worker_i);
+}
+
 void G1GCPhaseTimes::record_thread_work_item(GCParPhases phase, uint worker_i, size_t count, uint index) {
   _gc_par_phases[phase]->set_thread_work_item(worker_i, count, index);
 }
@@ -259,6 +275,10 @@
   _gc_par_phases[phase]->set_or_add_thread_work_item(worker_i, count, index);
 }
 
+size_t G1GCPhaseTimes::get_thread_work_item(GCParPhases phase, uint worker_i, uint index) {
+  return _gc_par_phases[phase]->get_thread_work_item(worker_i, index);
+}
+
 // return the average time for a phase in milliseconds
 double G1GCPhaseTimes::average_time_ms(GCParPhases phase) {
   return _gc_par_phases[phase]->average() * 1000.0;
@@ -374,12 +394,14 @@
     info_time("Evacuate Optional Collection Set", sum_ms);
     debug_phase(_gc_par_phases[OptScanRS]);
     debug_phase(_gc_par_phases[OptObjCopy]);
+    debug_phase(_gc_par_phases[OptCodeRoots]);
+    debug_phase(_gc_par_phases[OptTermination]);
   }
   return sum_ms;
 }
 
 double G1GCPhaseTimes::print_evacuate_collection_set() const {
-  const double sum_ms = _cur_collection_par_time_ms;
+  const double sum_ms = _cur_collection_initial_evac_time_ms;
 
   info_time("Evacuate Collection Set", sum_ms);
 
@@ -517,9 +539,11 @@
       "ScanRS",
       "OptScanRS",
       "CodeRoots",
+      "OptCodeRoots",
       "ObjCopy",
       "OptObjCopy",
       "Termination",
+      "OptTermination",
       "Other",
       "GCWorkerTotal",
       "GCWorkerEnd",
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -67,9 +67,11 @@
     ScanRS,
     OptScanRS,
     CodeRoots,
+    OptCodeRoots,
     ObjCopy,
     OptObjCopy,
     Termination,
+    OptTermination,
     Other,
     GCWorkerTotal,
     GCWorkerEnd,
@@ -87,7 +89,9 @@
   enum GCScanRSWorkItems {
     ScanRSScannedCards,
     ScanRSClaimedCards,
-    ScanRSSkippedCards
+    ScanRSSkippedCards,
+    ScanRSScannedOptRefs,
+    ScanRSUsedMemory
   };
 
   enum GCUpdateRSWorkItems {
@@ -101,13 +105,6 @@
     ObjCopyLABUndoWaste
   };
 
-  enum GCOptCSetWorkItems {
-      OptCSetScannedCards,
-      OptCSetClaimedCards,
-      OptCSetSkippedCards,
-      OptCSetUsedMemory
-  };
-
  private:
   // Markers for grouping the phases in the GCPhases enum above
   static const int GCMainParPhasesLast = GCWorkerEnd;
@@ -122,19 +119,25 @@
   WorkerDataArray<size_t>* _scan_rs_claimed_cards;
   WorkerDataArray<size_t>* _scan_rs_skipped_cards;
 
+  WorkerDataArray<size_t>* _opt_scan_rs_scanned_cards;
+  WorkerDataArray<size_t>* _opt_scan_rs_claimed_cards;
+  WorkerDataArray<size_t>* _opt_scan_rs_skipped_cards;
+  WorkerDataArray<size_t>* _opt_scan_rs_scanned_opt_refs;
+  WorkerDataArray<size_t>* _opt_scan_rs_used_memory;
+
   WorkerDataArray<size_t>* _obj_copy_lab_waste;
   WorkerDataArray<size_t>* _obj_copy_lab_undo_waste;
 
-  WorkerDataArray<size_t>* _opt_cset_scanned_cards;
-  WorkerDataArray<size_t>* _opt_cset_claimed_cards;
-  WorkerDataArray<size_t>* _opt_cset_skipped_cards;
-  WorkerDataArray<size_t>* _opt_cset_used_memory;
+  WorkerDataArray<size_t>* _opt_obj_copy_lab_waste;
+  WorkerDataArray<size_t>* _opt_obj_copy_lab_undo_waste;
 
   WorkerDataArray<size_t>* _termination_attempts;
 
+  WorkerDataArray<size_t>* _opt_termination_attempts;
+
   WorkerDataArray<size_t>* _redirtied_cards;
 
-  double _cur_collection_par_time_ms;
+  double _cur_collection_initial_evac_time_ms;
   double _cur_optional_evac_ms;
   double _cur_collection_code_root_fixup_time_ms;
   double _cur_strong_code_root_purge_time_ms;
@@ -225,10 +228,14 @@
 
   void record_or_add_time_secs(GCParPhases phase, uint worker_i, double secs);
 
+  double get_time_secs(GCParPhases phase, uint worker_i);
+
   void record_thread_work_item(GCParPhases phase, uint worker_i, size_t count, uint index = 0);
 
   void record_or_add_thread_work_item(GCParPhases phase, uint worker_i, size_t count, uint index = 0);
 
+  size_t get_thread_work_item(GCParPhases phase, uint worker_i, uint index = 0);
+
   // return the average time for a phase in milliseconds
   double average_time_ms(GCParPhases phase);
 
@@ -256,16 +263,16 @@
     _cur_expand_heap_time_ms = ms;
   }
 
-  void record_par_time(double ms) {
-    _cur_collection_par_time_ms = ms;
+  void record_initial_evac_time(double ms) {
+    _cur_collection_initial_evac_time_ms = ms;
   }
 
-  void record_optional_evacuation(double ms) {
-    _cur_optional_evac_ms = ms;
+  void record_or_add_optional_evac_time(double ms) {
+    _cur_optional_evac_ms += ms;
   }
 
-  void record_code_root_fixup_time(double ms) {
-    _cur_collection_code_root_fixup_time_ms = ms;
+  void record_or_add_code_root_fixup_time(double ms) {
+    _cur_collection_code_root_fixup_time_ms += ms;
   }
 
   void record_strong_code_root_purge_time(double ms) {
@@ -360,7 +367,7 @@
   }
 
   double cur_collection_par_time_ms() {
-    return _cur_collection_par_time_ms;
+    return _cur_collection_initial_evac_time_ms;
   }
 
   double cur_clear_ct_time_ms() {
--- a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -371,6 +371,7 @@
   }
 
   bool do_heap_region(HeapRegion* r) {
+    guarantee(!r->has_index_in_opt_cset(), "Region %u still has opt collection set index %u", r->hrm_index(), r->index_in_opt_cset());
     guarantee(!r->is_young() || r->rem_set()->is_complete(), "Remembered set for Young region %u must be complete, is %s", r->hrm_index(), r->rem_set()->get_state_str());
     // Humongous and old regions regions might be of any state, so can't check here.
     guarantee(!r->is_free() || !r->rem_set()->is_tracked(), "Remembered set for free region %u must be untracked, is %s", r->hrm_index(), r->rem_set()->get_state_str());
--- a/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -228,23 +228,25 @@
   MutexLockerEx x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
   // Recalculate all the sizes from scratch.
 
-  uint young_list_length = _g1h->young_regions_count();
+  // This never includes used bytes of current allocating heap region.
+  _overall_used = _g1h->used_unlocked();
+  _eden_space_used = _g1h->eden_regions_used_bytes();
+  _survivor_space_used = _g1h->survivor_regions_used_bytes();
+
+  // _overall_used and _eden_space_used are obtained concurrently so
+  // may be inconsistent with each other. To prevent _old_gen_used going negative,
+  // use smaller value to substract.
+  _old_gen_used = _overall_used - MIN2(_overall_used, _eden_space_used + _survivor_space_used);
+
   uint survivor_list_length = _g1h->survivor_regions_count();
-  assert(young_list_length >= survivor_list_length, "invariant");
-  uint eden_list_length = young_list_length - survivor_list_length;
   // Max length includes any potential extensions to the young gen
   // we'll do when the GC locker is active.
   uint young_list_max_length = _g1h->policy()->young_list_max_length();
   assert(young_list_max_length >= survivor_list_length, "invariant");
   uint eden_list_max_length = young_list_max_length - survivor_list_length;
 
-  _overall_used = _g1h->used_unlocked();
-  _eden_space_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
-  _survivor_space_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
-  _old_gen_used = subtract_up_to_zero(_overall_used, _eden_space_used + _survivor_space_used);
-
   // First calculate the committed sizes that can be calculated independently.
-  _survivor_space_committed = _survivor_space_used;
+  _survivor_space_committed = survivor_list_length * HeapRegion::GrainBytes;
   _old_gen_committed = HeapRegion::align_up_to_region_byte_size(_old_gen_used);
 
   // Next, start with the overall committed size.
@@ -274,11 +276,15 @@
   // Somewhat defensive: cap the eden used size to make sure it
   // never exceeds the committed size.
   _eden_space_used = MIN2(_eden_space_used, _eden_space_committed);
-  // _survivor_committed and _old_committed are calculated in terms of
-  // the corresponding _*_used value, so the next two conditions
-  // should hold.
-  assert(_survivor_space_used <= _survivor_space_committed, "post-condition");
-  assert(_old_gen_used <= _old_gen_committed, "post-condition");
+  // _survivor_space_used is calculated during a safepoint and _survivor_space_committed
+  // is calculated from survivor region count * heap region size.
+  assert(_survivor_space_used <= _survivor_space_committed, "Survivor used bytes(" SIZE_FORMAT
+         ") should be less than or equal to survivor committed(" SIZE_FORMAT ")",
+         _survivor_space_used, _survivor_space_committed);
+  // _old_gen_committed is calculated in terms of _old_gen_used value.
+  assert(_old_gen_used <= _old_gen_committed, "Old gen used bytes(" SIZE_FORMAT
+         ") should be less than or equal to old gen committed(" SIZE_FORMAT ")",
+         _old_gen_used, _old_gen_committed);
 }
 
 void G1MonitoringSupport::update_sizes() {
--- a/src/hotspot/share/gc/g1/g1MonitoringSupport.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1MonitoringSupport.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -174,21 +174,6 @@
 
   size_t _old_gen_used;
 
-  // It returns x - y if x > y, 0 otherwise.
-  // As described in the comment above, some of the inputs to the
-  // calculations we have to do are obtained concurrently and hence
-  // may be inconsistent with each other. So, this provides a
-  // defensive way of performing the subtraction and avoids the value
-  // going negative (which would mean a very large result, given that
-  // the parameter are size_t).
-  static size_t subtract_up_to_zero(size_t x, size_t y) {
-    if (x > y) {
-      return x - y;
-    } else {
-      return 0;
-    }
-  }
-
   // Recalculate all the sizes.
   void recalculate_sizes();
 
--- a/src/hotspot/share/gc/g1/g1OopStarChunkedList.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1OopStarChunkedList.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,9 +32,11 @@
   delete_list(_coops);
 }
 
-void G1OopStarChunkedList::oops_do(OopClosure* obj_cl, OopClosure* root_cl) {
-  chunks_do(_roots, root_cl);
-  chunks_do(_croots, root_cl);
-  chunks_do(_oops, obj_cl);
-  chunks_do(_coops, obj_cl);
+size_t G1OopStarChunkedList::oops_do(OopClosure* obj_cl, OopClosure* root_cl) {
+  size_t result = 0;
+  result += chunks_do(_roots, root_cl);
+  result += chunks_do(_croots, root_cl);
+  result += chunks_do(_oops, obj_cl);
+  result += chunks_do(_coops, obj_cl);
+  return result;
 }
--- a/src/hotspot/share/gc/g1/g1OopStarChunkedList.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1OopStarChunkedList.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -41,8 +41,8 @@
   template <typename T> void delete_list(ChunkedList<T*, mtGC>* c);
 
   template <typename T>
-  void chunks_do(ChunkedList<T*, mtGC>* head,
-                 OopClosure* cl);
+  size_t chunks_do(ChunkedList<T*, mtGC>* head,
+                   OopClosure* cl);
 
   template <typename T>
   inline void push(ChunkedList<T*, mtGC>** field, T* p);
@@ -53,7 +53,7 @@
 
   size_t used_memory() { return _used_memory; }
 
-  void oops_do(OopClosure* obj_cl, OopClosure* root_cl);
+  size_t oops_do(OopClosure* obj_cl, OopClosure* root_cl);
 
   inline void push_oop(oop* p);
   inline void push_oop(narrowOop* p);
--- a/src/hotspot/share/gc/g1/g1OopStarChunkedList.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1OopStarChunkedList.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -72,13 +72,16 @@
 }
 
 template <typename T>
-void G1OopStarChunkedList::chunks_do(ChunkedList<T*, mtGC>* head, OopClosure* cl) {
+size_t G1OopStarChunkedList::chunks_do(ChunkedList<T*, mtGC>* head, OopClosure* cl) {
+  size_t result = 0;
   for (ChunkedList<T*, mtGC>* c = head; c != NULL; c = c->next_used()) {
+    result += c->size();
     for (size_t i = 0; i < c->size(); i++) {
       T* p = c->at(i);
       cl->do_oop(p);
     }
   }
+  return result;
 }
 
 #endif // SHARE_GC_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP
--- a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -372,7 +372,7 @@
     }
 
     size_t used_memory = pss->oops_into_optional_region(hr)->used_memory();
-    _g1h->phase_times()->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_index, used_memory, G1GCPhaseTimes::OptCSetUsedMemory);
+    _g1h->phase_times()->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_index, used_memory, G1GCPhaseTimes::ScanRSUsedMemory);
   }
 }
 
--- a/src/hotspot/share/gc/g1/g1Policy.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1Policy.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -105,7 +105,7 @@
 
   assert(Heap_lock->owned_by_self(), "Locking discipline.");
 
-  if (!adaptive_young_list_length()) {
+  if (!use_adaptive_young_list_length()) {
     _young_list_fixed_length = _young_gen_sizer->min_desired_young_length();
   }
   _young_gen_sizer->adjust_max_new_size(_g1h->max_expandable_regions());
@@ -195,7 +195,7 @@
 
 uint G1Policy::calculate_young_list_desired_min_length(uint base_min_length) const {
   uint desired_min_length = 0;
-  if (adaptive_young_list_length()) {
+  if (use_adaptive_young_list_length()) {
     if (_analytics->num_alloc_rate_ms() > 3) {
       double now_sec = os::elapsedTime();
       double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0;
@@ -252,7 +252,7 @@
   uint desired_max_length = calculate_young_list_desired_max_length();
 
   uint young_list_target_length = 0;
-  if (adaptive_young_list_length()) {
+  if (use_adaptive_young_list_length()) {
     if (collector_state()->in_young_only_phase()) {
       young_list_target_length =
                         calculate_young_list_target_length(rs_lengths,
@@ -304,7 +304,7 @@
                                                     uint base_min_length,
                                                     uint desired_min_length,
                                                     uint desired_max_length) const {
-  assert(adaptive_young_list_length(), "pre-condition");
+  assert(use_adaptive_young_list_length(), "pre-condition");
   assert(collector_state()->in_young_only_phase(), "only call this for young GCs");
 
   // In case some edge-condition makes the desired max length too small...
@@ -414,7 +414,7 @@
 }
 
 void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_lengths) {
-  guarantee( adaptive_young_list_length(), "should not call this otherwise" );
+  guarantee(use_adaptive_young_list_length(), "should not call this otherwise" );
 
   if (rs_lengths > _rs_lengths_prediction) {
     // add 10% to avoid having to recalculate often
@@ -430,7 +430,7 @@
 }
 
 void G1Policy::update_rs_lengths_prediction(size_t prediction) {
-  if (collector_state()->in_young_only_phase() && adaptive_young_list_length()) {
+  if (collector_state()->in_young_only_phase() && use_adaptive_young_list_length()) {
     _rs_lengths_prediction = prediction;
   }
 }
@@ -659,7 +659,11 @@
 
     double cost_per_entry_ms = 0.0;
     if (cards_scanned > 10) {
-      cost_per_entry_ms = average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned;
+      double avg_time_scan_rs = average_time_ms(G1GCPhaseTimes::ScanRS);
+      if (this_pause_was_young_only) {
+        avg_time_scan_rs += average_time_ms(G1GCPhaseTimes::OptScanRS);
+      }
+      cost_per_entry_ms = avg_time_scan_rs / cards_scanned;
       _analytics->report_cost_per_entry_ms(cost_per_entry_ms, this_pause_was_young_only);
     }
 
@@ -694,7 +698,7 @@
     double cost_per_byte_ms = 0.0;
 
     if (copied_bytes > 0) {
-      cost_per_byte_ms = average_time_ms(G1GCPhaseTimes::ObjCopy) / (double) copied_bytes;
+      cost_per_byte_ms = (average_time_ms(G1GCPhaseTimes::ObjCopy) + average_time_ms(G1GCPhaseTimes::OptObjCopy)) / (double) copied_bytes;
       _analytics->report_cost_per_byte_ms(cost_per_byte_ms, collector_state()->mark_or_rebuild_in_progress());
     }
 
@@ -906,8 +910,8 @@
   return young_list_length < young_list_max_length;
 }
 
-bool G1Policy::adaptive_young_list_length() const {
-  return _young_gen_sizer->adaptive_young_list_length();
+bool G1Policy::use_adaptive_young_list_length() const {
+  return _young_gen_sizer->use_adaptive_young_list_length();
 }
 
 size_t G1Policy::desired_survivor_size(uint max_regions) const {
@@ -1188,11 +1192,135 @@
   return (uint) result;
 }
 
-uint G1Policy::finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) {
-  double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms, survivor);
-  _collection_set->finalize_old_part(time_remaining_ms);
+void G1Policy::calculate_old_collection_set_regions(G1CollectionSetCandidates* candidates,
+                                                    double time_remaining_ms,
+                                                    uint& num_initial_regions,
+                                                    uint& num_optional_regions) {
+  assert(candidates != NULL, "Must be");
+
+  num_initial_regions = 0;
+  num_optional_regions = 0;
+  uint num_expensive_regions = 0;
+
+  double predicted_old_time_ms = 0.0;
+  double predicted_initial_time_ms = 0.0;
+  double predicted_optional_time_ms = 0.0;
+
+  double optional_threshold_ms = time_remaining_ms * optional_prediction_fraction();
+
+  const uint min_old_cset_length = calc_min_old_cset_length();
+  const uint max_old_cset_length = MAX2(min_old_cset_length, calc_max_old_cset_length());
+  const uint max_optional_regions = max_old_cset_length - min_old_cset_length;
+  bool check_time_remaining = use_adaptive_young_list_length();
+
+  uint candidate_idx = candidates->cur_idx();
+
+  log_debug(gc, ergo, cset)("Start adding old regions to collection set. Min %u regions, max %u regions, "
+                            "time remaining %1.2fms, optional threshold %1.2fms",
+                            min_old_cset_length, max_old_cset_length, time_remaining_ms, optional_threshold_ms);
+
+  HeapRegion* hr = candidates->at(candidate_idx);
+  while (hr != NULL) {
+    if (num_initial_regions + num_optional_regions >= max_old_cset_length) {
+      // Added maximum number of old regions to the CSet.
+      log_debug(gc, ergo, cset)("Finish adding old regions to collection set (Maximum number of regions). "
+                                "Initial %u regions, optional %u regions",
+                                num_initial_regions, num_optional_regions);
+      break;
+    }
+
+    // Stop adding regions if the remaining reclaimable space is
+    // not above G1HeapWastePercent.
+    size_t reclaimable_bytes = candidates->remaining_reclaimable_bytes();
+    double reclaimable_percent = reclaimable_bytes_percent(reclaimable_bytes);
+    double threshold = (double) G1HeapWastePercent;
+    if (reclaimable_percent <= threshold) {
+      // We've added enough old regions that the amount of uncollected
+      // reclaimable space is at or below the waste threshold. Stop
+      // adding old regions to the CSet.
+      log_debug(gc, ergo, cset)("Finish adding old regions to collection set (Reclaimable percentage below threshold). "
+                                "Reclaimable: " SIZE_FORMAT "%s (%1.2f%%) threshold: " UINTX_FORMAT "%%",
+                                byte_size_in_proper_unit(reclaimable_bytes), proper_unit_for_byte_size(reclaimable_bytes),
+                                reclaimable_percent, G1HeapWastePercent);
+      break;
+    }
 
-  return _collection_set->region_length();
+    double predicted_time_ms = predict_region_elapsed_time_ms(hr, false);
+    time_remaining_ms = MAX2(time_remaining_ms - predicted_time_ms, 0.0);
+    // Add regions to old set until we reach the minimum amount
+    if (num_initial_regions < min_old_cset_length) {
+      predicted_old_time_ms += predicted_time_ms;
+      num_initial_regions++;
+      // Record the number of regions added with no time remaining
+      if (time_remaining_ms == 0.0) {
+        num_expensive_regions++;
+      }
+    } else if (!check_time_remaining) {
+      // In the non-auto-tuning case, we'll finish adding regions
+      // to the CSet if we reach the minimum.
+      log_debug(gc, ergo, cset)("Finish adding old regions to collection set (Region amount reached min).");
+      break;
+    } else {
+      // Keep adding regions to old set until we reach the optional threshold
+      if (time_remaining_ms > optional_threshold_ms) {
+        predicted_old_time_ms += predicted_time_ms;
+        num_initial_regions++;
+      } else if (time_remaining_ms > 0) {
+        // Keep adding optional regions until time is up.
+        assert(num_optional_regions < max_optional_regions, "Should not be possible.");
+        predicted_optional_time_ms += predicted_time_ms;
+        num_optional_regions++;
+      } else {
+        log_debug(gc, ergo, cset)("Finish adding old regions to collection set (Predicted time too high).");
+        break;
+      }
+    }
+    hr = candidates->at(++candidate_idx);
+  }
+  if (hr == NULL) {
+    log_debug(gc, ergo, cset)("Old candidate collection set empty.");
+  }
+
+  if (num_expensive_regions > 0) {
+    log_debug(gc, ergo, cset)("Added %u initial old regions to collection set although the predicted time was too high.",
+                              num_expensive_regions);
+  }
+
+  log_debug(gc, ergo, cset)("Finish choosing collection set old regions. Initial: %u, optional: %u, "
+                            "predicted old time: %1.2fms, predicted optional time: %1.2fms, time remaining: %1.2f",
+                            num_initial_regions, num_optional_regions,
+                            predicted_initial_time_ms, predicted_optional_time_ms, time_remaining_ms);
+}
+
+void G1Policy::calculate_optional_collection_set_regions(G1CollectionSetCandidates* candidates,
+                                                         uint const max_optional_regions,
+                                                         double time_remaining_ms,
+                                                         uint& num_optional_regions) {
+  assert(_g1h->collector_state()->in_mixed_phase(), "Should only be called in mixed phase");
+
+  num_optional_regions = 0;
+  double prediction_ms = 0;
+  uint candidate_idx = candidates->cur_idx();
+
+  HeapRegion* r = candidates->at(candidate_idx);
+  while (num_optional_regions < max_optional_regions) {
+    assert(r != NULL, "Region must exist");
+    prediction_ms += predict_region_elapsed_time_ms(r, false);
+
+    if (prediction_ms > time_remaining_ms) {
+      log_debug(gc, ergo, cset)("Prediction %.3fms for region %u does not fit remaining time: %.3fms.",
+                                prediction_ms, r->hrm_index(), time_remaining_ms);
+      break;
+    }
+    // This region will be included in the next optional evacuation.
+
+    time_remaining_ms -= prediction_ms;
+    num_optional_regions++;
+    r = candidates->at(++candidate_idx);
+  }
+
+  log_debug(gc, ergo, cset)("Prepared %u regions out of %u for optional evacuation. Predicted time: %.3fms",
+                            num_optional_regions, max_optional_regions, prediction_ms);
 }
 
 void G1Policy::transfer_survivors_to_cset(const G1SurvivorRegions* survivors) {
--- a/src/hotspot/share/gc/g1/g1Policy.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1Policy.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -44,6 +44,7 @@
 
 class HeapRegion;
 class G1CollectionSet;
+class G1CollectionSetCandidates;
 class G1CollectionSetChooser;
 class G1IHOPControl;
 class G1Analytics;
@@ -344,7 +345,21 @@
   bool next_gc_should_be_mixed(const char* true_action_str,
                                const char* false_action_str) const;
 
-  uint finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor);
+  // Calculate and return the number of initial and optional old gen regions from
+  // the given collection set candidates and the remaining time.
+  void calculate_old_collection_set_regions(G1CollectionSetCandidates* candidates,
+                                            double time_remaining_ms,
+                                            uint& num_initial_regions,
+                                            uint& num_optional_regions);
+
+  // Calculate the number of optional regions from the given collection set candidates,
+  // the remaining time and the maximum number of these regions and return the number
+  // of actually selected regions in num_optional_regions.
+  void calculate_optional_collection_set_regions(G1CollectionSetCandidates* candidates,
+                                                 uint const max_optional_regions,
+                                                 double time_remaining_ms,
+                                                 uint& num_optional_regions);
+
 private:
   // Set the state to start a concurrent marking cycle and clear
   // _initiate_conc_mark_if_possible because it has now been
@@ -384,7 +399,7 @@
     return _young_list_max_length;
   }
 
-  bool adaptive_young_list_length() const;
+  bool use_adaptive_young_list_length() const;
 
   void transfer_survivors_to_cset(const G1SurvivorRegions* survivors);
 
@@ -403,11 +418,13 @@
   AgeTable _survivors_age_table;
 
   size_t desired_survivor_size(uint max_regions) const;
-public:
+
   // Fraction used when predicting how many optional regions to include in
   // the CSet. This fraction of the available time is used for optional regions,
   // the rest is used to add old regions to the normal CSet.
   double optional_prediction_fraction() { return 0.2; }
+
+public:
   // Fraction used when evacuating the optional regions. This fraction of the
   // remaining time is used to choose what regions to include in the evacuation.
   double optional_evacuation_fraction() { return 0.75; }
--- a/src/hotspot/share/gc/g1/g1RemSet.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1RemSet.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -316,6 +316,8 @@
   _scan_state(scan_state),
   _phase(phase),
   _worker_i(worker_i),
+  _opt_refs_scanned(0),
+  _opt_refs_memory_used(0),
   _cards_scanned(0),
   _cards_claimed(0),
   _cards_skipped(0),
@@ -338,6 +340,19 @@
   _cards_scanned++;
 }
 
+void G1ScanRSForRegionClosure::scan_opt_rem_set_roots(HeapRegion* r) {
+  EventGCPhaseParallel event;
+
+  G1OopStarChunkedList* opt_rem_set_list = _pss->oops_into_optional_region(r);
+
+  G1ScanObjsDuringScanRSClosure scan_cl(_g1h, _pss);
+  G1ScanRSForOptionalClosure cl(&scan_cl);
+  _opt_refs_scanned += opt_rem_set_list->oops_do(&cl, _pss->closures()->raw_strong_oops());
+  _opt_refs_memory_used += opt_rem_set_list->used_memory();
+
+  event.commit(GCId::current(), _worker_i, G1GCPhaseTimes::phase_name(_phase));
+}
+
 void G1ScanRSForRegionClosure::scan_rem_set_roots(HeapRegion* r) {
   EventGCPhaseParallel event;
   uint const region_idx = r->hrm_index();
@@ -414,11 +429,16 @@
 }
 
 bool G1ScanRSForRegionClosure::do_heap_region(HeapRegion* r) {
-  assert(r->in_collection_set(),
-         "Should only be called on elements of the collection set but region %u is not.",
-         r->hrm_index());
+  assert(r->in_collection_set(), "Region %u is not in the collection set.", r->hrm_index());
   uint const region_idx = r->hrm_index();
 
+  // The individual references for the optional remembered set are per-worker, so we
+  // always need to scan them.
+  if (r->has_index_in_opt_cset()) {
+    G1EvacPhaseWithTrimTimeTracker timer(_pss, _rem_set_root_scan_time, _rem_set_trim_partially_time);
+    scan_opt_rem_set_roots(r);
+  }
+
   // Do an early out if we know we are complete.
   if (_scan_state->iter_is_complete(region_idx)) {
     return false;
@@ -437,22 +457,33 @@
   return false;
 }
 
-void G1RemSet::scan_rem_set(G1ParScanThreadState* pss, uint worker_i) {
+void G1RemSet::scan_rem_set(G1ParScanThreadState* pss,
+                            uint worker_i,
+                            G1GCPhaseTimes::GCParPhases scan_phase,
+                            G1GCPhaseTimes::GCParPhases objcopy_phase,
+                            G1GCPhaseTimes::GCParPhases coderoots_phase) {
+  assert(pss->trim_ticks().value() == 0, "Queues must have been trimmed before entering.");
+
   G1ScanObjsDuringScanRSClosure scan_cl(_g1h, pss);
-  G1ScanRSForRegionClosure cl(_scan_state, &scan_cl, pss, G1GCPhaseTimes::ScanRS, worker_i);
-  _g1h->collection_set_iterate_from(&cl, worker_i);
+  G1ScanRSForRegionClosure cl(_scan_state, &scan_cl, pss, scan_phase, worker_i);
+  _g1h->collection_set_iterate_increment_from(&cl, worker_i);
 
   G1GCPhaseTimes* p = _g1p->phase_times();
 
-  p->record_time_secs(G1GCPhaseTimes::ScanRS, worker_i, cl.rem_set_root_scan_time().seconds());
-  p->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_i, cl.rem_set_trim_partially_time().seconds());
+  p->record_or_add_time_secs(objcopy_phase, worker_i, cl.rem_set_trim_partially_time().seconds());
 
-  p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_scanned(), G1GCPhaseTimes::ScanRSScannedCards);
-  p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_claimed(), G1GCPhaseTimes::ScanRSClaimedCards);
-  p->record_thread_work_item(G1GCPhaseTimes::ScanRS, worker_i, cl.cards_skipped(), G1GCPhaseTimes::ScanRSSkippedCards);
+  p->record_or_add_time_secs(scan_phase, worker_i, cl.rem_set_root_scan_time().seconds());
+  p->record_or_add_thread_work_item(scan_phase, worker_i, cl.cards_scanned(), G1GCPhaseTimes::ScanRSScannedCards);
+  p->record_or_add_thread_work_item(scan_phase, worker_i, cl.cards_claimed(), G1GCPhaseTimes::ScanRSClaimedCards);
+  p->record_or_add_thread_work_item(scan_phase, worker_i, cl.cards_skipped(), G1GCPhaseTimes::ScanRSSkippedCards);
+  // At this time we only record some metrics for the optional remembered set.
+  if (scan_phase == G1GCPhaseTimes::OptScanRS) {
+    p->record_or_add_thread_work_item(scan_phase, worker_i, cl.opt_refs_scanned(), G1GCPhaseTimes::ScanRSScannedOptRefs);
+    p->record_or_add_thread_work_item(scan_phase, worker_i, cl.opt_refs_memory_used(), G1GCPhaseTimes::ScanRSUsedMemory);
+  }
 
-  p->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, cl.strong_code_root_scan_time().seconds());
-  p->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_i, cl.strong_code_root_trim_partially_time().seconds());
+  p->record_or_add_time_secs(coderoots_phase, worker_i, cl.strong_code_root_scan_time().seconds());
+  p->add_time_secs(objcopy_phase, worker_i, cl.strong_code_root_trim_partially_time().seconds());
 }
 
 // Closure used for updating rem sets. Only called during an evacuation pause.
@@ -514,11 +545,6 @@
   }
 }
 
-void G1RemSet::oops_into_collection_set_do(G1ParScanThreadState* pss, uint worker_i) {
-  update_rem_set(pss, worker_i);
-  scan_rem_set(pss, worker_i);;
-}
-
 void G1RemSet::prepare_for_oops_into_collection_set_do() {
   G1BarrierSet::dirty_card_queue_set().concatenate_logs();
   _scan_state->reset();
--- a/src/hotspot/share/gc/g1/g1RemSet.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1RemSet.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -60,14 +60,6 @@
 
   G1RemSetSummary _prev_period_summary;
 
-  // Scan all remembered sets of the collection set for references into the collection
-  // set.
-  void scan_rem_set(G1ParScanThreadState* pss, uint worker_i);
-
-  // Flush remaining refinement buffers for cross-region references to either evacuate references
-  // into the collection set or update the remembered set.
-  void update_rem_set(G1ParScanThreadState* pss, uint worker_i);
-
   G1CollectedHeap* _g1h;
   size_t _num_conc_refined_cards; // Number of cards refined concurrently to the mutator.
 
@@ -93,12 +85,19 @@
            G1HotCardCache* hot_card_cache);
   ~G1RemSet();
 
-  // Process all oops in the collection set from the cards in the refinement buffers and
-  // remembered sets using pss.
-  //
+  // Scan all remembered sets of the collection set for references into the collection
+  // set.
   // Further applies heap_region_codeblobs on the oops of the unmarked nmethods on the strong code
   // roots list for each region in the collection set.
-  void oops_into_collection_set_do(G1ParScanThreadState* pss, uint worker_i);
+  void scan_rem_set(G1ParScanThreadState* pss,
+                    uint worker_i,
+                    G1GCPhaseTimes::GCParPhases scan_phase,
+                    G1GCPhaseTimes::GCParPhases objcopy_phase,
+                    G1GCPhaseTimes::GCParPhases coderoots_phase);
+
+  // Flush remaining refinement buffers for cross-region references to either evacuate references
+  // into the collection set or update the remembered set.
+  void update_rem_set(G1ParScanThreadState* pss, uint worker_i);
 
   // Prepare for and cleanup after an oops_into_collection_set_do
   // call.  Must call each of these once before and after (in sequential
@@ -144,6 +143,9 @@
 
   uint   _worker_i;
 
+  size_t _opt_refs_scanned;
+  size_t _opt_refs_memory_used;
+
   size_t _cards_scanned;
   size_t _cards_claimed;
   size_t _cards_skipped;
@@ -157,6 +159,7 @@
   void claim_card(size_t card_index, const uint region_idx_for_card);
   void scan_card(MemRegion mr, uint region_idx_for_card);
 
+  void scan_opt_rem_set_roots(HeapRegion* r);
   void scan_rem_set_roots(HeapRegion* r);
   void scan_strong_code_roots(HeapRegion* r);
 public:
@@ -177,6 +180,9 @@
   size_t cards_scanned() const { return _cards_scanned; }
   size_t cards_claimed() const { return _cards_claimed; }
   size_t cards_skipped() const { return _cards_skipped; }
+
+  size_t opt_refs_scanned() const { return _opt_refs_scanned; }
+  size_t opt_refs_memory_used() const { return _opt_refs_memory_used; }
 };
 
 #endif // SHARE_GC_G1_G1REMSET_HPP
--- a/src/hotspot/share/gc/g1/g1RootProcessor.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1RootProcessor.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -38,7 +38,6 @@
 #include "gc/g1/g1RootClosures.hpp"
 #include "gc/g1/g1RootProcessor.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
-#include "gc/shared/oopStorageParState.hpp"
 #include "gc/shared/referenceProcessor.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/mutex.hpp"
@@ -71,7 +70,6 @@
     _g1h(g1h),
     _process_strong_tasks(G1RP_PS_NumElements),
     _srs(n_workers),
-    _par_state_string(StringTable::weak_storage()),
     _lock(Mutex::leaf, "G1 Root Scanning barrier lock", false, Monitor::_safepoint_check_never),
     _n_workers_discovered_strong_classes(0) {}
 
--- a/src/hotspot/share/gc/g1/g1RootProcessor.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1RootProcessor.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -25,7 +25,6 @@
 #ifndef SHARE_GC_G1_G1ROOTPROCESSOR_HPP
 #define SHARE_GC_G1_G1ROOTPROCESSOR_HPP
 
-#include "gc/shared/oopStorageParState.hpp"
 #include "gc/shared/strongRootsScope.hpp"
 #include "memory/allocation.hpp"
 #include "runtime/mutex.hpp"
@@ -50,7 +49,6 @@
   G1CollectedHeap* _g1h;
   SubTasksDone _process_strong_tasks;
   StrongRootsScope _srs;
-  OopStorage::ParState<false, false> _par_state_string;
 
   // Used to implement the Thread work barrier.
   Monitor _lock;
--- a/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp	Tue Apr 09 11:48:54 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
@@ -28,7 +28,9 @@
 #include "utilities/growableArray.hpp"
 #include "utilities/debug.hpp"
 
-G1SurvivorRegions::G1SurvivorRegions() : _regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapRegion*>(8, true, mtGC)) {}
+G1SurvivorRegions::G1SurvivorRegions() :
+  _regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapRegion*>(8, true, mtGC)),
+  _used_bytes(0) {}
 
 void G1SurvivorRegions::add(HeapRegion* hr) {
   assert(hr->is_survivor(), "should be flagged as survivor region");
@@ -51,5 +53,9 @@
 
 void G1SurvivorRegions::clear() {
   _regions->clear();
+  _used_bytes = 0;
 }
 
+void G1SurvivorRegions::add_used_bytes(size_t used_bytes) {
+  _used_bytes += used_bytes;
+}
--- a/src/hotspot/share/gc/g1/g1SurvivorRegions.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1SurvivorRegions.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -34,6 +34,7 @@
 class G1SurvivorRegions {
 private:
   GrowableArray<HeapRegion*>* _regions;
+  volatile size_t             _used_bytes;
 
 public:
   G1SurvivorRegions();
@@ -49,6 +50,11 @@
   const GrowableArray<HeapRegion*>* regions() const {
     return _regions;
   }
+
+  // Used bytes of all survivor regions.
+  size_t used_bytes() const { return _used_bytes; }
+
+  void add_used_bytes(size_t used_bytes);
 };
 
 #endif // SHARE_GC_G1_G1SURVIVORREGIONS_HPP
--- a/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1YoungGenSizer.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -30,14 +30,14 @@
 #include "logging/log.hpp"
 
 G1YoungGenSizer::G1YoungGenSizer() : _sizer_kind(SizerDefaults),
-  _adaptive_size(true), _min_desired_young_length(0), _max_desired_young_length(0) {
+  _use_adaptive_sizing(true), _min_desired_young_length(0), _max_desired_young_length(0) {
 
   if (FLAG_IS_CMDLINE(NewRatio)) {
     if (FLAG_IS_CMDLINE(NewSize) || FLAG_IS_CMDLINE(MaxNewSize)) {
       log_warning(gc, ergo)("-XX:NewSize and -XX:MaxNewSize override -XX:NewRatio");
     } else {
       _sizer_kind = SizerNewRatio;
-      _adaptive_size = false;
+      _use_adaptive_sizing = false;
       return;
     }
   }
@@ -59,7 +59,7 @@
                              MAX2((uint) (MaxNewSize / HeapRegion::GrainBytes),
                                   1U);
       _sizer_kind = SizerMaxAndNewSize;
-      _adaptive_size = _min_desired_young_length != _max_desired_young_length;
+      _use_adaptive_sizing = _min_desired_young_length != _max_desired_young_length;
     } else {
       _sizer_kind = SizerNewSizeOnly;
     }
--- a/src/hotspot/share/gc/g1/g1YoungGenSizer.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1YoungGenSizer.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -77,7 +77,7 @@
 
   // False when using a fixed young generation size due to command-line options,
   // true otherwise.
-  bool _adaptive_size;
+  bool _use_adaptive_sizing;
 
   uint calculate_default_min_length(uint new_number_of_heap_regions);
   uint calculate_default_max_length(uint new_number_of_heap_regions);
@@ -104,8 +104,8 @@
     return _max_desired_young_length;
   }
 
-  bool adaptive_young_list_length() const {
-    return _adaptive_size;
+  bool use_adaptive_young_list_length() const {
+    return _use_adaptive_sizing;
   }
 
   static G1YoungGenSizer* create_gen_sizer(G1CollectorPolicy* policy);
--- a/src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1YoungRemSetSamplingThread.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -165,7 +165,7 @@
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   G1Policy* policy = g1h->policy();
 
-  if (policy->adaptive_young_list_length()) {
+  if (policy->use_adaptive_young_list_length()) {
     G1YoungRemSetSamplingClosure cl(&sts);
 
     G1CollectionSet* g1cs = g1h->collection_set();
--- a/src/hotspot/share/gc/g1/heapRegion.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/heapRegion.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -117,6 +117,7 @@
          "Should not clear heap region %u in the collection set", hrm_index());
 
   set_young_index_in_cset(-1);
+  clear_index_in_opt_cset();
   uninstall_surv_rate_group();
   set_free();
   reset_pre_dummy_top();
@@ -241,7 +242,7 @@
     _containing_set(NULL),
 #endif
     _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0),
-    _index_in_opt_cset(G1OptionalCSet::InvalidCSetIndex), _young_index_in_cset(-1),
+    _index_in_opt_cset(InvalidCSetIndex), _young_index_in_cset(-1),
     _surv_rate_group(NULL), _age_index(-1),
     _prev_top_at_mark_start(NULL), _next_top_at_mark_start(NULL),
     _recorded_rs_length(0), _predicted_elapsed_time_ms(0)
@@ -514,7 +515,7 @@
     if (!CompressedOops::is_null(heap_oop)) {
       oop obj = CompressedOops::decode_not_null(heap_oop);
       bool failed = false;
-      if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
+      if (!_g1h->is_in(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
         MutexLockerEx x(ParGCRareEvent_lock,
           Mutex::_no_safepoint_check_flag);
 
@@ -522,7 +523,7 @@
           log.error("----------");
         }
         ResourceMark rm;
-        if (!_g1h->is_in_closed_subset(obj)) {
+        if (!_g1h->is_in(obj)) {
           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
                     p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
--- a/src/hotspot/share/gc/g1/heapRegion.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/heapRegion.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -250,6 +250,8 @@
   // The calculated GC efficiency of the region.
   double _gc_efficiency;
 
+  static const uint InvalidCSetIndex = UINT_MAX;
+
   // The index in the optional regions array, if this region
   // is considered optional during a mixed collections.
   uint _index_in_opt_cset;
@@ -549,8 +551,13 @@
   void calc_gc_efficiency(void);
   double gc_efficiency() const { return _gc_efficiency;}
 
-  uint index_in_opt_cset() const { return _index_in_opt_cset; }
+  uint index_in_opt_cset() const {
+    assert(has_index_in_opt_cset(), "Opt cset index not set.");
+    return _index_in_opt_cset;
+  }
+  bool has_index_in_opt_cset() const { return _index_in_opt_cset != InvalidCSetIndex; }
   void set_index_in_opt_cset(uint index) { _index_in_opt_cset = index; }
+  void clear_index_in_opt_cset() { _index_in_opt_cset = InvalidCSetIndex; }
 
   int  young_index_in_cset() const { return _young_index_in_cset; }
   void set_young_index_in_cset(int index) {
--- a/src/hotspot/share/gc/g1/vmStructs_g1.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/g1/vmStructs_g1.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -52,8 +52,8 @@
   nonstatic_field(HeapRegionManager, _regions,          G1HeapRegionTable)    \
   nonstatic_field(HeapRegionManager, _num_committed,    uint)                 \
                                                                               \
-  nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t)               \
-  nonstatic_field(G1CollectedHeap, _hrm,                HeapRegionManager*)    \
+  volatile_nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t)      \
+  nonstatic_field(G1CollectedHeap, _hrm,                HeapRegionManager*)   \
   nonstatic_field(G1CollectedHeap, _g1mm,               G1MonitoringSupport*) \
   nonstatic_field(G1CollectedHeap, _old_set,            HeapRegionSetBase)    \
   nonstatic_field(G1CollectedHeap, _archive_set,        HeapRegionSetBase)    \
--- a/src/hotspot/share/gc/serial/serialHeap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/serial/serialHeap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -59,11 +59,6 @@
   virtual GrowableArray<GCMemoryManager*> memory_managers();
   virtual GrowableArray<MemoryPool*> memory_pools();
 
-  // override
-  virtual bool is_in_closed_subset(const void* p) const {
-    return is_in(p);
-  }
-
   DefNewGeneration* young_gen() const {
     assert(_young_gen->kind() == Generation::DefNew, "Wrong generation type");
     return static_cast<DefNewGeneration*>(_young_gen);
--- a/src/hotspot/share/gc/shared/barrierSet.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/barrierSet.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -130,8 +130,18 @@
   virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) {}
   virtual void on_thread_create(Thread* thread) {}
   virtual void on_thread_destroy(Thread* thread) {}
+
+  // These perform BarrierSet-related initialization/cleanup before the thread
+  // is added to or removed from the corresponding set of threads. The
+  // argument thread is the current thread. These are called either holding
+  // the Threads_lock (for a JavaThread) and so not at a safepoint, or holding
+  // the NonJavaThreadsList_lock (for a NonJavaThread) locked by the
+  // caller. That locking ensures the operation is "atomic" with the list
+  // modification wrto operations that hold the NJTList_lock and either also
+  // hold the Threads_lock or are at a safepoint.
   virtual void on_thread_attach(Thread* thread) {}
   virtual void on_thread_detach(Thread* thread) {}
+
   virtual void make_parsable(JavaThread* thread) {}
 
 #ifdef CHECK_UNHANDLED_OOPS
--- a/src/hotspot/share/gc/shared/collectedHeap.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/collectedHeap.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -575,3 +575,8 @@
 size_t CollectedHeap::obj_size(oop obj) const {
   return obj->size();
 }
+
+uint32_t CollectedHeap::hash_oop(oop obj) const {
+  const uintptr_t addr = cast_from_oop<uintptr_t>(obj);
+  return static_cast<uint32_t>(addr >> LogMinObjAlignment);
+}
--- a/src/hotspot/share/gc/shared/collectedHeap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/collectedHeap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -239,37 +239,7 @@
 
   DEBUG_ONLY(bool is_in_or_null(const void* p) const { return p == NULL || is_in(p); })
 
-  // Let's define some terms: a "closed" subset of a heap is one that
-  //
-  // 1) contains all currently-allocated objects, and
-  //
-  // 2) is closed under reference: no object in the closed subset
-  //    references one outside the closed subset.
-  //
-  // Membership in a heap's closed subset is useful for assertions.
-  // Clearly, the entire heap is a closed subset, so the default
-  // implementation is to use "is_in_reserved".  But this may not be too
-  // liberal to perform useful checking.  Also, the "is_in" predicate
-  // defines a closed subset, but may be too expensive, since "is_in"
-  // verifies that its argument points to an object head.  The
-  // "closed_subset" method allows a heap to define an intermediate
-  // predicate, allowing more precise checking than "is_in_reserved" at
-  // lower cost than "is_in."
-
-  // One important case is a heap composed of disjoint contiguous spaces,
-  // such as the Garbage-First collector.  Such heaps have a convenient
-  // closed subset consisting of the allocated portions of those
-  // contiguous spaces.
-
-  // Return "TRUE" iff the given pointer points into the heap's defined
-  // closed subset (which defaults to the entire heap).
-  virtual bool is_in_closed_subset(const void* p) const {
-    return is_in_reserved(p);
-  }
-
-  bool is_in_closed_subset_or_null(const void* p) const {
-    return p == NULL || is_in_closed_subset(p);
-  }
+  virtual uint32_t hash_oop(oop obj) const;
 
   void set_gc_cause(GCCause::Cause v) {
      if (UsePerfData) {
@@ -510,11 +480,11 @@
   void print_heap_after_gc();
 
   // Registering and unregistering an nmethod (compiled code) with the heap.
-  // Override with specific mechanism for each specialized heap type.
-  virtual void register_nmethod(nmethod* nm) {}
-  virtual void unregister_nmethod(nmethod* nm) {}
-  virtual void flush_nmethod(nmethod* nm) {}
-  virtual void verify_nmethod(nmethod* nmethod) {}
+  virtual void register_nmethod(nmethod* nm) = 0;
+  virtual void unregister_nmethod(nmethod* nm) = 0;
+  // Callback for when nmethod is about to be deleted.
+  virtual void flush_nmethod(nmethod* nm) = 0;
+  virtual void verify_nmethod(nmethod* nm) = 0;
 
   void trace_heap_before_gc(const GCTracer* gc_tracer);
   void trace_heap_after_gc(const GCTracer* gc_tracer);
--- a/src/hotspot/share/gc/shared/concurrentGCThread.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/concurrentGCThread.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -23,72 +23,58 @@
  */
 
 #include "precompiled.hpp"
-#include "classfile/systemDictionary.hpp"
 #include "gc/shared/concurrentGCThread.hpp"
-#include "oops/instanceRefKlass.hpp"
-#include "oops/oop.inline.hpp"
 #include "runtime/init.hpp"
-#include "runtime/java.hpp"
-#include "runtime/javaCalls.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/orderAccess.hpp"
 #include "runtime/os.hpp"
 
 ConcurrentGCThread::ConcurrentGCThread() :
-  _should_terminate(false), _has_terminated(false) {
-};
+    _should_terminate(false),
+    _has_terminated(false) {}
 
 void ConcurrentGCThread::create_and_start(ThreadPriority prio) {
   if (os::create_thread(this, os::cgc_thread)) {
-    // XXX: need to set this to low priority
-    // unless "aggressive mode" set; priority
-    // should be just less than that of VMThread.
     os::set_priority(this, prio);
-    if (!_should_terminate) {
-      os::start_thread(this);
-    }
-  }
-}
-
-void ConcurrentGCThread::initialize_in_thread() {
-  this->set_active_handles(JNIHandleBlock::allocate_block());
-  // From this time Thread::current() should be working.
-  assert(this == Thread::current(), "just checking");
-}
-
-void ConcurrentGCThread::terminate() {
-  assert(_should_terminate, "Should only be called on terminate request.");
-  // Signal that it is terminated
-  {
-    MutexLockerEx mu(Terminator_lock,
-                     Mutex::_no_safepoint_check_flag);
-    _has_terminated = true;
-    Terminator_lock->notify();
+    os::start_thread(this);
   }
 }
 
 void ConcurrentGCThread::run() {
-  initialize_in_thread();
+  // Setup handle area
+  set_active_handles(JNIHandleBlock::allocate_block());
+
+  // Wait for initialization to complete
   wait_init_completed();
 
   run_service();
 
-  terminate();
+  // Signal thread has terminated
+  MonitorLockerEx ml(Terminator_lock);
+  OrderAccess::release_store(&_has_terminated, true);
+  ml.notify_all();
 }
 
 void ConcurrentGCThread::stop() {
-  // it is ok to take late safepoints here, if needed
-  {
-    MutexLockerEx mu(Terminator_lock);
-    assert(!_has_terminated,   "stop should only be called once");
-    assert(!_should_terminate, "stop should only be called once");
-    _should_terminate = true;
-  }
+  assert(!should_terminate(), "Invalid state");
+  assert(!has_terminated(), "Invalid state");
+
+  // Signal thread to terminate
+  OrderAccess::release_store_fence(&_should_terminate, true);
 
   stop_service();
 
-  {
-    MutexLockerEx mu(Terminator_lock);
-    while (!_has_terminated) {
-      Terminator_lock->wait();
-    }
+  // Wait for thread to terminate
+  MonitorLockerEx ml(Terminator_lock);
+  while (!_has_terminated) {
+    ml.wait();
   }
 }
+
+bool ConcurrentGCThread::should_terminate() const {
+  return OrderAccess::load_acquire(&_should_terminate);
+}
+
+bool ConcurrentGCThread::has_terminated() const {
+  return OrderAccess::load_acquire(&_has_terminated);
+}
--- a/src/hotspot/share/gc/shared/concurrentGCThread.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/concurrentGCThread.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -26,48 +26,28 @@
 #define SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP
 
 #include "runtime/thread.hpp"
-#include "utilities/macros.hpp"
 
 class ConcurrentGCThread: public NamedThread {
-  friend class VMStructs;
-
-  bool volatile _should_terminate;
-  bool _has_terminated;
-
-  // Do initialization steps in the thread: record stack base and size,
-  // init thread local storage, set JNI handle block.
-  void initialize_in_thread();
-
-  // Wait until Universe::is_fully_initialized();
-  void wait_for_universe_init();
-
-  // Record that the current thread is terminating, and will do more
-  // concurrent work.
-  void terminate();
+private:
+  volatile bool _should_terminate;
+  volatile bool _has_terminated;
 
 protected:
-  // Create and start the thread (setting it's priority.)
   void create_and_start(ThreadPriority prio = NearMaxPriority);
 
-  // Do the specific GC work. Called by run() after initialization complete.
   virtual void run_service() = 0;
-
-  // Shut down the specific GC work. Called by stop() as part of termination protocol.
-  virtual void stop_service()  = 0;
+  virtual void stop_service() = 0;
 
 public:
   ConcurrentGCThread();
 
-  // Tester
-  bool is_ConcurrentGC_thread() const { return true; }
+  virtual bool is_ConcurrentGC_thread() const { return true; }
 
   virtual void run();
-
-  // shutdown following termination protocol
   virtual void stop();
 
-  bool should_terminate() { return _should_terminate; }
-  bool has_terminated()   { return _has_terminated; }
+  bool should_terminate() const;
+  bool has_terminated() const;
 };
 
 #endif // SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -824,7 +824,6 @@
                                      CLDClosure* weak_cld_closure,
                                      CodeBlobToOopClosure* code_roots) {
   // General roots.
-  assert(Threads::thread_claim_parity() != 0, "must have called prologue code");
   assert(code_roots != NULL, "code root closure should always be set");
   // _n_termination for _process_strong_tasks should be set up stream
   // in a method not running in a GC worker.  Otherwise the GC worker
--- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -234,10 +234,9 @@
   void collect(GCCause::Cause cause, GenerationType max_generation);
 
   // Returns "TRUE" iff "p" points into the committed areas of the heap.
-  // The methods is_in(), is_in_closed_subset() and is_in_youngest() may
-  // be expensive to compute in general, so, to prevent
-  // their inadvertent use in product jvm's, we restrict their use to
-  // assertion checking or verification only.
+  // The methods is_in() and is_in_youngest() may be expensive to compute
+  // in general, so, to prevent their inadvertent use in product jvm's, we
+  // restrict their use to assertion checking or verification only.
   bool is_in(const void* p) const;
 
   // Returns true if the reference is to an object in the reserved space
--- a/src/hotspot/share/gc/shared/satbMarkQueue.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/satbMarkQueue.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -170,7 +170,11 @@
 #ifdef ASSERT
   verify_active_states(expected_active);
 #endif // ASSERT
-  _all_active = active;
+  // Update the global state, synchronized with threads list management.
+  {
+    MutexLockerEx ml(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag);
+    _all_active = active;
+  }
 
   class SetThreadActiveClosure : public ThreadClosure {
     SATBMarkQueueSet* _qset;
--- a/src/hotspot/share/gc/shared/strongRootsScope.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/strongRootsScope.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 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
@@ -37,7 +37,7 @@
 }
 
 StrongRootsScope::StrongRootsScope(uint n_threads) : _n_threads(n_threads) {
-  Threads::change_thread_claim_parity();
+  Threads::change_thread_claim_token();
 }
 
 StrongRootsScope::~StrongRootsScope() {
--- a/src/hotspot/share/gc/shared/workerDataArray.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/workerDataArray.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -34,7 +34,7 @@
 class WorkerDataArray  : public CHeapObj<mtGC> {
   friend class WDAPrinter;
 public:
-  static const uint MaxThreadWorkItems = 4;
+  static const uint MaxThreadWorkItems = 5;
 private:
   T*          _data;
   uint        _length;
@@ -50,6 +50,7 @@
   void set_thread_work_item(uint worker_i, size_t value, uint index = 0);
   void add_thread_work_item(uint worker_i, size_t value, uint index = 0);
   void set_or_add_thread_work_item(uint worker_i, size_t value, uint index = 0);
+  size_t get_thread_work_item(uint worker_i, uint index = 0);
 
   WorkerDataArray<size_t>* thread_work_items(uint index = 0) const {
     assert(index < MaxThreadWorkItems, "Tried to access thread work item %u max %u", index, MaxThreadWorkItems);
--- a/src/hotspot/share/gc/shared/workerDataArray.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shared/workerDataArray.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -92,6 +92,13 @@
 }
 
 template <typename T>
+size_t WorkerDataArray<T>::get_thread_work_item(uint worker_i, uint index) {
+  assert(index < MaxThreadWorkItems, "Tried to access thread work item %u (max %u)", index, MaxThreadWorkItems);
+  assert(_thread_work_items[index] != NULL, "No sub count");
+  return _thread_work_items[index]->get(worker_i);
+}
+
+template <typename T>
 void WorkerDataArray<T>::add(uint worker_i, T value) {
   assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
   assert(_data[worker_i] != uninitialized(), "No data to add to for worker %d", worker_i);
--- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -46,9 +46,9 @@
   bs->gen_pre_barrier_stub(ce, this);
 }
 
-void ShenandoahWriteBarrierStub::emit_code(LIR_Assembler* ce) {
+void ShenandoahLoadReferenceBarrierStub::emit_code(LIR_Assembler* ce) {
   ShenandoahBarrierSetAssembler* bs = (ShenandoahBarrierSetAssembler*)BarrierSet::barrier_set()->barrier_set_assembler();
-  bs->gen_write_barrier_stub(ce, this);
+  bs->gen_load_reference_barrier_stub(ce, this);
 }
 
 void ShenandoahBarrierSetC1::pre_barrier(LIRGenerator* gen, CodeEmitInfo* info, DecoratorSet decorators, LIR_Opr addr_opr, LIR_Opr pre_val) {
@@ -105,40 +105,16 @@
   __ branch_destination(slow->continuation());
 }
 
-LIR_Opr ShenandoahBarrierSetC1::read_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
-  if (UseShenandoahGC && ShenandoahReadBarrier) {
-    return read_barrier_impl(gen, obj, info, need_null_check);
+LIR_Opr ShenandoahBarrierSetC1::load_reference_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
+  if (ShenandoahLoadRefBarrier) {
+    return load_reference_barrier_impl(gen, obj, info, need_null_check);
   } else {
     return obj;
   }
 }
 
-LIR_Opr ShenandoahBarrierSetC1::read_barrier_impl(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
-  assert(UseShenandoahGC && (ShenandoahReadBarrier || ShenandoahStoreValReadBarrier), "Should be enabled");
-  LabelObj* done = new LabelObj();
-  LIR_Opr result = gen->new_register(T_OBJECT);
-  __ move(obj, result);
-  if (need_null_check) {
-    __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
-    __ branch(lir_cond_equal, T_LONG, done->label());
-  }
-  LIR_Address* brooks_ptr_address = gen->generate_address(result, ShenandoahBrooksPointer::byte_offset(), T_ADDRESS);
-  __ load(brooks_ptr_address, result, info ? new CodeEmitInfo(info) : NULL, lir_patch_none);
-
-  __ branch_destination(done->label());
-  return result;
-}
-
-LIR_Opr ShenandoahBarrierSetC1::write_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
-  if (UseShenandoahGC && ShenandoahWriteBarrier) {
-    return write_barrier_impl(gen, obj, info, need_null_check);
-  } else {
-    return obj;
-  }
-}
-
-LIR_Opr ShenandoahBarrierSetC1::write_barrier_impl(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
-  assert(UseShenandoahGC && (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "Should be enabled");
+LIR_Opr ShenandoahBarrierSetC1::load_reference_barrier_impl(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
+  assert(ShenandoahLoadRefBarrier, "Should be enabled");
 
   obj = ensure_in_register(gen, obj);
   assert(obj->is_register(), "must be a register at this point");
@@ -168,7 +144,7 @@
   }
   __ cmp(lir_cond_notEqual, flag_val, LIR_OprFact::intConst(0));
 
-  CodeStub* slow = new ShenandoahWriteBarrierStub(obj, result, info ? new CodeEmitInfo(info) : NULL, need_null_check);
+  CodeStub* slow = new ShenandoahLoadReferenceBarrierStub(obj, result, info ? new CodeEmitInfo(info) : NULL, need_null_check);
   __ branch(lir_cond_notEqual, T_INT, slow);
   __ branch_destination(slow->continuation());
 
@@ -189,58 +165,13 @@
 }
 
 LIR_Opr ShenandoahBarrierSetC1::storeval_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, DecoratorSet decorators) {
-  bool need_null_check = (decorators & IS_NOT_NULL) == 0;
   if (ShenandoahStoreValEnqueueBarrier) {
-    obj = write_barrier_impl(gen, obj, info, need_null_check);
+    obj = ensure_in_register(gen, obj);
     pre_barrier(gen, info, decorators, LIR_OprFact::illegalOpr, obj);
   }
-  if (ShenandoahStoreValReadBarrier) {
-    obj = read_barrier_impl(gen, obj, info, true /*need_null_check*/);
-  }
   return obj;
 }
 
-LIR_Opr ShenandoahBarrierSetC1::resolve_address(LIRAccess& access, bool resolve_in_register) {
-  DecoratorSet decorators = access.decorators();
-  bool is_array = (decorators & IS_ARRAY) != 0;
-  bool needs_patching = (decorators & C1_NEEDS_PATCHING) != 0;
-
-  bool is_write = (decorators & ACCESS_WRITE) != 0;
-  bool needs_null_check = (decorators & IS_NOT_NULL) == 0;
-
-  LIR_Opr base = access.base().item().result();
-  LIR_Opr offset = access.offset().opr();
-  LIRGenerator* gen = access.gen();
-
-  if (is_write) {
-    base = write_barrier(gen, base, access.access_emit_info(), needs_null_check);
-  } else {
-    base = read_barrier(gen, base, access.access_emit_info(), needs_null_check);
-  }
-
-  LIR_Opr addr_opr;
-  if (is_array) {
-    addr_opr = LIR_OprFact::address(gen->emit_array_address(base, offset, access.type()));
-  } else if (needs_patching) {
-    // we need to patch the offset in the instruction so don't allow
-    // generate_address to try to be smart about emitting the -1.
-    // Otherwise the patching code won't know how to find the
-    // instruction to patch.
-    addr_opr = LIR_OprFact::address(new LIR_Address(base, PATCHED_ADDR, access.type()));
-  } else {
-    addr_opr = LIR_OprFact::address(gen->generate_address(base, offset, 0, 0, access.type()));
-  }
-
-  if (resolve_in_register) {
-    LIR_Opr resolved_addr = gen->new_pointer_register();
-    __ leal(addr_opr, resolved_addr);
-    resolved_addr = LIR_OprFact::address(new LIR_Address(resolved_addr, access.type()));
-    return resolved_addr;
-  } else {
-    return addr_opr;
-  }
-}
-
 void ShenandoahBarrierSetC1::store_at_resolved(LIRAccess& access, LIR_Opr value) {
   if (access.is_oop()) {
     if (ShenandoahSATBBarrier) {
@@ -252,15 +183,28 @@
 }
 
 void ShenandoahBarrierSetC1::load_at_resolved(LIRAccess& access, LIR_Opr result) {
-  BarrierSetC1::load_at_resolved(access, result);
+  if (!access.is_oop()) {
+    BarrierSetC1::load_at_resolved(access, result);
+    return;
+  }
+
+  LIRGenerator *gen = access.gen();
+
+  if (ShenandoahLoadRefBarrier) {
+    LIR_Opr tmp = gen->new_register(T_OBJECT);
+    BarrierSetC1::load_at_resolved(access, tmp);
+    tmp = load_reference_barrier(access.gen(), tmp, access.access_emit_info(), true);
+    __ move(tmp, result);
+  } else {
+    BarrierSetC1::load_at_resolved(access, result);
+  }
 
   if (ShenandoahKeepAliveBarrier) {
     DecoratorSet decorators = access.decorators();
     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;
-    LIRGenerator *gen = access.gen();
-    if (access.is_oop() && (is_weak || is_phantom || is_anonymous)) {
+    if (is_weak || is_phantom || is_anonymous) {
       // Register the value in the referent field with the pre-barrier
       LabelObj *Lcont_anonymous;
       if (is_anonymous) {
@@ -276,19 +220,6 @@
   }
 }
 
-LIR_Opr ShenandoahBarrierSetC1::atomic_add_at_resolved(LIRAccess& access, LIRItem& value) {
-  return BarrierSetC1::atomic_add_at_resolved(access, value);
-}
-
-LIR_Opr ShenandoahBarrierSetC1::resolve(LIRGenerator* gen, DecoratorSet decorators, LIR_Opr obj) {
-  bool is_write = decorators & ACCESS_WRITE;
-  if (is_write) {
-    return write_barrier(gen, obj, NULL, (decorators & IS_NOT_NULL) == 0);
-  } else {
-    return read_barrier(gen, obj, NULL, (decorators & IS_NOT_NULL) == 0);
-  }
-}
-
 class C1ShenandoahPreBarrierCodeGenClosure : public StubAssemblerCodeGenClosure {
   virtual OopMapSet* generate_code(StubAssembler* sasm) {
     ShenandoahBarrierSetAssembler* bs = (ShenandoahBarrierSetAssembler*)BarrierSet::barrier_set()->barrier_set_assembler();
--- a/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/c1/shenandoahBarrierSetC1.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -85,7 +85,7 @@
 #endif // PRODUCT
 };
 
-class ShenandoahWriteBarrierStub: public CodeStub {
+class ShenandoahLoadReferenceBarrierStub: public CodeStub {
   friend class ShenandoahBarrierSetC1;
 private:
   LIR_Opr _obj;
@@ -94,7 +94,7 @@
   bool _needs_null_check;
 
 public:
-  ShenandoahWriteBarrierStub(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info, bool needs_null_check) :
+  ShenandoahLoadReferenceBarrierStub(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info, bool needs_null_check) :
     _obj(obj), _result(result), _info(info), _needs_null_check(needs_null_check)
   {
     assert(_obj->is_register(), "should be register");
@@ -113,7 +113,7 @@
     visitor->do_temp(_result);
   }
 #ifndef PRODUCT
-  virtual void print_name(outputStream* out) const { out->print("ShenandoahWritePreBarrierStub"); }
+  virtual void print_name(outputStream* out) const { out->print("ShenandoahLoadReferenceBarrierStub"); }
 #endif // PRODUCT
 };
 
@@ -181,12 +181,10 @@
 
   void pre_barrier(LIRGenerator* gen, CodeEmitInfo* info, DecoratorSet decorators, LIR_Opr addr_opr, LIR_Opr pre_val);
 
-  LIR_Opr read_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
-  LIR_Opr write_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
+  LIR_Opr load_reference_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
   LIR_Opr storeval_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, DecoratorSet decorators);
 
-  LIR_Opr read_barrier_impl(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
-  LIR_Opr write_barrier_impl(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
+  LIR_Opr load_reference_barrier_impl(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool need_null_check);
 
   LIR_Opr ensure_in_register(LIRGenerator* gen, LIR_Opr obj);
 
@@ -194,7 +192,6 @@
   CodeBlob* pre_barrier_c1_runtime_code_blob() { return _pre_barrier_c1_runtime_code_blob; }
 
 protected:
-  virtual LIR_Opr resolve_address(LIRAccess& access, bool resolve_in_register);
 
   virtual void store_at_resolved(LIRAccess& access, LIR_Opr value);
   virtual void load_at_resolved(LIRAccess& access, LIR_Opr result);
@@ -202,10 +199,8 @@
   virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);
 
   virtual LIR_Opr atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value);
-  virtual LIR_Opr atomic_add_at_resolved(LIRAccess& access, LIRItem& value);
 
 public:
-  virtual LIR_Opr resolve(LIRGenerator* gen, DecoratorSet decorators, LIR_Opr obj);
 
   virtual void generate_c1_runtime_stubs(BufferBlob* buffer_blob);
 };
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -43,121 +43,56 @@
 }
 
 ShenandoahBarrierSetC2State::ShenandoahBarrierSetC2State(Arena* comp_arena)
-  : _shenandoah_barriers(new (comp_arena) GrowableArray<ShenandoahWriteBarrierNode*>(comp_arena, 8,  0, NULL)) {
+  : _enqueue_barriers(new (comp_arena) GrowableArray<ShenandoahEnqueueBarrierNode*>(comp_arena, 8,  0, NULL)),
+    _load_reference_barriers(new (comp_arena) GrowableArray<ShenandoahLoadReferenceBarrierNode*>(comp_arena, 8,  0, NULL)) {
 }
 
-int ShenandoahBarrierSetC2State::shenandoah_barriers_count() const {
-  return _shenandoah_barriers->length();
+int ShenandoahBarrierSetC2State::enqueue_barriers_count() const {
+  return _enqueue_barriers->length();
 }
 
-ShenandoahWriteBarrierNode* ShenandoahBarrierSetC2State::shenandoah_barrier(int idx) const {
-  return _shenandoah_barriers->at(idx);
+ShenandoahEnqueueBarrierNode* ShenandoahBarrierSetC2State::enqueue_barrier(int idx) const {
+  return _enqueue_barriers->at(idx);
 }
 
-void ShenandoahBarrierSetC2State::add_shenandoah_barrier(ShenandoahWriteBarrierNode * n) {
-  assert(!_shenandoah_barriers->contains(n), "duplicate entry in barrier list");
-  _shenandoah_barriers->append(n);
+void ShenandoahBarrierSetC2State::add_enqueue_barrier(ShenandoahEnqueueBarrierNode * n) {
+  assert(!_enqueue_barriers->contains(n), "duplicate entry in barrier list");
+  _enqueue_barriers->append(n);
 }
 
-void ShenandoahBarrierSetC2State::remove_shenandoah_barrier(ShenandoahWriteBarrierNode * n) {
-  if (_shenandoah_barriers->contains(n)) {
-    _shenandoah_barriers->remove(n);
+void ShenandoahBarrierSetC2State::remove_enqueue_barrier(ShenandoahEnqueueBarrierNode * n) {
+  if (_enqueue_barriers->contains(n)) {
+    _enqueue_barriers->remove(n);
   }
 }
 
-#define __ kit->
+int ShenandoahBarrierSetC2State::load_reference_barriers_count() const {
+  return _load_reference_barriers->length();
+}
+
+ShenandoahLoadReferenceBarrierNode* ShenandoahBarrierSetC2State::load_reference_barrier(int idx) const {
+  return _load_reference_barriers->at(idx);
+}
 
-Node* ShenandoahBarrierSetC2::shenandoah_read_barrier(GraphKit* kit, Node* obj) const {
-  if (ShenandoahReadBarrier) {
-    obj = shenandoah_read_barrier_impl(kit, obj, false, true, true);
+void ShenandoahBarrierSetC2State::add_load_reference_barrier(ShenandoahLoadReferenceBarrierNode * n) {
+  assert(!_load_reference_barriers->contains(n), "duplicate entry in barrier list");
+  _load_reference_barriers->append(n);
+}
+
+void ShenandoahBarrierSetC2State::remove_load_reference_barrier(ShenandoahLoadReferenceBarrierNode * n) {
+  if (_load_reference_barriers->contains(n)) {
+    _load_reference_barriers->remove(n);
   }
-  return obj;
 }
 
 Node* ShenandoahBarrierSetC2::shenandoah_storeval_barrier(GraphKit* kit, Node* obj) const {
   if (ShenandoahStoreValEnqueueBarrier) {
-    obj = shenandoah_write_barrier(kit, obj);
     obj = shenandoah_enqueue_barrier(kit, obj);
   }
-  if (ShenandoahStoreValReadBarrier) {
-    obj = shenandoah_read_barrier_impl(kit, obj, true, false, false);
-  }
   return obj;
 }
 
-Node* ShenandoahBarrierSetC2::shenandoah_read_barrier_impl(GraphKit* kit, Node* obj, bool use_ctrl, bool use_mem, bool allow_fromspace) const {
-  const Type* obj_type = obj->bottom_type();
-  if (obj_type->higher_equal(TypePtr::NULL_PTR)) {
-    return obj;
-  }
-  const TypePtr* adr_type = ShenandoahBarrierNode::brooks_pointer_type(obj_type);
-  Node* mem = use_mem ? __ memory(adr_type) : __ immutable_memory();
-
-  if (! ShenandoahBarrierNode::needs_barrier(&__ gvn(), NULL, obj, mem, allow_fromspace)) {
-    // We know it is null, no barrier needed.
-    return obj;
-  }
-
-  if (obj_type->meet(TypePtr::NULL_PTR) == obj_type->remove_speculative()) {
-
-    // We don't know if it's null or not. Need null-check.
-    enum { _not_null_path = 1, _null_path, PATH_LIMIT };
-    RegionNode* region = new RegionNode(PATH_LIMIT);
-    Node*       phi    = new PhiNode(region, obj_type);
-    Node* null_ctrl = __ top();
-    Node* not_null_obj = __ null_check_oop(obj, &null_ctrl);
-
-    region->init_req(_null_path, null_ctrl);
-    phi   ->init_req(_null_path, __ zerocon(T_OBJECT));
-
-    Node* ctrl = use_ctrl ? __ control() : NULL;
-    ShenandoahReadBarrierNode* rb = new ShenandoahReadBarrierNode(ctrl, mem, not_null_obj, allow_fromspace);
-    Node* n = __ gvn().transform(rb);
-
-    region->init_req(_not_null_path, __ control());
-    phi   ->init_req(_not_null_path, n);
-
-    __ set_control(__ gvn().transform(region));
-    __ record_for_igvn(region);
-    return __ gvn().transform(phi);
-
-  } else {
-    // We know it is not null. Simple barrier is sufficient.
-    Node* ctrl = use_ctrl ? __ control() : NULL;
-    ShenandoahReadBarrierNode* rb = new ShenandoahReadBarrierNode(ctrl, mem, obj, allow_fromspace);
-    Node* n = __ gvn().transform(rb);
-    __ record_for_igvn(n);
-    return n;
-  }
-}
-
-Node* ShenandoahBarrierSetC2::shenandoah_write_barrier_helper(GraphKit* kit, Node* obj, const TypePtr* adr_type) const {
-  ShenandoahWriteBarrierNode* wb = new ShenandoahWriteBarrierNode(kit->C, kit->control(), kit->memory(adr_type), obj);
-  Node* n = __ gvn().transform(wb);
-  if (n == wb) { // New barrier needs memory projection.
-    Node* proj = __ gvn().transform(new ShenandoahWBMemProjNode(n));
-    __ set_memory(proj, adr_type);
-  }
-  return n;
-}
-
-Node* ShenandoahBarrierSetC2::shenandoah_write_barrier(GraphKit* kit, Node* obj) const {
-  if (ShenandoahWriteBarrier) {
-    obj = shenandoah_write_barrier_impl(kit, obj);
-  }
-  return obj;
-}
-
-Node* ShenandoahBarrierSetC2::shenandoah_write_barrier_impl(GraphKit* kit, Node* obj) const {
-  if (! ShenandoahBarrierNode::needs_barrier(&__ gvn(), NULL, obj, NULL, true)) {
-    return obj;
-  }
-  const Type* obj_type = obj->bottom_type();
-  const TypePtr* adr_type = ShenandoahBarrierNode::brooks_pointer_type(obj_type);
-  Node* n = shenandoah_write_barrier_helper(kit, obj, adr_type);
-  __ record_for_igvn(n);
-  return n;
-}
+#define __ kit->
 
 bool ShenandoahBarrierSetC2::satb_can_remove_pre_barrier(GraphKit* kit, PhaseTransform* phase, Node* adr,
                                                          BasicType bt, uint adr_idx) const {
@@ -304,7 +239,7 @@
   Node* gc_state = __ AddP(no_base, tls, __ ConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset())));
   Node* ld = __ load(__ ctrl(), gc_state, TypeInt::BYTE, T_BYTE, Compile::AliasIdxRaw);
   marking = __ AndI(ld, __ ConI(ShenandoahHeap::MARKING));
-  assert(ShenandoahWriteBarrierNode::is_gc_state_load(ld), "Should match the shape");
+  assert(ShenandoahBarrierC2Support::is_gc_state_load(ld), "Should match the shape");
 
   // if (!marking)
   __ if_then(marking, BoolTest::ne, zero, unlikely); {
@@ -361,7 +296,7 @@
 
 bool ShenandoahBarrierSetC2::is_shenandoah_wb_call(Node* call) {
   return call->is_CallLeaf() &&
-         call->as_CallLeaf()->entry_point() == CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_JRT);
+         call->as_CallLeaf()->entry_point() == CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_JRT);
 }
 
 bool ShenandoahBarrierSetC2::is_shenandoah_marking_if(PhaseTransform *phase, Node* n) {
@@ -549,88 +484,6 @@
   return TypeFunc::make(domain, range);
 }
 
-void ShenandoahBarrierSetC2::resolve_address(C2Access& access) const {
-  const TypePtr* adr_type = access.addr().type();
-
-  if ((access.decorators() & IN_NATIVE) == 0 && (adr_type->isa_instptr() || adr_type->isa_aryptr())) {
-    int off = adr_type->is_ptr()->offset();
-    int base_off = adr_type->isa_instptr() ? instanceOopDesc::base_offset_in_bytes() :
-      arrayOopDesc::base_offset_in_bytes(adr_type->is_aryptr()->elem()->array_element_basic_type());
-    assert(off != Type::OffsetTop, "unexpected offset");
-    if (off == Type::OffsetBot || off >= base_off) {
-      DecoratorSet decorators = access.decorators();
-      bool is_write = (decorators & C2_WRITE_ACCESS) != 0;
-      GraphKit* kit = NULL;
-      if (access.is_parse_access()) {
-        C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(access);
-        kit = parse_access.kit();
-      }
-      Node* adr = access.addr().node();
-      assert(adr->is_AddP(), "unexpected address shape");
-      Node* base = adr->in(AddPNode::Base);
-
-      if (is_write) {
-        if (kit != NULL) {
-          base = shenandoah_write_barrier(kit, base);
-        } else {
-          assert(access.is_opt_access(), "either parse or opt access");
-          assert((access.decorators() & C2_ARRAY_COPY) != 0, "can be skipped for clone");
-        }
-      } else {
-        if (adr_type->isa_instptr()) {
-          Compile* C = access.gvn().C;
-          ciField* field = C->alias_type(adr_type)->field();
-
-          // Insert read barrier for Shenandoah.
-          if (field != NULL &&
-              ((ShenandoahOptimizeStaticFinals   && field->is_static()  && field->is_final()) ||
-               (ShenandoahOptimizeInstanceFinals && !field->is_static() && field->is_final()) ||
-               (ShenandoahOptimizeStableFinals   && field->is_stable()))) {
-            // Skip the barrier for special fields
-          } else {
-            if (kit != NULL) {
-              base = shenandoah_read_barrier(kit, base);
-            } else {
-              assert(access.is_opt_access(), "either parse or opt access");
-              assert((access.decorators() & C2_ARRAY_COPY) != 0, "can be skipped for arraycopy");
-            }
-          }
-        } else {
-          if (kit != NULL) {
-            base = shenandoah_read_barrier(kit, base);
-          } else {
-            assert(access.is_opt_access(), "either parse or opt access");
-            assert((access.decorators() & C2_ARRAY_COPY) != 0, "can be skipped for arraycopy");
-          }
-        }
-      }
-      if (base != adr->in(AddPNode::Base)) {
-        assert(kit != NULL, "no barrier should have been added");
-
-        Node* address = adr->in(AddPNode::Address);
-
-        if (address->is_AddP()) {
-          assert(address->in(AddPNode::Base) == adr->in(AddPNode::Base), "unexpected address shape");
-          assert(!address->in(AddPNode::Address)->is_AddP(), "unexpected address shape");
-          assert(address->in(AddPNode::Address) == adr->in(AddPNode::Base), "unexpected address shape");
-          address = address->clone();
-          address->set_req(AddPNode::Base, base);
-          address->set_req(AddPNode::Address, base);
-          address = kit->gvn().transform(address);
-        } else {
-          assert(address == adr->in(AddPNode::Base), "unexpected address shape");
-          address = base;
-        }
-        adr = adr->clone();
-        adr->set_req(AddPNode::Base, base);
-        adr->set_req(AddPNode::Address, address);
-        adr = kit->gvn().transform(adr);
-        access.addr().set_node(adr);
-      }
-    }
-  }
-}
-
 Node* ShenandoahBarrierSetC2::store_at_resolved(C2Access& access, C2AccessValue& val) const {
   DecoratorSet decorators = access.decorators();
 
@@ -662,44 +515,8 @@
     PhaseGVN& gvn =  opt_access.gvn();
     MergeMemNode* mm = opt_access.mem();
 
-    if (ShenandoahStoreValReadBarrier) {
-      RegionNode* region = new RegionNode(3);
-      const Type* v_t = gvn.type(val.node());
-      Node* phi = new PhiNode(region, v_t->isa_oopptr() ? v_t->is_oopptr()->cast_to_nonconst() : v_t);
-      Node* cmp = gvn.transform(new CmpPNode(val.node(), gvn.zerocon(T_OBJECT)));
-      Node* bol = gvn.transform(new BoolNode(cmp, BoolTest::ne));
-      IfNode* iff = new IfNode(opt_access.ctl(), bol, PROB_LIKELY_MAG(3), COUNT_UNKNOWN);
-
-      gvn.transform(iff);
-      if (gvn.is_IterGVN()) {
-        gvn.is_IterGVN()->_worklist.push(iff);
-      } else {
-        gvn.record_for_igvn(iff);
-      }
-
-      Node* null_true = gvn.transform(new IfFalseNode(iff));
-      Node* null_false = gvn.transform(new IfTrueNode(iff));
-      region->init_req(1, null_true);
-      region->init_req(2, null_false);
-      phi->init_req(1, gvn.zerocon(T_OBJECT));
-      Node* cast = new CastPPNode(val.node(), gvn.type(val.node())->join_speculative(TypePtr::NOTNULL));
-      cast->set_req(0, null_false);
-      cast = gvn.transform(cast);
-      Node* rb = gvn.transform(new ShenandoahReadBarrierNode(null_false, gvn.C->immutable_memory(), cast, false));
-      phi->init_req(2, rb);
-      opt_access.set_ctl(gvn.transform(region));
-      val.set_node(gvn.transform(phi));
-    }
     if (ShenandoahStoreValEnqueueBarrier) {
-      const TypePtr* adr_type = ShenandoahBarrierNode::brooks_pointer_type(gvn.type(val.node()));
-      int alias = gvn.C->get_alias_index(adr_type);
-      Node* wb = new ShenandoahWriteBarrierNode(gvn.C, opt_access.ctl(), mm->memory_at(alias), val.node());
-      Node* wb_transformed = gvn.transform(wb);
-      Node* enqueue = gvn.transform(new ShenandoahEnqueueBarrierNode(wb_transformed));
-      if (wb_transformed == wb) {
-        Node* proj = gvn.transform(new ShenandoahWBMemProjNode(wb));
-        mm->set_memory_at(alias, proj);
-      }
+      Node* enqueue = gvn.transform(new ShenandoahEnqueueBarrierNode(val.node()));
       val.set_node(enqueue);
     }
   }
@@ -724,6 +541,17 @@
   Node* offset = adr->is_AddP() ? adr->in(AddPNode::Offset) : top;
   Node* load = BarrierSetC2::load_at_resolved(access, val_type);
 
+  if (access.is_oop()) {
+    if (ShenandoahLoadRefBarrier) {
+      load = new ShenandoahLoadReferenceBarrierNode(NULL, load);
+      if (access.is_parse_access()) {
+        load = static_cast<C2ParseAccess &>(access).kit()->gvn().transform(load);
+      } else {
+        load = static_cast<C2OptAccess &>(access).gvn().transform(load);
+      }
+    }
+  }
+
   // If we are reading the value of the referent field of a Reference
   // object (either by using Unsafe directly or through reflection)
   // then, if SATB is enabled, we need to record the referent in an
@@ -797,9 +625,10 @@
 
 #ifdef _LP64
     if (adr->bottom_type()->is_ptr_to_narrowoop()) {
-      return kit->gvn().transform(new DecodeNNode(load_store, load_store->get_ptr_type()));
+      load_store = kit->gvn().transform(new DecodeNNode(load_store, load_store->get_ptr_type()));
     }
 #endif
+    load_store = kit->gvn().transform(new ShenandoahLoadReferenceBarrierNode(NULL, load_store));
     return load_store;
   }
   return BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, value_type);
@@ -867,6 +696,7 @@
   }
   Node* result = BarrierSetC2::atomic_xchg_at_resolved(access, val, value_type);
   if (access.is_oop()) {
+    result = kit->gvn().transform(new ShenandoahLoadReferenceBarrierNode(NULL, result));
     shenandoah_write_barrier_pre(kit, false /* do_load */,
                                  NULL, NULL, max_juint, NULL, NULL,
                                  result /* pre_val */, T_OBJECT);
@@ -876,19 +706,9 @@
 
 void ShenandoahBarrierSetC2::clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array) const {
   assert(!src->is_AddP(), "unexpected input");
-  src = shenandoah_read_barrier(kit, src);
   BarrierSetC2::clone(kit, src, dst, size, is_array);
 }
 
-Node* ShenandoahBarrierSetC2::resolve(GraphKit* kit, Node* n, DecoratorSet decorators) const {
-  bool is_write = decorators & ACCESS_WRITE;
-  if (is_write) {
-    return shenandoah_write_barrier(kit, n);
-  } else {
-  return shenandoah_read_barrier(kit, n);
-  }
-}
-
 Node* ShenandoahBarrierSetC2::obj_allocate(PhaseMacroExpand* macro, Node* ctrl, Node* mem, Node* toobig_false, Node* size_in_bytes,
                                            Node*& i_o, Node*& needgc_ctrl,
                                            Node*& fast_oop_ctrl, Node*& fast_oop_rawmem,
@@ -915,6 +735,7 @@
 
 // Support for GC barriers emitted during parsing
 bool ShenandoahBarrierSetC2::is_gc_barrier_node(Node* node) const {
+  if (node->Opcode() == Op_ShenandoahLoadReferenceBarrier) return true;
   if (node->Opcode() != Op_CallLeaf && node->Opcode() != Op_CallLeafNoFP) {
     return false;
   }
@@ -929,26 +750,30 @@
 }
 
 Node* ShenandoahBarrierSetC2::step_over_gc_barrier(Node* c) const {
-  return ShenandoahBarrierNode::skip_through_barrier(c);
+  if (c->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
+    return c->in(ShenandoahLoadReferenceBarrierNode::ValueIn);
+  }
+  if (c->Opcode() == Op_ShenandoahEnqueueBarrier) {
+    c = c->in(1);
+  }
+  return c;
 }
 
 bool ShenandoahBarrierSetC2::expand_barriers(Compile* C, PhaseIterGVN& igvn) const {
-  return !ShenandoahWriteBarrierNode::expand(C, igvn);
+  return !ShenandoahBarrierC2Support::expand(C, igvn);
 }
 
 bool ShenandoahBarrierSetC2::optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const {
   if (mode == LoopOptsShenandoahExpand) {
     assert(UseShenandoahGC, "only for shenandoah");
-    ShenandoahWriteBarrierNode::pin_and_expand(phase);
+    ShenandoahBarrierC2Support::pin_and_expand(phase);
     return true;
   } else if (mode == LoopOptsShenandoahPostExpand) {
     assert(UseShenandoahGC, "only for shenandoah");
     visited.Clear();
-    ShenandoahWriteBarrierNode::optimize_after_expansion(visited, nstack, worklist, phase);
+    ShenandoahBarrierC2Support::optimize_after_expansion(visited, nstack, worklist, phase);
     return true;
   }
-  GrowableArray<MemoryGraphFixer*> memory_graph_fixers;
-  ShenandoahWriteBarrierNode::optimize_before_expansion(phase, memory_graph_fixers, false);
   return false;
 }
 
@@ -957,7 +782,6 @@
   if (!is_oop) {
     return false;
   }
-
   if (tightly_coupled_alloc) {
     if (phase == Optimization) {
       return false;
@@ -985,7 +809,7 @@
       }
     } else {
       return true;
-    }
+        }
   } else if (src_type->isa_aryptr()) {
     BasicType src_elem  = src_type->klass()->as_array_klass()->element_type()->basic_type();
     if (src_elem == T_OBJECT || src_elem == T_ARRAY) {
@@ -1038,14 +862,20 @@
 
 // Support for macro expanded GC barriers
 void ShenandoahBarrierSetC2::register_potential_barrier_node(Node* node) const {
-  if (node->Opcode() == Op_ShenandoahWriteBarrier) {
-    state()->add_shenandoah_barrier((ShenandoahWriteBarrierNode*) node);
+  if (node->Opcode() == Op_ShenandoahEnqueueBarrier) {
+    state()->add_enqueue_barrier((ShenandoahEnqueueBarrierNode*) node);
+  }
+  if (node->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
+    state()->add_load_reference_barrier((ShenandoahLoadReferenceBarrierNode*) node);
   }
 }
 
 void ShenandoahBarrierSetC2::unregister_potential_barrier_node(Node* node) const {
-  if (node->Opcode() == Op_ShenandoahWriteBarrier) {
-    state()->remove_shenandoah_barrier((ShenandoahWriteBarrierNode*) node);
+  if (node->Opcode() == Op_ShenandoahEnqueueBarrier) {
+    state()->remove_enqueue_barrier((ShenandoahEnqueueBarrierNode*) node);
+  }
+  if (node->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
+    state()->remove_load_reference_barrier((ShenandoahLoadReferenceBarrierNode*) node);
   }
 }
 
@@ -1091,19 +921,18 @@
       }
     }
   }
-  for (int i = state()->shenandoah_barriers_count()-1; i >= 0; i--) {
-    ShenandoahWriteBarrierNode* n = state()->shenandoah_barrier(i);
+  for (int i = state()->enqueue_barriers_count() - 1; i >= 0; i--) {
+    ShenandoahEnqueueBarrierNode* n = state()->enqueue_barrier(i);
     if (!useful.member(n)) {
-      state()->remove_shenandoah_barrier(n);
+      state()->remove_enqueue_barrier(n);
     }
   }
-
-}
-
-bool ShenandoahBarrierSetC2::has_special_unique_user(const Node* node) const {
-  assert(node->outcnt() == 1, "match only for unique out");
-  Node* n = node->unique_out();
-  return node->Opcode() == Op_ShenandoahWriteBarrier && n->Opcode() == Op_ShenandoahWBMemProj;
+  for (int i = state()->load_reference_barriers_count() - 1; i >= 0; i--) {
+    ShenandoahLoadReferenceBarrierNode* n = state()->load_reference_barrier(i);
+    if (!useful.member(n)) {
+      state()->remove_load_reference_barrier(n);
+    }
+  }
 }
 
 void ShenandoahBarrierSetC2::add_users_to_worklist(Unique_Node_List* worklist) const {}
@@ -1123,7 +952,7 @@
 #ifdef ASSERT
 void ShenandoahBarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase phase) const {
   if (ShenandoahVerifyOptoBarriers && phase == BarrierSetC2::BeforeExpand) {
-    ShenandoahBarrierNode::verify(Compile::current()->root());
+    ShenandoahBarrierC2Support::verify(Compile::current()->root());
   } else if (phase == BarrierSetC2::BeforeCodeGen) {
     // Verify G1 pre-barriers
     const int marking_offset = in_bytes(ShenandoahThreadLocalData::satb_mark_queue_active_offset());
@@ -1229,7 +1058,7 @@
     }
   } else if (can_reshape &&
              n->Opcode() == Op_If &&
-             ShenandoahWriteBarrierNode::is_heap_stable_test(n) &&
+             ShenandoahBarrierC2Support::is_heap_stable_test(n) &&
              n->in(0) != NULL) {
     Node* dom = n->in(0);
     Node* prev_dom = n;
@@ -1237,7 +1066,7 @@
     int dist = 16;
     // Search up the dominator tree for another heap stable test
     while (dom->Opcode() != op    ||  // Not same opcode?
-           !ShenandoahWriteBarrierNode::is_heap_stable_test(dom) ||  // Not same input 1?
+           !ShenandoahBarrierC2Support::is_heap_stable_test(dom) ||  // Not same input 1?
            prev_dom->in(0) != dom) {  // One path of test does not dominate?
       if (dist < 0) return NULL;
 
@@ -1258,46 +1087,6 @@
   return NULL;
 }
 
-Node* ShenandoahBarrierSetC2::identity_node(PhaseGVN* phase, Node* n) const {
-  if (n->is_Load()) {
-    Node *mem = n->in(MemNode::Memory);
-    Node *value = n->as_Load()->can_see_stored_value(mem, phase);
-    if (value) {
-      PhaseIterGVN *igvn = phase->is_IterGVN();
-      if (igvn != NULL &&
-          value->is_Phi() &&
-          value->req() > 2 &&
-          value->in(1) != NULL &&
-          value->in(1)->is_ShenandoahBarrier()) {
-        if (igvn->_worklist.member(value) ||
-            igvn->_worklist.member(value->in(0)) ||
-            (value->in(0)->in(1) != NULL &&
-             value->in(0)->in(1)->is_IfProj() &&
-             (igvn->_worklist.member(value->in(0)->in(1)) ||
-              (value->in(0)->in(1)->in(0) != NULL &&
-               igvn->_worklist.member(value->in(0)->in(1)->in(0)))))) {
-          igvn->_worklist.push(n);
-          return n;
-        }
-      }
-      // (This works even when value is a Con, but LoadNode::Value
-      // usually runs first, producing the singleton type of the Con.)
-      Node *value_no_barrier = step_over_gc_barrier(value->Opcode() == Op_EncodeP ? value->in(1) : value);
-      if (value->Opcode() == Op_EncodeP) {
-        if (value_no_barrier != value->in(1)) {
-          Node *encode = value->clone();
-          encode->set_req(1, value_no_barrier);
-          encode = phase->transform(encode);
-          return encode;
-        }
-      } else {
-        return value_no_barrier;
-      }
-    }
-  }
-  return n;
-}
-
 bool ShenandoahBarrierSetC2::has_only_shenandoah_wb_pre_uses(Node* n) {
   for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
     Node* u = n->fast_out(i);
@@ -1308,20 +1097,6 @@
   return n->outcnt() > 0;
 }
 
-bool ShenandoahBarrierSetC2::flatten_gc_alias_type(const TypePtr*& adr_type) const {
-  int offset = adr_type->offset();
-  if (offset == ShenandoahBrooksPointer::byte_offset()) {
-    if (adr_type->isa_aryptr()) {
-      adr_type = TypeAryPtr::make(adr_type->ptr(), adr_type->isa_aryptr()->ary(), adr_type->isa_aryptr()->klass(), false, offset);
-    } else if (adr_type->isa_instptr()) {
-      adr_type = TypeInstPtr::make(adr_type->ptr(), ciEnv::current()->Object_klass(), false, NULL, offset);
-    }
-    return true;
-  } else {
-    return false;
-  }
-}
-
 bool ShenandoahBarrierSetC2::final_graph_reshaping(Compile* compile, Node* n, uint opcode) const {
   switch (opcode) {
     case Op_CallLeaf:
@@ -1356,9 +1131,7 @@
       }
 #endif
       return true;
-    case Op_ShenandoahReadBarrier:
-      return true;
-    case Op_ShenandoahWriteBarrier:
+    case Op_ShenandoahLoadReferenceBarrier:
       assert(false, "should have been expanded already");
       return true;
     default:
@@ -1366,17 +1139,6 @@
   }
 }
 
-#ifdef ASSERT
-bool ShenandoahBarrierSetC2::verify_gc_alias_type(const TypePtr* adr_type, int offset) const {
-  if (offset == ShenandoahBrooksPointer::byte_offset() &&
-      (adr_type->base() == Type::AryPtr || adr_type->base() == Type::OopPtr)) {
-    return true;
-  } else {
-    return false;
-  }
-}
-#endif
-
 bool ShenandoahBarrierSetC2::escape_add_to_con_graph(ConnectionGraph* conn_graph, PhaseGVN* gvn, Unique_Node_List* delayed_worklist, Node* n, uint opcode) const {
   switch (opcode) {
     case Op_ShenandoahCompareAndExchangeP:
@@ -1412,15 +1174,12 @@
       }
       return false;
     }
-    case Op_ShenandoahReadBarrier:
-    case Op_ShenandoahWriteBarrier:
-      // Barriers 'pass through' its arguments. I.e. what goes in, comes out.
-      // It doesn't escape.
-      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(ShenandoahBarrierNode::ValueIn), delayed_worklist);
-      break;
     case Op_ShenandoahEnqueueBarrier:
       conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(1), delayed_worklist);
       break;
+    case Op_ShenandoahLoadReferenceBarrier:
+      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(ShenandoahLoadReferenceBarrierNode::ValueIn), delayed_worklist);
+      return true;
     default:
       // Nothing
       break;
@@ -1441,15 +1200,12 @@
     case Op_ShenandoahWeakCompareAndSwapP:
     case Op_ShenandoahWeakCompareAndSwapN:
       return conn_graph->add_final_edges_unsafe_access(n, opcode);
-    case Op_ShenandoahReadBarrier:
-    case Op_ShenandoahWriteBarrier:
-      // Barriers 'pass through' its arguments. I.e. what goes in, comes out.
-      // It doesn't escape.
-      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(ShenandoahBarrierNode::ValueIn), NULL);
-      return true;
     case Op_ShenandoahEnqueueBarrier:
       conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(1), NULL);
       return true;
+    case Op_ShenandoahLoadReferenceBarrier:
+      conn_graph->add_local_var_and_edge(n, PointsToNode::NoEscape, n->in(ShenandoahLoadReferenceBarrierNode::ValueIn), NULL);
+      return true;
     default:
       // Nothing
       break;
@@ -1464,21 +1220,7 @@
 }
 
 bool ShenandoahBarrierSetC2::escape_is_barrier_node(Node* n) const {
-  return n->is_ShenandoahBarrier();
-}
-
-bool ShenandoahBarrierSetC2::matcher_find_shared_visit(Matcher* matcher, Matcher::MStack& mstack, Node* n, uint opcode, bool& mem_op, int& mem_addr_idx) const {
-  switch (opcode) {
-    case Op_ShenandoahReadBarrier:
-      if (n->in(ShenandoahBarrierNode::ValueIn)->is_DecodeNarrowPtr()) {
-        matcher->set_shared(n->in(ShenandoahBarrierNode::ValueIn)->in(1));
-      }
-      matcher->set_shared(n);
-      return true;
-    default:
-      break;
-  }
-  return false;
+  return n->Opcode() == Op_ShenandoahLoadReferenceBarrier;
 }
 
 bool ShenandoahBarrierSetC2::matcher_find_shared_post_visit(Matcher* matcher, Node* n, uint opcode) const {
@@ -1510,62 +1252,3 @@
          xop == Op_ShenandoahCompareAndSwapN ||
          xop == Op_ShenandoahCompareAndSwapP;
 }
-
-void ShenandoahBarrierSetC2::igvn_add_users_to_worklist(PhaseIterGVN* igvn, Node* use) const {
-  if (use->is_ShenandoahBarrier()) {
-    for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
-      Node* u = use->fast_out(i2);
-      Node* cmp = use->find_out_with(Op_CmpP);
-      if (u->Opcode() == Op_CmpP) {
-        igvn->_worklist.push(cmp);
-      }
-    }
-  }
-}
-
-void ShenandoahBarrierSetC2::ccp_analyze(PhaseCCP* ccp, Unique_Node_List& worklist, Node* use) const {
-  if (use->is_ShenandoahBarrier()) {
-    for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
-      Node* p = use->fast_out(i2);
-      if (p->Opcode() == Op_AddP) {
-        for (DUIterator_Fast i3max, i3 = p->fast_outs(i3max); i3 < i3max; i3++) {
-          Node* q = p->fast_out(i3);
-          if (q->is_Load()) {
-            if(q->bottom_type() != ccp->type(q)) {
-              worklist.push(q);
-            }
-          }
-        }
-      }
-    }
-  }
-}
-
-Node* ShenandoahBarrierSetC2::split_if_pre(PhaseIdealLoop* phase, Node* n) const {
-  if (n->Opcode() == Op_ShenandoahReadBarrier) {
-    ((ShenandoahReadBarrierNode*)n)->try_move(phase);
-  } else if (n->Opcode() == Op_ShenandoahWriteBarrier) {
-    return ((ShenandoahWriteBarrierNode*)n)->try_split_thru_phi(phase);
-  }
-
-  return NULL;
-}
-
-bool ShenandoahBarrierSetC2::build_loop_late_post(PhaseIdealLoop* phase, Node* n) const {
-  return ShenandoahBarrierNode::build_loop_late_post(phase, n);
-}
-
-bool ShenandoahBarrierSetC2::sink_node(PhaseIdealLoop* phase, Node* n, Node* x, Node* x_ctrl, Node* n_ctrl) const {
-  if (n->is_ShenandoahBarrier()) {
-    return x->as_ShenandoahBarrier()->sink_node(phase, x_ctrl, n_ctrl);
-  }
-  if (n->is_MergeMem()) {
-    // PhaseIdealLoop::split_if_with_blocks_post() would:
-    // _igvn._worklist.yank(x);
-    // which sometimes causes chains of MergeMem which some of
-    // shenandoah specific code doesn't support
-    phase->register_new_node(x, x_ctrl);
-    return true;
-  }
-  return false;
-}
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -30,14 +30,21 @@
 
 class ShenandoahBarrierSetC2State : public ResourceObj {
 private:
-  GrowableArray<ShenandoahWriteBarrierNode*>* _shenandoah_barriers;
+  GrowableArray<ShenandoahEnqueueBarrierNode*>* _enqueue_barriers;
+  GrowableArray<ShenandoahLoadReferenceBarrierNode*>* _load_reference_barriers;
 
 public:
   ShenandoahBarrierSetC2State(Arena* comp_arena);
-  int shenandoah_barriers_count() const;
-  ShenandoahWriteBarrierNode* shenandoah_barrier(int idx) const;
-  void add_shenandoah_barrier(ShenandoahWriteBarrierNode * n);
-  void remove_shenandoah_barrier(ShenandoahWriteBarrierNode * n);
+
+  int enqueue_barriers_count() const;
+  ShenandoahEnqueueBarrierNode* enqueue_barrier(int idx) const;
+  void add_enqueue_barrier(ShenandoahEnqueueBarrierNode* n);
+  void remove_enqueue_barrier(ShenandoahEnqueueBarrierNode * n);
+
+  int load_reference_barriers_count() const;
+  ShenandoahLoadReferenceBarrierNode* load_reference_barrier(int idx) const;
+  void add_load_reference_barrier(ShenandoahLoadReferenceBarrierNode* n);
+  void remove_load_reference_barrier(ShenandoahLoadReferenceBarrierNode * n);
 };
 
 class ShenandoahBarrierSetC2 : public BarrierSetC2 {
@@ -66,12 +73,7 @@
                                     BasicType bt) const;
 
   Node* shenandoah_enqueue_barrier(GraphKit* kit, Node* val) const;
-  Node* shenandoah_read_barrier(GraphKit* kit, Node* obj) const;
   Node* shenandoah_storeval_barrier(GraphKit* kit, Node* obj) const;
-  Node* shenandoah_write_barrier(GraphKit* kit, Node* obj) const;
-  Node* shenandoah_read_barrier_impl(GraphKit* kit, Node* obj, bool use_ctrl, bool use_mem, bool allow_fromspace) const;
-  Node* shenandoah_write_barrier_impl(GraphKit* kit, Node* obj) const;
-  Node* shenandoah_write_barrier_helper(GraphKit* kit, Node* obj, const TypePtr* adr_type) const;
 
   void insert_pre_barrier(GraphKit* kit, Node* base_oop, Node* offset,
                           Node* pre_val, bool need_mem_bar) const;
@@ -79,7 +81,6 @@
   static bool clone_needs_postbarrier(ArrayCopyNode *ac, PhaseIterGVN& igvn);
 
 protected:
-  virtual void resolve_address(C2Access& access) const;
   virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const;
   virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const;
   virtual Node* atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
@@ -102,12 +103,11 @@
   static const TypeFunc* write_ref_field_pre_entry_Type();
   static const TypeFunc* shenandoah_clone_barrier_Type();
   static const TypeFunc* shenandoah_write_barrier_Type();
+  virtual bool has_load_barriers() const { return true; }
 
   // This is the entry-point for the backend to perform accesses through the Access API.
   virtual void clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array) const;
 
-  virtual Node* resolve(GraphKit* kit, Node* n, DecoratorSet decorators) const;
-
   virtual Node* obj_allocate(PhaseMacroExpand* macro, Node* ctrl, Node* mem, Node* toobig_false, Node* size_in_bytes,
                              Node*& i_o, Node*& needgc_ctrl,
                              Node*& fast_oop_ctrl, Node*& fast_oop_rawmem,
@@ -144,13 +144,7 @@
   virtual void verify_gc_barriers(Compile* compile, CompilePhase phase) const;
 #endif
 
-  virtual bool flatten_gc_alias_type(const TypePtr*& adr_type) const;
-#ifdef ASSERT
-  virtual bool verify_gc_alias_type(const TypePtr* adr_type, int offset) const;
-#endif
-
   virtual Node* ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const;
-  virtual Node* identity_node(PhaseGVN* phase, Node* n) const;
   virtual bool final_graph_reshaping(Compile* compile, Node* n, uint opcode) const;
 
   virtual bool escape_add_to_con_graph(ConnectionGraph* conn_graph, PhaseGVN* gvn, Unique_Node_List* delayed_worklist, Node* n, uint opcode) const;
@@ -158,17 +152,8 @@
   virtual bool escape_has_out_with_unsafe_object(Node* n) const;
   virtual bool escape_is_barrier_node(Node* n) const;
 
-  virtual bool matcher_find_shared_visit(Matcher* matcher, Matcher::MStack& mstack, Node* n, uint opcode, bool& mem_op, int& mem_addr_idx) const;
   virtual bool matcher_find_shared_post_visit(Matcher* matcher, Node* n, uint opcode) const;
   virtual bool matcher_is_store_load_barrier(Node* x, uint xop) const;
-
-  virtual void igvn_add_users_to_worklist(PhaseIterGVN* igvn, Node* use) const;
-  virtual void ccp_analyze(PhaseCCP* ccp, Unique_Node_List& worklist, Node* use) const;
-
-  virtual bool has_special_unique_user(const Node* node) const;
-  virtual Node* split_if_pre(PhaseIdealLoop* phase, Node* n) const;
-  virtual bool build_loop_late_post(PhaseIdealLoop* phase, Node* n) const;
-  virtual bool sink_node(PhaseIdealLoop* phase, Node* n, Node* x, Node* x_ctrl, Node* n_ctrl) const;
 };
 
 #endif // SHARE_GC_SHENANDOAH_C2_SHENANDOAHBARRIERSETC2_HPP
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -41,383 +41,28 @@
 #include "opto/runtime.hpp"
 #include "opto/subnode.hpp"
 
-Node* ShenandoahBarrierNode::skip_through_barrier(Node* n) {
-  if (n == NULL) {
-    return NULL;
-  }
-  if (n->Opcode() == Op_ShenandoahEnqueueBarrier) {
-    n = n->in(1);
-  }
-
-  if (n->is_ShenandoahBarrier()) {
-    return n->in(ValueIn);
-  } else if (n->is_Phi() &&
-             n->req() == 3 &&
-             n->in(1) != NULL &&
-             n->in(1)->is_ShenandoahBarrier() &&
-             n->in(2) != NULL &&
-             n->in(2)->bottom_type() == TypePtr::NULL_PTR &&
-             n->in(0) != NULL &&
-             n->in(0)->in(1) != NULL &&
-             n->in(0)->in(1)->is_IfProj() &&
-             n->in(0)->in(2) != NULL &&
-             n->in(0)->in(2)->is_IfProj() &&
-             n->in(0)->in(1)->in(0) != NULL &&
-             n->in(0)->in(1)->in(0) == n->in(0)->in(2)->in(0) &&
-             n->in(1)->in(ValueIn)->Opcode() == Op_CastPP) {
-    Node* iff = n->in(0)->in(1)->in(0);
-    Node* res = n->in(1)->in(ValueIn)->in(1);
-    if (iff->is_If() &&
-        iff->in(1) != NULL &&
-        iff->in(1)->is_Bool() &&
-        iff->in(1)->as_Bool()->_test._test == BoolTest::ne &&
-        iff->in(1)->in(1) != NULL &&
-        iff->in(1)->in(1)->Opcode() == Op_CmpP &&
-        iff->in(1)->in(1)->in(1) != NULL &&
-        iff->in(1)->in(1)->in(1) == res &&
-        iff->in(1)->in(1)->in(2) != NULL &&
-        iff->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) {
-      return res;
-    }
-  }
-  return n;
-}
-
-bool ShenandoahBarrierNode::needs_barrier(PhaseGVN* phase, ShenandoahBarrierNode* orig, Node* n, Node* rb_mem, bool allow_fromspace) {
-  Unique_Node_List visited;
-  return needs_barrier_impl(phase, orig, n, rb_mem, allow_fromspace, visited);
-}
-
-bool ShenandoahBarrierNode::needs_barrier_impl(PhaseGVN* phase, ShenandoahBarrierNode* orig, Node* n, Node* rb_mem, bool allow_fromspace, Unique_Node_List &visited) {
-  if (visited.member(n)) {
-    return false; // Been there.
-  }
-  visited.push(n);
-
-  if (n->is_Allocate()) {
-    return false;
-  }
-
-  if (n->is_Call()) {
-    return true;
-  }
-
-  const Type* type = phase->type(n);
-  if (type == Type::TOP) {
-    return false;
-  }
-  if (type->make_ptr()->higher_equal(TypePtr::NULL_PTR)) {
-    return false;
-  }
-  if (type->make_oopptr() && type->make_oopptr()->const_oop() != NULL) {
-    return false;
-  }
-
-  if (ShenandoahOptimizeStableFinals) {
-    const TypeAryPtr* ary = type->isa_aryptr();
-    if (ary && ary->is_stable() && allow_fromspace) {
-      return false;
-    }
-  }
-
-  if (n->is_CheckCastPP() || n->is_ConstraintCast() || n->Opcode() == Op_ShenandoahEnqueueBarrier) {
-    return needs_barrier_impl(phase, orig, n->in(1), rb_mem, allow_fromspace, visited);
-  }
-  if (n->is_Parm()) {
-    return true;
-  }
-  if (n->is_Proj()) {
-    return needs_barrier_impl(phase, orig, n->in(0), rb_mem, allow_fromspace, visited);
-  }
-
-  if (n->Opcode() == Op_ShenandoahWBMemProj) {
-    return needs_barrier_impl(phase, orig, n->in(ShenandoahWBMemProjNode::WriteBarrier), rb_mem, allow_fromspace, visited);
-  }
-  if (n->is_Phi()) {
-    bool need_barrier = false;
-    for (uint i = 1; i < n->req() && ! need_barrier; i++) {
-      Node* input = n->in(i);
-      if (input == NULL) {
-        need_barrier = true; // Phi not complete yet?
-      } else if (needs_barrier_impl(phase, orig, input, rb_mem, allow_fromspace, visited)) {
-        need_barrier = true;
-      }
-    }
-    return need_barrier;
-  }
-  if (n->is_CMove()) {
-    return needs_barrier_impl(phase, orig, n->in(CMoveNode::IfFalse), rb_mem, allow_fromspace, visited) ||
-           needs_barrier_impl(phase, orig, n->in(CMoveNode::IfTrue ), rb_mem, allow_fromspace, visited);
-  }
-  if (n->Opcode() == Op_CreateEx) {
-    return true;
-  }
-  if (n->Opcode() == Op_ShenandoahWriteBarrier) {
-    return false;
-  }
-  if (n->Opcode() == Op_ShenandoahReadBarrier) {
-    if (rb_mem == n->in(Memory)) {
-      return false;
-    } else {
-      return true;
-    }
-  }
-
-  if (n->Opcode() == Op_LoadP ||
-      n->Opcode() == Op_LoadN ||
-      n->Opcode() == Op_GetAndSetP ||
-      n->Opcode() == Op_CompareAndExchangeP ||
-      n->Opcode() == Op_ShenandoahCompareAndExchangeP ||
-      n->Opcode() == Op_GetAndSetN ||
-      n->Opcode() == Op_CompareAndExchangeN ||
-      n->Opcode() == Op_ShenandoahCompareAndExchangeN) {
-    return true;
-  }
-  if (n->Opcode() == Op_DecodeN ||
-      n->Opcode() == Op_EncodeP) {
-    return needs_barrier_impl(phase, orig, n->in(1), rb_mem, allow_fromspace, visited);
-  }
-
-#ifdef ASSERT
-  tty->print("need barrier on?: "); n->dump();
-  ShouldNotReachHere();
-#endif
-  return true;
-}
-
-bool ShenandoahReadBarrierNode::dominates_memory_rb_impl(PhaseGVN* phase,
-                                                         Node* b1,
-                                                         Node* b2,
-                                                         Node* current,
-                                                         bool linear) {
-  ResourceMark rm;
-  VectorSet visited(Thread::current()->resource_area());
-  Node_Stack phis(0);
-
-  for(int i = 0; i < 10; i++) {
-    if (current == NULL) {
-      return false;
-    } else if (visited.test_set(current->_idx) || current->is_top() || current == b1) {
-      current = NULL;
-      while (phis.is_nonempty() && current == NULL) {
-        uint idx = phis.index();
-        Node* phi = phis.node();
-        if (idx >= phi->req()) {
-          phis.pop();
-        } else {
-          current = phi->in(idx);
-          phis.set_index(idx+1);
-        }
-      }
-      if (current == NULL) {
-        return true;
-      }
-    } else if (current == phase->C->immutable_memory()) {
-      return false;
-    } else if (current->isa_Phi()) {
-      if (!linear) {
+bool ShenandoahBarrierC2Support::expand(Compile* C, PhaseIterGVN& igvn) {
+  ShenandoahBarrierSetC2State* state = ShenandoahBarrierSetC2::bsc2()->state();
+  if ((state->enqueue_barriers_count() +
+       state->load_reference_barriers_count()) > 0) {
+    bool attempt_more_loopopts = ShenandoahLoopOptsAfterExpansion;
+    C->clear_major_progress();
+    PhaseIdealLoop ideal_loop(igvn, LoopOptsShenandoahExpand);
+    if (C->failing()) return false;
+    PhaseIdealLoop::verify(igvn);
+    DEBUG_ONLY(verify_raw_mem(C->root());)
+    if (attempt_more_loopopts) {
+      C->set_major_progress();
+      if (!C->optimize_loops(igvn, LoopOptsShenandoahPostExpand)) {
         return false;
       }
-      phis.push(current, 2);
-      current = current->in(1);
-    } else if (current->Opcode() == Op_ShenandoahWriteBarrier) {
-      const Type* in_type = current->bottom_type();
-      const Type* this_type = b2->bottom_type();
-      if (is_independent(in_type, this_type)) {
-        current = current->in(Memory);
-      } else {
-        return false;
-      }
-    } else if (current->Opcode() == Op_ShenandoahWBMemProj) {
-      current = current->in(ShenandoahWBMemProjNode::WriteBarrier);
-    } else if (current->is_Proj()) {
-      current = current->in(0);
-    } else if (current->is_Call()) {
-      return false; // TODO: Maybe improve by looking at the call's memory effects?
-    } else if (current->is_MemBar()) {
-      return false; // TODO: Do we need to stop at *any* membar?
-    } else if (current->is_MergeMem()) {
-      const TypePtr* adr_type = brooks_pointer_type(phase->type(b2));
-      uint alias_idx = phase->C->get_alias_index(adr_type);
-      current = current->as_MergeMem()->memory_at(alias_idx);
-    } else {
-#ifdef ASSERT
-      current->dump();
-#endif
-      ShouldNotReachHere();
-      return false;
-    }
-  }
-  return false;
-}
-
-bool ShenandoahReadBarrierNode::is_independent(Node* mem) {
-  if (mem->is_Phi() || mem->is_Proj() || mem->is_MergeMem()) {
-    return true;
-  } else if (mem->Opcode() == Op_ShenandoahWBMemProj) {
-    return true;
-  } else if (mem->Opcode() == Op_ShenandoahWriteBarrier) {
-    const Type* mem_type = mem->bottom_type();
-    const Type* this_type = bottom_type();
-    if (is_independent(mem_type, this_type)) {
-      return true;
-    } else {
-      return false;
-    }
-  } else if (mem->is_Call() || mem->is_MemBar()) {
-    return false;
-  }
-#ifdef ASSERT
-  mem->dump();
-#endif
-  ShouldNotReachHere();
-  return true;
-}
-
-bool ShenandoahReadBarrierNode::dominates_memory_rb(PhaseGVN* phase, Node* b1, Node* b2, bool linear) {
-  return dominates_memory_rb_impl(phase, b1->in(Memory), b2, b2->in(Memory), linear);
-}
-
-bool ShenandoahReadBarrierNode::is_independent(const Type* in_type, const Type* this_type) {
-  assert(in_type->isa_oopptr(), "expect oop ptr");
-  assert(this_type->isa_oopptr(), "expect oop ptr");
-
-  ciKlass* in_kls = in_type->is_oopptr()->klass();
-  ciKlass* this_kls = this_type->is_oopptr()->klass();
-  if (in_kls != NULL && this_kls != NULL &&
-      in_kls->is_loaded() && this_kls->is_loaded() &&
-      (!in_kls->is_subclass_of(this_kls)) &&
-      (!this_kls->is_subclass_of(in_kls))) {
-    return true;
-  }
-  return false;
-}
-
-Node* ShenandoahReadBarrierNode::Ideal(PhaseGVN *phase, bool can_reshape) {
-  if (! can_reshape) {
-    return NULL;
-  }
-
-  if (in(Memory) == phase->C->immutable_memory()) return NULL;
-
-  // If memory input is a MergeMem, take the appropriate slice out of it.
-  Node* mem_in = in(Memory);
-  if (mem_in->isa_MergeMem()) {
-    const TypePtr* adr_type = brooks_pointer_type(bottom_type());
-    uint alias_idx = phase->C->get_alias_index(adr_type);
-    mem_in = mem_in->as_MergeMem()->memory_at(alias_idx);
-    set_req(Memory, mem_in);
-    return this;
-  }
-
-  Node* input = in(Memory);
-  if (input->Opcode() == Op_ShenandoahWBMemProj) {
-    ResourceMark rm;
-    VectorSet seen(Thread::current()->resource_area());
-    Node* n = in(Memory);
-    while (n->Opcode() == Op_ShenandoahWBMemProj &&
-           n->in(ShenandoahWBMemProjNode::WriteBarrier) != NULL &&
-           n->in(ShenandoahWBMemProjNode::WriteBarrier)->Opcode() == Op_ShenandoahWriteBarrier &&
-           n->in(ShenandoahWBMemProjNode::WriteBarrier)->in(Memory) != NULL) {
-      if (seen.test_set(n->_idx)) {
-        return NULL; // loop
-      }
-      n = n->in(ShenandoahWBMemProjNode::WriteBarrier)->in(Memory);
-    }
-
-    Node* wb = input->in(ShenandoahWBMemProjNode::WriteBarrier);
-    const Type* in_type = phase->type(wb);
-    // is_top() test not sufficient here: we can come here after CCP
-    // in a dead branch of the graph that has not yet been removed.
-    if (in_type == Type::TOP) return NULL; // Dead path.
-    assert(wb->Opcode() == Op_ShenandoahWriteBarrier, "expect write barrier");
-    if (is_independent(in_type, _type)) {
-      phase->igvn_rehash_node_delayed(wb);
-      set_req(Memory, wb->in(Memory));
-      if (can_reshape && input->outcnt() == 0) {
-        phase->is_IterGVN()->_worklist.push(input);
-      }
-      return this;
-    }
-  }
-  return NULL;
-}
-
-ShenandoahWriteBarrierNode::ShenandoahWriteBarrierNode(Compile* C, Node* ctrl, Node* mem, Node* obj)
-  : ShenandoahBarrierNode(ctrl, mem, obj, false) {
-  assert(UseShenandoahGC && ShenandoahWriteBarrier, "should be enabled");
-  ShenandoahBarrierSetC2::bsc2()->state()->add_shenandoah_barrier(this);
-}
-
-Node* ShenandoahWriteBarrierNode::Identity(PhaseGVN* phase) {
-  assert(in(0) != NULL, "should have control");
-  PhaseIterGVN* igvn = phase->is_IterGVN();
-  Node* mem_in = in(Memory);
-  Node* mem_proj = NULL;
-
-  if (igvn != NULL) {
-    mem_proj = find_out_with(Op_ShenandoahWBMemProj);
-    if (mem_in == mem_proj) {
-      return this;
-    }
-  }
-
-  Node* replacement = Identity_impl(phase);
-  if (igvn != NULL) {
-    if (replacement != NULL && replacement != this && mem_proj != NULL) {
-      igvn->replace_node(mem_proj, mem_in);
-    }
-  }
-  return replacement;
-}
-
-Node* ShenandoahWriteBarrierNode::Ideal(PhaseGVN *phase, bool can_reshape) {
-  assert(in(0) != NULL, "should have control");
-  if (!can_reshape) {
-    return NULL;
-  }
-
-  Node* mem_in = in(Memory);
-
-  if (mem_in->isa_MergeMem()) {
-    const TypePtr* adr_type = brooks_pointer_type(bottom_type());
-    uint alias_idx = phase->C->get_alias_index(adr_type);
-    mem_in = mem_in->as_MergeMem()->memory_at(alias_idx);
-    set_req(Memory, mem_in);
-    return this;
-  }
-
-  Node* val = in(ValueIn);
-  if (val->is_ShenandoahBarrier()) {
-    set_req(ValueIn, val->in(ValueIn));
-    return this;
-  }
-
-  return NULL;
-}
-
-bool ShenandoahWriteBarrierNode::expand(Compile* C, PhaseIterGVN& igvn) {
-  if (UseShenandoahGC) {
-    if (ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count() > 0 || (!ShenandoahWriteBarrier && ShenandoahStoreValEnqueueBarrier)) {
-      bool attempt_more_loopopts = ShenandoahLoopOptsAfterExpansion;
       C->clear_major_progress();
-      PhaseIdealLoop ideal_loop(igvn, LoopOptsShenandoahExpand);
-      if (C->failing()) return false;
-      PhaseIdealLoop::verify(igvn);
-      DEBUG_ONLY(ShenandoahBarrierNode::verify_raw_mem(C->root());)
-      if (attempt_more_loopopts) {
-        C->set_major_progress();
-        if (!C->optimize_loops(igvn, LoopOptsShenandoahPostExpand)) {
-          return false;
-        }
-        C->clear_major_progress();
-      }
     }
   }
   return true;
 }
 
-bool ShenandoahWriteBarrierNode::is_heap_state_test(Node* iff, int mask) {
+bool ShenandoahBarrierC2Support::is_heap_state_test(Node* iff, int mask) {
   if (!UseShenandoahGC) {
     return false;
   }
@@ -450,11 +95,11 @@
   return is_gc_state_load(in1);
 }
 
-bool ShenandoahWriteBarrierNode::is_heap_stable_test(Node* iff) {
+bool ShenandoahBarrierC2Support::is_heap_stable_test(Node* iff) {
   return is_heap_state_test(iff, ShenandoahHeap::HAS_FORWARDED);
 }
 
-bool ShenandoahWriteBarrierNode::is_gc_state_load(Node *n) {
+bool ShenandoahBarrierC2Support::is_gc_state_load(Node *n) {
   if (!UseShenandoahGC) {
     return false;
   }
@@ -476,7 +121,7 @@
   return true;
 }
 
-bool ShenandoahWriteBarrierNode::has_safepoint_between(Node* start, Node* stop, PhaseIdealLoop *phase) {
+bool ShenandoahBarrierC2Support::has_safepoint_between(Node* start, Node* stop, PhaseIdealLoop *phase) {
   assert(phase->is_dominator(stop, start), "bad inputs");
   ResourceMark rm;
   Unique_Node_List wq;
@@ -500,7 +145,7 @@
   return false;
 }
 
-bool ShenandoahWriteBarrierNode::try_common_gc_state_load(Node *n, PhaseIdealLoop *phase) {
+bool ShenandoahBarrierC2Support::try_common_gc_state_load(Node *n, PhaseIdealLoop *phase) {
   assert(is_gc_state_load(n), "inconsistent");
   Node* addp = n->in(MemNode::Address);
   Node* dominator = NULL;
@@ -525,193 +170,8 @@
   return true;
 }
 
-bool ShenandoahBarrierNode::dominates_memory_impl(PhaseGVN* phase,
-                                                  Node* b1,
-                                                  Node* b2,
-                                                  Node* current,
-                                                  bool linear) {
-  ResourceMark rm;
-  VectorSet visited(Thread::current()->resource_area());
-  Node_Stack phis(0);
-
-  for(int i = 0; i < 10; i++) {
-    if (current == NULL) {
-      return false;
-    } else if (visited.test_set(current->_idx) || current->is_top() || current == b1) {
-      current = NULL;
-      while (phis.is_nonempty() && current == NULL) {
-        uint idx = phis.index();
-        Node* phi = phis.node();
-        if (idx >= phi->req()) {
-          phis.pop();
-        } else {
-          current = phi->in(idx);
-          phis.set_index(idx+1);
-        }
-      }
-      if (current == NULL) {
-        return true;
-      }
-    } else if (current == b2) {
-      return false;
-    } else if (current == phase->C->immutable_memory()) {
-      return false;
-    } else if (current->isa_Phi()) {
-      if (!linear) {
-        return false;
-      }
-      phis.push(current, 2);
-      current = current->in(1);
-    } else if (current->Opcode() == Op_ShenandoahWriteBarrier) {
-      current = current->in(Memory);
-    } else if (current->Opcode() == Op_ShenandoahWBMemProj) {
-      current = current->in(ShenandoahWBMemProjNode::WriteBarrier);
-    } else if (current->is_Proj()) {
-      current = current->in(0);
-    } else if (current->is_Call()) {
-      current = current->in(TypeFunc::Memory);
-    } else if (current->is_MemBar()) {
-      current = current->in(TypeFunc::Memory);
-    } else if (current->is_MergeMem()) {
-      const TypePtr* adr_type = brooks_pointer_type(phase->type(b2));
-      uint alias_idx = phase->C->get_alias_index(adr_type);
-      current = current->as_MergeMem()->memory_at(alias_idx);
-    } else {
 #ifdef ASSERT
-      current->dump();
-#endif
-      ShouldNotReachHere();
-      return false;
-    }
-  }
-  return false;
-}
-
-/**
- * Determines if b1 dominates b2 through memory inputs. It returns true if:
- * - b1 can be reached by following each branch in b2's memory input (through phis, etc)
- * - or we get back to b2 (i.e. through a loop) without seeing b1
- * In all other cases, (in particular, if we reach immutable_memory without having seen b1)
- * we return false.
- */
-bool ShenandoahBarrierNode::dominates_memory(PhaseGVN* phase, Node* b1, Node* b2, bool linear) {
-  return dominates_memory_impl(phase, b1, b2, b2->in(Memory), linear);
-}
-
-Node* ShenandoahBarrierNode::Identity_impl(PhaseGVN* phase) {
-  Node* n = in(ValueIn);
-
-  Node* rb_mem = Opcode() == Op_ShenandoahReadBarrier ? in(Memory) : NULL;
-  if (! needs_barrier(phase, this, n, rb_mem, _allow_fromspace)) {
-    return n;
-  }
-
-  // Try to find a write barrier sibling with identical inputs that we can fold into.
-  for (DUIterator i = n->outs(); n->has_out(i); i++) {
-    Node* sibling = n->out(i);
-    if (sibling == this) {
-      continue;
-    }
-    if (sibling->Opcode() != Op_ShenandoahWriteBarrier) {
-      continue;
-    }
-
-    assert(sibling->in(ValueIn) == in(ValueIn), "sanity");
-    assert(sibling->Opcode() == Op_ShenandoahWriteBarrier, "sanity");
-
-    if (dominates_memory(phase, sibling, this, phase->is_IterGVN() == NULL)) {
-      return sibling;
-    }
-  }
-  return this;
-}
-
-#ifndef PRODUCT
-void ShenandoahBarrierNode::dump_spec(outputStream *st) const {
-  const TypePtr* adr = adr_type();
-  if (adr == NULL) {
-    return;
-  }
-  st->print(" @");
-  adr->dump_on(st);
-  st->print(" (");
-  Compile::current()->alias_type(adr)->adr_type()->dump_on(st);
-  st->print(") ");
-}
-#endif
-
-Node* ShenandoahReadBarrierNode::Identity(PhaseGVN* phase) {
-  Node* id = Identity_impl(phase);
-
-  if (id == this && phase->is_IterGVN()) {
-    Node* n = in(ValueIn);
-    // No success in super call. Try to combine identical read barriers.
-    for (DUIterator i = n->outs(); n->has_out(i); i++) {
-      Node* sibling = n->out(i);
-      if (sibling == this || sibling->Opcode() != Op_ShenandoahReadBarrier) {
-        continue;
-      }
-      assert(sibling->in(ValueIn)  == in(ValueIn), "sanity");
-      if (phase->is_IterGVN()->hash_find(sibling) &&
-          sibling->bottom_type() == bottom_type() &&
-          sibling->in(Control) == in(Control) &&
-          dominates_memory_rb(phase, sibling, this, phase->is_IterGVN() == NULL)) {
-        return sibling;
-      }
-    }
-  }
-  return id;
-}
-
-const Type* ShenandoahBarrierNode::Value(PhaseGVN* phase) const {
-  // Either input is TOP ==> the result is TOP
-  const Type *t1 = phase->type(in(Memory));
-  if (t1 == Type::TOP) return Type::TOP;
-  const Type *t2 = phase->type(in(ValueIn));
-  if( t2 == Type::TOP ) return Type::TOP;
-
-  if (t2 == TypePtr::NULL_PTR) {
-    return _type;
-  }
-
-  const Type* type = t2->is_oopptr()->cast_to_nonconst();
-  return type;
-}
-
-uint ShenandoahBarrierNode::hash() const {
-  return TypeNode::hash() + _allow_fromspace;
-}
-
-uint ShenandoahBarrierNode::cmp(const Node& n) const {
-  return _allow_fromspace == ((ShenandoahBarrierNode&) n)._allow_fromspace
-    && TypeNode::cmp(n);
-}
-
-uint ShenandoahBarrierNode::size_of() const {
-  return sizeof(*this);
-}
-
-Node* ShenandoahWBMemProjNode::Identity(PhaseGVN* phase) {
-  Node* wb = in(WriteBarrier);
-  if (wb->is_top()) return phase->C->top(); // Dead path.
-
-  assert(wb->Opcode() == Op_ShenandoahWriteBarrier, "expect write barrier");
-  PhaseIterGVN* igvn = phase->is_IterGVN();
-  // We can't do the below unless the graph is fully constructed.
-  if (igvn == NULL) {
-    return this;
-  }
-
-  // If the mem projection has no barrier users, it's not needed anymore.
-  if (wb->outcnt() == 1) {
-    return wb->in(ShenandoahBarrierNode::Memory);
-  }
-
-  return this;
-}
-
-#ifdef ASSERT
-bool ShenandoahBarrierNode::verify_helper(Node* in, Node_Stack& phis, VectorSet& visited, verify_type t, bool trace, Unique_Node_List& barriers_used) {
+bool ShenandoahBarrierC2Support::verify_helper(Node* in, Node_Stack& phis, VectorSet& visited, verify_type t, bool trace, Unique_Node_List& barriers_used) {
   assert(phis.size() == 0, "");
 
   while (true) {
@@ -732,12 +192,24 @@
         in = in->in(AddPNode::Address);
         continue;
       } else if (in->is_Con()) {
-        if (trace) {tty->print("Found constant"); in->dump();}
-      } else if (in->is_ShenandoahBarrier()) {
+        if (trace) {
+          tty->print("Found constant");
+          in->dump();
+        }
+      } else if (in->Opcode() == Op_Parm) {
+        if (trace) {
+          tty->print("Found argument");
+        }
+      } else if (in->Opcode() == Op_CreateEx) {
+        if (trace) {
+          tty->print("Found create-exception");
+        }
+      } else if (in->Opcode() == Op_LoadP && in->adr_type() == TypeRawPtr::BOTTOM) {
+        if (trace) {
+          tty->print("Found raw LoadP (OSR argument?)");
+        }
+      } else if (in->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
         if (t == ShenandoahOopStore) {
-          if (in->Opcode() != Op_ShenandoahWriteBarrier) {
-            return false;
-          }
           uint i = 0;
           for (; i < phis.size(); i++) {
             Node* n = phis.node_at(i);
@@ -748,8 +220,6 @@
           if (i == phis.size()) {
             return false;
           }
-        } else if (t == ShenandoahStore && in->Opcode() != Op_ShenandoahWriteBarrier) {
-          return false;
         }
         barriers_used.push(in);
         if (trace) {tty->print("Found barrier"); in->dump();}
@@ -763,7 +233,14 @@
         in = in->in(1);
         continue;
       } else if (in->is_Proj() && in->in(0)->is_Allocate()) {
-        if (trace) {tty->print("Found alloc"); in->in(0)->dump();}
+        if (trace) {
+          tty->print("Found alloc");
+          in->in(0)->dump();
+        }
+      } else if (in->is_Proj() && (in->in(0)->Opcode() == Op_CallStaticJava || in->in(0)->Opcode() == Op_CallDynamicJava)) {
+        if (trace) {
+          tty->print("Found Java call");
+        }
       } else if (in->is_Phi()) {
         if (!visited.test_set(in->_idx)) {
           if (trace) {tty->print("Pushed phi:"); in->dump();}
@@ -809,7 +286,7 @@
   return true;
 }
 
-void ShenandoahBarrierNode::report_verify_failure(const char *msg, Node *n1, Node *n2) {
+void ShenandoahBarrierC2Support::report_verify_failure(const char* msg, Node* n1, Node* n2) {
   if (n1 != NULL) {
     n1->dump(+10);
   }
@@ -819,7 +296,7 @@
   fatal("%s", msg);
 }
 
-void ShenandoahBarrierNode::verify(RootNode* root) {
+void ShenandoahBarrierC2Support::verify(RootNode* root) {
   ResourceMark rm;
   Unique_Node_List wq;
   GrowableArray<Node*> barriers;
@@ -871,7 +348,7 @@
             }
           }
 
-          if (verify && !ShenandoahBarrierNode::verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahLoad, trace, barriers_used)) {
+          if (verify && !verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahLoad, trace, barriers_used)) {
             report_verify_failure("Shenandoah verification: Load should have barriers", n);
           }
         }
@@ -899,11 +376,11 @@
           }
         }
 
-        if (verify && !ShenandoahBarrierNode::verify_helper(n->in(MemNode::ValueIn), phis, visited, ShenandoahStoreValEnqueueBarrier ? ShenandoahOopStore : ShenandoahValue, trace, barriers_used)) {
+        if (verify && !verify_helper(n->in(MemNode::ValueIn), phis, visited, ShenandoahStoreValEnqueueBarrier ? ShenandoahOopStore : ShenandoahValue, trace, barriers_used)) {
           report_verify_failure("Shenandoah verification: Store should have barriers", n);
         }
       }
-      if (!ShenandoahBarrierNode::verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahStore, trace, barriers_used)) {
+      if (!verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahStore, trace, barriers_used)) {
         report_verify_failure("Shenandoah verification: Store (address) should have barriers", n);
       }
     } else if (n->Opcode() == Op_CmpP) {
@@ -926,26 +403,26 @@
         } else {
           assert(in2->bottom_type()->isa_oopptr(), "");
 
-          if (!ShenandoahBarrierNode::verify_helper(in1, phis, visited, ShenandoahStore, trace, barriers_used) ||
-              !ShenandoahBarrierNode::verify_helper(in2, phis, visited, ShenandoahStore, trace, barriers_used)) {
+          if (!verify_helper(in1, phis, visited, ShenandoahStore, trace, barriers_used) ||
+              !verify_helper(in2, phis, visited, ShenandoahStore, trace, barriers_used)) {
             report_verify_failure("Shenandoah verification: Cmp should have barriers", n);
           }
         }
         if (verify_no_useless_barrier &&
             mark_inputs &&
-            (!ShenandoahBarrierNode::verify_helper(in1, phis, visited, ShenandoahValue, trace, barriers_used) ||
-             !ShenandoahBarrierNode::verify_helper(in2, phis, visited, ShenandoahValue, trace, barriers_used))) {
+            (!verify_helper(in1, phis, visited, ShenandoahValue, trace, barriers_used) ||
+             !verify_helper(in2, phis, visited, ShenandoahValue, trace, barriers_used))) {
           phis.clear();
           visited.Reset();
         }
       }
     } else if (n->is_LoadStore()) {
       if (n->in(MemNode::ValueIn)->bottom_type()->make_ptr() &&
-          !ShenandoahBarrierNode::verify_helper(n->in(MemNode::ValueIn), phis, visited, ShenandoahStoreValEnqueueBarrier ? ShenandoahOopStore : ShenandoahValue, trace, barriers_used)) {
+          !verify_helper(n->in(MemNode::ValueIn), phis, visited, ShenandoahStoreValEnqueueBarrier ? ShenandoahOopStore : ShenandoahValue, trace, barriers_used)) {
         report_verify_failure("Shenandoah verification: LoadStore (value) should have barriers", n);
       }
 
-      if (n->in(MemNode::Address)->bottom_type()->make_oopptr() && !ShenandoahBarrierNode::verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahStore, trace, barriers_used)) {
+      if (n->in(MemNode::Address)->bottom_type()->make_oopptr() && !verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahStore, trace, barriers_used)) {
         report_verify_failure("Shenandoah verification: LoadStore (address) should have barriers", n);
       }
     } else if (n->Opcode() == Op_CallLeafNoFP || n->Opcode() == Op_CallLeaf) {
@@ -1041,13 +518,13 @@
             }
           }
         }
-        if (!ShenandoahBarrierNode::verify_helper(n->in(TypeFunc::Parms), phis, visited, ShenandoahLoad, trace, barriers_used) ||
-            !ShenandoahBarrierNode::verify_helper(dest, phis, visited, ShenandoahStore, trace, barriers_used)) {
+        if (!verify_helper(n->in(TypeFunc::Parms), phis, visited, ShenandoahLoad, trace, barriers_used) ||
+            !verify_helper(dest, phis, visited, ShenandoahStore, trace, barriers_used)) {
           report_verify_failure("Shenandoah verification: ArrayCopy should have barriers", n);
         }
       } else if (strlen(call->_name) > 5 &&
                  !strcmp(call->_name + strlen(call->_name) - 5, "_fill")) {
-        if (!ShenandoahBarrierNode::verify_helper(n->in(TypeFunc::Parms), phis, visited, ShenandoahStore, trace, barriers_used)) {
+        if (!verify_helper(n->in(TypeFunc::Parms), phis, visited, ShenandoahStore, trace, barriers_used)) {
           report_verify_failure("Shenandoah verification: _fill should have barriers", n);
         }
       } else if (!strcmp(call->_name, "shenandoah_wb_pre")) {
@@ -1067,7 +544,7 @@
             if (pos == -1) {
               break;
             }
-            if (!ShenandoahBarrierNode::verify_helper(call->in(pos), phis, visited, calls[i].args[j].t, trace, barriers_used)) {
+            if (!verify_helper(call->in(pos), phis, visited, calls[i].args[j].t, trace, barriers_used)) {
               report_verify_failure("Shenandoah verification: intrinsic calls should have barriers", n);
             }
           }
@@ -1090,15 +567,8 @@
           }
         }
       }
-    } else if (n->is_ShenandoahBarrier()) {
-      assert(!barriers.contains(n), "");
-      assert(n->Opcode() != Op_ShenandoahWriteBarrier || n->find_out_with(Op_ShenandoahWBMemProj) != NULL, "bad shenandoah write barrier");
-      assert(n->Opcode() != Op_ShenandoahWriteBarrier || n->outcnt() > 1, "bad shenandoah write barrier");
-      barriers.push(n);
-    } else if (n->Opcode() == Op_ShenandoahEnqueueBarrier) {
+    } else if (n->Opcode() == Op_ShenandoahEnqueueBarrier || n->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
       // skip
-    } else if (n->Opcode() == Op_ShenandoahWBMemProj) {
-      assert(n->in(0) == NULL && n->in(ShenandoahWBMemProjNode::WriteBarrier)->Opcode() == Op_ShenandoahWriteBarrier, "strange ShenandoahWBMemProj");
     } else if (n->is_AddP()
                || n->is_Phi()
                || n->is_ConstraintCast()
@@ -1165,7 +635,7 @@
           if (pos == -1) {
             break;
           }
-          if (!ShenandoahBarrierNode::verify_helper(n->in(pos), phis, visited, others[i].inputs[j].t, trace, barriers_used)) {
+          if (!verify_helper(n->in(pos), phis, visited, others[i].inputs[j].t, trace, barriers_used)) {
             report_verify_failure("Shenandoah verification: intrinsic calls should have barriers", n);
           }
         }
@@ -1193,7 +663,7 @@
       SafePointNode* sfpt = n->as_SafePoint();
       if (verify_no_useless_barrier && sfpt->jvms() != NULL) {
         for (uint i = sfpt->jvms()->scloff(); i < sfpt->jvms()->endoff(); i++) {
-          if (!ShenandoahBarrierNode::verify_helper(sfpt->in(i), phis, visited, ShenandoahLoad, trace, barriers_used)) {
+          if (!verify_helper(sfpt->in(i), phis, visited, ShenandoahLoad, trace, barriers_used)) {
             phis.clear();
             visited.Reset();
           }
@@ -1227,9 +697,8 @@
             n->Opcode() == Op_SCMemProj ||
             n->Opcode() == Op_EncodeP ||
             n->Opcode() == Op_DecodeN ||
-            n->Opcode() == Op_ShenandoahWriteBarrier ||
-            n->Opcode() == Op_ShenandoahWBMemProj ||
-            n->Opcode() == Op_ShenandoahEnqueueBarrier)) {
+            n->Opcode() == Op_ShenandoahEnqueueBarrier ||
+            n->Opcode() == Op_ShenandoahLoadReferenceBarrier)) {
         if (m->bottom_type()->make_oopptr() && m->bottom_type()->make_oopptr()->meet(TypePtr::NULL_PTR) == m->bottom_type()) {
           report_verify_failure("Shenandoah verification: null input", n, m);
         }
@@ -1251,7 +720,7 @@
 }
 #endif
 
-bool ShenandoahBarrierNode::is_dominator_same_ctrl(Node*c, Node* d, Node* n, PhaseIdealLoop* phase) {
+bool ShenandoahBarrierC2Support::is_dominator_same_ctrl(Node* c, Node* d, Node* n, PhaseIdealLoop* phase) {
   // That both nodes have the same control is not sufficient to prove
   // domination, verify that there's no path from d to n
   ResourceMark rm;
@@ -1275,7 +744,7 @@
   return true;
 }
 
-bool ShenandoahBarrierNode::is_dominator(Node *d_c, Node *n_c, Node* d, Node* n, PhaseIdealLoop* phase) {
+bool ShenandoahBarrierC2Support::is_dominator(Node* d_c, Node* n_c, Node* d, Node* n, PhaseIdealLoop* phase) {
   if (d_c != n_c) {
     return phase->is_dominator(d_c, n_c);
   }
@@ -1290,15 +759,11 @@
     res = mem->in(TypeFunc::Memory);
   } else if (mem->is_Phi()) {
     res = mem->in(1);
-  } else if (mem->is_ShenandoahBarrier()) {
-    res = mem->in(ShenandoahBarrierNode::Memory);
   } else if (mem->is_MergeMem()) {
     res = mem->as_MergeMem()->memory_at(alias);
   } else if (mem->is_Store() || mem->is_LoadStore() || mem->is_ClearArray()) {
     assert(alias = Compile::AliasIdxRaw, "following raw memory can't lead to a barrier");
     res = mem->in(MemNode::Memory);
-  } else if (mem->Opcode() == Op_ShenandoahWBMemProj) {
-    res = mem->in(ShenandoahWBMemProjNode::WriteBarrier);
   } else {
 #ifdef ASSERT
     mem->dump();
@@ -1308,7 +773,7 @@
   return res;
 }
 
-Node* ShenandoahBarrierNode::no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase) {
+Node* ShenandoahBarrierC2Support::no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase) {
   Node* iffproj = NULL;
   while (c != dom) {
     Node* next = phase->idom(c);
@@ -1373,270 +838,7 @@
   return iffproj;
 }
 
-bool ShenandoahBarrierNode::build_loop_late_post(PhaseIdealLoop* phase, Node* n) {
-  if (n->Opcode() == Op_ShenandoahReadBarrier ||
-      n->Opcode() == Op_ShenandoahWriteBarrier ||
-      n->Opcode() == Op_ShenandoahWBMemProj) {
-
-    phase->build_loop_late_post_work(n, false);
-
-    if (n->Opcode() == Op_ShenandoahWriteBarrier) {
-      // The write barrier and its memory proj must have the same
-      // control otherwise some loop opts could put nodes (Phis) between
-      // them
-      Node* proj = n->find_out_with(Op_ShenandoahWBMemProj);
-      if (proj != NULL) {
-        phase->set_ctrl_and_loop(proj, phase->get_ctrl(n));
-      }
-    }
-    return true;
-  }
-  return false;
-}
-
-bool ShenandoahBarrierNode::sink_node(PhaseIdealLoop* phase, Node* ctrl, Node* n_ctrl) {
-  ctrl = phase->find_non_split_ctrl(ctrl);
-  assert(phase->dom_depth(n_ctrl) <= phase->dom_depth(ctrl), "n is later than its clone");
-  set_req(0, ctrl);
-  phase->register_new_node(this, ctrl);
-  return true;
-}
-
-#ifdef ASSERT
-void ShenandoahWriteBarrierNode::memory_dominates_all_paths_helper(Node* c, Node* rep_ctrl, Unique_Node_List& controls, PhaseIdealLoop* phase) {
-  const bool trace = false;
-  if (trace) { tty->print("X control is"); c->dump(); }
-
-  uint start = controls.size();
-  controls.push(c);
-  for (uint i = start; i < controls.size(); i++) {
-    Node *n = controls.at(i);
-
-    if (trace) { tty->print("X from"); n->dump(); }
-
-    if (n == rep_ctrl) {
-      continue;
-    }
-
-    if (n->is_Proj()) {
-      Node* n_dom = n->in(0);
-      IdealLoopTree* n_dom_loop = phase->get_loop(n_dom);
-      if (n->is_IfProj() && n_dom->outcnt() == 2) {
-        n_dom_loop = phase->get_loop(n_dom->as_If()->proj_out(n->as_Proj()->_con == 0 ? 1 : 0));
-      }
-      if (n_dom_loop != phase->ltree_root()) {
-        Node* tail = n_dom_loop->tail();
-        if (tail->is_Region()) {
-          for (uint j = 1; j < tail->req(); j++) {
-            if (phase->is_dominator(n_dom, tail->in(j)) && !phase->is_dominator(n, tail->in(j))) {
-              assert(phase->is_dominator(rep_ctrl, tail->in(j)), "why are we here?");
-              // entering loop from below, mark backedge
-              if (trace) { tty->print("X pushing backedge"); tail->in(j)->dump(); }
-              controls.push(tail->in(j));
-              //assert(n->in(0) == n_dom, "strange flow control");
-            }
-          }
-        } else if (phase->get_loop(n) != n_dom_loop && phase->is_dominator(n_dom, tail)) {
-          // entering loop from below, mark backedge
-          if (trace) { tty->print("X pushing backedge"); tail->dump(); }
-          controls.push(tail);
-          //assert(n->in(0) == n_dom, "strange flow control");
-        }
-      }
-    }
-
-    if (n->is_Loop()) {
-      Node* c = n->in(LoopNode::EntryControl);
-      if (trace) { tty->print("X pushing"); c->dump(); }
-      controls.push(c);
-    } else if (n->is_Region()) {
-      for (uint i = 1; i < n->req(); i++) {
-        Node* c = n->in(i);
-        if (trace) { tty->print("X pushing"); c->dump(); }
-        controls.push(c);
-      }
-    } else {
-      Node* c = n->in(0);
-      if (trace) { tty->print("X pushing"); c->dump(); }
-      controls.push(c);
-    }
-  }
-}
-
-bool ShenandoahWriteBarrierNode::memory_dominates_all_paths(Node* mem, Node* rep_ctrl, int alias, PhaseIdealLoop* phase) {
-  const bool trace = false;
-  if (trace) {
-    tty->print("XXX mem is"); mem->dump();
-    tty->print("XXX rep ctrl is"); rep_ctrl->dump();
-    tty->print_cr("XXX alias is %d", alias);
-  }
-  ResourceMark rm;
-  Unique_Node_List wq;
-  Unique_Node_List controls;
-  wq.push(mem);
-  for (uint next = 0; next < wq.size(); next++) {
-    Node *nn = wq.at(next);
-    if (trace) { tty->print("XX from mem"); nn->dump(); }
-    assert(nn->bottom_type() == Type::MEMORY, "memory only");
-
-    if (nn->is_Phi()) {
-      Node* r = nn->in(0);
-      for (DUIterator_Fast jmax, j = r->fast_outs(jmax); j < jmax; j++) {
-        Node* u = r->fast_out(j);
-        if (u->is_Phi() && u->bottom_type() == Type::MEMORY && u != nn &&
-            (u->adr_type() == TypePtr::BOTTOM || phase->C->get_alias_index(u->adr_type()) == alias)) {
-          if (trace) { tty->print("XX Next mem (other phi)"); u->dump(); }
-          wq.push(u);
-        }
-      }
-    }
-
-    for (DUIterator_Fast imax, i = nn->fast_outs(imax); i < imax; i++) {
-      Node* use = nn->fast_out(i);
-
-      if (trace) { tty->print("XX use %p", use->adr_type()); use->dump(); }
-      if (use->is_CFG() && use->in(TypeFunc::Memory) == nn) {
-        Node* c = use->in(0);
-        if (phase->is_dominator(rep_ctrl, c)) {
-          memory_dominates_all_paths_helper(c, rep_ctrl, controls, phase);
-        } else if (use->is_CallStaticJava() && use->as_CallStaticJava()->uncommon_trap_request() != 0 && c->is_Region()) {
-          Node* region = c;
-          if (trace) { tty->print("XX unc region"); region->dump(); }
-          for (uint j = 1; j < region->req(); j++) {
-            if (phase->is_dominator(rep_ctrl, region->in(j))) {
-              if (trace) { tty->print("XX unc follows"); region->in(j)->dump(); }
-              memory_dominates_all_paths_helper(region->in(j), rep_ctrl, controls, phase);
-            }
-          }
-        }
-        //continue;
-      } else if (use->is_Phi()) {
-        assert(use->bottom_type() == Type::MEMORY, "bad phi");
-        if ((use->adr_type() == TypePtr::BOTTOM) ||
-            phase->C->get_alias_index(use->adr_type()) == alias) {
-          for (uint j = 1; j < use->req(); j++) {
-            if (use->in(j) == nn) {
-              Node* c = use->in(0)->in(j);
-              if (phase->is_dominator(rep_ctrl, c)) {
-                memory_dominates_all_paths_helper(c, rep_ctrl, controls, phase);
-              }
-            }
-          }
-        }
-        //        continue;
-      }
-
-      if (use->is_MergeMem()) {
-        if (use->as_MergeMem()->memory_at(alias) == nn) {
-          if (trace) { tty->print("XX Next mem"); use->dump(); }
-          // follow the memory edges
-          wq.push(use);
-        }
-      } else if (use->is_Phi()) {
-        assert(use->bottom_type() == Type::MEMORY, "bad phi");
-        if ((use->adr_type() == TypePtr::BOTTOM) ||
-            phase->C->get_alias_index(use->adr_type()) == alias) {
-          if (trace) { tty->print("XX Next mem"); use->dump(); }
-          // follow the memory edges
-          wq.push(use);
-        }
-      } else if (use->bottom_type() == Type::MEMORY &&
-                 (use->adr_type() == TypePtr::BOTTOM || phase->C->get_alias_index(use->adr_type()) == alias)) {
-        if (trace) { tty->print("XX Next mem"); use->dump(); }
-        // follow the memory edges
-        wq.push(use);
-      } else if ((use->is_SafePoint() || use->is_MemBar()) &&
-                 (use->adr_type() == TypePtr::BOTTOM || phase->C->get_alias_index(use->adr_type()) == alias)) {
-        for (DUIterator_Fast jmax, j = use->fast_outs(jmax); j < jmax; j++) {
-          Node* u = use->fast_out(j);
-          if (u->bottom_type() == Type::MEMORY) {
-            if (trace) { tty->print("XX Next mem"); u->dump(); }
-            // follow the memory edges
-            wq.push(u);
-          }
-        }
-      } else if (use->Opcode() == Op_ShenandoahWriteBarrier && phase->C->get_alias_index(use->adr_type()) == alias) {
-        Node* m = use->find_out_with(Op_ShenandoahWBMemProj);
-        if (m != NULL) {
-          if (trace) { tty->print("XX Next mem"); m->dump(); }
-          // follow the memory edges
-          wq.push(m);
-        }
-      }
-    }
-  }
-
-  if (controls.size() == 0) {
-    return false;
-  }
-
-  for (uint i = 0; i < controls.size(); i++) {
-    Node *n = controls.at(i);
-
-    if (trace) { tty->print("X checking"); n->dump(); }
-
-    if (n->unique_ctrl_out() != NULL) {
-      continue;
-    }
-
-    if (n->Opcode() == Op_NeverBranch) {
-      Node* taken = n->as_Multi()->proj_out(0);
-      if (!controls.member(taken)) {
-        if (trace) { tty->print("X not seen"); taken->dump(); }
-        return false;
-      }
-      continue;
-    }
-
-    for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
-      Node* u = n->fast_out(j);
-
-      if (u->is_CFG()) {
-        if (!controls.member(u)) {
-          if (u->is_Proj() && u->as_Proj()->is_uncommon_trap_proj(Deoptimization::Reason_none)) {
-            if (trace) { tty->print("X not seen but unc"); u->dump(); }
-          } else {
-            Node* c = u;
-            do {
-              c = c->unique_ctrl_out();
-            } while (c != NULL && c->is_Region());
-            if (c != NULL && c->Opcode() == Op_Halt) {
-              if (trace) { tty->print("X not seen but halt"); c->dump(); }
-            } else {
-              if (trace) { tty->print("X not seen"); u->dump(); }
-              return false;
-            }
-          }
-        } else {
-          if (trace) { tty->print("X seen"); u->dump(); }
-        }
-      }
-    }
-  }
-  return true;
-}
-#endif
-
-Node* ShenandoahBarrierNode::dom_mem(Node* mem, Node*& mem_ctrl, Node* n, Node* rep_ctrl, int alias, PhaseIdealLoop* phase) {
-  ResourceMark rm;
-  VectorSet wq(Thread::current()->resource_area());
-  wq.set(mem->_idx);
-  mem_ctrl = phase->get_ctrl(mem);
-  while (!is_dominator(mem_ctrl, rep_ctrl, mem, n, phase)) {
-    mem = next_mem(mem, alias);
-    if (wq.test_set(mem->_idx)) {
-      return NULL; // hit an unexpected loop
-    }
-    mem_ctrl = phase->ctrl_or_self(mem);
-  }
-  if (mem->is_MergeMem()) {
-    mem = mem->as_MergeMem()->memory_at(alias);
-    mem_ctrl = phase->ctrl_or_self(mem);
-  }
-  return mem;
-}
-
-Node* ShenandoahBarrierNode::dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase) {
+Node* ShenandoahBarrierC2Support::dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase) {
   ResourceMark rm;
   VectorSet wq(Thread::current()->resource_area());
   wq.set(mem->_idx);
@@ -1655,650 +857,7 @@
   return mem;
 }
 
-static void disconnect_barrier_mem(Node* wb, PhaseIterGVN& igvn) {
-  Node* mem_in = wb->in(ShenandoahBarrierNode::Memory);
-  Node* proj = wb->find_out_with(Op_ShenandoahWBMemProj);
-
-  for (DUIterator_Last imin, i = proj->last_outs(imin); i >= imin; ) {
-    Node* u = proj->last_out(i);
-    igvn.rehash_node_delayed(u);
-    int nb = u->replace_edge(proj, mem_in);
-    assert(nb > 0, "no replacement?");
-    i -= nb;
-  }
-}
-
-Node* ShenandoahWriteBarrierNode::move_above_predicates(LoopNode* cl, Node* val_ctrl, PhaseIdealLoop* phase) {
-  Node* entry = cl->skip_strip_mined(-1)->in(LoopNode::EntryControl);
-  Node* above_pred = phase->skip_all_loop_predicates(entry);
-  Node* ctrl = entry;
-  while (ctrl != above_pred) {
-    Node* next = ctrl->in(0);
-    if (!phase->is_dominator(val_ctrl, next)) {
-      break;
-    }
-    ctrl = next;
-  }
-  return ctrl;
-}
-
-static MemoryGraphFixer* find_fixer(GrowableArray<MemoryGraphFixer*>& memory_graph_fixers, int alias) {
-  for (int i = 0; i < memory_graph_fixers.length(); i++) {
-    if (memory_graph_fixers.at(i)->alias() == alias) {
-      return memory_graph_fixers.at(i);
-    }
-  }
-  return NULL;
-}
-
-static MemoryGraphFixer* create_fixer(GrowableArray<MemoryGraphFixer*>& memory_graph_fixers, int alias, PhaseIdealLoop* phase, bool include_lsm) {
-  assert(find_fixer(memory_graph_fixers, alias) == NULL, "none should exist yet");
-  MemoryGraphFixer* fixer = new MemoryGraphFixer(alias, include_lsm, phase);
-  memory_graph_fixers.push(fixer);
-  return fixer;
-}
-
-void ShenandoahWriteBarrierNode::try_move_before_loop_helper(LoopNode* cl, Node* val_ctrl, GrowableArray<MemoryGraphFixer*>& memory_graph_fixers, PhaseIdealLoop* phase, bool include_lsm, Unique_Node_List& uses) {
-  assert(cl->is_Loop(), "bad control");
-  Node* ctrl = move_above_predicates(cl, val_ctrl, phase);
-  Node* mem_ctrl = NULL;
-  int alias = phase->C->get_alias_index(adr_type());
-
-  MemoryGraphFixer* fixer = find_fixer(memory_graph_fixers, alias);
-  if (fixer == NULL) {
-    fixer = create_fixer(memory_graph_fixers, alias, phase, include_lsm);
-  }
-
-  Node* proj = find_out_with(Op_ShenandoahWBMemProj);
-
-  fixer->remove(proj);
-  Node* mem = fixer->find_mem(ctrl, NULL);
-
-  assert(!ShenandoahVerifyOptoBarriers || memory_dominates_all_paths(mem, ctrl, alias, phase), "can't fix the memory graph");
-
-  phase->set_ctrl_and_loop(this, ctrl);
-  phase->igvn().replace_input_of(this, Control, ctrl);
-
-  disconnect_barrier_mem(this, phase->igvn());
-
-  phase->igvn().replace_input_of(this, Memory, mem);
-  phase->set_ctrl_and_loop(proj, ctrl);
-
-  fixer->fix_mem(ctrl, ctrl, mem, mem, proj, uses);
-  assert(proj->outcnt() > 0, "disconnected write barrier");
-}
-
-LoopNode* ShenandoahWriteBarrierNode::try_move_before_pre_loop(Node* c, Node* val_ctrl, PhaseIdealLoop* phase) {
-  // A write barrier between a pre and main loop can get in the way of
-  // vectorization. Move it above the pre loop if possible
-  CountedLoopNode* cl = NULL;
-  if (c->is_IfFalse() &&
-      c->in(0)->is_CountedLoopEnd()) {
-    cl = c->in(0)->as_CountedLoopEnd()->loopnode();
-  } else if (c->is_IfProj() &&
-             c->in(0)->is_If() &&
-             c->in(0)->in(0)->is_IfFalse() &&
-             c->in(0)->in(0)->in(0)->is_CountedLoopEnd()) {
-    cl = c->in(0)->in(0)->in(0)->as_CountedLoopEnd()->loopnode();
-  }
-  if (cl != NULL &&
-      cl->is_pre_loop() &&
-      val_ctrl != cl &&
-      phase->is_dominator(val_ctrl, cl)) {
-    return cl;
-  }
-  return NULL;
-}
-
-void ShenandoahWriteBarrierNode::try_move_before_loop(GrowableArray<MemoryGraphFixer*>& memory_graph_fixers, PhaseIdealLoop* phase, bool include_lsm, Unique_Node_List& uses) {
-  Node *n_ctrl = phase->get_ctrl(this);
-  IdealLoopTree *n_loop = phase->get_loop(n_ctrl);
-  Node* val = in(ValueIn);
-  Node* val_ctrl = phase->get_ctrl(val);
-  if (n_loop != phase->ltree_root() && !n_loop->_irreducible) {
-    IdealLoopTree *val_loop = phase->get_loop(val_ctrl);
-    Node* mem = in(Memory);
-    IdealLoopTree *mem_loop = phase->get_loop(phase->get_ctrl(mem));
-    if (!n_loop->is_member(val_loop) &&
-        n_loop->is_member(mem_loop)) {
-      Node* n_loop_head = n_loop->_head;
-
-      if (n_loop_head->is_Loop()) {
-        LoopNode* loop = n_loop_head->as_Loop();
-        if (n_loop_head->is_CountedLoop() && n_loop_head->as_CountedLoop()->is_main_loop()) {
-          LoopNode* res = try_move_before_pre_loop(n_loop_head->in(LoopNode::EntryControl), val_ctrl, phase);
-          if (res != NULL) {
-            loop = res;
-          }
-        }
-
-        try_move_before_loop_helper(loop, val_ctrl, memory_graph_fixers, phase, include_lsm, uses);
-      }
-    }
-  }
-  LoopNode* ctrl = try_move_before_pre_loop(in(0), val_ctrl, phase);
-  if (ctrl != NULL) {
-    try_move_before_loop_helper(ctrl, val_ctrl, memory_graph_fixers, phase, include_lsm, uses);
-  }
-}
-
-Node* ShenandoahWriteBarrierNode::would_subsume(ShenandoahBarrierNode* other, PhaseIdealLoop* phase) {
-  Node* val = in(ValueIn);
-  Node* val_ctrl = phase->get_ctrl(val);
-  Node* other_mem = other->in(Memory);
-  Node* other_ctrl = phase->get_ctrl(other);
-  Node* this_ctrl = phase->get_ctrl(this);
-  IdealLoopTree* this_loop = phase->get_loop(this_ctrl);
-  IdealLoopTree* other_loop = phase->get_loop(other_ctrl);
-
-  Node* ctrl = phase->dom_lca(other_ctrl, this_ctrl);
-
-  if (ctrl->is_Proj() &&
-      ctrl->in(0)->is_Call() &&
-      ctrl->unique_ctrl_out() != NULL &&
-      ctrl->unique_ctrl_out()->Opcode() == Op_Catch &&
-      !phase->is_dominator(val_ctrl, ctrl->in(0)->in(0))) {
-    return NULL;
-  }
-
-  IdealLoopTree* loop = phase->get_loop(ctrl);
-
-  // We don't want to move a write barrier in a loop
-  // If the LCA is in a inner loop, try a control out of loop if possible
-  while (!loop->is_member(this_loop) && (other->Opcode() != Op_ShenandoahWriteBarrier || !loop->is_member(other_loop))) {
-    ctrl = phase->idom(ctrl);
-    if (ctrl->is_MultiBranch()) {
-      ctrl = ctrl->in(0);
-    }
-    if (ctrl != val_ctrl && phase->is_dominator(ctrl, val_ctrl)) {
-      return NULL;
-    }
-    loop = phase->get_loop(ctrl);
-  }
-
-  if (ShenandoahDontIncreaseWBFreq) {
-    Node* this_iffproj = no_branches(this_ctrl, ctrl, true, phase);
-    if (other->Opcode() == Op_ShenandoahWriteBarrier) {
-      Node* other_iffproj = no_branches(other_ctrl, ctrl, true, phase);
-      if (other_iffproj == NULL || this_iffproj == NULL) {
-        return ctrl;
-      } else if (other_iffproj != NodeSentinel && this_iffproj != NodeSentinel &&
-                 other_iffproj->in(0) == this_iffproj->in(0)) {
-        return ctrl;
-      }
-    } else if (this_iffproj == NULL) {
-      return ctrl;
-    }
-    return NULL;
-  }
-
-  return ctrl;
-}
-
-void ShenandoahWriteBarrierNode::optimize_before_expansion(PhaseIdealLoop* phase, GrowableArray<MemoryGraphFixer*> memory_graph_fixers, bool include_lsm) {
-  bool progress = false;
-  Unique_Node_List uses;
-  do {
-    progress = false;
-    for (int i = 0; i < ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count(); i++) {
-      ShenandoahWriteBarrierNode* wb = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barrier(i);
-
-      wb->try_move_before_loop(memory_graph_fixers, phase, include_lsm, uses);
-
-      Node* val = wb->in(ValueIn);
-
-      for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) {
-        Node* u = val->fast_out(j);
-        if (u != wb && u->is_ShenandoahBarrier()) {
-          Node* rep_ctrl = wb->would_subsume(u->as_ShenandoahBarrier(), phase);
-
-          if (rep_ctrl != NULL) {
-            Node* other = u;
-            Node* val_ctrl = phase->get_ctrl(val);
-            if (rep_ctrl->is_Proj() &&
-                rep_ctrl->in(0)->is_Call() &&
-                rep_ctrl->unique_ctrl_out() != NULL &&
-                rep_ctrl->unique_ctrl_out()->Opcode() == Op_Catch) {
-              rep_ctrl = rep_ctrl->in(0)->in(0);
-
-              assert(phase->is_dominator(val_ctrl, rep_ctrl), "bad control");
-            } else {
-              LoopNode* c = ShenandoahWriteBarrierNode::try_move_before_pre_loop(rep_ctrl, val_ctrl, phase);
-              if (c != NULL) {
-                rep_ctrl = ShenandoahWriteBarrierNode::move_above_predicates(c, val_ctrl, phase);
-              } else {
-                while (rep_ctrl->is_IfProj()) {
-                  CallStaticJavaNode* unc = rep_ctrl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
-                  if (unc != NULL) {
-                    int req = unc->uncommon_trap_request();
-                    Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
-                    if ((trap_reason == Deoptimization::Reason_loop_limit_check ||
-                         trap_reason == Deoptimization::Reason_predicate ||
-                         trap_reason == Deoptimization::Reason_profile_predicate) &&
-                        phase->is_dominator(val_ctrl, rep_ctrl->in(0)->in(0))) {
-                      rep_ctrl = rep_ctrl->in(0)->in(0);
-                      continue;
-                    }
-                  }
-                  break;
-                }
-              }
-            }
-
-            Node* wb_ctrl = phase->get_ctrl(wb);
-            Node* other_ctrl = phase->get_ctrl(other);
-            int alias = phase->C->get_alias_index(wb->adr_type());
-            MemoryGraphFixer* fixer = find_fixer(memory_graph_fixers, alias);;
-            if (!is_dominator(wb_ctrl, other_ctrl, wb, other, phase)) {
-              if (fixer == NULL) {
-                fixer = create_fixer(memory_graph_fixers, alias, phase, include_lsm);
-              }
-              Node* mem = fixer->find_mem(rep_ctrl, phase->get_ctrl(other) == rep_ctrl ? other : NULL);
-
-              if (mem->has_out_with(Op_Lock) || mem->has_out_with(Op_Unlock)) {
-                continue;
-              }
-
-              Node* wb_proj = wb->find_out_with(Op_ShenandoahWBMemProj);
-              fixer->remove(wb_proj);
-              Node* mem_for_ctrl = fixer->find_mem(rep_ctrl, NULL);
-
-              if (wb->in(Memory) != mem) {
-                disconnect_barrier_mem(wb, phase->igvn());
-                phase->igvn().replace_input_of(wb, Memory, mem);
-              }
-              if (rep_ctrl != wb_ctrl) {
-                phase->set_ctrl_and_loop(wb, rep_ctrl);
-                phase->igvn().replace_input_of(wb, Control, rep_ctrl);
-                phase->set_ctrl_and_loop(wb_proj, rep_ctrl);
-                progress = true;
-              }
-
-              fixer->fix_mem(rep_ctrl, rep_ctrl, mem, mem_for_ctrl, wb_proj, uses);
-
-              assert(!ShenandoahVerifyOptoBarriers || ShenandoahWriteBarrierNode::memory_dominates_all_paths(mem, rep_ctrl, alias, phase), "can't fix the memory graph");
-            }
-
-            if (other->Opcode() == Op_ShenandoahWriteBarrier) {
-              Node* other_proj = other->find_out_with(Op_ShenandoahWBMemProj);
-              if (fixer != NULL) {
-                fixer->remove(other_proj);
-              }
-              phase->igvn().replace_node(other_proj, other->in(Memory));
-            }
-            phase->igvn().replace_node(other, wb);
-            --j; --jmax;
-          }
-        }
-      }
-    }
-  } while(progress);
-}
-
-// Some code duplication with PhaseIdealLoop::split_if_with_blocks_pre()
-Node* ShenandoahWriteBarrierNode::try_split_thru_phi(PhaseIdealLoop* phase) {
-  Node *ctrl = phase->get_ctrl(this);
-  if (ctrl == NULL) {
-    return this;
-  }
-  Node *blk = phase->has_local_phi_input(this);
-  if (blk == NULL) {
-    return this;
-  }
-
-  if (in(0) != blk) {
-    return this;
-  }
-
-  int policy = blk->req() >> 2;
-
-  if (blk->is_CountedLoop()) {
-    IdealLoopTree *lp = phase->get_loop(blk);
-    if (lp && lp->_rce_candidate) {
-      return this;
-    }
-  }
-
-  if (phase->C->live_nodes() > 35000) {
-    return this;
-  }
-
-  uint unique = phase->C->unique();
-  Node *phi = phase->split_thru_phi(this, blk, policy);
-  if (phi == NULL) {
-    return this;
-  }
-
-  Node* mem_phi = new PhiNode(blk, Type::MEMORY, phase->C->alias_type(adr_type())->adr_type());
-  for (uint i = 1; i < blk->req(); i++) {
-    Node* n = phi->in(i);
-    if (n->Opcode() == Op_ShenandoahWriteBarrier &&
-        n->_idx >= unique) {
-      Node* proj = new ShenandoahWBMemProjNode(n);
-      phase->register_new_node(proj, phase->get_ctrl(n));
-      mem_phi->init_req(i, proj);
-    } else {
-      Node* mem = in(ShenandoahBarrierNode::Memory);
-      if (mem->is_Phi() && mem->in(0) == blk) {
-        mem = mem->in(i);
-      }
-      mem_phi->init_req(i, mem);
-    }
-  }
-  phase->register_new_node(mem_phi, blk);
-
-
-  Node* proj = find_out_with(Op_ShenandoahWBMemProj);
-  phase->igvn().replace_node(proj, mem_phi);
-  phase->igvn().replace_node(this, phi);
-
-  return phi;
-}
-
-void ShenandoahReadBarrierNode::try_move(PhaseIdealLoop* phase) {
-  Node *n_ctrl = phase->get_ctrl(this);
-  if (n_ctrl == NULL) {
-    return;
-  }
-  Node* mem = in(MemNode::Memory);
-  int alias = phase->C->get_alias_index(adr_type());
-  const bool trace = false;
-
-#ifdef ASSERT
-  if (trace) { tty->print("Trying to move mem of"); dump(); }
-#endif
-
-  Node* new_mem = mem;
-
-  ResourceMark rm;
-  VectorSet seen(Thread::current()->resource_area());
-  Node_List phis;
-
-  for (;;) {
-#ifdef ASSERT
-    if (trace) { tty->print("Looking for dominator from"); mem->dump(); }
-#endif
-    if (mem->is_Proj() && mem->in(0)->is_Start()) {
-      if (new_mem != in(MemNode::Memory)) {
-#ifdef ASSERT
-        if (trace) { tty->print("XXX Setting mem to"); new_mem->dump(); tty->print(" for "); dump(); }
-#endif
-        phase->igvn().replace_input_of(this, MemNode::Memory, new_mem);
-      }
-      return;
-    }
-
-    Node* candidate = mem;
-    do {
-      if (!is_independent(mem)) {
-        if (trace) { tty->print_cr("Not independent"); }
-        if (new_mem != in(MemNode::Memory)) {
-#ifdef ASSERT
-          if (trace) { tty->print("XXX Setting mem to"); new_mem->dump(); tty->print(" for "); dump(); }
-#endif
-          phase->igvn().replace_input_of(this, MemNode::Memory, new_mem);
-        }
-        return;
-      }
-      if (seen.test_set(mem->_idx)) {
-        if (trace) { tty->print_cr("Already seen"); }
-        ShouldNotReachHere();
-        // Strange graph
-        if (new_mem != in(MemNode::Memory)) {
-#ifdef ASSERT
-          if (trace) { tty->print("XXX Setting mem to"); new_mem->dump(); tty->print(" for "); dump(); }
-#endif
-          phase->igvn().replace_input_of(this, MemNode::Memory, new_mem);
-        }
-        return;
-      }
-      if (mem->is_Phi()) {
-        phis.push(mem);
-      }
-      mem = next_mem(mem, alias);
-      if (mem->bottom_type() == Type::MEMORY) {
-        candidate = mem;
-      }
-      assert(is_dominator(phase->ctrl_or_self(mem), n_ctrl, mem, this, phase) == phase->is_dominator(phase->ctrl_or_self(mem), n_ctrl), "strange dominator");
-#ifdef ASSERT
-      if (trace) { tty->print("Next mem is"); mem->dump(); }
-#endif
-    } while (mem->bottom_type() != Type::MEMORY || !phase->is_dominator(phase->ctrl_or_self(mem), n_ctrl));
-
-    assert(mem->bottom_type() == Type::MEMORY, "bad mem");
-
-    bool not_dom = false;
-    for (uint i = 0; i < phis.size() && !not_dom; i++) {
-      Node* nn = phis.at(i);
-
-#ifdef ASSERT
-      if (trace) { tty->print("Looking from phi"); nn->dump(); }
-#endif
-      assert(nn->is_Phi(), "phis only");
-      for (uint j = 2; j < nn->req() && !not_dom; j++) {
-        Node* m = nn->in(j);
-#ifdef ASSERT
-        if (trace) { tty->print("Input %d is", j); m->dump(); }
-#endif
-        while (m != mem && !seen.test_set(m->_idx)) {
-          if (is_dominator(phase->ctrl_or_self(m), phase->ctrl_or_self(mem), m, mem, phase)) {
-            not_dom = true;
-            // Scheduling anomaly
-#ifdef ASSERT
-            if (trace) { tty->print("Giving up"); m->dump(); }
-#endif
-            break;
-          }
-          if (!is_independent(m)) {
-            if (trace) { tty->print_cr("Not independent"); }
-            if (new_mem != in(MemNode::Memory)) {
-#ifdef ASSERT
-              if (trace) { tty->print("XXX Setting mem to"); new_mem->dump(); tty->print(" for "); dump(); }
-#endif
-              phase->igvn().replace_input_of(this, MemNode::Memory, new_mem);
-            }
-            return;
-          }
-          if (m->is_Phi()) {
-            phis.push(m);
-          }
-          m = next_mem(m, alias);
-#ifdef ASSERT
-          if (trace) { tty->print("Next mem is"); m->dump(); }
-#endif
-        }
-      }
-    }
-    if (!not_dom) {
-      new_mem = mem;
-      phis.clear();
-    } else {
-      seen.Clear();
-    }
-  }
-}
-
-CallStaticJavaNode* ShenandoahWriteBarrierNode::pin_and_expand_null_check(PhaseIterGVN& igvn) {
-  Node* val = in(ValueIn);
-
-  const Type* val_t = igvn.type(val);
-
-  if (val_t->meet(TypePtr::NULL_PTR) != val_t &&
-      val->Opcode() == Op_CastPP &&
-      val->in(0) != NULL &&
-      val->in(0)->Opcode() == Op_IfTrue &&
-      val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) &&
-      val->in(0)->in(0)->is_If() &&
-      val->in(0)->in(0)->in(1)->Opcode() == Op_Bool &&
-      val->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne &&
-      val->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
-      val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1) &&
-      val->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) {
-    assert(val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1), "");
-    CallStaticJavaNode* unc = val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
-    return unc;
-  }
-  return NULL;
-}
-
-void ShenandoahWriteBarrierNode::pin_and_expand_move_barrier(PhaseIdealLoop* phase, GrowableArray<MemoryGraphFixer*>& memory_graph_fixers, Unique_Node_List& uses) {
-  Node* unc = pin_and_expand_null_check(phase->igvn());
-  Node* val = in(ValueIn);
-
-  if (unc != NULL) {
-    Node* ctrl = phase->get_ctrl(this);
-    Node* unc_ctrl = val->in(0);
-
-    // Don't move write barrier in a loop
-    IdealLoopTree* loop = phase->get_loop(ctrl);
-    IdealLoopTree* unc_loop = phase->get_loop(unc_ctrl);
-
-    if (!unc_loop->is_member(loop)) {
-      return;
-    }
-
-    Node* branch = no_branches(ctrl, unc_ctrl, false, phase);
-    assert(branch == NULL || branch == NodeSentinel, "was not looking for a branch");
-    if (branch == NodeSentinel) {
-      return;
-    }
-
-    RegionNode* r = new RegionNode(3);
-    IfNode* iff = unc_ctrl->in(0)->as_If();
-
-    Node* ctrl_use = unc_ctrl->unique_ctrl_out();
-    Node* unc_ctrl_clone = unc_ctrl->clone();
-    phase->register_control(unc_ctrl_clone, loop, iff);
-    Node* c = unc_ctrl_clone;
-    Node* new_cast = clone_null_check(c, val, unc_ctrl_clone, phase);
-    r->init_req(1, new_cast->in(0)->in(0)->as_If()->proj_out(0));
-
-    phase->igvn().replace_input_of(unc_ctrl, 0, c->in(0));
-    phase->set_idom(unc_ctrl, c->in(0), phase->dom_depth(unc_ctrl));
-    phase->lazy_replace(c, unc_ctrl);
-    c = NULL;;
-    phase->igvn().replace_input_of(val, 0, unc_ctrl_clone);
-    phase->set_ctrl(val, unc_ctrl_clone);
-
-    IfNode* new_iff = new_cast->in(0)->in(0)->as_If();
-    fix_null_check(unc, unc_ctrl_clone, r, uses, phase);
-    Node* iff_proj = iff->proj_out(0);
-    r->init_req(2, iff_proj);
-    phase->register_control(r, phase->ltree_root(), iff);
-
-    Node* new_bol = new_iff->in(1)->clone();
-    Node* new_cmp = new_bol->in(1)->clone();
-    assert(new_cmp->Opcode() == Op_CmpP, "broken");
-    assert(new_cmp->in(1) == val->in(1), "broken");
-    new_bol->set_req(1, new_cmp);
-    new_cmp->set_req(1, this);
-    phase->register_new_node(new_bol, new_iff->in(0));
-    phase->register_new_node(new_cmp, new_iff->in(0));
-    phase->igvn().replace_input_of(new_iff, 1, new_bol);
-    phase->igvn().replace_input_of(new_cast, 1, this);
-
-    for (DUIterator_Fast imax, i = this->fast_outs(imax); i < imax; i++) {
-      Node* u = this->fast_out(i);
-      if (u == new_cast || u->Opcode() == Op_ShenandoahWBMemProj || u == new_cmp) {
-        continue;
-      }
-      phase->igvn().rehash_node_delayed(u);
-      int nb = u->replace_edge(this, new_cast);
-      assert(nb > 0, "no update?");
-      --i; imax -= nb;
-    }
-
-    for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
-      Node* u = val->fast_out(i);
-      if (u == this) {
-        continue;
-      }
-      phase->igvn().rehash_node_delayed(u);
-      int nb = u->replace_edge(val, new_cast);
-      assert(nb > 0, "no update?");
-      --i; imax -= nb;
-    }
-
-    Node* new_ctrl = unc_ctrl_clone;
-
-    int alias = phase->C->get_alias_index(adr_type());
-    MemoryGraphFixer* fixer = find_fixer(memory_graph_fixers, alias);
-    if (fixer == NULL) {
-      fixer = create_fixer(memory_graph_fixers, alias, phase, true);
-    }
-
-    Node* proj = find_out_with(Op_ShenandoahWBMemProj);
-    fixer->remove(proj);
-    Node* mem = fixer->find_mem(new_ctrl, NULL);
-
-    if (in(Memory) != mem) {
-      disconnect_barrier_mem(this, phase->igvn());
-      phase->igvn().replace_input_of(this, Memory, mem);
-    }
-
-    phase->set_ctrl_and_loop(this, new_ctrl);
-    phase->igvn().replace_input_of(this, Control, new_ctrl);
-    phase->set_ctrl_and_loop(proj, new_ctrl);
-
-    fixer->fix_mem(new_ctrl, new_ctrl, mem, mem, proj, uses);
-  }
-}
-
-void ShenandoahWriteBarrierNode::pin_and_expand_helper(PhaseIdealLoop* phase) {
-  Node* val = in(ValueIn);
-  CallStaticJavaNode* unc = pin_and_expand_null_check(phase->igvn());
-  Node* rep = this;
-  Node* ctrl = phase->get_ctrl(this);
-  if (unc != NULL && val->in(0) == ctrl) {
-    Node* unc_ctrl = val->in(0);
-    IfNode* other_iff = unc_ctrl->unique_ctrl_out()->as_If();
-    ProjNode* other_unc_ctrl = other_iff->proj_out(1);
-    Node* cast = NULL;
-    for (DUIterator_Fast imax, i = other_unc_ctrl->fast_outs(imax); i < imax && cast == NULL; i++) {
-      Node* u = other_unc_ctrl->fast_out(i);
-      if (u->Opcode() == Op_CastPP && u->in(1) == this) {
-        cast = u;
-      }
-    }
-    assert(other_unc_ctrl->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) == unc, "broken");
-    rep = cast;
-  }
-
-  // Replace all uses of barrier's input that are dominated by ctrl
-  // with the value returned by the barrier: no need to keep both
-  // live.
-  for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
-    Node* u = val->fast_out(i);
-    if (u != this) {
-      if (u->is_Phi()) {
-        int nb = 0;
-        for (uint j = 1; j < u->req(); j++) {
-          if (u->in(j) == val) {
-            Node* c = u->in(0)->in(j);
-            if (phase->is_dominator(ctrl, c)) {
-              phase->igvn().replace_input_of(u, j, rep);
-              nb++;
-            }
-          }
-        }
-        if (nb > 0) {
-          imax -= nb;
-          --i;
-        }
-      } else {
-        Node* c = phase->ctrl_or_self(u);
-        if (is_dominator(ctrl, c, this, u, phase)) {
-          phase->igvn().rehash_node_delayed(u);
-          int nb = u->replace_edge(val, rep);
-          assert(nb > 0, "no update?");
-          --i, imax -= nb;
-        }
-      }
-    }
-  }
-}
-
-Node* ShenandoahWriteBarrierNode::find_bottom_mem(Node* ctrl, PhaseIdealLoop* phase) {
+Node* ShenandoahBarrierC2Support::find_bottom_mem(Node* ctrl, PhaseIdealLoop* phase) {
   Node* mem = NULL;
   Node* c = ctrl;
   do {
@@ -2355,7 +914,7 @@
   return mem;
 }
 
-void ShenandoahWriteBarrierNode::follow_barrier_uses(Node* n, Node* ctrl, Unique_Node_List& uses, PhaseIdealLoop* phase) {
+void ShenandoahBarrierC2Support::follow_barrier_uses(Node* n, Node* ctrl, Unique_Node_List& uses, PhaseIdealLoop* phase) {
   for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
     Node* u = n->fast_out(i);
     if (!u->is_CFG() && phase->get_ctrl(u) == ctrl && (!u->is_Phi() || !u->in(0)->is_Loop() || u->in(LoopNode::LoopBackControl) != n)) {
@@ -2375,7 +934,7 @@
   inner->clear_strip_mined();
 }
 
-void ShenandoahWriteBarrierNode::test_heap_stable(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl,
+void ShenandoahBarrierC2Support::test_heap_stable(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl,
                                                   PhaseIdealLoop* phase) {
   IdealLoopTree* loop = phase->get_loop(ctrl);
   Node* thread = new ThreadLocalNode();
@@ -2407,7 +966,7 @@
   assert(is_heap_stable_test(heap_stable_iff), "Should match the shape");
 }
 
-void ShenandoahWriteBarrierNode::test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase) {
+void ShenandoahBarrierC2Support::test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase) {
   const Type* val_t = phase->igvn().type(val);
   if (val_t->meet(TypePtr::NULL_PTR) == val_t) {
     IdealLoopTree* loop = phase->get_loop(ctrl);
@@ -2424,7 +983,7 @@
   }
 }
 
-Node* ShenandoahWriteBarrierNode::clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase) {
+Node* ShenandoahBarrierC2Support::clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase) {
   IdealLoopTree *loop = phase->get_loop(c);
   Node* iff = unc_ctrl->in(0);
   assert(iff->is_If(), "broken");
@@ -2445,7 +1004,7 @@
   return val;
 }
 
-void ShenandoahWriteBarrierNode::fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl,
+void ShenandoahBarrierC2Support::fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl,
                                                 Unique_Node_List& uses, PhaseIdealLoop* phase) {
   IfNode* iff = unc_ctrl->in(0)->as_If();
   Node* proj = iff->proj_out(0);
@@ -2494,7 +1053,7 @@
   assert(nb == 1, "only use expected");
 }
 
-void ShenandoahWriteBarrierNode::in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase) {
+void ShenandoahBarrierC2Support::in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase) {
   IdealLoopTree *loop = phase->get_loop(ctrl);
   Node* raw_rbtrue = new CastP2XNode(ctrl, val);
   phase->register_new_node(raw_rbtrue, ctrl);
@@ -2523,23 +1082,18 @@
   phase->register_control(ctrl, loop, in_cset_fast_test_iff);
 }
 
-void ShenandoahWriteBarrierNode::call_wb_stub(Node*& ctrl, Node*& val, Node*& result_mem,
-                                              Node* raw_mem, Node* wb_mem,
-                                              int alias,
-                                              PhaseIdealLoop* phase) {
+void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node*& result_mem, Node* raw_mem, PhaseIdealLoop* phase) {
   IdealLoopTree*loop = phase->get_loop(ctrl);
   const TypePtr* obj_type = phase->igvn().type(val)->is_oopptr()->cast_to_nonconst();
 
   // The slow path stub consumes and produces raw memory in addition
   // to the existing memory edges
   Node* base = find_bottom_mem(ctrl, phase);
-
   MergeMemNode* mm = MergeMemNode::make(base);
-  mm->set_memory_at(alias, wb_mem);
   mm->set_memory_at(Compile::AliasIdxRaw, raw_mem);
   phase->register_new_node(mm, ctrl);
 
-  Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_write_barrier_Type(), CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_barrier_JRT), "shenandoah_write_barrier", TypeRawPtr::BOTTOM);
+  Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_write_barrier_Type(), CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_JRT), "shenandoah_write_barrier", TypeRawPtr::BOTTOM);
   call->init_req(TypeFunc::Control, ctrl);
   call->init_req(TypeFunc::I_O, phase->C->top());
   call->init_req(TypeFunc::Memory, mm);
@@ -2557,7 +1111,7 @@
   phase->register_new_node(val, ctrl);
 }
 
-void ShenandoahWriteBarrierNode::fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase) {
+void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase) {
   Node* ctrl = phase->get_ctrl(barrier);
   Node* init_raw_mem = fixer.find_mem(ctrl, barrier);
 
@@ -2610,26 +1164,32 @@
   }
 }
 
-void ShenandoahWriteBarrierNode::pin_and_expand(PhaseIdealLoop* phase) {
-  Node_List enqueue_barriers;
-  if (ShenandoahStoreValEnqueueBarrier) {
-    Unique_Node_List wq;
-    wq.push(phase->C->root());
-    for (uint i = 0; i < wq.size(); i++) {
-      Node* n = wq.at(i);
-      if (n->Opcode() == Op_ShenandoahEnqueueBarrier) {
-        enqueue_barriers.push(n);
-      }
-      for (uint i = 0; i < n->req(); i++) {
-        Node* in = n->in(i);
-        if (in != NULL) {
-          wq.push(in);
-        }
-      }
+static Node* create_phis_on_call_return(Node* ctrl, Node* c, Node* n, Node* n_clone, const CallProjections& projs, PhaseIdealLoop* phase) {
+  Node* region = NULL;
+  while (c != ctrl) {
+    if (c->is_Region()) {
+      region = c;
+    }
+    c = phase->idom(c);
+  }
+  assert(region != NULL, "");
+  Node* phi = new PhiNode(region, n->bottom_type());
+  for (uint j = 1; j < region->req(); j++) {
+    Node* in = region->in(j);
+    if (phase->is_dominator(projs.fallthrough_catchproj, in)) {
+      phi->init_req(j, n);
+    } else if (phase->is_dominator(projs.catchall_catchproj, in)) {
+      phi->init_req(j, n_clone);
+    } else {
+      phi->init_req(j, create_phis_on_call_return(ctrl, in, n, n_clone, projs, phase));
     }
   }
+  phase->register_new_node(phi, region);
+  return phi;
+}
 
-  const bool trace = false;
+void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
+  ShenandoahBarrierSetC2State* state = ShenandoahBarrierSetC2::bsc2()->state();
 
   // Collect raw memory state at CFG points in the entire graph and
   // record it in memory_nodes. Optimize the raw memory graph in the
@@ -2637,34 +1197,9 @@
   // simpler.
   GrowableArray<MemoryGraphFixer*> memory_graph_fixers;
 
-  // Let's try to common write barriers again
-  optimize_before_expansion(phase, memory_graph_fixers, true);
-
   Unique_Node_List uses;
-  for (int i = 0; i < ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count(); i++) {
-    ShenandoahWriteBarrierNode* wb = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barrier(i);
-    Node* ctrl = phase->get_ctrl(wb);
-
-    Node* val = wb->in(ValueIn);
-    if (ctrl->is_Proj() && ctrl->in(0)->is_CallJava()) {
-      assert(is_dominator(phase->get_ctrl(val), ctrl->in(0)->in(0), val, ctrl->in(0), phase), "can't move");
-      phase->set_ctrl(wb, ctrl->in(0)->in(0));
-    } else if (ctrl->is_CallRuntime()) {
-      assert(is_dominator(phase->get_ctrl(val), ctrl->in(0), val, ctrl, phase), "can't move");
-      phase->set_ctrl(wb, ctrl->in(0));
-    }
-
-    assert(wb->Opcode() == Op_ShenandoahWriteBarrier, "only for write barriers");
-    // Look for a null check that dominates this barrier and move the
-    // barrier right after the null check to enable implicit null
-    // checks
-    wb->pin_and_expand_move_barrier(phase, memory_graph_fixers, uses);
-
-    wb->pin_and_expand_helper(phase);
-  }
-
-  for (uint i = 0; i < enqueue_barriers.size(); i++) {
-    Node* barrier = enqueue_barriers.at(i);
+  for (int i = 0; i < state->enqueue_barriers_count(); i++) {
+    Node* barrier = state->enqueue_barrier(i);
     Node* ctrl = phase->get_ctrl(barrier);
     IdealLoopTree* loop = phase->get_loop(ctrl);
     if (loop->_head->is_OuterStripMinedLoop()) {
@@ -2676,24 +1211,386 @@
     }
   }
 
-  for (int i = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count(); i > 0; i--) {
-    int cnt = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count();
-    ShenandoahWriteBarrierNode* wb = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barrier(i-1);
-    Node* ctrl = phase->get_ctrl(wb);
-    IdealLoopTree* loop = phase->get_loop(ctrl);
-    if (loop->_head->is_OuterStripMinedLoop()) {
-      // Expanding a barrier here will break loop strip mining
-      // verification. Transform the loop so the loop nest doesn't
-      // appear as strip mined.
-      OuterStripMinedLoopNode* outer = loop->_head->as_OuterStripMinedLoop();
-      hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
+  Node_Stack stack(0);
+  Node_List clones;
+  for (int i = state->load_reference_barriers_count() - 1; i >= 0; i--) {
+    ShenandoahLoadReferenceBarrierNode* lrb = state->load_reference_barrier(i);
+    if (lrb->get_barrier_strength() == ShenandoahLoadReferenceBarrierNode::NONE) {
+      continue;
+    }
+
+    Node* ctrl = phase->get_ctrl(lrb);
+    Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn);
+
+    CallStaticJavaNode* unc = NULL;
+    Node* unc_ctrl = NULL;
+    Node* uncasted_val = val;
+
+    for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) {
+      Node* u = lrb->fast_out(i);
+      if (u->Opcode() == Op_CastPP &&
+          u->in(0) != NULL &&
+          phase->is_dominator(u->in(0), ctrl)) {
+        const Type* u_t = phase->igvn().type(u);
+
+        if (u_t->meet(TypePtr::NULL_PTR) != u_t &&
+            u->in(0)->Opcode() == Op_IfTrue &&
+            u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) &&
+            u->in(0)->in(0)->is_If() &&
+            u->in(0)->in(0)->in(1)->Opcode() == Op_Bool &&
+            u->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne &&
+            u->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
+            u->in(0)->in(0)->in(1)->in(1)->in(1) == val &&
+            u->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) {
+          IdealLoopTree* loop = phase->get_loop(ctrl);
+          IdealLoopTree* unc_loop = phase->get_loop(u->in(0));
+
+          if (!unc_loop->is_member(loop)) {
+            continue;
+          }
+
+          Node* branch = no_branches(ctrl, u->in(0), false, phase);
+          assert(branch == NULL || branch == NodeSentinel, "was not looking for a branch");
+          if (branch == NodeSentinel) {
+            continue;
+          }
+
+          phase->igvn().replace_input_of(u, 1, val);
+          phase->igvn().replace_input_of(lrb, ShenandoahLoadReferenceBarrierNode::ValueIn, u);
+          phase->set_ctrl(u, u->in(0));
+          phase->set_ctrl(lrb, u->in(0));
+          unc = u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
+          unc_ctrl = u->in(0);
+          val = u;
+
+          for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) {
+            Node* u = val->fast_out(j);
+            if (u == lrb) continue;
+            phase->igvn().rehash_node_delayed(u);
+            int nb = u->replace_edge(val, lrb);
+            --j; jmax -= nb;
+          }
+
+          RegionNode* r = new RegionNode(3);
+          IfNode* iff = unc_ctrl->in(0)->as_If();
+
+          Node* ctrl_use = unc_ctrl->unique_ctrl_out();
+          Node* unc_ctrl_clone = unc_ctrl->clone();
+          phase->register_control(unc_ctrl_clone, loop, iff);
+          Node* c = unc_ctrl_clone;
+          Node* new_cast = clone_null_check(c, val, unc_ctrl_clone, phase);
+          r->init_req(1, new_cast->in(0)->in(0)->as_If()->proj_out(0));
+
+          phase->igvn().replace_input_of(unc_ctrl, 0, c->in(0));
+          phase->set_idom(unc_ctrl, c->in(0), phase->dom_depth(unc_ctrl));
+          phase->lazy_replace(c, unc_ctrl);
+          c = NULL;;
+          phase->igvn().replace_input_of(val, 0, unc_ctrl_clone);
+          phase->set_ctrl(val, unc_ctrl_clone);
+
+          IfNode* new_iff = new_cast->in(0)->in(0)->as_If();
+          fix_null_check(unc, unc_ctrl_clone, r, uses, phase);
+          Node* iff_proj = iff->proj_out(0);
+          r->init_req(2, iff_proj);
+          phase->register_control(r, phase->ltree_root(), iff);
+
+          Node* new_bol = new_iff->in(1)->clone();
+          Node* new_cmp = new_bol->in(1)->clone();
+          assert(new_cmp->Opcode() == Op_CmpP, "broken");
+          assert(new_cmp->in(1) == val->in(1), "broken");
+          new_bol->set_req(1, new_cmp);
+          new_cmp->set_req(1, lrb);
+          phase->register_new_node(new_bol, new_iff->in(0));
+          phase->register_new_node(new_cmp, new_iff->in(0));
+          phase->igvn().replace_input_of(new_iff, 1, new_bol);
+          phase->igvn().replace_input_of(new_cast, 1, lrb);
+
+          for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) {
+            Node* u = lrb->fast_out(i);
+            if (u == new_cast || u == new_cmp) {
+              continue;
+            }
+            phase->igvn().rehash_node_delayed(u);
+            int nb = u->replace_edge(lrb, new_cast);
+            assert(nb > 0, "no update?");
+            --i; imax -= nb;
+          }
+
+          for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
+            Node* u = val->fast_out(i);
+            if (u == lrb) {
+              continue;
+            }
+            phase->igvn().rehash_node_delayed(u);
+            int nb = u->replace_edge(val, new_cast);
+            assert(nb > 0, "no update?");
+            --i; imax -= nb;
+          }
+
+          ctrl = unc_ctrl_clone;
+          phase->set_ctrl_and_loop(lrb, ctrl);
+          break;
+        }
+      }
+    }
+    if (ctrl->is_Proj() && ctrl->in(0)->is_CallJava()) {
+      CallNode* call = ctrl->in(0)->as_CallJava();
+      CallProjections projs;
+      call->extract_projections(&projs, false, false);
+
+      Node* lrb_clone = lrb->clone();
+      phase->register_new_node(lrb_clone, projs.catchall_catchproj);
+      phase->set_ctrl(lrb, projs.fallthrough_catchproj);
+
+      stack.push(lrb, 0);
+      clones.push(lrb_clone);
+
+      do {
+        assert(stack.size() == clones.size(), "");
+        Node* n = stack.node();
+#ifdef ASSERT
+        if (n->is_Load()) {
+          Node* mem = n->in(MemNode::Memory);
+          for (DUIterator_Fast jmax, j = mem->fast_outs(jmax); j < jmax; j++) {
+            Node* u = mem->fast_out(j);
+            assert(!u->is_Store() || !u->is_LoadStore() || phase->get_ctrl(u) != ctrl, "anti dependent store?");
+          }
+        }
+#endif
+        uint idx = stack.index();
+        Node* n_clone = clones.at(clones.size()-1);
+        if (idx < n->outcnt()) {
+          Node* u = n->raw_out(idx);
+          Node* c = phase->ctrl_or_self(u);
+          if (c == ctrl) {
+            stack.set_index(idx+1);
+            assert(!u->is_CFG(), "");
+            stack.push(u, 0);
+            Node* u_clone = u->clone();
+            int nb = u_clone->replace_edge(n, n_clone);
+            assert(nb > 0, "should have replaced some uses");
+            phase->register_new_node(u_clone, projs.catchall_catchproj);
+            clones.push(u_clone);
+            phase->set_ctrl(u, projs.fallthrough_catchproj);
+          } else {
+            bool replaced = false;
+            if (u->is_Phi()) {
+              for (uint k = 1; k < u->req(); k++) {
+                if (u->in(k) == n) {
+                  if (phase->is_dominator(projs.catchall_catchproj, u->in(0)->in(k))) {
+                    phase->igvn().replace_input_of(u, k, n_clone);
+                    replaced = true;
+                  } else if (!phase->is_dominator(projs.fallthrough_catchproj, u->in(0)->in(k))) {
+                    phase->igvn().replace_input_of(u, k, create_phis_on_call_return(ctrl, u->in(0)->in(k), n, n_clone, projs, phase));
+                    replaced = true;
+                  }
+                }
+              }
+            } else {
+              if (phase->is_dominator(projs.catchall_catchproj, c)) {
+                phase->igvn().rehash_node_delayed(u);
+                int nb = u->replace_edge(n, n_clone);
+                assert(nb > 0, "should have replaced some uses");
+                replaced = true;
+              } else if (!phase->is_dominator(projs.fallthrough_catchproj, c)) {
+                phase->igvn().rehash_node_delayed(u);
+                int nb = u->replace_edge(n, create_phis_on_call_return(ctrl, c, n, n_clone, projs, phase));
+                assert(nb > 0, "should have replaced some uses");
+                replaced = true;
+              }
+            }
+            if (!replaced) {
+              stack.set_index(idx+1);
+            }
+          }
+        } else {
+          // assert(n_clone->outcnt() > 0, "");
+          // assert(n->outcnt() > 0, "");
+          stack.pop();
+          clones.pop();
+        }
+      } while (stack.size() > 0);
+      assert(stack.size() == 0 && clones.size() == 0, "");
+      ctrl = projs.fallthrough_catchproj;
     }
   }
 
+  // Expand load-reference-barriers
   MemoryGraphFixer fixer(Compile::AliasIdxRaw, true, phase);
   Unique_Node_List uses_to_ignore;
-  for (uint i = 0; i < enqueue_barriers.size(); i++) {
-    Node* barrier = enqueue_barriers.at(i);
+  for (int i = state->load_reference_barriers_count() - 1; i >= 0; i--) {
+    ShenandoahLoadReferenceBarrierNode* lrb = state->load_reference_barrier(i);
+    if (lrb->get_barrier_strength() == ShenandoahLoadReferenceBarrierNode::NONE) {
+      phase->igvn().replace_node(lrb, lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn));
+      continue;
+    }
+    uint last = phase->C->unique();
+    Node* ctrl = phase->get_ctrl(lrb);
+    Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn);
+
+
+    Node* orig_ctrl = ctrl;
+
+    Node* raw_mem = fixer.find_mem(ctrl, lrb);
+    Node* init_raw_mem = raw_mem;
+    Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL);
+    // int alias = phase->C->get_alias_index(lrb->adr_type());
+
+    IdealLoopTree *loop = phase->get_loop(ctrl);
+    CallStaticJavaNode* unc = lrb->pin_and_expand_null_check(phase->igvn());
+    Node* unc_ctrl = NULL;
+    if (unc != NULL) {
+      if (val->in(ShenandoahLoadReferenceBarrierNode::Control) != ctrl) {
+        unc = NULL;
+      } else {
+        unc_ctrl = val->in(ShenandoahLoadReferenceBarrierNode::Control);
+      }
+    }
+
+    Node* uncasted_val = val;
+    if (unc != NULL) {
+      uncasted_val = val->in(1);
+    }
+
+    Node* heap_stable_ctrl = NULL;
+    Node* null_ctrl = NULL;
+
+    assert(val->bottom_type()->make_oopptr(), "need oop");
+    assert(val->bottom_type()->make_oopptr()->const_oop() == NULL, "expect non-constant");
+
+    enum { _heap_stable = 1, _not_cset, _not_equal, _evac_path, _null_path, PATH_LIMIT };
+    Node* region = new RegionNode(PATH_LIMIT);
+    Node* val_phi = new PhiNode(region, uncasted_val->bottom_type()->is_oopptr());
+    Node* raw_mem_phi = PhiNode::make(region, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM);
+
+    // Stable path.
+    test_heap_stable(ctrl, raw_mem, heap_stable_ctrl, phase);
+    IfNode* heap_stable_iff = heap_stable_ctrl->in(0)->as_If();
+
+    // Heap stable case
+    region->init_req(_heap_stable, heap_stable_ctrl);
+    val_phi->init_req(_heap_stable, uncasted_val);
+    raw_mem_phi->init_req(_heap_stable, raw_mem);
+
+    Node* reg2_ctrl = NULL;
+    // Null case
+    test_null(ctrl, val, null_ctrl, phase);
+    if (null_ctrl != NULL) {
+      reg2_ctrl = null_ctrl->in(0);
+      region->init_req(_null_path, null_ctrl);
+      val_phi->init_req(_null_path, uncasted_val);
+      raw_mem_phi->init_req(_null_path, raw_mem);
+    } else {
+      region->del_req(_null_path);
+      val_phi->del_req(_null_path);
+      raw_mem_phi->del_req(_null_path);
+    }
+
+    // Test for in-cset.
+    // Wires !in_cset(obj) to slot 2 of region and phis
+    Node* not_cset_ctrl = NULL;
+    in_cset_fast_test(ctrl, not_cset_ctrl, uncasted_val, raw_mem, phase);
+    if (not_cset_ctrl != NULL) {
+      if (reg2_ctrl == NULL) reg2_ctrl = not_cset_ctrl->in(0);
+      region->init_req(_not_cset, not_cset_ctrl);
+      val_phi->init_req(_not_cset, uncasted_val);
+      raw_mem_phi->init_req(_not_cset, raw_mem);
+    }
+
+    // Resolve object when orig-value is in cset.
+    // Make the unconditional resolve for fwdptr.
+    Node* new_val = uncasted_val;
+    if (unc_ctrl != NULL) {
+      // Clone the null check in this branch to allow implicit null check
+      new_val = clone_null_check(ctrl, val, unc_ctrl, phase);
+      fix_null_check(unc, unc_ctrl, ctrl->in(0)->as_If()->proj_out(0), uses, phase);
+
+      IfNode* iff = unc_ctrl->in(0)->as_If();
+      phase->igvn().replace_input_of(iff, 1, phase->igvn().intcon(1));
+    }
+    Node* addr = new AddPNode(new_val, uncasted_val, phase->igvn().MakeConX(ShenandoahBrooksPointer::byte_offset()));
+    phase->register_new_node(addr, ctrl);
+    assert(val->bottom_type()->isa_oopptr(), "what else?");
+    const TypePtr* obj_type =  val->bottom_type()->is_oopptr();
+    const TypePtr* adr_type = TypeRawPtr::BOTTOM;
+    Node* fwd = new LoadPNode(ctrl, raw_mem, addr, adr_type, obj_type, MemNode::unordered);
+    phase->register_new_node(fwd, ctrl);
+
+    // Only branch to LRB stub if object is not forwarded; otherwise reply with fwd ptr
+    Node* cmp = new CmpPNode(fwd, new_val);
+    phase->register_new_node(cmp, ctrl);
+    Node* bol = new BoolNode(cmp, BoolTest::eq);
+    phase->register_new_node(bol, ctrl);
+
+    IfNode* iff = new IfNode(ctrl, bol, PROB_UNLIKELY(0.999), COUNT_UNKNOWN);
+    if (reg2_ctrl == NULL) reg2_ctrl = iff;
+    phase->register_control(iff, loop, ctrl);
+    Node* if_not_eq = new IfFalseNode(iff);
+    phase->register_control(if_not_eq, loop, iff);
+    Node* if_eq = new IfTrueNode(iff);
+    phase->register_control(if_eq, loop, iff);
+
+    // Wire up not-equal-path in slots 3.
+    region->init_req(_not_equal, if_not_eq);
+    val_phi->init_req(_not_equal, fwd);
+    raw_mem_phi->init_req(_not_equal, raw_mem);
+
+    // Call wb-stub and wire up that path in slots 4
+    Node* result_mem = NULL;
+    ctrl = if_eq;
+    call_lrb_stub(ctrl, fwd, result_mem, raw_mem, phase);
+    region->init_req(_evac_path, ctrl);
+    val_phi->init_req(_evac_path, fwd);
+    raw_mem_phi->init_req(_evac_path, result_mem);
+
+    phase->register_control(region, loop, heap_stable_iff);
+    Node* out_val = val_phi;
+    phase->register_new_node(val_phi, region);
+    phase->register_new_node(raw_mem_phi, region);
+
+    fix_ctrl(lrb, region, fixer, uses, uses_to_ignore, last, phase);
+
+    ctrl = orig_ctrl;
+
+    if (unc != NULL) {
+      for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
+        Node* u = val->fast_out(i);
+        Node* c = phase->ctrl_or_self(u);
+        if (u != lrb && (c != ctrl || is_dominator_same_ctrl(c, lrb, u, phase))) {
+          phase->igvn().rehash_node_delayed(u);
+          int nb = u->replace_edge(val, out_val);
+          --i, imax -= nb;
+        }
+      }
+      if (val->outcnt() == 0) {
+        phase->igvn()._worklist.push(val);
+      }
+    }
+    phase->igvn().replace_node(lrb, out_val);
+
+    follow_barrier_uses(out_val, ctrl, uses, phase);
+
+    for(uint next = 0; next < uses.size(); next++ ) {
+      Node *n = uses.at(next);
+      assert(phase->get_ctrl(n) == ctrl, "bad control");
+      assert(n != init_raw_mem, "should leave input raw mem above the barrier");
+      phase->set_ctrl(n, region);
+      follow_barrier_uses(n, ctrl, uses, phase);
+    }
+
+    // The slow path call produces memory: hook the raw memory phi
+    // from the expanded load reference barrier with the rest of the graph
+    // which may require adding memory phis at every post dominated
+    // region and at enclosing loop heads. Use the memory state
+    // collected in memory_nodes to fix the memory graph. Update that
+    // memory state as we go.
+    fixer.fix_mem(ctrl, region, init_raw_mem, raw_mem_for_ctrl, raw_mem_phi, uses);
+  }
+  // Done expanding load-reference-barriers.
+  assert(ShenandoahBarrierSetC2::bsc2()->state()->load_reference_barriers_count() == 0, "all load reference barrier nodes should have been replaced");
+
+  for (int i = state->enqueue_barriers_count() - 1; i >= 0; i--) {
+    Node* barrier = state->enqueue_barrier(i);
     Node* pre_val = barrier->in(1);
 
     if (phase->igvn().type(pre_val)->higher_equal(TypePtr::NULL_PTR)) {
@@ -2840,212 +1737,11 @@
 
     phase->igvn().replace_node(barrier, pre_val);
   }
-
-  for (int i = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count(); i > 0; i--) {
-    int cnt = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count();
-    ShenandoahWriteBarrierNode* wb = ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barrier(i-1);
-
-    uint last = phase->C->unique();
-    Node* ctrl = phase->get_ctrl(wb);
-    Node* orig_ctrl = ctrl;
-
-    Node* raw_mem = fixer.find_mem(ctrl, wb);
-    Node* init_raw_mem = raw_mem;
-    Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL);
-    int alias = phase->C->get_alias_index(wb->adr_type());
-    Node* wb_mem =  wb->in(Memory);
-    Node* init_wb_mem = wb_mem;
-
-    Node* val = wb->in(ValueIn);
-    Node* wbproj = wb->find_out_with(Op_ShenandoahWBMemProj);
-    IdealLoopTree *loop = phase->get_loop(ctrl);
-
-    assert(val->Opcode() != Op_ShenandoahWriteBarrier, "No chain of write barriers");
-
-    CallStaticJavaNode* unc = wb->pin_and_expand_null_check(phase->igvn());
-    Node* unc_ctrl = NULL;
-    if (unc != NULL) {
-      if (val->in(0) != ctrl) {
-        unc = NULL;
-      } else {
-        unc_ctrl = val->in(0);
-      }
-    }
-
-    Node* uncasted_val = val;
-    if (unc != NULL) {
-      uncasted_val = val->in(1);
-    }
-
-    Node* heap_stable_ctrl = NULL;
-    Node* null_ctrl = NULL;
-
-    assert(val->bottom_type()->make_oopptr(), "need oop");
-    assert(val->bottom_type()->make_oopptr()->const_oop() == NULL, "expect non-constant");
-
-    enum { _heap_stable = 1, _heap_unstable, PATH_LIMIT };
-    Node* region = new RegionNode(PATH_LIMIT);
-    Node* val_phi = new PhiNode(region, uncasted_val->bottom_type()->is_oopptr());
-    Node* mem_phi = PhiNode::make(region, wb_mem, Type::MEMORY, phase->C->alias_type(wb->adr_type())->adr_type());
-    Node* raw_mem_phi = PhiNode::make(region, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM);
-
-    enum { _not_cset = 1, _not_equal, _evac_path, _null_path, PATH_LIMIT2 };
-    Node* region2 = new RegionNode(PATH_LIMIT2);
-    Node* val_phi2 = new PhiNode(region2, uncasted_val->bottom_type()->is_oopptr());
-    Node* mem_phi2 = PhiNode::make(region2, wb_mem, Type::MEMORY, phase->C->alias_type(wb->adr_type())->adr_type());
-    Node* raw_mem_phi2 = PhiNode::make(region2, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM);
-
-      // Stable path.
-    test_heap_stable(ctrl, raw_mem, heap_stable_ctrl, phase);
-    IfNode* heap_stable_iff = heap_stable_ctrl->in(0)->as_If();
-
-    // Heap stable case
-    region->init_req(_heap_stable, heap_stable_ctrl);
-    val_phi->init_req(_heap_stable, uncasted_val);
-    mem_phi->init_req(_heap_stable, wb_mem);
-    raw_mem_phi->init_req(_heap_stable, raw_mem);
-
-    Node* reg2_ctrl = NULL;
-    // Null case
-    test_null(ctrl, val, null_ctrl, phase);
-    if (null_ctrl != NULL) {
-      reg2_ctrl = null_ctrl->in(0);
-      region2->init_req(_null_path, null_ctrl);
-      val_phi2->init_req(_null_path, uncasted_val);
-      mem_phi2->init_req(_null_path, wb_mem);
-      raw_mem_phi2->init_req(_null_path, raw_mem);
-    } else {
-      region2->del_req(_null_path);
-      val_phi2->del_req(_null_path);
-      mem_phi2->del_req(_null_path);
-      raw_mem_phi2->del_req(_null_path);
-    }
-
-    // Test for in-cset.
-    // Wires !in_cset(obj) to slot 2 of region and phis
-    Node* not_cset_ctrl = NULL;
-    in_cset_fast_test(ctrl, not_cset_ctrl, uncasted_val, raw_mem, phase);
-    if (not_cset_ctrl != NULL) {
-      if (reg2_ctrl == NULL) reg2_ctrl = not_cset_ctrl->in(0);
-      region2->init_req(_not_cset, not_cset_ctrl);
-      val_phi2->init_req(_not_cset, uncasted_val);
-      mem_phi2->init_req(_not_cset, wb_mem);
-      raw_mem_phi2->init_req(_not_cset, raw_mem);
-    }
-
-    // Resolve object when orig-value is in cset.
-    // Make the unconditional resolve for fwdptr, not the read barrier.
-    Node* new_val = uncasted_val;
-    if (unc_ctrl != NULL) {
-      // Clone the null check in this branch to allow implicit null check
-      new_val = clone_null_check(ctrl, val, unc_ctrl, phase);
-      fix_null_check(unc, unc_ctrl, ctrl->in(0)->as_If()->proj_out(0), uses, phase);
+  assert(state->enqueue_barriers_count() == 0, "all enqueue barrier nodes should have been replaced");
 
-      IfNode* iff = unc_ctrl->in(0)->as_If();
-      phase->igvn().replace_input_of(iff, 1, phase->igvn().intcon(1));
-    }
-    Node* addr = new AddPNode(new_val, uncasted_val, phase->igvn().MakeConX(ShenandoahBrooksPointer::byte_offset()));
-    phase->register_new_node(addr, ctrl);
-    assert(val->bottom_type()->isa_oopptr(), "what else?");
-    const TypePtr* obj_type =  val->bottom_type()->is_oopptr();
-    const TypePtr* adr_type = ShenandoahBarrierNode::brooks_pointer_type(obj_type);
-    Node* fwd = new LoadPNode(ctrl, wb_mem, addr, adr_type, obj_type, MemNode::unordered);
-    phase->register_new_node(fwd, ctrl);
-
-    // Only branch to WB stub if object is not forwarded; otherwise reply with fwd ptr
-    Node* cmp = new CmpPNode(fwd, new_val);
-    phase->register_new_node(cmp, ctrl);
-    Node* bol = new BoolNode(cmp, BoolTest::eq);
-    phase->register_new_node(bol, ctrl);
-
-    IfNode* iff = new IfNode(ctrl, bol, PROB_UNLIKELY(0.999), COUNT_UNKNOWN);
-    if (reg2_ctrl == NULL) reg2_ctrl = iff;
-    phase->register_control(iff, loop, ctrl);
-    Node* if_not_eq = new IfFalseNode(iff);
-    phase->register_control(if_not_eq, loop, iff);
-    Node* if_eq = new IfTrueNode(iff);
-    phase->register_control(if_eq, loop, iff);
-
-    // Wire up not-equal-path in slots 3.
-    region2->init_req(_not_equal, if_not_eq);
-    val_phi2->init_req(_not_equal, fwd);
-    mem_phi2->init_req(_not_equal, wb_mem);
-    raw_mem_phi2->init_req(_not_equal, raw_mem);
-
-    // Call wb-stub and wire up that path in slots 4
-    Node* result_mem = NULL;
-    ctrl = if_eq;
-    call_wb_stub(ctrl, new_val, result_mem,
-                 raw_mem, wb_mem,
-                 alias, phase);
-    region2->init_req(_evac_path, ctrl);
-    val_phi2->init_req(_evac_path, new_val);
-    mem_phi2->init_req(_evac_path, result_mem);
-    raw_mem_phi2->init_req(_evac_path, result_mem);
-
-    phase->register_control(region2, loop, reg2_ctrl);
-    phase->register_new_node(val_phi2, region2);
-    phase->register_new_node(mem_phi2, region2);
-    phase->register_new_node(raw_mem_phi2, region2);
-
-    region->init_req(_heap_unstable, region2);
-    val_phi->init_req(_heap_unstable, val_phi2);
-    mem_phi->init_req(_heap_unstable, mem_phi2);
-    raw_mem_phi->init_req(_heap_unstable, raw_mem_phi2);
-
-    phase->register_control(region, loop, heap_stable_iff);
-    Node* out_val = val_phi;
-    phase->register_new_node(val_phi, region);
-    phase->register_new_node(mem_phi, region);
-    phase->register_new_node(raw_mem_phi, region);
-
-    fix_ctrl(wb, region, fixer, uses, uses_to_ignore, last, phase);
-
-    ctrl = orig_ctrl;
-
-    phase->igvn().replace_input_of(wbproj, ShenandoahWBMemProjNode::WriteBarrier, phase->C->top());
-    phase->igvn().replace_node(wbproj, mem_phi);
-    if (unc != NULL) {
-      for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
-        Node* u = val->fast_out(i);
-        Node* c = phase->ctrl_or_self(u);
-        if (u != wb && (c != ctrl || is_dominator_same_ctrl(c, wb, u, phase))) {
-          phase->igvn().rehash_node_delayed(u);
-          int nb = u->replace_edge(val, out_val);
-          --i, imax -= nb;
-        }
-      }
-      if (val->outcnt() == 0) {
-        phase->igvn()._worklist.push(val);
-      }
-    }
-    phase->igvn().replace_node(wb, out_val);
-
-    follow_barrier_uses(mem_phi, ctrl, uses, phase);
-    follow_barrier_uses(out_val, ctrl, uses, phase);
-
-    for(uint next = 0; next < uses.size(); next++ ) {
-      Node *n = uses.at(next);
-      assert(phase->get_ctrl(n) == ctrl, "bad control");
-      assert(n != init_raw_mem, "should leave input raw mem above the barrier");
-      phase->set_ctrl(n, region);
-      follow_barrier_uses(n, ctrl, uses, phase);
-    }
-
-    // The slow path call produces memory: hook the raw memory phi
-    // from the expanded write barrier with the rest of the graph
-    // which may require adding memory phis at every post dominated
-    // region and at enclosing loop heads. Use the memory state
-    // collected in memory_nodes to fix the memory graph. Update that
-    // memory state as we go.
-    fixer.fix_mem(ctrl, region, init_raw_mem, raw_mem_for_ctrl, raw_mem_phi, uses);
-    assert(ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count() == cnt - 1, "not replaced");
-  }
-
-  assert(ShenandoahBarrierSetC2::bsc2()->state()->shenandoah_barriers_count() == 0, "all write barrier nodes should have been replaced");
 }
 
-void ShenandoahWriteBarrierNode::move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase) {
+void ShenandoahBarrierC2Support::move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase) {
   IdealLoopTree *loop = phase->get_loop(iff);
   Node* loop_head = loop->_head;
   Node* entry_c = loop_head->in(LoopNode::EntryControl);
@@ -3078,7 +1774,7 @@
   }
 }
 
-bool ShenandoahWriteBarrierNode::identical_backtoback_ifs(Node *n, PhaseIdealLoop* phase) {
+bool ShenandoahBarrierC2Support::identical_backtoback_ifs(Node* n, PhaseIdealLoop* phase) {
   if (!n->is_If() || n->is_CountedLoopEnd()) {
     return false;
   }
@@ -3113,7 +1809,7 @@
   return true;
 }
 
-void ShenandoahWriteBarrierNode::merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase) {
+void ShenandoahBarrierC2Support::merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase) {
   assert(is_heap_stable_test(n), "no other tests");
   if (identical_backtoback_ifs(n, phase)) {
     Node* n_ctrl = n->in(0);
@@ -3149,7 +1845,7 @@
   }
 }
 
-IfNode* ShenandoahWriteBarrierNode::find_unswitching_candidate(const IdealLoopTree *loop, PhaseIdealLoop* phase) {
+IfNode* ShenandoahBarrierC2Support::find_unswitching_candidate(const IdealLoopTree* loop, PhaseIdealLoop* phase) {
   // Find first invariant test that doesn't exit the loop
   LoopNode *head = loop->_head->as_Loop();
   IfNode* unswitch_iff = NULL;
@@ -3194,10 +1890,9 @@
 }
 
 
-void ShenandoahWriteBarrierNode::optimize_after_expansion(VectorSet &visited, Node_Stack &stack, Node_List &old_new, PhaseIdealLoop* phase) {
+void ShenandoahBarrierC2Support::optimize_after_expansion(VectorSet &visited, Node_Stack &stack, Node_List &old_new, PhaseIdealLoop* phase) {
   Node_List heap_stable_tests;
   Node_List gc_state_loads;
-
   stack.push(phase->C->start(), 0);
   do {
     Node* n = stack.node();
@@ -3274,7 +1969,7 @@
 }
 
 #ifdef ASSERT
-void ShenandoahBarrierNode::verify_raw_mem(RootNode* root) {
+void ShenandoahBarrierC2Support::verify_raw_mem(RootNode* root) {
   const bool trace = false;
   ResourceMark rm;
   Unique_Node_List nodes;
@@ -3372,6 +2067,10 @@
 }
 #endif
 
+ShenandoahEnqueueBarrierNode::ShenandoahEnqueueBarrierNode(Node* val) : Node(NULL, val) {
+  ShenandoahBarrierSetC2::bsc2()->state()->add_enqueue_barrier(this);
+}
+
 const Type* ShenandoahEnqueueBarrierNode::bottom_type() const {
   if (in(1) == NULL || in(1)->is_top()) {
     return Type::TOP;
@@ -3400,6 +2099,7 @@
 int ShenandoahEnqueueBarrierNode::needed(Node* n) {
   if (n == NULL ||
       n->is_Allocate() ||
+      n->Opcode() == Op_ShenandoahEnqueueBarrier ||
       n->bottom_type() == TypePtr::NULL_PTR ||
       (n->bottom_type()->make_oopptr() != NULL && n->bottom_type()->make_oopptr()->const_oop() != NULL)) {
     return NotNeeded;
@@ -3530,6 +2230,26 @@
               Node* call = in->in(0)->in(0);
               assert(call->is_Call(), "");
               mem = call->in(TypeFunc::Memory);
+            } else if (in->Opcode() == Op_NeverBranch) {
+              ResourceMark rm;
+              Unique_Node_List wq;
+              wq.push(in);
+              wq.push(in->as_Multi()->proj_out(0));
+              for (uint j = 1; j < wq.size(); j++) {
+                Node* c = wq.at(j);
+                assert(!c->is_Root(), "shouldn't leave loop");
+                if (c->is_SafePoint()) {
+                  assert(mem == NULL, "only one safepoint");
+                  mem = c->in(TypeFunc::Memory);
+                }
+                for (DUIterator_Fast kmax, k = c->fast_outs(kmax); k < kmax; k++) {
+                  Node* u = c->fast_out(k);
+                  if (u->is_CFG()) {
+                    wq.push(u);
+                  }
+                }
+              }
+              assert(mem != NULL, "should have found safepoint");
             }
           }
         } else {
@@ -3568,12 +2288,6 @@
           assert(_alias == Compile::AliasIdxRaw, "");
           stack.push(mem, mem->req());
           mem = mem->in(MemNode::Memory);
-        } else if (mem->Opcode() == Op_ShenandoahWriteBarrier) {
-          assert(_alias != Compile::AliasIdxRaw, "");
-          mem = mem->in(ShenandoahBarrierNode::Memory);
-        } else if (mem->Opcode() == Op_ShenandoahWBMemProj) {
-          stack.push(mem, mem->req());
-          mem = mem->in(ShenandoahWBMemProjNode::WriteBarrier);
         } else {
 #ifdef ASSERT
           mem->dump();
@@ -3627,7 +2341,7 @@
   while (progress) {
     progress = false;
     iteration++;
-    assert(iteration <= 2+max_depth || _phase->C->has_irreducible_loop(), "");
+    assert(iteration <= 2+max_depth || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root()), "");
     if (trace) { tty->print_cr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); }
     IdealLoopTree* last_updated_ilt = NULL;
     for (int i = rpo_list.size() - 1; i >= 0; i--) {
@@ -3795,7 +2509,7 @@
     mem = _memory_nodes[c->_idx];
   }
   if (n != NULL && mem_is_valid(mem, c)) {
-    while (!ShenandoahWriteBarrierNode::is_dominator_same_ctrl(c, mem, n, _phase) && _phase->ctrl_or_self(mem) == ctrl) {
+    while (!ShenandoahBarrierC2Support::is_dominator_same_ctrl(c, mem, n, _phase) && _phase->ctrl_or_self(mem) == ctrl) {
       mem = next_mem(mem, _alias);
     }
     if (mem->is_MergeMem()) {
@@ -3841,12 +2555,6 @@
       } else if (old->Opcode() == Op_SCMemProj) {
         assert(_alias == Compile::AliasIdxRaw, "");
         old = old->in(0);
-      } else if (old->Opcode() == Op_ShenandoahWBMemProj) {
-        assert(_alias != Compile::AliasIdxRaw, "");
-        old = old->in(ShenandoahWBMemProjNode::WriteBarrier);
-      } else if (old->Opcode() == Op_ShenandoahWriteBarrier) {
-        assert(_alias != Compile::AliasIdxRaw, "");
-        old = old->in(ShenandoahBarrierNode::Memory);
       } else {
         ShouldNotReachHere();
       }
@@ -3856,7 +2564,7 @@
       _memory_nodes.map(ctrl->_idx, mem);
       _memory_nodes.map(new_ctrl->_idx, mem_for_ctrl);
     }
-    uint input = prev->Opcode() == Op_ShenandoahWriteBarrier ? (uint)ShenandoahBarrierNode::Memory : (uint)MemNode::Memory;
+    uint input = (uint)MemNode::Memory;
     _phase->igvn().replace_input_of(prev, input, new_mem);
   } else {
     uses.clear();
@@ -3924,19 +2632,14 @@
                 } else {
                   DEBUG_ONLY(if (trace) { tty->print("ZZZ NOT setting mem"); m->dump(); });
                   for (;;) {
-                    assert(m->is_Mem() || m->is_LoadStore() || m->is_Proj() || m->Opcode() == Op_ShenandoahWriteBarrier || m->Opcode() == Op_ShenandoahWBMemProj, "");
+                    assert(m->is_Mem() || m->is_LoadStore() || m->is_Proj(), "");
                     Node* next = NULL;
                     if (m->is_Proj()) {
                       next = m->in(0);
-                    } else if (m->Opcode() == Op_ShenandoahWBMemProj) {
-                      next = m->in(ShenandoahWBMemProjNode::WriteBarrier);
-                    } else if (m->is_Mem() || m->is_LoadStore()) {
+                    } else {
+                      assert(m->is_Mem() || m->is_LoadStore(), "");
                       assert(_alias == Compile::AliasIdxRaw, "");
                       next = m->in(MemNode::Memory);
-                    } else {
-                      assert(_alias != Compile::AliasIdxRaw, "");
-                      assert (m->Opcode() == Op_ShenandoahWriteBarrier, "");
-                      next = m->in(ShenandoahBarrierNode::Memory);
                     }
                     if (_phase->get_ctrl(next) != u) {
                       break;
@@ -3953,8 +2656,8 @@
                   }
 
                   DEBUG_ONLY(if (trace) { tty->print("ZZZ setting to phi"); m->dump(); });
-                  assert(m->is_Mem() || m->is_LoadStore() || m->Opcode() == Op_ShenandoahWriteBarrier, "");
-                  uint input = (m->is_Mem() || m->is_LoadStore()) ? (uint)MemNode::Memory : (uint)ShenandoahBarrierNode::Memory;
+                  assert(m->is_Mem() || m->is_LoadStore(), "");
+                  uint input = (uint)MemNode::Memory;
                   _phase->igvn().replace_input_of(m, input, phi);
                   push = false;
                 }
@@ -4180,20 +2883,7 @@
   for (DUIterator i = mem->outs(); mem->has_out(i); i++) {
     Node* u = mem->out(i);
     if (u != replacement && u->_idx < last) {
-      if (u->is_ShenandoahBarrier() && _alias != Compile::AliasIdxRaw) {
-        if (_phase->C->get_alias_index(u->adr_type()) == _alias && ShenandoahWriteBarrierNode::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
-          _phase->igvn().replace_input_of(u, u->find_edge(mem), rep_proj);
-          assert(u->find_edge(mem) == -1, "only one edge");
-          --i;
-        }
-      } else if (u->is_Mem()) {
-        if (_phase->C->get_alias_index(u->adr_type()) == _alias && ShenandoahWriteBarrierNode::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
-          assert(_alias == Compile::AliasIdxRaw , "only raw memory can lead to a memory operation");
-          _phase->igvn().replace_input_of(u, u->find_edge(mem), rep_proj);
-          assert(u->find_edge(mem) == -1, "only one edge");
-          --i;
-        }
-      } else if (u->is_MergeMem()) {
+      if (u->is_MergeMem()) {
         MergeMemNode* u_mm = u->as_MergeMem();
         if (u_mm->memory_at(_alias) == mem) {
           MergeMemNode* newmm = NULL;
@@ -4221,7 +2911,7 @@
                 }
               }
             } else {
-              if (rep_ctrl != uu && ShenandoahWriteBarrierNode::is_dominator(rep_ctrl, _phase->ctrl_or_self(uu), replacement, uu, _phase)) {
+              if (rep_ctrl != uu && ShenandoahBarrierC2Support::is_dominator(rep_ctrl, _phase->ctrl_or_self(uu), replacement, uu, _phase)) {
                 if (newmm == NULL) {
                   newmm = clone_merge_mem(u, mem, rep_proj, rep_ctrl, i);
                 }
@@ -4262,10 +2952,11 @@
                u->Opcode() == Op_Rethrow ||
                u->Opcode() == Op_Return ||
                u->Opcode() == Op_SafePoint ||
+               u->Opcode() == Op_StoreLConditional ||
                (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
                (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) ||
                u->Opcode() == Op_CallLeaf, "");
-        if (ShenandoahWriteBarrierNode::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
+        if (ShenandoahBarrierC2Support::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
           if (mm == NULL) {
             mm = allocate_merge_mem(mem, rep_proj, rep_ctrl);
           }
@@ -4273,7 +2964,7 @@
           --i;
         }
       } else if (_phase->C->get_alias_index(u->adr_type()) == _alias) {
-        if (ShenandoahWriteBarrierNode::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
+        if (ShenandoahBarrierC2Support::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
           _phase->igvn().replace_input_of(u, u->find_edge(mem), rep_proj);
           --i;
         }
@@ -4282,11 +2973,324 @@
   }
 }
 
-void MemoryGraphFixer::remove(Node* n) {
-  assert(n->Opcode() == Op_ShenandoahWBMemProj, "");
-  Node* c = _phase->get_ctrl(n);
-  Node* mem = find_mem(c, NULL);
-  if (mem == n) {
-    _memory_nodes.map(c->_idx, mem->in(ShenandoahWBMemProjNode::WriteBarrier)->in(ShenandoahBarrierNode::Memory));
+ShenandoahLoadReferenceBarrierNode::ShenandoahLoadReferenceBarrierNode(Node* ctrl, Node* obj)
+: Node(ctrl, obj) {
+  ShenandoahBarrierSetC2::bsc2()->state()->add_load_reference_barrier(this);
+}
+
+const Type* ShenandoahLoadReferenceBarrierNode::bottom_type() const {
+  if (in(ValueIn) == NULL || in(ValueIn)->is_top()) {
+    return Type::TOP;
+  }
+  const Type* t = in(ValueIn)->bottom_type();
+  if (t == TypePtr::NULL_PTR) {
+    return t;
+  }
+  return t->is_oopptr();
+}
+
+const Type* ShenandoahLoadReferenceBarrierNode::Value(PhaseGVN* phase) const {
+  // Either input is TOP ==> the result is TOP
+  const Type *t2 = phase->type(in(ValueIn));
+  if( t2 == Type::TOP ) return Type::TOP;
+
+  if (t2 == TypePtr::NULL_PTR) {
+    return t2;
+  }
+
+  const Type* type = t2->is_oopptr()/*->cast_to_nonconst()*/;
+  return type;
+}
+
+Node* ShenandoahLoadReferenceBarrierNode::Identity(PhaseGVN* phase) {
+  Node* value = in(ValueIn);
+  if (!needs_barrier(phase, value)) {
+    return value;
+  }
+  return this;
+}
+
+bool ShenandoahLoadReferenceBarrierNode::needs_barrier(PhaseGVN* phase, Node* n) {
+  Unique_Node_List visited;
+  return needs_barrier_impl(phase, n, visited);
+}
+
+bool ShenandoahLoadReferenceBarrierNode::needs_barrier_impl(PhaseGVN* phase, Node* n, Unique_Node_List &visited) {
+  if (n == NULL) return false;
+  if (visited.member(n)) {
+    return false; // Been there.
+  }
+  visited.push(n);
+
+  if (n->is_Allocate()) {
+    // tty->print_cr("optimize barrier on alloc");
+    return false;
+  }
+  if (n->is_Call()) {
+    // tty->print_cr("optimize barrier on call");
+    return false;
+  }
+
+  const Type* type = phase->type(n);
+  if (type == Type::TOP) {
+    return false;
+  }
+  if (type->make_ptr()->higher_equal(TypePtr::NULL_PTR)) {
+    // tty->print_cr("optimize barrier on null");
+    return false;
+  }
+  if (type->make_oopptr() && type->make_oopptr()->const_oop() != NULL) {
+    // tty->print_cr("optimize barrier on constant");
+    return false;
+  }
+
+  switch (n->Opcode()) {
+    case Op_AddP:
+      return true; // TODO: Can refine?
+    case Op_LoadP:
+    case Op_ShenandoahCompareAndExchangeN:
+    case Op_ShenandoahCompareAndExchangeP:
+    case Op_CompareAndExchangeN:
+    case Op_CompareAndExchangeP:
+    case Op_GetAndSetN:
+    case Op_GetAndSetP:
+      return true;
+    case Op_Phi: {
+      for (uint i = 1; i < n->req(); i++) {
+        if (needs_barrier_impl(phase, n->in(i), visited)) return true;
+      }
+      return false;
+    }
+    case Op_CheckCastPP:
+    case Op_CastPP:
+      return needs_barrier_impl(phase, n->in(1), visited);
+    case Op_Proj:
+      return needs_barrier_impl(phase, n->in(0), visited);
+    case Op_ShenandoahLoadReferenceBarrier:
+      // tty->print_cr("optimize barrier on barrier");
+      return false;
+    case Op_Parm:
+      // tty->print_cr("optimize barrier on input arg");
+      return false;
+    case Op_DecodeN:
+    case Op_EncodeP:
+      return needs_barrier_impl(phase, n->in(1), visited);
+    case Op_LoadN:
+      return true;
+    case Op_CMoveP:
+      return needs_barrier_impl(phase, n->in(2), visited) ||
+             needs_barrier_impl(phase, n->in(3), visited);
+    case Op_ShenandoahEnqueueBarrier:
+      return needs_barrier_impl(phase, n->in(1), visited);
+    default:
+      break;
   }
+#ifdef ASSERT
+  tty->print("need barrier on?: ");
+  tty->print_cr("ins:");
+  n->dump(2);
+  tty->print_cr("outs:");
+  n->dump(-2);
+  ShouldNotReachHere();
+#endif
+  return true;
 }
+
+ShenandoahLoadReferenceBarrierNode::Strength ShenandoahLoadReferenceBarrierNode::get_barrier_strength() {
+  Unique_Node_List visited;
+  Node_Stack stack(0);
+  stack.push(this, 0);
+  Strength strength = NONE;
+  while (strength != STRONG && stack.size() > 0) {
+    Node* n = stack.node();
+    if (visited.member(n)) {
+      stack.pop();
+      continue;
+    }
+    visited.push(n);
+    bool visit_users = false;
+    switch (n->Opcode()) {
+      case Op_StoreN:
+      case Op_StoreP: {
+        strength = STRONG;
+        break;
+      }
+      case Op_CmpP: {
+        if (!n->in(1)->bottom_type()->higher_equal(TypePtr::NULL_PTR) &&
+            !n->in(2)->bottom_type()->higher_equal(TypePtr::NULL_PTR)) {
+          strength = STRONG;
+        }
+        break;
+      }
+      case Op_CallStaticJava: {
+        strength = STRONG;
+        break;
+      }
+      case Op_CallDynamicJava:
+      case Op_CallLeaf:
+      case Op_CallLeafNoFP:
+      case Op_CompareAndSwapL:
+      case Op_CompareAndSwapI:
+      case Op_CompareAndSwapB:
+      case Op_CompareAndSwapS:
+      case Op_CompareAndSwapN:
+      case Op_CompareAndSwapP:
+      case Op_ShenandoahCompareAndSwapN:
+      case Op_ShenandoahCompareAndSwapP:
+      case Op_ShenandoahWeakCompareAndSwapN:
+      case Op_ShenandoahWeakCompareAndSwapP:
+      case Op_ShenandoahCompareAndExchangeN:
+      case Op_ShenandoahCompareAndExchangeP:
+      case Op_CompareAndExchangeL:
+      case Op_CompareAndExchangeI:
+      case Op_CompareAndExchangeB:
+      case Op_CompareAndExchangeS:
+      case Op_WeakCompareAndSwapL:
+      case Op_WeakCompareAndSwapI:
+      case Op_WeakCompareAndSwapB:
+      case Op_WeakCompareAndSwapS:
+      case Op_GetAndSetL:
+      case Op_GetAndSetI:
+      case Op_GetAndSetB:
+      case Op_GetAndSetS:
+      case Op_GetAndSetP:
+      case Op_GetAndSetN:
+      case Op_GetAndAddL:
+      case Op_GetAndAddI:
+      case Op_GetAndAddB:
+      case Op_GetAndAddS:
+      case Op_ShenandoahEnqueueBarrier:
+      case Op_FastLock:
+      case Op_FastUnlock:
+      case Op_Rethrow:
+      case Op_Return:
+      case Op_StoreB:
+      case Op_StoreC:
+      case Op_StoreD:
+      case Op_StoreF:
+      case Op_StoreL:
+      case Op_StoreLConditional:
+      case Op_StoreI:
+      case Op_StoreVector:
+      case Op_StrInflatedCopy:
+      case Op_StrCompressedCopy:
+      case Op_EncodeP:
+      case Op_CastP2X:
+      case Op_SafePoint:
+      case Op_EncodeISOArray:
+        strength = STRONG;
+        break;
+      case Op_LoadB:
+      case Op_LoadUB:
+      case Op_LoadUS:
+      case Op_LoadD:
+      case Op_LoadF:
+      case Op_LoadL:
+      case Op_LoadI:
+      case Op_LoadS:
+      case Op_LoadN:
+      case Op_LoadP:
+      case Op_LoadVector: {
+        const TypePtr* adr_type = n->adr_type();
+        int alias_idx = Compile::current()->get_alias_index(adr_type);
+        Compile::AliasType* alias_type = Compile::current()->alias_type(alias_idx);
+        ciField* field = alias_type->field();
+        bool is_static = field != NULL && field->is_static();
+        bool is_final = field != NULL && field->is_final();
+        bool is_stable = field != NULL && field->is_stable();
+        if (ShenandoahOptimizeStaticFinals && is_static && is_final) {
+          // Leave strength as is.
+        } else if (ShenandoahOptimizeInstanceFinals && !is_static && is_final) {
+          // Leave strength as is.
+        } else if (ShenandoahOptimizeStableFinals && (is_stable || (adr_type->isa_aryptr() && adr_type->isa_aryptr()->is_stable()))) {
+          // Leave strength as is.
+        } else {
+          strength = WEAK;
+        }
+        break;
+      }
+      case Op_AryEq: {
+        Node* n1 = n->in(2);
+        Node* n2 = n->in(3);
+        if (!ShenandoahOptimizeStableFinals ||
+            !n1->bottom_type()->isa_aryptr() || !n1->bottom_type()->isa_aryptr()->is_stable() ||
+            !n2->bottom_type()->isa_aryptr() || !n2->bottom_type()->isa_aryptr()->is_stable()) {
+          strength = WEAK;
+        }
+        break;
+      }
+      case Op_StrEquals:
+      case Op_StrComp:
+      case Op_StrIndexOf:
+      case Op_StrIndexOfChar:
+        if (!ShenandoahOptimizeStableFinals) {
+           strength = WEAK;
+        }
+        break;
+      case Op_Conv2B:
+      case Op_LoadRange:
+      case Op_LoadKlass:
+      case Op_LoadNKlass:
+        // NONE, i.e. leave current strength as is
+        break;
+      case Op_AddP:
+      case Op_CheckCastPP:
+      case Op_CastPP:
+      case Op_CMoveP:
+      case Op_Phi:
+      case Op_ShenandoahLoadReferenceBarrier:
+        visit_users = true;
+        break;
+      default: {
+#ifdef ASSERT
+        tty->print_cr("Unknown node in get_barrier_strength:");
+        n->dump(1);
+        ShouldNotReachHere();
+#else
+        strength = STRONG;
+#endif
+      }
+    }
+#ifdef ASSERT
+/*
+    if (strength == STRONG) {
+      tty->print("strengthening node: ");
+      n->dump();
+    }
+    */
+#endif
+    stack.pop();
+    if (visit_users) {
+      for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
+        Node* user = n->fast_out(i);
+        if (user != NULL) {
+          stack.push(user, 0);
+        }
+      }
+    }
+  }
+  return strength;
+}
+
+CallStaticJavaNode* ShenandoahLoadReferenceBarrierNode::pin_and_expand_null_check(PhaseIterGVN& igvn) {
+  Node* val = in(ValueIn);
+
+  const Type* val_t = igvn.type(val);
+
+  if (val_t->meet(TypePtr::NULL_PTR) != val_t &&
+      val->Opcode() == Op_CastPP &&
+      val->in(0) != NULL &&
+      val->in(0)->Opcode() == Op_IfTrue &&
+      val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) &&
+      val->in(0)->in(0)->is_If() &&
+      val->in(0)->in(0)->in(1)->Opcode() == Op_Bool &&
+      val->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne &&
+      val->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
+      val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1) &&
+      val->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) {
+    assert(val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1), "");
+    CallStaticJavaNode* unc = val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
+    return unc;
+  }
+  return NULL;
+}
--- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -36,10 +36,8 @@
 class PhaseGVN;
 class MemoryGraphFixer;
 
-class ShenandoahBarrierNode : public TypeNode {
+class ShenandoahBarrierC2Support : public AllStatic {
 private:
-  bool _allow_fromspace;
-
 #ifdef ASSERT
   enum verify_type {
     ShenandoahLoad,
@@ -50,204 +48,49 @@
   };
 
   static bool verify_helper(Node* in, Node_Stack& phis, VectorSet& visited, verify_type t, bool trace, Unique_Node_List& barriers_used);
-#endif
-
-public:
-  enum { Control,
-         Memory,
-         ValueIn
-  };
-
-  ShenandoahBarrierNode(Node* ctrl, Node* mem, Node* obj, bool allow_fromspace)
-    : TypeNode(obj->bottom_type()->isa_oopptr() ? obj->bottom_type()->is_oopptr()->cast_to_nonconst() : obj->bottom_type(), 3),
-      _allow_fromspace(allow_fromspace) {
-
-    init_req(Control, ctrl);
-    init_req(Memory, mem);
-    init_req(ValueIn, obj);
-
-    init_class_id(Class_ShenandoahBarrier);
-  }
-
-  static Node* skip_through_barrier(Node* n);
-
-  static const TypeOopPtr* brooks_pointer_type(const Type* t) {
-    return t->is_oopptr()->cast_to_nonconst()->add_offset(ShenandoahBrooksPointer::byte_offset())->is_oopptr();
-  }
-
-  virtual const TypePtr* adr_type() const {
-    if (bottom_type() == Type::TOP) {
-      return NULL;
-    }
-    //const TypePtr* adr_type = in(MemNode::Address)->bottom_type()->is_ptr();
-    const TypePtr* adr_type = brooks_pointer_type(bottom_type());
-    assert(adr_type->offset() == ShenandoahBrooksPointer::byte_offset(), "sane offset");
-    assert(Compile::current()->alias_type(adr_type)->is_rewritable(), "brooks ptr must be rewritable");
-    return adr_type;
-  }
-
-  virtual uint  ideal_reg() const { return Op_RegP; }
-  virtual uint match_edge(uint idx) const {
-    return idx >= ValueIn;
-  }
-
-  Node* Identity_impl(PhaseGVN* phase);
-
-  virtual const Type* Value(PhaseGVN* phase) const;
-  virtual bool depends_only_on_test() const {
-    return true;
-  };
-
-  static bool needs_barrier(PhaseGVN* phase, ShenandoahBarrierNode* orig, Node* n, Node* rb_mem, bool allow_fromspace);
-
-#ifdef ASSERT
   static void report_verify_failure(const char* msg, Node* n1 = NULL, Node* n2 = NULL);
-  static void verify(RootNode* root);
   static void verify_raw_mem(RootNode* root);
 #endif
-#ifndef PRODUCT
-  virtual void dump_spec(outputStream *st) const;
-#endif
-
-  // protected:
-  static Node* dom_mem(Node* mem, Node*& mem_ctrl, Node* n, Node* rep_ctrl, int alias, PhaseIdealLoop* phase);
   static Node* dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase);
-  static bool is_dominator(Node *d_c, Node *n_c, Node* d, Node* n, PhaseIdealLoop* phase);
-  static bool is_dominator_same_ctrl(Node* c, Node* d, Node* n, PhaseIdealLoop* phase);
   static Node* no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase);
-  static bool build_loop_late_post(PhaseIdealLoop* phase, Node* n);
-  bool sink_node(PhaseIdealLoop* phase, Node* ctrl, Node* n_ctrl);
-
-protected:
-  uint hash() const;
-  uint cmp(const Node& n) const;
-  uint size_of() const;
-
-private:
-  static bool needs_barrier_impl(PhaseGVN* phase, ShenandoahBarrierNode* orig, Node* n, Node* rb_mem, bool allow_fromspace, Unique_Node_List &visited);
-
-  static bool dominates_memory(PhaseGVN* phase, Node* b1, Node* b2, bool linear);
-  static bool dominates_memory_impl(PhaseGVN* phase, Node* b1, Node* b2, Node* current, bool linear);
-};
-
-class ShenandoahReadBarrierNode : public ShenandoahBarrierNode {
-public:
-  ShenandoahReadBarrierNode(Node* ctrl, Node* mem, Node* obj)
-    : ShenandoahBarrierNode(ctrl, mem, obj, true) {
-    assert(UseShenandoahGC && (ShenandoahReadBarrier || ShenandoahStoreValReadBarrier ||
-                               ShenandoahWriteBarrier || ShenandoahAcmpBarrier),
-           "should be enabled");
-  }
-  ShenandoahReadBarrierNode(Node* ctrl, Node* mem, Node* obj, bool allow_fromspace)
-    : ShenandoahBarrierNode(ctrl, mem, obj, allow_fromspace) {
-    assert(UseShenandoahGC && (ShenandoahReadBarrier || ShenandoahStoreValReadBarrier ||
-                               ShenandoahWriteBarrier || ShenandoahAcmpBarrier),
-           "should be enabled");
-  }
-
-  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
-  virtual Node* Identity(PhaseGVN* phase);
-  virtual int Opcode() const;
-
-  bool is_independent(Node* mem);
-
-  void try_move(PhaseIdealLoop* phase);
-
-private:
-  static bool is_independent(const Type* in_type, const Type* this_type);
-  static bool dominates_memory_rb(PhaseGVN* phase, Node* b1, Node* b2, bool linear);
-  static bool dominates_memory_rb_impl(PhaseGVN* phase, Node* b1, Node* b2, Node* current, bool linear);
-};
-
-class ShenandoahWriteBarrierNode : public ShenandoahBarrierNode {
-public:
-  ShenandoahWriteBarrierNode(Compile* C, Node* ctrl, Node* mem, Node* obj);
-
-  virtual int Opcode() const;
-  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
-  virtual Node* Identity(PhaseGVN* phase);
-  virtual bool depends_only_on_test() const { return false; }
-
-  static bool expand(Compile* C, PhaseIterGVN& igvn);
-  static bool is_gc_state_load(Node *n);
   static bool is_heap_state_test(Node* iff, int mask);
-  static bool is_heap_stable_test(Node* iff);
   static bool try_common_gc_state_load(Node *n, PhaseIdealLoop *phase);
   static bool has_safepoint_between(Node* start, Node* stop, PhaseIdealLoop *phase);
-
-  static LoopNode* try_move_before_pre_loop(Node* c, Node* val_ctrl, PhaseIdealLoop* phase);
-  static Node* move_above_predicates(LoopNode* cl, Node* val_ctrl, PhaseIdealLoop* phase);
-#ifdef ASSERT
-  static bool memory_dominates_all_paths(Node* mem, Node* rep_ctrl, int alias, PhaseIdealLoop* phase);
-  static void memory_dominates_all_paths_helper(Node* c, Node* rep_ctrl, Unique_Node_List& controls, PhaseIdealLoop* phase);
-#endif
-  void try_move_before_loop(GrowableArray<MemoryGraphFixer*>& memory_graph_fixers, PhaseIdealLoop* phase, bool include_lsm, Unique_Node_List& uses);
-  void try_move_before_loop_helper(LoopNode* cl, Node* val_ctrl, GrowableArray<MemoryGraphFixer*>& memory_graph_fixers, PhaseIdealLoop* phase, bool include_lsm, Unique_Node_List& uses);
-  static void pin_and_expand(PhaseIdealLoop* phase);
-  CallStaticJavaNode* pin_and_expand_null_check(PhaseIterGVN& igvn);
-  void pin_and_expand_move_barrier(PhaseIdealLoop* phase, GrowableArray<MemoryGraphFixer*>& memory_graph_fixers, Unique_Node_List& uses);
-  void pin_and_expand_helper(PhaseIdealLoop* phase);
   static Node* find_bottom_mem(Node* ctrl, PhaseIdealLoop* phase);
   static void follow_barrier_uses(Node* n, Node* ctrl, Unique_Node_List& uses, PhaseIdealLoop* phase);
   static void test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase);
-
   static void test_heap_stable(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl,
                                PhaseIdealLoop* phase);
-  static void call_wb_stub(Node*& ctrl, Node*& val, Node*& result_mem,
-                           Node* raw_mem, Node* wb_mem, int alias,
-                           PhaseIdealLoop* phase);
+  static void call_lrb_stub(Node*& ctrl, Node*& val, Node*& result_mem, Node* raw_mem, PhaseIdealLoop* phase);
   static Node* clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase);
   static void fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl, Unique_Node_List& uses,
                              PhaseIdealLoop* phase);
   static void in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase);
   static void move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase);
-
-  static void optimize_after_expansion(VectorSet &visited, Node_Stack &nstack, Node_List &old_new, PhaseIdealLoop* phase);
   static void merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase);
   static bool identical_backtoback_ifs(Node *n, PhaseIdealLoop* phase);
   static void fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase);
-
-  static void optimize_before_expansion(PhaseIdealLoop* phase, GrowableArray<MemoryGraphFixer*> memory_graph_fixers, bool include_lsm);
-  Node* would_subsume(ShenandoahBarrierNode* other, PhaseIdealLoop* phase);
   static IfNode* find_unswitching_candidate(const IdealLoopTree *loop, PhaseIdealLoop* phase);
 
-  Node* try_split_thru_phi(PhaseIdealLoop* phase);
-};
+public:
+  static bool is_dominator(Node* d_c, Node* n_c, Node* d, Node* n, PhaseIdealLoop* phase);
+  static bool is_dominator_same_ctrl(Node* c, Node* d, Node* n, PhaseIdealLoop* phase);
 
-class ShenandoahWBMemProjNode : public Node {
-public:
-  enum { Control,
-         WriteBarrier };
-
-  ShenandoahWBMemProjNode(Node *src) : Node(NULL, src) {
-    assert(UseShenandoahGC && ShenandoahWriteBarrier, "should be enabled");
-    assert(src->Opcode() == Op_ShenandoahWriteBarrier || src->is_Mach(), "epxect wb");
-  }
-  virtual Node* Identity(PhaseGVN* phase);
+  static bool is_gc_state_load(Node* n);
+  static bool is_heap_stable_test(Node* iff);
 
-  virtual int Opcode() const;
-  virtual bool      is_CFG() const  { return false; }
-  virtual const Type *bottom_type() const {return Type::MEMORY;}
-  virtual const TypePtr *adr_type() const {
-    Node* wb = in(WriteBarrier);
-    if (wb == NULL || wb->is_top())  return NULL; // node is dead
-    assert(wb->Opcode() == Op_ShenandoahWriteBarrier || (wb->is_Mach() && wb->as_Mach()->ideal_Opcode() == Op_ShenandoahWriteBarrier) || wb->is_Phi(), "expect wb");
-    return ShenandoahBarrierNode::brooks_pointer_type(wb->bottom_type());
-  }
+  static bool expand(Compile* C, PhaseIterGVN& igvn);
+  static void pin_and_expand(PhaseIdealLoop* phase);
+  static void optimize_after_expansion(VectorSet& visited, Node_Stack& nstack, Node_List& old_new, PhaseIdealLoop* phase);
 
-  virtual uint ideal_reg() const { return 0;} // memory projections don't have a register
-  virtual const Type *Value(PhaseGVN* phase ) const {
-    return bottom_type();
-  }
-#ifndef PRODUCT
-  virtual void dump_spec(outputStream *st) const {};
+#ifdef ASSERT
+  static void verify(RootNode* root);
 #endif
 };
 
 class ShenandoahEnqueueBarrierNode : public Node {
 public:
-  ShenandoahEnqueueBarrierNode(Node* val) : Node(NULL, val) {
-  }
+  ShenandoahEnqueueBarrierNode(Node* val);
 
   const Type *bottom_type() const;
   const Type* Value(PhaseGVN* phase) const;
@@ -289,7 +132,6 @@
   Node* find_mem(Node* ctrl, Node* n) const;
   void fix_mem(Node* ctrl, Node* region, Node* mem, Node* mem_for_ctrl, Node* mem_phi, Unique_Node_List& uses);
   int alias() const { return _alias; }
-  void remove(Node* n);
 };
 
 class ShenandoahCompareAndSwapPNode : public CompareAndSwapPNode {
@@ -382,4 +224,41 @@
   virtual int Opcode() const;
 };
 
+class ShenandoahLoadReferenceBarrierNode : public Node {
+public:
+  enum {
+    Control,
+    ValueIn
+  };
+
+  enum Strength {
+    NONE, WEAK, STRONG, NA
+  };
+
+  ShenandoahLoadReferenceBarrierNode(Node* ctrl, Node* val);
+
+  virtual int Opcode() const;
+  virtual const Type* bottom_type() const;
+  virtual const Type* Value(PhaseGVN* phase) const;
+  virtual const class TypePtr *adr_type() const { return TypeOopPtr::BOTTOM; }
+  virtual uint match_edge(uint idx) const {
+    return idx >= ValueIn;
+  }
+  virtual uint ideal_reg() const { return Op_RegP; }
+
+  virtual Node* Identity(PhaseGVN* phase);
+
+  uint size_of() const {
+    return sizeof(*this);
+  }
+
+  Strength get_barrier_strength();
+  CallStaticJavaNode* pin_and_expand_null_check(PhaseIterGVN& igvn);
+
+private:
+  bool needs_barrier(PhaseGVN* phase, Node* n);
+  bool needs_barrier_impl(PhaseGVN* phase, Node* n, Unique_Node_List &visited);
+};
+
+
 #endif // SHARE_GC_SHENANDOAH_C2_SHENANDOAHSUPPORT_HPP
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -41,13 +41,10 @@
   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
 
   // Final configuration checks
+  SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahReadBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahWriteBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahStoreValReadBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahAcmpBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
 }
 
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAggressiveHeuristics.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAggressiveHeuristics.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -47,13 +47,10 @@
   }
 
   // Final configuration checks
+  SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahReadBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahWriteBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahStoreValReadBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahAcmpBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
 }
 
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -42,13 +42,10 @@
   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold,     10);
 
   // Final configuration checks
+  SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahReadBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahWriteBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahStoreValReadBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahAcmpBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
 }
 
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -43,14 +43,11 @@
   }
 
   // Disable known barriers by default.
+  SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahLoadRefBarrier);
   SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahSATBBarrier);
   SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahKeepAliveBarrier);
-  SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahWriteBarrier);
-  SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahReadBarrier);
   SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahStoreValEnqueueBarrier);
-  SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahStoreValReadBarrier);
   SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahCASBarrier);
-  SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahAcmpBarrier);
   SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahCloneBarrier);
 
   // Final configuration checks
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -40,13 +40,10 @@
   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
 
   // Final configuration checks
+  SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahReadBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahWriteBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahStoreValReadBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahAcmpBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
 }
 
--- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahTraversalHeuristics.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahTraversalHeuristics.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -37,7 +37,6 @@
   _last_cset_select(0)
  {
   FLAG_SET_DEFAULT(ShenandoahSATBBarrier,            false);
-  FLAG_SET_DEFAULT(ShenandoahStoreValReadBarrier,    false);
   FLAG_SET_DEFAULT(ShenandoahStoreValEnqueueBarrier, true);
   FLAG_SET_DEFAULT(ShenandoahKeepAliveBarrier,       false);
   FLAG_SET_DEFAULT(ShenandoahAllowMixedAllocs,       false);
@@ -53,11 +52,9 @@
   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
 
   // Final configuration checks
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahReadBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahWriteBarrier);
+  SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahStoreValEnqueueBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
-  SHENANDOAH_CHECK_FLAG_SET(ShenandoahAcmpBarrier);
   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
 }
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -46,12 +46,8 @@
 
   FLAG_SET_DEFAULT(ShenandoahSATBBarrier,            false);
   FLAG_SET_DEFAULT(ShenandoahKeepAliveBarrier,       false);
-  FLAG_SET_DEFAULT(ShenandoahWriteBarrier,           false);
-  FLAG_SET_DEFAULT(ShenandoahReadBarrier,            false);
   FLAG_SET_DEFAULT(ShenandoahStoreValEnqueueBarrier, false);
-  FLAG_SET_DEFAULT(ShenandoahStoreValReadBarrier,    false);
   FLAG_SET_DEFAULT(ShenandoahCASBarrier,             false);
-  FLAG_SET_DEFAULT(ShenandoahAcmpBarrier,            false);
   FLAG_SET_DEFAULT(ShenandoahCloneBarrier,           false);
 #endif
 
@@ -111,12 +107,8 @@
   if (ShenandoahVerifyOptoBarriers &&
           (!FLAG_IS_DEFAULT(ShenandoahSATBBarrier)            ||
            !FLAG_IS_DEFAULT(ShenandoahKeepAliveBarrier)       ||
-           !FLAG_IS_DEFAULT(ShenandoahWriteBarrier)           ||
-           !FLAG_IS_DEFAULT(ShenandoahReadBarrier)            ||
            !FLAG_IS_DEFAULT(ShenandoahStoreValEnqueueBarrier) ||
-           !FLAG_IS_DEFAULT(ShenandoahStoreValReadBarrier)    ||
            !FLAG_IS_DEFAULT(ShenandoahCASBarrier)             ||
-           !FLAG_IS_DEFAULT(ShenandoahAcmpBarrier)            ||
            !FLAG_IS_DEFAULT(ShenandoahCloneBarrier)
           )) {
     warning("Unusual barrier configuration, disabling C2 barrier verification");
@@ -135,18 +127,6 @@
     FLAG_SET_DEFAULT(ShenandoahAlwaysPreTouch, true);
   }
 
-  // Shenandoah C2 optimizations apparently dislike the shape of thread-local handshakes.
-  // Disable it by default, unless we enable it specifically for debugging.
-  if (FLAG_IS_DEFAULT(ThreadLocalHandshakes)) {
-    if (ThreadLocalHandshakes) {
-      FLAG_SET_DEFAULT(ThreadLocalHandshakes, false);
-    }
-  } else {
-    if (ThreadLocalHandshakes) {
-      warning("Thread-local handshakes are not working correctly with Shenandoah at the moment. Enable at your own risk.");
-    }
-  }
-
   // Record more information about previous cycles for improved debugging pleasure
   if (FLAG_IS_DEFAULT(LogEventsBufferEntries)) {
     FLAG_SET_DEFAULT(LogEventsBufferEntries, 250);
@@ -176,13 +156,6 @@
     FLAG_SET_DEFAULT(UseAOT, false);
   }
 
-  // JNI fast get field stuff is not currently supported by Shenandoah.
-  // It would introduce another heap memory access for reading the forwarding
-  // pointer, which would have to be guarded by the signal handler machinery.
-  // See:
-  // http://mail.openjdk.java.net/pipermail/hotspot-dev/2018-June/032763.html
-  FLAG_SET_DEFAULT(UseFastJNIAccessors, false);
-
   // TLAB sizing policy makes resizing decisions before each GC cycle. It averages
   // historical data, assigning more recent data the weight according to TLABAllocationWeight.
   // Current default is good for generational collectors that run frequent young GCs.
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -107,11 +107,8 @@
 }
 
 void ShenandoahBarrierSet::write_ref_array(HeapWord* start, size_t count) {
-  assert(UseShenandoahGC, "should be enabled");
-  if (count == 0) return;
-  if (!ShenandoahCloneBarrier) return;
-
-  if (!need_update_refs_barrier()) return;
+  assert(_heap->is_update_refs_in_progress(), "should not be here otherwise");
+  assert(count > 0, "Should have been filtered before");
 
   if (_heap->is_concurrent_traversal_in_progress()) {
     ShenandoahEvacOOMScope oom_evac_scope;
@@ -132,12 +129,23 @@
 template <class T>
 void ShenandoahBarrierSet::write_ref_array_pre_work(T* dst, size_t count) {
   shenandoah_assert_not_in_cset_loc_except(dst, _heap->cancelled_gc());
-  if (ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) {
-    T* elem_ptr = dst;
-    for (size_t i = 0; i < count; i++, elem_ptr++) {
-      T heap_oop = RawAccess<>::oop_load(elem_ptr);
-      if (!CompressedOops::is_null(heap_oop)) {
-        enqueue(CompressedOops::decode_not_null(heap_oop));
+  assert(ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).is_active(), "Shouldn't be here otherwise");
+  assert(ShenandoahSATBBarrier, "Shouldn't be here otherwise");
+  assert(count > 0, "Should have been filtered before");
+
+  Thread* thread = Thread::current();
+  ShenandoahMarkingContext* ctx = _heap->marking_context();
+  bool has_forwarded = _heap->has_forwarded_objects();
+  T* elem_ptr = dst;
+  for (size_t i = 0; i < count; i++, elem_ptr++) {
+    T heap_oop = RawAccess<>::oop_load(elem_ptr);
+    if (!CompressedOops::is_null(heap_oop)) {
+      oop obj = CompressedOops::decode_not_null(heap_oop);
+      if (has_forwarded) {
+        obj = resolve_forwarded_not_null(obj);
+      }
+      if (!ctx->is_marked(obj)) {
+        ShenandoahThreadLocalData::satb_mark_queue(thread).enqueue_known_active(obj);
       }
     }
   }
@@ -186,9 +194,8 @@
 }
 
 void ShenandoahBarrierSet::write_region(MemRegion mr) {
-  assert(UseShenandoahGC, "should be enabled");
   if (!ShenandoahCloneBarrier) return;
-  if (! need_update_refs_barrier()) return;
+  if (!_heap->is_update_refs_in_progress()) return;
 
   // This is called for cloning an object (see jvm.cpp) after the clone
   // has been made. We are not interested in any 'previous value' because
@@ -207,31 +214,25 @@
   }
 }
 
-oop ShenandoahBarrierSet::read_barrier(oop src) {
-  // Check for forwarded objects, because on Full GC path we might deal with
-  // non-trivial fwdptrs that contain Full GC specific metadata. We could check
-  // for is_full_gc_in_progress(), but this also covers the case of stable heap,
-  // which provides a bit of performance improvement.
-  if (ShenandoahReadBarrier && _heap->has_forwarded_objects()) {
-    return ShenandoahBarrierSet::resolve_forwarded(src);
+oop ShenandoahBarrierSet::load_reference_barrier_not_null(oop obj) {
+  if (ShenandoahLoadRefBarrier && _heap->has_forwarded_objects()) {
+    return load_reference_barrier_impl(obj);
   } else {
-    return src;
+    return obj;
   }
 }
 
-bool ShenandoahBarrierSet::obj_equals(oop obj1, oop obj2) {
-  bool eq = oopDesc::equals_raw(obj1, obj2);
-  if (! eq && ShenandoahAcmpBarrier) {
-    OrderAccess::loadload();
-    obj1 = resolve_forwarded(obj1);
-    obj2 = resolve_forwarded(obj2);
-    eq = oopDesc::equals_raw(obj1, obj2);
+oop ShenandoahBarrierSet::load_reference_barrier(oop obj) {
+  if (obj != NULL) {
+    return load_reference_barrier_not_null(obj);
+  } else {
+    return obj;
   }
-  return eq;
 }
 
-oop ShenandoahBarrierSet::write_barrier_mutator(oop obj) {
-  assert(UseShenandoahGC && ShenandoahWriteBarrier, "should be enabled");
+
+oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj) {
+  assert(ShenandoahLoadRefBarrier, "should be enabled");
   assert(_heap->is_gc_in_progress_mask(ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL), "evac should be in progress");
   shenandoah_assert_in_cset(NULL, obj);
 
@@ -277,8 +278,8 @@
   return fwd;
 }
 
-oop ShenandoahBarrierSet::write_barrier_impl(oop obj) {
-  assert(UseShenandoahGC && ShenandoahWriteBarrier, "should be enabled");
+oop ShenandoahBarrierSet::load_reference_barrier_impl(oop obj) {
+  assert(ShenandoahLoadRefBarrier, "should be enabled");
   if (!CompressedOops::is_null(obj)) {
     bool evac_in_progress = _heap->is_gc_in_progress_mask(ShenandoahHeap::EVACUATION | ShenandoahHeap::TRAVERSAL);
     oop fwd = resolve_forwarded_not_null(obj);
@@ -300,27 +301,12 @@
   }
 }
 
-oop ShenandoahBarrierSet::write_barrier(oop obj) {
-  if (ShenandoahWriteBarrier && _heap->has_forwarded_objects()) {
-    return write_barrier_impl(obj);
-  } else {
-    return obj;
+void ShenandoahBarrierSet::storeval_barrier(oop obj) {
+  if (ShenandoahStoreValEnqueueBarrier && !CompressedOops::is_null(obj) && _heap->is_concurrent_traversal_in_progress()) {
+    enqueue(obj);
   }
 }
 
-oop ShenandoahBarrierSet::storeval_barrier(oop obj) {
-  if (ShenandoahStoreValEnqueueBarrier) {
-    if (!CompressedOops::is_null(obj)) {
-      obj = write_barrier(obj);
-      enqueue(obj);
-    }
-  }
-  if (ShenandoahStoreValReadBarrier) {
-    obj = resolve_forwarded(obj);
-  }
-  return obj;
-}
-
 void ShenandoahBarrierSet::keep_alive_barrier(oop obj) {
   if (ShenandoahKeepAliveBarrier && _heap->is_concurrent_mark_in_progress()) {
     enqueue(obj);
@@ -329,14 +315,14 @@
 
 void ShenandoahBarrierSet::enqueue(oop obj) {
   shenandoah_assert_not_forwarded_if(NULL, obj, _heap->is_concurrent_traversal_in_progress());
-  if (!_satb_mark_queue_set.is_active()) return;
+  assert(_satb_mark_queue_set.is_active(), "only get here when SATB active");
 
   // Filter marked objects before hitting the SATB queues. The same predicate would
   // be used by SATBMQ::filter to eliminate already marked objects downstream, but
   // filtering here helps to avoid wasteful SATB queueing work to begin with.
   if (!_heap->requires_marking<false>(obj)) return;
 
-  ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue(obj);
+  ShenandoahThreadLocalData::satb_mark_queue(Thread::current()).enqueue_known_active(obj);
 }
 
 void ShenandoahBarrierSet::on_thread_create(Thread* thread) {
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -87,34 +87,23 @@
   virtual void on_thread_attach(Thread* thread);
   virtual void on_thread_detach(Thread* thread);
 
-  virtual oop read_barrier(oop src);
-
   static inline oop resolve_forwarded_not_null(oop p);
   static inline oop resolve_forwarded(oop p);
 
-  virtual oop write_barrier(oop obj);
-
-  oop write_barrier_mutator(oop obj);
-
-  virtual oop storeval_barrier(oop obj);
+  void storeval_barrier(oop obj);
+  void keep_alive_barrier(oop obj);
 
-  virtual void keep_alive_barrier(oop obj);
-
-  bool obj_equals(oop obj1, oop obj2);
-
-#ifdef CHECK_UNHANDLED_OOPS
-  bool oop_equals_operator_allowed() { return !ShenandoahVerifyObjectEquals; }
-#endif
+  oop load_reference_barrier(oop obj);
+  oop load_reference_barrier_mutator(oop obj);
+  oop load_reference_barrier_not_null(oop obj);
 
   void enqueue(oop obj);
 
 private:
-  inline bool need_update_refs_barrier();
-
   template <class T, bool STOREVAL_WRITE_BARRIER>
   void write_ref_array_loop(HeapWord* start, size_t count);
 
-  oop write_barrier_impl(oop obj);
+  oop load_reference_barrier_impl(oop obj);
 
   static void keep_alive_if_weak(DecoratorSet decorators, oop value) {
     assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
@@ -141,7 +130,7 @@
   bool arraycopy_loop(T* src, T* dst, size_t length, Klass* bound, bool disjoint);
 
   template <typename T, bool CHECKCAST, bool SATB, ShenandoahBarrierSet::ArrayCopyStoreValMode STOREVAL_MODE>
-  bool arraycopy_element(T* cur_src, T* cur_dst, Klass* bound, Thread* thread);
+  bool arraycopy_element(T* cur_src, T* cur_dst, Klass* bound, Thread* const thread, ShenandoahMarkingContext* const ctx);
 
 public:
   // Callbacks for runtime accesses.
@@ -149,114 +138,31 @@
   class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
     typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
 
-  public:
-    // Primitive heap accesses. These accessors get resolved when
-    // IN_HEAP is set (e.g. when using the HeapAccess API), it is
-    // not an oop_* overload, and the barrier strength is AS_NORMAL.
     template <typename T>
-    static T load_in_heap(T* addr) {
-      ShouldNotReachHere();
-      return Raw::template load<T>(addr);
-    }
-
-    template <typename T>
-    static T load_in_heap_at(oop base, ptrdiff_t offset) {
-      base = ShenandoahBarrierSet::resolve_forwarded(base);
-      return Raw::template load_at<T>(base, offset);
-    }
-
-    template <typename T>
-    static void store_in_heap(T* addr, T value) {
-      ShouldNotReachHere();
-      Raw::store(addr, value);
-    }
-
-    template <typename T>
-    static void store_in_heap_at(oop base, ptrdiff_t offset, T value) {
-      base = ShenandoahBarrierSet::barrier_set()->write_barrier(base);
-      Raw::store_at(base, offset, value);
-    }
+    static oop oop_atomic_cmpxchg_in_heap_impl(oop new_value, T* addr, oop compare_value);
 
     template <typename T>
-    static T atomic_cmpxchg_in_heap(T new_value, T* addr, T compare_value) {
-      ShouldNotReachHere();
-      return Raw::atomic_cmpxchg(new_value, addr, compare_value);
-    }
-
-    template <typename T>
-    static T atomic_cmpxchg_in_heap_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
-      base = ShenandoahBarrierSet::barrier_set()->write_barrier(base);
-      return Raw::atomic_cmpxchg_at(new_value, base, offset, compare_value);
-    }
+    static oop oop_atomic_xchg_in_heap_impl(oop new_value, T* addr);
 
-    template <typename T>
-    static T atomic_xchg_in_heap(T new_value, T* addr) {
-      ShouldNotReachHere();
-      return Raw::atomic_xchg(new_value, addr);
-    }
-
-    template <typename T>
-    static T atomic_xchg_in_heap_at(T new_value, oop base, ptrdiff_t offset) {
-      base = ShenandoahBarrierSet::barrier_set()->write_barrier(base);
-      return Raw::atomic_xchg_at(new_value, base, offset);
-    }
-
-    template <typename T>
-    static void arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
-                                  arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
-                                  size_t length);
-
+  public:
     // Heap oop accesses. These accessors get resolved when
     // IN_HEAP is set (e.g. when using the HeapAccess API), it is
     // an oop_* overload, and the barrier strength is AS_NORMAL.
     template <typename T>
-    static oop oop_load_in_heap(T* addr) {
-      // ShouldNotReachHere();
-      oop value = Raw::template oop_load<oop>(addr);
-      keep_alive_if_weak(decorators, value);
-      return value;
-    }
-
-    static oop oop_load_in_heap_at(oop base, ptrdiff_t offset) {
-      base = ShenandoahBarrierSet::resolve_forwarded(base);
-      oop value = Raw::template oop_load_at<oop>(base, offset);
-      keep_alive_if_weak(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
-      return value;
-    }
+    static oop oop_load_in_heap(T* addr);
+    static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
 
     template <typename T>
-    static void oop_store_in_heap(T* addr, oop value) {
-      const bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
-      if (keep_alive) {
-        ShenandoahBarrierSet::barrier_set()->write_ref_field_pre_work(addr, value);
-      }
-      Raw::oop_store(addr, value);
-    }
-
-    static void oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value) {
-      base = ShenandoahBarrierSet::barrier_set()->write_barrier(base);
-      value = ShenandoahBarrierSet::barrier_set()->storeval_barrier(value);
-
-      oop_store_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), value);
-    }
+    static void oop_store_in_heap(T* addr, oop value);
+    static void oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value);
 
     template <typename T>
     static oop oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value);
-
-    static oop oop_atomic_cmpxchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value) {
-      base = ShenandoahBarrierSet::barrier_set()->write_barrier(base);
-      new_value = ShenandoahBarrierSet::barrier_set()->storeval_barrier(new_value);
-      return oop_atomic_cmpxchg_in_heap(new_value, AccessInternal::oop_field_addr<decorators>(base, offset), compare_value);
-    }
+    static oop oop_atomic_cmpxchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value);
 
     template <typename T>
     static oop oop_atomic_xchg_in_heap(oop new_value, T* addr);
-
-    static oop oop_atomic_xchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset) {
-      base = ShenandoahBarrierSet::barrier_set()->write_barrier(base);
-      new_value = ShenandoahBarrierSet::barrier_set()->storeval_barrier(new_value);
-      return oop_atomic_xchg_in_heap(new_value, AccessInternal::oop_field_addr<decorators>(base, offset));
-    }
+    static oop oop_atomic_xchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset);
 
     template <typename T>
     static bool oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
@@ -268,19 +174,13 @@
 
     // Needed for loads on non-heap weak references
     template <typename T>
-    static oop oop_load_not_in_heap(T* addr) {
-      oop value = Raw::oop_load_not_in_heap(addr);
-      keep_alive_if_weak(decorators, value);
-      return value;
-    }
+    static oop oop_load_not_in_heap(T* addr);
 
-    static oop resolve(oop obj) {
-      return ShenandoahBarrierSet::barrier_set()->write_barrier(obj);
-    }
+    template <typename T>
+    static oop oop_atomic_cmpxchg_not_in_heap(oop new_value, T* addr, oop compare_value);
 
-    static bool equals(oop o1, oop o2) {
-      return ShenandoahBarrierSet::barrier_set()->obj_equals(o1, o2);
-    }
+    template <typename T>
+    static oop oop_atomic_xchg_not_in_heap(oop new_value, T* addr);
 
   };
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -28,12 +28,9 @@
 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
 #include "gc/shenandoah/shenandoahBrooksPointer.inline.hpp"
 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
-
-bool ShenandoahBarrierSet::need_update_refs_barrier() {
-  return _heap->is_update_refs_in_progress() ||
-         _heap->is_concurrent_traversal_in_progress() ||
-         (_heap->is_concurrent_mark_in_progress() && _heap->has_forwarded_objects());
-}
+#include "gc/shenandoah/shenandoahHeapRegion.hpp"
+#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
+#include "gc/shenandoah/shenandoahThreadLocalData.hpp"
 
 inline oop ShenandoahBarrierSet::resolve_forwarded_not_null(oop p) {
   return ShenandoahBrooksPointer::forwardee(p);
@@ -49,7 +46,49 @@
 
 template <DecoratorSet decorators, typename BarrierSetT>
 template <typename T>
-inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value) {
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_in_heap(T* addr) {
+  oop value = Raw::oop_load_in_heap(addr);
+  value = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(value);
+  keep_alive_if_weak(decorators, value);
+  return value;
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_in_heap_at(oop base, ptrdiff_t offset) {
+  oop value = Raw::oop_load_in_heap_at(base, offset);
+  value = ShenandoahBarrierSet::barrier_set()->load_reference_barrier(value);
+  keep_alive_if_weak(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);
+  return value;
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+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()->load_reference_barrier(value);
+  keep_alive_if_weak(decorators, value);
+  return value;
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+template <typename T>
+inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_store_in_heap(T* addr, oop value) {
+  ShenandoahBarrierSet::barrier_set()->storeval_barrier(value);
+  const bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
+  if (keep_alive) {
+    ShenandoahBarrierSet::barrier_set()->write_ref_field_pre_work(addr, value);
+  }
+  Raw::oop_store_in_heap(addr, value);
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value) {
+  oop_store_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), value);
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+template <typename T>
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_not_in_heap(oop new_value, T* addr, oop compare_value) {
   oop res;
   oop expected = compare_value;
   do {
@@ -57,40 +96,79 @@
     res = Raw::oop_atomic_cmpxchg(new_value, addr, compare_value);
     expected = res;
   } while ((! oopDesc::equals_raw(compare_value, expected)) && oopDesc::equals_raw(resolve_forwarded(compare_value), resolve_forwarded(expected)));
-  if (oopDesc::equals_raw(expected, compare_value)) {
-    const bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
-    if (keep_alive && ShenandoahSATBBarrier && !CompressedOops::is_null(compare_value)) {
-      ShenandoahBarrierSet::barrier_set()->enqueue(compare_value);
-    }
+  if (res != NULL) {
+    return ShenandoahBarrierSet::barrier_set()->load_reference_barrier_not_null(res);
+  } else {
+    return res;
+  }
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+template <typename T>
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_in_heap_impl(oop new_value, T* addr, oop compare_value) {
+  ShenandoahBarrierSet::barrier_set()->storeval_barrier(new_value);
+  oop result = oop_atomic_cmpxchg_not_in_heap(new_value, addr, compare_value);
+  const bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
+  if (keep_alive && ShenandoahSATBBarrier && !CompressedOops::is_null(result) &&
+      oopDesc::equals_raw(result, compare_value) &&
+      ShenandoahHeap::heap()->is_concurrent_mark_in_progress()) {
+    ShenandoahBarrierSet::barrier_set()->enqueue(result);
   }
-  return res;
+  return result;
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+template <typename T>
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value) {
+  oop result = oop_atomic_cmpxchg_in_heap_impl(new_value, addr, compare_value);
+  keep_alive_if_weak(decorators, result);
+  return result;
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_cmpxchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value) {
+  oop result = oop_atomic_cmpxchg_in_heap_impl(new_value, AccessInternal::oop_field_addr<decorators>(base, offset), compare_value);
+  keep_alive_if_weak(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), result);
+  return result;
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+template <typename T>
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_not_in_heap(oop new_value, T* addr) {
+  oop previous = Raw::oop_atomic_xchg(new_value, addr);
+  if (previous != NULL) {
+    return ShenandoahBarrierSet::barrier_set()->load_reference_barrier_not_null(previous);
+  } else {
+    return previous;
+  }
+}
+
+template <DecoratorSet decorators, typename BarrierSetT>
+template <typename T>
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_in_heap_impl(oop new_value, T* addr) {
+  ShenandoahBarrierSet::barrier_set()->storeval_barrier(new_value);
+  oop result = oop_atomic_xchg_not_in_heap(new_value, addr);
+  const bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
+  if (keep_alive && ShenandoahSATBBarrier && !CompressedOops::is_null(result) &&
+      ShenandoahHeap::heap()->is_concurrent_mark_in_progress()) {
+    ShenandoahBarrierSet::barrier_set()->enqueue(result);
+  }
+  return result;
 }
 
 template <DecoratorSet decorators, typename BarrierSetT>
 template <typename T>
 inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_in_heap(oop new_value, T* addr) {
-  oop previous = Raw::oop_atomic_xchg(new_value, addr);
-  if (ShenandoahSATBBarrier) {
-    const bool keep_alive = (decorators & AS_NO_KEEPALIVE) == 0;
-    if (keep_alive && !CompressedOops::is_null(previous)) {
-      ShenandoahBarrierSet::barrier_set()->enqueue(previous);
-    }
-  }
-  return previous;
+  oop result = oop_atomic_xchg_in_heap_impl(new_value, addr);
+  keep_alive_if_weak(addr, result);
+  return result;
 }
 
 template <DecoratorSet decorators, typename BarrierSetT>
-template <typename T>
-void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
-                                                                                     arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
-                                                                                     size_t length) {
-  if (!CompressedOops::is_null(src_obj)) {
-    src_obj = arrayOop(ShenandoahBarrierSet::barrier_set()->read_barrier(src_obj));
-  }
-  if (!CompressedOops::is_null(dst_obj)) {
-    dst_obj = arrayOop(ShenandoahBarrierSet::barrier_set()->write_barrier(dst_obj));
-  }
-  Raw::arraycopy(src_obj, src_offset_in_bytes, src_raw, dst_obj, dst_offset_in_bytes, dst_raw, length);
+inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_atomic_xchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset) {
+  oop result = oop_atomic_xchg_in_heap_impl(new_value, AccessInternal::oop_field_addr<decorators>(base, offset));
+  keep_alive_if_weak(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), result);
+  return result;
 }
 
 template <typename T>
@@ -134,7 +212,7 @@
 template <typename T, bool CHECKCAST, bool SATB, ShenandoahBarrierSet::ArrayCopyStoreValMode STOREVAL_MODE>
 bool ShenandoahBarrierSet::arraycopy_loop(T* src, T* dst, size_t length, Klass* bound, bool disjoint) {
   Thread* thread = Thread::current();
-
+  ShenandoahMarkingContext* ctx = _heap->marking_context();
   ShenandoahEvacOOMScope oom_evac_scope;
 
   // We need to handle four cases:
@@ -161,7 +239,7 @@
     T* cur_dst = dst;
     T* src_end = src + length;
     for (; cur_src < src_end; cur_src++, cur_dst++) {
-      if (!arraycopy_element<T, CHECKCAST, SATB, STOREVAL_MODE>(cur_src, cur_dst, bound, thread)) {
+      if (!arraycopy_element<T, CHECKCAST, SATB, STOREVAL_MODE>(cur_src, cur_dst, bound, thread, ctx)) {
         return false;
       }
     }
@@ -170,7 +248,7 @@
     T* cur_src = src + length - 1;
     T* cur_dst = dst + length - 1;
     for (; cur_src >= src; cur_src--, cur_dst--) {
-      if (!arraycopy_element<T, CHECKCAST, SATB, STOREVAL_MODE>(cur_src, cur_dst, bound, thread)) {
+      if (!arraycopy_element<T, CHECKCAST, SATB, STOREVAL_MODE>(cur_src, cur_dst, bound, thread, ctx)) {
         return false;
       }
     }
@@ -179,14 +257,26 @@
 }
 
 template <typename T, bool CHECKCAST, bool SATB, ShenandoahBarrierSet::ArrayCopyStoreValMode STOREVAL_MODE>
-bool ShenandoahBarrierSet::arraycopy_element(T* cur_src, T* cur_dst, Klass* bound, Thread* thread) {
+bool ShenandoahBarrierSet::arraycopy_element(T* cur_src, T* cur_dst, Klass* bound, Thread* const thread, ShenandoahMarkingContext* const ctx) {
   T o = RawAccess<>::oop_load(cur_src);
 
   if (SATB) {
+    assert(ShenandoahThreadLocalData::satb_mark_queue(thread).is_active(), "Shouldn't be here otherwise");
     T prev = RawAccess<>::oop_load(cur_dst);
     if (!CompressedOops::is_null(prev)) {
       oop prev_obj = CompressedOops::decode_not_null(prev);
-      enqueue(prev_obj);
+      switch (STOREVAL_MODE) {
+      case NONE:
+        break;
+      case READ_BARRIER:
+      case WRITE_BARRIER:
+        // The write-barrier case cannot really happen. It's traversal-only and traversal
+        // doesn't currently use SATB. And even if it did, it would not be fatal to just do the normal RB here.
+        prev_obj = ShenandoahBarrierSet::resolve_forwarded_not_null(prev_obj);
+      }
+      if (!ctx->is_marked(prev_obj)) {
+        ShenandoahThreadLocalData::satb_mark_queue(thread).enqueue_known_active(prev_obj);
+      }
     }
   }
 
@@ -231,8 +321,6 @@
 // Clone barrier support
 template <DecoratorSet decorators, typename BarrierSetT>
 void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::clone_in_heap(oop src, oop dst, size_t size) {
-  src = arrayOop(ShenandoahBarrierSet::barrier_set()->read_barrier(src));
-  dst = arrayOop(ShenandoahBarrierSet::barrier_set()->write_barrier(dst));
   Raw::clone(src, dst, size);
   ShenandoahBarrierSet::barrier_set()->write_region(MemRegion((HeapWord*) dst, size));
 }
@@ -243,13 +331,6 @@
                                                                                          arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
                                                                                          size_t length) {
   ShenandoahHeap* heap = ShenandoahHeap::heap();
-  if (!CompressedOops::is_null(src_obj)) {
-    src_obj = arrayOop(ShenandoahBarrierSet::barrier_set()->read_barrier(src_obj));
-  }
-  if (!CompressedOops::is_null(dst_obj)) {
-    dst_obj = arrayOop(ShenandoahBarrierSet::barrier_set()->write_barrier(dst_obj));
-  }
-
   bool satb = ShenandoahSATBBarrier && heap->is_concurrent_mark_in_progress();
   bool checkcast = HasDecorator<decorators, ARRAYCOPY_CHECKCAST>::value;
   bool disjoint = HasDecorator<decorators, ARRAYCOPY_DISJOINT>::value;
@@ -257,7 +338,7 @@
   if (heap->has_forwarded_objects()) {
     if (heap->is_concurrent_traversal_in_progress()) {
       storeval_mode = WRITE_BARRIER;
-    } else if (heap->is_concurrent_mark_in_progress() || heap->is_update_refs_in_progress()) {
+    } else if (heap->is_update_refs_in_progress()) {
       storeval_mode = READ_BARRIER;
     } else {
       assert(heap->is_idle() || heap->is_evacuation_in_progress(), "must not have anything in progress");
--- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -119,39 +119,6 @@
   }
 };
 
-class ShenandoahNMethodOopInitializer : public OopClosure {
-private:
-  ShenandoahHeap* const _heap;
-
-public:
-  ShenandoahNMethodOopInitializer() : _heap(ShenandoahHeap::heap()) {};
-
-private:
-  template <class T>
-  inline void do_oop_work(T* p) {
-    T o = RawAccess<>::oop_load(p);
-    if (! CompressedOops::is_null(o)) {
-      oop obj1 = CompressedOops::decode_not_null(o);
-      oop obj2 = ShenandoahBarrierSet::barrier_set()->write_barrier(obj1);
-      if (! oopDesc::equals_raw(obj1, obj2)) {
-        shenandoah_assert_not_in_cset(NULL, obj2);
-        RawAccess<IS_NOT_NULL>::oop_store(p, obj2);
-        if (_heap->is_concurrent_traversal_in_progress()) {
-          ShenandoahBarrierSet::barrier_set()->enqueue(obj2);
-        }
-      }
-    }
-  }
-
-public:
-  void do_oop(oop* o) {
-    do_oop_work(o);
-  }
-  void do_oop(narrowOop* o) {
-    do_oop_work(o);
-  }
-};
-
 ShenandoahCodeRoots::PaddedLock ShenandoahCodeRoots::_recorded_nms_lock;
 GrowableArray<ShenandoahNMethod*>* ShenandoahCodeRoots::_recorded_nms;
 
@@ -163,21 +130,13 @@
 void ShenandoahCodeRoots::add_nmethod(nmethod* nm) {
   switch (ShenandoahCodeRootsStyle) {
     case 0:
-    case 1: {
-      ShenandoahNMethodOopInitializer init;
-      nm->oops_do(&init);
-      nm->fix_oop_relocations();
+    case 1:
       break;
-    }
     case 2: {
       ShenandoahNMethodOopDetector detector;
       nm->oops_do(&detector);
 
       if (detector.has_oops()) {
-        ShenandoahNMethodOopInitializer init;
-        nm->oops_do(&init);
-        nm->fix_oop_relocations();
-
         ShenandoahNMethod* nmr = new ShenandoahNMethod(nm, detector.oops());
         nmr->assert_alive_and_correct();
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -36,7 +36,7 @@
 #include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
 #include "gc/shenandoah/shenandoahMarkCompact.hpp"
 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
-#include "gc/shenandoah/shenandoahRootProcessor.hpp"
+#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
 #include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
 #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
@@ -120,11 +120,10 @@
 
     CLDToOopClosure clds_cl(oops, ClassLoaderData::_claim_strong);
     MarkingCodeBlobClosure blobs_cl(oops, ! CodeBlobToOopClosure::FixRelocations);
-    OopClosure* weak_oops = _process_refs ? NULL : oops;
 
     ResourceMark m;
     if (heap->unload_classes()) {
-      _rp->process_strong_roots(oops, weak_oops, &clds_cl, NULL, &blobs_cl, NULL, worker_id);
+      _rp->process_strong_roots(oops, &clds_cl, &blobs_cl, NULL, worker_id);
     } else {
       if (ShenandoahConcurrentScanCodeRoots) {
         CodeBlobClosure* code_blobs = NULL;
@@ -137,9 +136,9 @@
           code_blobs = &assert_to_space;
         }
 #endif
-        _rp->process_all_roots(oops, weak_oops, &clds_cl, code_blobs, NULL, worker_id);
+        _rp->process_all_roots(oops, &clds_cl, code_blobs, NULL, worker_id);
       } else {
-        _rp->process_all_roots(oops, weak_oops, &clds_cl, &blobs_cl, NULL, worker_id);
+        _rp->process_all_roots(oops, &clds_cl, &blobs_cl, NULL, worker_id);
       }
     }
   }
@@ -177,7 +176,7 @@
         DEBUG_ONLY(&assert_to_space)
         NOT_DEBUG(NULL);
     }
-    _rp->process_all_roots(&cl, &cl, &cldCl, code_blobs, NULL, worker_id);
+    _rp->update_all_roots<AlwaysTrueClosure>(&cl, &cldCl, code_blobs, NULL, worker_id);
   }
 };
 
@@ -214,15 +213,15 @@
 class ShenandoahSATBThreadsClosure : public ThreadClosure {
 private:
   ShenandoahSATBBufferClosure* _satb_cl;
-  int _thread_parity;
+  uintx _claim_token;
 
 public:
   ShenandoahSATBThreadsClosure(ShenandoahSATBBufferClosure* satb_cl) :
     _satb_cl(satb_cl),
-    _thread_parity(Threads::thread_claim_parity()) {}
+    _claim_token(Threads::thread_claim_token()) {}
 
   void do_thread(Thread* thread) {
-    if (thread->claim_oops_do(true, _thread_parity)) {
+    if (thread->claim_threads_do(true, _claim_token)) {
       ShenandoahThreadLocalData::satb_mark_queue(thread).apply_closure_and_empty(_satb_cl);
     }
   }
@@ -446,11 +445,16 @@
     weak_refs_work(full_gc);
   }
 
+  weak_roots_work();
+
   // And finally finish class unloading
   if (_heap->unload_classes()) {
     _heap->unload_classes_and_cleanup_tables(full_gc);
+  } else if (ShenandoahStringDedup::is_enabled()) {
+    ShenandoahIsAliveSelector alive;
+    BoolObjectClosure* is_alive = alive.is_alive_closure();
+    ShenandoahStringDedup::unlink_or_oops_do(is_alive, NULL, false);
   }
-
   assert(task_queues()->is_empty(), "Should be empty");
   TASKQUEUE_STATS_ONLY(task_queues()->print_taskqueue_stats());
   TASKQUEUE_STATS_ONLY(task_queues()->reset_taskqueue_stats());
@@ -555,11 +559,13 @@
 private:
   template <class T>
   inline void do_oop_work(T* p) {
+#ifdef ASSERT
     T o = RawAccess<>::oop_load(p);
     if (!CompressedOops::is_null(o)) {
       oop obj = CompressedOops::decode_not_null(o);
       shenandoah_assert_not_forwarded(p, obj);
     }
+#endif
   }
 
 public:
@@ -648,6 +654,23 @@
 
 }
 
+// Process leftover weak oops: update them, if needed or assert they do not
+// need updating otherwise.
+// Weak processor API requires us to visit the oops, even if we are not doing
+// anything to them.
+void ShenandoahConcurrentMark::weak_roots_work() {
+  WorkGang* workers = _heap->workers();
+  ShenandoahIsAliveSelector is_alive;
+
+  if (_heap->has_forwarded_objects()) {
+    ShenandoahWeakUpdateClosure cl;
+    WeakProcessor::weak_oops_do(workers, is_alive.is_alive_closure(), &cl, 1);
+  } else {
+    ShenandoahWeakAssertNotForwardedClosure cl;
+    WeakProcessor::weak_oops_do(workers, is_alive.is_alive_closure(), &cl, 1);
+  }
+}
+
 void ShenandoahConcurrentMark::weak_refs_work_doit(bool full_gc) {
   ReferenceProcessor* rp = _heap->ref_processor();
 
@@ -689,26 +712,18 @@
     ShenandoahGCPhase phase(phase_process);
     ShenandoahTerminationTracker phase_term(phase_process_termination);
 
-    // Process leftover weak oops: update them, if needed (using parallel version),
-    // or assert they do not need updating (using serial version) otherwise.
-    // Weak processor API requires us to visit the oops, even if we are not doing
-    // anything to them.
     if (_heap->has_forwarded_objects()) {
       ShenandoahCMKeepAliveUpdateClosure keep_alive(get_queue(serial_worker_id));
       rp->process_discovered_references(is_alive.is_alive_closure(), &keep_alive,
                                         &complete_gc, &executor,
                                         &pt);
 
-      ShenandoahWeakUpdateClosure cl;
-      WeakProcessor::weak_oops_do(workers, is_alive.is_alive_closure(), &cl, 1);
     } else {
       ShenandoahCMKeepAliveClosure keep_alive(get_queue(serial_worker_id));
       rp->process_discovered_references(is_alive.is_alive_closure(), &keep_alive,
                                         &complete_gc, &executor,
                                         &pt);
 
-      ShenandoahWeakAssertNotForwardedClosure cl;
-      WeakProcessor::weak_oops_do(is_alive.is_alive_closure(), &cl);
     }
 
     pt.print_all_references();
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
  *
  * 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
@@ -86,6 +86,8 @@
   void weak_refs_work(bool full_gc);
   void weak_refs_work_doit(bool full_gc);
 
+  void weak_roots_work();
+
 public:
   void preclean_weak_refs();
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -31,8 +31,8 @@
  * Provides safe handling of out-of-memory situations during evacuation.
  *
  * When a Java thread encounters out-of-memory while evacuating an object in a
- * write-barrier (i.e. it cannot copy the object to to-space), it does not necessarily
- * follow we can return immediately from the WB (and store to from-space).
+ * load-reference-barrier (i.e. it cannot copy the object to to-space), it does not
+ * necessarily follow we can return immediately from the LRB (and store to from-space).
  *
  * In very basic case, on such failure we may wait until the the evacuation is over,
  * and then resolve the forwarded copy, and to the store there. This is possible
@@ -64,17 +64,17 @@
  * - failure:
  *   - if offending value is a valid counter, then try again
  *   - if offending value is OOM-during-evac special value: loop until
- *     counter drops to 0, then exit with read-barrier
+ *     counter drops to 0, then exit with resolving the ptr
  *
  * Upon exit, exiting thread will decrease the counter using atomic dec.
  *
  * Upon OOM-during-evac, any thread will attempt to CAS OOM-during-evac
  * special value into the counter. Depending on result:
- *   - success: busy-loop until counter drops to zero, then exit with RB
+ *   - success: busy-loop until counter drops to zero, then exit with resolve
  *   - failure:
  *     - offender is valid counter update: try again
  *     - offender is OOM-during-evac: busy loop until counter drops to
- *       zero, then exit with RB
+ *       zero, then exit with resolve
  */
 class ShenandoahEvacOOMHandler {
 private:
@@ -94,7 +94,7 @@
    *
    * When this returns true, it is safe to continue with normal evacuation.
    * When this method returns false, evacuation must not be entered, and caller
-   * may safely continue with a read-barrier (if Java thread).
+   * may safely continue with a simple resolve (if Java thread).
    */
   void enter_evacuation();
 
@@ -106,7 +106,7 @@
   /**
    * Signal out-of-memory during evacuation. It will prevent any other threads
    * from entering the evacuation path, then wait until all threads have left the
-   * evacuation path, and then return. It is then safe to continue with a read-barrier.
+   * evacuation path, and then return. It is then safe to continue with a simple resolve.
    */
   void handle_out_of_memory_during_evacuation();
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -389,10 +389,6 @@
               err_msg("Heuristics \"%s\" is experimental, and must be enabled via -XX:+UnlockExperimentalVMOptions.",
                       _heuristics->name()));
     }
-
-    if (ShenandoahStoreValEnqueueBarrier && ShenandoahStoreValReadBarrier) {
-      vm_exit_during_initialization("Cannot use both ShenandoahStoreValEnqueueBarrier and ShenandoahStoreValReadBarrier");
-    }
     log_info(gc, init)("Shenandoah heuristics: %s",
                        _heuristics->name());
   } else {
@@ -436,6 +432,7 @@
   _cycle_memory_manager("Shenandoah Cycles", "end of GC cycle"),
   _gc_timer(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()),
   _soft_ref_policy(),
+  _log_min_obj_alignment_in_bytes(LogMinObjAlignmentInBytes),
   _ref_processor(NULL),
   _marking_context(NULL),
   _bitmap_size(0),
@@ -790,7 +787,7 @@
     assert(req.is_gc_alloc(), "Can only accept GC allocs here");
     result = allocate_memory_under_lock(req, in_new_region);
     // Do not call handle_alloc_failure() here, because we cannot block.
-    // The allocation failure would be handled by the WB slowpath with handle_alloc_failure_evac().
+    // The allocation failure would be handled by the LRB slowpath with handle_alloc_failure_evac().
   }
 
   if (in_new_region) {
@@ -1104,7 +1101,6 @@
     ShenandoahParallelWorkerSession worker_session(worker_id);
     ShenandoahEvacOOMScope oom_evac_scope;
     ShenandoahEvacuateUpdateRootsClosure cl;
-
     MarkingCodeBlobClosure blobsCl(&cl, CodeBlobToOopClosure::FixRelocations);
     _rp->process_evacuate_roots(&cl, &blobsCl, worker_id);
   }
@@ -1127,16 +1123,6 @@
 #endif
 }
 
-void ShenandoahHeap::roots_iterate(OopClosure* cl) {
-  assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Only iterate roots while world is stopped");
-
-  CodeBlobToOopClosure blobsCl(cl, false);
-  CLDToOopClosure cldCl(cl, ClassLoaderData::_claim_strong);
-
-  ShenandoahRootProcessor rp(this, 1, ShenandoahPhaseTimings::_num_phases);
-  rp.process_all_roots(cl, NULL, &cldCl, &blobsCl, NULL, 0);
-}
-
 // Returns size in bytes
 size_t ShenandoahHeap::unsafe_max_tlab_alloc(Thread *thread) const {
   if (ShenandoahElasticTLAB) {
@@ -1218,7 +1204,9 @@
 
 void ShenandoahHeap::gc_threads_do(ThreadClosure* tcl) const {
   workers()->threads_do(tcl);
-  _safepoint_workers->threads_do(tcl);
+  if (_safepoint_workers != NULL) {
+    _safepoint_workers->threads_do(tcl);
+  }
   if (ShenandoahStringDedup::is_enabled()) {
     ShenandoahStringDedup::threads_do(tcl);
   }
@@ -1337,7 +1325,7 @@
   ObjectIterateScanRootClosure oops(&_aux_bit_map, &oop_stack);
   CLDToOopClosure clds(&oops, ClassLoaderData::_claim_none);
   CodeBlobToOopClosure blobs(&oops, false);
-  rp.process_all_roots(&oops, &oops, &clds, &blobs, NULL, 0);
+  rp.process_all_roots(&oops, &clds, &blobs, NULL, 0);
 
   // Work through the oop stack to traverse heap.
   while (! oop_stack.is_empty()) {
@@ -1559,6 +1547,10 @@
       if (ShenandoahPacing) {
         pacer()->setup_for_evac();
       }
+
+      if (ShenandoahVerify) {
+        verifier()->verify_during_evacuation();
+      }
     } else {
       if (ShenandoahVerify) {
         verifier()->verify_after_concmark();
@@ -1809,13 +1801,13 @@
 
 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();
   }
-  set_concurrent_mark_in_progress(false);
 }
 
 void ShenandoahHeap::force_satb_flush_all_threads() {
@@ -1845,12 +1837,16 @@
 }
 
 void ShenandoahHeap::set_concurrent_mark_in_progress(bool in_progress) {
-  set_gc_state_mask(MARKING, in_progress);
+  if (has_forwarded_objects()) {
+    set_gc_state_mask(MARKING | UPDATEREFS, in_progress);
+  } else {
+    set_gc_state_mask(MARKING, in_progress);
+  }
   ShenandoahBarrierSet::satb_mark_queue_set().set_active_all_threads(in_progress, !in_progress);
 }
 
 void ShenandoahHeap::set_concurrent_traversal_in_progress(bool in_progress) {
-   set_gc_state_mask(TRAVERSAL | HAS_FORWARDED, in_progress);
+   set_gc_state_mask(TRAVERSAL | HAS_FORWARDED | UPDATEREFS, in_progress);
    ShenandoahBarrierSet::satb_mark_queue_set().set_active_all_threads(in_progress, !in_progress);
 }
 
@@ -2071,14 +2067,12 @@
 }
 
 oop ShenandoahHeap::pin_object(JavaThread* thr, oop o) {
-  o = ShenandoahBarrierSet::barrier_set()->write_barrier(o);
   ShenandoahHeapLocker locker(lock());
   heap_region_containing(o)->make_pinned();
   return o;
 }
 
 void ShenandoahHeap::unpin_object(JavaThread* thr, oop o) {
-  o = ShenandoahBarrierSet::barrier_set()->read_barrier(o);
   ShenandoahHeapLocker locker(lock());
   heap_region_containing(o)->make_unpinned();
 }
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -270,16 +270,16 @@
 //
 public:
   enum GCStateBitPos {
-    // Heap has forwarded objects: need RB, ACMP, CAS barriers.
+    // Heap has forwarded objects: needs LRB barriers.
     HAS_FORWARDED_BITPOS   = 0,
 
     // Heap is under marking: needs SATB barriers.
     MARKING_BITPOS    = 1,
 
-    // Heap is under evacuation: needs WB barriers. (Set together with UNSTABLE)
+    // Heap is under evacuation: needs LRB barriers. (Set together with HAS_FORWARDED)
     EVACUATION_BITPOS = 2,
 
-    // Heap is under updating: needs SVRB/SVWB barriers.
+    // Heap is under updating: needs no additional barriers.
     UPDATEREFS_BITPOS = 3,
 
     // Heap is under traversal collection
@@ -505,6 +505,8 @@
   ConcurrentGCTimer*           _gc_timer;
   SoftRefPolicy                _soft_ref_policy;
 
+  // For exporting to SA
+  int                          _log_min_obj_alignment_in_bytes;
 public:
   ShenandoahMonitoringSupport* monitoring_support() { return _monitoring_support;    }
   GCMemoryManager* cycle_memory_manager()           { return &_cycle_memory_manager; }
@@ -584,6 +586,8 @@
 public:
   void register_nmethod(nmethod* nm);
   void unregister_nmethod(nmethod* nm);
+  void flush_nmethod(nmethod* nm) {}
+  void verify_nmethod(nmethod* nm) {}
 
 // ---------- Pinning hooks
 //
@@ -742,8 +746,6 @@
 
   void stop_concurrent_marking();
 
-  void roots_iterate(OopClosure* cl);
-
 private:
   void trash_cset_regions();
   void update_heap_references(bool concurrent);
--- a/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -35,7 +35,7 @@
 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 #include "gc/shenandoah/shenandoahHeuristics.hpp"
 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
-#include "gc/shenandoah/shenandoahRootProcessor.hpp"
+#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
 #include "gc/shenandoah/shenandoahTraversalGC.hpp"
 #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
 #include "gc/shenandoah/shenandoahUtils.hpp"
@@ -129,7 +129,7 @@
 
   // Once marking is done, which may have fixed up forwarded objects, we can drop it.
   // Coming out of Full GC, we would not have any forwarded objects.
-  // This also prevents read barrier from kicking in while adjusting pointers in phase3.
+  // This also prevents resolves with fwdptr from kicking in while adjusting pointers in phase3.
   heap->set_has_forwarded_objects(false);
 
   heap->set_full_gc_move_in_progress(true);
@@ -572,9 +572,9 @@
     MarkingCodeBlobClosure adjust_code_closure(&cl,
                                              CodeBlobToOopClosure::FixRelocations);
 
-    _rp->process_all_roots(&cl, &cl,
-                           &adjust_cld_closure,
-                           &adjust_code_closure, NULL, worker_id);
+    _rp->update_all_roots<AlwaysTrueClosure>(&cl,
+                                             &adjust_cld_closure,
+                                             &adjust_code_closure, NULL, worker_id);
   }
 };
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -34,7 +34,7 @@
 
 enum UpdateRefsMode {
   NONE,       // No reference updating
-  RESOLVE,    // Only a read-barrier (no reference updating)
+  RESOLVE,    // Only a resolve (no reference updating)
   SIMPLE,     // Reference updating using simple store
   CONCURRENT  // Reference updating using CAS
 };
@@ -184,24 +184,16 @@
   virtual bool do_metadata()        { return true; }
 };
 
-class ShenandoahUpdateHeapRefsSuperClosure : public BasicOopIterateClosure {
+class ShenandoahUpdateHeapRefsClosure : public BasicOopIterateClosure {
 private:
   ShenandoahHeap* _heap;
-public:
-  ShenandoahUpdateHeapRefsSuperClosure() :
-    _heap(ShenandoahHeap::heap()) {}
 
   template <class T>
-  void work(T *p);
-};
-
-class ShenandoahUpdateHeapRefsClosure : public ShenandoahUpdateHeapRefsSuperClosure {
-private:
-  template <class T>
-  inline  void do_oop_work(T* p)    { work<T>(p); }
+  void do_oop_work(T* p);
 
 public:
-  ShenandoahUpdateHeapRefsClosure() : ShenandoahUpdateHeapRefsSuperClosure() {}
+  ShenandoahUpdateHeapRefsClosure() :
+    _heap(ShenandoahHeap::heap()) {}
 
   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
   virtual void do_oop(oop* p)       { do_oop_work(p); }
--- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -34,7 +34,7 @@
 }
 
 template <class T>
-inline void ShenandoahUpdateHeapRefsSuperClosure::work(T* p) {
+inline void ShenandoahUpdateHeapRefsClosure::do_oop_work(T* p) {
   _heap->maybe_update_with_forwarded(p);
 }
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -119,14 +119,9 @@
   Management::oops_do(oops);
   JvmtiExport::oops_do(oops);
   JNIHandles::oops_do(oops);
-  WeakProcessor::oops_do(oops);
   ObjectSynchronizer::oops_do(oops);
   SystemDictionary::oops_do(oops);
 
-  if (ShenandoahStringDedup::is_enabled()) {
-    ShenandoahStringDedup::oops_do_slow(oops);
-  }
-
   // Do thread roots the last. This allows verification code to find
   // any broken objects from those special roots first, not the accidental
   // dangling reference from the thread root.
@@ -134,21 +129,18 @@
 }
 
 void ShenandoahRootProcessor::process_strong_roots(OopClosure* oops,
-                                                   OopClosure* weak_oops,
                                                    CLDClosure* clds,
-                                                   CLDClosure* weak_clds,
                                                    CodeBlobClosure* blobs,
                                                    ThreadClosure* thread_cl,
                                                    uint worker_id) {
 
-  process_java_roots(oops, clds, weak_clds, blobs, thread_cl, worker_id);
-  process_vm_roots(oops, NULL, weak_oops, worker_id);
+  process_java_roots(oops, clds, NULL, blobs, thread_cl, worker_id);
+  process_vm_roots(oops, worker_id);
 
   _process_strong_tasks->all_tasks_completed(n_workers());
 }
 
 void ShenandoahRootProcessor::process_all_roots(OopClosure* oops,
-                                                OopClosure* weak_oops,
                                                 CLDClosure* clds,
                                                 CodeBlobClosure* blobs,
                                                 ThreadClosure* thread_cl,
@@ -156,7 +148,7 @@
 
   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
   process_java_roots(oops, clds, clds, blobs, thread_cl, worker_id);
-  process_vm_roots(oops, oops, weak_oops, worker_id);
+  process_vm_roots(oops, worker_id);
 
   if (blobs != NULL) {
     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
@@ -164,6 +156,7 @@
   }
 
   _process_strong_tasks->all_tasks_completed(n_workers());
+
 }
 
 class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
@@ -209,10 +202,7 @@
 }
 
 void ShenandoahRootProcessor::process_vm_roots(OopClosure* strong_roots,
-                                               OopClosure* weak_roots,
-                                               OopClosure* jni_weak_roots,
-                                               uint worker_id)
-{
+                                               uint worker_id) {
   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
   if (_process_strong_tasks->try_claim_task(SHENANDOAH_RP_PS_Universe_oops_do)) {
     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::UniverseRoots, worker_id);
@@ -235,15 +225,6 @@
     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::SystemDictionaryRoots, worker_id);
     SystemDictionary::oops_do(strong_roots);
   }
-  if (jni_weak_roots != NULL) {
-    AlwaysTrueClosure always_true;
-    _weak_processor_task.work<AlwaysTrueClosure, OopClosure>(worker_id, &always_true, jni_weak_roots);
-    _processed_weak_roots = true;
-  }
-
-  if (ShenandoahStringDedup::is_enabled() && weak_roots != NULL) {
-    ShenandoahStringDedup::parallel_oops_do(weak_roots, worker_id);
-  }
 
   {
     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ObjectSynchronizerRoots, worker_id);
@@ -261,13 +242,21 @@
   _evacuation_tasks(new SubTasksDone(SHENANDOAH_EVAC_NumElements)),
   _srs(n_workers),
   _phase(phase),
-  _coderoots_cset_iterator(ShenandoahCodeRoots::cset_iterator())
+  _coderoots_cset_iterator(ShenandoahCodeRoots::cset_iterator()),
+  _par_state_string(StringTable::weak_storage())
+
 {
   heap->phase_timings()->record_workers_start(_phase);
+  if (ShenandoahStringDedup::is_enabled()) {
+    StringDedup::gc_prologue(false);
+  }
 }
 
 ShenandoahRootEvacuator::~ShenandoahRootEvacuator() {
   delete _evacuation_tasks;
+  if (ShenandoahStringDedup::is_enabled()) {
+    StringDedup::gc_epilogue();
+  }
   ShenandoahHeap::heap()->phase_timings()->record_workers_end(_phase);
 }
 
@@ -289,11 +278,38 @@
     _coderoots_cset_iterator.possibly_parallel_blobs_do(blobs);
   }
 
-  if (_evacuation_tasks->try_claim_task(SHENANDOAH_EVAC_jvmti_oops_do)) {
+  if (ShenandoahStringDedup::is_enabled()) {
     ShenandoahForwardedIsAliveClosure is_alive;
+    ShenandoahStringDedup::parallel_oops_do(&is_alive, oops, worker_id);
+  }
+
+  if (_evacuation_tasks->try_claim_task(SHENANDOAH_EVAC_Universe_oops_do)) {
+    ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::UniverseRoots, worker_id);
+    Universe::oops_do(oops);
+  }
+
+  if (_evacuation_tasks->try_claim_task(SHENANDOAH_EVAC_Management_oops_do)) {
+    ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ManagementRoots, worker_id);
+    Management::oops_do(oops);
+  }
+
+  if (_evacuation_tasks->try_claim_task(SHENANDOAH_EVAC_jvmti_oops_do)) {
     ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::JVMTIRoots, worker_id);
+    JvmtiExport::oops_do(oops);
+    ShenandoahForwardedIsAliveClosure is_alive;
     JvmtiExport::weak_oops_do(&is_alive, oops);
   }
+
+  if (_evacuation_tasks->try_claim_task(SHENANDOAH_EVAC_SystemDictionary_oops_do)) {
+    ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::SystemDictionaryRoots, worker_id);
+    SystemDictionary::oops_do(oops);
+  }
+
+  if (_evacuation_tasks->try_claim_task(SHENANDOAH_EVAC_ObjectSynchronizer_oops_do)) {
+    ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::ObjectSynchronizerRoots, worker_id);
+    ObjectSynchronizer::oops_do(oops);
+  }
+
 }
 
 uint ShenandoahRootEvacuator::n_workers() const {
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -58,7 +58,7 @@
   StrongRootsScope _srs;
   OopStorage::ParState<false, false> _par_state_string;
   ShenandoahPhaseTimings::Phase _phase;
-  ParallelCLDRootIterator   _cld_iterator;
+  ParallelCLDRootIterator _cld_iterator;
   ShenandoahAllCodeRootsIterator _coderoots_all_iterator;
   CodeBlobClosure* _threads_nmethods_cl;
   WeakProcessorPhaseTimes _weak_processor_timings;
@@ -73,8 +73,6 @@
                           uint worker_i);
 
   void process_vm_roots(OopClosure* scan_non_heap_roots,
-                        OopClosure* scan_non_heap_weak_roots,
-                        OopClosure* weak_jni_roots,
                         uint worker_i);
 
   void weak_processor_timing_to_shenandoah_timing(const WeakProcessorPhases::Phase wpp,
@@ -86,21 +84,30 @@
                           ShenandoahPhaseTimings::Phase phase);
   ~ShenandoahRootProcessor();
 
-  // Apply oops, clds and blobs to all strongly reachable roots in the system
-  void process_strong_roots(OopClosure* oops, OopClosure* weak_oops,
+  // Apply oops, clds and blobs to all strongly reachable roots in the system.
+  // Optionally, apply class loader closure to weak clds, depending on class unloading
+  // for the particular GC cycles.
+  void process_strong_roots(OopClosure* oops,
                             CLDClosure* clds,
-                            CLDClosure* weak_clds,
                             CodeBlobClosure* blobs,
                             ThreadClosure* thread_cl,
                             uint worker_id);
 
-  // Apply oops, clds and blobs to strongly and weakly reachable roots in the system
-  void process_all_roots(OopClosure* oops, OopClosure* weak_oops,
+  // Apply oops, clds and blobs to strongly reachable roots in the system
+  void process_all_roots(OopClosure* oops,
                          CLDClosure* clds,
                          CodeBlobClosure* blobs,
                          ThreadClosure* thread_cl,
                          uint worker_id);
 
+  // Apply oops, clds and blobs to strongly and weakly reachable roots in the system
+  template <typename IsAlive>
+  void update_all_roots(OopClosure* oops,
+                        CLDClosure* clds,
+                        CodeBlobClosure* blobs,
+                        ThreadClosure* thread_cl,
+                        uint worker_id);
+
   // For slow debug/verification code
   void process_all_roots_slow(OopClosure* oops);
 
@@ -113,11 +120,16 @@
   StrongRootsScope _srs;
   ShenandoahPhaseTimings::Phase _phase;
   ShenandoahCsetCodeRootsIterator _coderoots_cset_iterator;
+  OopStorage::ParState<false, false> _par_state_string;
 
   enum Shenandoah_evacuate_roots_tasks {
-      SHENANDOAH_EVAC_jvmti_oops_do,
-      // Leave this one last.
-      SHENANDOAH_EVAC_NumElements
+    SHENANDOAH_EVAC_Universe_oops_do,
+    SHENANDOAH_EVAC_ObjectSynchronizer_oops_do,
+    SHENANDOAH_EVAC_Management_oops_do,
+    SHENANDOAH_EVAC_SystemDictionary_oops_do,
+    SHENANDOAH_EVAC_jvmti_oops_do,
+    // Leave this one last.
+    SHENANDOAH_EVAC_NumElements
   };
 public:
   ShenandoahRootEvacuator(ShenandoahHeap* heap, uint n_workers,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
+ *
+ * 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_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
+#define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
+
+#include "gc/shenandoah/shenandoahRootProcessor.hpp"
+
+template <typename IsAlive>
+void ShenandoahRootProcessor::update_all_roots(OopClosure* oops,
+                                               CLDClosure* clds,
+                                               CodeBlobClosure* blobs,
+                                               ThreadClosure* thread_cl,
+                                               uint worker_id) {
+  process_all_roots(oops, clds, blobs, thread_cl, worker_id);
+
+  IsAlive is_alive;
+  _weak_processor_task.work<IsAlive, OopClosure>(worker_id, &is_alive, oops);
+  _processed_weak_roots = true;
+
+  if (ShenandoahStringDedup::is_enabled()) {
+    ShenandoahStringDedup::parallel_oops_do(&is_alive, oops, worker_id);
+  }
+}
+
+#endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_INLINE_HPP
--- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -51,11 +51,12 @@
   }
   shenandoah_assert_correct(NULL, orig);
   // store the original value that was in the field reference
-  ShenandoahThreadLocalData::satb_mark_queue(thread).enqueue(orig);
+  assert(ShenandoahThreadLocalData::satb_mark_queue(thread).is_active(), "Shouldn't be here otherwise");
+  ShenandoahThreadLocalData::satb_mark_queue(thread).enqueue_known_active(orig);
 JRT_END
 
-JRT_LEAF(oopDesc*, ShenandoahRuntime::write_barrier_JRT(oopDesc* src))
-  oop result = ShenandoahBarrierSet::barrier_set()->write_barrier_mutator(src);
+JRT_LEAF(oopDesc*, ShenandoahRuntime::load_reference_barrier_JRT(oopDesc* src))
+  oop result = ShenandoahBarrierSet::barrier_set()->load_reference_barrier_mutator(src);
   return (oopDesc*) result;
 JRT_END
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -37,7 +37,7 @@
   static void write_ref_array_post_entry(HeapWord* dst, size_t length);
   static void write_ref_field_pre_entry(oopDesc* orig, JavaThread* thread);
 
-  static oopDesc* write_barrier_JRT(oopDesc* src);
+  static oopDesc* load_reference_barrier_JRT(oopDesc* src);
 
   static void shenandoah_clone_barrier(oopDesc* obj);
 };
--- a/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -71,13 +71,13 @@
   StringDedupTable::deduplicate(java_string, &dummy);
 }
 
-void ShenandoahStringDedup::parallel_oops_do(OopClosure* cl, uint worker_id) {
+void ShenandoahStringDedup::parallel_oops_do(BoolObjectClosure* is_alive, OopClosure* cl, uint worker_id) {
   assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
   assert(is_enabled(), "String deduplication not enabled");
 
   ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
 
-  StringDedupUnlinkOrOopsDoClosure sd_cl(NULL, cl);
+  StringDedupUnlinkOrOopsDoClosure sd_cl(is_alive, cl);
 
   {
     ShenandoahWorkerTimingsTracker x(worker_times, ShenandoahPhaseTimings::StringDedupQueueRoots, worker_id);
--- a/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -38,11 +38,11 @@
   // Deduplicate a string, the call is lock-free
   static void deduplicate(oop java_string);
 
-  static void parallel_oops_do(OopClosure* cl, uint worker_id);
+  static void parallel_oops_do(BoolObjectClosure* is_alive, OopClosure* cl, uint worker_id);
   static void oops_do_slow(OopClosure* cl);
 
   static inline bool is_candidate(oop obj);
-private:
+
   static void unlink_or_oops_do(BoolObjectClosure* is_alive,
                                 OopClosure* keep_alive,
                                 bool allow_resize_and_rehash);
--- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -40,7 +40,7 @@
 #include "gc/shenandoah/shenandoahHeuristics.hpp"
 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
 #include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
-#include "gc/shenandoah/shenandoahRootProcessor.hpp"
+#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
 #include "gc/shenandoah/shenandoahStringDedup.hpp"
 #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp"
 #include "gc/shenandoah/shenandoahTimingTracker.hpp"
@@ -188,13 +188,13 @@
       ShenandoahMarkCLDClosure cld_cl(&roots_cl);
       MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations);
       if (unload_classes) {
-        _rp->process_strong_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, NULL, NULL, NULL, worker_id);
+        _rp->process_strong_roots(&roots_cl, &cld_cl, NULL, NULL, worker_id);
         // Need to pre-evac code roots here. Otherwise we might see from-space constants.
         ShenandoahWorkerTimings* worker_times = _heap->phase_timings()->worker_times();
         ShenandoahWorkerTimingsTracker timer(worker_times, ShenandoahPhaseTimings::CodeCacheRoots, worker_id);
         _cset_coderoots->possibly_parallel_blobs_do(&code_cl);
       } else {
-        _rp->process_all_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &code_cl, NULL, worker_id);
+        _rp->process_all_roots(&roots_cl, &cld_cl, &code_cl, NULL, worker_id);
       }
     }
   }
@@ -269,20 +269,20 @@
       CLDToOopClosure cld_cl(&roots_cl, ClassLoaderData::_claim_strong);
       ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
       if (unload_classes) {
-        ShenandoahRemarkCLDClosure weak_cld_cl(&roots_cl);
-        _rp->process_strong_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &weak_cld_cl, NULL, &tc, worker_id);
+        ShenandoahRemarkCLDClosure remark_cld_cl(&roots_cl);
+        _rp->process_strong_roots(&roots_cl, &remark_cld_cl, NULL, &tc, worker_id);
       } else {
-        _rp->process_all_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, NULL, &tc, worker_id);
+        _rp->process_all_roots(&roots_cl, &cld_cl, NULL, &tc, worker_id);
       }
     } else {
       ShenandoahTraversalDegenClosure roots_cl(q, rp);
       CLDToOopClosure cld_cl(&roots_cl, ClassLoaderData::_claim_strong);
       ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
       if (unload_classes) {
-        ShenandoahRemarkCLDClosure weak_cld_cl(&roots_cl);
-        _rp->process_strong_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &weak_cld_cl, NULL, &tc, worker_id);
+        ShenandoahRemarkCLDClosure remark_cld_cl(&roots_cl);
+        _rp->process_strong_roots(&roots_cl, &remark_cld_cl, NULL, &tc, worker_id);
       } else {
-        _rp->process_all_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, NULL, &tc, worker_id);
+        _rp->process_all_roots(&roots_cl, &cld_cl, NULL, &tc, worker_id);
       }
     }
 
@@ -594,8 +594,11 @@
     weak_refs_work();
   }
 
-  if (!_heap->cancelled_gc() && _heap->unload_classes()) {
-    _heap->unload_classes_and_cleanup_tables(false);
+  if (!_heap->cancelled_gc()) {
+    if (_heap->unload_classes()) {
+      _heap->unload_classes_and_cleanup_tables(false);
+    }
+
     fixup_roots();
   }
 
@@ -691,14 +694,16 @@
 public:
   ShenandoahTraversalFixRootsTask(ShenandoahRootProcessor* rp) :
     AbstractGangTask("Shenandoah traversal fix roots"),
-    _rp(rp) {}
+    _rp(rp) {
+    assert(ShenandoahHeap::heap()->has_forwarded_objects(), "Must be");
+  }
 
   void work(uint worker_id) {
     ShenandoahParallelWorkerSession worker_session(worker_id);
     ShenandoahTraversalFixRootsClosure cl;
     MarkingCodeBlobClosure blobsCl(&cl, CodeBlobToOopClosure::FixRelocations);
     CLDToOopClosure cldCl(&cl, ClassLoaderData::_claim_strong);
-    _rp->process_all_roots(&cl, &cl, &cldCl, &blobsCl, NULL, worker_id);
+    _rp->update_all_roots<ShenandoahForwardedIsAliveClosure>(&cl, &cldCl, &blobsCl, NULL, worker_id);
   }
 };
 
--- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -628,6 +628,10 @@
         enabled = true;
         expected = ShenandoahHeap::HAS_FORWARDED;
         break;
+      case _verify_gcstate_evacuation:
+        enabled = true;
+        expected = ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::EVACUATION;
+        break;
       case _verify_gcstate_stable:
         enabled = true;
         expected = ShenandoahHeap::STABLE;
@@ -808,6 +812,18 @@
   );
 }
 
+void ShenandoahVerifier::verify_during_evacuation() {
+  verify_at_safepoint(
+          "During Evacuation",
+          _verify_forwarded_allow,   // some forwarded references are allowed
+          _verify_marked_disable,    // walk only roots
+          _verify_cset_disable,      // some cset references are not forwarded yet
+          _verify_liveness_disable,  // liveness data might be already stale after pre-evacs
+          _verify_regions_disable,   // trash regions not yet recycled
+          _verify_gcstate_evacuation // evacuation is in progress
+  );
+}
+
 void ShenandoahVerifier::verify_after_evacuation() {
   verify_at_safepoint(
           "After Evacuation",
--- a/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahVerifier.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -135,6 +135,9 @@
 
     // Nothing is in progress, some objects are forwarded
     _verify_gcstate_forwarded,
+
+    // Evacuation is in progress, some objects are forwarded
+    _verify_gcstate_evacuation,
   } VerifyGCState;
 
   struct VerifyOptions {
@@ -173,6 +176,7 @@
   void verify_before_concmark();
   void verify_after_concmark();
   void verify_before_evacuation();
+  void verify_during_evacuation();
   void verify_after_evacuation();
   void verify_before_updaterefs();
   void verify_after_updaterefs();
--- a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -244,7 +244,7 @@
           "Time is in microseconds.")                                       \
                                                                             \
   experimental(uintx, ShenandoahEvacAssist, 10,                             \
-          "How many objects to evacuate on WB assist path. "                \
+          "How many objects to evacuate on LRB assist path. "               \
           "Use zero to disable.")                                           \
                                                                             \
   experimental(bool, ShenandoahPacing, true,                                \
@@ -352,27 +352,18 @@
   diagnostic(bool, ShenandoahKeepAliveBarrier, true,                        \
           "Turn on/off keep alive barriers in Shenandoah")                  \
                                                                             \
-  diagnostic(bool, ShenandoahWriteBarrier, true,                            \
-          "Turn on/off write barriers in Shenandoah")                       \
-                                                                            \
-  diagnostic(bool, ShenandoahReadBarrier, true,                             \
-          "Turn on/off read barriers in Shenandoah")                        \
-                                                                            \
   diagnostic(bool, ShenandoahStoreValEnqueueBarrier, false,                 \
           "Turn on/off enqueuing of oops for storeval barriers")            \
                                                                             \
-  diagnostic(bool, ShenandoahStoreValReadBarrier, true,                     \
-          "Turn on/off store val read barriers in Shenandoah")              \
-                                                                            \
   diagnostic(bool, ShenandoahCASBarrier, true,                              \
           "Turn on/off CAS barriers in Shenandoah")                         \
                                                                             \
-  diagnostic(bool, ShenandoahAcmpBarrier, true,                             \
-          "Turn on/off acmp barriers in Shenandoah")                        \
-                                                                            \
   diagnostic(bool, ShenandoahCloneBarrier, true,                            \
           "Turn on/off clone barriers in Shenandoah")                       \
                                                                             \
+  diagnostic(bool, ShenandoahLoadRefBarrier, true,                          \
+          "Turn on/off load-reference barriers in Shenandoah")              \
+                                                                            \
   diagnostic(bool, ShenandoahStoreCheck, false,                             \
           "Emit additional code that checks objects are written to only"    \
           " in to-space")                                                   \
@@ -401,20 +392,13 @@
           "Turn it off for maximum compatibility with reflection or JNI "   \
           "code that manipulates final fields.")                            \
                                                                             \
-  diagnostic(bool, ShenandoahDecreaseRegisterPressure, false,               \
-          "Try to reuse after-barrier values to reduce register pressure")  \
-                                                                            \
   experimental(bool, ShenandoahCommonGCStateLoads, false,                   \
          "Enable commonming for GC state loads in generated code.")         \
                                                                             \
   develop(bool, ShenandoahVerifyOptoBarriers, false,                        \
           "Verify no missing barriers in C2")                               \
                                                                             \
-  experimental(bool, ShenandoahDontIncreaseWBFreq, true,                    \
-          "Common 2 WriteBarriers or WriteBarrier and a ReadBarrier only "  \
-          "if the resulting WriteBarrier isn't executed more frequently")   \
-                                                                            \
   experimental(bool, ShenandoahLoopOptsAfterExpansion, true,                \
-          "Attempt more loop opts after write barrier expansion")           \
+          "Attempt more loop opts after barrier expansion")                 \
 
 #endif // SHARE_GC_SHENANDOAH_SHENANDOAH_GLOBALS_HPP
--- a/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
  *
  * 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
@@ -27,13 +27,28 @@
 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
 
-#define VM_STRUCTS_SHENANDOAH(nonstatic_field, volatile_nonstatic_field, static_field)  \
-  static_field(ShenandoahHeapRegion, RegionSizeBytes,        size_t)                    \
-  nonstatic_field(ShenandoahHeap, _num_regions,              size_t)                    \
-  volatile_nonstatic_field(ShenandoahHeap, _used,            size_t)                    \
-  volatile_nonstatic_field(ShenandoahHeap, _committed,       size_t)                    \
+#define VM_STRUCTS_SHENANDOAH(nonstatic_field, volatile_nonstatic_field, static_field)                \
+  nonstatic_field(ShenandoahHeap, _num_regions,                    size_t)                            \
+  nonstatic_field(ShenandoahHeap, _regions,                        ShenandoahHeapRegion**)            \
+  nonstatic_field(ShenandoahHeap, _log_min_obj_alignment_in_bytes, int)                               \
+  volatile_nonstatic_field(ShenandoahHeap, _used,                  size_t)                            \
+  volatile_nonstatic_field(ShenandoahHeap, _committed,             size_t)                            \
+  static_field(ShenandoahHeapRegion, RegionSizeBytes,              size_t)                            \
+  static_field(ShenandoahHeapRegion, RegionSizeBytesShift,         size_t)                            \
+  nonstatic_field(ShenandoahHeapRegion, _state,                    ShenandoahHeapRegion::RegionState) \
+  nonstatic_field(ShenandoahHeapRegion, _region_number,            size_t)                            \
 
-#define VM_INT_CONSTANTS_SHENANDOAH(declare_constant, declare_constant_with_value)
+#define VM_INT_CONSTANTS_SHENANDOAH(declare_constant, declare_constant_with_value) \
+  declare_constant(ShenandoahHeapRegion::_empty_uncommitted)                       \
+  declare_constant(ShenandoahHeapRegion::_empty_committed)                         \
+  declare_constant(ShenandoahHeapRegion::_regular)                                 \
+  declare_constant(ShenandoahHeapRegion::_humongous_start)                         \
+  declare_constant(ShenandoahHeapRegion::_humongous_cont)                          \
+  declare_constant(ShenandoahHeapRegion::_pinned_humongous_start)                  \
+  declare_constant(ShenandoahHeapRegion::_cset)                                    \
+  declare_constant(ShenandoahHeapRegion::_pinned)                                  \
+  declare_constant(ShenandoahHeapRegion::_pinned_cset)                             \
+  declare_constant(ShenandoahHeapRegion::_trash)                                   \
 
 #define VM_TYPES_SHENANDOAH(declare_type,                                     \
                             declare_toplevel_type,                            \
@@ -42,5 +57,6 @@
   declare_type(ShenandoahHeapRegion, ContiguousSpace)                         \
   declare_toplevel_type(ShenandoahHeap*)                                      \
   declare_toplevel_type(ShenandoahHeapRegion*)                                \
+  declare_toplevel_type(ShenandoahHeapRegion::RegionState)                    \
 
 #endif // SHARE_GC_SHENANDOAH_VMSTRUCTS_SHENANDOAH_HPP
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -194,9 +194,9 @@
   return sizeof(*this);
 }
 
-uint LoadBarrierNode::cmp(const Node& n) const {
+bool LoadBarrierNode::cmp(const Node& n) const {
   ShouldNotReachHere();
-  return 0;
+  return false;
 }
 
 const Type *LoadBarrierNode::bottom_type() const {
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -63,7 +63,7 @@
 
   virtual int Opcode() const;
   virtual uint size_of() const;
-  virtual uint cmp(const Node& n) const;
+  virtual bool cmp(const Node& n) const;
   virtual const Type *bottom_type() const;
   virtual const TypePtr* adr_type() const;
   virtual const Type *Value(PhaseGVN *phase) const;
--- a/src/hotspot/share/gc/z/zCollectedHeap.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zCollectedHeap.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -110,8 +110,8 @@
   return is_in_reserved(p) && _heap.is_in((uintptr_t)p);
 }
 
-bool ZCollectedHeap::is_in_closed_subset(const void* p) const {
-  return is_in(p);
+uint32_t ZCollectedHeap::hash_oop(oop obj) const {
+  return _heap.hash_oop(obj);
 }
 
 HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) {
--- a/src/hotspot/share/gc/z/zCollectedHeap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zCollectedHeap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -72,7 +72,8 @@
 
   virtual bool is_maximal_no_gc() const;
   virtual bool is_in(const void* p) const;
-  virtual bool is_in_closed_subset(const void* p) const;
+
+  virtual uint32_t hash_oop(oop obj) const;
 
   virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
   virtual MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
--- a/src/hotspot/share/gc/z/zForwarding.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zForwarding.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -58,7 +58,7 @@
 
   for (ZForwardingCursor i = 0; i < _entries.length(); i++) {
     const ZForwardingEntry entry = at(&i);
-    if (entry.is_empty()) {
+    if (!entry.populated()) {
       // Skip empty entries
       continue;
     }
--- a/src/hotspot/share/gc/z/zForwarding.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zForwarding.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -119,9 +119,9 @@
 inline ZForwardingEntry ZForwarding::find(uintptr_t from_index, ZForwardingCursor* cursor) const {
   // Reading entries in the table races with the atomic CAS done for
   // insertion into the table. This is safe because each entry is at
-  // most updated once (from -1 to something else).
+  // most updated once (from zero to something else).
   ZForwardingEntry entry = first(from_index, cursor);
-  while (!entry.is_empty()) {
+  while (entry.populated()) {
     if (entry.from_index() == from_index) {
       // Match found, return matching entry
       return entry;
@@ -140,14 +140,14 @@
 
   for (;;) {
     const ZForwardingEntry prev_entry = Atomic::cmpxchg(new_entry, entries() + *cursor, old_entry);
-    if (prev_entry.is_empty()) {
+    if (!prev_entry.populated()) {
       // Success
       return to_offset;
     }
 
     // Find next empty or matching entry
     ZForwardingEntry entry = at(cursor);
-    while (!entry.is_empty()) {
+    while (entry.populated()) {
       if (entry.from_index() == from_index) {
         // Match found, return already inserted address
         return entry.to_offset();
--- a/src/hotspot/share/gc/z/zForwardingEntry.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zForwardingEntry.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -32,40 +32,40 @@
 // Forwarding entry layout
 // -----------------------
 //
-//   6                      4 4                                             0
-//   3                      2 1                                             0
-//  +------------------------+-----------------------------------------------+
-//  |11111111 11111111 111111|11 11111111 11111111 11111111 11111111 11111111|
-//  +------------------------+-----------------------------------------------+
-//  |                        |
-//  |                        * 41-0 To Object Offset (42-bits)
+//   6                  4 4
+//   3                  6 5                                                1 0
+//  +--------------------+--------------------------------------------------+-+
+//  |11111111 11111111 11|111111 11111111 11111111 11111111 11111111 1111111|1|
+//  +--------------------+--------------------------------------------------+-+
+//  |                    |                                                  |
+//  |                    |                      0-0 Populated Flag (1-bits) *
+//  |                    |
+//  |                    * 45-1 To Object Offset (45-bits)
 //  |
-//  * 63-42 From Object Index (22-bits)
+//  * 63-46 From Object Index (18-bits)
 //
 
 class ZForwardingEntry {
   friend struct PrimitiveConversions;
 
 private:
-  typedef ZBitField<uint64_t, size_t, 0,  42> field_to_offset;
-  typedef ZBitField<uint64_t, size_t, 42, 22> field_from_index;
+  typedef ZBitField<uint64_t, bool,   0,   1> field_populated;
+  typedef ZBitField<uint64_t, size_t, 1,  45> field_to_offset;
+  typedef ZBitField<uint64_t, size_t, 46, 18> field_from_index;
 
   uint64_t _entry;
 
-  static uintptr_t empty() {
-    return (uintptr_t)-1;
-  }
-
 public:
   ZForwardingEntry() :
-      _entry(empty()) {}
+      _entry(0) {}
 
   ZForwardingEntry(size_t from_index, size_t to_offset) :
-      _entry(field_from_index::encode(from_index) |
-             field_to_offset::encode(to_offset)) {}
+      _entry(field_populated::encode(true) |
+             field_to_offset::encode(to_offset) |
+             field_from_index::encode(from_index)) {}
 
-  bool is_empty() const {
-    return _entry == empty();
+  bool populated() const {
+    return field_populated::decode(_entry);
   }
 
   size_t to_offset() const {
--- a/src/hotspot/share/gc/z/zHeap.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeap.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -540,16 +540,19 @@
 
 class ZVerifyRootsTask : public ZTask {
 private:
+  ZStatTimerDisable  _disable;
   ZRootsIterator     _strong_roots;
   ZWeakRootsIterator _weak_roots;
 
 public:
   ZVerifyRootsTask() :
       ZTask("ZVerifyRootsTask"),
+      _disable(),
       _strong_roots(),
       _weak_roots() {}
 
   virtual void work() {
+    ZStatTimerDisable disable;
     ZVerifyOopClosure cl;
     _strong_roots.oops_do(&cl);
     _weak_roots.oops_do(&cl);
--- a/src/hotspot/share/gc/z/zHeap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -103,6 +103,7 @@
   size_t unsafe_max_tlab_alloc() const;
 
   bool is_in(uintptr_t addr) const;
+  uint32_t hash_oop(oop obj) const;
 
   // Block
   uintptr_t block_start(uintptr_t addr) const;
--- a/src/hotspot/share/gc/z/zHeap.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeap.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -27,6 +27,7 @@
 #include "gc/z/zAddress.inline.hpp"
 #include "gc/z/zForwarding.inline.hpp"
 #include "gc/z/zForwardingTable.inline.hpp"
+#include "gc/z/zHash.inline.hpp"
 #include "gc/z/zHeap.hpp"
 #include "gc/z/zMark.inline.hpp"
 #include "gc/z/zOop.inline.hpp"
@@ -44,6 +45,11 @@
   return &_reference_processor;
 }
 
+inline uint32_t ZHeap::hash_oop(oop obj) const {
+  const uintptr_t offset = ZAddress::offset(ZOop::to_address(obj));
+  return ZHash::address_to_uint32(offset);
+}
+
 inline bool ZHeap::is_object_live(uintptr_t addr) const {
   ZPage* page = _page_table.get(addr);
   return page->is_object_live(addr);
--- a/src/hotspot/share/gc/z/zHeapIterator.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeapIterator.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -28,6 +28,7 @@
 #include "gc/z/zHeapIterator.hpp"
 #include "gc/z/zOop.inline.hpp"
 #include "gc/z/zRootsIterator.hpp"
+#include "gc/z/zStat.hpp"
 #include "memory/iterator.inline.hpp"
 #include "utilities/bitMap.inline.hpp"
 #include "utilities/stack.inline.hpp"
@@ -170,6 +171,7 @@
   // If we didn't do this the application would have expected to see
   // ObjectFree events for phantom reachable objects in the tag map.
 
+  ZStatTimerDisable disable;
   ZHeapIteratorRootOopClosure root_cl(this);
 
   // Push strong roots onto stack
--- a/src/hotspot/share/gc/z/zRelocate.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zRelocate.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -88,7 +88,7 @@
 
   // Lookup forwarding entry
   const ZForwardingEntry entry = forwarding->find(from_index, &cursor);
-  if (entry.from_index() == from_index) {
+  if (entry.populated() && entry.from_index() == from_index) {
     // Already relocated, return new address
     return entry.to_offset();
   }
@@ -150,7 +150,9 @@
   const uintptr_t from_index = (from_offset - forwarding->start()) >> forwarding->object_alignment_shift();
   const ZForwardingEntry entry = forwarding->find(from_index);
 
+  assert(entry.populated(), "Should be forwarded");
   assert(entry.from_index() == from_index, "Should be forwarded");
+
   return ZAddress::good(entry.to_offset());
 }
 
--- a/src/hotspot/share/gc/z/zRelocationSetSelector.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zRelocationSetSelector.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -103,6 +103,7 @@
   const size_t npages = _registered_pages.size();
   size_t selected_from = 0;
   size_t selected_to = 0;
+  size_t selected_from_size = 0;
   size_t from_size = 0;
 
   semi_sort();
@@ -127,6 +128,7 @@
     if (diff_reclaimable > ZFragmentationLimit) {
       selected_from = from;
       selected_to = to;
+      selected_from_size = from_size;
     }
 
     log_trace(gc, reloc)("Candidate Relocation Set (%s Pages): "
@@ -138,7 +140,7 @@
   _nselected = selected_from;
 
   // Update statistics
-  _relocating = from_size;
+  _relocating = selected_from_size;
   for (size_t i = _nselected; i < npages; i++) {
     ZPage* const page = _sorted_pages[i];
     _fragmentation += page->size() - page->live_bytes();
--- a/src/hotspot/share/gc/z/zRootsIterator.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zRootsIterator.cpp	Tue Apr 09 11:48:54 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
@@ -179,7 +179,7 @@
     _code_cache(this) {
   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
   ZStatTimer timer(ZSubPhasePauseRootsSetup);
-  Threads::change_thread_claim_parity();
+  Threads::change_thread_claim_token();
   COMPILER2_PRESENT(DerivedPointerTable::clear());
   if (ClassUnloading) {
     nmethod::oops_do_marking_prologue();
@@ -404,7 +404,7 @@
     _threads(this) {
   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
   ZStatTimer timer(ZSubPhasePauseRootsSetup);
-  Threads::change_thread_claim_parity();
+  Threads::change_thread_claim_token();
 }
 
 ZThreadRootsIterator::~ZThreadRootsIterator() {
--- a/src/hotspot/share/gc/z/zStat.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zStat.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -749,6 +749,11 @@
 }
 
 //
+// Stat timer
+//
+__thread uint32_t ZStatTimerDisable::_active = 0;
+
+//
 // Stat sample/inc
 //
 void ZStatSample(const ZStatSampler& sampler, uint64_t value, bool trace) {
--- a/src/hotspot/share/gc/z/zStat.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/gc/z/zStat.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -269,21 +269,45 @@
 //
 // Stat timer
 //
+class ZStatTimerDisable : public StackObj {
+private:
+  static __thread uint32_t _active;
+
+public:
+  ZStatTimerDisable() {
+    _active++;
+  }
+
+  ~ZStatTimerDisable() {
+    _active--;
+  }
+
+  static bool is_active() {
+    return _active > 0;
+  }
+};
+
 class ZStatTimer : public StackObj {
 private:
+  const bool        _enabled;
   const ZStatPhase& _phase;
   const Ticks       _start;
 
 public:
   ZStatTimer(const ZStatPhase& phase) :
+      _enabled(!ZStatTimerDisable::is_active()),
       _phase(phase),
       _start(Ticks::now()) {
-    _phase.register_start(_start);
+    if (_enabled) {
+      _phase.register_start(_start);
+    }
   }
 
   ~ZStatTimer() {
-    const Ticks end = Ticks::now();
-    _phase.register_end(_start, end);
+    if (_enabled) {
+      const Ticks end = Ticks::now();
+      _phase.register_end(_start, end);
+    }
   }
 };
 
--- a/src/hotspot/share/interpreter/linkResolver.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/interpreter/linkResolver.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -264,10 +264,6 @@
   _check_access  = true;
 }
 
-char* LinkInfo::method_string() const {
-  return Method::name_and_sig_as_C_string(_resolved_klass, _name, _signature);
-}
-
 #ifndef PRODUCT
 void LinkInfo::print() {
   ResourceMark rm;
@@ -593,14 +589,12 @@
     Exceptions::fthrow(
       THREAD_AND_LOCATION,
       vmSymbols::java_lang_IllegalAccessError(),
-      "class %s tried to access %s%s%smethod %s.%s%s (%s%s%s)",
+      "class %s tried to access %s%s%smethod '%s' (%s%s%s)",
       ref_klass->external_name(),
       sel_method->is_abstract()  ? "abstract "  : "",
       sel_method->is_protected() ? "protected " : "",
       sel_method->is_private()   ? "private "   : "",
-      sel_klass->external_name(),
-      sel_method->name()->as_C_string(),
-      sel_method->signature()->as_C_string(),
+      sel_method->external_name(),
       (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
       (same_module) ? "" : "; ",
       (same_module) ? "" : sel_klass->class_in_module_of_loader()
@@ -670,12 +664,11 @@
     assert(target_loader_data != NULL, "resolved method's class has no class loader data");
 
     stringStream ss;
-    ss.print("loader constraint violation: when resolving %s"
-             " \"%s\" the class loader %s of the current class, %s,"
+    ss.print("loader constraint violation: when resolving %s '", method_type);
+    Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());
+    ss.print("' the class loader %s of the current class, %s,"
              " and the class loader %s for the method's defining class, %s, have"
              " different Class objects for the type %s used in the signature (%s; %s)",
-             method_type,
-             link_info.method_string(),
              current_loader_data->loader_name_and_id(),
              current_class->name()->as_C_string(),
              target_loader_data->loader_name_and_id(),
@@ -739,9 +732,11 @@
   // 2. check constant pool tag for called method - must be JVM_CONSTANT_Methodref
   if (!link_info.tag().is_invalid() && !link_info.tag().is_method()) {
     ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Method %s must be Methodref constant", link_info.method_string());
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+    stringStream ss;
+    ss.print("Method '");
+    Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());
+    ss.print("' must be Methodref constant");
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
   }
 
   // 3. lookup method in resolved klass and its super klasses
@@ -764,11 +759,12 @@
   // 5. method lookup failed
   if (resolved_method.is_null()) {
     ResourceMark rm(THREAD);
+    stringStream ss;
+    ss.print("'");
+    Method::print_external_name(&ss, resolved_klass, link_info.name(), link_info.signature());
+    ss.print("'");
     THROW_MSG_CAUSE_(vmSymbols::java_lang_NoSuchMethodError(),
-                    Method::name_and_sig_as_C_string(resolved_klass,
-                                                     link_info.name(),
-                                                     link_info.signature()),
-                    nested_exception, NULL);
+                     ss.as_string(), nested_exception, NULL);
   }
 
   // 6. access checks, access checking may be turned off when calling from within the VM.
@@ -840,9 +836,11 @@
   // check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref
   if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) {
     ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Method %s must be InterfaceMethodref constant", link_info.method_string());
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+    stringStream ss;
+    ss.print("Method '");
+    Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature());
+    ss.print("' must be InterfaceMethodref constant");
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
   }
 
   // lookup method in this interface or its super, java.lang.Object
@@ -857,10 +855,11 @@
   if (resolved_method.is_null()) {
     // no method found
     ResourceMark rm(THREAD);
-    THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(),
-                   Method::name_and_sig_as_C_string(resolved_klass,
-                                                    link_info.name(),
-                                                    link_info.signature()));
+    stringStream ss;
+    ss.print("'");
+    Method::print_external_name(&ss, resolved_klass, link_info.name(), link_info.signature());
+    ss.print("'");
+    THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), ss.as_string());
   }
 
   if (link_info.check_access()) {
@@ -881,11 +880,12 @@
 
   if (code != Bytecodes::_invokestatic && resolved_method->is_static()) {
     ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s",
-                 Method::name_and_sig_as_C_string(resolved_klass,
-                 resolved_method->name(), resolved_method->signature()));
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+    stringStream ss;
+    ss.print("Expected instance not static method '");
+    Method::print_external_name(&ss, resolved_klass,
+                                resolved_method->name(), resolved_method->signature());
+    ss.print("'");
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
   }
 
   if (log_develop_is_enabled(Trace, itables)) {
@@ -1086,11 +1086,11 @@
   // check if static
   if (!resolved_method->is_static()) {
     ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Expected static method %s", Method::name_and_sig_as_C_string(resolved_klass,
-                                                      resolved_method->name(),
-                                                      resolved_method->signature()));
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+    stringStream ss;
+    ss.print("Expected static method '");
+    resolved_method()->print_external_name(&ss);
+    ss.print("'");
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
   }
   return resolved_method;
 }
@@ -1127,14 +1127,16 @@
   if (resolved_method->name() == vmSymbols::object_initializer_name() &&
       resolved_method->method_holder() != resolved_klass) {
     ResourceMark rm(THREAD);
+    stringStream ss;
+    ss.print("%s: method '", resolved_klass->external_name());
+    resolved_method->signature()->print_as_signature_external_return_type(&ss);
+    ss.print(" %s(", resolved_method->name()->as_C_string());
+    resolved_method->signature()->print_as_signature_external_parameters(&ss);
+    ss.print(")' not found");
     Exceptions::fthrow(
       THREAD_AND_LOCATION,
       vmSymbols::java_lang_NoSuchMethodError(),
-      "%s: method %s%s not found",
-      resolved_klass->external_name(),
-      resolved_method->name()->as_C_string(),
-      resolved_method->signature()->as_C_string()
-    );
+      "%s", ss.as_string());
     return NULL;
   }
 
@@ -1153,27 +1155,23 @@
     if (!is_reflect &&
         !klass_to_check->is_same_or_direct_interface(resolved_klass)) {
       ResourceMark rm(THREAD);
-      char buf[200];
-      jio_snprintf(buf, sizeof(buf),
-                   "Interface method reference: %s, is in an indirect superinterface of %s",
-                   Method::name_and_sig_as_C_string(resolved_klass,
-                                                                           resolved_method->name(),
-                                                                           resolved_method->signature()),
-                   current_klass->external_name());
-      THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+      stringStream ss;
+      ss.print("Interface method reference: '");
+      resolved_method->print_external_name(&ss);
+      ss.print("', is in an indirect superinterface of %s",
+               current_klass->external_name());
+      THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
     }
   }
 
   // check if not static
   if (resolved_method->is_static()) {
     ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf),
-                 "Expecting non-static method %s",
-                 Method::name_and_sig_as_C_string(resolved_klass,
-                                                  resolved_method->name(),
-                                                  resolved_method->signature()));
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+    stringStream ss;
+    ss.print("Expecting non-static method '");
+    resolved_method->print_external_name(&ss);
+    ss.print("'");
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
   }
 
   if (log_develop_is_enabled(Trace, itables)) {
@@ -1219,10 +1217,11 @@
       // check if found
       if (sel_method.is_null()) {
         ResourceMark rm(THREAD);
-        THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-                  Method::name_and_sig_as_C_string(resolved_klass,
-                                            resolved_method->name(),
-                                            resolved_method->signature()));
+        stringStream ss;
+        ss.print("'");
+        resolved_method->print_external_name(&ss);
+        ss.print("'");
+        THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());
       // check loader constraints if found a different method
       } else if (sel_method() != resolved_method()) {
         check_method_loader_constraints(link_info, sel_method, "method", CHECK);
@@ -1244,8 +1243,8 @@
         char buf[500];
         jio_snprintf(buf, sizeof(buf),
                      "Receiver class %s must be the current class or a subtype of interface %s",
-                     receiver_klass->name()->as_C_string(),
-                     sender->name()->as_C_string());
+                     receiver_klass->external_name(),
+                     sender->external_name());
         THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf);
       }
     }
@@ -1254,20 +1253,21 @@
   // check if not static
   if (sel_method->is_static()) {
     ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
-                                                                                      resolved_method->name(),
-                                                                                      resolved_method->signature()));
-    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+    stringStream ss;
+    ss.print("Expecting non-static method '");
+    resolved_method->print_external_name(&ss);
+    ss.print("'");
+    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
   }
 
   // check if abstract
   if (sel_method->is_abstract()) {
     ResourceMark rm(THREAD);
-    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
-              Method::name_and_sig_as_C_string(resolved_klass,
-                                               sel_method->name(),
-                                               sel_method->signature()));
+    stringStream ss;
+    ss.print("'");
+    Method::print_external_name(&ss, resolved_klass, sel_method->name(), sel_method->signature());
+    ss.print("'");
+    THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());
   }
 
   if (log_develop_is_enabled(Trace, itables)) {
@@ -1305,23 +1305,22 @@
   // This is impossible, if resolve_klass is an interface, we've thrown icce in resolve_method
   if (resolved_klass->is_interface() && resolved_method->is_private()) {
     ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokevirtual: method %s, caller-class:%s",
-                 Method::name_and_sig_as_C_string(resolved_klass,
-                                                  resolved_method->name(),
-                                                  resolved_method->signature()),
-                   (current_klass == NULL ? "<NULL>" : current_klass->internal_name()));
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+    stringStream ss;
+    ss.print("private interface method requires invokespecial, not invokevirtual: method '");
+    resolved_method->print_external_name(&ss);
+    ss.print("', caller-class: %s",
+             (current_klass == NULL ? "<null>" : current_klass->internal_name()));
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
   }
 
   // check if not static
   if (resolved_method->is_static()) {
     ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Expecting non-static method %s", Method::name_and_sig_as_C_string(resolved_klass,
-                                                                                           resolved_method->name(),
-                                                                                           resolved_method->signature()));
-    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+    stringStream ss;
+    ss.print("Expecting non-static method '");
+    resolved_method->print_external_name(&ss);
+    ss.print("'");
+    THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
   }
 
   if (log_develop_is_enabled(Trace, vtables)) {
@@ -1470,10 +1469,11 @@
     // Throw Illegal Access Error if selected_method is not public.
     if (!selected_method->is_public()) {
       ResourceMark rm(THREAD);
-      THROW_MSG(vmSymbols::java_lang_IllegalAccessError(),
-                Method::name_and_sig_as_C_string(recv_klass,
-                                                 selected_method->name(),
-                                                 selected_method->signature()));
+      stringStream ss;
+      ss.print("'");
+      Method::print_external_name(&ss, recv_klass, selected_method->name(), selected_method->signature());
+      ss.print("'");
+      THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());
     }
     // check if abstract
     if (check_null_and_abstract && selected_method->is_abstract()) {
@@ -1806,19 +1806,22 @@
   }
 
   assert(resolved_method.not_null(), "Sanity");
-  ss.print(" resolved method %s%s%s%s of %s %s.",
+  ss.print(" resolved method '%s%s",
            resolved_method->is_abstract() ? "abstract " : "",
-           resolved_method->is_private()  ? "private "  : "",
-           resolved_method->name()->as_C_string(),
-           resolved_method->signature()->as_C_string(),
+           resolved_method->is_private()  ? "private "  : "");
+  resolved_method->signature()->print_as_signature_external_return_type(&ss);
+  ss.print(" %s(", resolved_method->name()->as_C_string());
+  resolved_method->signature()->print_as_signature_external_parameters(&ss);
+  ss.print(")' of %s %s.",
            resolved_klass->external_kind(),
            resolved_klass->external_name());
 
   if (selected_method.not_null() && !(resolved_method == selected_method)) {
-    ss.print(" Selected method is %s%s%s.",
+    ss.print(" Selected method is '%s%s",
              selected_method->is_abstract() ? "abstract " : "",
-             selected_method->is_private()  ? "private "  : "",
-             selected_method->name_and_sig_as_C_string());
+             selected_method->is_private()  ? "private "  : "");
+    selected_method->print_external_name(&ss);
+    ss.print("'.");
   }
 
   THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string());
--- a/src/hotspot/share/interpreter/linkResolver.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/interpreter/linkResolver.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -182,7 +182,6 @@
   methodHandle current_method() const { return _current_method; }
   constantTag tag() const            { return _tag; }
   bool check_access() const          { return _check_access; }
-  char* method_string() const;
 
   void         print()  PRODUCT_RETURN;
 };
--- a/src/hotspot/share/jvmci/jvmciRuntime.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -565,12 +565,12 @@
 
 JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child))
   bool ret = true;
-  if(!Universe::heap()->is_in_closed_subset(parent)) {
+  if(!Universe::heap()->is_in(parent)) {
     tty->print_cr("Parent Object " INTPTR_FORMAT " not in heap", p2i(parent));
     parent->print();
     ret=false;
   }
-  if(!Universe::heap()->is_in_closed_subset(child)) {
+  if(!Universe::heap()->is_in(child)) {
     tty->print_cr("Child Object " INTPTR_FORMAT " not in heap", p2i(child));
     child->print();
     ret=false;
--- a/src/hotspot/share/memory/allocation.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/allocation.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -84,8 +84,14 @@
   return Metaspace::allocate(loader_data, word_size, type, THREAD);
 }
 
-bool MetaspaceObj::is_metaspace_object() const {
-  return Metaspace::contains((void*)this);
+bool MetaspaceObj::is_valid(const MetaspaceObj* p) {
+  // Weed out obvious bogus values first without traversing metaspace
+  if ((size_t)p < os::min_page_size()) {
+    return false;
+  } else if (!is_aligned((address)p, sizeof(MetaWord))) {
+    return false;
+  }
+  return Metaspace::contains((void*)p);
 }
 
 void MetaspaceObj::print_address_on(outputStream* st) const {
--- a/src/hotspot/share/memory/allocation.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/allocation.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -258,12 +258,19 @@
   static void* _shared_metaspace_top;  // (exclusive) high address
 
  public:
-  bool is_metaspace_object() const;
-  bool is_shared() const {
+
+  // Returns true if the pointer points to a valid MetaspaceObj. A valid
+  // MetaspaceObj is MetaWord-aligned and contained within either
+  // non-shared or shared metaspace.
+  static bool is_valid(const MetaspaceObj* p);
+
+  static bool is_shared(const MetaspaceObj* p) {
     // If no shared metaspace regions are mapped, _shared_metaspace_{base,top} will
     // both be NULL and all values of p will be rejected quickly.
-    return (((void*)this) < _shared_metaspace_top && ((void*)this) >= _shared_metaspace_base);
+    return (((void*)p) < _shared_metaspace_top && ((void*)p) >= _shared_metaspace_base);
   }
+  bool is_shared() const { return MetaspaceObj::is_shared(this); }
+
   void print_address_on(outputStream* st) const;  // nonvirtual address printing
 
   static void set_shared_metaspace_range(void* base, void* top) {
--- a/src/hotspot/share/memory/filemap.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/filemap.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,9 @@
 
 #include "precompiled.hpp"
 #include "jvm.h"
+#include "classfile/classFileStream.hpp"
 #include "classfile/classLoader.inline.hpp"
+#include "classfile/classLoaderData.inline.hpp"
 #include "classfile/classLoaderExt.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionaryShared.hpp"
@@ -1489,7 +1491,7 @@
   return ent;
 }
 
-ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, TRAPS) {
+ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS) {
   int path_index = ik->shared_classpath_index();
   assert(path_index >= 0, "should be called for shared built-in classes only");
   assert(path_index < (int)_shared_path_table_size, "sanity");
@@ -1501,7 +1503,12 @@
   const char* const class_name = name->as_C_string();
   const char* const file_name = ClassLoader::file_name_for_class_name(class_name,
                                                                       name->utf8_length());
-  return cpe->open_stream(file_name, THREAD);
+  ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
+  ClassFileStream* cfs = cpe->open_stream_for_loader(file_name, loader_data, THREAD);
+  assert(cfs != NULL, "must be able to read the classfile data of shared classes for built-in loaders.");
+  log_debug(cds, jvmti)("classfile data for %s [%d: %s] = %d bytes", class_name, path_index,
+                        cfs->source(), cfs->length());
+  return cfs;
 }
 
 #endif
--- a/src/hotspot/share/memory/filemap.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/filemap.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -303,7 +303,7 @@
   static void update_shared_classpath(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS);
 
 #if INCLUDE_JVMTI
-  static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, TRAPS);
+  static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
 #endif
 
   static SharedClassPathEntry* shared_path(int index) {
--- a/src/hotspot/share/memory/heapShared.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/heapShared.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -69,6 +69,7 @@
   {"java/lang/Short$ShortCache",               "archivedCache"},
   {"java/lang/Character$CharacterCache",       "archivedCache"},
   {"java/util/jar/Attributes$Name",            "KNOWN_NAMES"},
+  {"sun/util/locale/BaseLocale",               "constantBaseLocales"},
 };
 // Entry fields for subgraphs archived in the open archive heap region.
 static ArchivableStaticFieldInfo open_archive_subgraph_entry_fields[] = {
--- a/src/hotspot/share/memory/iterator.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/iterator.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -56,7 +56,7 @@
     T heap_oop = RawAccess<>::oop_load(p);
     if (!CompressedOops::is_null(heap_oop)) {
       oop o = CompressedOops::decode_not_null(heap_oop);
-      assert(Universe::heap()->is_in_closed_subset(o),
+      assert(Universe::heap()->is_in(o),
              "should be in closed *p " PTR_FORMAT " " PTR_FORMAT, p2i(p), p2i(o));
     }
   }
--- a/src/hotspot/share/memory/metaspace.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/metaspace.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -534,6 +534,23 @@
   }
 }
 
+static void print_basic_switches(outputStream* out, size_t scale) {
+  out->print("MaxMetaspaceSize: ");
+  if (MaxMetaspaceSize >= (max_uintx) - (2 * os::vm_page_size())) {
+    // aka "very big". Default is max_uintx, but due to rounding in arg parsing the real
+    // value is smaller.
+    out->print("unlimited");
+  } else {
+    print_human_readable_size(out, MaxMetaspaceSize, scale);
+  }
+  out->cr();
+  if (Metaspace::using_class_space()) {
+    out->print("CompressedClassSpaceSize: ");
+    print_human_readable_size(out, CompressedClassSpaceSize, scale);
+  }
+  out->cr();
+}
+
 // This will print out a basic metaspace usage report but
 // unlike print_report() is guaranteed not to lock or to walk the CLDG.
 void MetaspaceUtils::print_basic_report(outputStream* out, size_t scale) {
@@ -614,6 +631,12 @@
                               Metaspace::chunk_manager_metadata()->free_chunks_total_bytes(), scale);
     out->cr();
   }
+
+  out->cr();
+
+  // Print basic settings
+  print_basic_switches(out, scale);
+
   out->cr();
 
 }
@@ -805,19 +828,11 @@
   // Print some interesting settings
   out->cr();
   out->cr();
-  out->print("MaxMetaspaceSize: ");
-  print_human_readable_size(out, MaxMetaspaceSize, scale);
+  print_basic_switches(out, scale);
+
   out->cr();
   out->print("InitialBootClassLoaderMetaspaceSize: ");
   print_human_readable_size(out, InitialBootClassLoaderMetaspaceSize, scale);
-  out->cr();
-
-  out->print("UseCompressedClassPointers: %s", UseCompressedClassPointers ? "true" : "false");
-  out->cr();
-  if (Metaspace::using_class_space()) {
-    out->print("CompressedClassSpaceSize: ");
-    print_human_readable_size(out, CompressedClassSpaceSize, scale);
-  }
 
   out->cr();
   out->cr();
--- a/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -92,9 +92,9 @@
   assert_lock_strong(MetaspaceExpand_lock);
   // Don't use a VirtualSpaceListIterator because this
   // list is being changed and a straightforward use of an iterator is not safe.
-  VirtualSpaceNode* purged_vsl = NULL;
   VirtualSpaceNode* prev_vsl = virtual_space_list();
   VirtualSpaceNode* next_vsl = prev_vsl;
+  int num_purged_nodes = 0;
   while (next_vsl != NULL) {
     VirtualSpaceNode* vsl = next_vsl;
     DEBUG_ONLY(vsl->verify(false);)
@@ -118,20 +118,17 @@
       dec_reserved_words(vsl->reserved_words());
       dec_committed_words(vsl->committed_words());
       dec_virtual_space_count();
-      purged_vsl = vsl;
       delete vsl;
+      num_purged_nodes ++;
     } else {
       prev_vsl = vsl;
     }
   }
+
+  // Verify list
 #ifdef ASSERT
-  if (purged_vsl != NULL) {
-    // List should be stable enough to use an iterator here.
-    VirtualSpaceListIterator iter(virtual_space_list());
-    while (iter.repeat()) {
-      VirtualSpaceNode* vsl = iter.get_next();
-      assert(vsl != purged_vsl, "Purge of vsl failed");
-    }
+  if (num_purged_nodes > 0) {
+    verify(false);
   }
 #endif
 }
@@ -143,11 +140,13 @@
 VirtualSpaceNode* VirtualSpaceList::find_enclosing_space(const void* ptr) {
   // List should be stable enough to use an iterator here because removing virtual
   // space nodes is only allowed at a safepoint.
-  VirtualSpaceListIterator iter(virtual_space_list());
-  while (iter.repeat()) {
-    VirtualSpaceNode* vsn = iter.get_next();
-    if (vsn->contains(ptr)) {
-      return vsn;
+  if (is_within_envelope((address)ptr)) {
+    VirtualSpaceListIterator iter(virtual_space_list());
+    while (iter.repeat()) {
+      VirtualSpaceNode* vsn = iter.get_next();
+      if (vsn->contains(ptr)) {
+        return vsn;
+      }
     }
   }
   return NULL;
@@ -170,7 +169,9 @@
                                    _is_class(false),
                                    _reserved_words(0),
                                    _committed_words(0),
-                                   _virtual_space_count(0) {
+                                   _virtual_space_count(0),
+                                   _envelope_lo((address)max_uintx),
+                                   _envelope_hi(NULL) {
   MutexLockerEx cl(MetaspaceExpand_lock,
                    Mutex::_no_safepoint_check_flag);
   create_new_virtual_space(word_size);
@@ -182,12 +183,17 @@
                                    _is_class(true),
                                    _reserved_words(0),
                                    _committed_words(0),
-                                   _virtual_space_count(0) {
+                                   _virtual_space_count(0),
+                                   _envelope_lo((address)max_uintx),
+                                   _envelope_hi(NULL) {
   MutexLockerEx cl(MetaspaceExpand_lock,
                    Mutex::_no_safepoint_check_flag);
   VirtualSpaceNode* class_entry = new VirtualSpaceNode(is_class(), rs);
   bool succeeded = class_entry->initialize();
   if (succeeded) {
+    expand_envelope_to_include_node(class_entry);
+    // ensure lock-free iteration sees fully initialized node
+    OrderAccess::storestore();
     link_vs(class_entry);
   }
 }
@@ -224,12 +230,16 @@
   } else {
     assert(new_entry->reserved_words() == vs_word_size,
         "Reserved memory size differs from requested memory size");
+    expand_envelope_to_include_node(new_entry);
     // ensure lock-free iteration sees fully initialized node
     OrderAccess::storestore();
     link_vs(new_entry);
     DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_vsnodes_created));
     return true;
   }
+
+  DEBUG_ONLY(verify(false);)
+
 }
 
 void VirtualSpaceList::link_vs(VirtualSpaceNode* new_entry) {
@@ -399,5 +409,41 @@
   }
 }
 
+// Given a node, expand range such that it includes the node.
+void VirtualSpaceList::expand_envelope_to_include_node(const VirtualSpaceNode* node) {
+  _envelope_lo = MIN2(_envelope_lo, (address)node->low_boundary());
+  _envelope_hi = MAX2(_envelope_hi, (address)node->high_boundary());
+}
+
+
+#ifdef ASSERT
+void VirtualSpaceList::verify(bool slow) {
+  VirtualSpaceNode* list = virtual_space_list();
+  VirtualSpaceListIterator iter(list);
+  size_t reserved = 0;
+  size_t committed = 0;
+  size_t node_count = 0;
+  while (iter.repeat()) {
+    VirtualSpaceNode* node = iter.get_next();
+    if (slow) {
+      node->verify(true);
+    }
+    // Check that the node resides fully within our envelope.
+    assert((address)node->low_boundary() >= _envelope_lo && (address)node->high_boundary() <= _envelope_hi,
+           "Node " SIZE_FORMAT " [" PTR_FORMAT ", " PTR_FORMAT ") outside envelope [" PTR_FORMAT ", " PTR_FORMAT ").",
+           node_count, p2i(node->low_boundary()), p2i(node->high_boundary()), p2i(_envelope_lo), p2i(_envelope_hi));
+    reserved += node->reserved_words();
+    committed += node->committed_words();
+    node_count ++;
+  }
+  assert(reserved == reserved_words() && committed == committed_words() && node_count == _virtual_space_count,
+      "Mismatch: reserved real: " SIZE_FORMAT " expected: " SIZE_FORMAT
+      ", committed real: " SIZE_FORMAT " expected: " SIZE_FORMAT
+      ", node count real: " SIZE_FORMAT " expected: " SIZE_FORMAT ".",
+      reserved, reserved_words(), committed, committed_words(),
+      node_count, _virtual_space_count);
+}
+#endif // ASSERT
+
 } // namespace metaspace
 
--- a/src/hotspot/share/memory/metaspace/virtualSpaceList.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/metaspace/virtualSpaceList.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -58,6 +58,19 @@
   // Number of virtual spaces
   size_t _virtual_space_count;
 
+  // Optimization: we keep an address range to quickly exclude pointers
+  // which are clearly not pointing into metaspace. This is an optimization for
+  // VirtualSpaceList::contains().
+  address _envelope_lo;
+  address _envelope_hi;
+
+  bool is_within_envelope(address p) const {
+    return p >= _envelope_lo && p < _envelope_hi;
+  }
+
+  // Given a node, expand range such that it includes the node.
+  void expand_envelope_to_include_node(const VirtualSpaceNode* node);
+
   ~VirtualSpaceList();
 
   VirtualSpaceNode* virtual_space_list() const { return _virtual_space_list; }
@@ -80,6 +93,8 @@
   // virtual space and add the chunks to the free list.
   void retire_current_virtual_space();
 
+  DEBUG_ONLY(bool contains_node(const VirtualSpaceNode* node) const;)
+
  public:
   VirtualSpaceList(size_t word_size);
   VirtualSpaceList(ReservedSpace rs);
@@ -126,6 +141,8 @@
   void print_on(outputStream* st, size_t scale) const;
   void print_map(outputStream* st) const;
 
+  DEBUG_ONLY(void verify(bool slow);)
+
   class VirtualSpaceListIterator : public StackObj {
     VirtualSpaceNode* _virtual_spaces;
    public:
--- a/src/hotspot/share/memory/metaspace/virtualSpaceNode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/metaspace/virtualSpaceNode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -60,6 +60,8 @@
   // Convenience functions to access the _virtual_space
   char* low()  const { return virtual_space()->low(); }
   char* high() const { return virtual_space()->high(); }
+  char* low_boundary()  const { return virtual_space()->low_boundary(); }
+  char* high_boundary() const { return virtual_space()->high_boundary(); }
 
   // The first Metachunk will be allocated at the bottom of the
   // VirtualSpace
--- a/src/hotspot/share/memory/metaspaceShared.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/metaspaceShared.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -36,6 +36,7 @@
 #include "classfile/systemDictionary.hpp"
 #include "classfile/systemDictionaryShared.hpp"
 #include "code/codeCache.hpp"
+#include "gc/shared/softRefPolicy.hpp"
 #include "interpreter/bytecodeStream.hpp"
 #include "interpreter/bytecodes.hpp"
 #include "logging/log.hpp"
--- a/src/hotspot/share/memory/oopFactory.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/memory/oopFactory.cpp	Tue Apr 09 11:48:54 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
@@ -37,6 +37,7 @@
 #include "oops/oop.inline.hpp"
 #include "oops/typeArrayOop.inline.hpp"
 #include "runtime/handles.inline.hpp"
+#include "utilities/utf8.hpp"
 
 
 typeArrayOop oopFactory::new_charArray(const char* utf8_str, TRAPS) {
--- a/src/hotspot/share/oops/arrayKlass.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/arrayKlass.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/javaClasses.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
--- a/src/hotspot/share/oops/constantPool.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/constantPool.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -280,9 +280,7 @@
       rr->obj_at_put(i, NULL);
       if (p != NULL && i < ref_map_len) {
         int index = object_to_cp_index(i);
-        // Skip the entry if the string hash code is 0 since the string
-        // is not included in the shared string_table, see StringTable::copy_shared_string.
-        if (tag_at(index).is_string() && java_lang_String::hash_code(p) != 0) {
+        if (tag_at(index).is_string()) {
           oop op = StringTable::create_archived_string(p, THREAD);
           // If the String object is not archived (possibly too large),
           // NULL is returned. Also set it in the array, so we won't
@@ -1002,14 +1000,17 @@
       if ((callee->is_interface() && m_tag.is_method()) ||
           ((!callee->is_interface() && m_tag.is_interface_method()))) {
         ResourceMark rm(THREAD);
-        char buf[400];
-        jio_snprintf(buf, sizeof(buf),
-          "Inconsistent constant pool data in classfile for class %s. "
-          "Method %s%s at index %d is %s and should be %s",
-          callee->name()->as_C_string(), name->as_C_string(), signature->as_C_string(), index,
-          callee->is_interface() ? "CONSTANT_MethodRef" : "CONSTANT_InterfaceMethodRef",
-          callee->is_interface() ? "CONSTANT_InterfaceMethodRef" : "CONSTANT_MethodRef");
-        THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+        stringStream ss;
+        ss.print("Inconsistent constant pool data in classfile for class %s. "
+                 "Method '", callee->name()->as_C_string());
+        signature->print_as_signature_external_return_type(&ss);
+        ss.print(" %s(", name->as_C_string());
+        signature->print_as_signature_external_parameters(&ss);
+        ss.print(")' at index %d is %s and should be %s",
+                 index,
+                 callee->is_interface() ? "CONSTANT_MethodRef" : "CONSTANT_InterfaceMethodRef",
+                 callee->is_interface() ? "CONSTANT_InterfaceMethodRef" : "CONSTANT_MethodRef");
+        THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string());
       }
 
       Klass* klass = this_cp->pool_holder();
--- a/src/hotspot/share/oops/instanceKlass.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -2438,6 +2438,23 @@
   return (old_state != is_in_error_state());
 }
 
+void InstanceKlass::set_class_loader_type(s2 loader_type) {
+  switch (loader_type) {
+  case ClassLoader::BOOT_LOADER:
+    _misc_flags |= _misc_is_shared_boot_class;
+    break;
+  case ClassLoader::PLATFORM_LOADER:
+    _misc_flags |= _misc_is_shared_platform_class;
+    break;
+  case ClassLoader::APP_LOADER:
+    _misc_flags |= _misc_is_shared_app_class;
+    break;
+  default:
+    ShouldNotReachHere();
+    break;
+  }
+}
+
 #if INCLUDE_JVMTI
 static void clear_all_breakpoints(Method* m) {
   m->clear_all_breakpoints();
@@ -3087,7 +3104,7 @@
   for (int i = 0; i < len; i++) {
     intptr_t e = start[i];
     st->print("%d : " INTPTR_FORMAT, i, e);
-    if (e != 0 && ((Metadata*)e)->is_metaspace_object()) {
+    if (MetaspaceObj::is_valid((Metadata*)e)) {
       st->print(" ");
       ((Metadata*)e)->print_value_on(st);
     }
--- a/src/hotspot/share/oops/instanceKlass.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/instanceKlass.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -25,10 +25,7 @@
 #ifndef SHARE_OOPS_INSTANCEKLASS_HPP
 #define SHARE_OOPS_INSTANCEKLASS_HPP
 
-#include "classfile/classLoader.hpp"
 #include "classfile/classLoaderData.hpp"
-#include "classfile/moduleEntry.hpp"
-#include "classfile/packageEntry.hpp"
 #include "memory/referenceType.hpp"
 #include "oops/annotations.hpp"
 #include "oops/constMethod.hpp"
@@ -63,6 +60,7 @@
 class BreakpointInfo;
 #endif
 class ClassFileParser;
+class ClassFileStream;
 class KlassDepChange;
 class DependencyContext;
 class fieldDescriptor;
@@ -70,9 +68,10 @@
 class JNIid;
 class JvmtiCachedClassFieldMap;
 class nmethodBucket;
-class SuperTypeClosure;
 class OopMapCache;
 class InterpreterOopMap;
+class PackageEntry;
+class ModuleEntry;
 
 // This is used in iterators below.
 class FieldClosure: public StackObj {
@@ -349,22 +348,7 @@
     _misc_flags &= ~loader_type_bits();
   }
 
-  void set_class_loader_type(s2 loader_type) {
-    switch (loader_type) {
-    case ClassLoader::BOOT_LOADER:
-      _misc_flags |= _misc_is_shared_boot_class;
-       break;
-    case ClassLoader::PLATFORM_LOADER:
-      _misc_flags |= _misc_is_shared_platform_class;
-      break;
-    case ClassLoader::APP_LOADER:
-      _misc_flags |= _misc_is_shared_app_class;
-      break;
-    default:
-      ShouldNotReachHere();
-      break;
-    }
-  }
+  void set_class_loader_type(s2 loader_type);
 
   bool has_nonstatic_fields() const        {
     return (_misc_flags & _misc_has_nonstatic_fields) != 0;
@@ -1025,7 +1009,6 @@
   void methods_do(void f(Method* method));
   void array_klasses_do(void f(Klass* k));
   void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);
-  bool super_types_do(SuperTypeClosure* blk);
 
   static InstanceKlass* cast(Klass* k) {
     return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
--- a/src/hotspot/share/oops/klass.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/klass.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -27,6 +27,7 @@
 #include "classfile/classLoaderDataGraph.inline.hpp"
 #include "classfile/dictionary.hpp"
 #include "classfile/javaClasses.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
--- a/src/hotspot/share/oops/klassVtable.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/klassVtable.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -500,11 +500,11 @@
             if (failed_type_symbol != NULL) {
               stringStream ss;
               ss.print("loader constraint violation for class %s: when selecting "
-                       "overriding method %s the class loader %s of the "
+                       "overriding method '", klass->external_name());
+              target_method()->print_external_name(&ss),
+              ss.print("' the class loader %s of the "
                        "selected method's type %s, and the class loader %s for its super "
                        "type %s have different Class objects for the type %s used in the signature (%s; %s)",
-                       klass->external_name(),
-                       target_method()->name_and_sig_as_C_string(),
                        target_klass->class_loader_data()->loader_name_and_id(),
                        target_klass->external_name(),
                        super_klass->class_loader_data()->loader_name_and_id(),
@@ -1227,15 +1227,16 @@
           if (failed_type_symbol != NULL) {
             stringStream ss;
             ss.print("loader constraint violation in interface itable"
-                     " initialization for class %s: when selecting method %s the"
-                     " class loader %s for super interface %s, and the class"
-                     " loader %s of the selected method's type, %s have"
+                     " initialization for class %s: when selecting method '",
+                     _klass->external_name());
+            m->print_external_name(&ss),
+            ss.print("' the class loader %s for super interface %s, and the class"
+                     " loader %s of the selected method's %s, %s have"
                      " different Class objects for the type %s used in the signature (%s; %s)",
-                     _klass->external_name(),
-                     m->name_and_sig_as_C_string(),
                      interf->class_loader_data()->loader_name_and_id(),
                      interf->external_name(),
                      target()->method_holder()->class_loader_data()->loader_name_and_id(),
+                     target()->method_holder()->external_kind(),
                      target()->method_holder()->external_name(),
                      failed_type_symbol->as_klass_external_name(),
                      interf->class_in_module_of_loader(false, true),
--- a/src/hotspot/share/oops/markOop.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/markOop.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -138,23 +138,15 @@
          epoch_mask_in_place      = epoch_mask << epoch_shift,
          cms_mask                 = right_n_bits(cms_bits),
          cms_mask_in_place        = cms_mask << cms_shift
-#ifndef _WIN64
-         ,hash_mask               = right_n_bits(hash_bits),
-         hash_mask_in_place       = (address_word)hash_mask << hash_shift
-#endif
   };
 
+  const static uintptr_t hash_mask = right_n_bits(hash_bits);
+  const static uintptr_t hash_mask_in_place = hash_mask << hash_shift;
+
   // Alignment of JavaThread pointers encoded in object header required by biased locking
   enum { biased_lock_alignment    = 2 << (epoch_shift + epoch_bits)
   };
 
-#ifdef _WIN64
-    // These values are too big for Win64
-    const static uintptr_t hash_mask = right_n_bits(hash_bits);
-    const static uintptr_t hash_mask_in_place  =
-                            (address_word)hash_mask << hash_shift;
-#endif
-
   enum { locked_value             = 0,
          unlocked_value           = 1,
          monitor_value            = 2,
--- a/src/hotspot/share/oops/method.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/method.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -178,6 +178,27 @@
   return buf;
 }
 
+const char* Method::external_name() const {
+  return external_name(constants()->pool_holder(), name(), signature());
+}
+
+void Method::print_external_name(outputStream *os) const {
+  print_external_name(os, constants()->pool_holder(), name(), signature());
+}
+
+const char* Method::external_name(Klass* klass, Symbol* method_name, Symbol* signature) {
+  stringStream ss;
+  print_external_name(&ss, klass, method_name, signature);
+  return ss.as_string();
+}
+
+void Method::print_external_name(outputStream *os, Klass* klass, Symbol* method_name, Symbol* signature) {
+  signature->print_as_signature_external_return_type(os);
+  os->print(" %s.%s(", klass->external_name(), method_name->as_C_string());
+  signature->print_as_signature_external_parameters(os);
+  os->print(")");
+}
+
 int Method::fast_exception_handler_bci_for(const methodHandle& mh, Klass* ex_klass, int throw_bci, TRAPS) {
   // exception table holds quadruple entries of the form (beg_bci, end_bci, handler_bci, klass_index)
   // access exception table
--- a/src/hotspot/share/oops/method.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/method.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -180,8 +180,8 @@
   }
 
   // Helper routine: get klass name + "." + method name + signature as
-  // C string, for the purpose of providing more useful NoSuchMethodErrors
-  // and fatal error handling. The string is allocated in resource
+  // C string, for the purpose of providing more useful
+  // fatal error handling. The string is allocated in resource
   // area if a buffer is not provided by the caller.
   char* name_and_sig_as_C_string() const;
   char* name_and_sig_as_C_string(char* buf, int size) const;
@@ -190,6 +190,18 @@
   static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature);
   static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature, char* buf, int size);
 
+  // Get return type + klass name + "." + method name + ( parameters types )
+  // as a C string or print it to an outputStream.
+  // This is to be used to assemble strings passed to Java, so that
+  // the text more resembles Java code. Used in exception messages.
+  // Memory is allocated in the resource area; the caller needs
+  // a ResourceMark.
+  const char* external_name() const;
+  void  print_external_name(outputStream *os) const;
+
+  static const char* external_name(                  Klass* klass, Symbol* method_name, Symbol* signature);
+  static void  print_external_name(outputStream *os, Klass* klass, Symbol* method_name, Symbol* signature);
+
   Bytecodes::Code java_code_at(int bci) const {
     return Bytecodes::java_code_at(this, bcp_from(bci));
   }
--- a/src/hotspot/share/oops/oop.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/oop.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -122,12 +122,6 @@
 }
 
 #ifndef PRODUCT
-// used only for asserts
-bool oopDesc::is_unlocked_oop() const {
-  if (!Universe::heap()->is_in_reserved(this)) return false;
-  return mark()->is_unlocked();
-}
-
 #if INCLUDE_CDS_JAVA_HEAP
 bool oopDesc::is_archived_object(oop p) {
   return HeapShared::is_archived_object(p);
--- a/src/hotspot/share/oops/oop.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/oop.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -256,7 +256,6 @@
   static bool is_oop(oop obj, bool ignore_mark_word = false);
   static bool is_oop_or_null(oop obj, bool ignore_mark_word = false);
 #ifndef PRODUCT
-  inline bool is_unlocked_oop() const;
   static bool is_archived_object(oop p) NOT_CDS_JAVA_HEAP_RETURN_(false);
 #endif
 
--- a/src/hotspot/share/oops/symbol.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/symbol.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -34,6 +34,7 @@
 #include "oops/symbol.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/os.hpp"
+#include "utilities/utf8.hpp"
 
 uint32_t Symbol::pack_length_and_refcount(int length, int refcount) {
   STATIC_ASSERT(max_symbol_length == ((1 << 16) - 1));
@@ -199,6 +200,66 @@
   return str;
 }
 
+static void print_class(outputStream *os, char *class_str, int len) {
+  for (int i = 0; i < len; ++i) {
+    if (class_str[i] == '/') {
+      os->put('.');
+    } else {
+      os->put(class_str[i]);
+    }
+  }
+}
+
+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] == '[') {
+      dimensions++;
+    } else if (array_str[i] == 'L') {
+      // Expected format: L<type name>;. Skip 'L' and ';' delimiting the type name.
+      print_class(os, array_str+i+1, len-i-2);
+      break;
+    } else {
+      os->print("%s", type2name(char2type(array_str[i])));
+    }
+  }
+  for (int i = 0; i < dimensions; ++i) {
+    os->print("[]");
+  }
+}
+
+void Symbol::print_as_signature_external_return_type(outputStream *os) {
+  for (SignatureStream ss(this); !ss.is_done(); ss.next()) {
+    if (ss.at_return_type()) {
+      if (ss.is_array()) {
+        print_array(os, (char*)ss.raw_bytes(), (int)ss.raw_length());
+      } else if (ss.is_object()) {
+        // Expected format: L<type name>;. Skip 'L' and ';' delimiting the class name.
+        print_class(os, (char*)ss.raw_bytes()+1, (int)ss.raw_length()-2);
+      } else {
+        os->print("%s", type2name(ss.type()));
+      }
+    }
+  }
+}
+
+void Symbol::print_as_signature_external_parameters(outputStream *os) {
+  bool first = true;
+  for (SignatureStream ss(this); !ss.is_done(); ss.next()) {
+    if (ss.at_return_type()) break;
+    if (!first) { os->print(", "); }
+    if (ss.is_array()) {
+      print_array(os, (char*)ss.raw_bytes(), (int)ss.raw_length());
+    } else if (ss.is_object()) {
+      // Skip 'L' and ';'.
+      print_class(os, (char*)ss.raw_bytes()+1, (int)ss.raw_length()-2);
+    } else {
+      os->print("%s", type2name(ss.type()));
+    }
+    first = false;
+  }
+}
+
 // Increment refcount while checking for zero.  If the Symbol's refcount becomes zero
 // a thread could be concurrently removing the Symbol.  This is used during SymbolTable
 // lookup to avoid reviving a dead Symbol.
--- a/src/hotspot/share/oops/symbol.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/oops/symbol.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -28,7 +28,6 @@
 #include "memory/allocation.hpp"
 #include "utilities/exceptions.hpp"
 #include "utilities/macros.hpp"
-#include "utilities/utf8.hpp"
 
 // A Symbol is a canonicalized string.
 // All Symbols reside in global SymbolTable and are reference counted.
@@ -230,6 +229,15 @@
   const char* as_klass_external_name() const;
   const char* as_klass_external_name(char* buf, int size) const;
 
+  // Treating the symbol as a signature, print the return
+  // type to the outputStream. Prints external names as 'double' or
+  // 'java.lang.Object[][]'.
+  void print_as_signature_external_return_type(outputStream *os);
+  // Treating the symbol as a signature, print the parameter types
+  // seperated by ', ' to the outputStream.  Prints external names as
+  //  'double' or 'java.lang.Object[][]'.
+  void print_as_signature_external_parameters(outputStream *os);
+
   void metaspace_pointers_do(MetaspaceClosure* it);
   MetaspaceObj::Type type() const { return SymbolType; }
 
--- a/src/hotspot/share/opto/callnode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/callnode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -49,7 +49,7 @@
 
 //=============================================================================
 uint StartNode::size_of() const { return sizeof(*this); }
-uint StartNode::cmp( const Node &n ) const
+bool StartNode::cmp( const Node &n ) const
 { return _domain == ((StartNode&)n)._domain; }
 const Type *StartNode::bottom_type() const { return _domain; }
 const Type* StartNode::Value(PhaseGVN* phase) const { return _domain; }
@@ -666,7 +666,7 @@
 }
 
 //=============================================================================
-uint CallNode::cmp( const Node &n ) const
+bool CallNode::cmp( const Node &n ) const
 { return _tf == ((CallNode&)n)._tf && _jvms == ((CallNode&)n)._jvms; }
 #ifndef PRODUCT
 void CallNode::dump_req(outputStream *st) const {
@@ -962,7 +962,7 @@
 
 //=============================================================================
 uint CallJavaNode::size_of() const { return sizeof(*this); }
-uint CallJavaNode::cmp( const Node &n ) const {
+bool CallJavaNode::cmp( const Node &n ) const {
   CallJavaNode &call = (CallJavaNode&)n;
   return CallNode::cmp(call) && _method == call._method &&
          _override_symbolic_info == call._override_symbolic_info;
@@ -999,7 +999,7 @@
 
 //=============================================================================
 uint CallStaticJavaNode::size_of() const { return sizeof(*this); }
-uint CallStaticJavaNode::cmp( const Node &n ) const {
+bool CallStaticJavaNode::cmp( const Node &n ) const {
   CallStaticJavaNode &call = (CallStaticJavaNode&)n;
   return CallJavaNode::cmp(call);
 }
@@ -1056,7 +1056,7 @@
 
 //=============================================================================
 uint CallDynamicJavaNode::size_of() const { return sizeof(*this); }
-uint CallDynamicJavaNode::cmp( const Node &n ) const {
+bool CallDynamicJavaNode::cmp( const Node &n ) const {
   CallDynamicJavaNode &call = (CallDynamicJavaNode&)n;
   return CallJavaNode::cmp(call);
 }
@@ -1069,7 +1069,7 @@
 
 //=============================================================================
 uint CallRuntimeNode::size_of() const { return sizeof(*this); }
-uint CallRuntimeNode::cmp( const Node &n ) const {
+bool CallRuntimeNode::cmp( const Node &n ) const {
   CallRuntimeNode &call = (CallRuntimeNode&)n;
   return CallNode::cmp(call) && !strcmp(_name,call._name);
 }
@@ -1118,7 +1118,7 @@
 }
 
 uint SafePointNode::size_of() const { return sizeof(*this); }
-uint SafePointNode::cmp( const Node &n ) const {
+bool SafePointNode::cmp( const Node &n ) const {
   return (&n == this);          // Always fail except on self
 }
 
@@ -1314,7 +1314,7 @@
 
 // Do not allow value-numbering for SafePointScalarObject node.
 uint SafePointScalarObjectNode::hash() const { return NO_HASH; }
-uint SafePointScalarObjectNode::cmp( const Node &n ) const {
+bool SafePointScalarObjectNode::cmp( const Node &n ) const {
   return (&n == this); // Always fail except on self
 }
 
@@ -2084,4 +2084,3 @@
 
   return true;
 }
-
--- a/src/hotspot/share/opto/callnode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/callnode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -63,7 +63,7 @@
 //------------------------------StartNode--------------------------------------
 // The method start node
 class StartNode : public MultiNode {
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
 public:
   const TypeTuple *_domain;
@@ -321,7 +321,7 @@
 // potential code sharing) only - conceptually it is independent of
 // the Node semantics.
 class SafePointNode : public MultiNode {
-  virtual uint           cmp( const Node &n ) const;
+  virtual bool           cmp( const Node &n ) const;
   virtual uint           size_of() const;       // Size is bigger
 
 public:
@@ -497,7 +497,7 @@
   DEBUG_ONLY(AllocateNode* _alloc;)
 
   virtual uint hash() const ; // { return NO_HASH; }
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
 
   uint first_index() const { return _first_index; }
 
@@ -598,7 +598,7 @@
   virtual const Type* Value(PhaseGVN* phase) const;
   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   virtual Node* Identity(PhaseGVN* phase) { return this; }
-  virtual uint        cmp( const Node &n ) const;
+  virtual bool        cmp( const Node &n ) const;
   virtual uint        size_of() const = 0;
   virtual void        calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const;
   virtual Node       *match( const ProjNode *proj, const Matcher *m );
@@ -654,7 +654,7 @@
 class CallJavaNode : public CallNode {
   friend class VMStructs;
 protected:
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
 
   bool    _optimized_virtual;
@@ -696,7 +696,7 @@
 // calls and optimized virtual calls, plus calls to wrappers for run-time
 // routines); generates static stub.
 class CallStaticJavaNode : public CallJavaNode {
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
 public:
   CallStaticJavaNode(Compile* C, const TypeFunc* tf, address addr, ciMethod* method, int bci)
@@ -750,7 +750,7 @@
 //------------------------------CallDynamicJavaNode----------------------------
 // Make a dispatched call using Java calling convention.
 class CallDynamicJavaNode : public CallJavaNode {
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
 public:
   CallDynamicJavaNode( const TypeFunc *tf , address addr, ciMethod* method, int vtable_index, int bci ) : CallJavaNode(tf,addr,method,bci), _vtable_index(vtable_index) {
@@ -767,7 +767,7 @@
 //------------------------------CallRuntimeNode--------------------------------
 // Make a direct subroutine call node into compiled C++ code.
 class CallRuntimeNode : public CallNode {
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
 public:
   CallRuntimeNode(const TypeFunc* tf, address addr, const char* name,
--- a/src/hotspot/share/opto/castnode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/castnode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -81,7 +81,7 @@
   return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
 }
 
-uint ConstraintCastNode::cmp(const Node &n) const {
+bool ConstraintCastNode::cmp(const Node &n) const {
   return TypeNode::cmp(n) && ((ConstraintCastNode&)n)._carry_dependency == _carry_dependency;
 }
 
@@ -262,7 +262,7 @@
   return NULL;
 }
 
-uint CastIINode::cmp(const Node &n) const {
+bool CastIINode::cmp(const Node &n) const {
   return ConstraintCastNode::cmp(n) && ((CastIINode&)n)._range_check_dependency == _range_check_dependency;
 }
 
--- a/src/hotspot/share/opto/castnode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/castnode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -35,7 +35,7 @@
   protected:
   // Can this node be removed post CCP or does it carry a required dependency?
   const bool _carry_dependency;
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const;
 
   public:
@@ -65,7 +65,7 @@
   protected:
   // Is this node dependent on a range check?
   const bool _range_check_dependency;
-  virtual uint cmp(const Node &n) const;
+  virtual bool cmp(const Node &n) const;
   virtual uint size_of() const;
 
   public:
--- a/src/hotspot/share/opto/cfgnode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/cfgnode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -883,7 +883,7 @@
   const Type* at = _adr_type;
   return TypeNode::hash() + (at ? at->hash() : 0);
 }
-uint PhiNode::cmp( const Node &n ) const {
+bool PhiNode::cmp( const Node &n ) const {
   return TypeNode::cmp(n) && _adr_type == ((PhiNode&)n)._adr_type;
 }
 static inline
@@ -2353,7 +2353,7 @@
 //=============================================================================
 
 uint PCTableNode::hash() const { return Node::hash() + _size; }
-uint PCTableNode::cmp( const Node &n ) const
+bool PCTableNode::cmp( const Node &n ) const
 { return _size == ((PCTableNode&)n)._size; }
 
 const Type *PCTableNode::bottom_type() const {
@@ -2383,7 +2383,7 @@
   return Node::hash() + _dest_bci;
 }
 
-uint JumpProjNode::cmp( const Node &n ) const {
+bool JumpProjNode::cmp( const Node &n ) const {
   return ProjNode::cmp(n) &&
     _dest_bci == ((JumpProjNode&)n)._dest_bci;
 }
@@ -2446,7 +2446,7 @@
 }
 
 
-uint CatchProjNode::cmp( const Node &n ) const {
+bool CatchProjNode::cmp( const Node &n ) const {
   return ProjNode::cmp(n) &&
     _handler_bci == ((CatchProjNode&)n)._handler_bci;
 }
--- a/src/hotspot/share/opto/cfgnode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/cfgnode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -131,7 +131,7 @@
   const int _inst_offset; // Offset of the instance memory slice.
   // Size is bigger to hold the _adr_type field.
   virtual uint hash() const;    // Check the type
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const { return sizeof(*this); }
 
   // Determine if CMoveNode::is_cmove_id can be used at this join point.
@@ -465,7 +465,7 @@
 // Undefined behavior if passed-in index is not inside the table.
 class PCTableNode : public MultiBranchNode {
   virtual uint hash() const;    // Target count; table size
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const { return sizeof(*this); }
 
 public:
@@ -507,7 +507,7 @@
 
 class JumpProjNode : public JProjNode {
   virtual uint hash() const;
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const { return sizeof(*this); }
 
  private:
@@ -550,7 +550,7 @@
 // the projection doesn't lead to an exception handler.
 class CatchProjNode : public CProjNode {
   virtual uint hash() const;
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const { return sizeof(*this); }
 
 private:
--- a/src/hotspot/share/opto/classes.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/classes.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -281,9 +281,7 @@
 shmacro(ShenandoahWeakCompareAndSwapN)
 shmacro(ShenandoahWeakCompareAndSwapP)
 shmacro(ShenandoahEnqueueBarrier)
-shmacro(ShenandoahReadBarrier)
-shmacro(ShenandoahWriteBarrier)
-shmacro(ShenandoahWBMemProj)
+shmacro(ShenandoahLoadReferenceBarrier)
 macro(SCMemProj)
 macro(SqrtD)
 macro(SqrtF)
--- a/src/hotspot/share/opto/compile.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/compile.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -3070,7 +3070,7 @@
         Node *m = wq.at(next);
         for (DUIterator_Fast imax, i = m->fast_outs(imax); i < imax; i++) {
           Node* use = m->fast_out(i);
-          if (use->is_Mem() || use->is_EncodeNarrowPtr() || use->is_ShenandoahBarrier()) {
+          if (use->is_Mem() || use->is_EncodeNarrowPtr()) {
             use->ensure_control_or_add_prec(n->in(0));
           } else {
             switch(use->Opcode()) {
--- a/src/hotspot/share/opto/lcm.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/lcm.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -178,7 +178,6 @@
     case Op_LoadRange:
     case Op_LoadD_unaligned:
     case Op_LoadL_unaligned:
-    case Op_ShenandoahReadBarrier:
       assert(mach->in(2) == val, "should be address");
       break;
     case Op_StoreB:
--- a/src/hotspot/share/opto/library_call.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/library_call.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -4485,7 +4485,7 @@
         for (MergeMemStream mms(merged_memory(), mem->as_MergeMem()); mms.next_non_empty2(); ) {
           Node* n = mms.memory();
           if (n != mms.memory2() && !(n->is_Proj() && n->in(0) == alloc->initialization())) {
-            assert(n->is_Store() || n->Opcode() == Op_ShenandoahWBMemProj, "what else?");
+            assert(n->is_Store(), "what else?");
             no_interfering_store = false;
             break;
           }
@@ -4494,7 +4494,7 @@
         for (MergeMemStream mms(merged_memory()); mms.next_non_empty(); ) {
           Node* n = mms.memory();
           if (n != mem && !(n->is_Proj() && n->in(0) == alloc->initialization())) {
-            assert(n->is_Store() || n->Opcode() == Op_ShenandoahWBMemProj, "what else?");
+            assert(n->is_Store(), "what else?");
             no_interfering_store = false;
             break;
           }
--- a/src/hotspot/share/opto/locknode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/locknode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -55,7 +55,7 @@
 }
 
 //------------------------------cmp--------------------------------------------
-uint BoxLockNode::cmp( const Node &n ) const {
+bool BoxLockNode::cmp( const Node &n ) const {
   if (EliminateNestedLocks)
     return (&n == this); // Always fail except on self
   const BoxLockNode &bn = (const BoxLockNode &)n;
@@ -139,7 +139,7 @@
 uint FastLockNode::size_of() const { return sizeof(*this); }
 
 //------------------------------cmp--------------------------------------------
-uint FastLockNode::cmp( const Node &n ) const {
+bool FastLockNode::cmp( const Node &n ) const {
   return (&n == this);                // Always fail except on self
 }
 
@@ -148,7 +148,7 @@
 uint FastUnlockNode::hash() const { return NO_HASH; }
 
 //------------------------------cmp--------------------------------------------
-uint FastUnlockNode::cmp( const Node &n ) const {
+bool FastUnlockNode::cmp( const Node &n ) const {
   return (&n == this);                // Always fail except on self
 }
 
--- a/src/hotspot/share/opto/locknode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/locknode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -47,7 +47,7 @@
   virtual const RegMask &out_RegMask() const;
   virtual uint size_of() const;
   virtual uint hash() const;
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual const class Type *bottom_type() const { return TypeRawPtr::BOTTOM; }
   virtual uint ideal_reg() const { return Op_RegP; }
 
@@ -94,7 +94,7 @@
   // LockNode/UnLockNode to avoid creating Phi's.
   virtual uint hash() const ;                  // { return NO_HASH; }
   virtual uint size_of() const;
-  virtual uint cmp( const Node &n ) const ;    // Always fail, except on self
+  virtual bool cmp( const Node &n ) const ;    // Always fail, except on self
   virtual int Opcode() const;
   virtual const Type* Value(PhaseGVN* phase) const { return TypeInt::CC; }
   const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;}
@@ -121,7 +121,7 @@
   // FastLock and FastUnlockNode do not hash, we need one for each correspoding
   // LockNode/UnLockNode to avoid creating Phi's.
   virtual uint hash() const ;                  // { return NO_HASH; }
-  virtual uint cmp( const Node &n ) const ;    // Always fail, except on self
+  virtual bool cmp( const Node &n ) const ;    // Always fail, except on self
   virtual int Opcode() const;
   virtual const Type* Value(PhaseGVN* phase) const { return TypeInt::CC; }
   const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;}
--- a/src/hotspot/share/opto/loopPredicate.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/loopPredicate.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -536,9 +536,6 @@
     if (_lpt->is_invariant(n)) { // known invariant
       _invariant.set(n->_idx);
     } else if (!n->is_CFG()) {
-      if (n->Opcode() == Op_ShenandoahWriteBarrier) {
-        return;
-      }
       Node *n_ctrl = _phase->ctrl_or_self(n);
       Node *u_ctrl = _phase->ctrl_or_self(use); // self if use is a CFG
       if (_phase->is_dominator(n_ctrl, u_ctrl)) {
--- a/src/hotspot/share/opto/loopnode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/loopnode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -3971,7 +3971,7 @@
     }
     while(worklist.size() != 0 && LCA != early) {
       Node* s = worklist.pop();
-      if (s->is_Load() || s->is_ShenandoahBarrier() || s->Opcode() == Op_SafePoint ||
+      if (s->is_Load() || s->Opcode() == Op_SafePoint ||
           (s->is_CallStaticJava() && s->as_CallStaticJava()->uncommon_trap_request() != 0)) {
         continue;
       } else if (s->is_MergeMem()) {
--- a/src/hotspot/share/opto/loopnode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/loopnode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -38,8 +38,6 @@
 class LoopNode;
 class Node;
 class OuterStripMinedLoopEndNode;
-class ShenandoahBarrierNode;
-class ShenandoahWriteBarrierNode;
 class PathFrequency;
 class PhaseIdealLoop;
 class CountedLoopReserveKit;
@@ -638,8 +636,7 @@
   friend class IdealLoopTree;
   friend class SuperWord;
   friend class CountedLoopReserveKit;
-  friend class ShenandoahBarrierNode;
-  friend class ShenandoahWriteBarrierNode;
+  friend class ShenandoahBarrierC2Support;
 
   // Pre-computed def-use info
   PhaseIterGVN &_igvn;
--- a/src/hotspot/share/opto/loopopts.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/loopopts.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1082,11 +1082,6 @@
         Node* m = n->fast_out(j);
         if (m->is_FastLock())
           return false;
-#if INCLUDE_SHENANDOAHGC
-        if (m->is_ShenandoahBarrier() && m->has_out_with(Op_FastLock)) {
-          return false;
-        }
-#endif
 #ifdef _LP64
         if (m->Opcode() == Op_ConvI2L)
           return false;
@@ -3210,7 +3205,7 @@
 
           // 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() && n->Opcode() != Op_ShenandoahWBMemProj) {
+          if (n->in(0) == NULL && !n->is_Load() && !n->is_CMove()) {
             cloned_for_outside_use += clone_for_use_outside_loop( loop, n, worklist );
             sink_list.push(n);
             peel     >>= n->_idx; // delete n from peel set.
--- a/src/hotspot/share/opto/machnode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/machnode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -93,7 +93,7 @@
 
 //------------------------------cmp--------------------------------------------
 // Print any per-operand special info
-uint MachOper::cmp( const MachOper &oper ) const {
+bool MachOper::cmp( const MachOper &oper ) const {
   ShouldNotCallThis();
   return opcode() == oper.opcode();
 }
@@ -106,7 +106,7 @@
 
 //------------------------------cmp--------------------------------------------
 // Print any per-operand special info
-uint labelOper::cmp( const MachOper &oper ) const {
+bool labelOper::cmp( const MachOper &oper ) const {
   return (opcode() == oper.opcode()) && (_label == oper.label());
 }
 
@@ -118,7 +118,7 @@
 
 //------------------------------cmp--------------------------------------------
 // Print any per-operand special info
-uint methodOper::cmp( const MachOper &oper ) const {
+bool methodOper::cmp( const MachOper &oper ) const {
   return (opcode() == oper.opcode()) && (_method == oper.method());
 }
 
@@ -167,15 +167,15 @@
 }
 
 //-----------------------------cmp---------------------------------------------
-uint MachNode::cmp( const Node &node ) const {
+bool MachNode::cmp( const Node &node ) const {
   MachNode& n = *((Node&)node).as_Mach();
   uint no = num_opnds();
-  if( no != n.num_opnds() ) return 0;
-  if( rule() != n.rule() ) return 0;
+  if( no != n.num_opnds() ) return false;
+  if( rule() != n.rule() ) return false;
   for( uint i=0; i<no; i++ )    // All operands must match
     if( !_opnds[i]->cmp( *n._opnds[i] ) )
-      return 0;                 // mis-matched operands
-  return 1;                     // match
+      return false;             // mis-matched operands
+  return true;                  // match
 }
 
 // Return an equivalent instruction using memory for cisc_operand position
@@ -651,7 +651,7 @@
 
 //=============================================================================
 
-uint MachCallNode::cmp( const Node &n ) const
+bool MachCallNode::cmp( const Node &n ) const
 { return _tf == ((MachCallNode&)n)._tf; }
 const Type *MachCallNode::bottom_type() const { return tf()->range(); }
 const Type* MachCallNode::Value(PhaseGVN* phase) const { return tf()->range(); }
@@ -707,7 +707,7 @@
 
 //=============================================================================
 uint MachCallJavaNode::size_of() const { return sizeof(*this); }
-uint MachCallJavaNode::cmp( const Node &n ) const {
+bool MachCallJavaNode::cmp( const Node &n ) const {
   MachCallJavaNode &call = (MachCallJavaNode&)n;
   return MachCallNode::cmp(call) && _method->equals(call._method) &&
          _override_symbolic_info == call._override_symbolic_info;
@@ -745,7 +745,7 @@
 
 //=============================================================================
 uint MachCallStaticJavaNode::size_of() const { return sizeof(*this); }
-uint MachCallStaticJavaNode::cmp( const Node &n ) const {
+bool MachCallStaticJavaNode::cmp( const Node &n ) const {
   MachCallStaticJavaNode &call = (MachCallStaticJavaNode&)n;
   return MachCallJavaNode::cmp(call) && _name == call._name;
 }
@@ -791,7 +791,7 @@
 #endif
 //=============================================================================
 uint MachCallRuntimeNode::size_of() const { return sizeof(*this); }
-uint MachCallRuntimeNode::cmp( const Node &n ) const {
+bool MachCallRuntimeNode::cmp( const Node &n ) const {
   MachCallRuntimeNode &call = (MachCallRuntimeNode&)n;
   return MachCallNode::cmp(call) && !strcmp(_name,call._name);
 }
--- a/src/hotspot/share/opto/machnode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/machnode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -161,7 +161,7 @@
 
   // Hash and compare over operands are currently identical
   virtual uint  hash() const;
-  virtual uint  cmp( const MachOper &oper ) const;
+  virtual bool  cmp( const MachOper &oper ) const;
 
   // Virtual clone, since I do not know how big the MachOper is.
   virtual MachOper *clone() const = 0;
@@ -292,7 +292,7 @@
 
   // Hash and compare over operands.  Used to do GVN on machine Nodes.
   virtual uint  hash() const;
-  virtual uint  cmp( const Node &n ) const;
+  virtual bool  cmp( const Node &n ) const;
 
   // Expand method for MachNode, replaces nodes representing pseudo
   // instructions with a set of nodes which represent real machine
@@ -861,7 +861,7 @@
 class MachCallNode : public MachSafePointNode {
 protected:
   virtual uint hash() const { return NO_HASH; }  // CFG nodes do not hash
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const = 0; // Size is bigger
 public:
   const TypeFunc *_tf;        // Function type
@@ -904,7 +904,7 @@
 // "Base" class for machine-specific versions of subroutine calls
 class MachCallJavaNode : public MachCallNode {
 protected:
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
 public:
   ciMethod* _method;                 // Method being direct called
@@ -937,7 +937,7 @@
 //------------------------------MachCallStaticJavaNode------------------------
 // Machine-specific versions of monomorphic subroutine calls
 class MachCallStaticJavaNode : public MachCallJavaNode {
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
 public:
   const char *_name;            // Runtime wrapper name
@@ -973,7 +973,7 @@
 //------------------------------MachCallRuntimeNode----------------------------
 // Machine-specific versions of subroutine calls
 class MachCallRuntimeNode : public MachCallNode {
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
 public:
   const char *_name;            // Printable name, if _method is NULL
@@ -1066,7 +1066,7 @@
   virtual uint           opcode() const;
 
   virtual uint           hash()   const;
-  virtual uint           cmp( const MachOper &oper ) const;
+  virtual bool           cmp( const MachOper &oper ) const;
 #ifndef PRODUCT
   virtual const char    *Name()   const { return "Label";}
 
@@ -1093,7 +1093,7 @@
   virtual uint           opcode() const;
 
   virtual uint           hash()   const;
-  virtual uint           cmp( const MachOper &oper ) const;
+  virtual bool           cmp( const MachOper &oper ) const;
 #ifndef PRODUCT
   virtual const char    *Name()   const { return "Method";}
 
--- a/src/hotspot/share/opto/memnode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/memnode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -758,7 +758,7 @@
   return true;
 }
 uint LoadNode::size_of() const { return sizeof(*this); }
-uint LoadNode::cmp( const Node &n ) const
+bool LoadNode::cmp( const Node &n ) const
 { return !Type::cmp( _type, ((LoadNode&)n)._type ); }
 const Type *LoadNode::bottom_type() const { return _type; }
 uint LoadNode::ideal_reg() const {
@@ -2627,7 +2627,7 @@
 //------------------------------cmp--------------------------------------------
 // Do not common stores up together.  They generally have to be split
 // back up anyways, so do not bother.
-uint StoreNode::cmp( const Node &n ) const {
+bool StoreNode::cmp( const Node &n ) const {
   return (&n == this);          // Always fail except on self
 }
 
@@ -3057,7 +3057,7 @@
 
 //------------------------------cmp--------------------------------------------
 uint MemBarNode::hash() const { return NO_HASH; }
-uint MemBarNode::cmp( const Node &n ) const {
+bool MemBarNode::cmp( const Node &n ) const {
   return (&n == this);          // Always fail except on self
 }
 
@@ -4438,7 +4438,7 @@
 
 //------------------------------cmp--------------------------------------------
 uint MergeMemNode::hash() const { return NO_HASH; }
-uint MergeMemNode::cmp( const Node &n ) const {
+bool MergeMemNode::cmp( const Node &n ) const {
   return (&n == this);          // Always fail except on self
 }
 
--- a/src/hotspot/share/opto/memnode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/memnode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -183,7 +183,7 @@
   const MemOrd _mo;
 
 protected:
-  virtual uint cmp(const Node &n) const;
+  virtual bool cmp(const Node &n) const;
   virtual uint size_of() const; // Size is bigger
   // Should LoadNode::Ideal() attempt to remove control edges?
   virtual bool can_remove_control() const;
@@ -373,7 +373,7 @@
 // Load a long from memory
 class LoadLNode : public LoadNode {
   virtual uint hash() const { return LoadNode::hash() + _require_atomic_access; }
-  virtual uint cmp( const Node &n ) const {
+  virtual bool cmp( const Node &n ) const {
     return _require_atomic_access == ((LoadLNode&)n)._require_atomic_access
       && LoadNode::cmp(n);
   }
@@ -425,7 +425,7 @@
 // Load a double (64 bits) from memory
 class LoadDNode : public LoadNode {
   virtual uint hash() const { return LoadNode::hash() + _require_atomic_access; }
-  virtual uint cmp( const Node &n ) const {
+  virtual bool cmp( const Node &n ) const {
     return _require_atomic_access == ((LoadDNode&)n)._require_atomic_access
       && LoadNode::cmp(n);
   }
@@ -535,7 +535,7 @@
   // Needed for proper cloning.
   virtual uint size_of() const { return sizeof(*this); }
 protected:
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual bool depends_only_on_test() const { return false; }
 
   Node *Ideal_masked_input       (PhaseGVN *phase, uint mask);
@@ -650,7 +650,7 @@
 // Store long to memory
 class StoreLNode : public StoreNode {
   virtual uint hash() const { return StoreNode::hash() + _require_atomic_access; }
-  virtual uint cmp( const Node &n ) const {
+  virtual bool cmp( const Node &n ) const {
     return _require_atomic_access == ((StoreLNode&)n)._require_atomic_access
       && StoreNode::cmp(n);
   }
@@ -686,7 +686,7 @@
 // Store double to memory
 class StoreDNode : public StoreNode {
   virtual uint hash() const { return StoreNode::hash() + _require_atomic_access; }
-  virtual uint cmp( const Node &n ) const {
+  virtual bool cmp( const Node &n ) const {
     return _require_atomic_access == ((StoreDNode&)n)._require_atomic_access
       && StoreNode::cmp(n);
   }
@@ -746,7 +746,7 @@
 class StoreCMNode : public StoreNode {
  private:
   virtual uint hash() const { return StoreNode::hash() + _oop_alias_idx; }
-  virtual uint cmp( const Node &n ) const {
+  virtual bool cmp( const Node &n ) const {
     return _oop_alias_idx == ((StoreCMNode&)n)._oop_alias_idx
       && StoreNode::cmp(n);
   }
@@ -1142,7 +1142,7 @@
 // separate it from any following volatile-load.
 class MemBarNode: public MultiNode {
   virtual uint hash() const ;                  // { return NO_HASH; }
-  virtual uint cmp( const Node &n ) const ;    // Always fail, except on self
+  virtual bool cmp( const Node &n ) const ;    // Always fail, except on self
 
   virtual uint size_of() const { return sizeof(*this); }
   // Memory type this node is serializing.  Usually either rawptr or bottom.
@@ -1399,7 +1399,7 @@
 // (See comment in memnode.cpp near MergeMemNode::MergeMemNode for semantics.)
 class MergeMemNode: public Node {
   virtual uint hash() const ;                  // { return NO_HASH; }
-  virtual uint cmp( const Node &n ) const ;    // Always fail, except on self
+  virtual bool cmp( const Node &n ) const ;    // Always fail, except on self
   friend class MergeMemStream;
   MergeMemNode(Node* def);  // clients use MergeMemNode::make
 
--- a/src/hotspot/share/opto/multnode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/multnode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -76,7 +76,7 @@
   // only one input
   return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
 }
-uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
+bool ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
 uint ProjNode::size_of() const { return sizeof(ProjNode); }
 
 // Test if we propagate interesting control along this projection
--- a/src/hotspot/share/opto/multnode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/multnode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -58,7 +58,7 @@
 class ProjNode : public Node {
 protected:
   virtual uint hash() const;
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const;
   void check_con() const;       // Called from constructor.
   const Type* proj_type(const Type* t) const;
--- a/src/hotspot/share/opto/node.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/node.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1433,8 +1433,8 @@
 
 //------------------------------cmp--------------------------------------------
 // Compare special parts of simple Nodes
-uint Node::cmp( const Node &n ) const {
-  return 1;                     // Must be same
+bool Node::cmp( const Node &n ) const {
+  return true;                  // Must be same
 }
 
 //------------------------------rematerialize-----------------------------------
@@ -2452,7 +2452,7 @@
 uint TypeNode::hash() const {
   return Node::hash() + _type->hash();
 }
-uint TypeNode::cmp( const Node &n ) const
+bool TypeNode::cmp( const Node &n ) const
 { return !Type::cmp( _type, ((TypeNode&)n)._type ); }
 const Type *TypeNode::bottom_type() const { return _type; }
 const Type* TypeNode::Value(PhaseGVN* phase) const { return _type; }
--- a/src/hotspot/share/opto/node.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/node.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -142,7 +142,6 @@
 class RootNode;
 class SafePointNode;
 class SafePointScalarObjectNode;
-class ShenandoahBarrierNode;
 class StartNode;
 class State;
 class StoreNode;
@@ -676,7 +675,6 @@
       DEFINE_CLASS_ID(EncodeNarrowPtr, Type, 6)
         DEFINE_CLASS_ID(EncodeP, EncodeNarrowPtr, 0)
         DEFINE_CLASS_ID(EncodePKlass, EncodeNarrowPtr, 1)
-      DEFINE_CLASS_ID(ShenandoahBarrier, Type, 7)
 
     DEFINE_CLASS_ID(Proj,  Node, 3)
       DEFINE_CLASS_ID(CatchProj, Proj, 0)
@@ -875,7 +873,6 @@
   DEFINE_CLASS_QUERY(Root)
   DEFINE_CLASS_QUERY(SafePoint)
   DEFINE_CLASS_QUERY(SafePointScalarObject)
-  DEFINE_CLASS_QUERY(ShenandoahBarrier)
   DEFINE_CLASS_QUERY(Start)
   DEFINE_CLASS_QUERY(Store)
   DEFINE_CLASS_QUERY(Sub)
@@ -1003,7 +1000,7 @@
   // won't go into the table and we'll lose a little optimization.
   enum { NO_HASH = 0 };
   virtual uint hash() const;
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
 
   // Operation appears to be iteratively computed (such as an induction variable)
   // It is possible for this operation to return false for a loop-varying
@@ -1718,7 +1715,7 @@
 class TypeNode : public Node {
 protected:
   virtual uint hash() const;    // Check the type
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
   const Type* const _type;
 public:
--- a/src/hotspot/share/opto/opaquenode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/opaquenode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -29,7 +29,7 @@
 //=============================================================================
 // Do not allow value-numbering
 uint Opaque1Node::hash() const { return NO_HASH; }
-uint Opaque1Node::cmp( const Node &n ) const {
+bool Opaque1Node::cmp( const Node &n ) const {
   return (&n == this);          // Always fail except on self
 }
 
@@ -56,7 +56,7 @@
 
 // Do not allow value-numbering
 uint Opaque2Node::hash() const { return NO_HASH; }
-uint Opaque2Node::cmp( const Node &n ) const {
+bool Opaque2Node::cmp( const Node &n ) const {
   return (&n == this);          // Always fail except on self
 }
 
@@ -67,7 +67,7 @@
 //=============================================================================
 
 uint ProfileBooleanNode::hash() const { return NO_HASH; }
-uint ProfileBooleanNode::cmp( const Node &n ) const {
+bool ProfileBooleanNode::cmp( const Node &n ) const {
   return (&n == this);
 }
 
--- a/src/hotspot/share/opto/opaquenode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/opaquenode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -33,7 +33,7 @@
 // Stops value-numbering, Ideal calls or Identity functions.
 class Opaque1Node : public Node {
   virtual uint hash() const ;                  // { return NO_HASH; }
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   public:
   Opaque1Node(Compile* C, Node *n) : Node(NULL, n) {
     // Put it on the Macro nodes list to removed during macro nodes expansion.
@@ -64,7 +64,7 @@
 // it's OK to be slightly sloppy on optimizations here.
 class Opaque2Node : public Node {
   virtual uint hash() const ;                  // { return NO_HASH; }
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   public:
   Opaque2Node( Compile* C, Node *n ) : Node(0,n) {
     // Put it on the Macro nodes list to removed during macro nodes expansion.
@@ -117,7 +117,7 @@
   bool _consumed;
   bool _delay_removal;
   virtual uint hash() const ;                  // { return NO_HASH; }
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   public:
   ProfileBooleanNode(Node *n, uint false_cnt, uint true_cnt) : Node(0, n),
           _false_cnt(false_cnt), _true_cnt(true_cnt), _consumed(false), _delay_removal(true) {}
--- a/src/hotspot/share/opto/subnode.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/subnode.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1279,7 +1279,7 @@
 uint BoolNode::size_of() const { return sizeof(BoolNode); }
 
 //------------------------------operator==-------------------------------------
-uint BoolNode::cmp( const Node &n ) const {
+bool BoolNode::cmp( const Node &n ) const {
   const BoolNode *b = (const BoolNode *)&n; // Cast up
   return (_test._test == b->_test._test);
 }
--- a/src/hotspot/share/opto/subnode.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/opto/subnode.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -300,7 +300,7 @@
 // A Node to convert a Condition Codes to a Logical result.
 class BoolNode : public Node {
   virtual uint hash() const;
-  virtual uint cmp( const Node &n ) const;
+  virtual bool cmp( const Node &n ) const;
   virtual uint size_of() const;
 
   // Try to optimize signed integer comparison
--- a/src/hotspot/share/prims/jni.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/jni.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -2955,8 +2955,9 @@
   if (method == NULL) {
     ResourceMark rm;
     stringStream st;
-    st.print("Method %s name or signature does not match",
-             Method::name_and_sig_as_C_string(k, name, signature));
+    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()) {
@@ -2965,8 +2966,9 @@
     if (method == NULL) {
       ResourceMark rm;
       stringStream st;
-      st.print("Method %s is not declared as native",
-               Method::name_and_sig_as_C_string(k, name, signature));
+      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);
     }
   }
@@ -4166,7 +4168,7 @@
 
   if (attach_failed) {
     // Added missing cleanup
-    thread->cleanup_failed_attach_current_thread();
+    thread->cleanup_failed_attach_current_thread(daemon);
     return JNI_ERR;
   }
 
--- a/src/hotspot/share/prims/jvmtiEnv.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/jvmtiEnv.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -74,6 +74,7 @@
 #include "services/threadService.hpp"
 #include "utilities/exceptions.hpp"
 #include "utilities/preserveException.hpp"
+#include "utilities/utf8.hpp"
 
 
 #define FIXLATER 0 // REMOVE this when completed.
--- a/src/hotspot/share/prims/jvmtiEnvBase.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/classLoaderDataGraph.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
 #include "memory/resourceArea.hpp"
--- a/src/hotspot/share/prims/jvmtiExport.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/jvmtiExport.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "classfile/javaClasses.inline.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "code/nmethod.hpp"
 #include "code/pcDesc.hpp"
--- a/src/hotspot/share/prims/jvmtiRawMonitor.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/jvmtiRawMonitor.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, 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
@@ -167,7 +167,12 @@
   RawMonitor_lock->unlock() ;
   if (w != NULL) {
       guarantee (w ->TState == ObjectWaiter::TS_ENTER, "invariant") ;
+      // Once we set TState to TS_RUN the waiting thread can complete
+      // SimpleEnter and 'w' is pointing into random stack space. So we have
+      // to ensure we extract the ParkEvent (which is in type-stable memory)
+      // before we set the state, and then don't access 'w'.
       ParkEvent * ev = w->_event ;
+      OrderAccess::loadstore();
       w->TState = ObjectWaiter::TS_RUN ;
       OrderAccess::fence() ;
       ev->unpark() ;
@@ -200,7 +205,7 @@
 
   // If thread still resides on the waitset then unlink it.
   // Double-checked locking -- the usage is safe in this context
-  // as we TState is volatile and the lock-unlock operators are
+  // as TState is volatile and the lock-unlock operators are
   // serializing (barrier-equivalent).
 
   if (Node.TState == ObjectWaiter::TS_WAIT) {
--- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -207,7 +207,7 @@
 
   // Mark methods seen on stack and everywhere else so old methods are not
   // cleaned up if they're on the stack.
-  MetadataOnStackMark md_on_stack(true);
+  MetadataOnStackMark md_on_stack(/*walk_all_metadata*/true, /*redefinition_walk*/true);
   HandleMark hm(thread);   // make sure any handles created are deleted
                            // before the stack walk again.
 
@@ -3842,7 +3842,7 @@
   // This is the first redefinition, mark all the nmethods for deoptimization
   if (!JvmtiExport::all_dependencies_are_recorded()) {
     log_debug(redefine, class, nmethod)("Marked all nmethods for deopt");
-    CodeCache::mark_all_nmethods_for_deoptimization();
+    CodeCache::mark_all_nmethods_for_evol_deoptimization();
     deopt_needed = true;
   } else {
     int deopt = CodeCache::mark_dependents_for_evol_deoptimization();
--- a/src/hotspot/share/prims/jvmtiTagMap.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/jvmtiTagMap.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, 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
@@ -181,17 +181,9 @@
 
   // hash a given key (oop) with the specified size
   static unsigned int hash(oop key, int size) {
-    ZGC_ONLY(assert(ZAddressMetadataShift >= sizeof(unsigned int) * BitsPerByte, "cast removes the metadata bits");)
-
-    // shift right to get better distribution (as these bits will be zero
-    // with aligned addresses)
-    key = Access<>::resolve(key);
-    unsigned int addr = (unsigned int)(cast_from_oop<intptr_t>(key));
-#ifdef _LP64
-    return (addr >> 3) % size;
-#else
-    return (addr >> 2) % size;
-#endif
+    const oop obj = Access<>::resolve(key);
+    const unsigned int hash = Universe::heap()->hash_oop(obj);
+    return hash % size;
   }
 
   // hash a given key (oop)
--- a/src/hotspot/share/prims/methodHandles.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/methodHandles.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -316,7 +316,7 @@
   }
 
   Handle resolved_method = info.resolved_method_name();
-  assert(java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method()) == m(),
+  assert(java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method()) == m() || m->is_old(),
          "Should not change after link resolution");
 
   oop mname_oop = mname();
--- a/src/hotspot/share/prims/nativeLookup.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/nativeLookup.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -43,6 +43,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/signature.hpp"
 #include "utilities/macros.hpp"
+#include "utilities/utf8.hpp"
 #if INCLUDE_JFR
 #include "jfr/jfr.hpp"
 #endif
@@ -379,8 +380,11 @@
   if (entry != NULL) return entry;
 
   // Native function not found, throw UnsatisfiedLinkError
-  THROW_MSG_0(vmSymbols::java_lang_UnsatisfiedLinkError(),
-              method->name_and_sig_as_C_string());
+  stringStream ss;
+  ss.print("'");
+  method->print_external_name(&ss);
+  ss.print("'");
+  THROW_MSG_0(vmSymbols::java_lang_UnsatisfiedLinkError(), ss.as_string());
 }
 
 
--- a/src/hotspot/share/prims/resolvedMethodTable.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/resolvedMethodTable.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -126,17 +126,14 @@
 
   Method* method = m();
   // Check if method has been redefined while taking out ResolvedMethodTable_lock, if so
-  // use new method.  The old method won't be deallocated because it's passed in as a Handle.
+  // use new method in the ResolvedMethodName.  The old method won't be deallocated
+  // yet because it's passed in as a Handle.
   if (method->is_old()) {
-    // Replace method with redefined version
-    InstanceKlass* holder = method->method_holder();
-    method = holder->method_with_idnum(method->method_idnum());
-    if (method == NULL) {
-      // Replace deleted method with NSME.
-      method = Universe::throw_no_such_method_error();
-    }
+    method = (method->is_deleted()) ? Universe::throw_no_such_method_error() :
+                                      method->get_new_method();
     java_lang_invoke_ResolvedMethodName::set_vmtarget(resolved_method_name(), method);
   }
+
   // Set flag in class to indicate this InstanceKlass has entries in the table
   // to avoid walking table during redefinition if none of the redefined classes
   // have any membernames in the table.
--- a/src/hotspot/share/prims/stackwalk.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/stackwalk.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -151,8 +151,8 @@
           index == start_index && method->caller_sensitive()) {
       ResourceMark rm(THREAD);
       THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(),
-        err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method",
-                method->name_and_sig_as_C_string()));
+        err_msg("StackWalker::getCallerClass called from @CallerSensitive '%s' method",
+                method->external_name()));
     }
     // fill in StackFrameInfo and initialize MemberName
     stream.fill_frame(index, frames_array, method, CHECK_0);
--- a/src/hotspot/share/prims/unsafe.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/prims/unsafe.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -26,6 +26,7 @@
 #include "jni.h"
 #include "jvm.h"
 #include "classfile/classFileStream.hpp"
+#include "classfile/classLoader.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "jfr/jfrEvents.hpp"
 #include "memory/allocation.inline.hpp"
@@ -291,18 +292,6 @@
   return JNIHandles::make_local(env, v);
 } UNSAFE_END
 
-UNSAFE_LEAF(jboolean, Unsafe_isBigEndian0(JNIEnv *env, jobject unsafe)) {
-#ifdef VM_LITTLE_ENDIAN
-  return false;
-#else
-  return true;
-#endif
-} UNSAFE_END
-
-UNSAFE_LEAF(jint, Unsafe_unalignedAccess0(JNIEnv *env, jobject unsafe)) {
-  return UseUnalignedAccesses;
-} UNSAFE_END
-
 #define DEFINE_GETSETOOP(java_type, Type) \
  \
 UNSAFE_ENTRY(java_type, Unsafe_Get##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) { \
@@ -445,14 +434,6 @@
 
 ////// Random queries
 
-UNSAFE_LEAF(jint, Unsafe_AddressSize0(JNIEnv *env, jobject unsafe)) {
-  return sizeof(void*);
-} UNSAFE_END
-
-UNSAFE_LEAF(jint, Unsafe_PageSize()) {
-  return os::vm_page_size();
-} UNSAFE_END
-
 static jlong find_field_offset(jclass clazz, jstring name, TRAPS) {
   assert(clazz != NULL, "clazz must not be NULL");
   assert(name != NULL, "name must not be NULL");
@@ -1072,8 +1053,6 @@
     {CC "ensureClassInitialized0", CC "(" CLS ")V",      FN_PTR(Unsafe_EnsureClassInitialized0)},
     {CC "arrayBaseOffset0",   CC "(" CLS ")I",           FN_PTR(Unsafe_ArrayBaseOffset0)},
     {CC "arrayIndexScale0",   CC "(" CLS ")I",           FN_PTR(Unsafe_ArrayIndexScale0)},
-    {CC "addressSize0",       CC "()I",                  FN_PTR(Unsafe_AddressSize0)},
-    {CC "pageSize",           CC "()I",                  FN_PTR(Unsafe_PageSize)},
 
     {CC "defineClass0",       CC "(" DC_Args ")" CLS,    FN_PTR(Unsafe_DefineClass0)},
     {CC "allocateInstance",   CC "(" CLS ")" OBJ,        FN_PTR(Unsafe_AllocateInstance)},
@@ -1101,9 +1080,6 @@
     {CC "loadFence",          CC "()V",                  FN_PTR(Unsafe_LoadFence)},
     {CC "storeFence",         CC "()V",                  FN_PTR(Unsafe_StoreFence)},
     {CC "fullFence",          CC "()V",                  FN_PTR(Unsafe_FullFence)},
-
-    {CC "isBigEndian0",       CC "()Z",                  FN_PTR(Unsafe_isBigEndian0)},
-    {CC "unalignedAccess0",   CC "()Z",                  FN_PTR(Unsafe_unalignedAccess0)}
 };
 
 #undef CC
--- a/src/hotspot/share/runtime/arguments.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/arguments.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -2875,6 +2875,20 @@
       if (FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true) != JVMFlag::SUCCESS) {
         return JNI_EINVAL;
       }
+    } else if (match_option(option, "-XX:+ErrorFileToStderr")) {
+      if (FLAG_SET_CMDLINE(bool, ErrorFileToStdout, false) != JVMFlag::SUCCESS) {
+        return JNI_EINVAL;
+      }
+      if (FLAG_SET_CMDLINE(bool, ErrorFileToStderr, true) != JVMFlag::SUCCESS) {
+        return JNI_EINVAL;
+      }
+    } else if (match_option(option, "-XX:+ErrorFileToStdout")) {
+      if (FLAG_SET_CMDLINE(bool, ErrorFileToStderr, false) != JVMFlag::SUCCESS) {
+        return JNI_EINVAL;
+      }
+      if (FLAG_SET_CMDLINE(bool, ErrorFileToStdout, true) != JVMFlag::SUCCESS) {
+        return JNI_EINVAL;
+      }
     } else if (match_option(option, "-XX:+ExtendedDTraceProbes")) {
 #if defined(DTRACE_ENABLED)
       if (FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true) != JVMFlag::SUCCESS) {
--- a/src/hotspot/share/runtime/frame.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/frame.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "classfile/moduleEntry.hpp"
 #include "code/codeCache.hpp"
 #include "code/vmreg.inline.hpp"
 #include "compiler/abstractCompiler.hpp"
--- a/src/hotspot/share/runtime/globals.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/globals.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1267,6 +1267,12 @@
   product(bool, DisplayVMOutputToStdout, false,                             \
           "If DisplayVMOutput is true, display all VM output to stdout")    \
                                                                             \
+  product(bool, ErrorFileToStderr, false,                                   \
+          "If true, error data is printed to stderr instead of a file")     \
+                                                                            \
+  product(bool, ErrorFileToStdout, false,                                   \
+          "If true, error data is printed to stdout instead of a file")     \
+                                                                            \
   product(bool, UseHeavyMonitors, false,                                    \
           "use heavyweight instead of lightweight Java monitors")           \
                                                                             \
--- a/src/hotspot/share/runtime/handshake.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/handshake.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -281,7 +281,7 @@
 
 void HandshakeState::clear_handshake(JavaThread* target) {
   _operation = NULL;
-  SafepointMechanism::disarm_local_poll_release(target);
+  SafepointMechanism::disarm_if_needed(target, true /* release */);
 }
 
 void HandshakeState::process_self_inner(JavaThread* thread) {
--- a/src/hotspot/share/runtime/init.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/init.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -122,6 +122,7 @@
   accessFlags_init();
   templateTable_init();
   InterfaceSupport_init();
+  VMRegImpl::set_regName();  // need this before generate_stubs (for printing oop maps).
   SharedRuntime::generate_stubs();
   universe2_init();  // dependent on codeCache_init and stubRoutines_init1
   javaClasses_init();// must happen after vtable initialization, before referenceProcessor_init
@@ -139,7 +140,6 @@
   if (!compileBroker_init()) {
     return JNI_EINVAL;
   }
-  VMRegImpl::set_regName();
 
   if (!universe_post_init()) {
     return JNI_ERR;
--- a/src/hotspot/share/runtime/interfaceSupport.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/interfaceSupport.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -34,6 +34,7 @@
 #include "runtime/thread.hpp"
 #include "runtime/vmOperations.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/histogram.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/preserveException.hpp"
 
@@ -282,6 +283,7 @@
   }
   ~ThreadBlockInVM() {
     trans_and_fence(_thread_blocked, _thread_in_vm);
+    OrderAccess::cross_modify_fence();
     // We don't need to clear_walkable because it will happen automagically when we return to java
   }
 };
@@ -336,6 +338,8 @@
 
     _thread->set_thread_state(_thread_in_vm);
     CHECK_UNHANDLED_OOPS_ONLY(_thread->clear_unhandled_oops();)
+
+    OrderAccess::cross_modify_fence();
   }
 };
 
--- a/src/hotspot/share/runtime/mutex.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/mutex.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -27,8 +27,6 @@
 
 #include "memory/allocation.hpp"
 #include "runtime/os.hpp"
-#include "utilities/histogram.hpp"
-
 
 // A Mutex/Monitor is a simple wrapper around a native lock plus condition
 // variable that supports lock ownership tracking, lock ranking for deadlock
--- a/src/hotspot/share/runtime/mutexLocker.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/mutexLocker.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -76,6 +76,7 @@
 Monitor* SerializePage_lock           = NULL;
 Monitor* Threads_lock                 = NULL;
 Mutex*   NonJavaThreadsList_lock      = NULL;
+Mutex*   NonJavaThreadsListSync_lock  = NULL;
 Monitor* CGC_lock                     = NULL;
 Monitor* STS_lock                     = NULL;
 Monitor* FullGCCount_lock             = NULL;
@@ -279,6 +280,7 @@
 
   def(Threads_lock                 , PaddedMonitor, barrier,     true,  Monitor::_safepoint_check_sometimes);
   def(NonJavaThreadsList_lock      , PaddedMutex,   leaf,        true,  Monitor::_safepoint_check_never);
+  def(NonJavaThreadsListSync_lock  , PaddedMutex,   leaf,        true,  Monitor::_safepoint_check_never);
 
   def(VMOperationQueue_lock        , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);  // VM_thread allowed to block on these
   def(VMOperationRequest_lock      , PaddedMonitor, nonleaf,     true,  Monitor::_safepoint_check_sometimes);
--- a/src/hotspot/share/runtime/mutexLocker.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/mutexLocker.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -72,6 +72,7 @@
 extern Monitor* Threads_lock;                    // a lock on the Threads table of active Java threads
                                                  // (also used by Safepoints too to block threads creation/destruction)
 extern Mutex*   NonJavaThreadsList_lock;         // a lock on the NonJavaThreads list
+extern Mutex*   NonJavaThreadsListSync_lock;     // a lock for NonJavaThreads list synchronization
 extern Monitor* CGC_lock;                        // used for coordination between
                                                  // fore- & background GC threads.
 extern Monitor* STS_lock;                        // used for joining/leaving SuspendibleThreadSet.
--- a/src/hotspot/share/runtime/orderAccess.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/orderAccess.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -266,6 +266,8 @@
   static void     release();
   static void     fence();
 
+  static void     cross_modify_fence();
+
   template <typename T>
   static T        load_acquire(const volatile T* p);
 
--- a/src/hotspot/share/runtime/os.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/os.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -704,12 +704,15 @@
   // Wrap memory with guard
   GuardedMemory guarded(ptr, size + nmt_header_size);
   ptr = guarded.get_user_ptr();
-#endif
+
   if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) {
     log_warning(malloc, free)("os::malloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, p2i(ptr));
     breakpoint();
   }
-  debug_only(if (paranoid) verify_memory(ptr));
+  if (paranoid) {
+    verify_memory(ptr);
+  }
+#endif
 
   // we do not track guard memory
   return MemTracker::record_malloc((address)ptr, size, memflags, stack, level);
@@ -760,10 +763,8 @@
     // Guard's user data contains NMT header
     size_t memblock_size = guarded.get_user_size() - MemTracker::malloc_header_size(memblock);
     memcpy(ptr, memblock, MIN2(size, memblock_size));
-    if (paranoid) verify_memory(MemTracker::malloc_base(ptr));
-    if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) {
-      log_warning(malloc, free)("os::realloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, p2i(ptr));
-      breakpoint();
+    if (paranoid) {
+      verify_memory(MemTracker::malloc_base(ptr));
     }
     os::free(memblock);
   }
@@ -1023,8 +1024,9 @@
 }
 
 bool os::is_readable_range(const void* from, const void* to) {
-  for (address p = align_down((address)from, min_page_size()); p < to; p += min_page_size()) {
-    if (!is_readable_pointer(p)) {
+  if ((uintptr_t)from >= (uintptr_t)to) return false;
+  for (uintptr_t p = align_down((uintptr_t)from, min_page_size()); p < (uintptr_t)to; p += min_page_size()) {
+    if (!is_readable_pointer((const void*)p)) {
       return false;
     }
   }
--- a/src/hotspot/share/runtime/reflection.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/reflection.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1085,11 +1085,12 @@
           if (method->is_abstract()) {
             // new default: 6531596
             ResourceMark rm(THREAD);
+            stringStream ss;
+            ss.print("'");
+            Method::print_external_name(&ss, target_klass, method->name(), method->signature());
+            ss.print("'");
             Handle h_origexception = Exceptions::new_exception(THREAD,
-              vmSymbols::java_lang_AbstractMethodError(),
-              Method::name_and_sig_as_C_string(target_klass,
-              method->name(),
-              method->signature()));
+              vmSymbols::java_lang_AbstractMethodError(), ss.as_string());
             JavaCallArguments args(h_origexception);
             THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
               vmSymbols::throwable_void_signature(),
@@ -1104,10 +1105,13 @@
   // an internal vtable bug. If you ever get this please let Karen know.
   if (method.is_null()) {
     ResourceMark rm(THREAD);
-    THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(),
-                Method::name_and_sig_as_C_string(klass,
-                reflected_method->name(),
-                reflected_method->signature()));
+    stringStream ss;
+    ss.print("'");
+    Method::print_external_name(&ss, klass,
+                                     reflected_method->name(),
+                                     reflected_method->signature());
+    ss.print("'");
+    THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), ss.as_string());
   }
 
   assert(ptypes->is_objArray(), "just checking");
--- a/src/hotspot/share/runtime/safepoint.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/safepoint.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -477,7 +477,8 @@
       assert(!cur_state->is_running(), "Thread not suspended at safepoint");
       cur_state->restart(); // TSS _running
       assert(cur_state->is_running(), "safepoint state has not been reset");
-      SafepointMechanism::disarm_local_poll(current);
+
+      SafepointMechanism::disarm_if_needed(current, false /* NO release */);
     }
   } // ~JavaThreadIteratorWithHandle
 
@@ -716,8 +717,6 @@
 }
 
 bool SafepointSynchronize::handshake_safe(JavaThread *thread) {
-  // The polls must be armed otherwise the safe state can change to unsafe at any time.
-  assert(SafepointMechanism::should_block(thread), "Must be armed");
   // This function must be called with the Threads_lock held so an externally
   // suspended thread cannot be resumed thus it is safe.
   assert(Threads_lock->owned_by_self() && Thread::current()->is_VM_thread(),
@@ -851,6 +850,9 @@
     thread->handle_special_runtime_exit_condition(
       !thread->is_at_poll_safepoint() && (state != _thread_in_native_trans));
   }
+
+  // cross_modify_fence is done by SafepointMechanism::block_if_requested_slow
+  // which is the only caller here.
 }
 
 // ------------------------------------------------------------------------------------------------------
--- a/src/hotspot/share/runtime/safepointMechanism.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/safepointMechanism.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -83,8 +83,7 @@
   }
 }
 
-void SafepointMechanism::block_if_requested_slow(JavaThread *thread) {
-  // local poll already checked, if used.
+void SafepointMechanism::block_or_handshake(JavaThread *thread) {
   if (global_poll()) {
     // Any load in ::block must not pass the global poll load.
     // Otherwise we might load an old safepoint counter (for example).
@@ -92,10 +91,31 @@
     SafepointSynchronize::block(thread);
   }
   if (uses_thread_local_poll() && thread->has_handshake()) {
-      thread->handshake_process_by_self();
+    thread->handshake_process_by_self();
   }
 }
 
+void SafepointMechanism::block_if_requested_slow(JavaThread *thread) {
+  // Read global poll and has_handshake after local poll
+  OrderAccess::loadload();
+
+  // local poll already checked, if used.
+  block_or_handshake(thread);
+
+  OrderAccess::loadload();
+
+  if (uses_thread_local_poll() && local_poll_armed(thread)) {
+    disarm_local_poll_release(thread);
+    // We might have disarmed next safepoint/handshake
+    OrderAccess::storeload();
+    if (global_poll() || thread->has_handshake()) {
+      arm_local_poll(thread);
+    }
+  }
+
+  OrderAccess::cross_modify_fence();
+}
+
 void SafepointMechanism::initialize_header(JavaThread* thread) {
   disarm_local_poll(thread);
 }
--- a/src/hotspot/share/runtime/safepointMechanism.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/safepointMechanism.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -46,9 +46,13 @@
 
   static inline bool local_poll_armed(JavaThread* thread);
 
+  static inline void disarm_local_poll(JavaThread* thread);
+  static inline void disarm_local_poll_release(JavaThread* thread);
+
   static inline bool local_poll(Thread* thread);
   static inline bool global_poll();
 
+  static void block_or_handshake(JavaThread *thread);
   static void block_if_requested_slow(JavaThread *thread);
 
   static void default_initialize();
@@ -80,10 +84,10 @@
 
   // Caller is responsible for using a memory barrier if needed.
   static inline void arm_local_poll(JavaThread* thread);
-  static inline void disarm_local_poll(JavaThread* thread);
-
+  // Release semantics
   static inline void arm_local_poll_release(JavaThread* thread);
-  static inline void disarm_local_poll_release(JavaThread* thread);
+  // Optional release
+  static inline void disarm_if_needed(JavaThread* thread, bool memory_order_release);
 
   // Setup the selected safepoint mechanism
   static void initialize();
--- a/src/hotspot/share/runtime/safepointMechanism.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/safepointMechanism.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -56,7 +56,7 @@
 }
 
 void SafepointMechanism::block_if_requested(JavaThread *thread) {
-  if (uses_thread_local_poll() && !SafepointMechanism::local_poll_armed(thread)) {
+  if (uses_thread_local_poll() && !local_poll_armed(thread)) {
     return;
   }
   block_if_requested_slow(thread);
@@ -70,6 +70,19 @@
   thread->set_polling_page(poll_disarmed_value());
 }
 
+void SafepointMechanism::disarm_if_needed(JavaThread* thread, bool memory_order_release) {
+  JavaThreadState jts = thread->thread_state();
+  if (jts == _thread_in_native || jts == _thread_in_native_trans) {
+    // JavaThread will disarm itself and execute cross_modify_fence() before continuing
+    return;
+  }
+  if (memory_order_release) {
+    thread->set_polling_page_release(poll_disarmed_value());
+  } else {
+    thread->set_polling_page(poll_disarmed_value());
+  }
+}
+
 void SafepointMechanism::arm_local_poll_release(JavaThread* thread) {
   thread->set_polling_page_release(poll_armed_value());
 }
--- a/src/hotspot/share/runtime/sweeper.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/sweeper.cpp	Tue Apr 09 11:48:54 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
@@ -219,7 +219,7 @@
   NMethodMarkingTask(NMethodMarkingThreadClosure* cl) :
     AbstractGangTask("Parallel NMethod Marking"),
     _cl(cl) {
-    Threads::change_thread_claim_parity();
+    Threads::change_thread_claim_token();
   }
 
   ~NMethodMarkingTask() {
--- a/src/hotspot/share/runtime/thread.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/thread.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -238,8 +238,8 @@
   set_last_handle_mark(NULL);
   DEBUG_ONLY(_missed_ic_stub_refill_verifier = NULL);
 
-  // This initial value ==> never claimed.
-  _oops_do_parity = 0;
+  // Initial value of zero ==> never claimed.
+  _threads_do_token = 0;
   _threads_hazard_ptr = NULL;
   _threads_list_ptr = NULL;
   _nested_threads_hazard_ptr_cnt = 0;
@@ -885,16 +885,14 @@
 
 
 // GC Support
-bool Thread::claim_oops_do_par_case(int strong_roots_parity) {
-  int thread_parity = _oops_do_parity;
-  if (thread_parity != strong_roots_parity) {
-    jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
-    if (res == thread_parity) {
+bool Thread::claim_par_threads_do(uintx claim_token) {
+  uintx token = _threads_do_token;
+  if (token != claim_token) {
+    uintx res = Atomic::cmpxchg(claim_token, &_threads_do_token, token);
+    if (res == token) {
       return true;
-    } else {
-      guarantee(res == strong_roots_parity, "Or else what?");
-      return false;
     }
+    guarantee(res == claim_token, "invariant");
   }
   return false;
 }
@@ -1291,29 +1289,35 @@
 NonJavaThread::~NonJavaThread() { }
 
 void NonJavaThread::add_to_the_list() {
-  MutexLockerEx lock(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag);
-  _next = _the_list._head;
+  MutexLockerEx ml(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag);
+  // Initialize BarrierSet-related data before adding to list.
+  BarrierSet::barrier_set()->on_thread_attach(this);
+  OrderAccess::release_store(&_next, _the_list._head);
   OrderAccess::release_store(&_the_list._head, this);
 }
 
 void NonJavaThread::remove_from_the_list() {
-  MutexLockerEx lock(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag);
-  NonJavaThread* volatile* p = &_the_list._head;
-  for (NonJavaThread* t = *p; t != NULL; p = &t->_next, t = *p) {
-    if (t == this) {
-      *p = this->_next;
-      // Wait for any in-progress iterators.  Concurrent synchronize is
-      // not allowed, so do it while holding the list lock.
-      _the_list._protect.synchronize();
-      break;
+  {
+    MutexLockerEx ml(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag);
+    // Cleanup BarrierSet-related data before removing from list.
+    BarrierSet::barrier_set()->on_thread_detach(this);
+    NonJavaThread* volatile* p = &_the_list._head;
+    for (NonJavaThread* t = *p; t != NULL; p = &t->_next, t = *p) {
+      if (t == this) {
+        *p = _next;
+        break;
+      }
     }
   }
+  // Wait for any in-progress iterators.  Concurrent synchronize is not
+  // allowed, so do it while holding a dedicated lock.  Outside and distinct
+  // from NJTList_lock in case an iteration attempts to lock it.
+  MutexLockerEx ml(NonJavaThreadsListSync_lock, Mutex::_no_safepoint_check_flag);
+  _the_list._protect.synchronize();
+  _next = NULL;                 // Safe to drop the link now.
 }
 
 void NonJavaThread::pre_run() {
-  // Initialize BarrierSet-related data before adding to list.
-  assert(BarrierSet::barrier_set() != NULL, "invariant");
-  BarrierSet::barrier_set()->on_thread_attach(this);
   add_to_the_list();
 
   // This is slightly odd in that NamedThread is a subclass, but
@@ -1324,8 +1328,6 @@
 
 void NonJavaThread::post_run() {
   JFR_ONLY(Jfr::on_thread_exit(this);)
-  // Clean up BarrierSet data before removing from list.
-  BarrierSet::barrier_set()->on_thread_detach(this);
   remove_from_the_list();
   // Ensure thread-local-storage is cleared before termination.
   Thread::clear_thread_current();
@@ -1506,7 +1508,7 @@
   {
     MutexLockerEx mu(Terminator_lock, Mutex::_no_safepoint_check_flag);
     _watcher_thread = NULL;
-    Terminator_lock->notify();
+    Terminator_lock->notify_all();
   }
 }
 
@@ -1836,6 +1838,10 @@
   // Thread is now sufficiently initialized to be handled by the safepoint code as being
   // in the VM. Change thread state from _thread_new to _thread_in_vm
   ThreadStateTransition::transition_and_fence(this, _thread_new, _thread_in_vm);
+  // Before a thread is on the threads list it is always safe, so after leaving the
+  // _thread_new we should emit a instruction barrier. The distance to modified code
+  // from here is probably far enough, but this is consistent and safe.
+  OrderAccess::cross_modify_fence();
 
   assert(JavaThread::current() == this, "sanity check");
   assert(!Thread::current()->owns_locks(), "sanity check");
@@ -2015,6 +2021,10 @@
     _timer_exit_phase1.stop();
     _timer_exit_phase2.start();
   }
+
+  // Capture daemon status before the thread is marked as terminated.
+  bool daemon = is_daemon(threadObj());
+
   // Notify waiters on thread object. This has to be done after exit() is called
   // on the thread (if the thread is the last thread in a daemon ThreadGroup the
   // group should have the destroyed bit set before waiters are notified).
@@ -2083,7 +2093,7 @@
     _timer_exit_phase4.start();
   }
   // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
-  Threads::remove(this);
+  Threads::remove(this, daemon);
 
   if (log_is_enabled(Debug, os, thread, timer)) {
     _timer_exit_phase4.stop();
@@ -2101,7 +2111,7 @@
   }
 }
 
-void JavaThread::cleanup_failed_attach_current_thread() {
+void JavaThread::cleanup_failed_attach_current_thread(bool is_daemon) {
   if (active_handles() != NULL) {
     JNIHandleBlock* block = active_handles();
     set_active_handles(NULL);
@@ -2123,7 +2133,7 @@
 
   BarrierSet::barrier_set()->on_thread_detach(this);
 
-  Threads::remove(this);
+  Threads::remove(this, is_daemon);
   this->smr_delete();
 }
 
@@ -2439,7 +2449,6 @@
       this->SR_lock()->wait(Mutex::_no_safepoint_check_flag);
     }
   }
-
   return ret;
 }
 
@@ -2467,6 +2476,9 @@
   set_thread_state(_thread_blocked);
   java_suspend_self();
   set_thread_state(state);
+  // Since we are not using a regular thread-state transition helper here,
+  // we must manually emit the instruction barrier after leaving a safe state.
+  OrderAccess::cross_modify_fence();
   InterfaceSupport::serialize_thread_state_with_handler(this);
   if (state != _thread_in_native) {
     SafepointMechanism::block_if_requested(this);
@@ -3462,7 +3474,7 @@
 int         Threads::_number_of_threads = 0;
 int         Threads::_number_of_non_daemon_threads = 0;
 int         Threads::_return_code = 0;
-int         Threads::_thread_claim_parity = 0;
+uintx       Threads::_thread_claim_token = 1; // Never zero.
 size_t      JavaThread::_stack_size_at_create = 0;
 
 #ifdef ASSERT
@@ -3522,14 +3534,14 @@
 }
 
 void Threads::possibly_parallel_threads_do(bool is_par, ThreadClosure* tc) {
-  int cp = Threads::thread_claim_parity();
+  uintx claim_token = Threads::thread_claim_token();
   ALL_JAVA_THREADS(p) {
-    if (p->claim_oops_do(is_par, cp)) {
+    if (p->claim_threads_do(is_par, claim_token)) {
       tc->do_thread(p);
     }
   }
   VMThread* vmt = VMThread::vm_thread();
-  if (vmt->claim_oops_do(is_par, cp)) {
+  if (vmt->claim_threads_do(is_par, claim_token)) {
     tc->do_thread(vmt);
   }
 }
@@ -3616,6 +3628,7 @@
   initialize_class(vmSymbols::java_lang_Thread(), CHECK);
   oop thread_object = create_initial_thread(thread_group, main_thread, CHECK);
   main_thread->set_threadObj(thread_object);
+
   // Set thread status to running since main thread has
   // been started and running.
   java_lang_Thread::set_thread_status(thread_object,
@@ -3624,6 +3637,15 @@
   // The VM creates objects of this class.
   initialize_class(vmSymbols::java_lang_Module(), CHECK);
 
+#ifdef ASSERT
+  InstanceKlass *k = SystemDictionary::UnsafeConstants_klass();
+  assert(k->is_not_initialized(), "UnsafeConstants should not already be initialized");
+#endif
+
+  // initialize the hardware-specific constants needed by Unsafe
+  initialize_class(vmSymbols::jdk_internal_misc_UnsafeConstants(), CHECK);
+  jdk_internal_misc_UnsafeConstants::set_unsafe_constants();
+
   // The VM preresolves methods to these classes. Make sure that they get initialized
   initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK);
   initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK);
@@ -4447,7 +4469,7 @@
   Events::log(p, "Thread added: " INTPTR_FORMAT, p2i(p));
 }
 
-void Threads::remove(JavaThread* p) {
+void Threads::remove(JavaThread* p, bool is_daemon) {
 
   // Reclaim the ObjectMonitors from the omInUseList and omFreeList of the moribund thread.
   ObjectSynchronizer::omFlush(p);
@@ -4476,11 +4498,8 @@
     }
 
     _number_of_threads--;
-    oop threadObj = p->threadObj();
-    bool daemon = true;
-    if (!is_daemon(threadObj)) {
+    if (!is_daemon) {
       _number_of_non_daemon_threads--;
-      daemon = false;
 
       // Only one thread left, do a notify on the Threads_lock so a thread waiting
       // on destroy_vm will wake up.
@@ -4488,7 +4507,7 @@
         Threads_lock->notify_all();
       }
     }
-    ThreadService::remove_thread(p, daemon);
+    ThreadService::remove_thread(p, is_daemon);
 
     // Make sure that safepoint code disregard this thread. This is needed since
     // the thread might mess around with locks after this point. This can cause it
@@ -4515,27 +4534,39 @@
   VMThread::vm_thread()->oops_do(f, cf);
 }
 
-void Threads::change_thread_claim_parity() {
-  // Set the new claim parity.
-  assert(_thread_claim_parity >= 0 && _thread_claim_parity <= 2,
-         "Not in range.");
-  _thread_claim_parity++;
-  if (_thread_claim_parity == 3) _thread_claim_parity = 1;
-  assert(_thread_claim_parity >= 1 && _thread_claim_parity <= 2,
-         "Not in range.");
+void Threads::change_thread_claim_token() {
+  if (++_thread_claim_token == 0) {
+    // On overflow of the token counter, there is a risk of future
+    // collisions between a new global token value and a stale token
+    // for a thread, because not all iterations visit all threads.
+    // (Though it's pretty much a theoretical concern for non-trivial
+    // token counter sizes.)  To deal with the possibility, reset all
+    // the thread tokens to zero on global token overflow.
+    struct ResetClaims : public ThreadClosure {
+      virtual void do_thread(Thread* t) {
+        t->claim_threads_do(false, 0);
+      }
+    } reset_claims;
+    Threads::threads_do(&reset_claims);
+    // On overflow, update the global token to non-zero, to
+    // avoid the special "never claimed" initial thread value.
+    _thread_claim_token = 1;
+  }
 }
 
 #ifdef ASSERT
+void assert_thread_claimed(const char* kind, Thread* t, uintx expected) {
+  const uintx token = t->threads_do_token();
+  assert(token == expected,
+         "%s " PTR_FORMAT " has incorrect value " UINTX_FORMAT " != "
+         UINTX_FORMAT, kind, p2i(t), token, expected);
+}
+
 void Threads::assert_all_threads_claimed() {
   ALL_JAVA_THREADS(p) {
-    const int thread_parity = p->oops_do_parity();
-    assert((thread_parity == _thread_claim_parity),
-           "Thread " PTR_FORMAT " has incorrect parity %d != %d", p2i(p), thread_parity, _thread_claim_parity);
-  }
-  VMThread* vmt = VMThread::vm_thread();
-  const int thread_parity = vmt->oops_do_parity();
-  assert((thread_parity == _thread_claim_parity),
-         "VMThread " PTR_FORMAT " has incorrect parity %d != %d", p2i(vmt), thread_parity, _thread_claim_parity);
+    assert_thread_claimed("Thread", p, _thread_claim_token);
+  }
+  assert_thread_claimed("VMThread", VMThread::vm_thread(), _thread_claim_token);
 }
 #endif // ASSERT
 
--- a/src/hotspot/share/runtime/thread.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/runtime/thread.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -338,9 +338,8 @@
   // Point to the last handle mark
   HandleMark* _last_handle_mark;
 
-  // The parity of the last strong_roots iteration in which this thread was
-  // claimed as a task.
-  int _oops_do_parity;
+  // Claim value for parallel iteration over threads.
+  uintx _threads_do_token;
 
   // Support for GlobalCounter
  private:
@@ -647,27 +646,28 @@
   // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames
   virtual void oops_do(OopClosure* f, CodeBlobClosure* cf);
 
-  // Handles the parallel case for the method below.
+  // Handles the parallel case for claim_threads_do.
  private:
-  bool claim_oops_do_par_case(int collection_parity);
+  bool claim_par_threads_do(uintx claim_token);
  public:
-  // Requires that "collection_parity" is that of the current roots
-  // iteration.  If "is_par" is false, sets the parity of "this" to
-  // "collection_parity", and returns "true".  If "is_par" is true,
-  // uses an atomic instruction to set the current threads parity to
-  // "collection_parity", if it is not already.  Returns "true" iff the
+  // Requires that "claim_token" is that of the current iteration.
+  // If "is_par" is false, sets the token of "this" to
+  // "claim_token", and returns "true".  If "is_par" is true,
+  // uses an atomic instruction to set the current thread's token to
+  // "claim_token", if it is not already.  Returns "true" iff the
   // calling thread does the update, this indicates that the calling thread
-  // has claimed the thread's stack as a root group in the current
-  // collection.
-  bool claim_oops_do(bool is_par, int collection_parity) {
+  // has claimed the thread in the current iteration.
+  bool claim_threads_do(bool is_par, uintx claim_token) {
     if (!is_par) {
-      _oops_do_parity = collection_parity;
+      _threads_do_token = claim_token;
       return true;
     } else {
-      return claim_oops_do_par_case(collection_parity);
+      return claim_par_threads_do(claim_token);
     }
   }
 
+  uintx threads_do_token() const { return _threads_do_token; }
+
   // jvmtiRedefineClasses support
   void metadata_handles_do(void f(Metadata*));
 
@@ -750,7 +750,6 @@
   Monitor* owned_locks() const                   { return _owned_locks;          }
   bool owns_locks() const                        { return owned_locks() != NULL; }
   bool owns_locks_but_compiled_lock() const;
-  int oops_do_parity() const                     { return _oops_do_parity; }
 
   // Deadlock detection
   bool allow_allocation()                        { return _allow_allocation_count == 0; }
@@ -1243,7 +1242,7 @@
   };
   void exit(bool destroy_vm, ExitType exit_type = normal_exit);
 
-  void cleanup_failed_attach_current_thread();
+  void cleanup_failed_attach_current_thread(bool is_daemon);
 
   // Testers
   virtual bool is_Java_thread() const            { return true;  }
@@ -2223,7 +2222,7 @@
   static int         _number_of_threads;
   static int         _number_of_non_daemon_threads;
   static int         _return_code;
-  static int         _thread_claim_parity;
+  static uintx       _thread_claim_token;
 #ifdef ASSERT
   static bool        _vm_complete;
 #endif
@@ -2236,7 +2235,7 @@
   // force_daemon is a concession to JNI, where we may need to add a
   // thread to the thread list before allocating its thread object
   static void add(JavaThread* p, bool force_daemon = false);
-  static void remove(JavaThread* p);
+  static void remove(JavaThread* p, bool is_daemon);
   static void non_java_threads_do(ThreadClosure* tc);
   static void java_threads_do(ThreadClosure* tc);
   static void java_threads_and_vm_thread_do(ThreadClosure* tc);
@@ -2256,21 +2255,23 @@
   // Does not include JNI_VERSION_1_1
   static jboolean is_supported_jni_version(jint version);
 
-  // The "thread claim parity" provides a way for threads to be claimed
+  // The "thread claim token" provides a way for threads to be claimed
   // by parallel worker tasks.
   //
-  // Each thread contains a "parity" field. A task will claim the
-  // thread only if its parity field is the same as the global parity,
-  // which is updated by calling change_thread_claim_parity().
+  // Each thread contains a "token" field. A task will claim the
+  // thread only if its token is different from the global token,
+  // which is updated by calling change_thread_claim_token().  When
+  // a thread is claimed, it's token is set to the global token value
+  // so other threads in the same iteration pass won't claim it.
   //
-  // For this to work change_thread_claim_parity() needs to be called
+  // For this to work change_thread_claim_token() needs to be called
   // exactly once in sequential code before starting parallel tasks
   // that should claim threads.
   //
-  // New threads get their parity set to 0 and change_thread_claim_parity()
-  // never sets the global parity to 0.
-  static int thread_claim_parity() { return _thread_claim_parity; }
-  static void change_thread_claim_parity();
+  // New threads get their token set to 0 and change_thread_claim_token()
+  // never sets the global token to 0.
+  static uintx thread_claim_token() { return _thread_claim_token; }
+  static void change_thread_claim_token();
   static void assert_all_threads_claimed() NOT_DEBUG_RETURN;
 
   // Apply "f->do_oop" to all root oops in all threads.
@@ -2324,6 +2325,8 @@
 
   // Deoptimizes all frames tied to marked nmethods
   static void deoptimized_wrt_marked_nmethods();
+
+  struct Test;                  // For private gtest access.
 };
 
 
--- a/src/hotspot/share/services/management.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/services/management.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "jmm.h"
+#include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "compiler/compileBroker.hpp"
 #include "memory/allocation.inline.hpp"
--- a/src/hotspot/share/utilities/hashtable.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/utilities/hashtable.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, 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
@@ -129,7 +129,7 @@
   }
 }
 
-static int literal_size(ClassLoaderWeakHandle v) {
+static int literal_size(WeakHandle<vm_class_loader_data> v) {
   return literal_size(v.peek());
 }
 
@@ -244,7 +244,7 @@
   l->print();
 }
 
-static void print_literal(ClassLoaderWeakHandle l) {
+static void print_literal(WeakHandle<vm_class_loader_data> l) {
   l.print();
 }
 
@@ -308,15 +308,14 @@
 template class Hashtable<Symbol*, mtSymbol>;
 template class Hashtable<Klass*, mtClass>;
 template class Hashtable<InstanceKlass*, mtClass>;
-template class Hashtable<ClassLoaderWeakHandle, mtClass>;
+template class Hashtable<WeakHandle<vm_class_loader_data>, mtClass>;
 template class Hashtable<Symbol*, mtModule>;
 template class Hashtable<oop, mtSymbol>;
-template class Hashtable<ClassLoaderWeakHandle, mtSymbol>;
 template class Hashtable<Symbol*, mtClass>;
 template class HashtableEntry<Symbol*, mtSymbol>;
 template class HashtableEntry<Symbol*, mtClass>;
 template class HashtableEntry<oop, mtSymbol>;
-template class HashtableEntry<ClassLoaderWeakHandle, mtSymbol>;
+template class HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass>;
 template class HashtableBucket<mtClass>;
 template class BasicHashtableEntry<mtSymbol>;
 template class BasicHashtableEntry<mtCode>;
--- a/src/hotspot/share/utilities/vmError.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/hotspot/share/utilities/vmError.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1445,9 +1445,13 @@
     }
   }
 
-  // print to screen
+  // Part 1: print an abbreviated version (the '#' section) to stdout.
   if (!out_done) {
-    report(&out, false);
+    // Suppress this output if we plan to print Part 2 to stdout too.
+    // No need to have the "#" section twice.
+    if (!(ErrorFileToStdout && out.fd() == 1)) {
+      report(&out, false);
+    }
 
     out_done = true;
 
@@ -1455,21 +1459,27 @@
     _current_step_info = "";
   }
 
+  // Part 2: print a full error log file (optionally to stdout or stderr).
   // print to error log file
   if (!log_done) {
     // see if log file is already open
     if (!log.is_open()) {
       // open log file
-      fd_log = prepare_log_file(ErrorFile, "hs_err_pid%p.log", buffer, sizeof(buffer));
-      if (fd_log != -1) {
-        out.print_raw("# An error report file with more information is saved as:\n# ");
-        out.print_raw_cr(buffer);
-
-        log.set_fd(fd_log);
+      if (ErrorFileToStdout) {
+        fd_log = 1;
+      } else if (ErrorFileToStderr) {
+        fd_log = 2;
       } else {
-        out.print_raw_cr("# Can not save log file, dump to screen..");
-        log.set_fd(fd_out);
+        fd_log = prepare_log_file(ErrorFile, "hs_err_pid%p.log", buffer, sizeof(buffer));
+        if (fd_log != -1) {
+          out.print_raw("# An error report file with more information is saved as:\n# ");
+          out.print_raw_cr(buffer);
+        } else {
+          out.print_raw_cr("# Can not save log file, dump to screen..");
+          fd_log = 1;
+        }
       }
+      log.set_fd(fd_log);
     }
 
     report(&log, true);
@@ -1477,7 +1487,7 @@
     _current_step = 0;
     _current_step_info = "";
 
-    if (fd_log != -1) {
+    if (fd_log > 3) {
       close(fd_log);
       fd_log = -1;
     }
--- a/src/java.base/share/classes/java/io/File.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/io/File.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1869,7 +1869,7 @@
      *
      * <p> The returned number of available bytes is a hint, but not a
      * guarantee, that it is possible to use most or any of these bytes.  The
-     * number of unallocated bytes is most likely to be accurate immediately
+     * number of available bytes is most likely to be accurate immediately
      * after this call.  It is likely to be made inaccurate by any external
      * I/O operations including those made on the system outside of this
      * virtual machine.  This method makes no guarantee that write operations
--- a/src/java.base/share/classes/java/lang/String.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/lang/String.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1510,8 +1510,14 @@
     public int hashCode() {
         int h = hash;
         if (h == 0 && value.length > 0) {
-            hash = h = isLatin1() ? StringLatin1.hashCode(value)
-                                  : StringUTF16.hashCode(value);
+            h = isLatin1() ? StringLatin1.hashCode(value)
+                           : StringUTF16.hashCode(value);
+            // Avoid issuing a store if the calculated value is also zero:
+            // in addition to a minor performance benefit, this allows storing
+            // Strings with zero hash code in read-only memory.
+            if (h != 0) {
+                hash = h;
+            }
         }
         return h;
     }
--- a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java	Tue Apr 09 11:48:54 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
@@ -56,7 +56,10 @@
  * {@code Field}s, {@code Method}s, or {@code Constructor}s are used to get or
  * set fields, to invoke methods, or to create and initialize new instances of
  * classes, respectively. Every reflected object checks that the code using it
- * is in an appropriate class, package, or module. </p>
+ * is in an appropriate class, package, or module. The check when invoked by
+ * <a href="{@docRoot}/../specs/jni/index.html">JNI code</a> with no Java
+ * class on the stack only succeeds if the member and the declaring class are
+ * public, and the class is in a package that is exported to all modules. </p>
  *
  * <p> The one variation from Java language access control is that the checks
  * by reflected objects assume readability. That is, the module containing
@@ -670,6 +673,13 @@
     private boolean slowVerifyAccess(Class<?> caller, Class<?> memberClass,
                                      Class<?> targetClass, int modifiers)
     {
+
+        if (caller == null) {
+            // No caller frame when a native thread attaches to the VM
+            // only allow access to a public accessible member
+            return Reflection.verifyPublicMemberAccess(memberClass, modifiers);
+        }
+
         if (!Reflection.verifyMemberAccess(caller, memberClass, targetClass, modifiers)) {
             // access denied
             return false;
--- a/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java	Tue Apr 09 11:48:54 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
@@ -363,9 +363,8 @@
     /**
      * Returns the calendar system era object from the given numeric value.
      *
-     * See the description of each Era for the numeric values of:
-     * {@link JapaneseEra#HEISEI}, {@link JapaneseEra#SHOWA},{@link JapaneseEra#TAISHO},
-     * {@link JapaneseEra#MEIJI}), only Meiji and later eras are supported.
+     * The numeric values supported by this method are the same as the
+     * numeric values supported by {@link JapaneseEra#of(int)}.
      *
      * @param eraValue  the era value
      * @return the Japanese {@code Era} for the given numeric era value
--- a/src/java.base/share/classes/java/time/chrono/JapaneseEra.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/time/chrono/JapaneseEra.java	Tue Apr 09 11:48:54 2019 +0100
@@ -151,14 +151,15 @@
      */
     public static final JapaneseEra HEISEI = new JapaneseEra(2, LocalDate.of(1989, 1, 8));
     /**
-     * The singleton instance for the 'NewEra' era (2019-05-01 - current)
-     * which has the value 3.
+     * The singleton instance for the 'Reiwa' era (2019-05-01 - )
+     * which has the value 3. The end date of this era is not specified, unless
+     * the Japanese Government defines it.
      */
-    private static final JapaneseEra NEWERA = new JapaneseEra(3, LocalDate.of(2019, 5, 1));
+    public static final JapaneseEra REIWA = new JapaneseEra(3, LocalDate.of(2019, 5, 1));
 
     // The number of predefined JapaneseEra constants.
     // There may be a supplemental era defined by the property.
-    private static final int N_ERA_CONSTANTS = NEWERA.getValue() + ERA_OFFSET;
+    private static final int N_ERA_CONSTANTS = REIWA.getValue() + ERA_OFFSET;
 
     /**
      * Serialization version.
@@ -176,7 +177,7 @@
         KNOWN_ERAS[1] = TAISHO;
         KNOWN_ERAS[2] = SHOWA;
         KNOWN_ERAS[3] = HEISEI;
-        KNOWN_ERAS[4] = NEWERA;
+        KNOWN_ERAS[4] = REIWA;
         for (int i = N_ERA_CONSTANTS; i < ERA_CONFIG.length; i++) {
             CalendarDate date = ERA_CONFIG[i].getSinceDate();
             LocalDate isoDate = LocalDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth());
--- a/src/java.base/share/classes/java/util/ImmutableCollections.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/ImmutableCollections.java	Tue Apr 09 11:48:54 2019 +0100
@@ -95,11 +95,6 @@
         }
     }
 
-    @SuppressWarnings("unchecked")
-    static <E> List<E> emptyList() {
-        return (List<E>) ListN.EMPTY_LIST;
-    }
-
     static abstract class AbstractImmutableList<E> extends AbstractImmutableCollection<E>
             implements List<E>, RandomAccess {
 
@@ -409,6 +404,11 @@
         }
 
         @Override
+        public boolean isEmpty() {
+            return false;
+        }
+
+        @Override
         public E get(int index) {
             if (index == 0) {
                 return e0;
@@ -485,7 +485,7 @@
 
         @Override
         public boolean isEmpty() {
-            return size() == 0;
+            return elements.length == 0;
         }
 
         @Override
@@ -556,11 +556,6 @@
         public abstract int hashCode();
     }
 
-    @SuppressWarnings("unchecked")
-    static <E> Set<E> emptySet() {
-        return (Set<E>) SetN.EMPTY_SET;
-    }
-
     static final class Set12<E> extends AbstractImmutableSet<E>
             implements Serializable {
 
@@ -589,6 +584,11 @@
         }
 
         @Override
+        public boolean isEmpty() {
+            return false;
+        }
+
+        @Override
         public boolean contains(Object o) {
             return o.equals(e0) || o.equals(e1); // implicit nullcheck of o
         }
@@ -716,6 +716,11 @@
         }
 
         @Override
+        public boolean isEmpty() {
+            return size == 0;
+        }
+
+        @Override
         public boolean contains(Object o) {
             Objects.requireNonNull(o);
             return size > 0 && probe(o) >= 0;
@@ -844,11 +849,6 @@
 
     // ---------- Map Implementations ----------
 
-    @SuppressWarnings("unchecked")
-    static <K,V> Map<K,V> emptyMap() {
-        return (Map<K,V>) MapN.EMPTY_MAP;
-    }
-
     abstract static class AbstractImmutableMap<K,V> extends AbstractMap<K,V> implements Serializable {
         @Override public void clear() { throw uoe(); }
         @Override public V compute(K key, BiFunction<? super K,? super V,? extends V> rf) { throw uoe(); }
@@ -891,6 +891,16 @@
             return o.equals(v0); // implicit nullcheck of o
         }
 
+        @Override
+        public int size() {
+            return 1;
+        }
+
+        @Override
+        public boolean isEmpty() {
+            return false;
+        }
+
         private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
             throw new InvalidObjectException("not serial proxy");
         }
@@ -1008,6 +1018,11 @@
             return size;
         }
 
+        @Override
+        public boolean isEmpty() {
+            return size == 0;
+        }
+
         class MapNIterator implements Iterator<Map.Entry<K,V>> {
 
             private int remaining;
@@ -1248,7 +1263,7 @@
                     return Set.of(array);
                 case IMM_MAP:
                     if (array.length == 0) {
-                        return ImmutableCollections.emptyMap();
+                        return ImmutableCollections.MapN.EMPTY_MAP;
                     } else if (array.length == 2) {
                         return new ImmutableCollections.Map1<>(array[0], array[1]);
                     } else {
--- a/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java	Tue Apr 09 11:48:54 2019 +0100
@@ -50,7 +50,7 @@
  *     2       Taisho      1912-07-30T00:00:00 local time
  *     3       Showa       1926-12-25T00:00:00 local time
  *     4       Heisei      1989-01-08T00:00:00 local time
- *     5       NewEra      2019-05-01T00:00:00 local time
+ *     5       Reiwa       2019-05-01T00:00:00 local time
  * ------------------------------------------------------
  * }</pre>
  *
@@ -129,9 +129,9 @@
     public static final int HEISEI = 4;
 
     /**
-     * The ERA constant designating the NewEra era.
+     * The ERA constant designating the Reiwa era.
      */
-    private static final int NEWERA = 5;
+    private static final int REIWA = 5;
 
     private static final int EPOCH_OFFSET   = 719163; // Fixed date of January 1, 1970 (Gregorian)
 
@@ -1761,12 +1761,12 @@
                     }
                 } else if (transitionYear) {
                     if (jdate.getYear() == 1) {
-                        // As of NewEra (since Meiji) there's no case
+                        // As of Reiwa (since Meiji) there's no case
                         // that there are multiple transitions in a
                         // year.  Historically there was such
                         // case. There might be such case again in the
                         // future.
-                        if (era > NEWERA) {
+                        if (era > REIWA) {
                             CalendarDate pd = eras[era - 1].getSinceDate();
                             if (normalizedYear == pd.getYear()) {
                                 d.setMonth(pd.getMonth()).setDayOfMonth(pd.getDayOfMonth());
--- a/src/java.base/share/classes/java/util/List.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/List.java	Tue Apr 09 11:48:54 2019 +0100
@@ -787,8 +787,9 @@
      *
      * @since 9
      */
+    @SuppressWarnings("unchecked")
     static <E> List<E> of() {
-        return ImmutableCollections.emptyList();
+        return (List<E>) ImmutableCollections.ListN.EMPTY_LIST;
     }
 
     /**
@@ -1031,7 +1032,9 @@
     static <E> List<E> of(E... elements) {
         switch (elements.length) { // implicit null check of elements
             case 0:
-                return ImmutableCollections.emptyList();
+                @SuppressWarnings("unchecked")
+                var list = (List<E>) ImmutableCollections.ListN.EMPTY_LIST;
+                return list;
             case 1:
                 return new ImmutableCollections.List12<>(elements[0]);
             case 2:
--- a/src/java.base/share/classes/java/util/Locale.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/Locale.java	Tue Apr 09 11:48:54 2019 +0100
@@ -484,63 +484,111 @@
  */
 public final class Locale implements Cloneable, Serializable {
 
-    private static final  Cache LOCALECACHE = new Cache();
+    /** Useful constant for language.
+     */
+    public static final Locale ENGLISH;
 
     /** Useful constant for language.
      */
-    public static final Locale ENGLISH = createConstant("en", "");
+    public static final Locale FRENCH;
 
     /** Useful constant for language.
      */
-    public static final Locale FRENCH = createConstant("fr", "");
+    public static final Locale GERMAN;
 
     /** Useful constant for language.
      */
-    public static final Locale GERMAN = createConstant("de", "");
+    public static final Locale ITALIAN;
+
+    /** Useful constant for language.
+     */
+    public static final Locale JAPANESE;
 
     /** Useful constant for language.
      */
-    public static final Locale ITALIAN = createConstant("it", "");
+    public static final Locale KOREAN;
 
     /** Useful constant for language.
      */
-    public static final Locale JAPANESE = createConstant("ja", "");
+    public static final Locale CHINESE;
 
     /** Useful constant for language.
      */
-    public static final Locale KOREAN = createConstant("ko", "");
+    public static final Locale SIMPLIFIED_CHINESE;
 
     /** Useful constant for language.
      */
-    public static final Locale CHINESE = createConstant("zh", "");
+    public static final Locale TRADITIONAL_CHINESE;
+
+    /** Useful constant for country.
+     */
+    public static final Locale FRANCE;
 
-    /** Useful constant for language.
+    /** Useful constant for country.
+     */
+    public static final Locale GERMANY;
+
+    /** Useful constant for country.
+     */
+    public static final Locale ITALY;
+
+    /** Useful constant for country.
      */
-    public static final Locale SIMPLIFIED_CHINESE = createConstant("zh", "CN");
+    public static final Locale JAPAN;
+
+    /** Useful constant for country.
+     */
+    public static final Locale KOREA;
 
-    /** Useful constant for language.
+    /** Useful constant for country.
+     */
+    public static final Locale UK;
+
+    /** Useful constant for country.
      */
-    public static final Locale TRADITIONAL_CHINESE = createConstant("zh", "TW");
+    public static final Locale US;
+
+    /** Useful constant for country.
+     */
+    public static final Locale CANADA;
 
     /** Useful constant for country.
      */
-    public static final Locale FRANCE = createConstant("fr", "FR");
+    public static final Locale CANADA_FRENCH;
 
-    /** Useful constant for country.
-     */
-    public static final Locale GERMANY = createConstant("de", "DE");
-
-    /** Useful constant for country.
+    /**
+     * Useful constant for the root locale.  The root locale is the locale whose
+     * language, country, and variant are empty ("") strings.  This is regarded
+     * as the base locale of all locales, and is used as the language/country
+     * neutral locale for the locale sensitive operations.
+     *
+     * @since 1.6
      */
-    public static final Locale ITALY = createConstant("it", "IT");
+    public static final Locale ROOT;
+
+    private static final Map<BaseLocale, Locale> CONSTANT_LOCALES = new HashMap<>();
 
-    /** Useful constant for country.
-     */
-    public static final Locale JAPAN = createConstant("ja", "JP");
-
-    /** Useful constant for country.
-     */
-    public static final Locale KOREA = createConstant("ko", "KR");
+    static {
+        ENGLISH = createConstant(BaseLocale.ENGLISH);
+        FRENCH = createConstant(BaseLocale.FRENCH);
+        GERMAN = createConstant(BaseLocale.GERMAN);
+        ITALIAN = createConstant(BaseLocale.ITALIAN);
+        JAPANESE = createConstant(BaseLocale.JAPANESE);
+        KOREAN = createConstant(BaseLocale.KOREAN);
+        CHINESE = createConstant(BaseLocale.CHINESE);
+        SIMPLIFIED_CHINESE = createConstant(BaseLocale.SIMPLIFIED_CHINESE);
+        TRADITIONAL_CHINESE = createConstant(BaseLocale.TRADITIONAL_CHINESE);
+        FRANCE = createConstant(BaseLocale.FRANCE);
+        GERMANY = createConstant(BaseLocale.GERMANY);
+        ITALY = createConstant(BaseLocale.ITALY);
+        JAPAN = createConstant(BaseLocale.JAPAN);
+        KOREA = createConstant(BaseLocale.KOREA);
+        UK = createConstant(BaseLocale.UK);
+        US = createConstant(BaseLocale.US);
+        CANADA = createConstant(BaseLocale.CANADA);
+        CANADA_FRENCH = createConstant(BaseLocale.CANADA_FRENCH);
+        ROOT = createConstant(BaseLocale.ROOT);
+    }
 
     /** Useful constant for country.
      */
@@ -554,31 +602,16 @@
      */
     public static final Locale TAIWAN = TRADITIONAL_CHINESE;
 
-    /** Useful constant for country.
-     */
-    public static final Locale UK = createConstant("en", "GB");
-
-    /** Useful constant for country.
-     */
-    public static final Locale US = createConstant("en", "US");
-
-    /** Useful constant for country.
+    /**
+     * This method must be called only for creating the Locale.*
+     * constants due to making shortcuts.
      */
-    public static final Locale CANADA = createConstant("en", "CA");
-
-    /** Useful constant for country.
-     */
-    public static final Locale CANADA_FRENCH = createConstant("fr", "CA");
-
-    /**
-     * Useful constant for the root locale.  The root locale is the locale whose
-     * language, country, and variant are empty ("") strings.  This is regarded
-     * as the base locale of all locales, and is used as the language/country
-     * neutral locale for the locale sensitive operations.
-     *
-     * @since 1.6
-     */
-    public static final Locale ROOT = createConstant("", "");
+    private static Locale createConstant(byte baseType) {
+        BaseLocale base = BaseLocale.constantBaseLocales[baseType];
+        Locale locale = new Locale(base, null);
+        CONSTANT_LOCALES.put(base, locale);
+        return locale;
+    }
 
     /**
      * The key for the private use extension ('x').
@@ -709,7 +742,7 @@
      * @exception NullPointerException thrown if any argument is null.
      */
     public Locale(String language, String country, String variant) {
-        if (language== null || country == null || variant == null) {
+        if (language == null || country == null || variant == null) {
             throw new NullPointerException();
         }
         baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
@@ -767,15 +800,6 @@
     }
 
     /**
-     * This method must be called only for creating the Locale.*
-     * constants due to making shortcuts.
-     */
-    private static Locale createConstant(String lang, String country) {
-        BaseLocale base = BaseLocale.createInstance(lang, country);
-        return getInstance(base, null);
-    }
-
-    /**
      * Returns a <code>Locale</code> constructed from the given
      * <code>language</code>, <code>country</code> and
      * <code>variant</code>. If the same <code>Locale</code> instance
@@ -803,20 +827,27 @@
             extensions = getCompatibilityExtensions(language, script, country, variant);
         }
 
-        BaseLocale baseloc = BaseLocale.getInstance(language, script, country, variant);
+        BaseLocale baseloc = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
         return getInstance(baseloc, extensions);
     }
 
     static Locale getInstance(BaseLocale baseloc, LocaleExtensions extensions) {
         if (extensions == null) {
-            return LOCALECACHE.get(baseloc);
+            Locale locale = CONSTANT_LOCALES.get(baseloc);
+            if (locale != null) {
+                return locale;
+            }
+            return Cache.LOCALECACHE.get(baseloc);
         } else {
             LocaleKey key = new LocaleKey(baseloc, extensions);
-            return LOCALECACHE.get(key);
+            return Cache.LOCALECACHE.get(key);
         }
     }
 
     private static class Cache extends LocaleObjectCache<Object, Locale> {
+
+        private static final Cache LOCALECACHE = new Cache();
+
         private Cache() {
         }
 
@@ -977,8 +1008,11 @@
     }
 
     private static Optional<LocaleExtensions> getDefaultExtensions(String extensionsProp) {
+        if (LocaleUtils.isEmpty(extensionsProp)) {
+            return Optional.empty();
+        }
+
         LocaleExtensions exts = null;
-
         try {
             exts = new InternalLocaleBuilder()
                 .setExtensions(extensionsProp)
@@ -2308,6 +2342,7 @@
         String country = (String)fields.get("country", "");
         String variant = (String)fields.get("variant", "");
         String extStr = (String)fields.get("extensions", "");
+
         baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
         if (!extStr.isEmpty()) {
             try {
--- a/src/java.base/share/classes/java/util/Map.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/Map.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1286,8 +1286,9 @@
      *
      * @since 9
      */
+    @SuppressWarnings("unchecked")
     static <K, V> Map<K, V> of() {
-        return ImmutableCollections.emptyMap();
+        return (Map<K,V>) ImmutableCollections.MapN.EMPTY_MAP;
     }
 
     /**
@@ -1604,7 +1605,9 @@
     @SuppressWarnings("varargs")
     static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
         if (entries.length == 0) { // implicit null check of entries array
-            return ImmutableCollections.emptyMap();
+            @SuppressWarnings("unchecked")
+            var map = (Map<K,V>) ImmutableCollections.MapN.EMPTY_MAP;
+            return map;
         } else if (entries.length == 1) {
             // implicit null check of the array slot
             return new ImmutableCollections.Map1<>(entries[0].getKey(),
--- a/src/java.base/share/classes/java/util/Optional.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/Optional.java	Tue Apr 09 11:48:54 2019 +0100
@@ -61,7 +61,7 @@
     /**
      * Common instance for {@code empty()}.
      */
-    private static final Optional<?> EMPTY = new Optional<>();
+    private static final Optional<?> EMPTY = new Optional<>(null);
 
     /**
      * If non-null, the value; if null, indicates no value is present
@@ -69,16 +69,6 @@
     private final T value;
 
     /**
-     * Constructs an empty instance.
-     *
-     * @implNote Generally only one empty instance, {@link Optional#EMPTY},
-     * should exist per VM.
-     */
-    private Optional() {
-        this.value = null;
-    }
-
-    /**
      * Returns an empty {@code Optional} instance.  No value is present for this
      * {@code Optional}.
      *
@@ -100,11 +90,12 @@
     /**
      * Constructs an instance with the described value.
      *
-     * @param value the non-{@code null} value to describe
-     * @throws NullPointerException if value is {@code null}
+     * @param value the value to describe; it's the caller's responsibility to
+     *        ensure the value is non-{@code null} unless creating the singleton
+     *        instance returned by {@code empty()}.
      */
     private Optional(T value) {
-        this.value = Objects.requireNonNull(value);
+        this.value = value;
     }
 
     /**
@@ -117,7 +108,7 @@
      * @throws NullPointerException if value is {@code null}
      */
     public static <T> Optional<T> of(T value) {
-        return new Optional<>(value);
+        return new Optional<>(Objects.requireNonNull(value));
     }
 
     /**
@@ -129,8 +120,10 @@
      * @return an {@code Optional} with a present value if the specified value
      *         is non-{@code null}, otherwise an empty {@code Optional}
      */
+    @SuppressWarnings("unchecked")
     public static <T> Optional<T> ofNullable(T value) {
-        return value == null ? empty() : of(value);
+        return value == null ? (Optional<T>) EMPTY
+                             : new Optional<>(value);
     }
 
     /**
--- a/src/java.base/share/classes/java/util/Set.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/Set.java	Tue Apr 09 11:48:54 2019 +0100
@@ -448,8 +448,9 @@
      *
      * @since 9
      */
+    @SuppressWarnings("unchecked")
     static <E> Set<E> of() {
-        return ImmutableCollections.emptySet();
+        return (Set<E>) ImmutableCollections.SetN.EMPTY_SET;
     }
 
     /**
@@ -692,7 +693,9 @@
     static <E> Set<E> of(E... elements) {
         switch (elements.length) { // implicit null check of elements
             case 0:
-                return ImmutableCollections.emptySet();
+                @SuppressWarnings("unchecked")
+                var set = (Set<E>) ImmutableCollections.SetN.EMPTY_SET;
+                return set;
             case 1:
                 return new ImmutableCollections.Set12<>(elements[0]);
             case 2:
--- a/src/java.base/share/classes/java/util/jar/Attributes.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/jar/Attributes.java	Tue Apr 09 11:48:54 2019 +0100
@@ -703,9 +703,12 @@
                 addName(names, SEALED);
                 addName(names, EXTENSION_LIST);
                 addName(names, EXTENSION_NAME);
+                addName(names, EXTENSION_INSTALLATION);
                 addName(names, IMPLEMENTATION_TITLE);
                 addName(names, IMPLEMENTATION_VERSION);
                 addName(names, IMPLEMENTATION_VENDOR);
+                addName(names, IMPLEMENTATION_VENDOR_ID);
+                addName(names, IMPLEMENTATION_URL);
                 addName(names, SPECIFICATION_TITLE);
                 addName(names, SPECIFICATION_VERSION);
                 addName(names, SPECIFICATION_VENDOR);
--- a/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/java/util/spi/CalendarNameProvider.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, 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
@@ -114,8 +114,8 @@
  *     <td>B.E. (Buddhist Era)</td>
  *   </tr>
  *   <tr>
- *     <th scope="row" rowspan="6" style="font-weight:normal; text-align:left; vertical-align:top">{@code "japanese"}</th>
- *     <th scope="row" rowspan="5" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
+ *     <th scope="row" rowspan="7" style="font-weight:normal; text-align:left; vertical-align:top">{@code "japanese"}</th>
+ *     <th scope="row" rowspan="6" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#ERA}</th>
  *     <th scope="row" style="font-weight:normal">0</th>
  *     <td>Seireki (Before Meiji)</td>
  *   </tr>
@@ -133,7 +133,11 @@
  *   </tr>
  *   <tr>
  *     <th scope="row" style="font-weight:normal">4</th>
- *     <td >Heisei</td>
+ *     <td>Heisei</td>
+ *   </tr>
+ *   <tr>
+ *     <th scope="row" style="font-weight:normal">5</th>
+ *     <td>Reiwa</td>
  *   </tr>
  *   <tr>
  *     <th scope="row" style="font-weight:normal; text-align:left; vertical-align:top">{@link Calendar#YEAR}</th>
--- a/src/java.base/share/classes/javax/net/ssl/SSLContext.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/javax/net/ssl/SSLContext.java	Tue Apr 09 11:48:54 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
@@ -26,8 +26,9 @@
 package javax.net.ssl;
 
 import java.security.*;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.VarHandle;
 import java.util.Objects;
-
 import sun.security.jca.GetInstance;
 
 /**
@@ -58,6 +59,20 @@
 
     private final String protocol;
 
+    private static volatile SSLContext defaultContext;
+
+    private static final VarHandle VH_DEFAULT_CONTEXT;
+
+    static {
+        try {
+            VH_DEFAULT_CONTEXT = MethodHandles.lookup()
+                .findStaticVarHandle(
+                    SSLContext.class, "defaultContext", SSLContext.class);
+        } catch (Exception e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
+
     /**
      * Creates an SSLContext object.
      *
@@ -72,8 +87,6 @@
         this.protocol = protocol;
     }
 
-    private static SSLContext defaultContext;
-
     /**
      * Returns the default SSL context.
      *
@@ -91,12 +104,16 @@
      *   {@link SSLContext#getInstance SSLContext.getInstance()} call fails
      * @since 1.6
      */
-    public static synchronized SSLContext getDefault()
-            throws NoSuchAlgorithmException {
-        if (defaultContext == null) {
-            defaultContext = SSLContext.getInstance("Default");
+    public static SSLContext getDefault() throws NoSuchAlgorithmException {
+        SSLContext temporaryContext = defaultContext;
+        if (temporaryContext == null) {
+            temporaryContext = SSLContext.getInstance("Default");
+            if (!VH_DEFAULT_CONTEXT.compareAndSet(null, temporaryContext)) {
+                temporaryContext = defaultContext;
+            }
         }
-        return defaultContext;
+
+        return temporaryContext;
     }
 
     /**
@@ -111,7 +128,7 @@
      *          {@code SSLPermission("setDefaultSSLContext")}
      * @since 1.6
      */
-    public static synchronized void setDefault(SSLContext context) {
+    public static void setDefault(SSLContext context) {
         if (context == null) {
             throw new NullPointerException();
         }
@@ -119,6 +136,7 @@
         if (sm != null) {
             sm.checkPermission(new SSLPermission("setDefaultSSLContext"));
         }
+
         defaultContext = context;
     }
 
--- a/src/java.base/share/classes/javax/net/ssl/SSLContextSpi.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/javax/net/ssl/SSLContextSpi.java	Tue Apr 09 11:48:54 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
@@ -194,10 +194,9 @@
      */
     protected SSLParameters engineGetSupportedSSLParameters() {
         SSLSocket socket = getDefaultSocket();
-        SSLParameters params = new SSLParameters();
+        SSLParameters params = socket.getSSLParameters();
         params.setCipherSuites(socket.getSupportedCipherSuites());
         params.setProtocols(socket.getSupportedProtocols());
         return params;
     }
-
 }
--- a/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java	Tue Apr 09 11:48:54 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
@@ -42,17 +42,7 @@
  * @see SSLServerSocket
  * @author David Brownell
  */
-public abstract class SSLServerSocketFactory extends ServerSocketFactory
-{
-    private static SSLServerSocketFactory theFactory;
-
-    private static boolean propertyChecked;
-
-    private static void log(String msg) {
-        if (SSLSocketFactory.DEBUG) {
-            System.out.println(msg);
-        }
-    }
+public abstract class SSLServerSocketFactory extends ServerSocketFactory {
 
     /**
      * Constructor is used only by subclasses.
@@ -75,39 +65,9 @@
      * @return the default <code>ServerSocketFactory</code>
      * @see SSLContext#getDefault
      */
-    public static synchronized ServerSocketFactory getDefault() {
-        if (theFactory != null) {
-            return theFactory;
-        }
-
-        if (propertyChecked == false) {
-            propertyChecked = true;
-            String clsName = SSLSocketFactory.getSecurityProperty
-                                        ("ssl.ServerSocketFactory.provider");
-            if (clsName != null) {
-                log("setting up default SSLServerSocketFactory");
-                try {
-                    Class<?> cls = null;
-                    try {
-                        cls = Class.forName(clsName);
-                    } catch (ClassNotFoundException e) {
-                        ClassLoader cl = ClassLoader.getSystemClassLoader();
-                        if (cl != null) {
-                            cls = cl.loadClass(clsName);
-                        }
-                    }
-                    log("class " + clsName + " is loaded");
-                    @SuppressWarnings("deprecation")
-                    SSLServerSocketFactory fac = (SSLServerSocketFactory)cls.newInstance();
-                    log("instantiated an instance of class " + clsName);
-                    theFactory = fac;
-                    return fac;
-                } catch (Exception e) {
-                    log("SSLServerSocketFactory instantiation failed: " + e);
-                    theFactory = new DefaultSSLServerSocketFactory(e);
-                    return theFactory;
-                }
-            }
+    public static ServerSocketFactory getDefault() {
+        if (DefaultFactoryHolder.defaultFactory != null) {
+            return DefaultFactoryHolder.defaultFactory;
         }
 
         try {
@@ -156,9 +116,51 @@
      * @see #getDefaultCipherSuites()
      */
     public abstract String [] getSupportedCipherSuites();
+
+    // lazy initialization holder class idiom for static default factory
+    //
+    // See Effective Java Second Edition: Item 71.
+    private static final class DefaultFactoryHolder {
+        private static final SSLServerSocketFactory defaultFactory;
+
+        static {
+            SSLServerSocketFactory mediator = null;
+            String clsName = SSLSocketFactory.getSecurityProperty(
+                    "ssl.ServerSocketFactory.provider");
+            if (clsName != null) {
+                log("setting up default SSLServerSocketFactory");
+                try {
+                    Class<?> cls = null;
+                    try {
+                        cls = Class.forName(clsName);
+                    } catch (ClassNotFoundException e) {
+                        ClassLoader cl = ClassLoader.getSystemClassLoader();
+                        if (cl != null) {
+                            cls = cl.loadClass(clsName);
+                        }
+                    }
+                    log("class " + clsName + " is loaded");
+
+                    mediator = (SSLServerSocketFactory)cls
+                            .getDeclaredConstructor().newInstance();
+                    log("instantiated an instance of class " + clsName);
+                } catch (Exception e) {
+                    log("SSLServerSocketFactory instantiation failed: " + e);
+                    mediator = new DefaultSSLServerSocketFactory(e);
+                }
+            }
+
+            defaultFactory = mediator;
+        }
+
+        private static void log(String msg) {
+            if (SSLSocketFactory.DEBUG) {
+                System.out.println(msg);
+            }
+        }
+    }
 }
 
-
 //
 // The default factory does NOTHING.
 //
--- a/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java	Tue Apr 09 11:48:54 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
@@ -42,31 +42,20 @@
  * @see SSLSocket
  * @author David Brownell
  */
-public abstract class SSLSocketFactory extends SocketFactory
-{
-    private static SSLSocketFactory theFactory;
-
-    private static boolean propertyChecked;
-
+public abstract class SSLSocketFactory extends SocketFactory {
     static final boolean DEBUG;
 
     static {
-        String s = GetPropertyAction.privilegedGetProperty("javax.net.debug", "")
-                .toLowerCase(Locale.ENGLISH);
-
+        String s = GetPropertyAction.privilegedGetProperty(
+                "javax.net.debug", "").toLowerCase(Locale.ENGLISH);
         DEBUG = s.contains("all") || s.contains("ssl");
     }
 
-    private static void log(String msg) {
-        if (DEBUG) {
-            System.out.println(msg);
-        }
-    }
-
     /**
      * Constructor is used only by subclasses.
      */
     public SSLSocketFactory() {
+        // blank
     }
 
     /**
@@ -85,38 +74,9 @@
      * @return the default <code>SocketFactory</code>
      * @see SSLContext#getDefault
      */
-    public static synchronized SocketFactory getDefault() {
-        if (theFactory != null) {
-            return theFactory;
-        }
-
-        if (propertyChecked == false) {
-            propertyChecked = true;
-            String clsName = getSecurityProperty("ssl.SocketFactory.provider");
-            if (clsName != null) {
-                log("setting up default SSLSocketFactory");
-                try {
-                    Class<?> cls = null;
-                    try {
-                        cls = Class.forName(clsName);
-                    } catch (ClassNotFoundException e) {
-                        ClassLoader cl = ClassLoader.getSystemClassLoader();
-                        if (cl != null) {
-                            cls = cl.loadClass(clsName);
-                        }
-                    }
-                    log("class " + clsName + " is loaded");
-                    @SuppressWarnings("deprecation")
-                    SSLSocketFactory fac = (SSLSocketFactory)cls.newInstance();
-                    log("instantiated an instance of class " + clsName);
-                    theFactory = fac;
-                    return fac;
-                } catch (Exception e) {
-                    log("SSLSocketFactory instantiation failed: " + e.toString());
-                    theFactory = new DefaultSSLSocketFactory(e);
-                    return theFactory;
-                }
-            }
+    public static SocketFactory getDefault() {
+        if (DefaultFactoryHolder.defaultFactory != null) {
+            return DefaultFactoryHolder.defaultFactory;
         }
 
         try {
@@ -246,6 +206,49 @@
             boolean autoClose) throws IOException {
         throw new UnsupportedOperationException();
     }
+
+    // lazy initialization holder class idiom for static default factory
+    //
+    // See Effective Java Second Edition: Item 71.
+    private static final class DefaultFactoryHolder {
+        private static final SSLSocketFactory defaultFactory;
+
+        static {
+            SSLSocketFactory mediator = null;
+            String clsName = getSecurityProperty("ssl.SocketFactory.provider");
+            if (clsName != null) {
+                log("setting up default SSLSocketFactory");
+                try {
+                    Class<?> cls = null;
+                    try {
+                        cls = Class.forName(clsName);
+                    } catch (ClassNotFoundException e) {
+                        ClassLoader cl = ClassLoader.getSystemClassLoader();
+                        if (cl != null) {
+                            cls = cl.loadClass(clsName);
+                        }
+                    }
+                    log("class " + clsName + " is loaded");
+
+                    mediator = (SSLSocketFactory)cls
+                            .getDeclaredConstructor().newInstance();
+
+                    log("instantiated an instance of class " + clsName);
+                } catch (Exception e) {
+                    log("SSLSocketFactory instantiation failed: " + e);
+                    mediator = new DefaultSSLSocketFactory(e);
+                }
+            }
+
+            defaultFactory = mediator;
+        }
+
+        private static void log(String msg) {
+            if (DEBUG) {
+                System.out.println(msg);
+            }
+        }
+    }
 }
 
 
--- a/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java	Tue Apr 09 11:48:54 2019 +0100
@@ -64,6 +64,7 @@
 import jdk.internal.misc.VM;
 import jdk.internal.module.ModulePatcher.PatchedModuleReader;
 import jdk.internal.module.Resources;
+import jdk.internal.vm.annotation.Stable;
 
 
 /**
@@ -117,14 +118,18 @@
     private static class LoadedModule {
         private final BuiltinClassLoader loader;
         private final ModuleReference mref;
-        private final URL codeSourceURL;          // may be null
+        private final URI uri;                      // may be null
+        private @Stable URL codeSourceURL;          // may be null
 
         LoadedModule(BuiltinClassLoader loader, ModuleReference mref) {
             URL url = null;
-            if (mref.location().isPresent()) {
-                try {
-                    url = mref.location().get().toURL();
-                } catch (MalformedURLException | IllegalArgumentException e) { }
+            this.uri = mref.location().orElse(null);
+
+            // for non-jrt schemes we need to resolve the codeSourceURL
+            // eagerly during bootstrap since the handler might be
+            // overridden
+            if (uri != null && !"jrt".equals(uri.getScheme())) {
+                url = createURL(uri);
             }
             this.loader = loader;
             this.mref = mref;
@@ -134,7 +139,23 @@
         BuiltinClassLoader loader() { return loader; }
         ModuleReference mref() { return mref; }
         String name() { return mref.descriptor().name(); }
-        URL codeSourceURL() { return codeSourceURL; }
+
+        URL codeSourceURL() {
+            URL url = codeSourceURL;
+            if (url == null && uri != null) {
+                codeSourceURL = url = createURL(uri);
+            }
+            return url;
+        }
+
+        private URL createURL(URI uri) {
+            URL url = null;
+            try {
+                url = uri.toURL();
+            } catch (MalformedURLException | IllegalArgumentException e) {
+            }
+            return url;
+        }
     }
 
 
--- a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Tue Apr 09 11:48:54 2019 +0100
@@ -33,6 +33,7 @@
 import java.lang.reflect.Field;
 import java.security.ProtectionDomain;
 
+import static jdk.internal.misc.UnsafeConstants.*;
 
 /**
  * A collection of methods for performing low-level, unsafe operations.
@@ -1166,14 +1167,13 @@
     }
 
     /** The value of {@code addressSize()} */
-    public static final int ADDRESS_SIZE = theUnsafe.addressSize0();
+    public static final int ADDRESS_SIZE = ADDRESS_SIZE0;
 
     /**
      * Reports the size in bytes of a native memory page (whatever that is).
      * This value will always be a power of two.
      */
-    public native int pageSize();
-
+    public int pageSize() { return PAGE_SIZE; }
 
     /// random trusted operations from JNI:
 
@@ -1417,7 +1417,7 @@
                                              byte x) {
         long wordOffset = offset & ~3;
         int shift = (int) (offset & 3) << 3;
-        if (BE) {
+        if (BIG_ENDIAN) {
             shift = 24 - shift;
         }
         int mask           = 0xFF << shift;
@@ -1491,7 +1491,7 @@
         }
         long wordOffset = offset & ~3;
         int shift = (int) (offset & 3) << 3;
-        if (BE) {
+        if (BIG_ENDIAN) {
             shift = 16 - shift;
         }
         int mask           = 0xFFFF << shift;
@@ -3354,14 +3354,14 @@
      * @return Returns true if the native byte ordering of this
      * platform is big-endian, false if it is little-endian.
      */
-    public final boolean isBigEndian() { return BE; }
+    public final boolean isBigEndian() { return BIG_ENDIAN; }
 
     /**
      * @return Returns true if this platform is capable of performing
      * accesses at addresses which are not aligned for the type of the
      * primitive type being accessed, false otherwise.
      */
-    public final boolean unalignedAccess() { return unalignedAccess; }
+    public final boolean unalignedAccess() { return UNALIGNED_ACCESS; }
 
     /**
      * Fetches a value at some byte offset into a given Java object.
@@ -3603,14 +3603,7 @@
         putCharUnaligned(o, offset, convEndian(bigEndian, x));
     }
 
-    // JVM interface methods
-    // BE is true iff the native endianness of this platform is big.
-    private static final boolean BE = theUnsafe.isBigEndian0();
-
-    // unalignedAccess is true iff this platform can perform unaligned accesses.
-    private static final boolean unalignedAccess = theUnsafe.unalignedAccess0();
-
-    private static int pickPos(int top, int pos) { return BE ? top - pos : pos; }
+    private static int pickPos(int top, int pos) { return BIG_ENDIAN ? top - pos : pos; }
 
     // These methods construct integers from bytes.  The byte ordering
     // is the native endianness of this platform.
@@ -3649,9 +3642,9 @@
                      | (toUnsignedInt(i1) << pickPos(8, 8)));
     }
 
-    private static byte  pick(byte  le, byte  be) { return BE ? be : le; }
-    private static short pick(short le, short be) { return BE ? be : le; }
-    private static int   pick(int   le, int   be) { return BE ? be : le; }
+    private static byte  pick(byte  le, byte  be) { return BIG_ENDIAN ? be : le; }
+    private static short pick(short le, short be) { return BIG_ENDIAN ? be : le; }
+    private static int   pick(int   le, int   be) { return BIG_ENDIAN ? be : le; }
 
     // These methods write integers to memory from smaller parts
     // provided by their caller.  The ordering in which these parts
@@ -3699,10 +3692,10 @@
     private static long toUnsignedLong(int n)   { return n & 0xffffffffl; }
 
     // Maybe byte-reverse an integer
-    private static char convEndian(boolean big, char n)   { return big == BE ? n : Character.reverseBytes(n); }
-    private static short convEndian(boolean big, short n) { return big == BE ? n : Short.reverseBytes(n)    ; }
-    private static int convEndian(boolean big, int n)     { return big == BE ? n : Integer.reverseBytes(n)  ; }
-    private static long convEndian(boolean big, long n)   { return big == BE ? n : Long.reverseBytes(n)     ; }
+    private static char convEndian(boolean big, char n)   { return big == BIG_ENDIAN ? n : Character.reverseBytes(n); }
+    private static short convEndian(boolean big, short n) { return big == BIG_ENDIAN ? n : Short.reverseBytes(n)    ; }
+    private static int convEndian(boolean big, int n)     { return big == BIG_ENDIAN ? n : Integer.reverseBytes(n)  ; }
+    private static long convEndian(boolean big, long n)   { return big == BIG_ENDIAN ? n : Long.reverseBytes(n)     ; }
 
 
 
@@ -3721,11 +3714,8 @@
     private native void ensureClassInitialized0(Class<?> c);
     private native int arrayBaseOffset0(Class<?> arrayClass);
     private native int arrayIndexScale0(Class<?> arrayClass);
-    private native int addressSize0();
     private native Class<?> defineAnonymousClass0(Class<?> hostClass, byte[] data, Object[] cpPatches);
     private native int getLoadAverage0(double[] loadavg, int nelems);
-    private native boolean unalignedAccess0();
-    private native boolean isBigEndian0();
 
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/jdk/internal/misc/UnsafeConstants.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2019, Red Hat Inc. 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.misc;
+
+/**
+ * A class used to expose details of the underlying hardware that
+ * configure the operation of class Unsafe.  This class is
+ * package-private as the only intended client is class Unsafe.
+ * All fields in this class must be static final constants.
+ *
+ * @since 13
+ *
+ * @implNote
+ *
+ * The JVM injects hardware-specific values into all the static fields
+ * of this class during JVM initialization. The static initialization
+ * block is executed when the class is initialized then JVM injection
+ * updates the fields with the correct constants. The static block
+ * is required to prevent the fields from being considered constant
+ * variables, so the field values will be not be compiled directly into
+ * any class that uses them.
+ */
+
+final class UnsafeConstants {
+
+    /**
+     * This constructor is private because the class is not meant to
+     * be instantiated.
+     */
+    private UnsafeConstants() {}
+
+    /**
+     * The size in bytes of a native pointer, as stored via {@link
+     * #putAddress}.  This value will be either 4 or 8.  Note that the
+     * sizes of other primitive types (as stored in native memory
+     * blocks) is determined fully by their information content.
+     *
+     * @implNote
+     * The actual value for this field is injected by the JVM.
+     */
+
+    static final int ADDRESS_SIZE0;
+
+    /**
+     * The size in bytes of a native memory page (whatever that is).
+     * This value will always be a power of two.
+     *
+     * @implNote
+     * The actual value for this field is injected by the JVM.
+     */
+
+    static final int PAGE_SIZE;
+
+    /**
+     * Flag whose value is true if and only if the native endianness
+     * of this platform is big.
+     *
+     * @implNote
+     * The actual value for this field is injected by the JVM.
+     */
+
+    static final boolean BIG_ENDIAN;
+
+    /**
+     * Flag whose value is true if and only if the platform can
+     * perform unaligned accesses
+     *
+     * @implNote
+     * The actual value for this field is injected by the JVM.
+     */
+
+    static final boolean UNALIGNED_ACCESS;
+
+    static {
+        ADDRESS_SIZE0 = 0;
+        PAGE_SIZE = 0;
+        BIG_ENDIAN = false;
+        UNALIGNED_ACCESS = false;
+    }
+}
--- a/src/java.base/share/classes/jdk/internal/reflect/Reflection.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/jdk/internal/reflect/Reflection.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, 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
@@ -122,6 +122,9 @@
                                              Class<?> targetClass,
                                              int modifiers)
     {
+        Objects.requireNonNull(currentClass);
+        Objects.requireNonNull(memberClass);
+
         if (currentClass == memberClass) {
             // Always succeeds
             return true;
@@ -201,6 +204,22 @@
         return true;
     }
 
+    /*
+     * Verify if a member is public and memberClass is a public type
+     * in a package that is unconditionally exported and
+     * return {@code true}if it is granted.
+     *
+     * @param memberClass the declaring class of the member being accessed
+     * @param modifiers the member's access modifiers
+     * @return {@code true} if the member is public and in a publicly accessible type
+     */
+    public static boolean verifyPublicMemberAccess(Class<?> memberClass, int modifiers) {
+        Module m = memberClass.getModule();
+        return Modifier.isPublic(modifiers)
+            && m.isExported(memberClass.getPackageName())
+            && Modifier.isPublic(Reflection.getClassAccessFlags(memberClass));
+    }
+
     /**
      * Returns {@code true} if memberClass's module exports memberClass's
      * package to currentModule.
@@ -325,8 +344,10 @@
                                                                    Class<?> memberClass,
                                                                    Class<?> targetClass,
                                                                    int modifiers)
-        throws IllegalAccessException
     {
+        if (currentClass == null)
+            return newIllegalAccessException(memberClass, modifiers);
+
         String currentSuffix = "";
         String memberSuffix = "";
         Module m1 = currentClass.getModule();
@@ -356,6 +377,36 @@
     }
 
     /**
+     * Returns an IllegalAccessException with an exception message where
+     * there is no caller frame.
+     */
+    private static IllegalAccessException newIllegalAccessException(Class<?> memberClass,
+                                                                    int modifiers)
+    {
+        String memberSuffix = "";
+        Module m2 = memberClass.getModule();
+        if (m2.isNamed())
+            memberSuffix = " (in " + m2 + ")";
+
+        String memberPackageName = memberClass.getPackageName();
+
+        String msg = "JNI attached native thread (null caller frame) cannot access ";
+        if (m2.isExported(memberPackageName)) {
+
+            // module access okay so include the modifiers in the message
+            msg += "a member of " + memberClass + memberSuffix +
+                " with modifiers \"" + Modifier.toString(modifiers) + "\"";
+
+        } else {
+            // module access failed
+            msg += memberClass + memberSuffix+ " because "
+                + m2 + " does not export " + memberPackageName;
+        }
+
+        return new IllegalAccessException(msg);
+    }
+
+    /**
      * Returns true if {@code currentClass} and {@code memberClass}
      * are nestmates - that is, if they have the same nesthost as
      * determined by the VM.
--- a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -57,8 +57,7 @@
 public class HttpsURLConnectionImpl
         extends javax.net.ssl.HttpsURLConnection {
 
-    // NOTE: made protected for plugin so that subclass can set it.
-    protected DelegateHttpsURLConnection delegate;
+    private final DelegateHttpsURLConnection delegate;
 
     HttpsURLConnectionImpl(URL u, Handler handler) throws IOException {
         this(u, null, handler);
@@ -78,13 +77,6 @@
         delegate = new DelegateHttpsURLConnection(url, p, handler, this);
     }
 
-    // NOTE: introduced for plugin
-    // subclass needs to overwrite this to set delegate to
-    // the appropriate delegatee
-    protected HttpsURLConnectionImpl(URL u) throws IOException {
-        super(u);
-    }
-
     /**
      * Create a new HttpClient object, bypassing the cache of
      * HTTP client objects/connections.
@@ -219,11 +211,11 @@
      * - get input, [read input,] get output, [write output]
      */
 
-    public synchronized OutputStream getOutputStream() throws IOException {
+    public OutputStream getOutputStream() throws IOException {
         return delegate.getOutputStream();
     }
 
-    public synchronized InputStream getInputStream() throws IOException {
+    public InputStream getInputStream() throws IOException {
         return delegate.getInputStream();
     }
 
--- a/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/BaseSSLSocketImpl.java	Tue Apr 09 11:48:54 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
@@ -632,7 +632,7 @@
     }
 
     @Override
-    public synchronized void setSoTimeout(int timeout) throws SocketException {
+    public void setSoTimeout(int timeout) throws SocketException {
         if (self == this) {
             super.setSoTimeout(timeout);
         } else {
--- a/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateVerify.java	Tue Apr 09 11:48:54 2019 +0100
@@ -565,7 +565,7 @@
             ClientHandshakeContext chc = (ClientHandshakeContext)context;
             this.signatureScheme = SignatureScheme.getPreferableAlgorithm(
                     chc.peerRequestedSignatureSchemes,
-                    x509Possession.popPrivateKey,
+                    x509Possession,
                     chc.negotiatedProtocol);
             if (signatureScheme == null) {
                 // Unlikely, the credentials generator should have
@@ -866,7 +866,7 @@
 
             this.signatureScheme = SignatureScheme.getPreferableAlgorithm(
                     context.peerRequestedSignatureSchemes,
-                    x509Possession.popPrivateKey,
+                    x509Possession,
                     context.negotiatedProtocol);
             if (signatureScheme == null) {
                 // Unlikely, the credentials generator should have
--- a/src/java.base/share/classes/sun/security/ssl/CipherSuite.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/CipherSuite.java	Tue Apr 09 11:48:54 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
@@ -56,20 +56,22 @@
     // the following criteria:
     // 1. Prefer Suite B compliant cipher suites, see RFC6460 (To be
     //    changed later, see below).
-    // 2. Prefer the stronger bulk cipher, in the order of AES_256(GCM),
+    // 2. Prefer forward secrecy cipher suites.
+    // 3. Prefer the stronger bulk cipher, in the order of AES_256(GCM),
     //    AES_128(GCM), AES_256, AES_128, 3DES-EDE.
-    // 3. Prefer the stronger MAC algorithm, in the order of SHA384,
+    // 4. Prefer the stronger MAC algorithm, in the order of SHA384,
     //    SHA256, SHA, MD5.
-    // 4. Prefer the better performance of key exchange and digital
+    // 5. Prefer the better performance of key exchange and digital
     //    signature algorithm, in the order of ECDHE-ECDSA, ECDHE-RSA,
-    //    RSA, ECDH-ECDSA, ECDH-RSA, DHE-RSA, DHE-DSS.
+    //    DHE-RSA, DHE-DSS, ECDH-ECDSA, ECDH-RSA, RSA.
 
+    // TLS 1.3 cipher suites.
+    TLS_AES_256_GCM_SHA384(
+            0x1302, true, "TLS_AES_256_GCM_SHA384",
+            ProtocolVersion.PROTOCOLS_OF_13, B_AES_256_GCM_IV, H_SHA384),
     TLS_AES_128_GCM_SHA256(
             0x1301, true, "TLS_AES_128_GCM_SHA256",
             ProtocolVersion.PROTOCOLS_OF_13, B_AES_128_GCM_IV, H_SHA256),
-    TLS_AES_256_GCM_SHA384(
-            0x1302, true, "TLS_AES_256_GCM_SHA384",
-            ProtocolVersion.PROTOCOLS_OF_13, B_AES_256_GCM_IV, H_SHA384),
     TLS_CHACHA20_POLY1305_SHA256(
             0x1303, true, "TLS_CHACHA20_POLY1305_SHA256",
             ProtocolVersion.PROTOCOLS_OF_13, B_CC20_P1305, H_SHA256),
@@ -97,7 +99,11 @@
             ProtocolVersion.PROTOCOLS_OF_12,
             K_ECDHE_ECDSA, B_CC20_P1305, M_NULL, H_SHA256),
 
-    // AES_256(GCM)
+    //
+    // Forward screcy cipher suites.
+    //
+
+    // AES_256(GCM) - ECDHE
     TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384(
             0xC030, true, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "",
             ProtocolVersion.PROTOCOLS_OF_12,
@@ -106,18 +112,14 @@
             0xCCA8, true, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "",
             ProtocolVersion.PROTOCOLS_OF_12,
             K_ECDHE_RSA, B_CC20_P1305, M_NULL, H_SHA256),
-    TLS_RSA_WITH_AES_256_GCM_SHA384(
-            0x009D, true, "TLS_RSA_WITH_AES_256_GCM_SHA384", "",
+
+    // AES_128(GCM) - ECDHE
+    TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256(
+            0xC02F, true, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "",
             ProtocolVersion.PROTOCOLS_OF_12,
-            K_RSA, B_AES_256_GCM, M_NULL, H_SHA384),
-    TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384(
-            0xC02E, true, "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDH_ECDSA, B_AES_256_GCM, M_NULL, H_SHA384),
-    TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384(
-            0xC032, true, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDH_RSA, B_AES_256_GCM, M_NULL, H_SHA384),
+            K_ECDHE_RSA, B_AES_128_GCM, M_NULL, H_SHA256),
+
+    // AES_256(GCM) - DHE
     TLS_DHE_RSA_WITH_AES_256_GCM_SHA384(
             0x009F, true, "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", "",
             ProtocolVersion.PROTOCOLS_OF_12,
@@ -131,23 +133,7 @@
             ProtocolVersion.PROTOCOLS_OF_12,
             K_DHE_DSS, B_AES_256_GCM, M_NULL, H_SHA384),
 
-    // AES_128(GCM)
-    TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256(
-            0xC02F, true, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDHE_RSA, B_AES_128_GCM, M_NULL, H_SHA256),
-    TLS_RSA_WITH_AES_128_GCM_SHA256(
-            0x009C, true, "TLS_RSA_WITH_AES_128_GCM_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_RSA, B_AES_128_GCM, M_NULL, H_SHA256),
-    TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256(
-            0xC02D, true, "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDH_ECDSA, B_AES_128_GCM, M_NULL, H_SHA256),
-    TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256(
-            0xC031, true, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDH_RSA, B_AES_128_GCM, M_NULL, H_SHA256),
+    // AES_128(GCM) - DHE
     TLS_DHE_RSA_WITH_AES_128_GCM_SHA256(
             0x009E, true, "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", "",
             ProtocolVersion.PROTOCOLS_OF_12,
@@ -157,7 +143,7 @@
             ProtocolVersion.PROTOCOLS_OF_12,
             K_DHE_DSS, B_AES_128_GCM, M_NULL, H_SHA256),
 
-    // AES_256(CBC)
+    // AES_256(CBC) - ECDHE
     TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384(
             0xC024, true, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "",
             ProtocolVersion.PROTOCOLS_OF_12,
@@ -166,18 +152,18 @@
             0xC028, true, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "",
             ProtocolVersion.PROTOCOLS_OF_12,
             K_ECDHE_RSA, B_AES_256, M_SHA384, H_SHA384),
-    TLS_RSA_WITH_AES_256_CBC_SHA256(
-            0x003D, true, "TLS_RSA_WITH_AES_256_CBC_SHA256", "",
+
+    // AES_128(CBC) - ECDHE
+    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256(
+            0xC023, true, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "",
             ProtocolVersion.PROTOCOLS_OF_12,
-            K_RSA, B_AES_256, M_SHA256, H_SHA256),
-    TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384(
-            0xC026, true, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", "",
+            K_ECDHE_ECDSA, B_AES_128, M_SHA256, H_SHA256),
+    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256(
+            0xC027, true, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "",
             ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDH_ECDSA, B_AES_256, M_SHA384, H_SHA384),
-    TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384(
-            0xC02A, true, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDH_RSA, B_AES_256, M_SHA384, H_SHA384),
+            K_ECDHE_RSA, B_AES_128, M_SHA256, H_SHA256),
+
+    // AES_256(CBC) - DHE
     TLS_DHE_RSA_WITH_AES_256_CBC_SHA256(
             0x006B, true, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", "",
             ProtocolVersion.PROTOCOLS_OF_12,
@@ -187,6 +173,65 @@
             ProtocolVersion.PROTOCOLS_OF_12,
             K_DHE_DSS, B_AES_256, M_SHA256, H_SHA256),
 
+    // AES_128(CBC) - DHE
+    TLS_DHE_RSA_WITH_AES_128_CBC_SHA256(
+            0x0067, true, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_DHE_RSA, B_AES_128, M_SHA256, H_SHA256),
+    TLS_DHE_DSS_WITH_AES_128_CBC_SHA256(
+            0x0040, true, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_DHE_DSS, B_AES_128, M_SHA256, H_SHA256),
+
+    //
+    // not forward screcy cipher suites.
+    //
+
+    // AES_256(GCM)
+    TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384(
+            0xC02E, true, "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_ECDH_ECDSA, B_AES_256_GCM, M_NULL, H_SHA384),
+    TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384(
+            0xC032, true, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_ECDH_RSA, B_AES_256_GCM, M_NULL, H_SHA384),
+
+    // AES_128(GCM)
+    TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256(
+            0xC02D, true, "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_ECDH_ECDSA, B_AES_128_GCM, M_NULL, H_SHA256),
+    TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256(
+            0xC031, true, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_ECDH_RSA, B_AES_128_GCM, M_NULL, H_SHA256),
+
+    // AES_256(CBC)
+    TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384(
+            0xC026, true, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_ECDH_ECDSA, B_AES_256, M_SHA384, H_SHA384),
+    TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384(
+            0xC02A, true, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_ECDH_RSA, B_AES_256, M_SHA384, H_SHA384),
+
+    // AES_128(CBC)
+    TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256(
+            0xC025, true, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_ECDH_ECDSA, B_AES_128, M_SHA256, H_SHA256),
+    TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256(
+            0xC029, true, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_ECDH_RSA, B_AES_128, M_SHA256, H_SHA256),
+
+    //
+    // Legacy, used for compatibility
+    //
+
+    // AES_256(CBC) - ECDHE - Using SHA
     TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA(
             0xC00A, true, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "",
             ProtocolVersion.PROTOCOLS_TO_12,
@@ -195,18 +240,18 @@
             0xC014, true, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "",
             ProtocolVersion.PROTOCOLS_TO_12,
             K_ECDHE_RSA, B_AES_256, M_SHA, H_SHA256),
-    TLS_RSA_WITH_AES_256_CBC_SHA(
-            0x0035, true, "TLS_RSA_WITH_AES_256_CBC_SHA", "",
+
+    // AES_128(CBC) - ECDHE - using SHA
+    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA(
+            0xC009, true, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "",
             ProtocolVersion.PROTOCOLS_TO_12,
-            K_RSA, B_AES_256, M_SHA, H_SHA256),
-    TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA(
-            0xC005, true, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", "",
+            K_ECDHE_ECDSA, B_AES_128, M_SHA, H_SHA256),
+    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA(
+            0xC013, true, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "",
             ProtocolVersion.PROTOCOLS_TO_12,
-            K_ECDH_ECDSA, B_AES_256, M_SHA, H_SHA256),
-    TLS_ECDH_RSA_WITH_AES_256_CBC_SHA(
-            0xC00F, true, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", "",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_ECDH_RSA, B_AES_256, M_SHA, H_SHA256),
+            K_ECDHE_RSA, B_AES_128, M_SHA, H_SHA256),
+
+    // AES_256(CBC) - DHE - Using SHA
     TLS_DHE_RSA_WITH_AES_256_CBC_SHA(
             0x0039, true, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", "",
             ProtocolVersion.PROTOCOLS_TO_12,
@@ -216,56 +261,7 @@
             ProtocolVersion.PROTOCOLS_TO_12,
             K_DHE_DSS, B_AES_256, M_SHA, H_SHA256),
 
-    // AES_128(CBC)
-    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256(
-            0xC023, true, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDHE_ECDSA, B_AES_128, M_SHA256, H_SHA256),
-    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256(
-            0xC027, true, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDHE_RSA, B_AES_128, M_SHA256, H_SHA256),
-    TLS_RSA_WITH_AES_128_CBC_SHA256(
-            0x003C, true, "TLS_RSA_WITH_AES_128_CBC_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_RSA, B_AES_128, M_SHA256, H_SHA256),
-    TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256(
-            0xC025, true, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDH_ECDSA, B_AES_128, M_SHA256, H_SHA256),
-    TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256(
-            0xC029, true, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_ECDH_RSA, B_AES_128, M_SHA256, H_SHA256),
-    TLS_DHE_RSA_WITH_AES_128_CBC_SHA256(
-            0x0067, true, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_DHE_RSA, B_AES_128, M_SHA256, H_SHA256),
-    TLS_DHE_DSS_WITH_AES_128_CBC_SHA256(
-            0x0040, true, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", "",
-            ProtocolVersion.PROTOCOLS_OF_12,
-            K_DHE_DSS, B_AES_128, M_SHA256, H_SHA256),
-
-    TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA(
-            0xC009, true, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_ECDHE_ECDSA, B_AES_128, M_SHA, H_SHA256),
-    TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA(
-            0xC013, true, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_ECDHE_RSA, B_AES_128, M_SHA, H_SHA256),
-    TLS_RSA_WITH_AES_128_CBC_SHA(
-            0x002F, true, "TLS_RSA_WITH_AES_128_CBC_SHA", "",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_RSA, B_AES_128, M_SHA, H_SHA256),
-    TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA(
-            0xC004, true, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", "",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_ECDH_ECDSA, B_AES_128, M_SHA, H_SHA256),
-    TLS_ECDH_RSA_WITH_AES_128_CBC_SHA(
-            0xC00E, true, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", "",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_ECDH_RSA, B_AES_128, M_SHA, H_SHA256),
+    // AES_128(CBC) - DHE - using SHA
     TLS_DHE_RSA_WITH_AES_128_CBC_SHA(
             0x0033, true, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "",
             ProtocolVersion.PROTOCOLS_TO_12,
@@ -275,7 +271,67 @@
             ProtocolVersion.PROTOCOLS_TO_12,
             K_DHE_DSS, B_AES_128, M_SHA, H_SHA256),
 
-    // 3DES_EDE
+    // AES_256(CBC) - using SHA, not forward screcy
+    TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA(
+            0xC005, true, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", "",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_ECDH_ECDSA, B_AES_256, M_SHA, H_SHA256),
+    TLS_ECDH_RSA_WITH_AES_256_CBC_SHA(
+            0xC00F, true, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", "",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_ECDH_RSA, B_AES_256, M_SHA, H_SHA256),
+
+    // AES_128(CBC) - using SHA, not forward screcy
+    TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA(
+            0xC004, true, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", "",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_ECDH_ECDSA, B_AES_128, M_SHA, H_SHA256),
+    TLS_ECDH_RSA_WITH_AES_128_CBC_SHA(
+            0xC00E, true, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", "",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_ECDH_RSA, B_AES_128, M_SHA, H_SHA256),
+
+    //
+    // deprecated, used for compatibility
+    //
+
+    // RSA, AES_256(GCM)
+    TLS_RSA_WITH_AES_256_GCM_SHA384(
+            0x009D, true, "TLS_RSA_WITH_AES_256_GCM_SHA384", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_RSA, B_AES_256_GCM, M_NULL, H_SHA384),
+
+    // RSA, AES_128(GCM)
+    TLS_RSA_WITH_AES_128_GCM_SHA256(
+            0x009C, true, "TLS_RSA_WITH_AES_128_GCM_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_RSA, B_AES_128_GCM, M_NULL, H_SHA256),
+
+    // RSA, AES_256(CBC)
+    TLS_RSA_WITH_AES_256_CBC_SHA256(
+            0x003D, true, "TLS_RSA_WITH_AES_256_CBC_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_RSA, B_AES_256, M_SHA256, H_SHA256),
+
+    // RSA, AES_128(CBC)
+    TLS_RSA_WITH_AES_128_CBC_SHA256(
+            0x003C, true, "TLS_RSA_WITH_AES_128_CBC_SHA256", "",
+            ProtocolVersion.PROTOCOLS_OF_12,
+            K_RSA, B_AES_128, M_SHA256, H_SHA256),
+
+    // RSA, AES_256(CBC) - using SHA, not forward screcy
+    TLS_RSA_WITH_AES_256_CBC_SHA(
+            0x0035, true, "TLS_RSA_WITH_AES_256_CBC_SHA", "",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_RSA, B_AES_256, M_SHA, H_SHA256),
+
+    // RSA, AES_128(CBC) - using SHA, not forward screcy
+    TLS_RSA_WITH_AES_128_CBC_SHA(
+            0x002F, true, "TLS_RSA_WITH_AES_128_CBC_SHA", "",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_RSA, B_AES_128, M_SHA, H_SHA256),
+
+    // 3DES_EDE, forward secrecy.
     TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA(
             0xC008, true, "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", "",
             ProtocolVersion.PROTOCOLS_TO_12,
@@ -284,19 +340,6 @@
             0xC012, true, "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", "",
             ProtocolVersion.PROTOCOLS_TO_12,
             K_ECDHE_RSA, B_3DES, M_SHA, H_SHA256),
-    SSL_RSA_WITH_3DES_EDE_CBC_SHA(
-            0x000A, true, "SSL_RSA_WITH_3DES_EDE_CBC_SHA",
-                          "TLS_RSA_WITH_3DES_EDE_CBC_SHA",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_RSA, B_3DES, M_SHA, H_SHA256),
-    TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA(
-            0xC003, true, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", "",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_ECDH_ECDSA, B_3DES, M_SHA, H_SHA256),
-    TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA(
-            0xC00D, true, "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", "",
-            ProtocolVersion.PROTOCOLS_TO_12,
-            K_ECDH_RSA, B_3DES, M_SHA, H_SHA256),
     SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA(
             0x0016, true, "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
                           "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
@@ -308,6 +351,21 @@
             ProtocolVersion.PROTOCOLS_TO_12,
             K_DHE_DSS, B_3DES, M_SHA, H_SHA256),
 
+    // 3DES_EDE, not forward secrecy.
+    TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA(
+            0xC003, true, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", "",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_ECDH_ECDSA, B_3DES, M_SHA, H_SHA256),
+    TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA(
+            0xC00D, true, "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", "",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_ECDH_RSA, B_3DES, M_SHA, H_SHA256),
+    SSL_RSA_WITH_3DES_EDE_CBC_SHA(
+            0x000A, true, "SSL_RSA_WITH_3DES_EDE_CBC_SHA",
+                          "TLS_RSA_WITH_3DES_EDE_CBC_SHA",
+            ProtocolVersion.PROTOCOLS_TO_12,
+            K_RSA, B_3DES, M_SHA, H_SHA256),
+
     // Renegotiation protection request Signalling Cipher Suite Value (SCSV).
     TLS_EMPTY_RENEGOTIATION_INFO_SCSV(        //  RFC 5746, TLS 1.2 and prior
             0x00FF, true, "TLS_EMPTY_RENEGOTIATION_INFO_SCSV", "",
--- a/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/DHServerKeyExchange.java	Tue Apr 09 11:48:54 2019 +0100
@@ -127,7 +127,7 @@
                 if (useExplicitSigAlgorithm) {
                     signatureScheme = SignatureScheme.getPreferableAlgorithm(
                             shc.peerRequestedSignatureSchemes,
-                            x509Possession.popPrivateKey,
+                            x509Possession,
                             shc.negotiatedProtocol);
                     if (signatureScheme == null) {
                         // Unlikely, the credentials generator should have
--- a/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/DTLSInputRecord.java	Tue Apr 09 11:48:54 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
@@ -58,7 +58,7 @@
     }
 
     @Override
-    public synchronized void close() throws IOException {
+    public void close() throws IOException {
         if (!isClosed) {
             super.close();
         }
--- a/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/DTLSOutputRecord.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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,13 +58,18 @@
     }
 
     @Override
-    public synchronized void close() throws IOException {
-        if (!isClosed) {
-            if (fragmenter != null && fragmenter.hasAlert()) {
-                isCloseWaiting = true;
-            } else {
-                super.close();
+    public void close() throws IOException {
+        recordLock.lock();
+        try {
+            if (!isClosed) {
+                if (fragmenter != null && fragmenter.hasAlert()) {
+                    isCloseWaiting = true;
+                } else {
+                    super.close();
+                }
             }
+        } finally {
+            recordLock.unlock();
         }
     }
 
--- a/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/ECDHClientKeyExchange.java	Tue Apr 09 11:48:54 2019 +0100
@@ -31,9 +31,7 @@
 import java.security.CryptoPrimitive;
 import java.security.GeneralSecurityException;
 import java.security.KeyFactory;
-import java.security.PrivateKey;
 import java.security.PublicKey;
-import java.security.interfaces.ECPrivateKey;
 import java.security.interfaces.ECPublicKey;
 import java.security.spec.ECParameterSpec;
 import java.security.spec.ECPoint;
@@ -285,14 +283,13 @@
                     "No expected EC server cert for ECDH client key exchange");
             }
 
-            PrivateKey privateKey = x509Possession.popPrivateKey;
-            if (!privateKey.getAlgorithm().equals("EC")) {
+            ECParameterSpec params = x509Possession.getECParameterSpec();
+            if (params == null) {
                 // unlikely, have been checked during cipher suite negotiation.
                 throw shc.conContext.fatal(Alert.ILLEGAL_PARAMETER,
                     "Not EC server cert for ECDH client key exchange");
             }
 
-            ECParameterSpec params = ((ECPrivateKey)privateKey).getParams();
             NamedGroup namedGroup = NamedGroup.valueOf(params);
             if (namedGroup == null) {
                 // unlikely, have been checked during cipher suite negotiation.
--- a/src/java.base/share/classes/sun/security/ssl/ECDHKeyExchange.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/ECDHKeyExchange.java	Tue Apr 09 11:48:54 2019 +0100
@@ -35,7 +35,6 @@
 import java.security.PrivateKey;
 import java.security.PublicKey;
 import java.security.SecureRandom;
-import java.security.interfaces.ECPrivateKey;
 import java.security.interfaces.ECPublicKey;
 import java.security.spec.AlgorithmParameterSpec;
 import java.security.spec.ECGenParameterSpec;
@@ -265,12 +264,12 @@
                     continue;
                 }
 
-                PrivateKey privateKey = ((X509Possession)poss).popPrivateKey;
-                if (!privateKey.getAlgorithm().equals("EC")) {
+                ECParameterSpec params =
+                        ((X509Possession)poss).getECParameterSpec();
+                if (params == null) {
                     continue;
                 }
 
-                ECParameterSpec params = ((ECPrivateKey)privateKey).getParams();
                 NamedGroup ng = NamedGroup.valueOf(params);
                 if (ng == null) {
                     // unlikely, have been checked during cipher suite negotiation.
--- a/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/ECDHServerKeyExchange.java	Tue Apr 09 11:48:54 2019 +0100
@@ -142,7 +142,7 @@
                 if (useExplicitSigAlgorithm) {
                     signatureScheme = SignatureScheme.getPreferableAlgorithm(
                             shc.peerRequestedSignatureSchemes,
-                            x509Possession.popPrivateKey,
+                            x509Possession,
                             shc.negotiatedProtocol);
                     if (signatureScheme == null) {
                         // Unlikely, the credentials generator should have
--- a/src/java.base/share/classes/sun/security/ssl/EphemeralKeyManager.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/EphemeralKeyManager.java	Tue Apr 09 11:48:54 2019 +0100
@@ -26,6 +26,7 @@
 package sun.security.ssl;
 
 import java.security.*;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * The "KeyManager" for ephemeral RSA keys. Ephemeral DH and ECDH keys
@@ -48,6 +49,8 @@
         new EphemeralKeyPair(null),
     };
 
+    private final ReentrantLock cachedKeysLock = new ReentrantLock();
+
     EphemeralKeyManager() {
         // empty
     }
@@ -65,20 +68,32 @@
             index = INDEX_RSA1024;
         }
 
-        synchronized (keys) {
-            KeyPair kp = keys[index].getKeyPair();
-            if (kp == null) {
-                try {
-                    KeyPairGenerator kgen = KeyPairGenerator.getInstance("RSA");
-                    kgen.initialize(length, random);
-                    keys[index] = new EphemeralKeyPair(kgen.genKeyPair());
-                    kp = keys[index].getKeyPair();
-                } catch (Exception e) {
-                    // ignore
-                }
-            }
+        KeyPair kp = keys[index].getKeyPair();
+        if (kp != null) {
             return kp;
         }
+
+        cachedKeysLock.lock();
+        try {
+            // double check
+            kp = keys[index].getKeyPair();
+            if (kp != null) {
+                return kp;
+            }
+
+            try {
+                KeyPairGenerator kgen = KeyPairGenerator.getInstance("RSA");
+                kgen.initialize(length, random);
+                keys[index] = new EphemeralKeyPair(kgen.genKeyPair());
+                kp = keys[index].getKeyPair();
+            } catch (Exception e) {
+                // ignore
+            }
+        } finally {
+            cachedKeysLock.unlock();
+        }
+
+        return kp;
     }
 
     /**
--- a/src/java.base/share/classes/sun/security/ssl/HelloCookieManager.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/HelloCookieManager.java	Tue Apr 09 11:48:54 2019 +0100
@@ -30,6 +30,7 @@
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.util.Arrays;
+import java.util.concurrent.locks.ReentrantLock;
 import static sun.security.ssl.ClientHello.ClientHelloMessage;
 
 /**
@@ -45,6 +46,8 @@
         private volatile D13HelloCookieManager d13HelloCookieManager;
         private volatile T13HelloCookieManager t13HelloCookieManager;
 
+        private final ReentrantLock managerLock = new ReentrantLock();
+
         Builder(SecureRandom secureRandom) {
             this.secureRandom = secureRandom;
         }
@@ -56,11 +59,14 @@
                         return d13HelloCookieManager;
                     }
 
-                    synchronized (this) {
+                    managerLock.lock();
+                    try {
                         if (d13HelloCookieManager == null) {
                             d13HelloCookieManager =
                                     new D13HelloCookieManager(secureRandom);
                         }
+                    } finally {
+                        managerLock.unlock();
                     }
 
                     return d13HelloCookieManager;
@@ -69,11 +75,14 @@
                         return d10HelloCookieManager;
                     }
 
-                    synchronized (this) {
+                    managerLock.lock();
+                    try {
                         if (d10HelloCookieManager == null) {
                             d10HelloCookieManager =
                                     new D10HelloCookieManager(secureRandom);
                         }
+                    } finally {
+                        managerLock.unlock();
                     }
 
                     return d10HelloCookieManager;
@@ -84,11 +93,14 @@
                         return t13HelloCookieManager;
                     }
 
-                    synchronized (this) {
+                    managerLock.lock();
+                    try {
                         if (t13HelloCookieManager == null) {
                             t13HelloCookieManager =
                                     new T13HelloCookieManager(secureRandom);
                         }
+                    } finally {
+                        managerLock.unlock();
                     }
 
                     return t13HelloCookieManager;
@@ -114,6 +126,8 @@
         private byte[]      cookieSecret;
         private byte[]      legacySecret;
 
+        private final ReentrantLock d10ManagerLock = new ReentrantLock();
+
         D10HelloCookieManager(SecureRandom secureRandom) {
             this.secureRandom = secureRandom;
 
@@ -131,7 +145,8 @@
             int version;
             byte[] secret;
 
-            synchronized (this) {
+            d10ManagerLock.lock();
+            try {
                 version = cookieVersion;
                 secret = cookieSecret;
 
@@ -142,6 +157,8 @@
                 }
 
                 cookieVersion++;
+            } finally {
+                d10ManagerLock.unlock();
             }
 
             MessageDigest md;
@@ -168,12 +185,15 @@
             }
 
             byte[] secret;
-            synchronized (this) {
+            d10ManagerLock.lock();
+            try {
                 if (((cookieVersion >> 24) & 0xFF) == cookie[0]) {
                     secret = cookieSecret;
                 } else {
                     secret = legacySecret;  // including out of window cookies
                 }
+            } finally {
+                d10ManagerLock.unlock();
             }
 
             MessageDigest md;
@@ -218,6 +238,8 @@
         private final byte[]    cookieSecret;
         private final byte[]    legacySecret;
 
+        private final ReentrantLock t13ManagerLock = new ReentrantLock();
+
         T13HelloCookieManager(SecureRandom secureRandom) {
             this.secureRandom = secureRandom;
             this.cookieVersion = secureRandom.nextInt();
@@ -234,7 +256,8 @@
             int version;
             byte[] secret;
 
-            synchronized (this) {
+            t13ManagerLock.lock();
+            try {
                 version = cookieVersion;
                 secret = cookieSecret;
 
@@ -245,6 +268,8 @@
                 }
 
                 cookieVersion++;        // allow wrapped version number
+            } finally {
+                t13ManagerLock.unlock();
             }
 
             MessageDigest md;
@@ -313,12 +338,15 @@
                     Arrays.copyOfRange(cookie, 3 + hashLen, cookie.length);
 
             byte[] secret;
-            synchronized (this) {
+            t13ManagerLock.lock();
+            try {
                 if ((byte)((cookieVersion >> 24) & 0xFF) == cookie[2]) {
                     secret = cookieSecret;
                 } else {
                     secret = legacySecret;  // including out of window cookies
                 }
+            } finally {
+                t13ManagerLock.unlock();
             }
 
             MessageDigest md;
--- a/src/java.base/share/classes/sun/security/ssl/InputRecord.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/InputRecord.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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 @@
 import java.io.OutputStream;
 import java.nio.BufferUnderflowException;
 import java.nio.ByteBuffer;
+import java.util.concurrent.locks.ReentrantLock;
 import javax.crypto.BadPaddingException;
 import sun.security.ssl.SSLCipher.SSLReadCipher;
 
@@ -43,10 +44,10 @@
 abstract class InputRecord implements Record, Closeable {
     SSLReadCipher       readCipher;
     // Needed for KeyUpdate, used after Handshake.Finished
-    TransportContext            tc;
+    TransportContext    tc;
 
     final HandshakeHash handshakeHash;
-    boolean             isClosed;
+    volatile boolean    isClosed;
 
     // The ClientHello version to accept. If set to ProtocolVersion.SSL20Hello
     // and the first message we read is a ClientHello in V2 format, we convert
@@ -56,6 +57,8 @@
     // fragment size
     int                 fragmentSize;
 
+    final ReentrantLock recordLock = new ReentrantLock();
+
     InputRecord(HandshakeHash handshakeHash, SSLReadCipher readCipher) {
         this.readCipher = readCipher;
         this.helloVersion = ProtocolVersion.TLS10;
@@ -92,14 +95,19 @@
      * and flag the record as holding no data.
      */
     @Override
-    public synchronized void close() throws IOException {
-        if (!isClosed) {
-            isClosed = true;
-            readCipher.dispose();
+    public void close() throws IOException {
+        recordLock.lock();
+        try {
+            if (!isClosed) {
+                isClosed = true;
+                readCipher.dispose();
+            }
+        } finally {
+            recordLock.unlock();
         }
     }
 
-    synchronized boolean isClosed() {
+    boolean isClosed() {
         return isClosed;
     }
 
--- a/src/java.base/share/classes/sun/security/ssl/OutputRecord.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/OutputRecord.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -30,6 +30,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
+import java.util.concurrent.locks.ReentrantLock;
 import sun.security.ssl.SSLCipher.SSLWriteCipher;
 
 /**
@@ -68,6 +69,8 @@
     // closed or not?
     volatile boolean            isClosed;
 
+    final ReentrantLock recordLock = new ReentrantLock();
+
     /*
      * Mappings from V3 cipher suite encodings to their pure V2 equivalents.
      * This is taken from the SSL V3 specification, Appendix E.
@@ -89,15 +92,25 @@
         // Please set packetSize and protocolVersion in the implementation.
     }
 
-    synchronized void setVersion(ProtocolVersion protocolVersion) {
-        this.protocolVersion = protocolVersion;
+    void setVersion(ProtocolVersion protocolVersion) {
+        recordLock.lock();
+        try {
+            this.protocolVersion = protocolVersion;
+        } finally {
+            recordLock.unlock();
+        }
     }
 
     /*
      * Updates helloVersion of this record.
      */
-    synchronized void setHelloVersion(ProtocolVersion helloVersion) {
-        this.helloVersion = helloVersion;
+    void setHelloVersion(ProtocolVersion helloVersion) {
+        recordLock.lock();
+        try {
+            this.helloVersion = helloVersion;
+        } finally {
+            recordLock.unlock();
+        }
     }
 
     /*
@@ -108,9 +121,14 @@
         return false;
     }
 
-    synchronized boolean seqNumIsHuge() {
-        return (writeCipher.authenticator != null) &&
+    boolean seqNumIsHuge() {
+        recordLock.lock();
+        try {
+            return (writeCipher.authenticator != null) &&
                         writeCipher.authenticator.seqNumIsHuge();
+        } finally {
+            recordLock.unlock();
+        }
     }
 
     // SSLEngine and SSLSocket
@@ -148,68 +166,93 @@
     }
 
     // Change write ciphers, may use change_cipher_spec record.
-    synchronized void changeWriteCiphers(SSLWriteCipher writeCipher,
+    void changeWriteCiphers(SSLWriteCipher writeCipher,
             boolean useChangeCipherSpec) throws IOException {
-        if (isClosed()) {
-            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                SSLLogger.warning("outbound has closed, ignore outbound " +
-                    "change_cipher_spec message");
+        recordLock.lock();
+        try {
+            if (isClosed()) {
+                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                    SSLLogger.warning("outbound has closed, ignore outbound " +
+                        "change_cipher_spec message");
+                }
+                return;
+            }
+
+            if (useChangeCipherSpec) {
+                encodeChangeCipherSpec();
             }
-            return;
-        }
 
-        if (useChangeCipherSpec) {
-            encodeChangeCipherSpec();
+            /*
+             * Dispose of any intermediate state in the underlying cipher.
+             * For PKCS11 ciphers, this will release any attached sessions,
+             * and thus make finalization faster.
+             *
+             * Since MAC's doFinal() is called for every SSL/TLS packet, it's
+             * not necessary to do the same with MAC's.
+             */
+            writeCipher.dispose();
+
+            this.writeCipher = writeCipher;
+            this.isFirstAppOutputRecord = true;
+        } finally {
+            recordLock.unlock();
         }
-
-        /*
-         * Dispose of any intermediate state in the underlying cipher.
-         * For PKCS11 ciphers, this will release any attached sessions,
-         * and thus make finalization faster.
-         *
-         * Since MAC's doFinal() is called for every SSL/TLS packet, it's
-         * not necessary to do the same with MAC's.
-         */
-        writeCipher.dispose();
-
-        this.writeCipher = writeCipher;
-        this.isFirstAppOutputRecord = true;
     }
 
     // Change write ciphers using key_update handshake message.
-    synchronized void changeWriteCiphers(SSLWriteCipher writeCipher,
+    void changeWriteCiphers(SSLWriteCipher writeCipher,
             byte keyUpdateRequest) throws IOException {
-        if (isClosed()) {
-            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                SSLLogger.warning("outbound has closed, ignore outbound " +
-                    "key_update handshake message");
+        recordLock.lock();
+        try {
+            if (isClosed()) {
+                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                    SSLLogger.warning("outbound has closed, ignore outbound " +
+                        "key_update handshake message");
+                }
+                return;
             }
-            return;
-        }
 
-        // encode the handshake message, KeyUpdate
-        byte[] hm = HANDSHAKE_MESSAGE_KEY_UPDATE.clone();
-        hm[hm.length - 1] = keyUpdateRequest;
-        encodeHandshake(hm, 0, hm.length);
-        flush();
+            // encode the handshake message, KeyUpdate
+            byte[] hm = HANDSHAKE_MESSAGE_KEY_UPDATE.clone();
+            hm[hm.length - 1] = keyUpdateRequest;
+            encodeHandshake(hm, 0, hm.length);
+            flush();
 
-        // Dispose of any intermediate state in the underlying cipher.
-        writeCipher.dispose();
+            // Dispose of any intermediate state in the underlying cipher.
+            writeCipher.dispose();
 
-        this.writeCipher = writeCipher;
-        this.isFirstAppOutputRecord = true;
+            this.writeCipher = writeCipher;
+            this.isFirstAppOutputRecord = true;
+        } finally {
+            recordLock.unlock();
+        }
     }
 
-    synchronized void changePacketSize(int packetSize) {
-        this.packetSize = packetSize;
+    void changePacketSize(int packetSize) {
+        recordLock.lock();
+        try {
+            this.packetSize = packetSize;
+        } finally {
+            recordLock.unlock();
+        }
     }
 
-    synchronized void changeFragmentSize(int fragmentSize) {
-        this.fragmentSize = fragmentSize;
+    void changeFragmentSize(int fragmentSize) {
+        recordLock.lock();
+        try {
+            this.fragmentSize = fragmentSize;
+        } finally {
+            recordLock.unlock();
+        }
     }
 
-    synchronized int getMaxPacketSize() {
-        return packetSize;
+    int getMaxPacketSize() {
+        recordLock.lock();
+        try {
+            return packetSize;
+        } finally {
+            recordLock.unlock();
+        }
     }
 
     // apply to DTLS SSLEngine
@@ -228,13 +271,18 @@
     }
 
     @Override
-    public synchronized void close() throws IOException {
-        if (isClosed) {
-            return;
+    public void close() throws IOException {
+        recordLock.lock();
+        try {
+            if (isClosed) {
+                return;
+            }
+
+            isClosed = true;
+            writeCipher.dispose();
+        } finally {
+            recordLock.unlock();
         }
-
-        isClosed = true;
-        writeCipher.dispose();
     }
 
     boolean isClosed() {
--- a/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java	Tue Apr 09 11:48:54 2019 +0100
@@ -126,7 +126,7 @@
         this.identificationProtocol = null;
         this.serverNames = Collections.<SNIServerName>emptyList();
         this.sniMatchers = Collections.<SNIMatcher>emptyList();
-        this.preferLocalCipherSuites = false;
+        this.preferLocalCipherSuites = true;
 
         this.applicationProtocols = new String[0];
         this.enableRetransmissions = sslContext.isDTLS();
--- a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -30,6 +30,7 @@
 import java.security.*;
 import java.security.cert.*;
 import java.util.*;
+import java.util.concurrent.locks.ReentrantLock;
 import javax.net.ssl.*;
 import sun.security.action.GetPropertyAction;
 import sun.security.provider.certpath.AlgorithmChecker;
@@ -69,6 +70,8 @@
 
     private volatile StatusResponseManager statusResponseManager;
 
+    private final ReentrantLock contextLock = new ReentrantLock();
+
     SSLContextImpl() {
         ephemeralKeyManager = new EphemeralKeyManager();
         clientCache = new SSLSessionContextImpl();
@@ -230,11 +233,14 @@
     // Used for DTLS in server mode only.
     HelloCookieManager getHelloCookieManager(ProtocolVersion protocolVersion) {
         if (helloCookieManagerBuilder == null) {
-            synchronized (this) {
+            contextLock.lock();
+            try {
                 if (helloCookieManagerBuilder == null) {
                     helloCookieManagerBuilder =
                             new HelloCookieManager.Builder(secureRandom);
                 }
+            } finally {
+                contextLock.unlock();
             }
         }
 
@@ -243,7 +249,8 @@
 
     StatusResponseManager getStatusResponseManager() {
         if (serverEnableStapling && statusResponseManager == null) {
-            synchronized (this) {
+            contextLock.lock();
+            try {
                 if (statusResponseManager == null) {
                     if (SSLLogger.isOn && SSLLogger.isOn("ssl,sslctx")) {
                         SSLLogger.finest(
@@ -251,6 +258,8 @@
                     }
                     statusResponseManager = new StatusResponseManager();
                 }
+            } finally {
+                contextLock.unlock();
             }
         }
 
--- a/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SSLEngineImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, 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,7 @@
 import java.security.PrivilegedExceptionAction;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.locks.ReentrantLock;
 import java.util.function.BiFunction;
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLEngineResult;
@@ -54,6 +55,7 @@
 final class SSLEngineImpl extends SSLEngine implements SSLTransport {
     private final SSLContextImpl        sslContext;
     final TransportContext              conContext;
+    private final ReentrantLock         engineLock = new ReentrantLock();
 
     /**
      * Constructor for an SSLEngine from SSLContext, without
@@ -93,57 +95,68 @@
     }
 
     @Override
-    public synchronized void beginHandshake() throws SSLException {
-        if (conContext.isUnsureMode) {
-            throw new IllegalStateException(
-                    "Client/Server mode has not yet been set.");
-        }
-
+    public void beginHandshake() throws SSLException {
+        engineLock.lock();
         try {
-            conContext.kickstart();
-        } catch (IOException ioe) {
-            throw conContext.fatal(Alert.HANDSHAKE_FAILURE,
-                "Couldn't kickstart handshaking", ioe);
-        } catch (Exception ex) {     // including RuntimeException
-            throw conContext.fatal(Alert.INTERNAL_ERROR,
-                "Fail to begin handshake", ex);
+            if (conContext.isUnsureMode) {
+                throw new IllegalStateException(
+                        "Client/Server mode has not yet been set.");
+            }
+
+            try {
+                conContext.kickstart();
+            } catch (IOException ioe) {
+                throw conContext.fatal(Alert.HANDSHAKE_FAILURE,
+                    "Couldn't kickstart handshaking", ioe);
+            } catch (Exception ex) {     // including RuntimeException
+                throw conContext.fatal(Alert.INTERNAL_ERROR,
+                    "Fail to begin handshake", ex);
+            }
+        } finally {
+            engineLock.unlock();
         }
     }
 
     @Override
-    public synchronized SSLEngineResult wrap(ByteBuffer[] appData,
+    public SSLEngineResult wrap(ByteBuffer[] appData,
             int offset, int length, ByteBuffer netData) throws SSLException {
         return wrap(appData, offset, length, new ByteBuffer[]{ netData }, 0, 1);
     }
 
     // @Override
-    public synchronized SSLEngineResult wrap(
+    public SSLEngineResult wrap(
         ByteBuffer[] srcs, int srcsOffset, int srcsLength,
         ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws SSLException {
 
-        if (conContext.isUnsureMode) {
-            throw new IllegalStateException(
-                    "Client/Server mode has not yet been set.");
-        }
-
-        // See if the handshaker needs to report back some SSLException.
-        checkTaskThrown();
-
-        // check parameters
-        checkParams(srcs, srcsOffset, srcsLength, dsts, dstsOffset, dstsLength);
-
+        engineLock.lock();
         try {
-            return writeRecord(
-                srcs, srcsOffset, srcsLength, dsts, dstsOffset, dstsLength);
-        } catch (SSLProtocolException spe) {
-            // may be an unexpected handshake message
-            throw conContext.fatal(Alert.UNEXPECTED_MESSAGE, spe);
-        } catch (IOException ioe) {
-            throw conContext.fatal(Alert.INTERNAL_ERROR,
-                "problem wrapping app data", ioe);
-        } catch (Exception ex) {     // including RuntimeException
-            throw conContext.fatal(Alert.INTERNAL_ERROR,
-                "Fail to wrap application data", ex);
+            if (conContext.isUnsureMode) {
+                throw new IllegalStateException(
+                        "Client/Server mode has not yet been set.");
+            }
+
+            // See if the handshaker needs to report back some SSLException.
+            checkTaskThrown();
+
+            // check parameters
+            checkParams(srcs, srcsOffset, srcsLength,
+                    dsts, dstsOffset, dstsLength);
+
+            try {
+                return writeRecord(
+                    srcs, srcsOffset, srcsLength, dsts, dstsOffset, dstsLength);
+            } catch (SSLProtocolException spe) {
+                // may be an unexpected handshake message
+                throw conContext.fatal(Alert.UNEXPECTED_MESSAGE, spe);
+            } catch (IOException ioe) {
+                throw conContext.fatal(Alert.INTERNAL_ERROR,
+                    "problem wrapping app data", ioe);
+            } catch (Exception ex) {     // including RuntimeException
+                throw conContext.fatal(Alert.INTERNAL_ERROR,
+                    "Fail to wrap application data", ex);
+            }
+        } finally {
+            engineLock.unlock();
         }
     }
 
@@ -428,47 +441,53 @@
     }
 
     @Override
-    public synchronized SSLEngineResult unwrap(ByteBuffer src,
+    public SSLEngineResult unwrap(ByteBuffer src,
             ByteBuffer[] dsts, int offset, int length) throws SSLException {
         return unwrap(
                 new ByteBuffer[]{src}, 0, 1, dsts, offset, length);
     }
 
     // @Override
-    public synchronized SSLEngineResult unwrap(
+    public SSLEngineResult unwrap(
         ByteBuffer[] srcs, int srcsOffset, int srcsLength,
         ByteBuffer[] dsts, int dstsOffset, int dstsLength) throws SSLException {
 
-        if (conContext.isUnsureMode) {
-            throw new IllegalStateException(
-                    "Client/Server mode has not yet been set.");
-        }
-
-        // See if the handshaker needs to report back some SSLException.
-        checkTaskThrown();
-
-        // check parameters
-        checkParams(srcs, srcsOffset, srcsLength, dsts, dstsOffset, dstsLength);
-
+        engineLock.lock();
         try {
-            return readRecord(
-                srcs, srcsOffset, srcsLength, dsts, dstsOffset, dstsLength);
-        } catch (SSLProtocolException spe) {
-            // may be an unexpected handshake message
-            throw conContext.fatal(Alert.UNEXPECTED_MESSAGE,
-                    spe.getMessage(), spe);
-        } catch (IOException ioe) {
-            /*
-             * Don't reset position so it looks like we didn't
-             * consume anything.  We did consume something, and it
-             * got us into this situation, so report that much back.
-             * Our days of consuming are now over anyway.
-             */
-            throw conContext.fatal(Alert.INTERNAL_ERROR,
-                    "problem unwrapping net record", ioe);
-        } catch (Exception ex) {     // including RuntimeException
-            throw conContext.fatal(Alert.INTERNAL_ERROR,
-                "Fail to unwrap network record", ex);
+            if (conContext.isUnsureMode) {
+                throw new IllegalStateException(
+                        "Client/Server mode has not yet been set.");
+            }
+
+            // See if the handshaker needs to report back some SSLException.
+            checkTaskThrown();
+
+            // check parameters
+            checkParams(srcs, srcsOffset, srcsLength,
+                    dsts, dstsOffset, dstsLength);
+
+            try {
+                return readRecord(
+                    srcs, srcsOffset, srcsLength, dsts, dstsOffset, dstsLength);
+            } catch (SSLProtocolException spe) {
+                // may be an unexpected handshake message
+                throw conContext.fatal(Alert.UNEXPECTED_MESSAGE,
+                        spe.getMessage(), spe);
+            } catch (IOException ioe) {
+                /*
+                 * Don't reset position so it looks like we didn't
+                 * consume anything.  We did consume something, and it
+                 * got us into this situation, so report that much back.
+                 * Our days of consuming are now over anyway.
+                 */
+                throw conContext.fatal(Alert.INTERNAL_ERROR,
+                        "problem unwrapping net record", ioe);
+            } catch (Exception ex) {     // including RuntimeException
+                throw conContext.fatal(Alert.INTERNAL_ERROR,
+                    "Fail to unwrap network record", ex);
+            }
+        } finally {
+            engineLock.unlock();
         }
     }
 
@@ -703,61 +722,87 @@
     }
 
     @Override
-    public synchronized Runnable getDelegatedTask() {
-        if (conContext.handshakeContext != null && // PRE or POST handshake
-                !conContext.handshakeContext.taskDelegated &&
-                !conContext.handshakeContext.delegatedActions.isEmpty()) {
-            conContext.handshakeContext.taskDelegated = true;
-            return new DelegatedTask(this);
+    public Runnable getDelegatedTask() {
+        engineLock.lock();
+        try {
+            if (conContext.handshakeContext != null && // PRE or POST handshake
+                    !conContext.handshakeContext.taskDelegated &&
+                    !conContext.handshakeContext.delegatedActions.isEmpty()) {
+                conContext.handshakeContext.taskDelegated = true;
+                return new DelegatedTask(this);
+            }
+        } finally {
+            engineLock.unlock();
         }
 
         return null;
     }
 
     @Override
-    public synchronized void closeInbound() throws SSLException {
-        if (isInboundDone()) {
-            return;
-        }
+    public void closeInbound() throws SSLException {
+        engineLock.lock();
+        try {
+            if (isInboundDone()) {
+                return;
+            }
 
-        if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-            SSLLogger.finest("Closing inbound of SSLEngine");
-        }
+            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                SSLLogger.finest("Closing inbound of SSLEngine");
+            }
 
-        // Is it ready to close inbound?
-        //
-        // No need to throw exception if the initial handshake is not started.
-        if (!conContext.isInputCloseNotified &&
-            (conContext.isNegotiated || conContext.handshakeContext != null)) {
+            // Is it ready to close inbound?
+            //
+            // No exception if the initial handshake is not started.
+            if (!conContext.isInputCloseNotified &&
+                (conContext.isNegotiated ||
+                    conContext.handshakeContext != null)) {
 
-            throw conContext.fatal(Alert.INTERNAL_ERROR,
-                    "closing inbound before receiving peer's close_notify");
+                throw conContext.fatal(Alert.INTERNAL_ERROR,
+                        "closing inbound before receiving peer's close_notify");
+            }
+
+            conContext.closeInbound();
+        } finally {
+            engineLock.unlock();
         }
-
-        conContext.closeInbound();
     }
 
     @Override
-    public synchronized boolean isInboundDone() {
-        return conContext.isInboundClosed();
+    public boolean isInboundDone() {
+        engineLock.lock();
+        try {
+            return conContext.isInboundClosed();
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void closeOutbound() {
-        if (conContext.isOutboundClosed()) {
-            return;
-        }
+    public void closeOutbound() {
+        engineLock.lock();
+        try {
+            if (conContext.isOutboundClosed()) {
+                return;
+            }
 
-        if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-            SSLLogger.finest("Closing outbound of SSLEngine");
+            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                SSLLogger.finest("Closing outbound of SSLEngine");
+            }
+
+            conContext.closeOutbound();
+        } finally {
+            engineLock.unlock();
         }
-
-        conContext.closeOutbound();
     }
 
     @Override
-    public synchronized boolean isOutboundDone() {
-        return conContext.isOutboundDone();
+    public boolean isOutboundDone() {
+        engineLock.lock();
+        try {
+            return conContext.isOutboundDone();
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
@@ -766,14 +811,24 @@
     }
 
     @Override
-    public synchronized String[] getEnabledCipherSuites() {
-        return CipherSuite.namesOf(conContext.sslConfig.enabledCipherSuites);
+    public String[] getEnabledCipherSuites() {
+        engineLock.lock();
+        try {
+            return CipherSuite.namesOf(conContext.sslConfig.enabledCipherSuites);
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setEnabledCipherSuites(String[] suites) {
-        conContext.sslConfig.enabledCipherSuites =
-                CipherSuite.validValuesOf(suites);
+    public void setEnabledCipherSuites(String[] suites) {
+        engineLock.lock();
+        try {
+            conContext.sslConfig.enabledCipherSuites =
+                    CipherSuite.validValuesOf(suites);
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
@@ -783,119 +838,214 @@
     }
 
     @Override
-    public synchronized String[] getEnabledProtocols() {
-        return ProtocolVersion.toStringArray(
-                conContext.sslConfig.enabledProtocols);
-    }
-
-    @Override
-    public synchronized void setEnabledProtocols(String[] protocols) {
-        if (protocols == null) {
-            throw new IllegalArgumentException("Protocols cannot be null");
+    public String[] getEnabledProtocols() {
+        engineLock.lock();
+        try {
+            return ProtocolVersion.toStringArray(
+                    conContext.sslConfig.enabledProtocols);
+        } finally {
+            engineLock.unlock();
         }
-
-        conContext.sslConfig.enabledProtocols =
-                ProtocolVersion.namesOf(protocols);
     }
 
     @Override
-    public synchronized SSLSession getSession() {
-        return conContext.conSession;
-    }
+    public void setEnabledProtocols(String[] protocols) {
+        engineLock.lock();
+        try {
+            if (protocols == null) {
+                throw new IllegalArgumentException("Protocols cannot be null");
+            }
 
-    @Override
-    public synchronized SSLSession getHandshakeSession() {
-        return conContext.handshakeContext == null ?
-                null : conContext.handshakeContext.handshakeSession;
+            conContext.sslConfig.enabledProtocols =
+                    ProtocolVersion.namesOf(protocols);
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized SSLEngineResult.HandshakeStatus getHandshakeStatus() {
-        return conContext.getHandshakeStatus();
+    public SSLSession getSession() {
+        engineLock.lock();
+        try {
+            return conContext.conSession;
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setUseClientMode(boolean mode) {
-        conContext.setUseClientMode(mode);
-    }
-
-    @Override
-    public synchronized boolean getUseClientMode() {
-        return conContext.sslConfig.isClientMode;
+    public SSLSession getHandshakeSession() {
+        engineLock.lock();
+        try {
+            return conContext.handshakeContext == null ?
+                    null : conContext.handshakeContext.handshakeSession;
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setNeedClientAuth(boolean need) {
-        conContext.sslConfig.clientAuthType =
-                (need ? ClientAuthType.CLIENT_AUTH_REQUIRED :
-                        ClientAuthType.CLIENT_AUTH_NONE);
+    public SSLEngineResult.HandshakeStatus getHandshakeStatus() {
+        engineLock.lock();
+        try {
+            return conContext.getHandshakeStatus();
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized boolean getNeedClientAuth() {
-        return (conContext.sslConfig.clientAuthType ==
-                        ClientAuthType.CLIENT_AUTH_REQUIRED);
-    }
-
-    @Override
-    public synchronized void setWantClientAuth(boolean want) {
-        conContext.sslConfig.clientAuthType =
-                (want ? ClientAuthType.CLIENT_AUTH_REQUESTED :
-                        ClientAuthType.CLIENT_AUTH_NONE);
+    public void setUseClientMode(boolean mode) {
+        engineLock.lock();
+        try {
+            conContext.setUseClientMode(mode);
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized boolean getWantClientAuth() {
-        return (conContext.sslConfig.clientAuthType ==
-                        ClientAuthType.CLIENT_AUTH_REQUESTED);
-    }
-
-    @Override
-    public synchronized void setEnableSessionCreation(boolean flag) {
-        conContext.sslConfig.enableSessionCreation = flag;
+    public boolean getUseClientMode() {
+        engineLock.lock();
+        try {
+            return conContext.sslConfig.isClientMode;
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized boolean getEnableSessionCreation() {
-        return conContext.sslConfig.enableSessionCreation;
+    public void setNeedClientAuth(boolean need) {
+        engineLock.lock();
+        try {
+            conContext.sslConfig.clientAuthType =
+                    (need ? ClientAuthType.CLIENT_AUTH_REQUIRED :
+                            ClientAuthType.CLIENT_AUTH_NONE);
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized SSLParameters getSSLParameters() {
-        return conContext.sslConfig.getSSLParameters();
-    }
-
-    @Override
-    public synchronized void setSSLParameters(SSLParameters params) {
-        conContext.sslConfig.setSSLParameters(params);
-
-        if (conContext.sslConfig.maximumPacketSize != 0) {
-            conContext.outputRecord.changePacketSize(
-                    conContext.sslConfig.maximumPacketSize);
+    public boolean getNeedClientAuth() {
+        engineLock.lock();
+        try {
+            return (conContext.sslConfig.clientAuthType ==
+                            ClientAuthType.CLIENT_AUTH_REQUIRED);
+        } finally {
+            engineLock.unlock();
         }
     }
 
     @Override
-    public synchronized String getApplicationProtocol() {
-        return conContext.applicationProtocol;
+    public void setWantClientAuth(boolean want) {
+        engineLock.lock();
+        try {
+            conContext.sslConfig.clientAuthType =
+                    (want ? ClientAuthType.CLIENT_AUTH_REQUESTED :
+                            ClientAuthType.CLIENT_AUTH_NONE);
+        } finally {
+            engineLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean getWantClientAuth() {
+        engineLock.lock();
+        try {
+            return (conContext.sslConfig.clientAuthType ==
+                            ClientAuthType.CLIENT_AUTH_REQUESTED);
+        } finally {
+            engineLock.unlock();
+        }
+    }
+
+    @Override
+    public void setEnableSessionCreation(boolean flag) {
+        engineLock.lock();
+        try {
+            conContext.sslConfig.enableSessionCreation = flag;
+        } finally {
+            engineLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean getEnableSessionCreation() {
+        engineLock.lock();
+        try {
+            return conContext.sslConfig.enableSessionCreation;
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized String getHandshakeApplicationProtocol() {
-        return conContext.handshakeContext == null ?
-                null : conContext.handshakeContext.applicationProtocol;
+    public SSLParameters getSSLParameters() {
+        engineLock.lock();
+        try {
+            return conContext.sslConfig.getSSLParameters();
+        } finally {
+            engineLock.unlock();
+        }
+   }
+
+    @Override
+    public void setSSLParameters(SSLParameters params) {
+        engineLock.lock();
+        try {
+            conContext.sslConfig.setSSLParameters(params);
+
+            if (conContext.sslConfig.maximumPacketSize != 0) {
+                conContext.outputRecord.changePacketSize(
+                        conContext.sslConfig.maximumPacketSize);
+            }
+        } finally {
+            engineLock.unlock();
+        }
+   }
+
+    @Override
+    public String getApplicationProtocol() {
+        engineLock.lock();
+        try {
+            return conContext.applicationProtocol;
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setHandshakeApplicationProtocolSelector(
-            BiFunction<SSLEngine, List<String>, String> selector) {
-        conContext.sslConfig.engineAPSelector = selector;
+    public String getHandshakeApplicationProtocol() {
+        engineLock.lock();
+        try {
+            return conContext.handshakeContext == null ?
+                    null : conContext.handshakeContext.applicationProtocol;
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
-    public synchronized BiFunction<SSLEngine, List<String>, String>
+    public void setHandshakeApplicationProtocolSelector(
+            BiFunction<SSLEngine, List<String>, String> selector) {
+        engineLock.lock();
+        try {
+            conContext.sslConfig.engineAPSelector = selector;
+        } finally {
+            engineLock.unlock();
+        }
+    }
+
+    @Override
+    public BiFunction<SSLEngine, List<String>, String>
             getHandshakeApplicationProtocolSelector() {
-        return conContext.sslConfig.engineAPSelector;
+        engineLock.lock();
+        try {
+            return conContext.sslConfig.engineAPSelector;
+        } finally {
+            engineLock.unlock();
+        }
     }
 
     @Override
@@ -909,38 +1059,42 @@
      * null, report back the Exception that happened in the delegated
      * task(s).
      */
-    private synchronized void checkTaskThrown() throws SSLException {
+    private void checkTaskThrown() throws SSLException {
 
         Exception exc = null;
-
-        // First check the handshake context.
-        HandshakeContext hc = conContext.handshakeContext;
-        if ((hc != null) && (hc.delegatedThrown != null)) {
-            exc = hc.delegatedThrown;
-            hc.delegatedThrown = null;
-        }
+        engineLock.lock();
+        try {
+            // First check the handshake context.
+            HandshakeContext hc = conContext.handshakeContext;
+            if ((hc != null) && (hc.delegatedThrown != null)) {
+                exc = hc.delegatedThrown;
+                hc.delegatedThrown = null;
+            }
 
-        /*
-         * hc.delegatedThrown and conContext.delegatedThrown are most likely
-         * the same, but it's possible we could have had a non-fatal
-         * exception and thus the new HandshakeContext is still valid
-         * (alert warning).  If so, then we may have a secondary exception
-         * waiting to be reported from the TransportContext, so we will
-         * need to clear that on a successive call.  Otherwise, clear it now.
-         */
-        if (conContext.delegatedThrown != null) {
-            if (exc != null) {
-                // hc object comparison
-                if (conContext.delegatedThrown == exc) {
-                    // clear if/only if both are the same
+            /*
+             * hc.delegatedThrown and conContext.delegatedThrown are most
+             * likely the same, but it's possible we could have had a non-fatal
+             * exception and thus the new HandshakeContext is still valid
+             * (alert warning).  If so, then we may have a secondary exception
+             * waiting to be reported from the TransportContext, so we will
+             * need to clear that on a successive call. Otherwise, clear it now.
+             */
+            if (conContext.delegatedThrown != null) {
+                if (exc != null) {
+                    // hc object comparison
+                    if (conContext.delegatedThrown == exc) {
+                        // clear if/only if both are the same
+                        conContext.delegatedThrown = null;
+                    } // otherwise report the hc delegatedThrown
+                } else {
+                    // Nothing waiting in HandshakeContext, but one is in the
+                    // TransportContext.
+                    exc = conContext.delegatedThrown;
                     conContext.delegatedThrown = null;
-                } // otherwise report the hc delegatedThrown
-            } else {
-                // Nothing waiting in HandshakeContext, but one is in the
-                // TransportContext.
-                exc = conContext.delegatedThrown;
-                conContext.delegatedThrown = null;
+                }
             }
+        } finally {
+            engineLock.unlock();
         }
 
         // Anything to report?
@@ -998,7 +1152,8 @@
 
         @Override
         public void run() {
-            synchronized (engine) {
+            engine.engineLock.lock();
+            try {
                 HandshakeContext hc = engine.conContext.handshakeContext;
                 if (hc == null || hc.delegatedActions.isEmpty()) {
                     return;
@@ -1055,6 +1210,8 @@
                 if (hc != null) {
                     hc.taskDelegated = false;
                 }
+            } finally {
+                engine.engineLock.unlock();
             }
         }
 
--- a/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SSLEngineOutputRecord.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -51,13 +51,18 @@
     }
 
     @Override
-    public synchronized void close() throws IOException {
-        if (!isClosed) {
-            if (fragmenter != null && fragmenter.hasAlert()) {
-                isCloseWaiting = true;
-            } else {
-                super.close();
+    public void close() throws IOException {
+        recordLock.lock();
+        try {
+            if (!isClosed) {
+                if (fragmenter != null && fragmenter.hasAlert()) {
+                    isCloseWaiting = true;
+                } else {
+                    super.close();
+                }
             }
+        } finally {
+            recordLock.unlock();
         }
     }
 
--- a/src/java.base/share/classes/sun/security/ssl/SSLServerSocketImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SSLServerSocketImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -28,6 +28,7 @@
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
+import java.util.concurrent.locks.ReentrantLock;
 import javax.net.ssl.SSLParameters;
 import javax.net.ssl.SSLServerSocket;
 
@@ -56,6 +57,7 @@
 final class SSLServerSocketImpl extends SSLServerSocket {
     private final SSLContextImpl        sslContext;
     private final SSLConfiguration      sslConfig;
+    private final ReentrantLock         serverSocketLock = new ReentrantLock();
 
     SSLServerSocketImpl(SSLContextImpl sslContext) throws IOException {
 
@@ -84,14 +86,24 @@
     }
 
     @Override
-    public synchronized String[] getEnabledCipherSuites() {
-        return CipherSuite.namesOf(sslConfig.enabledCipherSuites);
+    public String[] getEnabledCipherSuites() {
+        serverSocketLock.lock();
+        try {
+            return CipherSuite.namesOf(sslConfig.enabledCipherSuites);
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setEnabledCipherSuites(String[] suites) {
-        sslConfig.enabledCipherSuites =
-                CipherSuite.validValuesOf(suites);
+    public void setEnabledCipherSuites(String[] suites) {
+        serverSocketLock.lock();
+        try {
+            sslConfig.enabledCipherSuites =
+                    CipherSuite.validValuesOf(suites);
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
@@ -106,93 +118,153 @@
     }
 
     @Override
-    public synchronized String[] getEnabledProtocols() {
-        return ProtocolVersion.toStringArray(sslConfig.enabledProtocols);
+    public String[] getEnabledProtocols() {
+        serverSocketLock.lock();
+        try {
+            return ProtocolVersion.toStringArray(sslConfig.enabledProtocols);
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setEnabledProtocols(String[] protocols) {
-        if (protocols == null) {
-            throw new IllegalArgumentException("Protocols cannot be null");
-        }
-
-        sslConfig.enabledProtocols = ProtocolVersion.namesOf(protocols);
-    }
+    public void setEnabledProtocols(String[] protocols) {
+        serverSocketLock.lock();
+        try {
+            if (protocols == null) {
+                throw new IllegalArgumentException("Protocols cannot be null");
+            }
 
-    @Override
-    public synchronized void setNeedClientAuth(boolean need) {
-        sslConfig.clientAuthType =
-                (need ? ClientAuthType.CLIENT_AUTH_REQUIRED :
-                        ClientAuthType.CLIENT_AUTH_NONE);
-    }
-
-    @Override
-    public synchronized boolean getNeedClientAuth() {
-        return (sslConfig.clientAuthType ==
-                        ClientAuthType.CLIENT_AUTH_REQUIRED);
+            sslConfig.enabledProtocols = ProtocolVersion.namesOf(protocols);
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setWantClientAuth(boolean want) {
-        sslConfig.clientAuthType =
-                (want ? ClientAuthType.CLIENT_AUTH_REQUESTED :
-                        ClientAuthType.CLIENT_AUTH_NONE);
-    }
-
-    @Override
-    public synchronized boolean getWantClientAuth() {
-        return (sslConfig.clientAuthType ==
-                        ClientAuthType.CLIENT_AUTH_REQUESTED);
+    public void setNeedClientAuth(boolean need) {
+        serverSocketLock.lock();
+        try {
+            sslConfig.clientAuthType =
+                    (need ? ClientAuthType.CLIENT_AUTH_REQUIRED :
+                            ClientAuthType.CLIENT_AUTH_NONE);
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setUseClientMode(boolean useClientMode) {
-        /*
-         * If we need to change the client mode and the enabled
-         * protocols and cipher suites haven't specifically been
-         * set by the user, change them to the corresponding
-         * default ones.
-         */
-        if (sslConfig.isClientMode != useClientMode) {
-            if (sslContext.isDefaultProtocolVesions(
-                    sslConfig.enabledProtocols)) {
-                sslConfig.enabledProtocols =
-                        sslContext.getDefaultProtocolVersions(!useClientMode);
-            }
+    public boolean getNeedClientAuth() {
+        serverSocketLock.lock();
+        try {
+            return (sslConfig.clientAuthType ==
+                        ClientAuthType.CLIENT_AUTH_REQUIRED);
+        } finally {
+            serverSocketLock.unlock();
+        }
+    }
 
-            if (sslContext.isDefaultCipherSuiteList(
-                    sslConfig.enabledCipherSuites)) {
-                sslConfig.enabledCipherSuites =
-                        sslContext.getDefaultCipherSuites(!useClientMode);
-            }
+    @Override
+    public void setWantClientAuth(boolean want) {
+        serverSocketLock.lock();
+        try {
+            sslConfig.clientAuthType =
+                    (want ? ClientAuthType.CLIENT_AUTH_REQUESTED :
+                            ClientAuthType.CLIENT_AUTH_NONE);
+        } finally {
+            serverSocketLock.unlock();
+        }
+    }
 
-            sslConfig.isClientMode = useClientMode;
+    @Override
+    public boolean getWantClientAuth() {
+        serverSocketLock.lock();
+        try {
+            return (sslConfig.clientAuthType ==
+                        ClientAuthType.CLIENT_AUTH_REQUESTED);
+        } finally {
+            serverSocketLock.unlock();
         }
     }
 
     @Override
-    public synchronized boolean getUseClientMode() {
-        return sslConfig.isClientMode;
-    }
+    public void setUseClientMode(boolean useClientMode) {
+        serverSocketLock.lock();
+        try {
+            /*
+             * If we need to change the client mode and the enabled
+             * protocols and cipher suites haven't specifically been
+             * set by the user, change them to the corresponding
+             * default ones.
+             */
+            if (sslConfig.isClientMode != useClientMode) {
+                if (sslContext.isDefaultProtocolVesions(
+                        sslConfig.enabledProtocols)) {
+                    sslConfig.enabledProtocols =
+                        sslContext.getDefaultProtocolVersions(!useClientMode);
+                }
 
-    @Override
-    public synchronized void setEnableSessionCreation(boolean flag) {
-        sslConfig.enableSessionCreation = flag;
+                if (sslContext.isDefaultCipherSuiteList(
+                        sslConfig.enabledCipherSuites)) {
+                    sslConfig.enabledCipherSuites =
+                        sslContext.getDefaultCipherSuites(!useClientMode);
+                }
+
+                sslConfig.isClientMode = useClientMode;
+            }
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized boolean getEnableSessionCreation() {
-        return sslConfig.enableSessionCreation;
+    public boolean getUseClientMode() {
+        serverSocketLock.lock();
+        try {
+            return sslConfig.isClientMode;
+        } finally {
+            serverSocketLock.unlock();
+        }
+    }
+
+    @Override
+    public void setEnableSessionCreation(boolean flag) {
+        serverSocketLock.lock();
+        try {
+            sslConfig.enableSessionCreation = flag;
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized SSLParameters getSSLParameters() {
-        return sslConfig.getSSLParameters();
+    public boolean getEnableSessionCreation() {
+        serverSocketLock.lock();
+        try {
+            return sslConfig.enableSessionCreation;
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setSSLParameters(SSLParameters params) {
-        sslConfig.setSSLParameters(params);
+    public SSLParameters getSSLParameters() {
+        serverSocketLock.lock();
+        try {
+            return sslConfig.getSSLParameters();
+        } finally {
+            serverSocketLock.unlock();
+        }
+    }
+
+    @Override
+    public void setSSLParameters(SSLParameters params) {
+        serverSocketLock.lock();
+        try {
+            sslConfig.setSSLParameters(params);
+        } finally {
+            serverSocketLock.unlock();
+        }
     }
 
     @Override
--- a/src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSessionImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -38,6 +38,7 @@
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.locks.ReentrantLock;
 import javax.crypto.SecretKey;
 import javax.net.ssl.ExtendedSSLSession;
 import javax.net.ssl.SNIServerName;
@@ -133,7 +134,9 @@
 
     // The endpoint identification algorithm used to check certificates
     // in this session.
-    private final String              identificationProtocol;
+    private final String        identificationProtocol;
+
+    private final ReentrantLock sessionLock = new ReentrantLock();
 
     /*
      * Create a new non-rejoinable session, using the default (null)
@@ -289,15 +292,22 @@
         return resumptionMasterSecret;
     }
 
-    synchronized SecretKey getPreSharedKey() {
-        return preSharedKey;
+    SecretKey getPreSharedKey() {
+        sessionLock.lock();
+        try {
+            return preSharedKey;
+        } finally {
+            sessionLock.unlock();
+        }
     }
 
-    synchronized SecretKey consumePreSharedKey() {
+    SecretKey consumePreSharedKey() {
+        sessionLock.lock();
         try {
             return preSharedKey;
         } finally {
             preSharedKey = null;
+            sessionLock.unlock();
         }
     }
 
@@ -313,11 +323,13 @@
      * be used once. This method will return the identity and then clear it
      * so it cannot be used again.
      */
-    synchronized byte[] consumePskIdentity() {
+    byte[] consumePskIdentity() {
+        sessionLock.lock();
         try {
             return pskIdentity;
         } finally {
             pskIdentity = null;
+            sessionLock.unlock();
         }
     }
 
@@ -393,8 +405,13 @@
     }
 
     @Override
-    public synchronized boolean isValid() {
-        return isRejoinable();
+    public boolean isValid() {
+        sessionLock.lock();
+        try {
+            return isRejoinable();
+        } finally {
+            sessionLock.unlock();
+        }
     }
 
     /**
@@ -777,29 +794,35 @@
      * no connections will be able to rejoin this session.
      */
     @Override
-    public synchronized void invalidate() {
-        //
-        // Can't invalidate the NULL session -- this would be
-        // attempted when we get a handshaking error on a brand
-        // new connection, with no "real" session yet.
-        //
-        if (this == nullSession) {
-            return;
-        }
+    public void invalidate() {
+        sessionLock.lock();
+        try {
+            //
+            // Can't invalidate the NULL session -- this would be
+            // attempted when we get a handshaking error on a brand
+            // new connection, with no "real" session yet.
+            //
+            if (this == nullSession) {
+                return;
+            }
 
-        if (context != null) {
-            context.remove(sessionId);
-            context = null;
-        }
-        if (invalidated) {
-            return;
-        }
-        invalidated = true;
-        if (SSLLogger.isOn && SSLLogger.isOn("session")) {
-             SSLLogger.finest("Invalidated session:  " + this);
-        }
-        for (SSLSessionImpl child : childSessions) {
-            child.invalidate();
+            if (context != null) {
+                context.remove(sessionId);
+                context = null;
+            }
+
+            if (invalidated) {
+                return;
+            }
+            invalidated = true;
+            if (SSLLogger.isOn && SSLLogger.isOn("session")) {
+                 SSLLogger.finest("Invalidated session:  " + this);
+            }
+            for (SSLSessionImpl child : childSessions) {
+                child.invalidate();
+            }
+        } finally {
+            sessionLock.unlock();
         }
     }
 
@@ -912,8 +935,13 @@
      * Expand the buffer size of both SSL/TLS network packet and
      * application data.
      */
-    protected synchronized void expandBufferSizes() {
-        acceptLargeFragments = true;
+    protected void expandBufferSizes() {
+        sessionLock.lock();
+        try {
+            acceptLargeFragments = true;
+        } finally {
+            sessionLock.unlock();
+        }
     }
 
     /**
@@ -921,30 +949,35 @@
      * when using this session.
      */
     @Override
-    public synchronized int getPacketBufferSize() {
-        // Use the bigger packet size calculated from maximumPacketSize
-        // and negotiatedMaxFragLen.
-        int packetSize = 0;
-        if (negotiatedMaxFragLen > 0) {
-            packetSize = cipherSuite.calculatePacketSize(
-                    negotiatedMaxFragLen, protocolVersion,
-                    protocolVersion.isDTLS);
-        }
+    public int getPacketBufferSize() {
+        sessionLock.lock();
+        try {
+            // Use the bigger packet size calculated from maximumPacketSize
+            // and negotiatedMaxFragLen.
+            int packetSize = 0;
+            if (negotiatedMaxFragLen > 0) {
+                packetSize = cipherSuite.calculatePacketSize(
+                        negotiatedMaxFragLen, protocolVersion,
+                        protocolVersion.isDTLS);
+            }
 
-        if (maximumPacketSize > 0) {
-            return (maximumPacketSize > packetSize) ?
-                    maximumPacketSize : packetSize;
-        }
+            if (maximumPacketSize > 0) {
+                return (maximumPacketSize > packetSize) ?
+                        maximumPacketSize : packetSize;
+            }
+
+            if (packetSize != 0) {
+               return packetSize;
+            }
 
-        if (packetSize != 0) {
-           return packetSize;
-        }
-
-        if (protocolVersion.isDTLS) {
-            return DTLSRecord.maxRecordSize;
-        } else {
-            return acceptLargeFragments ?
-                    SSLRecord.maxLargeRecordSize : SSLRecord.maxRecordSize;
+            if (protocolVersion.isDTLS) {
+                return DTLSRecord.maxRecordSize;
+            } else {
+                return acceptLargeFragments ?
+                        SSLRecord.maxLargeRecordSize : SSLRecord.maxRecordSize;
+            }
+        } finally {
+            sessionLock.unlock();
         }
     }
 
@@ -953,31 +986,36 @@
      * expected when using this session.
      */
     @Override
-    public synchronized int getApplicationBufferSize() {
-        // Use the bigger fragment size calculated from maximumPacketSize
-        // and negotiatedMaxFragLen.
-        int fragmentSize = 0;
-        if (maximumPacketSize > 0) {
-            fragmentSize = cipherSuite.calculateFragSize(
-                    maximumPacketSize, protocolVersion,
-                    protocolVersion.isDTLS);
-        }
+    public int getApplicationBufferSize() {
+        sessionLock.lock();
+        try {
+            // Use the bigger fragment size calculated from maximumPacketSize
+            // and negotiatedMaxFragLen.
+            int fragmentSize = 0;
+            if (maximumPacketSize > 0) {
+                fragmentSize = cipherSuite.calculateFragSize(
+                        maximumPacketSize, protocolVersion,
+                        protocolVersion.isDTLS);
+            }
 
-        if (negotiatedMaxFragLen > 0) {
-            return (negotiatedMaxFragLen > fragmentSize) ?
-                    negotiatedMaxFragLen : fragmentSize;
-        }
+            if (negotiatedMaxFragLen > 0) {
+                return (negotiatedMaxFragLen > fragmentSize) ?
+                        negotiatedMaxFragLen : fragmentSize;
+            }
+
+            if (fragmentSize != 0) {
+                return fragmentSize;
+            }
 
-        if (fragmentSize != 0) {
-            return fragmentSize;
-        }
-
-        if (protocolVersion.isDTLS) {
-            return Record.maxDataSize;
-        } else {
-            int maxPacketSize = acceptLargeFragments ?
-                        SSLRecord.maxLargeRecordSize : SSLRecord.maxRecordSize;
-            return (maxPacketSize - SSLRecord.headerSize);
+            if (protocolVersion.isDTLS) {
+                return Record.maxDataSize;
+            } else {
+                int maxPacketSize = acceptLargeFragments ?
+                            SSLRecord.maxLargeRecordSize : SSLRecord.maxRecordSize;
+                return (maxPacketSize - SSLRecord.headerSize);
+            }
+        } finally {
+            sessionLock.unlock();
         }
     }
 
@@ -989,10 +1027,14 @@
      *         the negotiated maximum fragment length, or {@code -1} if
      *         no such length has been negotiated.
      */
-    synchronized void setNegotiatedMaxFragSize(
+    void setNegotiatedMaxFragSize(
             int negotiatedMaxFragLen) {
-
-        this.negotiatedMaxFragLen = negotiatedMaxFragLen;
+        sessionLock.lock();
+        try {
+            this.negotiatedMaxFragLen = negotiatedMaxFragLen;
+        } finally {
+            sessionLock.unlock();
+        }
     }
 
     /**
@@ -1002,16 +1044,31 @@
      * @return the negotiated maximum fragment length, or {@code -1} if
      *         no such length has been negotiated.
      */
-    synchronized int getNegotiatedMaxFragSize() {
-        return negotiatedMaxFragLen;
+    int getNegotiatedMaxFragSize() {
+        sessionLock.lock();
+        try {
+            return negotiatedMaxFragLen;
+        } finally {
+            sessionLock.unlock();
+        }
     }
 
-    synchronized void setMaximumPacketSize(int maximumPacketSize) {
-        this.maximumPacketSize = maximumPacketSize;
+    void setMaximumPacketSize(int maximumPacketSize) {
+        sessionLock.lock();
+        try {
+            this.maximumPacketSize = maximumPacketSize;
+        } finally {
+            sessionLock.unlock();
+        }
     }
 
-    synchronized int getMaximumPacketSize() {
-        return maximumPacketSize;
+    int getMaximumPacketSize() {
+        sessionLock.lock();
+        try {
+            return maximumPacketSize;
+        } finally {
+            sessionLock.unlock();
+        }
     }
 
     /**
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -38,6 +38,7 @@
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.util.List;
+import java.util.concurrent.locks.ReentrantLock;
 import java.util.function.BiFunction;
 import javax.net.ssl.HandshakeCompletedListener;
 import javax.net.ssl.SSLException;
@@ -84,6 +85,9 @@
     private boolean                 isConnected = false;
     private volatile boolean        tlsIsClosed = false;
 
+    private final ReentrantLock     socketLock = new ReentrantLock();
+    private final ReentrantLock     handshakeLock = new ReentrantLock();
+
     /*
      * Is the local name service trustworthy?
      *
@@ -292,14 +296,25 @@
     }
 
     @Override
-    public synchronized String[] getEnabledCipherSuites() {
-        return CipherSuite.namesOf(conContext.sslConfig.enabledCipherSuites);
+    public String[] getEnabledCipherSuites() {
+        socketLock.lock();
+        try {
+            return CipherSuite.namesOf(
+                    conContext.sslConfig.enabledCipherSuites);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setEnabledCipherSuites(String[] suites) {
-        conContext.sslConfig.enabledCipherSuites =
-                CipherSuite.validValuesOf(suites);
+    public void setEnabledCipherSuites(String[] suites) {
+        socketLock.lock();
+        try {
+            conContext.sslConfig.enabledCipherSuites =
+                    CipherSuite.validValuesOf(suites);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
@@ -309,19 +324,29 @@
     }
 
     @Override
-    public synchronized String[] getEnabledProtocols() {
-        return ProtocolVersion.toStringArray(
-                conContext.sslConfig.enabledProtocols);
+    public String[] getEnabledProtocols() {
+        socketLock.lock();
+        try {
+            return ProtocolVersion.toStringArray(
+                    conContext.sslConfig.enabledProtocols);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setEnabledProtocols(String[] protocols) {
+    public void setEnabledProtocols(String[] protocols) {
         if (protocols == null) {
             throw new IllegalArgumentException("Protocols cannot be null");
         }
 
-        conContext.sslConfig.enabledProtocols =
-                ProtocolVersion.namesOf(protocols);
+        socketLock.lock();
+        try {
+            conContext.sslConfig.enabledProtocols =
+                    ProtocolVersion.namesOf(protocols);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
@@ -341,29 +366,44 @@
     }
 
     @Override
-    public synchronized SSLSession getHandshakeSession() {
-        return conContext.handshakeContext == null ?
-                null : conContext.handshakeContext.handshakeSession;
+    public SSLSession getHandshakeSession() {
+        socketLock.lock();
+        try {
+            return conContext.handshakeContext == null ?
+                    null : conContext.handshakeContext.handshakeSession;
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void addHandshakeCompletedListener(
+    public void addHandshakeCompletedListener(
             HandshakeCompletedListener listener) {
         if (listener == null) {
             throw new IllegalArgumentException("listener is null");
         }
 
-        conContext.sslConfig.addHandshakeCompletedListener(listener);
+        socketLock.lock();
+        try {
+            conContext.sslConfig.addHandshakeCompletedListener(listener);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void removeHandshakeCompletedListener(
+    public void removeHandshakeCompletedListener(
             HandshakeCompletedListener listener) {
         if (listener == null) {
             throw new IllegalArgumentException("listener is null");
         }
 
-        conContext.sslConfig.removeHandshakeCompletedListener(listener);
+        socketLock.lock();
+        try {
+            conContext.sslConfig.removeHandshakeCompletedListener(listener);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
@@ -377,7 +417,8 @@
             throw new SocketException("Socket has been closed or broken");
         }
 
-        synchronized (conContext) {     // handshake lock
+        handshakeLock.lock();
+        try {
             // double check the context status
             if (conContext.isBroken || conContext.isInboundClosed() ||
                     conContext.isOutboundClosed()) {
@@ -400,53 +441,95 @@
             } catch (Exception oe) {    // including RuntimeException
                 handleException(oe);
             }
+        } finally {
+            handshakeLock.unlock();
+        }
+    }
+
+    @Override
+    public void setUseClientMode(boolean mode) {
+        socketLock.lock();
+        try {
+            conContext.setUseClientMode(mode);
+        } finally {
+            socketLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean getUseClientMode() {
+        socketLock.lock();
+        try {
+            return conContext.sslConfig.isClientMode;
+        } finally {
+            socketLock.unlock();
+        }
+    }
+
+    @Override
+    public void setNeedClientAuth(boolean need) {
+        socketLock.lock();
+        try {
+            conContext.sslConfig.clientAuthType =
+                    (need ? ClientAuthType.CLIENT_AUTH_REQUIRED :
+                            ClientAuthType.CLIENT_AUTH_NONE);
+        } finally {
+            socketLock.unlock();
         }
     }
 
     @Override
-    public synchronized void setUseClientMode(boolean mode) {
-        conContext.setUseClientMode(mode);
+    public boolean getNeedClientAuth() {
+        socketLock.lock();
+        try {
+            return (conContext.sslConfig.clientAuthType ==
+                        ClientAuthType.CLIENT_AUTH_REQUIRED);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized boolean getUseClientMode() {
-        return conContext.sslConfig.isClientMode;
-    }
-
-    @Override
-    public synchronized void setNeedClientAuth(boolean need) {
-        conContext.sslConfig.clientAuthType =
-                (need ? ClientAuthType.CLIENT_AUTH_REQUIRED :
-                        ClientAuthType.CLIENT_AUTH_NONE);
+    public void setWantClientAuth(boolean want) {
+        socketLock.lock();
+        try {
+            conContext.sslConfig.clientAuthType =
+                    (want ? ClientAuthType.CLIENT_AUTH_REQUESTED :
+                            ClientAuthType.CLIENT_AUTH_NONE);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized boolean getNeedClientAuth() {
-        return (conContext.sslConfig.clientAuthType ==
-                        ClientAuthType.CLIENT_AUTH_REQUIRED);
-    }
-
-    @Override
-    public synchronized void setWantClientAuth(boolean want) {
-        conContext.sslConfig.clientAuthType =
-                (want ? ClientAuthType.CLIENT_AUTH_REQUESTED :
-                        ClientAuthType.CLIENT_AUTH_NONE);
+    public boolean getWantClientAuth() {
+        socketLock.lock();
+        try {
+            return (conContext.sslConfig.clientAuthType ==
+                        ClientAuthType.CLIENT_AUTH_REQUESTED);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized boolean getWantClientAuth() {
-        return (conContext.sslConfig.clientAuthType ==
-                        ClientAuthType.CLIENT_AUTH_REQUESTED);
+    public void setEnableSessionCreation(boolean flag) {
+        socketLock.lock();
+        try {
+            conContext.sslConfig.enableSessionCreation = flag;
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized void setEnableSessionCreation(boolean flag) {
-        conContext.sslConfig.enableSessionCreation = flag;
-    }
-
-    @Override
-    public synchronized boolean getEnableSessionCreation() {
-        return conContext.sslConfig.enableSessionCreation;
+    public boolean getEnableSessionCreation() {
+        socketLock.lock();
+        try {
+            return conContext.sslConfig.enableSessionCreation;
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
@@ -535,8 +618,9 @@
 
         // Need a lock here so that the user_canceled alert and the
         // close_notify alert can be delivered together.
+        conContext.outputRecord.recordLock.lock();
         try {
-            synchronized (conContext.outputRecord) {
+            try {
                 // send a user_canceled alert if needed.
                 if (useUserCanceled) {
                     conContext.warning(Alert.USER_CANCELED);
@@ -544,15 +628,17 @@
 
                 // send a close_notify alert
                 conContext.warning(Alert.CLOSE_NOTIFY);
+            } finally {
+                if (!conContext.isOutboundClosed()) {
+                    conContext.outputRecord.close();
+                }
+
+                if ((autoClose || !isLayered()) && !super.isOutputShutdown()) {
+                    super.shutdownOutput();
+                }
             }
         } finally {
-            if (!conContext.isOutboundClosed()) {
-                conContext.outputRecord.close();
-            }
-
-            if ((autoClose || !isLayered()) && !super.isOutputShutdown()) {
-                super.shutdownOutput();
-            }
+            conContext.outputRecord.recordLock.unlock();
         }
 
         if (!isInputShutdown()) {
@@ -681,20 +767,25 @@
     }
 
     @Override
-    public synchronized InputStream getInputStream() throws IOException {
-        if (isClosed()) {
-            throw new SocketException("Socket is closed");
-        }
+    public InputStream getInputStream() throws IOException {
+        socketLock.lock();
+        try {
+            if (isClosed()) {
+                throw new SocketException("Socket is closed");
+            }
 
-        if (!isConnected) {
-            throw new SocketException("Socket is not connected");
-        }
+            if (!isConnected) {
+                throw new SocketException("Socket is not connected");
+            }
 
-        if (conContext.isInboundClosed() || isInputShutdown()) {
-            throw new SocketException("Socket input is already shutdown");
+            if (conContext.isInboundClosed() || isInputShutdown()) {
+                throw new SocketException("Socket input is already shutdown");
+            }
+
+            return appInput;
+        } finally {
+            socketLock.unlock();
         }
-
-        return appInput;
     }
 
     private void ensureNegotiated() throws IOException {
@@ -703,7 +794,8 @@
             return;
         }
 
-        synchronized (conContext) {     // handshake lock
+        handshakeLock.lock();
+        try {
             // double check the context status
             if (conContext.isNegotiated || conContext.isBroken ||
                     conContext.isInboundClosed() ||
@@ -712,6 +804,8 @@
             }
 
             startHandshake();
+        } finally {
+            handshakeLock.unlock();
         }
     }
 
@@ -729,6 +823,9 @@
         // Is application data available in the stream?
         private volatile boolean appDataIsAvailable;
 
+        // reading lock
+        private final ReentrantLock readLock = new ReentrantLock();
+
         AppInputStream() {
             this.appDataIsAvailable = false;
             this.buffer = ByteBuffer.allocate(4096);
@@ -807,7 +904,8 @@
             //
             // Note that the receiving and processing of post-handshake message
             // are also synchronized with the read lock.
-            synchronized (this) {
+            readLock.lock();
+            try {
                 int remains = available();
                 if (remains > 0) {
                     int howmany = Math.min(remains, len);
@@ -839,6 +937,8 @@
                     // dummy for compiler
                     return -1;
                 }
+            } finally {
+                readLock.unlock();
             }
         }
 
@@ -850,19 +950,24 @@
          * things simpler.
          */
         @Override
-        public synchronized long skip(long n) throws IOException {
+        public long skip(long n) throws IOException {
             // dummy array used to implement skip()
             byte[] skipArray = new byte[256];
+            long skipped = 0;
 
-            long skipped = 0;
-            while (n > 0) {
-                int len = (int)Math.min(n, skipArray.length);
-                int r = read(skipArray, 0, len);
-                if (r <= 0) {
-                    break;
+            readLock.lock();
+            try {
+                while (n > 0) {
+                    int len = (int)Math.min(n, skipArray.length);
+                    int r = read(skipArray, 0, len);
+                    if (r <= 0) {
+                        break;
+                    }
+                    n -= r;
+                    skipped += r;
                 }
-                n -= r;
-                skipped += r;
+            } finally {
+                readLock.unlock();
             }
 
             return skipped;
@@ -910,8 +1015,18 @@
          * Try the best to use up the input records so as to close the
          * socket gracefully, without impact the performance too much.
          */
-        private synchronized void deplete() {
-            if (!conContext.isInboundClosed()) {
+        private void deplete() {
+            if (conContext.isInboundClosed()) {
+                return;
+            }
+
+            readLock.lock();
+            try {
+                // double check
+                if (conContext.isInboundClosed()) {
+                    return;
+                }
+
                 if (!(conContext.inputRecord instanceof SSLSocketInputRecord)) {
                     return;
                 }
@@ -927,25 +1042,32 @@
                             "input stream close depletion failed", ioe);
                     }
                 }
+            } finally {
+                readLock.unlock();
             }
         }
     }
 
     @Override
-    public synchronized OutputStream getOutputStream() throws IOException {
-        if (isClosed()) {
-            throw new SocketException("Socket is closed");
-        }
+    public OutputStream getOutputStream() throws IOException {
+        socketLock.lock();
+        try {
+            if (isClosed()) {
+                throw new SocketException("Socket is closed");
+            }
 
-        if (!isConnected) {
-            throw new SocketException("Socket is not connected");
-        }
+            if (!isConnected) {
+                throw new SocketException("Socket is not connected");
+            }
 
-        if (conContext.isOutboundDone() || isOutputShutdown()) {
-            throw new SocketException("Socket output is already shutdown");
+            if (conContext.isOutboundDone() || isOutputShutdown()) {
+                throw new SocketException("Socket output is already shutdown");
+            }
+
+            return appOutput;
+        } finally {
+            socketLock.unlock();
         }
-
-        return appOutput;
     }
 
 
@@ -1035,44 +1157,74 @@
     }
 
     @Override
-    public synchronized SSLParameters getSSLParameters() {
-        return conContext.sslConfig.getSSLParameters();
-    }
-
-    @Override
-    public synchronized void setSSLParameters(SSLParameters params) {
-        conContext.sslConfig.setSSLParameters(params);
-
-        if (conContext.sslConfig.maximumPacketSize != 0) {
-            conContext.outputRecord.changePacketSize(
-                    conContext.sslConfig.maximumPacketSize);
+    public SSLParameters getSSLParameters() {
+        socketLock.lock();
+        try {
+            return conContext.sslConfig.getSSLParameters();
+        } finally {
+            socketLock.unlock();
         }
     }
 
     @Override
-    public synchronized String getApplicationProtocol() {
-        return conContext.applicationProtocol;
+    public void setSSLParameters(SSLParameters params) {
+        socketLock.lock();
+        try {
+            conContext.sslConfig.setSSLParameters(params);
+
+            if (conContext.sslConfig.maximumPacketSize != 0) {
+                conContext.outputRecord.changePacketSize(
+                        conContext.sslConfig.maximumPacketSize);
+            }
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized String getHandshakeApplicationProtocol() {
-        if (conContext.handshakeContext != null) {
-            return conContext.handshakeContext.applicationProtocol;
+    public String getApplicationProtocol() {
+        socketLock.lock();
+        try {
+            return conContext.applicationProtocol;
+        } finally {
+            socketLock.unlock();
+        }
+    }
+
+    @Override
+    public String getHandshakeApplicationProtocol() {
+        socketLock.lock();
+        try {
+            if (conContext.handshakeContext != null) {
+                return conContext.handshakeContext.applicationProtocol;
+            }
+        } finally {
+            socketLock.unlock();
         }
 
         return null;
     }
 
     @Override
-    public synchronized void setHandshakeApplicationProtocolSelector(
+    public void setHandshakeApplicationProtocolSelector(
             BiFunction<SSLSocket, List<String>, String> selector) {
-        conContext.sslConfig.socketAPSelector = selector;
+        socketLock.lock();
+        try {
+            conContext.sslConfig.socketAPSelector = selector;
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     @Override
-    public synchronized BiFunction<SSLSocket, List<String>, String>
+    public BiFunction<SSLSocket, List<String>, String>
             getHandshakeApplicationProtocolSelector() {
-        return conContext.sslConfig.socketAPSelector;
+        socketLock.lock();
+        try {
+            return conContext.sslConfig.socketAPSelector;
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     /**
@@ -1142,8 +1294,11 @@
 
             try {
                 Plaintext plainText;
-                synchronized (this) {
+                socketLock.lock();
+                try {
                     plainText = decode(buffer);
+                } finally {
+                    socketLock.unlock();
                 }
                 if (plainText.contentType == ContentType.APPLICATION_DATA.id &&
                         buffer.position() > 0) {
@@ -1222,27 +1377,33 @@
      *
      * Called by connect, the layered constructor, and SSLServerSocket.
      */
-    synchronized void doneConnect() throws IOException {
-        // In server mode, it is not necessary to set host and serverNames.
-        // Otherwise, would require a reverse DNS lookup to get the hostname.
-        if (peerHost == null || peerHost.isEmpty()) {
-            boolean useNameService =
-                    trustNameService && conContext.sslConfig.isClientMode;
-            useImplicitHost(useNameService);
-        } else {
-            conContext.sslConfig.serverNames =
-                    Utilities.addToSNIServerNameList(
-                            conContext.sslConfig.serverNames, peerHost);
+    void doneConnect() throws IOException {
+        socketLock.lock();
+        try {
+            // In server mode, it is not necessary to set host and serverNames.
+            // Otherwise, would require a reverse DNS lookup to get
+            // the hostname.
+            if (peerHost == null || peerHost.isEmpty()) {
+                boolean useNameService =
+                        trustNameService && conContext.sslConfig.isClientMode;
+                useImplicitHost(useNameService);
+            } else {
+                conContext.sslConfig.serverNames =
+                        Utilities.addToSNIServerNameList(
+                                conContext.sslConfig.serverNames, peerHost);
+            }
+
+            InputStream sockInput = super.getInputStream();
+            conContext.inputRecord.setReceiverStream(sockInput);
+
+            OutputStream sockOutput = super.getOutputStream();
+            conContext.inputRecord.setDeliverStream(sockOutput);
+            conContext.outputRecord.setDeliverStream(sockOutput);
+
+            this.isConnected = true;
+        } finally {
+            socketLock.unlock();
         }
-
-        InputStream sockInput = super.getInputStream();
-        conContext.inputRecord.setReceiverStream(sockInput);
-
-        OutputStream sockOutput = super.getOutputStream();
-        conContext.inputRecord.setDeliverStream(sockOutput);
-        conContext.outputRecord.setDeliverStream(sockOutput);
-
-        this.isConnected = true;
     }
 
     private void useImplicitHost(boolean useNameService) {
@@ -1288,11 +1449,16 @@
     // Please NOTE that this method MUST be called before calling to
     // SSLSocket.setSSLParameters(). Otherwise, the {@code host} parameter
     // may override SNIHostName in the customized server name indication.
-    public synchronized void setHost(String host) {
-        this.peerHost = host;
-        this.conContext.sslConfig.serverNames =
-                Utilities.addToSNIServerNameList(
-                        conContext.sslConfig.serverNames, host);
+    public void setHost(String host) {
+        socketLock.lock();
+        try {
+            this.peerHost = host;
+            this.conContext.sslConfig.serverNames =
+                    Utilities.addToSNIServerNameList(
+                            conContext.sslConfig.serverNames, host);
+        } finally {
+            socketLock.unlock();
+        }
     }
 
     /**
--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketOutputRecord.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -51,123 +51,206 @@
     }
 
     @Override
-    synchronized void encodeAlert(
-            byte level, byte description) throws IOException {
-        if (isClosed()) {
-            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                SSLLogger.warning("outbound has closed, ignore outbound " +
-                    "alert message: " + Alert.nameOf(description));
+    void encodeAlert(byte level, byte description) throws IOException {
+        recordLock.lock();
+        try {
+            if (isClosed()) {
+                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                    SSLLogger.warning("outbound has closed, ignore outbound " +
+                        "alert message: " + Alert.nameOf(description));
+                }
+                return;
             }
-            return;
-        }
 
-        // use the buf of ByteArrayOutputStream
-        int position = headerSize + writeCipher.getExplicitNonceSize();
-        count = position;
+            // use the buf of ByteArrayOutputStream
+            int position = headerSize + writeCipher.getExplicitNonceSize();
+            count = position;
 
-        write(level);
-        write(description);
-        if (SSLLogger.isOn && SSLLogger.isOn("record")) {
-            SSLLogger.fine("WRITE: " + protocolVersion +
-                    " " + ContentType.ALERT.name +
-                    "(" + Alert.nameOf(description) + ")" +
-                    ", length = " + (count - headerSize));
-        }
+            write(level);
+            write(description);
+            if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+                SSLLogger.fine("WRITE: " + protocolVersion +
+                        " " + ContentType.ALERT.name +
+                        "(" + Alert.nameOf(description) + ")" +
+                        ", length = " + (count - headerSize));
+            }
 
-        // Encrypt the fragment and wrap up a record.
-        encrypt(writeCipher, ContentType.ALERT.id, headerSize);
+            // Encrypt the fragment and wrap up a record.
+            encrypt(writeCipher, ContentType.ALERT.id, headerSize);
 
-        // deliver this message
-        deliverStream.write(buf, 0, count);    // may throw IOException
-        deliverStream.flush();                 // may throw IOException
+            // deliver this message
+            deliverStream.write(buf, 0, count);    // may throw IOException
+            deliverStream.flush();                 // may throw IOException
 
-        if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
-            SSLLogger.fine("Raw write",
-                    (new ByteArrayInputStream(buf, 0, count)));
+            if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+                SSLLogger.fine("Raw write",
+                        (new ByteArrayInputStream(buf, 0, count)));
+            }
+
+            // reset the internal buffer
+            count = 0;
+        } finally {
+            recordLock.unlock();
         }
-
-        // reset the internal buffer
-        count = 0;
     }
 
     @Override
-    synchronized void encodeHandshake(byte[] source,
+    void encodeHandshake(byte[] source,
             int offset, int length) throws IOException {
-        if (isClosed()) {
-            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                SSLLogger.warning("outbound has closed, ignore outbound " +
-                        "handshake message",
-                        ByteBuffer.wrap(source, offset, length));
+        recordLock.lock();
+        try {
+            if (isClosed()) {
+                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                    SSLLogger.warning("outbound has closed, ignore outbound " +
+                            "handshake message",
+                            ByteBuffer.wrap(source, offset, length));
+                }
+                return;
             }
-            return;
-        }
+
+            if (firstMessage) {
+                firstMessage = false;
 
-        if (firstMessage) {
-            firstMessage = false;
-
-            if ((helloVersion == ProtocolVersion.SSL20Hello) &&
-                (source[offset] == SSLHandshake.CLIENT_HELLO.id) &&
+                if ((helloVersion == ProtocolVersion.SSL20Hello) &&
+                    (source[offset] == SSLHandshake.CLIENT_HELLO.id) &&
                                             //  5: recode header size
-                (source[offset + 4 + 2 + 32] == 0)) {
+                    (source[offset + 4 + 2 + 32] == 0)) {
                                             // V3 session ID is empty
                                             //  4: handshake header size
                                             //  2: client_version in ClientHello
                                             // 32: random in ClientHello
 
-                ByteBuffer v2ClientHello = encodeV2ClientHello(
-                        source, (offset + 4), (length - 4));
+                    ByteBuffer v2ClientHello = encodeV2ClientHello(
+                            source, (offset + 4), (length - 4));
+
+                    // array offset is zero
+                    byte[] record = v2ClientHello.array();
+                    int limit = v2ClientHello.limit();
+                    handshakeHash.deliver(record, 2, (limit - 2));
+
+                    if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+                        SSLLogger.fine(
+                                "WRITE: SSLv2 ClientHello message" +
+                                ", length = " + limit);
+                    }
+
+                    // deliver this message
+                    //
+                    // Version 2 ClientHello message should be plaintext.
+                    //
+                    // No max fragment length negotiation.
+                    deliverStream.write(record, 0, limit);
+                    deliverStream.flush();
+
+                    if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+                        SSLLogger.fine("Raw write",
+                                (new ByteArrayInputStream(record, 0, limit)));
+                    }
 
-                byte[] record = v2ClientHello.array();  // array offset is zero
-                int limit = v2ClientHello.limit();
-                handshakeHash.deliver(record, 2, (limit - 2));
+                    return;
+                }
+            }
+
+            byte handshakeType = source[0];
+            if (handshakeHash.isHashable(handshakeType)) {
+                handshakeHash.deliver(source, offset, length);
+            }
+
+            int fragLimit = getFragLimit();
+            int position = headerSize + writeCipher.getExplicitNonceSize();
+            if (count == 0) {
+                count = position;
+            }
+
+            if ((count - position) < (fragLimit - length)) {
+                write(source, offset, length);
+                return;
+            }
+
+            for (int limit = (offset + length); offset < limit;) {
+
+                int remains = (limit - offset) + (count - position);
+                int fragLen = Math.min(fragLimit, remains);
+
+                // use the buf of ByteArrayOutputStream
+                write(source, offset, fragLen);
+                if (remains < fragLimit) {
+                    return;
+                }
 
                 if (SSLLogger.isOn && SSLLogger.isOn("record")) {
                     SSLLogger.fine(
-                            "WRITE: SSLv2 ClientHello message" +
-                            ", length = " + limit);
+                            "WRITE: " + protocolVersion +
+                            " " + ContentType.HANDSHAKE.name +
+                            ", length = " + (count - headerSize));
                 }
 
+                // Encrypt the fragment and wrap up a record.
+                encrypt(writeCipher, ContentType.HANDSHAKE.id, headerSize);
+
                 // deliver this message
-                //
-                // Version 2 ClientHello message should be plaintext.
-                //
-                // No max fragment length negotiation.
-                deliverStream.write(record, 0, limit);
-                deliverStream.flush();
+                deliverStream.write(buf, 0, count);    // may throw IOException
+                deliverStream.flush();                 // may throw IOException
 
                 if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
                     SSLLogger.fine("Raw write",
-                            (new ByteArrayInputStream(record, 0, limit)));
+                            (new ByteArrayInputStream(buf, 0, count)));
                 }
 
+                // reset the offset
+                offset += fragLen;
+
+                // reset the internal buffer
+                count = position;
+            }
+        } finally {
+            recordLock.unlock();
+        }
+    }
+
+    @Override
+    void encodeChangeCipherSpec() throws IOException {
+        recordLock.lock();
+        try {
+            if (isClosed()) {
+                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                    SSLLogger.warning("outbound has closed, ignore outbound " +
+                        "change_cipher_spec message");
+                }
                 return;
             }
-        }
-
-        byte handshakeType = source[0];
-        if (handshakeHash.isHashable(handshakeType)) {
-            handshakeHash.deliver(source, offset, length);
-        }
-
-        int fragLimit = getFragLimit();
-        int position = headerSize + writeCipher.getExplicitNonceSize();
-        if (count == 0) {
-            count = position;
-        }
-
-        if ((count - position) < (fragLimit - length)) {
-            write(source, offset, length);
-            return;
-        }
-
-        for (int limit = (offset + length); offset < limit;) {
-
-            int remains = (limit - offset) + (count - position);
-            int fragLen = Math.min(fragLimit, remains);
 
             // use the buf of ByteArrayOutputStream
-            write(source, offset, fragLen);
-            if (remains < fragLimit) {
+            int position = headerSize + writeCipher.getExplicitNonceSize();
+            count = position;
+
+            write((byte)1);         // byte 1: change_cipher_spec(
+
+            // Encrypt the fragment and wrap up a record.
+            encrypt(writeCipher, ContentType.CHANGE_CIPHER_SPEC.id, headerSize);
+
+            // deliver this message
+            deliverStream.write(buf, 0, count);        // may throw IOException
+            // deliverStream.flush();                  // flush in Finished
+
+            if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+                SSLLogger.fine("Raw write",
+                        (new ByteArrayInputStream(buf, 0, count)));
+            }
+
+            // reset the internal buffer
+            count = 0;
+        } finally {
+            recordLock.unlock();
+        }
+    }
+
+    @Override
+    public void flush() throws IOException {
+        recordLock.lock();
+        try {
+            int position = headerSize + writeCipher.getExplicitNonceSize();
+            if (count <= position) {
                 return;
             }
 
@@ -190,155 +273,103 @@
                         (new ByteArrayInputStream(buf, 0, count)));
             }
 
-            // reset the offset
-            offset += fragLen;
-
             // reset the internal buffer
-            count = position;
+            count = 0;      // DON'T use position
+        } finally {
+            recordLock.unlock();
         }
     }
 
     @Override
-    synchronized void encodeChangeCipherSpec() throws IOException {
-        if (isClosed()) {
-            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                SSLLogger.warning("outbound has closed, ignore outbound " +
-                    "change_cipher_spec message");
+    void deliver(byte[] source, int offset, int length) throws IOException {
+        recordLock.lock();
+        try {
+            if (isClosed()) {
+                throw new SocketException(
+                        "Connection or outbound has been closed");
             }
-            return;
-        }
-
-        // use the buf of ByteArrayOutputStream
-        int position = headerSize + writeCipher.getExplicitNonceSize();
-        count = position;
-
-        write((byte)1);         // byte 1: change_cipher_spec(
-
-        // Encrypt the fragment and wrap up a record.
-        encrypt(writeCipher, ContentType.CHANGE_CIPHER_SPEC.id, headerSize);
-
-        // deliver this message
-        deliverStream.write(buf, 0, count);        // may throw IOException
-        // deliverStream.flush();                  // flush in Finished
-
-        if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
-            SSLLogger.fine("Raw write",
-                    (new ByteArrayInputStream(buf, 0, count)));
-        }
-
-        // reset the internal buffer
-        count = 0;
-    }
 
-    @Override
-    public synchronized void flush() throws IOException {
-        int position = headerSize + writeCipher.getExplicitNonceSize();
-        if (count <= position) {
-            return;
-        }
-
-        if (SSLLogger.isOn && SSLLogger.isOn("record")) {
-            SSLLogger.fine(
-                    "WRITE: " + protocolVersion +
-                    " " + ContentType.HANDSHAKE.name +
-                    ", length = " + (count - headerSize));
-        }
-
-        // Encrypt the fragment and wrap up a record.
-        encrypt(writeCipher, ContentType.HANDSHAKE.id, headerSize);
-
-        // deliver this message
-        deliverStream.write(buf, 0, count);    // may throw IOException
-        deliverStream.flush();                 // may throw IOException
+            if (writeCipher.authenticator.seqNumOverflow()) {
+                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
+                    SSLLogger.fine(
+                        "sequence number extremely close to overflow " +
+                        "(2^64-1 packets). Closing connection.");
+                }
 
-        if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
-            SSLLogger.fine("Raw write",
-                    (new ByteArrayInputStream(buf, 0, count)));
-        }
-
-        // reset the internal buffer
-        count = 0;      // DON'T use position
-    }
-
-    @Override
-    synchronized void deliver(
-            byte[] source, int offset, int length) throws IOException {
-        if (isClosed()) {
-            throw new SocketException("Connection or outbound has been closed");
-        }
-
-        if (writeCipher.authenticator.seqNumOverflow()) {
-            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
-                SSLLogger.fine(
-                    "sequence number extremely close to overflow " +
-                    "(2^64-1 packets). Closing connection.");
+                throw new SSLHandshakeException("sequence number overflow");
             }
 
-            throw new SSLHandshakeException("sequence number overflow");
-        }
+            boolean isFirstRecordOfThePayload = true;
+            for (int limit = (offset + length); offset < limit;) {
+                int fragLen;
+                if (packetSize > 0) {
+                    fragLen = Math.min(maxRecordSize, packetSize);
+                    fragLen = writeCipher.calculateFragmentSize(
+                            fragLen, headerSize);
 
-        boolean isFirstRecordOfThePayload = true;
-        for (int limit = (offset + length); offset < limit;) {
-            int fragLen;
-            if (packetSize > 0) {
-                fragLen = Math.min(maxRecordSize, packetSize);
-                fragLen =
-                        writeCipher.calculateFragmentSize(fragLen, headerSize);
+                    fragLen = Math.min(fragLen, Record.maxDataSize);
+                } else {
+                    fragLen = Record.maxDataSize;
+                }
 
-                fragLen = Math.min(fragLen, Record.maxDataSize);
-            } else {
-                fragLen = Record.maxDataSize;
-            }
+                if (fragmentSize > 0) {
+                    fragLen = Math.min(fragLen, fragmentSize);
+                }
 
-            if (fragmentSize > 0) {
-                fragLen = Math.min(fragLen, fragmentSize);
-            }
+                if (isFirstRecordOfThePayload && needToSplitPayload()) {
+                    fragLen = 1;
+                    isFirstRecordOfThePayload = false;
+                } else {
+                    fragLen = Math.min(fragLen, (limit - offset));
+                }
 
-            if (isFirstRecordOfThePayload && needToSplitPayload()) {
-                fragLen = 1;
-                isFirstRecordOfThePayload = false;
-            } else {
-                fragLen = Math.min(fragLen, (limit - offset));
-            }
+                // use the buf of ByteArrayOutputStream
+                int position = headerSize + writeCipher.getExplicitNonceSize();
+                count = position;
+                write(source, offset, fragLen);
 
-            // use the buf of ByteArrayOutputStream
-            int position = headerSize + writeCipher.getExplicitNonceSize();
-            count = position;
-            write(source, offset, fragLen);
+                if (SSLLogger.isOn && SSLLogger.isOn("record")) {
+                    SSLLogger.fine(
+                            "WRITE: " + protocolVersion +
+                            " " + ContentType.APPLICATION_DATA.name +
+                            ", length = " + (count - position));
+                }
 
-            if (SSLLogger.isOn && SSLLogger.isOn("record")) {
-                SSLLogger.fine(
-                        "WRITE: " + protocolVersion +
-                        " " + ContentType.APPLICATION_DATA.name +
-                        ", length = " + (count - position));
-            }
+                // Encrypt the fragment and wrap up a record.
+                encrypt(writeCipher,
+                        ContentType.APPLICATION_DATA.id, headerSize);
 
-            // Encrypt the fragment and wrap up a record.
-            encrypt(writeCipher, ContentType.APPLICATION_DATA.id, headerSize);
+                // deliver this message
+                deliverStream.write(buf, 0, count);    // may throw IOException
+                deliverStream.flush();                 // may throw IOException
 
-            // deliver this message
-            deliverStream.write(buf, 0, count);    // may throw IOException
-            deliverStream.flush();                 // may throw IOException
+                if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
+                    SSLLogger.fine("Raw write",
+                            (new ByteArrayInputStream(buf, 0, count)));
+                }
 
-            if (SSLLogger.isOn && SSLLogger.isOn("packet")) {
-                SSLLogger.fine("Raw write",
-                        (new ByteArrayInputStream(buf, 0, count)));
-            }
+                // reset the internal buffer
+                count = 0;
 
-            // reset the internal buffer
-            count = 0;
+                if (isFirstAppOutputRecord) {
+                    isFirstAppOutputRecord = false;
+                }
 
-            if (isFirstAppOutputRecord) {
-                isFirstAppOutputRecord = false;
+                offset += fragLen;
             }
-
-            offset += fragLen;
+        } finally {
+            recordLock.unlock();
         }
     }
 
     @Override
-    synchronized void setDeliverStream(OutputStream outputStream) {
-        this.deliverStream = outputStream;
+    void setDeliverStream(OutputStream outputStream) {
+        recordLock.lock();
+        try {
+            this.deliverStream = outputStream;
+        } finally {
+            recordLock.unlock();
+        }
     }
 
     /*
--- a/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SignatureScheme.java	Tue Apr 09 11:48:54 2019 +0100
@@ -41,6 +41,7 @@
 import java.util.Set;
 import sun.security.ssl.SupportedGroupsExtension.NamedGroup;
 import sun.security.ssl.SupportedGroupsExtension.NamedGroupType;
+import sun.security.ssl.X509Authentication.X509Possession;
 import sun.security.util.KeyUtil;
 
 enum SignatureScheme {
@@ -415,9 +416,10 @@
 
     static SignatureScheme getPreferableAlgorithm(
             List<SignatureScheme> schemes,
-            PrivateKey signingKey,
+            X509Possession x509Possession,
             ProtocolVersion version) {
 
+        PrivateKey signingKey = x509Possession.popPrivateKey;
         String keyAlgorithm = signingKey.getAlgorithm();
         int keySize;
         // Only need to check RSA algorithm at present.
@@ -434,8 +436,9 @@
                 if (ss.namedGroup != null &&
                     ss.namedGroup.type == NamedGroupType.NAMED_GROUP_ECDHE) {
                     ECParameterSpec params =
-                                ((ECPrivateKey)signingKey).getParams();
-                    if (ss.namedGroup == NamedGroup.valueOf(params)) {
+                            x509Possession.getECParameterSpec();
+                    if (params != null &&
+                            ss.namedGroup == NamedGroup.valueOf(params)) {
                         return ss;
                     }
                 } else {
--- a/src/java.base/share/classes/sun/security/ssl/SunJSSE.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SunJSSE.java	Tue Apr 09 11:48:54 2019 +0100
@@ -27,18 +27,12 @@
 
 import java.security.*;
 import java.util.*;
-import sun.security.rsa.SunRsaSignEntries;
 import static sun.security.util.SecurityConstants.PROVIDER_VER;
 import static sun.security.provider.SunEntries.createAliases;
 
 /**
  * The JSSE provider.
  *
- * The RSA implementation has been removed from JSSE, but we still need to
- * register the same algorithms for compatibility. We just point to the RSA
- * implementation in the SunRsaSign provider. This works because all classes
- * are in the bootclasspath and therefore loaded by the same classloader.
- *
  * SunJSSE now supports an experimental FIPS compliant mode when used with an
  * appropriate FIPS certified crypto provider. In FIPS mode, we:
  *  . allow only TLS 1.0 or later
@@ -84,12 +78,6 @@
     }
 
     private void doRegister() {
-        Iterator<Provider.Service> rsaIter =
-            new SunRsaSignEntries(this).iterator();
-        while (rsaIter.hasNext()) {
-            putService(rsaIter.next());
-        }
-
         ps("Signature", "MD5andSHA1withRSA",
             "sun.security.ssl.RSASignature", null, null);
 
--- a/src/java.base/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java	Tue Apr 09 11:48:54 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
@@ -102,25 +102,21 @@
      * Basic container for credentials implemented as an inner class.
      */
     private static class X509Credentials {
-        PrivateKey privateKey;
-        X509Certificate[] certificates;
-        private Set<X500Principal> issuerX500Principals;
+        final PrivateKey privateKey;
+        final X509Certificate[] certificates;
+        private final Set<X500Principal> issuerX500Principals;
 
         X509Credentials(PrivateKey privateKey, X509Certificate[] certificates) {
             // assert privateKey and certificates != null
             this.privateKey = privateKey;
             this.certificates = certificates;
+            this.issuerX500Principals = new HashSet<>(certificates.length);
+            for (X509Certificate certificate : certificates) {
+                issuerX500Principals.add(certificate.getIssuerX500Principal());
+            }
         }
 
-        synchronized Set<X500Principal> getIssuerX500Principals() {
-            // lazy initialization
-            if (issuerX500Principals == null) {
-                issuerX500Principals = new HashSet<X500Principal>();
-                for (int i = 0; i < certificates.length; i++) {
-                    issuerX500Principals.add(
-                                certificates[i].getIssuerX500Principal());
-                }
-            }
+        Set<X500Principal> getIssuerX500Principals() {
             return issuerX500Principals;
         }
     }
--- a/src/java.base/share/classes/sun/security/ssl/TransportContext.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/TransportContext.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -496,13 +496,16 @@
             }
 
             if (needCloseNotify) {
-                synchronized (outputRecord) {
+                outputRecord.recordLock.lock();
+                try {
                     try {
                         // send a close_notify alert
                         warning(Alert.CLOSE_NOTIFY);
                     } finally {
                         outputRecord.close();
                     }
+                } finally {
+                    outputRecord.recordLock.unlock();
                 }
             }
         }
@@ -541,7 +544,8 @@
 
         // Need a lock here so that the user_canceled alert and the
         // close_notify alert can be delivered together.
-        synchronized (outputRecord) {
+        outputRecord.recordLock.lock();
+        try {
             try {
                 // send a user_canceled alert if needed.
                 if (useUserCanceled) {
@@ -553,6 +557,8 @@
             } finally {
                 outputRecord.close();
             }
+        } finally {
+            outputRecord.recordLock.unlock();
         }
     }
 
--- a/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java	Tue Apr 09 11:48:54 2019 +0100
@@ -30,6 +30,7 @@
 import java.security.*;
 import java.security.cert.*;
 import java.util.*;
+import java.util.concurrent.locks.ReentrantLock;
 import sun.security.action.*;
 import sun.security.validator.TrustStoreUtil;
 
@@ -244,6 +245,8 @@
         // objects can be atomically cleared, and reloaded if needed.
         private WeakReference<Set<X509Certificate>> csRef;
 
+        private final ReentrantLock tamLock = new ReentrantLock();
+
         private TrustAnchorManager() {
             this.descriptor = null;
             this.ksRef = new WeakReference<>(null);
@@ -255,7 +258,7 @@
          *
          * @return null if the underlying KeyStore is not available.
          */
-        synchronized KeyStore getKeyStore(
+        KeyStore getKeyStore(
                 TrustStoreDescriptor descriptor) throws Exception {
 
             TrustStoreDescriptor temporaryDesc = this.descriptor;
@@ -264,15 +267,26 @@
                 return ks;
             }
 
-            // Reload a new key store.
-            if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
-                SSLLogger.fine("Reload the trust store");
+            tamLock.lock();
+            try {
+                // double check
+                ks = ksRef.get();
+                if ((ks != null) && descriptor.equals(temporaryDesc)) {
+                    return ks;
+                }
+
+                // Reload a new key store.
+                if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+                    SSLLogger.fine("Reload the trust store");
+                }
+
+                ks = loadKeyStore(descriptor);
+                this.descriptor = descriptor;
+                this.ksRef = new WeakReference<>(ks);
+            } finally {
+                tamLock.unlock();
             }
 
-            ks = loadKeyStore(descriptor);
-            this.descriptor = descriptor;
-            this.ksRef = new WeakReference<>(ks);
-
             return ks;
         }
 
@@ -282,51 +296,62 @@
          *
          * @return empty collection if the underlying KeyStore is not available.
          */
-        synchronized Set<X509Certificate> getTrustedCerts(
+        Set<X509Certificate> getTrustedCerts(
                 TrustStoreDescriptor descriptor) throws Exception {
 
             KeyStore ks = null;
             TrustStoreDescriptor temporaryDesc = this.descriptor;
             Set<X509Certificate> certs = csRef.get();
-            if (certs != null) {
-                if (descriptor.equals(temporaryDesc)) {
-                    return certs;
-                } else {
-                    // Use the new descriptor.
-                    this.descriptor = descriptor;
-                }
-            } else {
-                // Try to use the cached store at first.
-                if (descriptor.equals(temporaryDesc)) {
-                    ks = ksRef.get();
-                } else {
-                    // Use the new descriptor.
-                    this.descriptor = descriptor;
-                }
+            if ((certs != null) && descriptor.equals(temporaryDesc)) {
+                return certs;
             }
 
-            // Reload the trust store if needed.
-            if (ks == null) {
-                if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
-                    SSLLogger.fine("Reload the trust store");
+            tamLock.lock();
+            try {
+                // double check
+                temporaryDesc = this.descriptor;
+                certs = csRef.get();
+                if (certs != null) {
+                    if (descriptor.equals(temporaryDesc)) {
+                        return certs;
+                    } else {
+                        // Use the new descriptor.
+                        this.descriptor = descriptor;
+                    }
+                } else {
+                    // Try to use the cached store at first.
+                    if (descriptor.equals(temporaryDesc)) {
+                        ks = ksRef.get();
+                    } else {
+                        // Use the new descriptor.
+                        this.descriptor = descriptor;
+                    }
                 }
-                ks = loadKeyStore(descriptor);
-            }
 
-            // Reload trust certs from the key store.
-            if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
-                SSLLogger.fine("Reload trust certs");
-            }
+                // Reload the trust store if needed.
+                if (ks == null) {
+                    if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+                        SSLLogger.fine("Reload the trust store");
+                    }
+                    ks = loadKeyStore(descriptor);
+                    this.ksRef = new WeakReference<>(ks);
+                }
 
-            certs = loadTrustedCerts(ks);
-            if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
-                SSLLogger.fine("Reloaded " + certs.size() + " trust certs");
+                // Reload trust certs from the key store.
+                if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+                    SSLLogger.fine("Reload trust certs");
+                }
+
+                certs = loadTrustedCerts(ks);
+                if (SSLLogger.isOn && SSLLogger.isOn("trustmanager")) {
+                    SSLLogger.fine("Reloaded " + certs.size() + " trust certs");
+                }
+
+                this.csRef = new WeakReference<>(certs);
+            } finally {
+                tamLock.unlock();
             }
 
-            // Note that as ks is a local variable, it is not
-            // necessary to add it to the ksRef weak reference.
-            this.csRef = new WeakReference<>(certs);
-
             return certs;
         }
 
--- a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java	Tue Apr 09 11:48:54 2019 +0100
@@ -28,6 +28,7 @@
 import java.security.PrivateKey;
 import java.security.PublicKey;
 import java.security.cert.X509Certificate;
+import java.security.interfaces.ECKey;
 import java.security.interfaces.ECPublicKey;
 import java.security.spec.ECParameterSpec;
 import java.util.AbstractMap.SimpleImmutableEntry;
@@ -127,6 +128,26 @@
             this.popCerts = popCerts;
             this.popPrivateKey = popPrivateKey;
         }
+
+        ECParameterSpec getECParameterSpec() {
+            if (popPrivateKey == null ||
+                    !"EC".equals(popPrivateKey.getAlgorithm())) {
+                return null;
+            }
+
+            if (popPrivateKey instanceof ECKey) {
+                return ((ECKey)popPrivateKey).getParams();
+            } else if (popCerts != null && popCerts.length != 0) {
+                // The private key not extractable, get the parameters from
+                // the X.509 certificate.
+                PublicKey publicKey = popCerts[0].getPublicKey();
+                if (publicKey instanceof ECKey) {
+                    return ((ECKey)publicKey).getParams();
+                }
+            }
+
+            return null;
+        }
     }
 
     static final class X509Credentials implements SSLCredentials {
--- a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -29,6 +29,7 @@
 import java.security.*;
 import java.security.cert.*;
 import java.util.*;
+import java.util.concurrent.locks.ReentrantLock;
 import javax.net.ssl.*;
 import sun.security.util.AnchorCertificates;
 import sun.security.util.HostnameChecker;
@@ -63,6 +64,8 @@
     // the different extension checks. They are initialized lazily on demand.
     private volatile Validator clientValidator, serverValidator;
 
+    private final ReentrantLock validatorLock = new ReentrantLock();
+
     X509TrustManagerImpl(String validatorType,
             Collection<X509Certificate> trustedCerts) {
 
@@ -157,12 +160,15 @@
         if (isClient) {
             v = clientValidator;
             if (v == null) {
-                synchronized (this) {
+                validatorLock.lock();
+                try {
                     v = clientValidator;
                     if (v == null) {
                         v = getValidator(Validator.VAR_TLS_CLIENT);
                         clientValidator = v;
                     }
+                } finally {
+                    validatorLock.unlock();
                 }
             }
         } else {
@@ -170,12 +176,15 @@
             // (guaranteed under the new Tiger memory model)
             v = serverValidator;
             if (v == null) {
-                synchronized (this) {
+                validatorLock.lock();
+                try {
                     v = serverValidator;
                     if (v == null) {
                         v = getValidator(Validator.VAR_TLS_SERVER);
                         serverValidator = v;
                     }
+                } finally {
+                    validatorLock.unlock();
                 }
             }
         }
--- a/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java	Tue Apr 09 11:48:54 2019 +0100
@@ -287,8 +287,11 @@
             // Add all mandatory attributes
             info.set(X509CertInfo.VERSION,
                      new CertificateVersion(CertificateVersion.V3));
-            info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(
-                    new java.util.Random().nextInt() & 0x7fffffff));
+            if (prng == null) {
+                prng = new SecureRandom();
+            }
+            info.set(X509CertInfo.SERIAL_NUMBER,
+                    CertificateSerialNumber.newRandom64bit(prng));
             AlgorithmId algID = AlgorithmId.getWithParameterSpec(sigAlg, params);
             info.set(X509CertInfo.ALGORITHM_ID,
                      new CertificateAlgorithmId(algID));
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Tue Apr 09 11:48:54 2019 +0100
@@ -37,6 +37,7 @@
 import java.security.Key;
 import java.security.PublicKey;
 import java.security.PrivateKey;
+import java.security.SecureRandom;
 import java.security.Signature;
 import java.security.Timestamp;
 import java.security.UnrecoverableEntryException;
@@ -174,6 +175,8 @@
     private Set<char[]> passwords = new HashSet<>();
     private String startDate = null;
 
+    private boolean tlsInfo = false;
+
     private List<String> ids = new ArrayList<>();   // used in GENCRL
     private List<String> v3ext = new ArrayList<>();
 
@@ -259,6 +262,8 @@
         STOREPASSWD("Changes.the.store.password.of.a.keystore",
             NEW, KEYSTORE, CACERTS, STOREPASS, STORETYPE, PROVIDERNAME,
             ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V),
+        SHOWINFO("showinfo.command.help",
+            TLS, V),
 
         // Undocumented start here, KEYCLONE is used a marker in -help;
 
@@ -364,6 +369,7 @@
         STARTDATE("startdate", "<date>", "certificate.validity.start.date.time"),
         STOREPASS("storepass", "<arg>", "keystore.password"),
         STORETYPE("storetype", "<type>", "keystore.type"),
+        TLS("tls", null, "tls.option.help"),
         TRUSTCACERTS("trustcacerts", null, "trust.certificates.from.cacerts"),
         V("v", null, "verbose.output"),
         VALIDITY("validity", "<days>", "validity.number.of.days");
@@ -677,6 +683,8 @@
                 protectedPath = true;
             } else if (collator.compare(flags, "-srcprotected") == 0) {
                 srcprotectedPath = true;
+            } else if (collator.compare(flags, "-tls") == 0) {
+                tlsInfo = true;
             } else  {
                 System.err.println(rb.getString("Illegal.option.") + flags);
                 tinyHelp();
@@ -704,7 +712,7 @@
     }
 
     boolean isKeyStoreRelated(Command cmd) {
-        return cmd != PRINTCERT && cmd != PRINTCERTREQ;
+        return cmd != PRINTCERT && cmd != PRINTCERTREQ && cmd != SHOWINFO;
     }
 
     /**
@@ -873,8 +881,7 @@
         // Check if keystore exists.
         // If no keystore has been specified at the command line, try to use
         // the default, which is located in $HOME/.keystore.
-        // If the command is "genkey", "identitydb", "import", or "printcert",
-        // it is OK not to have a keystore.
+        // No need to check if isKeyStoreRelated(command) is false.
 
         // DO NOT open the existing keystore if this is an in-place import.
         // The keystore should be created as brand new.
@@ -888,6 +895,9 @@
                 }
                 ksStream = new FileInputStream(ksfile);
             } catch (FileNotFoundException e) {
+                // These commands do not need the keystore to be existing.
+                // Either it will create a new one or the keystore is
+                // optional (i.e. PRINTCRL).
                 if (command != GENKEYPAIR &&
                         command != GENSECKEY &&
                         command != IDENTITYDB &&
@@ -1310,6 +1320,8 @@
             }
         } else if (command == PRINTCRL) {
             doPrintCRL(filename, out);
+        } else if (command == SHOWINFO) {
+            doShowInfo();
         }
 
         // If we need to save the keystore, do so.
@@ -1436,8 +1448,8 @@
                 .getDefaultAlgorithmParameterSpec(sigAlgName, privateKey);
         AlgorithmId algID = AlgorithmId.getWithParameterSpec(sigAlgName, params);
         info.set(X509CertInfo.VALIDITY, interval);
-        info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(
-                    new java.util.Random().nextInt() & 0x7fffffff));
+        info.set(X509CertInfo.SERIAL_NUMBER,
+                CertificateSerialNumber.newRandom64bit(new SecureRandom()));
         info.set(X509CertInfo.VERSION,
                     new CertificateVersion(CertificateVersion.V3));
         info.set(X509CertInfo.ALGORITHM_ID,
@@ -2706,6 +2718,14 @@
         }
     }
 
+    private void doShowInfo() throws Exception {
+        if (tlsInfo) {
+            ShowInfo.tls(verbose);
+        } else {
+            System.out.println(rb.getString("showinfo.no.option"));
+        }
+    }
+
     private Collection<? extends Certificate> generateCertificates(InputStream in)
             throws CertificateException, IOException {
         byte[] data = in.readAllBytes();
@@ -2947,8 +2967,8 @@
         certInfo.set(X509CertInfo.VALIDITY, interval);
 
         // Make new serial number
-        certInfo.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(
-                    new java.util.Random().nextInt() & 0x7fffffff));
+        certInfo.set(X509CertInfo.SERIAL_NUMBER,
+                CertificateSerialNumber.newRandom64bit(new SecureRandom()));
 
         // Set owner and issuer fields
         X500Name owner;
--- a/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Tue Apr 09 11:48:54 2019 +0100
@@ -96,6 +96,8 @@
                 "Generates a self-signed certificate"}, //-selfcert
         {"Changes.the.store.password.of.a.keystore",
                 "Changes the store password of a keystore"}, //-storepasswd
+        {"showinfo.command.help", "Displays security-related information"},
+
         // keytool: help: options
         {"alias.name.of.the.entry.to.process",
                 "alias name of the entry to process"}, //-alias
@@ -141,6 +143,7 @@
                 "do not prompt"}, //-noprompt
         {"password.through.protected.mechanism",
                 "password through protected mechanism"}, //-protected
+        {"tls.option.help", "Displays TLS configuration information"},
 
         // The following 2 values should span 2 lines, the first for the
         // option itself, the second for its -providerArg value.
@@ -472,6 +475,8 @@
         {"backup.keystore.warning", "The original keystore \"%1$s\" is backed up as \"%3$s\"..."},
         {"importing.keystore.status", "Importing keystore %1$s to %2$s..."},
         {"keyalg.option.1.missing.warning", "No -keyalg option. The default key algorithm (%s) is a legacy algorithm and is no longer recommended. In a subsequent release of the JDK, the default will be removed and the -keyalg option must be specified."},
+
+        {"showinfo.no.option", "Missing option for -showinfo. Try \"keytool -showinfo -tls\"."},
     };
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/sun/security/tools/keytool/ShowInfo.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,53 @@
+/*
+ * 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 sun.security.tools.keytool;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+
+class ShowInfo {
+
+    // verbose is not used yet.
+    static void tls(boolean verbose) throws Exception {
+
+        SSLSocket ssls = (SSLSocket)
+                SSLContext.getDefault().getSocketFactory().createSocket();
+
+        System.out.println("Enabled Protocols");
+        System.out.println("-----------------");
+        for (String s : ssls.getEnabledProtocols()) {
+            System.out.println(s);
+        }
+
+        System.out.println();
+
+        System.out.println("Enabled Cipher Suites");
+        System.out.println("---------------------");
+        for (String s : ssls.getEnabledCipherSuites()) {
+            System.out.println(s);
+        }
+    }
+}
--- a/src/java.base/share/classes/sun/security/util/DerIndefLenConverter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/util/DerIndefLenConverter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, 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
@@ -26,7 +26,9 @@
 package sun.security.util;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 /**
  * A package private utility class to convert indefinite length DER
@@ -143,6 +145,10 @@
     /**
      * Parse the length and if it is an indefinite length then add
      * the current position to the <code>ndefsList</code> vector.
+     *
+     * @return the length of definite length data next, or -1 if there is
+     *         not enough bytes to determine it
+     * @throws IOException if invalid data is read
      */
     private int parseLength() throws IOException {
         int curLen = 0;
@@ -160,7 +166,7 @@
                 throw new IOException("Too much data");
             }
             if ((dataSize - dataPos) < (lenByte + 1)) {
-                throw new IOException("Too little data");
+                return -1;
             }
             for (int i = 0; i < lenByte; i++) {
                 curLen = (curLen << 8) + (data[dataPos++] & 0xff);
@@ -314,10 +320,10 @@
      * @param indefData the byte array holding the indefinite
      *        length encoding.
      * @return the byte array containing the definite length
-     *         DER encoding.
+     *         DER encoding, or null if there is not enough data.
      * @exception IOException on parsing or re-writing errors.
      */
-    byte[] convert(byte[] indefData) throws IOException {
+    byte[] convertBytes(byte[] indefData) throws IOException {
         data = indefData;
         dataPos=0; index=0;
         dataSize = data.length;
@@ -328,6 +334,9 @@
         while (dataPos < dataSize) {
             parseTag();
             len = parseLength();
+            if (len < 0) {
+                return null;
+            }
             parseValue(len);
             if (unresolved == 0) {
                 unused = dataSize - dataPos;
@@ -337,7 +346,7 @@
         }
 
         if (unresolved != 0) {
-            throw new IOException("not all indef len BER resolved");
+            return null;
         }
 
         newData = new byte[dataSize + numOfTotalLenBytes + unused];
@@ -354,4 +363,48 @@
 
         return newData;
     }
+
+    /**
+     * Read the input stream into a DER byte array. If an indef len BER is
+     * not resolved this method will try to read more data until EOF is reached.
+     * This may block.
+     *
+     * @param in the input stream with tag and lenByte already read
+     * @param lenByte the length of the length field to remember
+     * @param tag the tag to remember
+     * @return a DER byte array
+     * @throws IOException if not all indef len BER
+     *         can be resolved or another I/O error happens
+     */
+    public static byte[] convertStream(InputStream in, byte lenByte, byte tag)
+            throws IOException {
+        int offset = 2;     // for tag and length bytes
+        int readLen = in.available();
+        byte[] indefData = new byte[readLen + offset];
+        indefData[0] = tag;
+        indefData[1] = lenByte;
+        while (true) {
+            int bytesRead = in.readNBytes(indefData, offset, readLen);
+            if (bytesRead != readLen) {
+                readLen = bytesRead;
+                indefData = Arrays.copyOf(indefData, offset + bytesRead);
+            }
+            DerIndefLenConverter derIn = new DerIndefLenConverter();
+            byte[] result = derIn.convertBytes(indefData);
+            if (result == null) {
+                int next = in.read(); // This could block, but we need more
+                if (next == -1) {
+                    throw new IOException("not all indef len BER resolved");
+                }
+                int more = in.available();
+                // expand array to include next and more
+                indefData = Arrays.copyOf(indefData, offset + readLen + 1 + more);
+                indefData[offset + readLen] = (byte)next;
+                offset = offset + readLen + 1;
+                readLen = more;
+            } else {
+                return result;
+            }
+        }
+    }
 }
--- a/src/java.base/share/classes/sun/security/util/DerInputStream.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/util/DerInputStream.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -27,11 +27,9 @@
 
 import java.io.InputStream;
 import java.io.IOException;
-import java.io.EOFException;
 import java.util.Date;
 import java.util.Vector;
 import java.math.BigInteger;
-import java.io.DataInputStream;
 
 /**
  * A DER input stream, used for parsing ASN.1 DER-encoded data such as
@@ -130,7 +128,12 @@
                 System.arraycopy(data, offset, inData, 0, len);
 
                 DerIndefLenConverter derIn = new DerIndefLenConverter();
-                buffer = new DerInputBuffer(derIn.convert(inData), allowBER);
+                byte[] result = derIn.convertBytes(inData);
+                if (result == null) {
+                    throw new IOException("not all indef len BER resolved");
+                } else {
+                    buffer = new DerInputBuffer(result, allowBER);
+                }
             }
         } else {
             buffer = new DerInputBuffer(data, offset, len, allowBER);
@@ -389,16 +392,9 @@
 
         if (len == -1) {
            // indefinite length encoding found
-           int readLen = buffer.available();
-           int offset = 2;     // for tag and length bytes
-           byte[] indefData = new byte[readLen + offset];
-           indefData[0] = tag;
-           indefData[1] = lenByte;
-           DataInputStream dis = new DataInputStream(buffer);
-           dis.readFully(indefData, offset, readLen);
-           dis.close();
-           DerIndefLenConverter derIn = new DerIndefLenConverter();
-           buffer = new DerInputBuffer(derIn.convert(indefData), buffer.allowBER);
+           buffer = new DerInputBuffer(
+                   DerIndefLenConverter.convertStream(buffer, lenByte, tag),
+                   buffer.allowBER);
 
            if (tag != buffer.read())
                 throw new IOException("Indefinite length encoding" +
--- a/src/java.base/share/classes/sun/security/util/DerValue.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/util/DerValue.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -257,16 +257,9 @@
         length = DerInputStream.getLength(lenByte, in);
         if (length == -1) {  // indefinite length encoding found
             DerInputBuffer inbuf = in.dup();
-            int readLen = inbuf.available();
-            int offset = 2;     // for tag and length bytes
-            byte[] indefData = new byte[readLen + offset];
-            indefData[0] = tag;
-            indefData[1] = lenByte;
-            DataInputStream dis = new DataInputStream(inbuf);
-            dis.readFully(indefData, offset, readLen);
-            dis.close();
-            DerIndefLenConverter derIn = new DerIndefLenConverter();
-            inbuf = new DerInputBuffer(derIn.convert(indefData), in.allowBER);
+            inbuf = new DerInputBuffer(
+                    DerIndefLenConverter.convertStream(inbuf, lenByte, tag),
+                    in.allowBER);
             if (tag != inbuf.read())
                 throw new IOException
                         ("Indefinite length encoding not supported");
@@ -277,7 +270,7 @@
             // indefinite form is encoded by sending a length field with a
             // length of 0. - i.e. [1000|0000].
             // the object is ended by sending two zero bytes.
-            in.skip(length + offset);
+            in.skip(length + 2);
         } else {
 
             buffer = in.dup();
@@ -389,16 +382,8 @@
         byte lenByte = (byte)in.read();
         length = DerInputStream.getLength(lenByte, in);
         if (length == -1) { // indefinite length encoding found
-            int readLen = in.available();
-            int offset = 2;     // for tag and length bytes
-            byte[] indefData = new byte[readLen + offset];
-            indefData[0] = tag;
-            indefData[1] = lenByte;
-            DataInputStream dis = new DataInputStream(in);
-            dis.readFully(indefData, offset, readLen);
-            dis.close();
-            DerIndefLenConverter derIn = new DerIndefLenConverter();
-            in = new ByteArrayInputStream(derIn.convert(indefData));
+            in = new ByteArrayInputStream(
+                    DerIndefLenConverter.convertStream(in, lenByte, tag));
             if (tag != in.read())
                 throw new IOException
                         ("Indefinite length encoding not supported");
--- a/src/java.base/share/classes/sun/security/x509/CertificateSerialNumber.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/security/x509/CertificateSerialNumber.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -29,6 +29,7 @@
 import java.io.OutputStream;
 import java.math.BigInteger;
 import java.util.Enumeration;
+import java.util.Random;
 
 import sun.security.util.*;
 
@@ -179,4 +180,16 @@
     public String getName() {
         return (NAME);
     }
+
+    /**
+     * Generates a new random serial number.
+     */
+    public static CertificateSerialNumber newRandom64bit(Random rand) {
+        while (true) {
+            BigInteger b = new BigInteger(64, rand);
+            if (b.signum() != 0) {
+                return new CertificateSerialNumber(b);
+            }
+        }
+    }
 }
--- a/src/java.base/share/classes/sun/text/resources/FormatData.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/text/resources/FormatData.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -106,7 +106,7 @@
             "T",
             "S",
             "H",
-            "N", // NewEra
+            "R",
         };
 
         // Japanese imperial calendar era strings
@@ -116,7 +116,7 @@
             "Taisho",
             "Showa",
             "Heisei",
-            "NewEra", // NewEra
+            "Reiwa",
         };
 
         return new Object[][] {
--- a/src/java.base/share/classes/sun/text/resources/JavaTimeSupplementary.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/text/resources/JavaTimeSupplementary.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -159,7 +159,7 @@
             "Taisho",
             "Showa",
             "Heisei",
-            "NewEra", // New Era
+            "Reiwa",
         };
 
         final String[] sharedShortEras = {
--- a/src/java.base/share/classes/sun/util/calendar/Era.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/util/calendar/Era.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, 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
@@ -48,7 +48,7 @@
  *                           Taisho           1912-07-30T00:00:00 local time
  *                           Showa            1926-12-25T00:00:00 local time
  *                           Heisei           1989-01-08T00:00:00 local time
- *                           NewEra           2019-05-01T00:00:00 local time
+ *                           Reiwa            2019-05-01T00:00:00 local time
  *   -----------------------------------------------------------------------
  * }</pre>
  *
--- a/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java	Tue Apr 09 11:48:54 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
@@ -43,7 +43,7 @@
         new Era("Taisho", "T", -1812153600000L, true),
         new Era("Showa",  "S", -1357603200000L, true),
         new Era("Heisei", "H",   600220800000L, true),
-        new Era("NewEra", "N",  1556668800000L, true),
+        new Era("Reiwa",  "R",  1556668800000L, true),
     };
 
     private static boolean isValidEra(Era newEra, Era[] eras) {
--- a/src/java.base/share/classes/sun/util/locale/BaseLocale.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/util/locale/BaseLocale.java	Tue Apr 09 11:48:54 2019 +0100
@@ -32,14 +32,64 @@
 
 package sun.util.locale;
 
+import jdk.internal.misc.VM;
+import jdk.internal.vm.annotation.Stable;
+
 import java.lang.ref.SoftReference;
 import java.util.StringJoiner;
 
 public final class BaseLocale {
 
-    public static final String SEP = "_";
+    public static @Stable BaseLocale[] constantBaseLocales;
+    public static final byte ENGLISH = 0,
+            FRENCH = 1,
+            GERMAN = 2,
+            ITALIAN = 3,
+            JAPANESE = 4,
+            KOREAN = 5,
+            CHINESE = 6,
+            SIMPLIFIED_CHINESE = 7,
+            TRADITIONAL_CHINESE = 8,
+            FRANCE = 9,
+            GERMANY = 10,
+            ITALY = 11,
+            JAPAN = 12,
+            KOREA = 13,
+            UK = 14,
+            US = 15,
+            CANADA = 16,
+            CANADA_FRENCH = 17,
+            ROOT = 18,
+            NUM_CONSTANTS = 19;
+    static {
+        VM.initializeFromArchive(BaseLocale.class);
+        BaseLocale[] baseLocales = constantBaseLocales;
+        if (baseLocales == null) {
+            baseLocales = new BaseLocale[NUM_CONSTANTS];
+            baseLocales[ENGLISH] = createInstance("en", "");
+            baseLocales[FRENCH] = createInstance("fr", "");
+            baseLocales[GERMAN] = createInstance("de", "");
+            baseLocales[ITALIAN] = createInstance("it", "");
+            baseLocales[JAPANESE] = createInstance("ja", "");
+            baseLocales[KOREAN] = createInstance("ko", "");
+            baseLocales[CHINESE] = createInstance("zh", "");
+            baseLocales[SIMPLIFIED_CHINESE] = createInstance("zh", "CN");
+            baseLocales[TRADITIONAL_CHINESE] = createInstance("zh", "TW");
+            baseLocales[FRANCE] = createInstance("fr", "FR");
+            baseLocales[GERMANY] = createInstance("de", "DE");
+            baseLocales[ITALY] = createInstance("it", "IT");
+            baseLocales[JAPAN] = createInstance("ja", "JP");
+            baseLocales[KOREA] = createInstance("ko", "KR");
+            baseLocales[UK] = createInstance("en", "GB");
+            baseLocales[US] = createInstance("en", "US");
+            baseLocales[CANADA] = createInstance("en", "CA");
+            baseLocales[CANADA_FRENCH] = createInstance("fr", "CA");
+            baseLocales[ROOT] = createInstance("", "");
+            constantBaseLocales = baseLocales;
+        }
+    }
 
-    private static final Cache CACHE = new Cache();
+    public static final String SEP = "_";
 
     private final String language;
     private final String script;
@@ -67,28 +117,53 @@
 
     // Called for creating the Locale.* constants. No argument
     // validation is performed.
-    public static BaseLocale createInstance(String language, String region) {
-        BaseLocale base = new BaseLocale(language, "", region, "", false);
-        CACHE.put(new Key(base), base);
-        return base;
+    private static BaseLocale createInstance(String language, String region) {
+        return new BaseLocale(language, "", region, "", false);
     }
 
     public static BaseLocale getInstance(String language, String script,
                                          String region, String variant) {
+
+        if (script == null) {
+            script = "";
+        }
+        if (region == null) {
+            region = "";
+        }
+        if (language == null) {
+            language = null;
+        }
+        if (variant == null) {
+            variant = "";
+        }
+
+        // Non-allocating for most uses
+        language = LocaleUtils.toLowerString(language);
+        region = LocaleUtils.toUpperString(region);
+
+        // Check for constant base locales first
+        if (script.isEmpty() && variant.isEmpty()) {
+            for (BaseLocale baseLocale : constantBaseLocales) {
+                if (baseLocale.getLanguage().equals(language)
+                        && baseLocale.getRegion().equals(region)) {
+                    return baseLocale;
+                }
+            }
+        }
+
         // JDK uses deprecated ISO639.1 language codes for he, yi and id
-        if (language != null) {
-            if (LocaleUtils.caseIgnoreMatch(language, "he")) {
+        if (!language.isEmpty()) {
+            if (language.equals("he")) {
                 language = "iw";
-            } else if (LocaleUtils.caseIgnoreMatch(language, "yi")) {
+            } else if (language.equals("yi")) {
                 language = "ji";
-            } else if (LocaleUtils.caseIgnoreMatch(language, "id")) {
+            } else if (language.equals("id")) {
                 language = "in";
             }
         }
 
         Key key = new Key(language, script, region, variant, false);
-        BaseLocale baseLocale = CACHE.get(key);
-        return baseLocale;
+        return Cache.CACHE.get(key);
     }
 
     public String getLanguage() {
@@ -171,46 +246,8 @@
         private final boolean normalized;
         private final int hash;
 
-        /**
-         * Creates a Key. language and region must be normalized
-         * (intern'ed in the proper case).
-         */
-        private Key(BaseLocale locale) {
-            this.holder = locale;
-            this.holderRef = null;
-            this.normalized = true;
-            String language = locale.getLanguage();
-            String region = locale.getRegion();
-            assert LocaleUtils.toLowerString(language).intern() == language
-                    && LocaleUtils.toUpperString(region).intern() == region
-                    && locale.getVariant() == ""
-                    && locale.getScript() == "";
-
-            int h = language.hashCode();
-            if (region != "") {
-                int len = region.length();
-                for (int i = 0; i < len; i++) {
-                    h = 31 * h + LocaleUtils.toLower(region.charAt(i));
-                }
-            }
-            hash = h;
-        }
-
         private Key(String language, String script, String region,
                     String variant, boolean normalize) {
-            if (language == null) {
-                language = "";
-            }
-            if (script == null) {
-                script = "";
-            }
-            if (region == null) {
-                region = "";
-            }
-            if (variant == null) {
-                variant = "";
-            }
-
             BaseLocale locale = new BaseLocale(language, script, region, variant, normalize);
             this.normalized = normalize;
             if (normalized) {
@@ -291,6 +328,8 @@
 
     private static class Cache extends LocaleObjectCache<Key, BaseLocale> {
 
+        private static final Cache CACHE = new Cache();
+
         public Cache() {
         }
 
--- a/src/java.base/share/classes/sun/util/locale/LocaleUtils.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/util/locale/LocaleUtils.java	Tue Apr 09 11:48:54 2019 +0100
@@ -206,19 +206,19 @@
         return true;
     }
 
-    static boolean isEmpty(String str) {
+    public static boolean isEmpty(String str) {
         return str == null || str.isEmpty();
     }
 
-    static boolean isEmpty(Set<?> set) {
+    public static boolean isEmpty(Set<?> set) {
         return set == null || set.isEmpty();
     }
 
-    static boolean isEmpty(Map<?, ?> map) {
+    public static boolean isEmpty(Map<?, ?> map) {
         return map == null || map.isEmpty();
     }
 
-    static boolean isEmpty(List<?> list) {
+    public static boolean isEmpty(List<?> list) {
         return list == null || list.isEmpty();
     }
 }
--- a/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java	Tue Apr 09 11:48:54 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
@@ -84,10 +84,10 @@
                         Era[] jeras = CalendarSystem.forName("japanese").getEras();
                         if (value <= jeras.length) {
                             // Localized era name could not be retrieved from this provider.
-                            // This can occur either for NewEra or SupEra.
+                            // This can occur either for Reiwa or SupEra.
                             //
                             // If it's CLDR provider, try COMPAT first, which is guaranteed to have
-                            // the name for NewEra.
+                            // the name for Reiwa.
                             if (type == LocaleProviderAdapter.Type.CLDR) {
                                 lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
                                 key = getResourceKeyFor(LocaleProviderAdapter.Type.JRE,
--- a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -491,8 +491,7 @@
      */
     private static class AvailableJRELocales {
         private static final Locale[] localeList = createAvailableLocales();
-        private AvailableJRELocales() {
-        }
+        private AvailableJRELocales() {}
     }
 
     private static Locale[] createAvailableLocales() {
@@ -535,7 +534,7 @@
     public boolean isSupportedProviderLocale(Locale locale,  Set<String> langtags) {
         if (Locale.ROOT.equals(locale)) {
             return true;
-}
+        }
 
         locale = locale.stripExtensions();
         if (langtags.contains(locale.toLanguageTag())) {
--- a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java	Tue Apr 09 11:48:54 2019 +0100
@@ -44,6 +44,7 @@
 import java.lang.ref.SoftReference;
 import java.text.MessageFormat;
 import java.text.NumberFormat;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -325,7 +326,7 @@
         Set<String> keyset = getZoneIDs();
         // Use a LinkedHashSet to preseve the order
         Set<String[]> value = new LinkedHashSet<>();
-        Set<String> tzIds = new HashSet<>(Set.of(TimeZone.getAvailableIDs()));
+        Set<String> tzIds = new HashSet<>(Arrays.asList(TimeZone.getAvailableIDs()));
         for (String key : keyset) {
             if (!key.startsWith(TZNB_EXCITY_PREFIX)) {
                 value.add(rb.getStringArray(key));
--- a/src/java.base/share/legal/public_suffix.md	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/legal/public_suffix.md	Tue Apr 09 11:48:54 2019 +0100
@@ -11,7 +11,7 @@
 
 The Source Code of this file is available under the
 Mozilla Public License, v. 2.0 and is located at
-https://raw.githubusercontent.com/publicsuffix/list/2225db8d9f4a2a27ec697c883360632fa0c16261/public_suffix_list.dat.
+https://raw.githubusercontent.com/publicsuffix/list/ce0d1a5fba657e55adea3abde4b7f1e50636ff10/public_suffix_list.dat.
 If a copy of the MPL was not distributed with this file, you can obtain one
 at https://mozilla.org/MPL/2.0/.
 
--- a/src/java.base/share/lib/security/default.policy	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/share/lib/security/default.policy	Tue Apr 09 11:48:54 2019 +0100
@@ -160,6 +160,7 @@
 grant codeBase "jrt:/jdk.internal.vm.compiler.management" {
     permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.vm.compiler.collections";
     permission java.lang.RuntimePermission "accessClassInPackage.jdk.vm.ci.runtime";
+    permission java.lang.RuntimePermission "accessClassInPackage.jdk.vm.ci.services";
     permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.core.common";
     permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.debug";
     permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.hotspot";
--- a/src/java.base/windows/native/libjli/java_md.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/windows/native/libjli/java_md.c	Tue Apr 09 11:48:54 2019 +0100
@@ -41,8 +41,6 @@
 #define JVM_DLL "jvm.dll"
 #define JAVA_DLL "java.dll"
 
-#define ELP_PREFIX L"\\\\?\\"
-
 /*
  * Prototypes.
  */
@@ -497,57 +495,67 @@
     return rc;
 }
 
-/* On Windows, if _open fails, retry again with CreateFileW and
- *  "\\?\" prefix ( extended-length paths) - this allows to open paths with larger file names;
- * otherwise we run into the MAX_PATH limitation */
-int JLI_Open(const char* name, int flags) {
-    int fd = _open(name, flags);
-    if (fd == -1 && errno == ENOENT) {
-        wchar_t* wname = NULL;
-        wchar_t* wfullname = NULL;
-        wchar_t* wfullname_w_prefix = NULL;
-        size_t wnamelen, wfullnamelen, elplen;
-        HANDLE h;
-
-        wnamelen = strlen(name) + 1;
-        wname = (wchar_t*) malloc(wnamelen*sizeof(wchar_t));
-        if (wname == NULL) {
-            goto end;
-        }
-        if (mbstowcs(wname, name, wnamelen - 1) == -1) {
-            goto end;
+/* taken from hotspot and slightly adjusted for jli lib;
+ * creates a UNC/ELP path from input 'path'
+ * the return buffer is allocated in C heap and needs to be freed using
+ * JLI_MemFree by the caller.
+ */
+static wchar_t* create_unc_path(const char* path, errno_t* err) {
+    wchar_t* wpath = NULL;
+    size_t converted_chars = 0;
+    size_t path_len = strlen(path) + 1; /* includes the terminating NULL */
+    if (path[0] == '\\' && path[1] == '\\') {
+        if (path[2] == '?' && path[3] == '\\') {
+            /* if it already has a \\?\ don't do the prefix */
+            wpath = (wchar_t*) JLI_MemAlloc(path_len * sizeof(wchar_t));
+            if (wpath != NULL) {
+                *err = mbstowcs_s(&converted_chars, wpath, path_len, path, path_len);
+            } else {
+                *err = ENOMEM;
+            }
+        } else {
+            /* only UNC pathname includes double slashes here */
+            wpath = (wchar_t*) JLI_MemAlloc((path_len + 7) * sizeof(wchar_t));
+            if (wpath != NULL) {
+                wcscpy(wpath, L"\\\\?\\UNC\0");
+                *err = mbstowcs_s(&converted_chars, &wpath[7], path_len, path, path_len);
+            } else {
+                *err = ENOMEM;
+            }
         }
-        wname[wnamelen - 1] = L'\0';
-        wfullname = _wfullpath(wfullname, wname, 0);
-        if (wfullname == NULL) {
-            goto end;
+    } else {
+        wpath = (wchar_t*) JLI_MemAlloc((path_len + 4) * sizeof(wchar_t));
+        if (wpath != NULL) {
+            wcscpy(wpath, L"\\\\?\\\0");
+            *err = mbstowcs_s(&converted_chars, &wpath[4], path_len, path, path_len);
+        } else {
+            *err = ENOMEM;
         }
-
-        wfullnamelen = wcslen(wfullname);
-        if (wfullnamelen > 247) {
-            elplen = wcslen(ELP_PREFIX);
-            wfullname_w_prefix = (wchar_t*) malloc((elplen+wfullnamelen+1)*sizeof(wchar_t));
-            wcscpy(wfullname_w_prefix, ELP_PREFIX);
-            wcscpy(wfullname_w_prefix+elplen, wfullname);
+    }
+    return wpath;
+}
 
-            h = CreateFileW(wfullname_w_prefix, GENERIC_READ, FILE_SHARE_READ, NULL,
-                            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-            if (h == INVALID_HANDLE_VALUE) {
-                goto end;
-            }
-            /* associates fd with handle */
-            fd = _open_osfhandle((intptr_t)h, _O_RDONLY);
+int JLI_Open(const char* name, int flags) {
+    int fd;
+    if (strlen(name) < MAX_PATH) {
+        fd = _open(name, flags);
+    } else {
+        errno_t err = ERROR_SUCCESS;
+        wchar_t* wpath = create_unc_path(name, &err);
+        if (err != ERROR_SUCCESS) {
+            if (wpath != NULL) JLI_MemFree(wpath);
+            errno = err;
+            return -1;
         }
-end:
-        free(wname);
-        free(wfullname);
-        free(wfullname_w_prefix);
+        fd = _wopen(wpath, flags);
+        if (fd == -1) {
+            errno = GetLastError();
+        }
+        JLI_MemFree(wpath);
     }
     return fd;
 }
 
-
-
 JNIEXPORT void JNICALL
 JLI_ReportErrorMessage(const char* fmt, ...) {
     va_list vl;
--- a/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -1063,8 +1063,17 @@
     LPCWSTR link = jlong_to_ptr(linkAddress);
     LPCWSTR target = jlong_to_ptr(targetAddress);
 
-    /* On Windows 64-bit this appears to succeed even when there is insufficient privileges */
-    if (CreateSymbolicLinkW(link, target, (DWORD)flags) == 0)
+    // Allow creation of symbolic links when the process is not elevated.
+    // Developer Mode must be enabled for this option to function, otherwise
+    // it will be ignored. Check that symbol is available in current build SDK.
+    DWORD dwFlags = (DWORD)flags;
+#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
+    dwFlags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
+#endif
+
+    // On Windows 64-bit this appears to succeed even when there are
+    // insufficient privileges
+    if (CreateSymbolicLinkW(link, target, dwFlags) == 0)
         throwWindowsException(env, GetLastError());
 }
 
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m	Tue Apr 09 11:48:54 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
@@ -70,7 +70,7 @@
     AWT_ASSERT_APPKIT_THREAD;
     JNIEnv *env = [ThreadUtilities getJNIEnv];
     JNF_COCOA_ENTER(env);
-    
+
     // If we are called as a result of user pressing a shortcut, do nothing,
     // because AVTView has already sent corresponding key event to the Java
     // layer from performKeyEquivalent.
@@ -81,45 +81,26 @@
     // from this "frameless" menu, because there are no active windows. This
     // means we have to handle it here.
     NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
+
+    if ([currEvent type] == NSKeyDown) {
+        // The action event can be ignored only if the key window is an AWT window.
+        // Otherwise, the action event is the only notification and must be processed.
+        NSWindow *keyWindow = [NSApp keyWindow];
+        if (keyWindow != nil && [AWTWindow isAWTWindow: keyWindow]) {
+            return;
+        }
+    }
+
     if (fIsCheckbox) {
         static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
         static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
-        
+
         // Send the opposite of what's currently checked -- the action
         // indicates what state we're going to.
         NSInteger state = [sender state];
         jboolean newState = (state == NSOnState ? JNI_FALSE : JNI_TRUE);
         JNFCallVoidMethod(env, fPeer, jm_ckHandleAction, newState);
-    }
-    else {
-        if ([currEvent type] == NSKeyDown) {
-            // Event available through sender variable hence NSApplication
-            // not needed for checking the keyboard input sans the modifier keys
-            // Also, the method used to fetch eventKey earlier would be locale dependent
-            // With earlier implementation, if MenuKey: e EventKey: ा ; if input method
-            // is not U.S. (Devanagari in this case)
-            // With current implementation, EventKey = MenuKey = e irrespective of
-            // input method
-            NSString *eventKey = [sender keyEquivalent];
-            // Apple uses characters from private Unicode range for some of the
-            // keys, so we need to do the same translation here that we do
-            // for the regular key down events
-            if ([eventKey length] == 1) {
-                unichar origChar = [eventKey characterAtIndex:0];
-                unichar newChar =  NsCharToJavaChar(origChar, 0);
-                if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
-                    newChar = origChar;
-                }
-                eventKey = [NSString stringWithCharacters: &newChar length: 1];
-            }
-            // The action event can be ignored only if the key window is an AWT window.
-            // Otherwise, the action event is the only notification and must be processed.
-            NSWindow *keyWindow = [NSApp keyWindow];
-            if (keyWindow != nil && [AWTWindow isAWTWindow: keyWindow]) {
-                return;
-            }
-        }
-        
+    } else {
         static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
         static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
 
@@ -129,7 +110,6 @@
         JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
     }
     JNF_COCOA_EXIT(env);
-    
 }
 
 - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m	Tue Apr 09 11:48:54 2019 +0100
@@ -300,7 +300,7 @@
 
     // create a graphics context around the Java int array
     CGColorSpaceRef picColorSpace = CGColorSpaceCreateWithName(
-                                            kCGColorSpaceGenericRGB);
+                                            kCGColorSpaceSRGB);
     CGContextRef jPicContextRef = CGBitmapContextCreate(
                                             jPixelData,
                                             picWidth, picHeight,
--- a/src/java.desktop/share/classes/com/sun/beans/introspect/PropertyInfo.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/com/sun/beans/introspect/PropertyInfo.java	Tue Apr 09 11:48:54 2019 +0100
@@ -72,10 +72,12 @@
     }
 
     private boolean initialize() {
+        boolean isInitedToIsGetter = false;
         if (this.read != null) {
             this.type = this.read.type;
+            isInitedToIsGetter = isPrefix(this.read.method.getName(), "is");
         }
-        if (this.readList != null) {
+        if (!isInitedToIsGetter && this.readList != null) {
             for (MethodInfo info : this.readList) {
                 if ((this.read == null) || this.read.type.isAssignableFrom(info.type)) {
                     this.read = info;
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Tue Apr 09 11:48:54 2019 +0100
@@ -60,8 +60,12 @@
  * long term persistence.
  *
  * @author unattributed
+ * @deprecated The Motif Look and Feel is deprecated with the intent to remove
+ *             it in some future release. It is recommended to use
+ *             {@link javax.swing.plaf.metal.MetalLookAndFeel} instead.
  */
 @SuppressWarnings("serial") // Superclass is not serializable across versions
+@Deprecated(since="13", forRemoval=true)
 public class MotifLookAndFeel extends BasicLookAndFeel
 {
     public String getName() {
--- a/src/java.desktop/share/classes/java/awt/AlphaComposite.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/java/awt/AlphaComposite.java	Tue Apr 09 11:48:54 2019 +0100
@@ -163,7 +163,7 @@
  * </tbody>
  * </table>
  *
- * <h3>Preparing Inputs</h3>
+ * <h2>Preparing Inputs</h2>
  *
  * <p>
  * The {@code AlphaComposite} class defines an additional alpha
@@ -204,7 +204,7 @@
  *      <em>C<sub>d</sub></em> = <em>C<sub>dr</sub></em> * <em>A<sub>d</sub></em>    (if destination is not premultiplied)
  *      <em>C<sub>d</sub></em> = <em>C<sub>dr</sub></em>         (if destination is premultiplied) </pre>
  *
- * <h3>Applying the Blending Equation</h3>
+ * <h2>Applying the Blending Equation</h2>
  *
  * <p>
  * The adjusted <em>A<sub>s</sub></em>, <em>A<sub>d</sub></em>,
@@ -213,7 +213,7 @@
  * <em>F<sub>s</sub></em> and <em>F<sub>d</sub></em> and then the resulting
  * premultiplied components <em>A<sub>r</sub></em> and <em>C<sub>r</sub></em>.
  *
- * <h3>Preparing Results</h3>
+ * <h2>Preparing Results</h2>
  *
  * <p>
  * The results only need to be adjusted if they are to be stored
@@ -230,7 +230,7 @@
  * by zero" and the color components are left as
  * all zeros.
  *
- * <h3>Performance Considerations</h3>
+ * <h2>Performance Considerations</h2>
  *
  * <p>
  * For performance reasons, it is preferable that
@@ -243,7 +243,7 @@
  * appropriate conversions are performed before and after the compositing
  * operation.
  *
- * <h3><a id="caveats">Implementation Caveats</a></h3>
+ * <h2><a id="caveats">Implementation Caveats</a></h2>
  *
  * <ul>
  * <li>
--- a/src/java.desktop/share/classes/java/awt/Component.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/java/awt/Component.java	Tue Apr 09 11:48:54 2019 +0100
@@ -135,7 +135,7 @@
  * validated afterwards by means of the {@link Container#validate()} method
  * invoked on the top-most invalid container of the hierarchy.
  *
- * <h3>Serialization</h3>
+ * <h2>Serialization</h2>
  * It is important to note that only AWT listeners which conform
  * to the {@code Serializable} protocol will be saved when
  * the object is stored.  If an AWT object has listeners that
--- a/src/java.desktop/share/classes/java/awt/Font.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/java/awt/Font.java	Tue Apr 09 11:48:54 2019 +0100
@@ -74,7 +74,7 @@
  * and to render sequences of glyphs on {@code Graphics} and
  * {@code Component} objects.
  *
- * <h3>Characters and Glyphs</h3>
+ * <h2>Characters and Glyphs</h2>
  *
  * A <em>character</em> is a symbol that represents an item such as a letter,
  * a digit, or punctuation in an abstract way. For example, {@code 'g'},
@@ -96,7 +96,7 @@
  * of characters as well as the tables needed to map sequences of characters to
  * corresponding sequences of glyphs.
  *
- * <h3>Physical and Logical Fonts</h3>
+ * <h2>Physical and Logical Fonts</h2>
  *
  * The Java Platform distinguishes between two kinds of fonts:
  * <em>physical</em> fonts and <em>logical</em> fonts.
@@ -135,7 +135,7 @@
  * in <a href="https://docs.oracle.com/javase/tutorial/index.html">The Java Tutorials</a>
  * document.
  *
- * <h3>Font Faces and Names</h3>
+ * <h2>Font Faces and Names</h2>
  *
  * A {@code Font}
  * can have many faces, such as heavy, medium, oblique, gothic and
@@ -169,7 +169,7 @@
  * with varying sizes, styles, transforms and font features via the
  * {@code deriveFont} methods in this class.
  *
- * <h3>Font and TextAttribute</h3>
+ * <h2>Font and TextAttribute</h2>
  *
  * <p>{@code Font} supports most
  * {@code TextAttribute}s.  This makes some operations, such as
--- a/src/java.desktop/share/classes/java/awt/font/TextAttribute.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/java/awt/font/TextAttribute.java	Tue Apr 09 11:48:54 2019 +0100
@@ -67,7 +67,7 @@
  *   <LI>a description of the effect.
  * </UL>
  *
- * <H3>Values</H3>
+ * <H2>Values</H2>
  * <UL>
  *   <LI>The values of attributes must always be immutable.
  *   <LI>Where value limitations are given, any value outside of that
@@ -95,7 +95,7 @@
  *
  * </UL>
  *
- * <h4>Summary of attributes</h4>
+ * <h3>Summary of attributes</h3>
  *
  * <table style="width:95%;margin: 0px auto" class="striped">
  * <caption>Key, value type, principal constants, and default value behavior of
--- a/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java	Tue Apr 09 11:48:54 2019 +0100
@@ -46,7 +46,7 @@
  *      [ y'] = [  m10  m11  m12  ] [ y ] = [ m10x + m11y + m12 ]
  *      [ 1 ]   [   0    0    1   ] [ 1 ]   [         1         ]
  * </pre>
- * <h3><a id="quadrantapproximation">Handling 90-Degree Rotations</a></h3>
+ * <h2><a id="quadrantapproximation">Handling 90-Degree Rotations</a></h2>
  * <p>
  * In some variations of the {@code rotate} methods in the
  * {@code AffineTransform} class, a double-precision argument
--- a/src/java.desktop/share/classes/javax/accessibility/package-info.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/accessibility/package-info.java	Tue Apr 09 11:48:54 2019 +0100
@@ -37,8 +37,8 @@
  * interfaces, and 6 Java programming language classes. These are described
  * below.
  *
- * <h3><a id="Accessible"></a><a href="Accessible.html">Interface
- * Accessible</a></h3>
+ * <h2><a id="Accessible"></a><a href="Accessible.html">Interface
+ * Accessible</a></h2>
  * <a href="Accessible.html">Interface Accessible</a> is the main interface of
  * the Java Accessibility API. All components that support the Java
  * Accessibility API must implement this interface. It contains a single method,
@@ -48,8 +48,8 @@
  * object that is part of the user interface of a Java application, if that
  * program is to be compatible with assistive technologies.
  *
- * <h3><a id="AccessibleContext"></a><a href="AccessibleContext.html">Class
- * AccessibleContext</a></h3>
+ * <h2><a id="AccessibleContext"></a><a href="AccessibleContext.html">Class
+ * AccessibleContext</a></h2>
  * <a href="AccessibleContext.html">AccessibleContext</a> represents the minimum
  * information all accessible objects return and is obtained by calling the
  * {@code getAccessibleContext} method on an object that implements the
@@ -108,8 +108,8 @@
  *     called on an AccessibleContext.</li>
  * </ul>
  *
- * <h3><a id="AccessibleRole"></a><a href="AccessibleRole.html">Class
- * AccessibleRole</a></h3>
+ * <h2><a id="AccessibleRole"></a><a href="AccessibleRole.html">Class
+ * AccessibleRole</a></h2>
  * This class encapsulates the Accessible object's role in the user interface
  * and is obtained by calling the {@code getAccessibleRole} method on an
  * <a href="#AccessibleContext">AccessibleContext</a>. Accessible roles include
@@ -123,8 +123,8 @@
  * programmer-defined roles can be added in the future without needing to modify
  * the base class.
  *
- * <h3><a id="AccessibleState"></a><a href="AccessibleState.html">Class
- * AccessibleState</a></h3>
+ * <h2><a id="AccessibleState"></a><a href="AccessibleState.html">Class
+ * AccessibleState</a></h2>
  * This class encapsulates a particular state of the Accessible object.
  * Accessible states include things like "Armed", "Busy", "Checked", "Focused",
  * etc. These roles are identified by the constants in this class such as
@@ -142,8 +142,8 @@
  * additional, programmer-defined roles can be added in the future without
  * needing to modify the base class.
  *
- * <h3><a id="AccessibleStateSet"></a><a href="AccessibleStateSet.html">Class
- * AccessibleStateSet</a></h3>
+ * <h2><a id="AccessibleStateSet"></a><a href="AccessibleStateSet.html">Class
+ * AccessibleStateSet</a></h2>
  * This class encapsulates a collection of states of the Accessible object and
  * is obtained by calling the {@code getAccessibleStateSet} method on an
  * <a href="#AccessibleContext">AccessibleContext</a>. Since an object might
@@ -152,8 +152,8 @@
  * class provide for retrieving the individual
  * <a href="#AccessibleState">AccessibleStates</a> on the state set.
  *
- * <h3><a id="AccessibleBundle"></a><a href="AccessibleBundle.html">Class
- * AccessibleBundle</a></h3>
+ * <h2><a id="AccessibleBundle"></a><a href="AccessibleBundle.html">Class
+ * AccessibleBundle</a></h2>
  * This class is used to maintain a strongly typed enumeration. It is the super
  * class of both the <a href="#AccessibleRole">AccessibleRole</a> and
  * <a href="#AccessibleState">AccessibleState</a> classes. Programmers normally
@@ -161,8 +161,8 @@
  * <a href="#AccessibleRole">AccessibleRole</a> and
  * <a href="#AccessibleState">AccessibleState</a> classes.
  *
- * <h3><a id="AccessibleAction"></a><a href="AccessibleAction.html">Interface
- * AccessibleAction</a></h3>
+ * <h2><a id="AccessibleAction"></a><a href="AccessibleAction.html">Interface
+ * AccessibleAction</a></h2>
  * The <a href="AccessibleAction.html">AccessibleAction</a> interface should be
  * supported by any object that can perform one or more actions. This interface
  * provides the standard mechanism for an assistive technology to determine what
@@ -177,8 +177,8 @@
  * <a href="#AccessibleContext">AccessibleContext</a>. If the return value is
  * not {@code null}, the object supports this interface.
  *
- * <h3> <a id="AccessibleComponent"></a><a href="AccessibleComponent.html">
- * Interface AccessibleComponent</a></h3>
+ * <h2> <a id="AccessibleComponent"></a><a href="AccessibleComponent.html">
+ * Interface AccessibleComponent</a></h2>
  * The <a href="AccessibleComponent.html">AccessibleComponent</a> interface
  * should be supported by any object that is rendered on the screen. This
  * interface provides the standard mechanism for an assistive technology to
@@ -190,8 +190,8 @@
  * <a href="#AccessibleContext">AccessibleContext</a>. If the return value is
  * not {@code null}, the object supports this interface.
  *
- * <h3><a id="AccessibleSelection"></a><a href="AccessibleSelection.html">
- * Interface AccessibleSelection</a></h3>
+ * <h2><a id="AccessibleSelection"></a><a href="AccessibleSelection.html">
+ * Interface AccessibleSelection</a></h2>
  * The <a href="AccessibleSelection.html">AccessibleSelection</a> interface
  * provides the standard mechanism for an assistive technology to determine what
  * the current selected children are, as well as modify the selection set. Any
@@ -206,8 +206,8 @@
  * <a href="#AccessibleContext">AccessibleContext</a>. If the return value is
  * not {@code null}, the object supports this interface.
  *
- * <h3><a id="AccessibleText"></a><a href="AccessibleText.html">Interface
- * AccessibleText</a></h3>
+ * <h2><a id="AccessibleText"></a><a href="AccessibleText.html">Interface
+ * AccessibleText</a></h2>
  * Interface <a href="AccessibleText.html">AccessibleText</a> is the contract
  * for making rich, editable text Accessible. Not all text displayed on the
  * screen is rich and editable (e.g. text contained in buttons, labels, menus,
@@ -230,8 +230,8 @@
  * <a href="#AccessibleContext">AccessibleContext</a>. If the return value is
  * not {@code null}, the object supports this interface.
  *
- * <h3><a id="AccessibleHypertext"></a> <a href="AccessibleHypertext.html">
- * Interface AccessibleHypertext</a></h3>
+ * <h2><a id="AccessibleHypertext"></a> <a href="AccessibleHypertext.html">
+ * Interface AccessibleHypertext</a></h2>
  * The <a href="AccessibleHypertext.html">AccessibleHypertext</a> interface
  * should be supported by any object that presents hypertext information on the
  * display. This interface provides the standard mechanism for an assistive
@@ -246,16 +246,16 @@
  * class which extends AccessibleHypertext, then that object supports
  * AccessibleHypertext.
  *
- * <h3><a id="AccessibleHyperlink"></a><a href="AccessibleHyperlink.html">
- * Interface AccessibleHyperlink</a></h3>
+ * <h2><a id="AccessibleHyperlink"></a><a href="AccessibleHyperlink.html">
+ * Interface AccessibleHyperlink</a></h2>
  * An object that is a hyperlink should support the
  * <a href="AccessibleHyperlink.html">AccessibleHyperlink</a> interface.&nbsp;
  * An object that implements this interface will be returned by calling the
  * getLink method on an <a href="#AccessibleHypertext">AccessibleHypertext</a>
  * object.
  *
- * <h3><a id="AccessibleValue"></a><a href="AccessibleValue.html">Interface
- * AccessibleValue</a></h3>
+ * <h2><a id="AccessibleValue"></a><a href="AccessibleValue.html">Interface
+ * AccessibleValue</a></h2>
  * The <a href="AccessibleValue.html">AccessibleValue</a> interface should be
  * supported by any object that supports a numerical value (e.g., a scroll bar).
  * This interface provides the standard mechanism for an assistive technology to
--- a/src/java.desktop/share/classes/javax/print/DocFlavor.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/print/DocFlavor.java	Tue Apr 09 11:48:54 2019 +0100
@@ -60,7 +60,7 @@
  * class, from which the {@code DocPrintJob} then obtains the actual print data.
  *
  * <hr>
- * <h3>Client Formatted Print Data</h3>
+ * <h2>Client Formatted Print Data</h2>
  * There are two broad categories of print data, client formatted print data and
  * service formatted print data.
  * <p>
@@ -120,7 +120,7 @@
  * </ul>
  *
  * <hr>
- * <h3>Default and Platform Encodings</h3>
+ * <h2>Default and Platform Encodings</h2>
  * For byte print data where the doc flavor's MIME type does not include a
  * {@code charset} parameter, the Java Print Service instance assumes the
  * US-ASCII character set by default. This is in accordance with
@@ -161,7 +161,7 @@
  * the Java platform.
  *
  * <hr>
- * <h3>Recommended DocFlavors</h3>
+ * <h2>Recommended DocFlavors</h2>
  * The Java Print Service API does not define any mandatorily supported
  * {@code DocFlavors}. However, here are some examples of MIME types that a Java
  * Print Service instance might support for client formatted print data. Nested
@@ -261,7 +261,7 @@
  * </ul>
  *
  * <hr>
- * <h3>Service Formatted Print Data</h3>
+ * <h2>Service Formatted Print Data</h2>
  * For <b>service formatted print data</b>, the Java Print Service instance
  * determines the print data format. The doc flavor's representation class
  * denotes an interface whose methods the {@code DocPrintJob} invokes to
@@ -296,7 +296,7 @@
  * </ul>
  *
  * <hr>
- * <h3>Pre-defined Doc Flavors</h3>
+ * <h2>Pre-defined Doc Flavors</h2>
  * A Java Print Service instance is not <b><i>required</i></b> to support the
  * following print data formats and print data representation classes. In fact,
  * a developer using this class should <b>never</b> assume that a particular
@@ -342,7 +342,7 @@
  * The client must itself perform all plain text print data formatting not
  * addressed by the above requirements.
  *
- * <h3>Design Rationale</h3>
+ * <h2>Design Rationale</h2>
  * Class {@code DocFlavor} in package {@code javax.print} is similar to class
  * {@link java.awt.datatransfer.DataFlavor}. Class {@code DataFlavor} is not
  * used in the Java Print Service (JPS) API for three reasons which are all
--- a/src/java.desktop/share/classes/javax/print/attribute/package-info.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/print/attribute/package-info.java	Tue Apr 09 11:48:54 2019 +0100
@@ -27,7 +27,7 @@
  * Provides classes and interfaces that describe the types of Java&trade; Print
  * Service attributes and how they can be collected into attribute sets.
  *
- * <h3>What is an Attribute?</h3>
+ * <h2>What is an Attribute?</h2>
  * When setting up a print job, a client specifies two things: <b>print data</b>
  * and <b>processing instructions.</b> The print data is the actual content to
  * be printed. The processing instructions tell the printer how to print the
@@ -60,7 +60,7 @@
  * instructions as descriptive items provides more flexibility for implementing
  * print jobs.
  *
- * <h4>Attribute Categories and Values</h4>
+ * <h3>Attribute Categories and Values</h3>
  * Each printer has a set of capabilities, such as the ability to print on
  * different paper sizes or the ability to print more than one copy. Each of the
  * capabilities has a range of values. For example, a printer's orientation
@@ -80,7 +80,7 @@
  * attribute category, and the {@code Copies} instance represents the attribute
  * value.
  *
- * <h4><a id="role"></a>Attribute Roles</h4>
+ * <h3><a id="role"></a>Attribute Roles</h3>
  * When submitting a print job to a printer, the client provides the attributes
  * describing the characteristics of the print data, such as the document name,
  * and how the print data should be printed, such as double-sided, five copies.
@@ -128,7 +128,7 @@
  * conceptually separate from the generic apparatus defined in package
  * {@code javax.print.attribute}.
  *
- * <h3>Attribute Sets</h3>
+ * <h2>Attribute Sets</h2>
  * A client usually needs to provide more than one processing instruction when
  * submitting a print job. For example, the client might need to specify a media
  * size of A4 and a landscape orientation. To send more than one processing
@@ -201,7 +201,7 @@
  * restriction that the attribute set is only allowed to contain the
  * corresponding kind of attribute.
  *
- * <h3>Attribute Class Design</h3>
+ * <h2>Attribute Class Design</h2>
  * An attribute value is a small, atomic data item, such as an integer or an
  * enumerated value. The Java Print Service API does not use primitive data
  * types, such as int, to represent attribute values for these reasons:
@@ -295,7 +295,7 @@
  * references can be passed around freely. To get a different attribute value,
  * construct a different attribute object.
  *
- * <h3>Attribute Vendors</h3>
+ * <h2>Attribute Vendors</h2>
  * The Java Print Service API is designed so that vendors can:
  * <ul>
  *   <li>define new vendor-specific values for any standard attribute defined in
@@ -321,7 +321,7 @@
  * a new one. The new vendor-defined attribute can be used wherever an
  * {@code Attribute} is used, such as in an {@code AttributeSet}.
  *
- * <h3>Using Attributes</h3>
+ * <h2>Using Attributes</h2>
  * A typical printing application uses the {@code PrintRequestAttributeSet}
  * because print-request attributes are the types of attributes that client
  * usually specifies. This example demonstrates creating an attribute set of
--- a/src/java.desktop/share/classes/javax/print/attribute/standard/package-info.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/print/attribute/standard/package-info.java	Tue Apr 09 11:48:54 2019 +0100
@@ -82,19 +82,19 @@
  * from the above documents. The above authors' contribution to the API is
  * gratefully acknowledged.
  *
- * <h3>Attribute Organization</h3>
+ * <h2>Attribute Organization</h2>
  * There are five kinds of printing attributes: doc attributes, print request
  * attributes, print job attributes, print service attributes, and
  * supported-values attributes.
  *
- * <h4>Doc Attributes</h4>
+ * <h3>Doc Attributes</h3>
  * Doc attributes specify the characteristics of an individual doc and the print
  * job settings to be applied to an individual doc. A doc attribute class
  * implements interface <a href="../DocAttribute.html">DocAttribute</a>. A doc
  * attribute can appear in a <a href="../DocAttributeSet.html">
  * DocAttributeSet</a>.
  *
- * <h4>Print Request Attributes</h4>
+ * <h3>Print Request Attributes</h3>
  * Print request attributes specify the settings to be applied to a whole print
  * job and to all the docs in the print job. A print request attribute class
  * implements interface <a href="../PrintRequestAttribute.html">
@@ -114,7 +114,7 @@
  * the doc level overrides an attribute in the same category specified at the
  * Print Request level.
  *
- * <h4>Print Job Attributes</h4>
+ * <h3>Print Job Attributes</h3>
  * Print job attributes report the status of a Print Job. A print job attribute
  * class implements interface <a href="../PrintJobAttribute.html">
  * PrintJobAttribute</a>. A print job attribute can appear in a
@@ -127,14 +127,14 @@
  * attributes but not print request attributes; the print service itself adds
  * these attributes to the Print Job's attribute set.
  *
- * <h4>Print Service Attributes</h4>
+ * <h3>Print Service Attributes</h3>
  * Print service attributes report the status of a print service. A print
  * service attribute class implements interface
  * <a href="../PrintServiceAttribute.html">PrintServiceAttribute</a>. A print
  * service attribute can appear in a <a href="../PrintServiceAttributeSet.html">
  * PrintServiceAttributeSet</a>.
  *
- * <h4>Supported-Values Attributes</h4>
+ * <h3>Supported-Values Attributes</h3>
  * A supported-value attribute indicates the legal values for another attribute
  * that a print service supports. A supported-values attribute class implements
  * interface <a href="../SupportedValuesAttribute.html">
@@ -142,7 +142,7 @@
  * appear in attribute sets, so there is no restricted
  * <a href="../AttributeSet.html">AttributeSet</a> subinterface for them.
  *
- * <h4>Attribute Table</h4>
+ * <h3>Attribute Table</h3>
  * The table below lists all the printing attributes. The table shows the
  * tagging interfaces each attribute class implements in addition to interface
  * <a href="../Attribute.html"> Attribute</a>, thus indicating how each
--- a/src/java.desktop/share/classes/javax/print/package-info.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/print/package-info.java	Tue Apr 09 11:48:54 2019 +0100
@@ -34,7 +34,7 @@
  *   printed.
  * </ul>
  *
- * <h3>Print Service Discovery</h3>
+ * <h2>Print Service Discovery</h2>
  * An application invokes the static methods of the abstract class
  * {@link javax.print.PrintServiceLookup PrintServiceLookup} to locate print
  * services that have the capabilities to satisfy the application's print
@@ -48,7 +48,7 @@
  * dynamically install these {@code PrintServiceLookup} implementations using
  * the {@link java.util.ServiceLoader} facility.
  *
- * <h3>Attribute Definitions</h3>
+ * <h2>Attribute Definitions</h2>
  * The {@link javax.print.attribute} and {@link javax.print.attribute.standard}
  * packages define print attributes, which describe the capabilities of a print
  * service, specify the requirements of a print job, and track the progress of a
@@ -65,7 +65,7 @@
  * capabilities, such as: resolution, copies, media sizes, job priority, and
  * page ranges.
  *
- * <h3>Document Type Specification</h3>
+ * <h2>Document Type Specification</h2>
  * The {@link javax.print.DocFlavor DocFlavor} class represents the print data
  * format, such as JPEG or PostScript. A {@code DocFlavor} object consists of a
  * MIME type, which describes the format, and a document representation class
@@ -74,7 +74,7 @@
  * find printers that can print the document type specified by the
  * {@code DocFlavor} and have the capabilities specified by the attribute set.
  *
- * <h3>Using the API</h3>
+ * <h2>Using the API</h2>
  * A typical application using the Java Print Service API performs these steps
  * to process a print request:
  * <ol>
--- a/src/java.desktop/share/classes/javax/sound/sampled/Line.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/sound/sampled/Line.java	Tue Apr 09 11:48:54 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
@@ -324,20 +324,11 @@
          */
         @Override
         public String toString() {
-
-            String fullPackagePath = "javax.sound.sampled.";
-            String initialString = new String(getLineClass().toString());
-            String finalString;
-
-            int index = initialString.indexOf(fullPackagePath);
-
-            if (index != -1) {
-                finalString = initialString.substring(0, index) + initialString.substring( (index + fullPackagePath.length()), initialString.length() );
-            } else {
-                finalString = initialString;
+            final String str = getLineClass().toString();
+            if (getLineClass().getPackage() == Line.class.getPackage()) {
+                return str.replace("javax.sound.sampled.", "");
             }
-
-            return finalString;
+            return str;
         }
     }
 }
--- a/src/java.desktop/share/classes/javax/swing/Action.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/Action.java	Tue Apr 09 11:48:54 2019 +0100
@@ -69,7 +69,7 @@
  * are desired, and use simple <code>ActionListener</code>s elsewhere.
  * <br>
  *
- * <h3><a id="buttonActions"></a>Swing Components Supporting <code>Action</code></h3>
+ * <h2><a id="buttonActions"></a>Swing Components Supporting <code>Action</code></h2>
  * <p>
  * Many of Swing's components have an <code>Action</code> property.  When
  * an <code>Action</code> is set on a component, the following things
--- a/src/java.desktop/share/classes/javax/swing/GroupLayout.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/GroupLayout.java	Tue Apr 09 11:48:54 2019 +0100
@@ -2377,7 +2377,7 @@
      * {@code ParallelGroup} aligns its children in
      * four possible ways: along the baseline, centered, anchored to the
      * leading edge, or anchored to the trailing edge.
-     * <h3>Baseline</h3>
+     * <h2>Baseline</h2>
      * A {@code ParallelGroup} that aligns its children along the
      * baseline must first decide where the baseline is
      * anchored. The baseline can either be anchored to the top, or
@@ -2427,7 +2427,7 @@
      * ways: centered, anchored to the leading edge, or anchored to the
      * trailing edge.
      *
-     * <h3>Non-baseline {@code ParallelGroup}</h3>
+     * <h2>Non-baseline {@code ParallelGroup}</h2>
      * {@code ParallelGroup}s created with an alignment other than
      * {@code BASELINE} align elements that are smaller than the size
      * of the group in one of three ways: centered, anchored to the
--- a/src/java.desktop/share/classes/javax/swing/JTable.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/JTable.java	Tue Apr 09 11:48:54 2019 +0100
@@ -3050,9 +3050,9 @@
      *   of elements with a size, preferred size, maximum size and minimum size
      *   to have its elements manipulated by the algorithm.
      *
-     * <H3> Distributing the delta </H3>
-     *
-     * <H4> Overview </H4>
+     * <H4> Distributing the delta </H4>
+     *
+     * <H5> Overview </H5>
      * <P>
      * Call "DELTA" the difference between the target size and the
      * sum of the preferred sizes of the elements in r. The individual
@@ -3061,7 +3061,7 @@
      * how far each preferred size is from its limiting bound (minimum or
      * maximum).
      *
-     * <H4>Definition</H4>
+     * <H5>Definition</H5>
      * <P>
      * Call the individual constraints min[i], max[i], and pref[i].
      * <p>
@@ -3093,7 +3093,7 @@
      * k, towards the total minimum or maximum and that percentage guarantees
      * accommodation of the required space, DELTA.
      *
-     * <H4>Details</H4>
+     * <H5>Details</H5>
      * <P>
      * Naive evaluation of the formulae presented here would be subject to
      * the aggregated rounding errors caused by doing this operation in finite
@@ -3104,7 +3104,7 @@
      * <code>targetSize</code>, and does so by spreading the rounding
      * errors evenly over the given elements.
      *
-     * <H4>When the MAX and MIN bounds are hit</H4>
+     * <H5>When the MAX and MIN bounds are hit</H5>
      * <P>
      * When <code>targetSize</code> is outside the [MIN, MAX] range,
      * the algorithm sets all sizes to their appropriate limiting value
--- a/src/java.desktop/share/classes/javax/swing/SizeSequence.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/SizeSequence.java	Tue Apr 09 11:48:54 2019 +0100
@@ -76,7 +76,7 @@
  * could be just as valid.
  *
  *
- * <h3>Implementation Notes</h3>
+ * <h2>Implementation Notes</h2>
  *
  * Normally when storing the size and position of entries,
  * one would choose between
--- a/src/java.desktop/share/classes/javax/swing/SpringLayout.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/SpringLayout.java	Tue Apr 09 11:48:54 2019 +0100
@@ -128,9 +128,9 @@
  * the edges of components from different containers (either internal or
  * external) is undefined.
  *
- * <h3>
+ * <h2>
  * SpringLayout vs. Other Layout Managers
- * </h3>
+ * </h2>
  *
  * <blockquote>
  * <hr>
--- a/src/java.desktop/share/classes/javax/swing/UIManager.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/UIManager.java	Tue Apr 09 11:48:54 2019 +0100
@@ -70,7 +70,7 @@
  * are notified when the look and feel changes, look and feel defaults, and
  * convenience methods for obtaining various default values.
  *
- * <h3>Specifying the look and feel</h3>
+ * <h2>Specifying the look and feel</h2>
  *
  * The look and feel can be specified in two distinct ways: by
  * specifying the fully qualified name of the class for the look and
@@ -94,7 +94,7 @@
  * unspecified. It is very possible to receive unexpected exceptions,
  * painting problems, or worse.
  *
- * <h3>Default look and feel</h3>
+ * <h2>Default look and feel</h2>
  *
  * The class used for the default look and feel is chosen in the following
  * manner:
@@ -114,7 +114,7 @@
  *   <li>Otherwise use the cross platform look and feel.
  * </ol>
  *
- * <h3>Defaults</h3>
+ * <h2>Defaults</h2>
  *
  * {@code UIManager} manages three sets of {@code UIDefaults}. In order, they
  * are:
--- a/src/java.desktop/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java	Tue Apr 09 11:48:54 2019 +0100
@@ -42,7 +42,7 @@
  * All colors returned by {@code DefaultMetalTheme} are completely
  * opaque.
  *
- * <h3><a id="fontStyle"></a>Font Style</h3>
+ * <h2><a id="fontStyle"></a>Font Style</h2>
  *
  * {@code DefaultMetalTheme} uses bold fonts for many controls.  To make all
  * controls (with the exception of the internal frame title bars and
--- a/src/java.desktop/share/classes/javax/swing/text/Utilities.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/text/Utilities.java	Tue Apr 09 11:48:54 2019 +0100
@@ -657,7 +657,7 @@
     public static final int getBreakLocation(Segment s, FontMetrics metrics,
                                              float x0, float x, TabExpander e,
                                              int startOffset) {
-        return getBreakLocation(s, metrics, x0, x, e, startOffset, false);
+        return getBreakLocation(s, metrics, x0, x, e, startOffset, true);
     }
 
     /**
--- a/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Tue Apr 09 11:48:54 2019 +0100
@@ -360,7 +360,8 @@
         int currentWidth = getWidth();
         if (wordWrap) {
             p = p0 + Utilities.getBreakLocation(segment, metrics,
-                                                tabBase, tabBase + currentWidth,
+                                                (float)tabBase,
+                                                (float)(tabBase + currentWidth),
                                                 this, p0);
         } else {
             p = p0 + Utilities.getTabbedTextOffset(segment, metrics,
--- a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1275,10 +1275,12 @@
                printerResAttr = (PrinterResolution)
                    service.getDefaultAttributeValue(PrinterResolution.class);
             }
-            double xr =
-               printerResAttr.getCrossFeedResolution(ResolutionSyntax.DPI);
-            double yr = printerResAttr.getFeedResolution(ResolutionSyntax.DPI);
-            setXYRes(xr, yr);
+            if (printerResAttr != null) {
+                double xr =
+                        printerResAttr.getCrossFeedResolution(ResolutionSyntax.DPI);
+                double yr = printerResAttr.getFeedResolution(ResolutionSyntax.DPI);
+                setXYRes(xr, yr);
+            }
         }
 
         pageRangesAttr =  (PageRanges)attributes.get(PageRanges.class);
--- a/src/java.desktop/share/legal/giflib.md	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/legal/giflib.md	Tue Apr 09 11:48:54 2019 +0100
@@ -1,4 +1,4 @@
-## GIFLIB v5.1.4
+## GIFLIB v5.1.8
 
 ### GIFLIB License
 <pre>
--- a/src/java.desktop/share/native/common/awt/debug/debug_trace.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/common/awt/debug/debug_trace.c	Tue Apr 09 11:48:54 2019 +0100
@@ -25,7 +25,7 @@
 
 #include "debug_util.h"
 
-static void DTrace_PrintStdErr(const char *msg);
+static void JNICALL DTrace_PrintStdErr(const char *msg);
 
 #if defined(DEBUG)
 enum {
@@ -298,7 +298,7 @@
  * Support for Java tracing in release or debug mode builds
  */
 
-static void DTrace_PrintStdErr(const char *msg) {
+static void JNICALL DTrace_PrintStdErr(const char *msg) {
     fprintf(stderr, "%s", msg);
     fflush(stderr);
 }
--- a/src/java.desktop/share/native/common/awt/debug/debug_trace.h	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/common/awt/debug/debug_trace.h	Tue Apr 09 11:48:54 2019 +0100
@@ -45,10 +45,10 @@
 };
 
 /* prototype for client provided output callback function */
-typedef void (*DTRACE_OUTPUT_CALLBACK)(const char * msg);
+typedef void (JNICALL *DTRACE_OUTPUT_CALLBACK)(const char * msg);
 
 /* prototype for client provided print callback function */
-typedef void (*DTRACE_PRINT_CALLBACK)(const char * file, int line, int argc, const char * fmt, va_list arglist);
+typedef void (JNICALL *DTRACE_PRINT_CALLBACK)(const char * file, int line, int argc, const char * fmt, va_list arglist);
 
 extern void DTrace_EnableAll(dbool_t enabled);
 extern void DTrace_EnableFile(const char * file, dbool_t enabled);
--- a/src/java.desktop/share/native/libawt/awt/image/gif/gifdecoder.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libawt/awt/image/gif/gifdecoder.c	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -117,7 +117,7 @@
                                               jobject this,
                                               jint relx, jint rely,
                                               jint width, jint height,
-                                              jint interlace,
+                                              jboolean interlace,
                                               jint initCodeSize,
                                               jbyteArray blockh,
                                               jbyteArray raslineh,
--- a/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c	Tue Apr 09 11:48:54 2019 +0100
@@ -36,13 +36,16 @@
 #include <limits.h>
 #include <stdint.h>
 #include <fcntl.h>
+/** Begin JDK modifications to support building on Windows **/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+/** End JDK modifications to support building on Windows **/
 #include <stdio.h>
 #include <string.h>
 
 #ifdef _WIN32
 #include <io.h>
-#else
-#include <unistd.h>
 #endif /* _WIN32 */
 
 #include "gif_lib.h"
@@ -52,10 +55,14 @@
 #define UNSIGNED_LITTLE_ENDIAN(lo, hi) ((lo) | ((hi) << 8))
 
 /* avoid extra function call in case we use fread (TVT) */
-#define READ(_gif,_buf,_len)                                     \
-  (((GifFilePrivateType*)_gif->Private)->Read ?                   \
-    ((GifFilePrivateType*)_gif->Private)->Read(_gif,_buf,_len) : \
-    fread(_buf,1,_len,((GifFilePrivateType*)_gif->Private)->File))
+/** JDK modification "inline" is dropped to support c89 **/
+static /**inline**/ int InternalRead(GifFileType *gif, GifByteType *buf, int len) {
+    //fprintf(stderr, "### Read: %d\n", len);
+    return
+    (((GifFilePrivateType*)gif->Private)->Read ?
+     ((GifFilePrivateType*)gif->Private)->Read(gif,buf,len) :
+     fread(buf,1,len,((GifFilePrivateType*)gif->Private)->File));
+}
 
 static int DGifGetWord(GifFileType *GifFile, GifWord *Word);
 static int DGifSetupDecompress(GifFileType *GifFile);
@@ -142,7 +149,7 @@
 
     /* Let's see if this is a GIF file: */
     /* coverity[check_return] */
-    if (READ(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
+    if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
         if (Error != NULL)
             *Error = D_GIF_ERR_READ_FAILED;
         (void)fclose(f);
@@ -219,7 +226,7 @@
 
     /* Lets see if this is a GIF file: */
     /* coverity[check_return] */
-    if (READ(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
+    if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
         if (Error != NULL)
             *Error = D_GIF_ERR_READ_FAILED;
         free((char *)Private);
@@ -276,7 +283,7 @@
         DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR)
         return GIF_ERROR;
 
-    if (READ(GifFile, Buf, 3) != 3) {
+    if (InternalRead(GifFile, Buf, 3) != 3) {
         GifFile->Error = D_GIF_ERR_READ_FAILED;
         GifFreeMapObject(GifFile->SColorMap);
         GifFile->SColorMap = NULL;
@@ -300,7 +307,7 @@
         GifFile->SColorMap->SortFlag = SortFlag;
         for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
             /* coverity[check_return] */
-            if (READ(GifFile, Buf, 3) != 3) {
+            if (InternalRead(GifFile, Buf, 3) != 3) {
                 GifFreeMapObject(GifFile->SColorMap);
                 GifFile->SColorMap = NULL;
                 GifFile->Error = D_GIF_ERR_READ_FAILED;
@@ -314,9 +321,25 @@
         GifFile->SColorMap = NULL;
     }
 
+    /*
+     * No check here for whether the background color is in range for the
+     * screen color map.  Possibly there should be.
+     */
+
     return GIF_OK;
 }
 
+const char *
+DGifGetGifVersion(GifFileType *GifFile)
+{
+    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
+
+    if (Private->gif89)
+        return GIF89_STAMP;
+    else
+        return GIF87_STAMP;
+}
+
 /******************************************************************************
  This routine should be called before any attempt to read an image.
 ******************************************************************************/
@@ -333,11 +356,12 @@
     }
 
     /* coverity[check_return] */
-    if (READ(GifFile, &Buf, 1) != 1) {
+    if (InternalRead(GifFile, &Buf, 1) != 1) {
         GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
 
+    //fprintf(stderr, "### DGifGetRecordType: %02x\n", Buf);
     switch (Buf) {
       case DESCRIPTOR_INTRODUCER:
           *Type = IMAGE_DESC_RECORD_TYPE;
@@ -357,17 +381,12 @@
     return GIF_OK;
 }
 
-/******************************************************************************
- This routine should be called before any attempt to read an image.
- Note it is assumed the Image desc. header has been read.
-******************************************************************************/
 int
-DGifGetImageDesc(GifFileType *GifFile)
+DGifGetImageHeader(GifFileType *GifFile)
 {
     unsigned int BitsPerPixel;
     GifByteType Buf[3];
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
-    SavedImage *sp;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
@@ -380,7 +399,7 @@
         DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR ||
         DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR)
         return GIF_ERROR;
-    if (READ(GifFile, Buf, 1) != 1) {
+    if (InternalRead(GifFile, Buf, 1) != 1) {
         GifFile->Error = D_GIF_ERR_READ_FAILED;
         GifFreeMapObject(GifFile->Image.ColorMap);
         GifFile->Image.ColorMap = NULL;
@@ -407,7 +426,7 @@
         /* Get the image local color map: */
         for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
             /* coverity[check_return] */
-            if (READ(GifFile, Buf, 3) != 3) {
+            if (InternalRead(GifFile, Buf, 3) != 3) {
                 GifFreeMapObject(GifFile->Image.ColorMap);
                 GifFile->Error = D_GIF_ERR_READ_FAILED;
                 GifFile->Image.ColorMap = NULL;
@@ -419,6 +438,33 @@
         }
     }
 
+    Private->PixelCount = (long)GifFile->Image.Width *
+       (long)GifFile->Image.Height;
+
+    /* Reset decompress algorithm parameters. */
+    return DGifSetupDecompress(GifFile);
+}
+
+/******************************************************************************
+ This routine should be called before any attempt to read an image.
+ Note it is assumed the Image desc. header has been read.
+******************************************************************************/
+int
+DGifGetImageDesc(GifFileType *GifFile)
+{
+    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
+    SavedImage *sp;
+
+    if (!IS_READABLE(Private)) {
+        /* This file was NOT open for reading: */
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
+        return GIF_ERROR;
+    }
+
+    if (DGifGetImageHeader(GifFile) == GIF_ERROR) {
+        return GIF_ERROR;
+    }
+
     if (GifFile->SavedImages) {
         SavedImage* new_saved_images =
             (SavedImage *)reallocarray(GifFile->SavedImages,
@@ -453,11 +499,7 @@
 
     GifFile->ImageCount++;
 
-    Private->PixelCount = (long)GifFile->Image.Width *
-       (long)GifFile->Image.Height;
-
-    /* Reset decompress algorithm parameters. */
-    return DGifSetupDecompress(GifFile);
+    return GIF_OK;
 }
 
 /******************************************************************************
@@ -550,6 +592,7 @@
     GifByteType Buf;
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
+    //fprintf(stderr, "### -> DGifGetExtension:\n");
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
         GifFile->Error = D_GIF_ERR_NOT_READABLE;
@@ -557,11 +600,12 @@
     }
 
     /* coverity[check_return] */
-    if (READ(GifFile, &Buf, 1) != 1) {
+    if (InternalRead(GifFile, &Buf, 1) != 1) {
         GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
     *ExtCode = Buf;
+    //fprintf(stderr, "### <- DGifGetExtension: %02x, about to call next\n", Buf);
 
     return DGifGetExtensionNext(GifFile, Extension);
 }
@@ -577,20 +621,24 @@
     GifByteType Buf;
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
-    if (READ(GifFile, &Buf, 1) != 1) {
+    //fprintf(stderr, "### -> DGifGetExtensionNext\n");
+    if (InternalRead(GifFile, &Buf, 1) != 1) {
         GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
+    //fprintf(stderr, "### DGifGetExtensionNext sees %d\n", Buf);
+
     if (Buf > 0) {
         *Extension = Private->Buf;    /* Use private unused buffer. */
         (*Extension)[0] = Buf;  /* Pascal strings notation (pos. 0 is len.). */
         /* coverity[tainted_data,check_return] */
-        if (READ(GifFile, &((*Extension)[1]), Buf) != Buf) {
+        if (InternalRead(GifFile, &((*Extension)[1]), Buf) != Buf) {
             GifFile->Error = D_GIF_ERR_READ_FAILED;
             return GIF_ERROR;
         }
     } else
         *Extension = NULL;
+    //fprintf(stderr, "### <- DGifGetExtensionNext: %p\n", Extension);
 
     return GIF_OK;
 }
@@ -707,7 +755,7 @@
     unsigned char c[2];
 
     /* coverity[check_return] */
-    if (READ(GifFile, c, 2) != 2) {
+    if (InternalRead(GifFile, c, 2) != 2) {
         GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
@@ -752,7 +800,7 @@
 
     /* coverity[tainted_data_argument] */
     /* coverity[check_return] */
-    if (READ(GifFile, &Buf, 1) != 1) {
+    if (InternalRead(GifFile, &Buf, 1) != 1) {
         GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
@@ -762,7 +810,7 @@
         *CodeBlock = Private->Buf;    /* Use private unused buffer. */
         (*CodeBlock)[0] = Buf;  /* Pascal strings notation (pos. 0 is len.). */
         /* coverity[tainted_data] */
-        if (READ(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
+        if (InternalRead(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
             GifFile->Error = D_GIF_ERR_READ_FAILED;
             return GIF_ERROR;
         }
@@ -787,7 +835,7 @@
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
     /* coverity[check_return] */
-    if (READ(GifFile, &CodeSize, 1) < 1) {    /* Read Code size from file. */
+    if (InternalRead(GifFile, &CodeSize, 1) < 1) {    /* Read Code size from file. */
         return GIF_ERROR;    /* Failed to read Code size. */
     }
     BitsPerPixel = CodeSize;
@@ -921,7 +969,7 @@
                 while (StackPtr != 0 && i < LineLen)
                     Line[i++] = Stack[--StackPtr];
             }
-            if (LastCode != NO_SUCH_CODE && Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) {
+            if (LastCode != NO_SUCH_CODE && Private->RunningCode - 2 < LZ_MAX_CODE && Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) {
                 Prefix[Private->RunningCode - 2] = LastCode;
 
                 if (CrntCode == Private->RunningCode - 2) {
@@ -1069,7 +1117,7 @@
     if (Buf[0] == 0) {
         /* Needs to read the next buffer - this one is empty: */
         /* coverity[check_return] */
-        if (READ(GifFile, Buf, 1) != 1) {
+        if (InternalRead(GifFile, Buf, 1) != 1) {
             GifFile->Error = D_GIF_ERR_READ_FAILED;
             return GIF_ERROR;
         }
@@ -1081,7 +1129,7 @@
             GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
             return GIF_ERROR;
         }
-        if (READ(GifFile, &Buf[1], Buf[0]) != Buf[0]) {
+        if (InternalRead(GifFile, &Buf[1], Buf[0]) != Buf[0]) {
             GifFile->Error = D_GIF_ERR_READ_FAILED;
             return GIF_ERROR;
         }
@@ -1124,7 +1172,7 @@
 
               sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
               /* Allocate memory for the image */
-              if (sp->ImageDesc.Width < 0 && sp->ImageDesc.Height < 0 &&
+              if (sp->ImageDesc.Width <= 0 || sp->ImageDesc.Height <= 0 ||
                       sp->ImageDesc.Width > (INT_MAX / sp->ImageDesc.Height)) {
                   return GIF_ERROR;
               }
@@ -1184,9 +1232,11 @@
                       == GIF_ERROR)
                       return (GIF_ERROR);
               }
-              while (ExtData != NULL) {
+              for (;;) {
                   if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
                       return (GIF_ERROR);
+                  if (ExtData == NULL)
+                      break;
                   /* Continue the extension block */
                   if (ExtData != NULL)
                       if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_hash.h	Tue Apr 09 11:48:54 2019 +0100
@@ -31,6 +31,11 @@
 #ifndef _GIF_HASH_H_
 #define _GIF_HASH_H_
 
+/** Begin JDK modifications to support building on Windows **/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+/** End JDK modifications to support building on Windows **/
 #include <stdint.h>
 
 #define HT_SIZE         8192    /* 12bits = 4096 or twice as big! */
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h	Tue Apr 09 11:48:54 2019 +0100
@@ -37,19 +37,21 @@
 
 #define GIFLIB_MAJOR 5
 #define GIFLIB_MINOR 1
-#define GIFLIB_RELEASE 4
+#define GIFLIB_RELEASE 8
 
 #define GIF_ERROR   0
 #define GIF_OK      1
 
 #include <stddef.h>
-
+/** Begin JDK modifications to support building using old compilers**/
+//#include <stdbool.h>
 #ifdef bool
 #undef bool
 #endif
 typedef int bool;
 #define false 0
 #define true 1
+/** End JDK modifications to support building using old compilers**/
 
 #define GIF_STAMP "GIFVER"          /* First chars in file - GIF stamp.  */
 #define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1
@@ -88,7 +90,7 @@
 #define COMMENT_EXT_FUNC_CODE     0xfe    /* comment */
 #define GRAPHICS_EXT_FUNC_CODE    0xf9    /* graphics control (GIF89) */
 #define PLAINTEXT_EXT_FUNC_CODE   0x01    /* plaintext */
-#define APPLICATION_EXT_FUNC_CODE 0xff    /* application block */
+#define APPLICATION_EXT_FUNC_CODE 0xff    /* application block (GIF89) */
 } ExtensionBlock;
 
 typedef struct SavedImage {
@@ -230,10 +232,10 @@
 /* These are legacy.  You probably do not want to call them directly */
 int DGifGetScreenDesc(GifFileType *GifFile);
 int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
+int DGifGetImageHeader(GifFileType *GifFile);
 int DGifGetImageDesc(GifFileType *GifFile);
 int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
 int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
-int DGifGetComment(GifFileType *GifFile, char *GifComment);
 int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,
                      GifByteType **GifExtension);
 int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
@@ -241,6 +243,7 @@
                 GifByteType **GifCodeBlock);
 int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
 int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
+const char *DGifGetGifVersion(GifFileType *GifFile);
 
 
 /******************************************************************************
@@ -274,9 +277,6 @@
                                      GifPixelType ColorTransIn2[]);
 extern int GifBitSize(int n);
 
-extern void * reallocarray(void *optr, size_t nmemb, size_t size);
-
-
 /******************************************************************************
  Support for the in-core structures allocation (slurp mode).
 ******************************************************************************/
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib_private.h	Tue Apr 09 11:48:54 2019 +0100
@@ -34,6 +34,10 @@
 #include "gif_lib.h"
 #include "gif_hash.h"
 
+#ifndef SIZE_MAX
+    #define SIZE_MAX     UINTPTR_MAX
+#endif
+
 #define EXTENSION_INTRODUCER      0x21
 #define DESCRIPTOR_INTRODUCER     0x2c
 #define TERMINATOR_INTRODUCER     0x3b
@@ -78,6 +82,11 @@
     bool gif89;
 } GifFilePrivateType;
 
+#ifndef HAVE_REALLOCARRAY
+extern void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size);
+#define reallocarray openbsd_reallocarray
+#endif
+
 #endif /* _GIF_LIB_PRIVATE_H */
 
 /* end */
--- a/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c	Tue Apr 09 11:48:54 2019 +0100
@@ -33,6 +33,7 @@
 #include <string.h>
 
 #include "gif_lib.h"
+#include "gif_lib_private.h"
 
 #define MAX(x, y)    (((x) > (y)) ? (x) : (y))
 
@@ -348,15 +349,17 @@
 {
     if (GifFile->SavedImages == NULL)
         GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
-    else
-        GifFile->SavedImages = (SavedImage *)reallocarray(GifFile->SavedImages,
+    else {
+        SavedImage* newSavedImages = (SavedImage *)reallocarray(GifFile->SavedImages,
                                (GifFile->ImageCount + 1), sizeof(SavedImage));
-
+        if( newSavedImages == NULL)
+            return ((SavedImage *)NULL);
+        GifFile->SavedImages = newSavedImages;
+    }
     if (GifFile->SavedImages == NULL)
         return ((SavedImage *)NULL);
     else {
         SavedImage *sp = &GifFile->SavedImages[GifFile->ImageCount++];
-        memset((char *)sp, '\0', sizeof(SavedImage));
 
         if (CopyFrom != NULL) {
             memcpy((char *)sp, CopyFrom, sizeof(SavedImage));
@@ -368,7 +371,7 @@
              */
 
             /* first, the local color map */
-            if (sp->ImageDesc.ColorMap != NULL) {
+            if (CopyFrom->ImageDesc.ColorMap != NULL) {
                 sp->ImageDesc.ColorMap = GifMakeMapObject(
                                          CopyFrom->ImageDesc.ColorMap->ColorCount,
                                          CopyFrom->ImageDesc.ColorMap->Colors);
@@ -392,7 +395,7 @@
                    CopyFrom->ImageDesc.Width);
 
             /* finally, the extension blocks */
-            if (sp->ExtensionBlocks != NULL) {
+            if (CopyFrom->ExtensionBlocks != NULL) {
                 sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL,
                                       CopyFrom->ExtensionBlockCount,
                                       sizeof(ExtensionBlock));
@@ -404,6 +407,9 @@
                        sizeof(ExtensionBlock) * CopyFrom->ExtensionBlockCount);
             }
         }
+        else {
+            memset((char *)sp, '\0', sizeof(SavedImage));
+        }
 
         return (sp);
     }
--- a/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c	Tue Apr 09 11:48:54 2019 +0100
@@ -44,6 +44,10 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#ifndef SIZE_MAX
+    #define SIZE_MAX     UINTPTR_MAX
+#endif
+
 /*
  * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
  * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
@@ -51,7 +55,7 @@
 #define MUL_NO_OVERFLOW    ((size_t)1 << (sizeof(size_t) * 4))
 
 void *
-reallocarray(void *optr, size_t nmemb, size_t size)
+openbsd_reallocarray(void *optr, size_t nmemb, size_t size)
 {
     if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
         nmemb > 0 && SIZE_MAX / nmemb < size) {
--- a/src/java.desktop/share/native/libsplashscreen/splashscreen_impl.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libsplashscreen/splashscreen_impl.c	Tue Apr 09 11:48:54 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
@@ -46,7 +46,7 @@
     return &splash;
 }
 
-JNIEXPORT void JNICALL
+JNIEXPORT void
 SplashSetFileJarName(const char* fileName, const char* jarName) {
     Splash *splash = SplashGetInstance();
 
@@ -57,7 +57,7 @@
     splash->jarName = SplashConvertStringAlloc(jarName, &splash->jarNameLen);
 }
 
-JNIEXPORT void JNICALL
+JNIEXPORT void
 SplashInit()
 {
     Splash *splash = SplashGetInstance();
@@ -70,7 +70,7 @@
     SplashInitPlatform(splash);
 }
 
-JNIEXPORT void JNICALL
+JNIEXPORT void
 SplashClose()
 {
     Splash *splash = SplashGetInstance();
@@ -107,7 +107,7 @@
     SplashSetFileJarName(NULL, NULL);
 }
 
-JNIEXPORT void JNICALL
+JNIEXPORT void
 SplashSetScaleFactor(float scaleFactor)
 {
     Splash *splash = SplashGetInstance();
@@ -302,7 +302,7 @@
     return success;
 }
 
-JNIEXPORT int JNICALL
+JNIEXPORT int
 SplashLoadFile(const char *filename)
 {
     SplashStream stream;
@@ -310,7 +310,7 @@
                 SplashLoadStream(&stream);
 }
 
-JNIEXPORT int JNICALL
+JNIEXPORT int
 SplashLoadMemory(void *data, int size)
 {
     SplashStream stream;
@@ -395,7 +395,7 @@
     return 1;
 }
 
-JNIEXPORT int JNICALL
+JNIEXPORT int
 SplashGetScaledImgNameMaxPstfixLen(const char *fileName){
     return strlen(fileName) + strlen("@100pct") + 1;
 }
--- a/src/java.desktop/share/native/libsplashscreen/splashscreen_impl.h	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/share/native/libsplashscreen/splashscreen_impl.h	Tue Apr 09 11:48:54 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
@@ -30,29 +30,29 @@
 #include "splashscreen_gfx.h"
 #include "jni.h"
 
-JNIEXPORT int JNICALL
+JNIEXPORT int
 SplashLoadMemory(void *pdata, int size); /* requires preloading the file */
 
-JNIEXPORT int JNICALL
+JNIEXPORT int
 SplashLoadFile(const char *filename);  // FIXME: range checking for SplashLoadMemory
 
-JNIEXPORT void JNICALL
+JNIEXPORT void
 SplashInit(void);
 
-JNIEXPORT void JNICALL
+JNIEXPORT void
 SplashClose(void);
 
-JNIEXPORT void JNICALL
+JNIEXPORT void
 SplashSetScaleFactor(float);
 
-JNIEXPORT jboolean JNICALL
+JNIEXPORT jboolean
 SplashGetScaledImageName(const char*, const char*,
                               float*, char*, const size_t scaledImageNameLength);
 
-JNIEXPORT void JNICALL
+JNIEXPORT void
 SplashSetFileJarName(const char* fileName, const char* jarName);
 
-JNIEXPORT int JNICALL
+JNIEXPORT int
 SplashGetScaledImgNameMaxPstfixLen(const char*);
 typedef struct SplashImage
 {
--- a/src/java.desktop/unix/classes/sun/awt/X11/XAWTLookAndFeel.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XAWTLookAndFeel.java	Tue Apr 09 11:48:54 2019 +0100
@@ -38,7 +38,7 @@
 import com.sun.java.swing.plaf.motif.*;
 import sun.awt.X11.XComponentPeer;
 
-@SuppressWarnings("serial") // JDK-implementation class
+@SuppressWarnings({"serial", "removal"}) // JDK-implementation class
 class XAWTLookAndFeel extends MotifLookAndFeel {
 
     /**
--- a/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java	Tue Apr 09 11:48:54 2019 +0100
@@ -69,12 +69,6 @@
         this.scale = initScaleFactor();
     }
 
-    /*
-     * Initialize JNI field and method IDs for fields that may be
-     * accessed from C.
-     */
-    private static native void initIDs();
-
     /**
      * Returns the X11 screen of the device.
      */
--- a/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c	Tue Apr 09 11:48:54 2019 +0100
@@ -54,11 +54,6 @@
 #include <dlfcn.h>
 #include "Trace.h"
 
-#ifdef NETSCAPE
-#include <signal.h>
-extern int awt_init_xt;
-#endif
-
 #ifndef HEADLESS
 
 int awt_numScreens;     /* Xinerama-aware number of screens */
@@ -151,13 +146,6 @@
     CHECK_NULL(x11GraphicsConfigIDs.aData);
     x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I");
     CHECK_NULL(x11GraphicsConfigIDs.bitsPerPixel);
-
-    if (x11GraphicsConfigIDs.aData == NULL ||
-            x11GraphicsConfigIDs.bitsPerPixel == NULL) {
-
-            JNU_ThrowNoSuchFieldError(env, "Can't find a field");
-            return;
-        }
 }
 
 #ifndef HEADLESS
@@ -727,26 +715,11 @@
     Display *dpy;
     char errmsg[128];
     int i;
-#ifdef NETSCAPE
-    sigset_t alarm_set, oldset;
-#endif
 
     if (awt_display) {
         return awt_display;
     }
 
-#ifdef NETSCAPE
-    /* Disable interrupts during XtOpenDisplay to avoid bugs in unix os select
-       code: some unix systems don't implement SA_RESTART properly and
-       because of this, select returns with EINTR. Most implementations of
-       gethostbyname don't cope with EINTR properly and as a result we get
-       stuck (forever) in the gethostbyname code
-    */
-    sigemptyset(&alarm_set);
-    sigaddset(&alarm_set, SIGALRM);
-    sigprocmask(SIG_BLOCK, &alarm_set, &oldset);
-#endif
-
     /* Load AWT lock-related methods in SunToolkit */
     klass = (*env)->FindClass(env, "sun/awt/SunToolkit");
     if (klass == NULL) return NULL;
@@ -766,9 +739,6 @@
     }
 
     dpy = awt_display = XOpenDisplay(NULL);
-#ifdef NETSCAPE
-    sigprocmask(SIG_SETMASK, &oldset, NULL);
-#endif
     if (!dpy) {
         jio_snprintf(errmsg,
                      sizeof(errmsg),
--- a/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c	Tue Apr 09 11:48:54 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
@@ -801,7 +801,7 @@
     sendctl(splash, SPLASHCTL_RECONFIGURE);
 }
 
-JNIEXPORT jboolean JNICALL
+JNIEXPORT jboolean
 SplashGetScaledImageName(const char* jarName, const char* fileName,
                            float *scaleFactor, char *scaledImgName,
                            const size_t scaledImageNameLength)
--- a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java	Tue Apr 09 11:48:54 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
@@ -25,14 +25,8 @@
 
 package sun.print;
 
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
+import java.security.AccessController;
 import java.util.ArrayList;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
 import javax.print.DocFlavor;
 import javax.print.MultiDocPrintService;
 import javax.print.PrintService;
@@ -81,8 +75,9 @@
 
         if (refreshTimeStr != null) {
             try {
-                minRefreshTime = (Integer.valueOf(refreshTimeStr)).intValue();
+                minRefreshTime = Integer.parseInt(refreshTimeStr);
             } catch (NumberFormatException e) {
+                // ignore
             }
             if (minRefreshTime < DEFAULT_MINREFRESH) {
                 minRefreshTime = DEFAULT_MINREFRESH;
@@ -139,7 +134,7 @@
             if (pollServices) {
                 // start the remote printer listener thread
                 Thread remThr = new Thread(null, new RemotePrinterChangeListener(),
-                                        "RemotePrinterListener", 0, false);
+                                           "RemotePrinterListener", 0, false);
                 remThr.setDaemon(true);
                 remThr.start();
             }
@@ -358,6 +353,7 @@
         }
         return defaultPrintService;
     }
+
     class PrinterChangeListener implements Runnable {
         long chgObj;
         PrinterChangeListener() {
@@ -387,10 +383,10 @@
     /* Windows provides *PrinterChangeNotification* functions that provides
        information about printer status changes of the local printers but not
        network printers.
-       Alternatively, Windows provides a way thro' which one can get the
+       Alternatively, Windows provides a way through which one can get the
        network printer status changes by using WMI, RegistryKeyChange combination,
        which is a slightly complex mechanism.
-       The Windows WMI offers an async and sync method to read thro' registry
+       The Windows WMI offers an async and sync method to read through registry
        via the WQL query. The async method is considered dangerous as it leaves
        open a channel until we close it. But the async method has the advantage of
        being notified of a change in registry by calling callback without polling for it.
@@ -398,18 +394,17 @@
        RegistryValueChange cannot be used in combination with WMI to get registry
        value change notification because of an error that may be generated because the
        scope of the query would be too big to handle(at times).
-       Hence an alternative mechanism is choosen via the EnumPrinters by polling for the
+       Hence an alternative mechanism is chosen via the EnumPrinters by polling for the
        count of printer status changes(add\remove) and based on it update the printers
        list.
     */
     class RemotePrinterChangeListener implements Runnable {
-        private String[] prevRemotePrinters = null;
+        private String[] prevRemotePrinters;
 
         RemotePrinterChangeListener() {
-            prevRemotePrinters = getRemotePrintersNames();
         }
 
-        boolean doCompare(String[] str1, String[] str2) {
+        private boolean doCompare(String[] str1, String[] str2) {
             if (str1 == null && str2 == null) {
                 return false;
             } else if (str1 == null || str2 == null) {
@@ -419,8 +414,8 @@
             if (str1.length != str2.length) {
                 return true;
             } else {
-                for (int i = 0;i < str1.length;i++) {
-                    for (int j = 0;j < str2.length;j++) {
+                for (int i = 0; i < str1.length; i++) {
+                    for (int j = 0; j < str2.length; j++) {
                         // skip if both are nulls
                         if (str1[i] == null && str2[j] == null) {
                             continue;
@@ -445,27 +440,26 @@
 
         @Override
         public void run() {
-            while (true) {
-                if (prevRemotePrinters != null && prevRemotePrinters.length > 0) {
-                    String[] currentRemotePrinters = getRemotePrintersNames();
-                    if (doCompare(prevRemotePrinters, currentRemotePrinters)) {
+            // Init the list of remote printers
+            prevRemotePrinters = getRemotePrintersNames();
 
-                        // updated the printers data
-                        // printers list now contains both local and network printer data
-                        refreshServices();
-
-                        // store the current data for next comparison
-                        prevRemotePrinters = currentRemotePrinters;
-                    }
-                } else {
-                    prevRemotePrinters = getRemotePrintersNames();
-                }
-
+            while (true) {
                 try {
                     Thread.sleep(minRefreshTime * 1000);
                 } catch (InterruptedException e) {
                     break;
                 }
+
+                String[] currentRemotePrinters = getRemotePrintersNames();
+                if (doCompare(prevRemotePrinters, currentRemotePrinters)) {
+                    // The list of remote printers got updated,
+                    // so update the cached list printers which
+                    // includes both local and network printers
+                    refreshServices();
+
+                    // store the current data for next comparison
+                    prevRemotePrinters = currentRemotePrinters;
+                }
             }
         }
     }
--- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp	Tue Apr 09 11:48:54 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
@@ -118,10 +118,7 @@
 }
 
 
-JNIEXPORT jobjectArray JNICALL
-Java_sun_print_PrintServiceLookupProvider_getAllPrinterNames(JNIEnv *env,
-                                                          jobject peer)
-{
+static jobjectArray getPrinterNames(JNIEnv *env, DWORD flags) {
     TRY;
 
     DWORD cbNeeded = 0;
@@ -136,10 +133,10 @@
     jobjectArray nameArray;
 
     try {
-        ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
+        ::EnumPrinters(flags,
                        NULL, 4, NULL, 0, &cbNeeded, &cReturned);
         pPrinterEnum = new BYTE[cbNeeded];
-        ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
+        ::EnumPrinters(flags,
                        NULL, 4, pPrinterEnum, cbNeeded, &cbNeeded,
                        &cReturned);
 
@@ -174,6 +171,20 @@
     CATCH_BAD_ALLOC_RET(NULL);
 }
 
+JNIEXPORT jobjectArray JNICALL
+Java_sun_print_PrintServiceLookupProvider_getAllPrinterNames(JNIEnv *env,
+                                                             jobject peer)
+{
+    return getPrinterNames(env, PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS);
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_sun_print_PrintServiceLookupProvider_getRemotePrintersNames(JNIEnv *env,
+                                                                 jobject peer)
+{
+    return getPrinterNames(env, PRINTER_ENUM_CONNECTIONS);
+}
+
 
 JNIEXPORT jlong JNICALL
 Java_sun_print_PrintServiceLookupProvider_notifyFirstPrinterChange(JNIEnv *env,
@@ -232,82 +243,6 @@
     }
 }
 
-JNIEXPORT jobjectArray JNICALL
-Java_sun_print_PrintServiceLookupProvider_getRemotePrintersNames(JNIEnv *env,
-                                                           jobject peer)
-{
-    TRY;
-
-    int remotePrintersCount = 0;
-    DWORD cbNeeded = 0;
-    DWORD cReturned = 0;
-    LPBYTE pPrinterEnum = NULL;
-    LPBYTE pNetworkPrinterLoc = NULL;
-
-    jstring utf_str;
-    jclass clazz = env->FindClass("java/lang/String");
-    if (clazz == NULL) {
-        return NULL;
-    }
-    jobjectArray nameArray = NULL;
-
-    try {
-        ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
-                       NULL, 4, NULL, 0, &cbNeeded, &cReturned);
-        pPrinterEnum = new BYTE[cbNeeded];
-        pNetworkPrinterLoc = new BYTE[cbNeeded/sizeof(PRINTER_INFO_4)];
-        ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
-                       NULL, 4, pPrinterEnum, cbNeeded, &cbNeeded,
-                       &cReturned);
-
-        if (cReturned > 0) {
-            for (DWORD i = 0; i < cReturned; i++) {
-                PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *) (pPrinterEnum + i * sizeof(PRINTER_INFO_4));
-
-                // Store the network printers indexes
-                if (info4->Attributes & PRINTER_ATTRIBUTE_NETWORK) {
-                    pNetworkPrinterLoc[remotePrintersCount++] = i;
-                }
-            }
-
-            // return remote printers only if the list contains it.
-            if (remotePrintersCount > 0) {
-                // Allocate space only for the network type printers
-                nameArray = env->NewObjectArray(remotePrintersCount, clazz, NULL);
-                if (nameArray == NULL) {
-                    throw std::bad_alloc();
-                }
-            }
-        }
-
-        // Loop thro' network printers list only
-        for (int i = 0; i < remotePrintersCount; i++) {
-            PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *)
-                (pPrinterEnum + pNetworkPrinterLoc[i] * sizeof(PRINTER_INFO_4));
-            utf_str = JNU_NewStringPlatform(env, info4->pPrinterName);
-            if (utf_str == NULL) {
-                throw std::bad_alloc();
-            }
-            env->SetObjectArrayElement(nameArray, i, utf_str);
-            env->DeleteLocalRef(utf_str);
-        }
-    } catch (std::bad_alloc&) {
-        delete [] pPrinterEnum;
-        delete [] pNetworkPrinterLoc;
-        throw;
-    }
-
-    delete [] pPrinterEnum;
-    delete [] pNetworkPrinterLoc;
-
-    if (nameArray != NULL) {
-      return nameArray;
-    } else {
-      return env->NewObjectArray(0, clazz, NULL);
-    }
-
-    CATCH_BAD_ALLOC_RET(NULL);
-}
 
 JNIEXPORT jfloatArray JNICALL
 Java_sun_print_Win32PrintService_getMediaPrintableArea(JNIEnv *env,
--- a/src/java.desktop/windows/native/libsplashscreen/splashscreen_sys.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.desktop/windows/native/libsplashscreen/splashscreen_sys.c	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, 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
@@ -574,7 +574,7 @@
     PostMessage(splash->hWnd, WM_SPLASHRECONFIGURE, 0, 0);
 }
 
-JNIEXPORT jboolean JNICALL
+JNIEXPORT jboolean
 SplashGetScaledImageName(const char* jarName, const char* fileName,
                            float *scaleFactor, char *scaleImageName,
                            const size_t scaledImageLength)
--- a/src/java.instrument/unix/native/libinstrument/FileSystemSupport_md.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.instrument/unix/native/libinstrument/FileSystemSupport_md.c	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
--- a/src/java.instrument/windows/native/libinstrument/FileSystemSupport_md.c	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.instrument/windows/native/libinstrument/FileSystemSupport_md.c	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
--- a/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java	Tue Apr 09 11:48:54 2019 +0100
@@ -317,14 +317,13 @@
     void closeOrReturnToCache(HttpHeaders hdrs) {
         if (hdrs == null) {
             // the connection was closed by server, eof
+            Log.logTrace("Cannot return connection to pool: closing {0}", this);
             close();
             return;
         }
-        if (!isOpen()) {
-            return;
-        }
         HttpClientImpl client = client();
         if (client == null) {
+            Log.logTrace("Client released: closing {0}", this);
             close();
             return;
         }
@@ -333,10 +332,12 @@
                 .map((s) -> !s.equalsIgnoreCase("close"))
                 .orElse(true);
 
-        if (keepAlive) {
+        if (keepAlive && isOpen()) {
             Log.logTrace("Returning connection to the pool: {0}", this);
             pool.returnToPool(this);
         } else {
+            Log.logTrace("Closing connection (keepAlive={0}, isOpen={1}): {2}",
+                    keepAlive, isOpen(), this);
             close();
         }
     }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java	Tue Apr 09 11:48:54 2019 +0100
@@ -31,7 +31,7 @@
  * This engine does not conform to the POSIX regular expression.
  *
  * <hr width="50%">
- * <h3>How to use</h3>
+ * <h2>How to use</h2>
  *
  * <dl>
  *   <dt>A. Standard way
--- a/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java	Tue Apr 09 11:48:54 2019 +0100
@@ -164,7 +164,7 @@
  * set the property {@code javax.xml.catalog.defer} to false to allow the entire
  * catalog to be pre-loaded.
  *
- * <h3>Scope and Order</h3>
+ * <h2>Scope and Order</h2>
  * Features and properties can be set through the catalog file, the Catalog API,
  * system properties, and {@code jaxp.properties}, with a preference in the same order.
  * <p>
@@ -202,7 +202,7 @@
                         .build();
  * }</pre>
  *
- * <h3>JAXP XML Processor Support</h3>
+ * <h2>JAXP XML Processor Support</h2>
  * The Catalog Features are supported throughout the JAXP processors, including
  * SAX and DOM ({@link javax.xml.parsers}), and StAX parsers ({@link javax.xml.stream}),
  * Schema Validation ({@link javax.xml.validation}), and XML Transformation
@@ -246,7 +246,7 @@
  * The Catalog support is available for any process in the JAXP library that
  * supports a resolver. The following table lists all such processes.
  *
- * <h3><a id="ProcessesWithCatalogSupport">Processes with Catalog Support</a></h3>
+ * <h2><a id="ProcessesWithCatalogSupport">Processes with Catalog Support</a></h2>
  *
  * <table class="striped">
  * <caption>Processes with Catalog Support</caption>
--- a/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java	Tue Apr 09 11:48:54 2019 +0100
@@ -54,7 +54,7 @@
  * no further attempt will be made. Only if there is no match in the current
  * catalog, will alternate catalogs including delegate and next catalogs be considered.
  *
- * <h3>Search Order</h3>
+ * <h2>Search Order</h2>
  * The resolver will first search the system-type of entries with the specified
  * {@code systemId}. The system entries include {@code system},
  * {@code rewriteSystem} and {@code systemSuffix} entries.
@@ -75,7 +75,7 @@
  * with the specified {@code systemId} or {@code href}. The {@code uri} entries
  * include {@code uri}, {@code rewriteURI}, and {@code uriSuffix} entries.
  *
- * <h3>Error Handling</h3>
+ * <h2>Error Handling</h2>
  * The interfaces that the CatalogResolver extend specified checked exceptions, including:
  * <ul>
  * <li>
--- a/src/java.xml/share/classes/javax/xml/datatype/DatatypeFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/javax/xml/datatype/DatatypeFactory.java	Tue Apr 09 11:48:54 2019 +0100
@@ -183,7 +183,7 @@
      * it can use the factory to configure and obtain datatype instances.
      *
      *
-     * <h2>Tip for Trouble-shooting</h2>
+     * <h4>Tip for Trouble-shooting</h4>
      * <p>Setting the {@code jaxp.debug} system property will cause
      * this method to print a lot of debug messages
      * to {@code System.err} about what it is doing and where it is looking at.
--- a/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilderFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilderFactory.java	Tue Apr 09 11:48:54 2019 +0100
@@ -118,7 +118,7 @@
      * configure and obtain parser instances.
      *
      *
-     * <h2>Tip for Trouble-shooting</h2>
+     * <h4>Tip for Trouble-shooting</h4>
      * <p>
      * Setting the {@code jaxp.debug} system property will cause
      * this method to print a lot of debug messages
@@ -154,7 +154,7 @@
      * it can use the factory to configure and obtain parser instances.
      *
      *
-     * <h2>Tip for Trouble-shooting</h2>
+     * <h4>Tip for Trouble-shooting</h4>
      * <p>Setting the {@code jaxp.debug} system property will cause
      * this method to print a lot of debug messages
      * to {@code System.err} about what it is doing and where it is looking at.
@@ -549,7 +549,7 @@
      * exception when the {@link #newDocumentBuilder()} is invoked.
      *
      *
-     * <h3>Note for implementors</h3>
+     * <h4>Note for implementors</h4>
      *
      * <p>
      * A parser must be able to work with any {@link Schema}
--- a/src/java.xml/share/classes/javax/xml/parsers/SAXParserFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/javax/xml/parsers/SAXParserFactory.java	Tue Apr 09 11:48:54 2019 +0100
@@ -123,7 +123,7 @@
      *
      *
      *
-     * <h2>Tip for Trouble-shooting</h2>
+     * <h4>Tip for Trouble-shooting</h4>
      * <p>
      * Setting the {@code jaxp.debug} system property will cause
      * this method to print a lot of debug messages
@@ -161,7 +161,7 @@
      * it can use the factory to configure and obtain parser instances.
      *
      *
-     * <h2>Tip for Trouble-shooting</h2>
+     * <h4>Tip for Trouble-shooting</h4>
      * <p>Setting the {@code jaxp.debug} system property will cause
      * this method to print a lot of debug messages
      * to {@code System.err} about what it is doing and where it is looking at.
@@ -389,7 +389,7 @@
      * Such configuration will cause a {@link SAXException}
      * exception when those properties are set on a {@link SAXParser}.
      *
-     * <h3>Note for implementors</h3>
+     * <h4>Note for implementors</h4>
      * <p>
      * A parser must be able to work with any {@link Schema}
      * implementation. However, parsers and schemas are allowed
--- a/src/java.xml/share/classes/javax/xml/transform/TransformerFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/javax/xml/transform/TransformerFactory.java	Tue Apr 09 11:48:54 2019 +0100
@@ -140,7 +140,7 @@
      * {@code TransformerFactory} it can use the factory to configure
      * and obtain transformer instances.
      *
-     * <h2>Tip for Trouble-shooting</h2>
+     * <h4>Tip for Trouble-shooting</h4>
      * <p>Setting the {@code jaxp.debug} system property will cause
      * this method to print a lot of debug messages
      * to {@code System.err} about what it is doing and where it is looking at.
--- a/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java	Tue Apr 09 11:48:54 2019 +0100
@@ -206,7 +206,7 @@
      *
      * <p>If everything fails, {@link IllegalArgumentException} will be thrown.
      *
-     * <p><strong>Tip for Trouble-shooting:</strong>
+     * <h4>Tip for Trouble-shooting:</h4>
      * <p>See {@link java.util.Properties#load(java.io.InputStream)} for
      * exactly how a property file is parsed. In particular, colons ':'
      * need to be escaped in a property file, so make sure schema language
@@ -259,7 +259,7 @@
      * It gives more control to the application as it can specify which provider
      * should be loaded.
      *
-     * <h2>Tip for Trouble-shooting</h2>
+     * <h4>Tip for Trouble-shooting</h4>
      * <p>Setting the {@code jaxp.debug} system property will cause
      * this method to print a lot of debug messages
      * to {@code System.err} about what it is doing and where it is looking at.
@@ -717,7 +717,7 @@
      * to abort the further processing by throwing it. If an error handler is not set,
      * the callee will throw the first error it finds in the sources.
      *
-     * <h2>W3C XML Schema 1.0</h2>
+     * <h4>W3C XML Schema 1.0</h4>
      * <p>
      * The resulting schema contains components from the specified sources.
      * The same result would be achieved if all these sources were
@@ -737,7 +737,7 @@
      * specified in the section 5.1 of the XML Schema spec, then
      * the error must be reported to the {@link ErrorHandler}.
      *
-     * <h2>RELAX NG</h2>
+     * <h4>RELAX NG</h4>
      *
      * <p>For RELAX NG, this method must throw {@link UnsupportedOperationException}
      * if {@code schemas.length!=1}.
@@ -797,7 +797,7 @@
      * make sure that features, such as secure processing, are explicitly
      * set in both places.
      *
-     * <h2>W3C XML Schema 1.0</h2>
+     * <h4>W3C XML Schema 1.0</h4>
      * <p>
      * For XML Schema, this method creates a {@link Schema} object that
      * performs validation by using location hints specified in documents.
@@ -815,7 +815,7 @@
      * vulnerability to denial-of-service attacks.
      *
      *
-     * <h2>RELAX NG</h2>
+     * <h4>RELAX NG</h4>
      * <p>
      * RELAX NG does not support this operation.
      *
--- a/src/java.xml/share/classes/javax/xml/xpath/XPathFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/java.xml/share/classes/javax/xml/xpath/XPathFactory.java	Tue Apr 09 11:48:54 2019 +0100
@@ -239,7 +239,7 @@
      * should be loaded.</p>
      *
      *
-     * <h2>Tip for Trouble-shooting</h2>
+     * <h4>Tip for Trouble-shooting</h4>
      * <p>Setting the <code>jaxp.debug</code> system property will cause
      * this method to print a lot of debug messages
      * to <code>System.err</code> about what it is doing and where it is looking at.</p>
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataPatchProcessor.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataPatchProcessor.java	Tue Apr 09 11:48:54 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
@@ -47,6 +47,7 @@
 import jdk.vm.ci.hotspot.HotSpotObjectConstant;
 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
 import jdk.vm.ci.hotspot.HotSpotSentinelConstant;
+import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.VMConstant;
 
 final class DataPatchProcessor {
@@ -95,21 +96,24 @@
                 gotName = "got." + targetSymbol;
                 binaryContainer.addCountersSymbol(targetSymbol);
             }
-        } else if (constant instanceof HotSpotObjectConstant) {
-            HotSpotObjectConstant oopConstant = (HotSpotObjectConstant) constant;
-            if (oopConstant instanceof HotSpotConstantPoolObject) {
-                HotSpotConstantPoolObject cpo = (HotSpotConstantPoolObject) oopConstant;
+        } else if (constant instanceof JavaConstant) {
+            JavaConstant jConstant = (JavaConstant) constant;
+            if (jConstant instanceof HotSpotConstantPoolObject) {
+                HotSpotConstantPoolObject cpo = (HotSpotConstantPoolObject) jConstant;
                 // Even if two locations use the same object, resolve separately
-                targetSymbol = "ldc." + cpo.getCpType().getName() + cpo.getCpi();
-            } else {
+                targetSymbol = "ldc." + cpo.toValueString();
+                Integer offset = binaryContainer.addOopSymbol(targetSymbol);
+                gotName = "got.ldc." + offset;
+            } else if (jConstant instanceof HotSpotObjectConstant) {
+                HotSpotObjectConstant oopConstant = (HotSpotObjectConstant) jConstant;
                 // String constant.
                 targetSymbol = "ldc." + oopConstant.toValueString();
+                Integer offset = binaryContainer.addOopSymbol(targetSymbol);
+                gotName = "got.ldc." + offset;
+            } else if (jConstant instanceof HotSpotSentinelConstant) {
+                targetSymbol = "state.M" + methodInfo.getCodeId();
+                gotName = "got." + targetSymbol;
             }
-            Integer offset = binaryContainer.addOopSymbol(targetSymbol);
-            gotName = "got.ldc." + offset;
-        } else if (constant instanceof HotSpotSentinelConstant) {
-            targetSymbol = "state.M" + methodInfo.getCodeId();
-            gotName = "got." + targetSymbol;
         }
 
         assert gotName != null : "Unknown constant type: " + constant;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Tue Apr 09 11:48:54 2019 +0100
@@ -33,6 +33,7 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Set;
+import java.util.function.Supplier;
 
 import javax.lang.model.SourceVersion;
 import javax.tools.JavaFileManager;
@@ -222,7 +223,7 @@
         jrtIndex = useCtProps && JRTIndex.isAvailable() ? JRTIndex.getSharedInstance() : null;
 
         profile = Profile.instance(context);
-        cachedCompletionFailure = new CompletionFailure(null, (JCDiagnostic) null, dcfh);
+        cachedCompletionFailure = new CompletionFailure(null, () -> null, dcfh);
         cachedCompletionFailure.setStackTrace(new StackTraceElement[0]);
     }
 
@@ -298,9 +299,12 @@
             try {
                 fillIn(p);
             } catch (IOException ex) {
-                JCDiagnostic msg =
-                        diagFactory.fragment(Fragments.ExceptionMessage(ex.getLocalizedMessage()));
-                throw new CompletionFailure(sym, msg, dcfh).initCause(ex);
+                throw new CompletionFailure(
+                        sym,
+                        () -> diagFactory.fragment(
+                            Fragments.ExceptionMessage(ex.getLocalizedMessage())),
+                        dcfh)
+                    .initCause(ex);
             }
         }
         if (!reader.filling)
@@ -337,9 +341,8 @@
      */
     void fillIn(ClassSymbol c) {
         if (completionFailureName == c.fullname) {
-            JCDiagnostic msg =
-                    diagFactory.fragment(Fragments.UserSelectedCompletionFailure);
-            throw new CompletionFailure(c, msg, dcfh);
+            throw new CompletionFailure(
+                c, () -> diagFactory.fragment(Fragments.UserSelectedCompletionFailure), dcfh);
         }
         currentOwner = c;
         JavaFileObject classfile = c.classfile;
@@ -390,16 +393,15 @@
     }
     // where
         private CompletionFailure classFileNotFound(ClassSymbol c) {
-            JCDiagnostic diag =
-                diagFactory.fragment(Fragments.ClassFileNotFound(c.flatname));
-            return newCompletionFailure(c, diag);
+            return newCompletionFailure(
+                c, () -> diagFactory.fragment(Fragments.ClassFileNotFound(c.flatname)));
         }
         /** Static factory for CompletionFailure objects.
          *  In practice, only one can be used at a time, so we share one
          *  to reduce the expense of allocating new exception objects.
          */
         private CompletionFailure newCompletionFailure(TypeSymbol c,
-                                                       JCDiagnostic diag) {
+                                                       Supplier<JCDiagnostic> diag) {
             if (!cacheCompletionFailure) {
                 // log.warning("proc.messager",
                 //             Log.getLocalizedString("class.file.not.found", c.flatname));
@@ -408,7 +410,7 @@
             } else {
                 CompletionFailure result = cachedCompletionFailure;
                 result.sym = c;
-                result.diag = diag;
+                result.resetDiagnostic(diag);
                 return result;
             }
         }
@@ -782,7 +784,7 @@
 
         public BadClassFile(TypeSymbol sym, JavaFileObject file, JCDiagnostic diag,
                 JCDiagnostic.Factory diagFactory, DeferredCompletionFailureHandler dcfh) {
-            super(sym, createBadClassFileDiagnostic(file, diag, diagFactory), dcfh);
+            super(sym, () -> createBadClassFileDiagnostic(file, diag, diagFactory), dcfh);
         }
         // where
         private static JCDiagnostic createBadClassFileDiagnostic(
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Apr 09 11:48:54 2019 +0100
@@ -32,6 +32,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
+import java.util.function.Supplier;
 
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -2131,26 +2132,31 @@
 
         /** A diagnostic object describing the failure
          */
-        public JCDiagnostic diag;
+        private JCDiagnostic diag;
 
-        public CompletionFailure(Symbol sym, JCDiagnostic diag, DeferredCompletionFailureHandler dcfh) {
+        private Supplier<JCDiagnostic> diagSupplier;
+
+        public CompletionFailure(Symbol sym, Supplier<JCDiagnostic> diagSupplier, DeferredCompletionFailureHandler dcfh) {
             this.dcfh = dcfh;
             this.sym = sym;
-            this.diag = diag;
+            this.diagSupplier = diagSupplier;
 //          this.printStackTrace();//DEBUG
         }
 
         public JCDiagnostic getDiagnostic() {
+            if (diag == null && diagSupplier != null) {
+                diag = diagSupplier.get();
+            }
             return diag;
         }
 
         @Override
         public String getMessage() {
-            return diag.getMessage(null);
+            return getDiagnostic().getMessage(null);
         }
 
         public JCDiagnostic getDetailValue() {
-            return diag;
+            return getDiagnostic();
         }
 
         @Override
@@ -2159,6 +2165,11 @@
             return this;
         }
 
+        public void resetDiagnostic(Supplier<JCDiagnostic> diagSupplier) {
+            this.diagSupplier = diagSupplier;
+            this.diag = null;
+        }
+
     }
 
     /**
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java	Tue Apr 09 11:48:54 2019 +0100
@@ -2226,7 +2226,11 @@
                 // Warn about fall-through if lint switch fallthrough enabled.
             }
             if (!hasDefault) {
-                inits.andSet(initsSwitch);
+                if (tree.hasTag(SWITCH_EXPRESSION)) {
+                    markDead();
+                } else {
+                    inits.andSet(initsSwitch);
+                }
             }
             resolveBreaks(tree, prevPendingExits);
             nextadr = nextadrPrev;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Tue Apr 09 11:48:54 2019 +0100
@@ -237,7 +237,7 @@
         return true;
     }
     // where
-        private static final Set<Option> javacFileManagerOptions =
+        protected static final Set<Option> javacFileManagerOptions =
             Option.getJavacFileManagerOptions();
 
     @Override @DefinedBy(Api.COMPILER)
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Tue Apr 09 11:48:54 2019 +0100
@@ -27,6 +27,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.UncheckedIOException;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
 import java.net.MalformedURLException;
@@ -71,6 +72,7 @@
 
 import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
 import com.sun.tools.javac.file.RelativePath.RelativeFile;
+import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
@@ -129,6 +131,19 @@
     protected SortFiles sortFiles;
 
     /**
+     * We use a two-layered map instead of a map with a complex key because we don't want to reindex
+     * the values for every Location+RelativeDirectory pair. Once the PathsAndContainers are needed
+     * for a single Location, we should know all valid RelativeDirectory mappings. Because the
+     * indexing is costly for very large classpaths, this can result in a significant savings.
+     */
+    private Map<Location, Map<RelativeDirectory, java.util.List<PathAndContainer>>>
+        pathsAndContainersByLocationAndRelativeDirectory = new HashMap<>();
+
+    /** Containers that have no indexing by {@link RelativeDirectory}, keyed by {@link Location}. */
+    private Map<Location, java.util.List<PathAndContainer>> nonIndexingContainersByLocation =
+        new HashMap<>();
+
+    /**
      * Register a Context.Factory to create a JavacFileManager.
      */
     public static void preRegister(Context context) {
@@ -338,6 +353,13 @@
                                   ListBuffer<JavaFileObject> resultList) throws IOException;
         public abstract JavaFileObject getFileObject(Path userPath, RelativeFile name) throws IOException;
         public abstract void close() throws IOException;
+        public abstract boolean maintainsDirectoryIndex();
+
+        /**
+         * The directories this container indexes if {@link #maintainsDirectoryIndex()}, otherwise
+         * an empty iterable.
+         */
+        public abstract Iterable<RelativeDirectory> indexedDirectories();
     }
 
     private static final Container MISSING_CONTAINER =  new Container() {
@@ -354,6 +376,14 @@
         }
         @Override
         public void close() throws IOException {}
+        @Override
+        public boolean maintainsDirectoryIndex() {
+            return false;
+        }
+        @Override
+        public Iterable<RelativeDirectory> indexedDirectories() {
+            return List.nil();
+        }
     };
 
     private final class JRTImageContainer implements Container {
@@ -407,6 +437,16 @@
         @Override
         public void close() throws IOException {
         }
+
+        @Override
+        public boolean maintainsDirectoryIndex() {
+            return false;
+        }
+
+        @Override
+        public Iterable<RelativeDirectory> indexedDirectories() {
+            return List.nil();
+        }
     }
 
     private synchronized JRTIndex getJRTIndex() {
@@ -498,6 +538,16 @@
         @Override
         public void close() throws IOException {
         }
+
+        @Override
+        public boolean maintainsDirectoryIndex() {
+            return false;
+        }
+
+        @Override
+        public Iterable<RelativeDirectory> indexedDirectories() {
+            return List.nil();
+        }
     }
 
     private static final Set<FileVisitOption> NO_FILE_VISIT_OPTIONS = Set.of();
@@ -506,7 +556,7 @@
     private final class ArchiveContainer implements Container {
         private final Path archivePath;
         private final FileSystem fileSystem;
-        private final Map<RelativePath, Path> packages;
+        private final Map<RelativeDirectory, Path> packages;
 
         public ArchiveContainer(Path archivePath) throws IOException, ProviderNotFoundException, SecurityException {
             this.archivePath = archivePath;
@@ -604,6 +654,16 @@
         public void close() throws IOException {
             fileSystem.close();
         }
+
+        @Override
+        public boolean maintainsDirectoryIndex() {
+            return true;
+        }
+
+        @Override
+        public Iterable<RelativeDirectory> indexedDirectories() {
+            return packages.keySet();
+        }
     }
 
     /**
@@ -654,6 +714,8 @@
     @Override @DefinedBy(Api.COMPILER)
     public void flush() {
         contentCache.clear();
+        pathsAndContainersByLocationAndRelativeDirectory.clear();
+        nonIndexingContainersByLocation.clear();
     }
 
     /**
@@ -704,15 +766,12 @@
         nullCheck(packageName);
         nullCheck(kinds);
 
-        Iterable<? extends Path> path = getLocationAsPaths(location);
-        if (path == null)
-            return List.nil();
         RelativeDirectory subdirectory = RelativeDirectory.forPackage(packageName);
         ListBuffer<JavaFileObject> results = new ListBuffer<>();
 
-        for (Path directory : path) {
-            Container container = getContainer(directory);
-
+        for (PathAndContainer pathAndContainer : pathsAndContainers(location, subdirectory)) {
+            Path directory = pathAndContainer.path;
+            Container container = pathAndContainer.container;
             container.list(directory, subdirectory, kinds, recurse, results);
         }
 
@@ -927,6 +986,7 @@
     {
         nullCheck(location);
         locations.setLocation(location, asPaths(searchpath));
+        clearCachesForLocation(location);
     }
 
     @Override @DefinedBy(Api.COMPILER)
@@ -936,6 +996,7 @@
     {
         nullCheck(location);
         locations.setLocation(location, nullCheck(searchpath));
+        clearCachesForLocation(location);
     }
 
     @Override @DefinedBy(Api.COMPILER)
@@ -945,11 +1006,113 @@
     }
 
     @Override @DefinedBy(Api.COMPILER)
-    public Iterable<? extends Path> getLocationAsPaths(Location location) {
+    public Collection<? extends Path> getLocationAsPaths(Location location) {
         nullCheck(location);
         return locations.getLocation(location);
     }
 
+    private java.util.List<PathAndContainer> pathsAndContainers(
+            Location location, RelativeDirectory relativeDirectory) throws IOException {
+        try {
+            return pathsAndContainersByLocationAndRelativeDirectory.computeIfAbsent(
+                    location, this::indexPathsAndContainersByRelativeDirectory)
+                .computeIfAbsent(
+                    relativeDirectory, d -> nonIndexingContainersByLocation.get(location));
+        } catch (UncheckedIOException e) {
+            throw e.getCause();
+        }
+    }
+
+    private Map<RelativeDirectory, java.util.List<PathAndContainer>> indexPathsAndContainersByRelativeDirectory(
+            Location location) {
+        Map<RelativeDirectory, java.util.List<PathAndContainer>> result = new HashMap<>();
+        java.util.List<PathAndContainer> allPathsAndContainers = pathsAndContainers(location);
+
+        // First collect all of the containers that don't maintain their own index on
+        // RelativeDirectory. These need to always be included for all mappings
+        java.util.List<PathAndContainer> nonIndexingContainers = new ArrayList<>();
+        for (PathAndContainer pathAndContainer : allPathsAndContainers) {
+            if (!pathAndContainer.container.maintainsDirectoryIndex()) {
+                nonIndexingContainers.add(pathAndContainer);
+            }
+        }
+
+        // Next, use the container that do maintain their own RelativeDirectory index to create a
+        // single master index.
+        for (PathAndContainer pathAndContainer : allPathsAndContainers) {
+            Container container = pathAndContainer.container;
+            if (container.maintainsDirectoryIndex()) {
+                for (RelativeDirectory directory : container.indexedDirectories()) {
+                    result.computeIfAbsent(directory, d -> new ArrayList<>(nonIndexingContainers))
+                          .add(pathAndContainer);
+                }
+            }
+        }
+        nonIndexingContainersByLocation.put(location, nonIndexingContainers);
+
+        // Sorting preserves the search order used in the uncached Location path, which has
+        // maintains consistency with the classpath order
+        result.values().forEach(pathAndContainerList -> Collections.sort(pathAndContainerList));
+
+        return result;
+    }
+
+    /**
+     * For each {@linkplain #getLocationAsPaths(Location) path of the location}, compute the
+     * corresponding {@link Container}.
+     */
+    private java.util.List<PathAndContainer> pathsAndContainers(Location location) {
+        Collection<? extends Path> paths = getLocationAsPaths(location);
+        if (paths == null) {
+            return List.nil();
+        }
+        java.util.List<PathAndContainer> pathsAndContainers =
+            new ArrayList<>(paths.size());
+        for (Path path : paths) {
+            Container container;
+            try {
+                container = getContainer(path);
+            } catch (IOException e) {
+                throw new UncheckedIOException(e);
+            }
+            pathsAndContainers.add(new PathAndContainer(path, container, pathsAndContainers.size()));
+        }
+        return pathsAndContainers;
+    }
+
+    private static class PathAndContainer implements Comparable<PathAndContainer> {
+        private final Path path;
+        private final Container container;
+        private final int index;
+
+        PathAndContainer(Path path, Container container, int index) {
+            this.path = path;
+            this.container = container;
+            this.index = index;
+        }
+
+        @Override
+        public int compareTo(PathAndContainer other) {
+            return index - other.index;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+          if (o == null || !(o instanceof PathAndContainer)) {
+            return false;
+          }
+          PathAndContainer that = (PathAndContainer) o;
+          return path.equals(that.path)
+              && container.equals(that.container)
+              && index == this.index;
+        }
+
+        @Override
+        public int hashCode() {
+          return Objects.hash(path, container, index);
+        }
+    }
+
     @Override @DefinedBy(Api.COMPILER)
     public boolean contains(Location location, FileObject fo) throws IOException {
         nullCheck(location);
@@ -1008,6 +1171,7 @@
         nullCheck(location);
         checkModuleOrientedOrOutputLocation(location);
         locations.setLocationForModule(location, nullCheck(moduleName), nullCheck(paths));
+        clearCachesForLocation(location);
     }
 
     @Override @DefinedBy(Api.COMPILER)
@@ -1163,4 +1327,19 @@
             }
         };
     }
+
+    @Override
+    public boolean handleOption(Option option, String value) {
+        if (javacFileManagerOptions.contains(option)) {
+            pathsAndContainersByLocationAndRelativeDirectory.clear();
+            nonIndexingContainersByLocation.clear();
+        }
+        return super.handleOption(option, value);
+    }
+
+    private void clearCachesForLocation(Location location) {
+        nullCheck(location);
+        pathsAndContainersByLocationAndRelativeDirectory.remove(location);
+        nonIndexingContainersByLocation.remove(location);
+    }
 }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Apr 09 11:48:54 2019 +0100
@@ -3079,7 +3079,7 @@
                 }
             } catch (Exception e) {
                 throw new CompletionFailure(sym,
-                                            ClassReader.this.diagFactory.fragment(Fragments.ExceptionMessage(e.getMessage())),
+                                            () -> ClassReader.this.diagFactory.fragment(Fragments.ExceptionMessage(e.getMessage())),
                                             dcfh);
             }
 
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Apr 09 11:48:54 2019 +0100
@@ -805,9 +805,8 @@
      */
     public void readSourceFile(JCCompilationUnit tree, ClassSymbol c) throws CompletionFailure {
         if (completionFailureName == c.fullname) {
-            JCDiagnostic msg =
-                    diagFactory.fragment(Fragments.UserSelectedCompletionFailure);
-            throw new CompletionFailure(c, msg, dcfh);
+            throw new CompletionFailure(
+                c, () -> diagFactory.fragment(Fragments.UserSelectedCompletionFailure), dcfh);
         }
         JavaFileObject filename = c.classfile;
         JavaFileObject prev = log.useSource(filename);
@@ -835,7 +834,7 @@
         // have enough modules available to access java.lang, and
         // so risk getting FatalError("no.java.lang") from MemberEnter.
         if (!modules.enter(List.of(tree), c)) {
-            throw new CompletionFailure(c, diags.fragment(Fragments.CantResolveModules), dcfh);
+            throw new CompletionFailure(c, () -> diags.fragment(Fragments.CantResolveModules), dcfh);
         }
 
         enter.complete(List.of(tree), c);
@@ -990,6 +989,8 @@
             if (!log.hasDiagnosticListener()) {
                 printCount("error", errorCount());
                 printCount("warn", warningCount());
+                printSuppressedCount(errorCount(), log.nsuppressederrors, "count.error.recompile");
+                printSuppressedCount(warningCount(), log.nsuppressedwarns, "count.warn.recompile");
             }
             if (!taskListener.isEmpty()) {
                 taskListener.finished(new TaskEvent(TaskEvent.Kind.COMPILATION));
@@ -1845,6 +1846,15 @@
         }
     }
 
+    private void printSuppressedCount(int shown, int suppressed, String diagKey) {
+        if (suppressed > 0) {
+            int total = shown + suppressed;
+            log.printLines(WriterKind.ERROR, diagKey,
+                    String.valueOf(shown), String.valueOf(total));
+            log.flush(Log.WriterKind.ERROR);
+        }
+    }
+
     private static long now() {
         return System.currentTimeMillis();
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Apr 09 11:48:54 2019 +0100
@@ -1636,6 +1636,14 @@
 compiler.misc.count.error.plural=\
     {0} errors
 
+# 0: number, 1: number
+compiler.misc.count.error.recompile=\
+    only showing the first {0} errors, of {1} total; use -Xmaxerrs if you would like to see more
+
+# 0: number, 1: number
+compiler.misc.count.warn.recompile=\
+    only showing the first {0} warnings, of {1} total; use -Xmaxwarns if you would like to see more
+
 # 0: number
 compiler.misc.count.warn=\
     {0} warning
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Tue Apr 09 11:48:54 2019 +0100
@@ -419,6 +419,14 @@
      */
     public int nwarnings = 0;
 
+    /** The number of errors encountered after MaxErrors was reached.
+     */
+    public int nsuppressederrors = 0;
+
+    /** The number of warnings encountered after MaxWarnings was reached.
+     */
+    public int nsuppressedwarns = 0;
+
     /** A set of all errors generated so far. This is used to avoid printing an
      *  error message more than once. For each error, a pair consisting of the
      *  source file name and source code position of the error is added to the set.
@@ -708,16 +716,21 @@
                     if (nwarnings < MaxWarnings) {
                         writeDiagnostic(diagnostic);
                         nwarnings++;
+                    } else {
+                        nsuppressedwarns++;
                     }
                 }
                 break;
 
             case ERROR:
-                if (nerrors < MaxErrors &&
-                    (diagnostic.isFlagSet(DiagnosticFlag.API) ||
-                     shouldReport(diagnostic))) {
-                    writeDiagnostic(diagnostic);
-                    nerrors++;
+                if (diagnostic.isFlagSet(DiagnosticFlag.API) ||
+                     shouldReport(diagnostic)) {
+                    if (nerrors < MaxErrors) {
+                        writeDiagnostic(diagnostic);
+                        nerrors++;
+                    } else {
+                        nsuppressederrors++;
+                    }
                 }
                 break;
             }
@@ -844,6 +857,8 @@
             printRawDiag(errWriter, "error: ", pos, msg);
             prompt();
             nerrors++;
+        } else {
+            nsuppressederrors++;
         }
         errWriter.flush();
     }
@@ -852,8 +867,12 @@
      */
     public void rawWarning(int pos, String msg) {
         PrintWriter warnWriter = writers.get(WriterKind.ERROR);
-        if (nwarnings < MaxWarnings && emitWarnings) {
-            printRawDiag(warnWriter, "warning: ", pos, msg);
+        if (emitWarnings) {
+            if (nwarnings < MaxWarnings) {
+                printRawDiag(warnWriter, "warning: ", pos, msg);
+            } else {
+                nsuppressedwarns++;
+            }
         }
         prompt();
         nwarnings++;
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeap.java	Tue Apr 09 11:48:54 2019 +0100
@@ -64,6 +64,8 @@
   public abstract long capacity();
   public abstract long used();
 
+  public long oopOffset() { return 0; }
+
   public MemRegion reservedRegion() {
     return new MemRegion(addr.addOffsetTo(reservedFieldOffset));
   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahBitMap.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
+ *
+ * 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 sun.jvm.hotspot.gc.shenandoah;
+
+import sun.jvm.hotspot.utilities.BitMap;
+import sun.jvm.hotspot.utilities.BitMapInterface;
+
+import java.util.HashMap;
+
+public class ShenandoahBitMap implements BitMapInterface {
+    private HashMap<ShenandoahHeapRegion, BitMap> regionToBitMap = new HashMap<>();
+    private ShenandoahHeap heap;
+
+    ShenandoahBitMap(ShenandoahHeap heap) {
+        this.heap = heap;
+    }
+
+    @Override
+    public boolean at(long offset) {
+        ShenandoahHeapRegion region = heap.regionAtOffset(offset);
+        BitMap bitmap = regionToBitMap.get(region);
+        if (bitmap == null) {
+            return false;
+        } else {
+            int index = toBitMapOffset(offset, region);
+            return bitmap.at(index);
+        }
+    }
+
+    @Override
+    public void atPut(long offset, boolean value) {
+        ShenandoahHeapRegion region = heap.regionAtOffset(offset);
+        BitMap bitmap = getOrAddBitMap(region);
+        int index = toBitMapOffset(offset, region);
+        bitmap.atPut(index, value);
+    }
+
+    @Override
+    public void clear() {
+        for (BitMap bitMap : regionToBitMap.values()) {
+            bitMap.clear();
+        }
+    }
+
+    private int toBitMapOffset(long offset, ShenandoahHeapRegion region) {
+        long regionSize = ShenandoahHeapRegion.regionSizeBytes();
+        long regionOffset = region.regionNumber() * regionSize;
+        long offsetInRegion = offset - regionOffset;
+
+        if (offsetInRegion < 0 || offsetInRegion >= regionSize) {
+            throw new RuntimeException("Unexpected negative offset: " + offsetInRegion);
+        }
+        return (int)(offsetInRegion >>> heap.getLogMinObjAlignmentInBytes());
+    }
+
+    private BitMap getOrAddBitMap(ShenandoahHeapRegion region) {
+        BitMap bitMap = regionToBitMap.get(region);
+        if (bitMap == null) {
+            long regionSize = ShenandoahHeapRegion.regionSizeBytes();
+            long maxNumObjects = regionSize >>> heap.getLogMinObjAlignmentInBytes();
+
+            if (maxNumObjects > Integer.MAX_VALUE) {
+                throw new RuntimeException("int overflow");
+            }
+            int intMaxNumObjects = (int)maxNumObjects;
+
+            bitMap = new BitMap(intMaxNumObjects);
+            regionToBitMap.put(region,  bitMap);
+        }
+
+        return bitMap;
+    }
+}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2017, 2019, Red Hat, Inc. All rights reserved.
  *
  * 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
@@ -28,10 +28,14 @@
 import sun.jvm.hotspot.gc.shared.LiveRegionsClosure;
 import sun.jvm.hotspot.debugger.Address;
 import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.runtime.VMObjectFactory;
+import sun.jvm.hotspot.types.AddressField;
 import sun.jvm.hotspot.types.Type;
 import sun.jvm.hotspot.types.TypeDataBase;
 import sun.jvm.hotspot.memory.MemRegion;
 import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.utilities.BitMapInterface;
+
 import java.io.PrintStream;
 import java.util.Observable;
 import java.util.Observer;
@@ -40,6 +44,11 @@
     static private CIntegerField numRegions;
     static private CIntegerField used;
     static private CIntegerField committed;
+    static private AddressField  regions;
+    static private CIntegerField logMinObjAlignmentInBytes;
+
+    static private long regionPtrFieldSize;
+    static private long brookPtrSize;
     static {
         VM.registerVMInitializedObserver(new Observer() {
             public void update(Observable o, Object data) {
@@ -53,6 +62,21 @@
         numRegions = type.getCIntegerField("_num_regions");
         used = type.getCIntegerField("_used");
         committed = type.getCIntegerField("_committed");
+        regions = type.getAddressField("_regions");
+        logMinObjAlignmentInBytes = type.getCIntegerField("_log_min_obj_alignment_in_bytes");
+
+        brookPtrSize = db.lookupIntConstant("HeapWordSize").longValue();
+        Type regionPtrType = db.lookupType("ShenandoahHeapRegion*");
+        regionPtrFieldSize = regionPtrType.getSize();
+    }
+
+    public ShenandoahHeap(Address addr) {
+        super(addr);
+    }
+
+    @Override
+    public long oopOffset() {
+        return brookPtrSize;
     }
 
     @Override
@@ -78,10 +102,35 @@
         return committed.getValue(addr);
     }
 
+    public int getLogMinObjAlignmentInBytes() {
+        return logMinObjAlignmentInBytes.getJInt(addr);
+    }
+
+    public ShenandoahHeapRegion getRegion(long index) {
+        if (index < numOfRegions()) {
+            Address arrayAddr = regions.getValue(addr);
+            Address regAddr = arrayAddr.getAddressAt(index * regionPtrFieldSize);
+            ShenandoahHeapRegion region = VMObjectFactory.newObject(ShenandoahHeapRegion.class, regAddr);
+            region.setHeap(this);
+            return region;
+        }
+        return null;
+    }
+
+    public ShenandoahHeapRegion regionAtOffset(long offset) {
+        long index = offset >>> ShenandoahHeapRegion.regionSizeBytesShift();
+        if (index < 0 || index >= numOfRegions()) {
+            throw new RuntimeException("Invalid offset: " + offset);
+        }
+        return getRegion(index);
+    }
+
     @Override
     public void liveRegionsIterate(LiveRegionsClosure closure) {
-        // Operation (currently) not supported with Shenandoah GC.
-        System.err.println("Warning: Operation not supported with Shenandoah GC");
+        for (long index = 0; index < numOfRegions(); index ++) {
+            ShenandoahHeapRegion region = getRegion(index);
+            closure.doLiveRegions(region);
+        }
     }
 
     @Override
@@ -92,7 +141,9 @@
         tty.println(" region size " + ShenandoahHeapRegion.regionSizeBytes() / 1024 + " K");
     }
 
-    public ShenandoahHeap(Address addr) {
-        super(addr);
+    @Override
+    public BitMapInterface createBitMap(long bits) {
+        return new ShenandoahBitMap(this);
     }
+
 }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeapRegion.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeapRegion.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2017, 2019, Red Hat, Inc. All rights reserved.
  *
  * 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
@@ -23,19 +23,43 @@
 
 package sun.jvm.hotspot.gc.shenandoah;
 
+import sun.jvm.hotspot.debugger.OopHandle;
 import sun.jvm.hotspot.gc.shared.ContiguousSpace;
-import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.gc.shared.LiveRegionsProvider;
+import sun.jvm.hotspot.memory.MemRegion;
+import sun.jvm.hotspot.oops.Mark;
+import sun.jvm.hotspot.oops.Oop;
+import sun.jvm.hotspot.oops.UnknownOopException;
+import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.runtime.VM;
-import sun.jvm.hotspot.types.Type;
-import sun.jvm.hotspot.types.TypeDataBase;
 import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.utilities.AddressOps;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Observable;
 import java.util.Observer;
 
 
-public class ShenandoahHeapRegion extends ContiguousSpace {
-    private static CIntegerField RegionSizeBytes;
+public class ShenandoahHeapRegion extends ContiguousSpace implements LiveRegionsProvider {
+    private static int EmptyUncommitted;
+    private static int EmptyCommitted;
+    private static int Regular;
+    private static int HumongousStart;
+    private static int HumongousCont;
+    private static int PinnedHumongousStart;
+    private static int CSet;
+    private static int Pinned;
+    private static int PinnedCSet;
+    private static int Trash;
+
+    private static CIntegerField RegionSizeBytesField;
+    private static Field         RegionStateField;
+    private static CIntegerField RegionNumberField;
+    private static CIntegerField RegionSizeBytesShiftField;
+
+    private ShenandoahHeap heap;
+
     static {
         VM.registerVMInitializedObserver(new Observer() {
             public void update(Observable o, Object data) {
@@ -46,12 +70,154 @@
 
     static private synchronized void initialize(TypeDataBase db) {
         Type type = db.lookupType("ShenandoahHeapRegion");
-        RegionSizeBytes = type.getCIntegerField("RegionSizeBytes");
+        RegionSizeBytesField = type.getCIntegerField("RegionSizeBytes");
+        RegionStateField = type.getField("_state");
+        RegionNumberField = type.getCIntegerField("_region_number");
+
+        RegionSizeBytesShiftField = type.getCIntegerField("RegionSizeBytesShift");
+
+        EmptyUncommitted     = db.lookupIntConstant("ShenandoahHeapRegion::_empty_uncommitted").intValue();
+        EmptyCommitted       = db.lookupIntConstant("ShenandoahHeapRegion::_empty_committed").intValue();
+        Regular              = db.lookupIntConstant("ShenandoahHeapRegion::_regular").intValue();
+        HumongousStart       = db.lookupIntConstant("ShenandoahHeapRegion::_humongous_start").intValue();
+        HumongousCont        = db.lookupIntConstant("ShenandoahHeapRegion::_humongous_cont").intValue();
+        PinnedHumongousStart = db.lookupIntConstant("ShenandoahHeapRegion::_pinned_humongous_start").intValue();
+        CSet                 = db.lookupIntConstant("ShenandoahHeapRegion::_cset").intValue();
+        Pinned               = db.lookupIntConstant("ShenandoahHeapRegion::_pinned").intValue();
+        PinnedCSet           = db.lookupIntConstant("ShenandoahHeapRegion::_pinned_cset").intValue();
+        Trash                = db.lookupIntConstant("ShenandoahHeapRegion::_trash").intValue();
     }
 
-    public static long regionSizeBytes() { return RegionSizeBytes.getValue(); }
+    public static long regionSizeBytes() {
+        return RegionSizeBytesField.getValue();
+    }
+
+    public static int  regionSizeBytesShift() {
+        return RegionSizeBytesShiftField.getJInt();
+    }
 
     public ShenandoahHeapRegion(Address addr) {
         super(addr);
     }
+
+    public void setHeap(ShenandoahHeap heap) {
+        this.heap = heap;
+    }
+
+    @Override
+    public int hashCode() {
+        return (int)regionNumber();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other instanceof ShenandoahHeapRegion) {
+            ShenandoahHeapRegion otherRegion = (ShenandoahHeapRegion)other;
+            return otherRegion.regionNumber() == regionNumber();
+        }
+        return false;
+    }
+
+    public List<MemRegion> getLiveRegions() {
+        List<MemRegion> res = new ArrayList<>();
+        int state = regionState();
+        if (state == EmptyUncommitted || state == EmptyCommitted || state == Trash) {
+            // No live data
+        } else if (state == HumongousCont) {
+            // Handled by HumongousStart
+        } else if (state == HumongousStart || state == PinnedHumongousStart) {
+            handleHumongousRegion(res);
+        } else if (state == Regular || state == Pinned) {
+            handleRegularRegion(res);
+        } else if (state == CSet || state == PinnedCSet) {
+            // CSet
+            handleCSetRegion(res);
+        } else {
+            throw new RuntimeException("Unknown region state: " + state);
+        }
+        return res;
+    }
+
+    /*
+     * Note: RegionState is an enum on JVM side. Seems that there is not
+     *       a standard way to read enum value. We read it as an integer
+     *       from the field's offset.
+     */
+    private int regionState() {
+        long offset = RegionStateField.getOffset();
+        return addr.getJIntAt(offset);
+    }
+
+    private void handleHumongousRegion(List<MemRegion> res) {
+        long index = regionNumber();
+        Address topAddr = top();
+        ShenandoahHeapRegion region = heap.getRegion(++ index);
+        while (region.regionState() == HumongousCont) {
+            topAddr = region.top();
+            region = heap.getRegion(++ index);
+        }
+        res.add(new MemRegion(bottom(), topAddr));
+    }
+
+    private void handleRegularRegion(List<MemRegion> res) {
+        res.add(new MemRegion(bottom(), top()));
+    }
+
+    // Filter out forwarded objects, they should be counted in other regions
+    private void handleCSetRegion(List<MemRegion> res) {
+        Address end = top();
+        Address start = bottom();
+
+        Address regionStart = null;
+        Address regionEnd = null;
+        while (AddressOps.lessThan(start, end)) {
+            long size = getObjectSize(start);
+            if (hasForwardee(start)) {
+                // has to-space object, skip this one
+                if (regionEnd != null) {
+                    MemRegion mr = new MemRegion(regionStart, regionEnd);
+                    res.add(mr);
+                    regionStart = null;
+                    regionEnd = null;
+                }
+            } else {
+                if (regionStart == null) {
+                    regionStart = start;
+                } else {
+                    regionEnd = start.addOffsetTo(heap.oopOffset() + size);
+                }
+            }
+            start = start.addOffsetTo(heap.oopOffset() + size);
+        }
+
+        if (regionStart != null) {
+            MemRegion mr = new MemRegion(regionStart, top());
+            res.add(mr);
+        }
+    }
+
+    public long regionNumber() {
+        return RegionNumberField.getValue(addr);
+    }
+
+    private boolean hasForwardee(Address rawPtr) {
+        // Use Mark as a helper to read forward pointer value.
+        Mark mark = new Mark(rawPtr);
+        Address forwardee = mark.valueAsAddress();
+        return (forwardee != rawPtr.addOffsetTo(heap.oopOffset()));
+    }
+
+    private long getObjectSize(Address rawPtr) {
+        // Dealing with a raw pointer, offsets forward pointer to find real Oop.
+        OopHandle handle = rawPtr.addOffsetToAsOopHandle(heap.oopOffset());
+        Oop obj = null;
+
+        try {
+            // Best effort, may fail
+            obj = VM.getVM().getObjectHeap().newOop(handle);
+        } catch (UnknownOopException exp) {
+            throw new RuntimeException(" UnknownOopException  " + exp);
+        }
+        return obj.getObjectSize();
+    }
 }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, 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
@@ -172,7 +172,7 @@
     return 2;
   }
   public static int cellOffset(int index) {
-    return MethodData.cellSize + index * MethodData.cellSize;
+    return (headerSizeInCells() + index) * MethodData.cellSize;
   }
   // // Return a value which, when or-ed as a byte into _flags, sets the flag.
   // static int flagNumberToByteConstant(int flagNumber) {
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Tue Apr 09 11:48:54 2019 +0100
@@ -255,7 +255,9 @@
         OopHandle handle = bottom.addOffsetToAsOopHandle(0);
 
         while (handle.lessThan(top)) {
-        Oop obj = null;
+          Oop obj = null;
+          // Raw pointer walk
+          handle = handle.addOffsetToAsOopHandle(heap.oopOffset());
 
           try {
             obj = newOop(handle);
--- a/src/jdk.internal.vm.ci/share/classes/module-info.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.ci/share/classes/module-info.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,9 @@
  */
 
 module jdk.internal.vm.ci {
-    exports jdk.vm.ci.services to jdk.internal.vm.compiler;
+    exports jdk.vm.ci.services to
+        jdk.internal.vm.compiler,
+        jdk.internal.vm.compiler.management;
     exports jdk.vm.ci.runtime to
         jdk.internal.vm.compiler,
         jdk.internal.vm.compiler.management;
--- a/src/jdk.internal.vm.compiler.management/share/classes/org.graalvm.compiler.hotspot.management/src/org/graalvm/compiler/hotspot/management/HotSpotGraalRuntimeMBean.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler.management/share/classes/org.graalvm.compiler.hotspot.management/src/org/graalvm/compiler/hotspot/management/HotSpotGraalRuntimeMBean.java	Tue Apr 09 11:48:54 2019 +0100
@@ -52,6 +52,8 @@
 import org.graalvm.compiler.options.OptionsParser;
 import org.graalvm.compiler.serviceprovider.GraalServices;
 
+import jdk.vm.ci.services.Services;
+
 /**
  * MBean used to access properties and operations of a {@link HotSpotGraalRuntime} instance.
  */
@@ -84,7 +86,7 @@
 
     private static boolean initDebug() {
         try {
-            return Boolean.getBoolean(HotSpotGraalRuntimeMBean.class.getSimpleName() + ".debug");
+            return Boolean.parseBoolean(Services.getSavedProperties().get(HotSpotGraalRuntimeMBean.class.getSimpleName() + ".debug"));
         } catch (SecurityException e) {
             // Swallow the exception
             return false;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64Assembler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64Assembler.java	Tue Apr 09 11:48:54 2019 +0100
@@ -40,6 +40,7 @@
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.BR;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.BRK;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.CAS;
+import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.CCMP;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.CLREX;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.CLS;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.CLZ;
@@ -86,6 +87,7 @@
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.MOVK;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.MOVN;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.MOVZ;
+import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.MRS;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.MSUB;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.ORN;
 import static org.graalvm.compiler.asm.aarch64.AArch64Assembler.Instruction.ORR;
@@ -436,6 +438,7 @@
     private static final int FpImmOffset = 13;
 
     private static final int FpCmpOp = 0x1E202000;
+    private static final int FpCmpeOp = 0x1E202010;
 
     private static final int PcRelImmHiOffset = 5;
     private static final int PcRelImmLoOffset = 29;
@@ -532,6 +535,8 @@
         SUB(0x40000000),
         SUBS(SUB.encoding | AddSubSetFlag),
 
+        CCMP(0x7A400000),
+
         NOT(0x00200000),
         AND(0x00000000),
         BIC(AND.encoding | NOT.encoding),
@@ -618,6 +623,9 @@
         HINT(0xD503201F),
         DMB(0x000000A0),
 
+        MRS(0xD5300000),
+        MSR(0xD5100000),
+
         BLR_NATIVE(0xc0000000);
 
         public final int encoding;
@@ -628,6 +636,29 @@
 
     }
 
+    public enum SystemRegister {
+        FPCR(0b11, 0b011, 0b0100, 0b0100, 0b000),
+        FPSR(0b11, 0b011, 0b0100, 0b0100, 0b001);
+
+        SystemRegister(int op0, int op1, int crn, int crm, int op2) {
+            this.op0 = op0;
+            this.op1 = op1;
+            this.crn = crn;
+            this.crm = crm;
+            this.op2 = op2;
+        }
+
+        public int encoding() {
+            return op0 << 19 | op1 << 16 | crn << 12 | crm << 8 | op2 << 5;
+        }
+
+        private final int op0;
+        private final int op1;
+        private final int crn;
+        private final int crm;
+        private final int op2;
+    }
+
     public enum ShiftType {
         LSL(0),
         LSR(1),
@@ -971,8 +1002,10 @@
         int imm = (imm28 & NumUtil.getNbitNumberInt(28)) >> 2;
         int instrEncoding = instr.encoding | UnconditionalBranchImmOp;
         if (pos == -1) {
+            annotatePatchingImmediate(position(), instr, 26, 0, 2);
             emitInt(instrEncoding | imm);
         } else {
+            annotatePatchingImmediate(pos, instr, 26, 0, 2);
             emitInt(instrEncoding | imm, pos);
         }
     }
@@ -1011,6 +1044,7 @@
         assert !reg.equals(zr);
         assert !reg.equals(sp);
         emitInt(instr.encoding | UnconditionalBranchRegOp | rs1(reg));
+
     }
 
     /* Load-Store Single Register (5.3.1) */
@@ -1161,9 +1195,11 @@
         int memop = instr.encoding | transferSizeEncoding | is32Bit | isFloat | rt(reg);
         switch (address.getAddressingMode()) {
             case IMMEDIATE_SCALED:
+                annotatePatchingImmediate(position(), instr, 12, LoadStoreScaledImmOffset, log2TransferSize);
                 emitInt(memop | LoadStoreScaledOp | address.getImmediate() << LoadStoreScaledImmOffset | rs1(address.getBase()));
                 break;
             case IMMEDIATE_UNSCALED:
+                annotatePatchingImmediate(position(), instr, 9, LoadStoreUnscaledImmOffset, 0);
                 emitInt(memop | LoadStoreUnscaledOp | address.getImmediate() << LoadStoreUnscaledImmOffset | rs1(address.getBase()));
                 break;
             case BASE_REGISTER_ONLY:
@@ -1178,12 +1214,15 @@
             case PC_LITERAL:
                 assert log2TransferSize >= 2 : "PC literal loads only works for load/stores of 32-bit and larger";
                 transferSizeEncoding = (log2TransferSize - 2) << LoadStoreTransferSizeOffset;
+                annotatePatchingImmediate(position(), instr, 21, LoadLiteralImmeOffset, 2);
                 emitInt(transferSizeEncoding | isFloat | LoadLiteralOp | rd(reg) | address.getImmediate() << LoadLiteralImmeOffset);
                 break;
             case IMMEDIATE_POST_INDEXED:
+                annotatePatchingImmediate(position(), instr, 9, LoadStoreIndexedImmOffset, 0);
                 emitInt(memop | LoadStorePostIndexedOp | rs1(address.getBase()) | address.getImmediate() << LoadStoreIndexedImmOffset);
                 break;
             case IMMEDIATE_PRE_INDEXED:
+                annotatePatchingImmediate(position(), instr, 9, LoadStoreIndexedImmOffset, 0);
                 emitInt(memop | LoadStorePreIndexedOp | rs1(address.getBase()) | address.getImmediate() << LoadStoreIndexedImmOffset);
                 break;
             default:
@@ -1529,6 +1568,10 @@
         emitInt(type.encoding | instr.encoding | AddSubImmOp | encodeAimm(aimm) | rd(dst) | rs1(src));
     }
 
+    public void ccmp(int size, Register x, Register y, int aimm, ConditionFlag condition) {
+        emitInt(generalFromSize(size).encoding | CCMP.encoding | rs1(x) | rs2(y) | encodeAimm(aimm) | condition.encoding << ConditionalConditionOffset);
+    }
+
     /**
      * Encodes arithmetic immediate.
      *
@@ -2414,7 +2457,8 @@
             return false;
         }
         // bits[62] and bits[61] are opposites.
-        return ((bits ^ (bits << 1)) & (1L << 62)) != 0;
+        boolean result = ((bits ^ (bits << 1)) & (1L << 62)) != 0;
+        return result;
     }
 
     private static int getFloatImmediate(float imm) {
@@ -2694,6 +2738,20 @@
     }
 
     /**
+     * Signalling compares src1 to src2.
+     *
+     * @param size register size.
+     * @param src1 floating point register. May not be null.
+     * @param src2 floating point register. May not be null.
+     */
+    public void fcmpe(int size, Register src1, Register src2) {
+        assert src1.getRegisterCategory().equals(SIMD);
+        assert src2.getRegisterCategory().equals(SIMD);
+        InstructionType type = floatFromSize(size);
+        emitInt(type.encoding | FCMP.encoding | FpCmpeOp | rs1(src1) | rs2(src2));
+    }
+
+    /**
      * Conditional compare. NZCV = fcmp(src1, src2) if condition else uimm4.
      *
      * @param size register size.
@@ -2722,6 +2780,18 @@
         emitInt(type.encoding | FCMPZERO.encoding | FpCmpOp | rs1(src));
     }
 
+    /**
+     * Signalling compare register to 0.0 .
+     *
+     * @param size register size.
+     * @param src floating point register. May not be null.
+     */
+    public void fcmpeZero(int size, Register src) {
+        assert src.getRegisterCategory().equals(SIMD);
+        InstructionType type = floatFromSize(size);
+        emitInt(type.encoding | FCMPZERO.encoding | FpCmpeOp | rs1(src));
+    }
+
     /* Floating-point Conditional Select (5.7.11) */
 
     /**
@@ -2833,4 +2903,58 @@
         emitInt(DMB.encoding | BarrierOp | barrierKind.encoding << BarrierKindOffset);
     }
 
+    public void mrs(Register dst, SystemRegister systemRegister) {
+        emitInt(MRS.encoding | systemRegister.encoding() | rt(dst));
+    }
+
+    public void msr(SystemRegister systemRegister, Register src) {
+        emitInt(MRS.encoding | systemRegister.encoding() | rt(src));
+    }
+
+    public void annotatePatchingImmediate(int pos, Instruction instruction, int operandSizeBits, int offsetBits, int shift) {
+        if (codePatchingAnnotationConsumer != null) {
+            codePatchingAnnotationConsumer.accept(new OperandDataAnnotation(pos, instruction, operandSizeBits, offsetBits, shift));
+        }
+    }
+
+    void annotatePatchingImmediateNativeAddress(int pos, int operandSizeBits, int numInstrs) {
+        if (codePatchingAnnotationConsumer != null) {
+            codePatchingAnnotationConsumer.accept(new MovSequenceAnnotation(pos, operandSizeBits, numInstrs));
+        }
+    }
+
+    public static class OperandDataAnnotation extends CodeAnnotation {
+
+        /**
+         * The size of the operand, in bytes.
+         */
+        public final int operandSizeBits;
+        public final int offsetBits;
+        public final Instruction instruction;
+        public final int shift;
+
+        OperandDataAnnotation(int instructionPosition, Instruction instruction, int operandSizeBits, int offsetBits, int shift) {
+            super(instructionPosition);
+            this.operandSizeBits = operandSizeBits;
+            this.offsetBits = offsetBits;
+            this.shift = shift;
+            this.instruction = instruction;
+        }
+    }
+
+    public static class MovSequenceAnnotation extends CodeAnnotation {
+
+        /**
+         * The size of the operand, in bytes.
+         */
+        public final int operandSizeBits;
+        public final int numInstrs;
+
+        MovSequenceAnnotation(int instructionPosition, int operandSizeBits, int numInstrs) {
+            super(instructionPosition);
+            this.operandSizeBits = operandSizeBits;
+            this.numInstrs = numInstrs;
+        }
+    }
+
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64MacroAssembler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.aarch64/src/org/graalvm/compiler/asm/aarch64/AArch64MacroAssembler.java	Tue Apr 09 11:48:54 2019 +0100
@@ -266,7 +266,8 @@
      * @return AArch64Address pointing to memory at {@code base + displacement}.
      */
     public AArch64Address makeAddress(Register base, long displacement, int transferSize) {
-        return makeAddress(base, displacement, zr, /* signExtend */false, transferSize, zr, /* allowOverwrite */false);
+        return makeAddress(base, displacement, zr, /* signExtend */false, //
+                        transferSize, zr, /* allowOverwrite */false);
     }
 
     /**
@@ -365,7 +366,19 @@
      * @param imm immediate loaded into register.
      */
     public void mov(Register dst, long imm) {
+        mov(dst, imm, false);
+    }
+
+    /**
+     * Loads immediate into register.
+     *
+     * @param dst general purpose register. May not be null, zero-register or stackpointer.
+     * @param imm immediate loaded into register.
+     * @param annotateImm Flag to signal of the immediate value should be annotated.
+     */
+    public void mov(Register dst, long imm, boolean annotateImm) {
         assert dst.getRegisterCategory().equals(CPU);
+        int pos = position();
         if (imm == 0L) {
             movx(dst, zr);
         } else if (LogicalImmediateTable.isRepresentable(true, imm) != LogicalImmediateTable.Representable.NO) {
@@ -379,6 +392,9 @@
             sxt(64, 32, dst, dst);
         } else {
             mov64(dst, imm);
+            if (annotateImm) {
+                annotatePatchingImmediateNativeAddress(pos, 64, 4);
+            }
         }
     }
 
@@ -403,9 +419,25 @@
      * @param imm
      */
     public void movNativeAddress(Register dst, long imm) {
+        movNativeAddress(dst, imm, false);
+    }
+
+    /**
+     * Generates a 48-bit immediate move code sequence. The immediate may later be updated by
+     * HotSpot.
+     *
+     * In AArch64 mode the virtual address space is 48-bits in size, so we only need three
+     * instructions to create a patchable instruction sequence that can reach anywhere.
+     *
+     * @param dst general purpose register. May not be null, stackpointer or zero-register.
+     * @param imm The immediate address
+     * @param annotateImm Flag to signal of the immediate value should be annotated.
+     */
+    public void movNativeAddress(Register dst, long imm, boolean annotateImm) {
         assert (imm & 0xFFFF_0000_0000_0000L) == 0;
         // We have to move all non zero parts of the immediate in 16-bit chunks
         boolean firstMove = true;
+        int pos = position();
         for (int offset = 0; offset < 48; offset += 16) {
             int chunk = (int) (imm >> offset) & NumUtil.getNbitNumberInt(16);
             if (firstMove) {
@@ -415,6 +447,9 @@
                 movk(64, dst, chunk, offset);
             }
         }
+        if (annotateImm) {
+            annotatePatchingImmediateNativeAddress(pos, 48, 3);
+        }
         assert !firstMove;
     }
 
@@ -1597,7 +1632,7 @@
     }
 
     public void pause() {
-        throw GraalError.unimplemented();
+        super.hint(SystemHint.YIELD);
     }
 
     /**
@@ -1721,7 +1756,8 @@
      */
     @Override
     public AArch64Address makeAddress(Register base, int displacement) {
-        return makeAddress(base, displacement, zr, /* signExtend */false, /* transferSize */0, zr, /* allowOverwrite */false);
+        return makeAddress(base, displacement, zr, /* signExtend */false, /* transferSize */0, //
+                        zr, /* allowOverwrite */false);
     }
 
     @Override
@@ -1730,7 +1766,9 @@
     }
 
     public void addressOf(Register dst) {
-        // This will be fixed up later.
+        if (codePatchingAnnotationConsumer != null) {
+            codePatchingAnnotationConsumer.accept(new AdrpAddMacroInstruction(position()));
+        }
         super.adrp(dst);
         super.add(64, dst, dst, 0);
     }
@@ -1744,4 +1782,51 @@
     public void lea(Register d, AArch64Address a) {
         a.lea(this, d);
     }
+
+    public interface MacroInstruction {
+        void patch(int codePos, int relative, byte[] code);
+    }
+
+    /**
+     * Emits elf patchable adrp add sequence.
+     */
+    public void adrAddRel(int srcSize, Register result, AArch64Address a) {
+        if (codePatchingAnnotationConsumer != null) {
+            codePatchingAnnotationConsumer.accept(new ADRADDPRELMacroInstruction(position()));
+        }
+        super.adrp(a.getBase());
+        this.ldr(srcSize, result, a);
+    }
+
+    public static class ADRADDPRELMacroInstruction extends CodeAnnotation implements MacroInstruction {
+        public ADRADDPRELMacroInstruction(int position) {
+            super(position);
+        }
+
+        @Override
+        public String toString() {
+            return "ADR_PREL_PG";
+        }
+
+        @Override
+        public void patch(int codePos, int relative, byte[] code) {
+            throw GraalError.unimplemented();
+        }
+    }
+
+    public static class AdrpAddMacroInstruction extends CodeAnnotation implements MacroInstruction {
+        public AdrpAddMacroInstruction(int position) {
+            super(position);
+        }
+
+        @Override
+        public String toString() {
+            return "ADRP_ADD";
+        }
+
+        @Override
+        public void patch(int codePos, int relative, byte[] code) {
+            throw GraalError.unimplemented();
+        }
+    }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm/src/org/graalvm/compiler/asm/Assembler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm/src/org/graalvm/compiler/asm/Assembler.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -123,7 +123,7 @@
         return codeBuffer.getInt(pos);
     }
 
-    private static final String NEWLINE = System.getProperty("line.separator");
+    private static final String NEWLINE = System.lineSeparator();
 
     /**
      * Some GPU architectures have a text based encoding.
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64ArithmeticLIRGenerator.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64ArithmeticLIRGenerator.java	Tue Apr 09 11:48:54 2019 +0100
@@ -62,11 +62,26 @@
 
 public class AArch64ArithmeticLIRGenerator extends ArithmeticLIRGenerator implements AArch64ArithmeticLIRGeneratorTool {
 
+    public AArch64ArithmeticLIRGenerator(AllocatableValue nullRegisterValue) {
+        this.nullRegisterValue = nullRegisterValue;
+    }
+
+    private final AllocatableValue nullRegisterValue;
+
     @Override
     public AArch64LIRGenerator getLIRGen() {
         return (AArch64LIRGenerator) super.getLIRGen();
     }
 
+    public boolean mustReplaceNullWithNullRegister(JavaConstant nullConstant) {
+        /* Uncompressed null pointers only */
+        return nullRegisterValue != null && JavaConstant.NULL_POINTER.equals(nullConstant);
+    }
+
+    public AllocatableValue getNullRegisterValue() {
+        return nullRegisterValue;
+    }
+
     @Override
     protected boolean isNumericInteger(PlatformKind kind) {
         return ((AArch64Kind) kind).isInteger();
@@ -485,11 +500,6 @@
     }
 
     @Override
-    public void emitCompareOp(AArch64Kind cmpKind, Variable left, Value right) {
-        throw GraalError.unimplemented();
-    }
-
-    @Override
     public Value emitRound(Value value, RoundingMode mode) {
         AArch64ArithmeticOp op;
         switch (mode) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64LIRGenerator.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64LIRGenerator.java	Tue Apr 09 11:48:54 2019 +0100
@@ -164,7 +164,7 @@
     public Variable emitValueCompareAndSwap(LIRKind accessKind, Value address, Value expectedValue, Value newValue) {
         Variable result = newVariable(newValue.getValueKind());
         Variable scratch = newVariable(LIRKind.value(AArch64Kind.WORD));
-        append(new CompareAndSwapOp(result, loadNonCompareConst(expectedValue), loadReg(newValue), asAllocatable(address), scratch));
+        append(new CompareAndSwapOp(result, loadReg(expectedValue), loadReg(newValue), asAllocatable(address), scratch));
         return result;
     }
 
@@ -238,8 +238,13 @@
      *         null.
      */
     @Override
-    public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
-        boolean mirrored = emitCompare(cmpKind, left, right, cond, unorderedIsTrue);
+    public Variable emitConditionalMove(PlatformKind cmpKind, Value left, final Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
+        AArch64ArithmeticLIRGenerator arithLir = ((AArch64ArithmeticLIRGenerator) arithmeticLIRGen);
+        Value actualRight = right;
+        if (isJavaConstant(actualRight) && arithLir.mustReplaceNullWithNullRegister((asJavaConstant(actualRight)))) {
+            actualRight = arithLir.getNullRegisterValue();
+        }
+        boolean mirrored = emitCompare(cmpKind, left, actualRight, cond, unorderedIsTrue);
         Condition finalCondition = mirrored ? cond.mirror() : cond;
         boolean finalUnorderedIsTrue = mirrored ? !unorderedIsTrue : unorderedIsTrue;
         ConditionFlag cmpCondition = toConditionFlag(((AArch64Kind) cmpKind).isInteger(), finalCondition, finalUnorderedIsTrue);
@@ -256,30 +261,38 @@
     }
 
     @Override
-    public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination,
+    public void emitCompareBranch(PlatformKind cmpKind, Value left, final Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination,
                     double trueDestinationProbability) {
+        Value actualRight = right;
         if (cond == Condition.EQ) {
             // emit cbz instruction for IsNullNode.
             assert !LIRValueUtil.isNullConstant(left) : "emitNullCheckBranch()'s null input should be in right.";
-            if (LIRValueUtil.isNullConstant(right)) {
-                append(new CompareBranchZeroOp(asAllocatable(left), trueDestination, falseDestination, trueDestinationProbability));
-                return;
+            AArch64ArithmeticLIRGenerator arithLir = ((AArch64ArithmeticLIRGenerator) arithmeticLIRGen);
+            if (LIRValueUtil.isNullConstant(actualRight)) {
+                JavaConstant rightConstant = asJavaConstant(actualRight);
+                if (arithLir.mustReplaceNullWithNullRegister(rightConstant)) {
+                    actualRight = arithLir.getNullRegisterValue();
+                } else {
+                    append(new CompareBranchZeroOp(asAllocatable(left), trueDestination, falseDestination,
+                                    trueDestinationProbability));
+                    return;
+                }
             }
 
             // emit cbz instruction for IntegerEquals when any of the inputs is zero.
             AArch64Kind kind = (AArch64Kind) cmpKind;
             if (kind.isInteger()) {
                 if (isIntConstant(left, 0)) {
-                    append(new CompareBranchZeroOp(asAllocatable(right), trueDestination, falseDestination, trueDestinationProbability));
+                    append(new CompareBranchZeroOp(asAllocatable(actualRight), trueDestination, falseDestination, trueDestinationProbability));
                     return;
-                } else if (isIntConstant(right, 0)) {
+                } else if (isIntConstant(actualRight, 0)) {
                     append(new CompareBranchZeroOp(asAllocatable(left), trueDestination, falseDestination, trueDestinationProbability));
                     return;
                 }
             }
         }
 
-        boolean mirrored = emitCompare(cmpKind, left, right, cond, unorderedIsTrue);
+        boolean mirrored = emitCompare(cmpKind, left, actualRight, cond, unorderedIsTrue);
         Condition finalCondition = mirrored ? cond.mirror() : cond;
         boolean finalUnorderedIsTrue = mirrored ? !unorderedIsTrue : unorderedIsTrue;
         ConditionFlag cmpCondition = toConditionFlag(((AArch64Kind) cmpKind).isInteger(), finalCondition, finalUnorderedIsTrue);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.amd64.test/src/org/graalvm/compiler/core/amd64/test/AMD64MatchRuleTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.amd64.test/src/org/graalvm/compiler/core/amd64/test/AMD64MatchRuleTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -26,14 +26,19 @@
 
 import static org.junit.Assume.assumeTrue;
 
+import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
 import org.graalvm.compiler.core.test.MatchRuleTest;
 import org.graalvm.compiler.lir.LIR;
 import org.graalvm.compiler.lir.LIRInstruction;
+import org.graalvm.compiler.lir.amd64.AMD64Binary;
 import org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer.MemoryConstOp;
+import org.graalvm.compiler.lir.amd64.AMD64BinaryConsumer.ConstOp;
+import org.graalvm.compiler.lir.amd64.AMD64Unary;
 import org.junit.Before;
 import org.junit.Test;
 
 import jdk.vm.ci.amd64.AMD64;
+import jdk.vm.ci.amd64.AMD64Kind;
 
 public class AMD64MatchRuleTest extends MatchRuleTest {
     @Before
@@ -77,4 +82,182 @@
             this.x = x;
         }
     }
+
+    static volatile short shortValue;
+
+    public static long testVolatileExtensionSnippet() {
+        return shortValue;
+    }
+
+    @Test
+    public void testVolatileExtension() {
+        compile(getResolvedJavaMethod("testVolatileExtensionSnippet"), null);
+        LIR lir = getLIR();
+        boolean found = false;
+        for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
+            if (ins instanceof AMD64Unary.MemoryOp) {
+                ins.visitEachOutput((value, mode, flags) -> assertTrue(value.getPlatformKind().toString(), value.getPlatformKind().equals(AMD64Kind.QWORD)));
+                assertFalse("MemoryOp expected only once in first block", found);
+                found = true;
+            }
+        }
+        assertTrue("sign extending load must be in the LIR", found);
+    }
+
+    static int intValue;
+    static volatile int volatileIntValue;
+
+    /**
+     * Can't match test and load of input because of volatile store in between.
+     */
+    public static short testLoadTestNoMatchSnippet() {
+        int v = intValue;
+        volatileIntValue = 42;
+        if (v == 42) {
+            return shortValue;
+        }
+        return 0;
+    }
+
+    @Test
+    public void testLoadTestNoMatch() {
+        compile(getResolvedJavaMethod("testLoadTestNoMatchSnippet"), null);
+        LIR lir = getLIR();
+        boolean found = false;
+        for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
+            if (ins instanceof ConstOp && ((ConstOp) ins).getOpcode().toString().equals("CMP")) {
+                assertFalse("CMP expected only once in first block", found);
+                found = true;
+            }
+        }
+        assertTrue("CMP must be in the LIR", found);
+    }
+
+    /**
+     * Should match as an add with a memory operand.
+     */
+    public static int testAddLoadSnippet() {
+        int v1 = volatileIntValue;
+        int v2 = intValue;
+        return v2 + (2 * v1);
+    }
+
+    @Test
+    public void testAddLoad() {
+        compile(getResolvedJavaMethod("testAddLoadSnippet"), null);
+        LIR lir = getLIR();
+        boolean found = false;
+        for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
+            if (ins instanceof AMD64Binary.MemoryTwoOp && ((AMD64Binary.MemoryTwoOp) ins).getOpcode().toString().equals("ADD")) {
+                assertFalse("MemoryTwoOp expected only once in first block", found);
+                found = true;
+            }
+        }
+        assertTrue("ADD with memory argument must be in the LIR", found);
+    }
+
+    /**
+     * Can't match as an add with a memory operand because the other add input is too late.
+     */
+    public static int testAddLoadNoMatchSnippet() {
+        int v1 = volatileIntValue;
+        int v2 = intValue;
+        return v1 + (2 * v2);
+    }
+
+    @Test
+    public void testAddLoadNoMatch() {
+        compile(getResolvedJavaMethod("testAddLoadNoMatchSnippet"), null);
+        LIR lir = getLIR();
+        boolean found = false;
+        for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
+            if (ins instanceof AMD64Binary.CommutativeTwoOp && ((AMD64Binary.CommutativeTwoOp) ins).getOpcode().toString().equals("ADD")) {
+                assertFalse("CommutativeTwoOp expected only once in first block", found);
+                found = true;
+            }
+        }
+        assertTrue("ADD with memory argument must not be in the LIR", found);
+    }
+
+    /**
+     * sign extension and load are in different blocks but can still be matched as a single
+     * instruction.
+     */
+    public static long testVolatileExtensionDifferentBlocksSnippet(boolean flag) {
+        short v = shortValue;
+        if (flag) {
+            return v;
+        }
+        return 0;
+    }
+
+    @Test
+    public void testVolatileExtensionDifferentBlocks() {
+        compile(getResolvedJavaMethod("testVolatileExtensionDifferentBlocksSnippet"), null);
+        LIR lir = getLIR();
+        boolean found = false;
+        for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
+            if (ins instanceof AMD64Unary.MemoryOp) {
+                ins.visitEachOutput((value, mode, flags) -> assertTrue(value.getPlatformKind().toString(), value.getPlatformKind().equals(AMD64Kind.QWORD)));
+                assertFalse("MemoryOp expected only once in first block", found);
+                found = true;
+            }
+        }
+        assertTrue("sign extending load must be in the LIR", found);
+    }
+
+    /**
+     * Add and load are not in the same block and one input is too late: can't match.
+     */
+    public static int testAddLoadDifferentBlocksNoMatchSnippet(boolean flag) {
+        int v1 = volatileIntValue;
+        if (flag) {
+            int v2 = intValue;
+            return v1 + (2 * v2);
+        }
+        return 0;
+    }
+
+    @Test
+    public void testAddLoadDifferentBlocksNoMatch() {
+        compile(getResolvedJavaMethod("testAddLoadDifferentBlocksNoMatchSnippet"), null);
+        LIR lir = getLIR();
+        boolean found = false;
+        for (AbstractBlockBase<?> b : lir.codeEmittingOrder()) {
+            for (LIRInstruction ins : lir.getLIRforBlock(b)) {
+                if (ins instanceof AMD64Binary.CommutativeTwoOp && ((AMD64Binary.CommutativeTwoOp) ins).getOpcode().toString().equals("ADD")) {
+                    assertFalse("CommutativeTwoOp expected only once in first block", found);
+                    found = true;
+                }
+            }
+        }
+        assertTrue("ADD with memory argument must not be in the LIR", found);
+    }
+
+    /**
+     * Add and load are in different blocks but can still match.
+     */
+    public static int testAddLoadDifferentBlocksSnippet(boolean flag) {
+        int v2 = intValue;
+        int v1 = volatileIntValue;
+        if (flag) {
+            return v1 + v2;
+        }
+        return 0;
+    }
+
+    @Test
+    public void testAddLoadDifferentBlocks() {
+        compile(getResolvedJavaMethod("testAddLoadDifferentBlocksSnippet"), null);
+        LIR lir = getLIR();
+        boolean found = false;
+        for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
+            if (ins instanceof AMD64Binary.MemoryTwoOp && ((AMD64Binary.MemoryTwoOp) ins).getOpcode().toString().equals("ADD")) {
+                assertFalse("MemoryTwoOp expected only once in first block", found);
+                found = true;
+            }
+        }
+        assertTrue("ADD with memory argument must be in the LIR", found);
+    }
+
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.amd64/src/org/graalvm/compiler/core/amd64/AMD64ArithmeticLIRGenerator.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.amd64/src/org/graalvm/compiler/core/amd64/AMD64ArithmeticLIRGenerator.java	Tue Apr 09 11:48:54 2019 +0100
@@ -689,10 +689,9 @@
                 getLIRGen().append(new AMD64Unary.MOp(op.m1Op, size, result, input));
             } else {
                 /*
-                 * c is implicitly masked to 5 or 6 bits by the CPU, so casting it to (int) is
-                 * always correct, even without the NumUtil.is32bit() test.
+                 * c needs to be masked here, because shifts with immediate expect a byte.
                  */
-                getLIRGen().append(new AMD64Binary.ConstOp(op.miOp, size, result, input, (int) c.asLong()));
+                getLIRGen().append(new AMD64Binary.ConstOp(op.miOp, size, result, input, (byte) c.asLong()));
             }
         } else {
             getLIRGen().emitMove(RCX_I, b);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/Fields.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/Fields.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,7 @@
 
 package org.graalvm.compiler.core.common;
 
-import static org.graalvm.compiler.core.common.UnsafeAccess.UNSAFE;
+import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -38,6 +38,8 @@
  */
 public class Fields {
 
+    private static final Unsafe UNSAFE = getUnsafe();
+
     /**
      * Offsets used with {@link Unsafe} to access the fields.
      */
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/FieldsScanner.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/FieldsScanner.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,7 @@
 
 package org.graalvm.compiler.core.common;
 
-import static org.graalvm.compiler.core.common.UnsafeAccess.UNSAFE;
+import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
@@ -50,6 +50,8 @@
      */
     public static class DefaultCalcOffset implements CalcOffset {
 
+        private static final Unsafe UNSAFE = getUnsafe();
+
         @Override
         public long getOffset(Field field) {
             return UNSAFE.objectFieldOffset(field);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/GraalOptions.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/GraalOptions.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -278,4 +278,8 @@
 
     @Option(help = "Enable inlining decision tracing in stubs and snippets.", type = OptionType.Debug)
     public static final OptionKey<Boolean> TraceInliningForStubsAndSnippets = new OptionKey<>(false);
+
+    @Option(help = "Use Graal-generated stubs for complicated LIR operations instead of embedding all the emitted code.")
+    public static final OptionKey<Boolean> UseGraalStubs = new OptionKey<>(true);
+
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/UnsafeAccess.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, 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
- * 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 org.graalvm.compiler.core.common;
-
-import java.lang.reflect.Field;
-
-import sun.misc.Unsafe;
-
-/**
- * Package private access to the {@link Unsafe} capability.
- */
-class UnsafeAccess {
-
-    static final Unsafe UNSAFE = initUnsafe();
-
-    private static Unsafe initUnsafe() {
-        try {
-            // Fast path when we are trusted.
-            return Unsafe.getUnsafe();
-        } catch (SecurityException se) {
-            // Slow path when we are not trusted.
-            try {
-                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                return (Unsafe) theUnsafe.get(Unsafe.class);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to get Unsafe", e);
-            }
-        }
-    }
-}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsafeAccess.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, 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
- * 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 org.graalvm.compiler.core.common.util;
-
-import java.lang.reflect.Field;
-
-import sun.misc.Unsafe;
-
-/**
- * Package private access to the {@link Unsafe} capability.
- */
-class UnsafeAccess {
-
-    static final Unsafe UNSAFE = initUnsafe();
-
-    private static Unsafe initUnsafe() {
-        try {
-            // Fast path when we are trusted.
-            return Unsafe.getUnsafe();
-        } catch (SecurityException se) {
-            // Slow path when we are not trusted.
-            try {
-                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                return (Unsafe) theUnsafe.get(Unsafe.class);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to get Unsafe", e);
-            }
-        }
-    }
-}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsafeArrayTypeReader.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsafeArrayTypeReader.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,8 @@
 
 package org.graalvm.compiler.core.common.util;
 
-import static org.graalvm.compiler.core.common.util.UnsafeAccess.UNSAFE;
+import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe;
+
 import sun.misc.Unsafe;
 
 /**
@@ -41,6 +42,8 @@
  */
 public abstract class UnsafeArrayTypeReader implements TypeReader {
 
+    private static final Unsafe UNSAFE = getUnsafe();
+
     public static int getS1(byte[] data, long byteIndex) {
         return UNSAFE.getByte(data, readOffset(data, byteIndex, Byte.BYTES));
     }
@@ -142,6 +145,8 @@
 }
 
 final class UnalignedUnsafeArrayTypeReader extends UnsafeArrayTypeReader {
+    private static final Unsafe UNSAFE = getUnsafe();
+
     protected static int getS2(byte[] data, long byteIndex) {
         return UNSAFE.getShort(data, readOffset(data, byteIndex, Short.BYTES));
     }
@@ -181,6 +186,8 @@
 }
 
 class AlignedUnsafeArrayTypeReader extends UnsafeArrayTypeReader {
+    private static final Unsafe UNSAFE = getUnsafe();
+
     protected static int getS2(byte[] data, long byteIndex) {
         long offset = readOffset(data, byteIndex, Short.BYTES);
         return ((UNSAFE.getByte(data, offset + 0) & 0xFF) << 0) | //
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsafeArrayTypeWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/UnsafeArrayTypeWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -30,6 +30,8 @@
 import static org.graalvm.compiler.core.common.util.TypeConversion.asU1;
 import static org.graalvm.compiler.core.common.util.TypeConversion.asU2;
 import static org.graalvm.compiler.core.common.util.TypeConversion.asU4;
+import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe;
+
 import sun.misc.Unsafe;
 
 /**
@@ -44,6 +46,7 @@
  */
 public abstract class UnsafeArrayTypeWriter implements TypeWriter {
 
+    private static final Unsafe UNSAFE = getUnsafe();
     private static final int MIN_CHUNK_LENGTH = 200;
     private static final int MAX_CHUNK_LENGTH = 16000;
 
@@ -96,13 +99,13 @@
     @Override
     public final void putS1(long value) {
         long offset = writeOffset(Byte.BYTES);
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset, asS1(value));
+        UNSAFE.putByte(writeChunk.data, offset, asS1(value));
     }
 
     @Override
     public final void putU1(long value) {
         long offset = writeOffset(Byte.BYTES);
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset, asU1(value));
+        UNSAFE.putByte(writeChunk.data, offset, asU1(value));
     }
 
     @Override
@@ -134,52 +137,56 @@
 }
 
 final class UnalignedUnsafeArrayTypeWriter extends UnsafeArrayTypeWriter {
+    private static final Unsafe UNSAFE = getUnsafe();
+
     @Override
     public void putS2(long value) {
         long offset = writeOffset(Short.BYTES);
-        UnsafeAccess.UNSAFE.putShort(writeChunk.data, offset, asS2(value));
+        UNSAFE.putShort(writeChunk.data, offset, asS2(value));
     }
 
     @Override
     public void putS4(long value) {
         long offset = writeOffset(Integer.BYTES);
-        UnsafeAccess.UNSAFE.putInt(writeChunk.data, offset, asS4(value));
+        UNSAFE.putInt(writeChunk.data, offset, asS4(value));
     }
 
     @Override
     public void putS8(long value) {
         long offset = writeOffset(Long.BYTES);
-        UnsafeAccess.UNSAFE.putLong(writeChunk.data, offset, value);
+        UNSAFE.putLong(writeChunk.data, offset, value);
     }
 }
 
 final class AlignedUnsafeArrayTypeWriter extends UnsafeArrayTypeWriter {
+    private static final Unsafe UNSAFE = getUnsafe();
+
     @Override
     public void putS2(long value) {
         long offset = writeOffset(Short.BYTES);
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 0, (byte) (value >> 0));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 1, (byte) (value >> 8));
+        UNSAFE.putByte(writeChunk.data, offset + 0, (byte) (value >> 0));
+        UNSAFE.putByte(writeChunk.data, offset + 1, (byte) (value >> 8));
     }
 
     @Override
     public void putS4(long value) {
         long offset = writeOffset(Integer.BYTES);
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 0, (byte) (value >> 0));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 1, (byte) (value >> 8));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 2, (byte) (value >> 16));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 3, (byte) (value >> 24));
+        UNSAFE.putByte(writeChunk.data, offset + 0, (byte) (value >> 0));
+        UNSAFE.putByte(writeChunk.data, offset + 1, (byte) (value >> 8));
+        UNSAFE.putByte(writeChunk.data, offset + 2, (byte) (value >> 16));
+        UNSAFE.putByte(writeChunk.data, offset + 3, (byte) (value >> 24));
     }
 
     @Override
     public void putS8(long value) {
         long offset = writeOffset(Long.BYTES);
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 0, (byte) (value >> 0));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 1, (byte) (value >> 8));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 2, (byte) (value >> 16));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 3, (byte) (value >> 24));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 4, (byte) (value >> 32));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 5, (byte) (value >> 40));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 6, (byte) (value >> 48));
-        UnsafeAccess.UNSAFE.putByte(writeChunk.data, offset + 7, (byte) (value >> 56));
+        UNSAFE.putByte(writeChunk.data, offset + 0, (byte) (value >> 0));
+        UNSAFE.putByte(writeChunk.data, offset + 1, (byte) (value >> 8));
+        UNSAFE.putByte(writeChunk.data, offset + 2, (byte) (value >> 16));
+        UNSAFE.putByte(writeChunk.data, offset + 3, (byte) (value >> 24));
+        UNSAFE.putByte(writeChunk.data, offset + 4, (byte) (value >> 32));
+        UNSAFE.putByte(writeChunk.data, offset + 5, (byte) (value >> 40));
+        UNSAFE.putByte(writeChunk.data, offset + 6, (byte) (value >> 48));
+        UNSAFE.putByte(writeChunk.data, offset + 7, (byte) (value >> 56));
     }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.match.processor/src/org/graalvm/compiler/core/match/processor/MatchProcessor.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.match.processor/src/org/graalvm/compiler/core/match/processor/MatchProcessor.java	Tue Apr 09 11:48:54 2019 +0100
@@ -348,9 +348,15 @@
          */
         final boolean shareable;
 
+        /**
+         * Can this node be subsumed into a match even if there are side effecting nodes between
+         * this node and the match.
+         */
+        final boolean ignoresSideEffects;
+
         final Set<Element> originatingElements = new HashSet<>();
 
-        TypeDescriptor(TypeMirror mirror, String shortName, String nodeClass, String nodePackage, List<String> inputs, boolean commutative, boolean shareable) {
+        TypeDescriptor(TypeMirror mirror, String shortName, String nodeClass, String nodePackage, List<String> inputs, boolean commutative, boolean shareable, boolean ignoresSideEffects) {
             this.mirror = mirror;
             this.shortName = shortName;
             this.nodeClass = nodeClass;
@@ -358,6 +364,7 @@
             this.inputs = inputs;
             this.commutative = commutative;
             this.shareable = shareable;
+            this.ignoresSideEffects = ignoresSideEffects;
             assert !commutative || inputs.size() == 2;
         }
     }
@@ -369,8 +376,9 @@
 
     private TypeDescriptor valueType;
 
-    private void declareType(TypeMirror mirror, String shortName, String nodeClass, String nodePackage, List<String> inputs, boolean commutative, boolean shareable, Element element) {
-        TypeDescriptor descriptor = new TypeDescriptor(mirror, shortName, nodeClass, nodePackage, inputs, commutative, shareable);
+    private void declareType(TypeMirror mirror, String shortName, String nodeClass, String nodePackage, List<String> inputs, boolean commutative, boolean shareable, boolean ignoresSideEffects,
+                    Element element) {
+        TypeDescriptor descriptor = new TypeDescriptor(mirror, shortName, nodeClass, nodePackage, inputs, commutative, shareable, ignoresSideEffects);
         descriptor.originatingElements.add(element);
         knownTypes.put(shortName, descriptor);
     }
@@ -453,7 +461,7 @@
 
         private String formatPrefix() {
             if (nodeType == valueType) {
-                return String.format("new MatchPattern(%s, false", name != null ? ("\"" + name + "\"") : "null");
+                return String.format("new MatchPattern(%s, false, false", name != null ? ("\"" + name + "\"") : "null");
             } else {
                 return String.format("new MatchPattern(%s.class, %s", nodeType.nodeClass, name != null ? ("\"" + name + "\"") : "null");
             }
@@ -462,13 +470,13 @@
         private String formatSuffix() {
             if (nodeType != null) {
                 if (inputs.length != nodeType.inputs.size()) {
-                    return ", true)";
+                    return ", true, " + nodeType.ignoresSideEffects + ")";
                 } else {
                     if (nodeType.inputs.size() > 0) {
-                        return ", " + nodeType.nodeClass + "_positions, " + !nodeType.shareable + ")";
+                        return ", " + nodeType.nodeClass + "_positions, " + !nodeType.shareable + ", " + nodeType.ignoresSideEffects + ")";
                     }
                     if (nodeType.shareable) {
-                        return ", false)";
+                        return ", false, " + nodeType.ignoresSideEffects + ")";
                     }
                 }
             }
@@ -721,7 +729,7 @@
             // Define a TypeDescriptor for the generic node but don't enter it into the nodeTypes
             // table since it shouldn't be mentioned in match rules.
             TypeMirror valueTypeMirror = getTypeElement(VALUE_NODE_CLASS_NAME).asType();
-            valueType = new TypeDescriptor(valueTypeMirror, "Value", "ValueNode", "org.graalvm.compiler.nodes", Collections.emptyList(), false, false);
+            valueType = new TypeDescriptor(valueTypeMirror, "Value", "ValueNode", "org.graalvm.compiler.nodes", Collections.emptyList(), false, false, false);
 
             Map<TypeElement, MatchRuleDescriptor> map = new HashMap<>();
 
@@ -831,7 +839,8 @@
 
         boolean commutative = getAnnotationValue(matchable, "commutative", Boolean.class);
         boolean shareable = getAnnotationValue(matchable, "shareable", Boolean.class);
-        declareType(nodeClassMirror, shortName, nodeClass, nodePackage, inputs, commutative, shareable, element);
+        boolean ignoresSideEffects = getAnnotationValue(matchable, "ignoresSideEffects", Boolean.class);
+        declareType(nodeClassMirror, shortName, nodeClass, nodePackage, inputs, commutative, shareable, ignoresSideEffects, element);
     }
 
     private void processMatchRules(Map<TypeElement, MatchRuleDescriptor> map, Element element, List<AnnotationMirror> matchRules) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/CheckGraalInvariants.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/CheckGraalInvariants.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -32,6 +32,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
@@ -266,9 +267,11 @@
         verifiers.add(new VerifyVirtualizableUsage());
         verifiers.add(new VerifyUpdateUsages());
         verifiers.add(new VerifyBailoutUsage());
+        verifiers.add(new VerifySystemPropertyUsage());
         verifiers.add(new VerifyInstanceOfUsage());
         verifiers.add(new VerifyGraphAddUsage());
         verifiers.add(new VerifyGetOptionsUsage());
+        verifiers.add(new VerifyUnsafeAccess());
 
         VerifyFoldableMethods foldableMethodsVerifier = new VerifyFoldableMethods();
         if (tool.shouldVerifyFoldableMethods()) {
@@ -301,21 +304,29 @@
                 String className = c.getName();
                 executor.execute(() -> {
                     try {
-                        checkClass(c, metaAccess);
+                        checkClass(c, metaAccess, verifiers);
                     } catch (Throwable e) {
                         errors.add(String.format("Error while checking %s:%n%s", className, printStackTraceToString(e)));
                     }
                 });
 
-                for (Method m : c.getDeclaredMethods()) {
-                    if (Modifier.isNative(m.getModifiers()) || Modifier.isAbstract(m.getModifiers())) {
+                ResolvedJavaType type = metaAccess.lookupJavaType(c);
+                List<ResolvedJavaMethod> methods = new ArrayList<>();
+                methods.addAll(Arrays.asList(type.getDeclaredMethods()));
+                methods.addAll(Arrays.asList(type.getDeclaredConstructors()));
+                ResolvedJavaMethod clinit = type.getClassInitializer();
+                if (clinit != null) {
+                    methods.add(clinit);
+                }
+
+                for (ResolvedJavaMethod method : methods) {
+                    if (Modifier.isNative(method.getModifiers()) || Modifier.isAbstract(method.getModifiers())) {
                         // ignore
                     } else {
-                        String methodName = className + "." + m.getName();
+                        String methodName = className + "." + method.getName();
                         if (matches(filters, methodName)) {
                             executor.execute(() -> {
                                 try (DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER)) {
-                                    ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
                                     boolean isSubstitution = method.getAnnotation(Snippet.class) != null || method.getAnnotation(MethodSubstitution.class) != null;
                                     StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).setIsSubstitution(isSubstitution).build();
                                     try (DebugCloseable s = debug.disableIntercept(); DebugContext.Scope ds = debug.scope("CheckingGraph", graph, method)) {
@@ -400,14 +411,18 @@
 
     /**
      * @param metaAccess
+     * @param verifiers
      */
-    private static void checkClass(Class<?> c, MetaAccessProvider metaAccess) {
+    private static void checkClass(Class<?> c, MetaAccessProvider metaAccess, List<VerifyPhase<PhaseContext>> verifiers) {
         if (Node.class.isAssignableFrom(c)) {
             if (c.getAnnotation(NodeInfo.class) == null) {
                 throw new AssertionError(String.format("Node subclass %s requires %s annotation", c.getName(), NodeClass.class.getSimpleName()));
             }
             VerifyNodeCosts.verifyNodeClass(c);
         }
+        for (VerifyPhase<PhaseContext> verifier : verifiers) {
+            verifier.verifyClass(c, metaAccess);
+        }
     }
 
     private static void checkMethod(ResolvedJavaMethod method) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/FinalizableSubclassTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/FinalizableSubclassTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -77,8 +77,7 @@
         StructuredGraph graph = new StructuredGraph.Builder(options, getDebugContext(options, null, javaMethod), allowAssumptions).method(javaMethod).build();
 
         GraphBuilderConfiguration conf = GraphBuilderConfiguration.getSnippetDefault(getDefaultGraphBuilderPlugins());
-        new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), getProviders().getConstantReflection(), getProviders().getConstantFieldProvider(), conf,
-                        OptimisticOptimizations.ALL, null).apply(graph);
+        new GraphBuilderPhase.Instance(getProviders(), conf, OptimisticOptimizations.ALL, null).apply(graph);
         HighTierContext context = new HighTierContext(getProviders(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
         createInliningPhase().apply(graph, context);
         new CanonicalizerPhase().apply(graph, context);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/NewInstanceTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/NewInstanceTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -76,8 +76,7 @@
         StructuredGraph graph = new StructuredGraph.Builder(options, getDebugContext(options, null, javaMethod), AllowAssumptions.YES).method(javaMethod).build();
 
         GraphBuilderConfiguration conf = GraphBuilderConfiguration.getSnippetDefault(getDefaultGraphBuilderPlugins()).withUnresolvedIsError(false);
-        new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), getProviders().getConstantReflection(), getProviders().getConstantFieldProvider(), conf,
-                        OptimisticOptimizations.ALL, null).apply(graph);
+        new GraphBuilderPhase.Instance(getProviders(), conf, OptimisticOptimizations.ALL, null).apply(graph);
         return graph;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/SwitchTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,55 @@
+/*
+ * 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 org.graalvm.compiler.core.test;
+
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+import org.junit.Test;
+
+// Regression test for JDK-8220643 (GR-14583)
+public class SwitchTest extends GraalCompilerTest {
+    public static boolean test1(int arg) {
+        switch (arg) {
+            case -2139290527:
+            case -1466249004:
+            case -1063407861:
+            case 125135499:
+            case 425995464:
+            case 786490581:
+            case 1180611932:
+            case 1790655921:
+            case 1970660086:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    @Test
+    public void run1() throws Throwable {
+        ResolvedJavaMethod method = getResolvedJavaMethod("test1");
+        Result compiled = executeActual(method, null, -2139290527);
+        assertEquals(new Result(true, null), compiled);
+    }
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/UnbalancedMonitorsTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/UnbalancedMonitorsTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -94,7 +94,7 @@
             GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
             OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
 
-            GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), null, null, graphBuilderConfig, optimisticOpts, null);
+            GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(getProviders(), graphBuilderConfig, optimisticOpts, null);
             graphBuilder.apply(graph);
         } catch (BailoutException e) {
             if (e.getMessage().contains("unbalanced monitors")) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyBailoutUsage.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyBailoutUsage.java	Tue Apr 09 11:48:54 2019 +0100
@@ -73,7 +73,7 @@
     }
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         final ResolvedJavaType bailoutType = context.getMetaAccess().lookupJavaType(BailoutException.class);
         ResolvedJavaMethod caller = graph.method();
         String holderQualified = caller.format("%H");
@@ -92,7 +92,6 @@
                 }
             }
         }
-        return true;
     }
 
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyCallerSensitiveMethods.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyCallerSensitiveMethods.java	Tue Apr 09 11:48:54 2019 +0100
@@ -67,7 +67,7 @@
     }
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         Invoke invoke = callsReflectionGetCallerClass(graph, context);
         Annotation annotation = graph.method().getAnnotation(callerSensitiveClass);
         if (invoke != null) {
@@ -79,7 +79,6 @@
         } else if (annotation != null) {
             throw new VerificationError(String.format("%s: method annotated with @CallerSensitive does not call Reflection.getCallerClass()", graph.method().format("%H.%n(%p)")));
         }
-        return true;
     }
 
     private Invoke callsReflectionGetCallerClass(StructuredGraph graph, PhaseContext context) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyDebugUsage.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyDebugUsage.java	Tue Apr 09 11:48:54 2019 +0100
@@ -78,7 +78,7 @@
     MetaAccessProvider metaAccess;
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         metaAccess = context.getMetaAccess();
         ResolvedJavaType debugType = metaAccess.lookupJavaType(DebugContext.class);
         ResolvedJavaType nodeType = metaAccess.lookupJavaType(Node.class);
@@ -108,7 +108,6 @@
                 }
             }
         }
-        return true;
     }
 
     private void verifyParameters(MethodCallTargetNode callTarget, StructuredGraph callerGraph, NodeInputList<? extends ValueNode> args, ResolvedJavaType stringType, int startArgIdx) {
@@ -167,6 +166,7 @@
                     "org.graalvm.compiler.phases.BasePhase.dumpAfter",
                     "org.graalvm.compiler.replacements.ReplacementsImpl$GraphMaker.makeGraph",
                     "org.graalvm.compiler.replacements.SnippetTemplate.instantiate",
+                    "org.graalvm.compiler.replacements.SnippetTemplate.<init>",
                     "org.graalvm.compiler.hotspot.SymbolicSnippetEncoder.verifySnippetEncodeDecode"));
 
     private void verifyParameters(StructuredGraph callerGraph, MethodCallTargetNode debugCallTarget, List<? extends ValueNode> args, ResolvedJavaType stringType, int startArgIdx,
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyFoldableMethods.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyFoldableMethods.java	Tue Apr 09 11:48:54 2019 +0100
@@ -52,7 +52,7 @@
     ResolvedJavaType generatedInvocationPluginType;
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         ResolvedJavaMethod method = graph.method();
         if (method.getAnnotation(Fold.class) != null) {
             foldables.putIfAbsent(method, false);
@@ -69,7 +69,6 @@
                 }
             }
         }
-        return true;
     }
 
     public void finish() {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyGetOptionsUsage.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyGetOptionsUsage.java	Tue Apr 09 11:48:54 2019 +0100
@@ -36,6 +36,7 @@
 
 import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.meta.ResolvedJavaMethod.Parameter;
 import jdk.vm.ci.meta.ResolvedJavaType;
 
 /**
@@ -55,15 +56,19 @@
     }
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         MetaAccessProvider metaAccess = context.getMetaAccess();
         ResolvedJavaType canonicalizerToolClass = metaAccess.lookupJavaType(CanonicalizerTool.class);
         boolean hasTool = false;
+        ResolvedJavaMethod method = graph.method();
         try {
-            for (ResolvedJavaMethod.Parameter parameter : graph.method().getParameters()) {
-                if (parameter.getType().getName().equals(canonicalizerToolClass.getName())) {
-                    hasTool = true;
-                    break;
+            Parameter[] parameters = method.getParameters();
+            if (parameters != null) {
+                for (ResolvedJavaMethod.Parameter parameter : parameters) {
+                    if (parameter.getType().getName().equals(canonicalizerToolClass.getName())) {
+                        hasTool = true;
+                        break;
+                    }
                 }
             }
         } catch (MalformedParametersException e) {
@@ -76,13 +81,11 @@
                 if (callee.equals(getOptionsMethod)) {
                     if (hasTool) {
                         throw new VerificationError("Must use CanonicalizerTool.getOptions() instead of Node.getOptions() in method '%s' of class '%s'.",
-                                        graph.method().getName(), graph.method().getDeclaringClass().getName());
+                                        method.getName(), method.getDeclaringClass().getName());
                     }
                 }
             }
         }
-
-        return true;
     }
 
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyGraphAddUsage.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyGraphAddUsage.java	Tue Apr 09 11:48:54 2019 +0100
@@ -66,7 +66,7 @@
     }
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         boolean allowed = false;
         for (Class<?> cls : ALLOWED_CLASSES) {
             ResolvedJavaType declaringClass = graph.method().getDeclaringClass();
@@ -85,8 +85,6 @@
                 }
             }
         }
-
-        return true;
     }
 
     private void checkNonFactory(StructuredGraph graph, EconomicSet<Node> seen, PhaseContext context, ValueNode node) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyInstanceOfUsage.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyInstanceOfUsage.java	Tue Apr 09 11:48:54 2019 +0100
@@ -53,7 +53,7 @@
     }
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         final ResolvedJavaType[] bailoutType = new ResolvedJavaType[FORBIDDEN_INSTANCE_OF_CHECKS.length];
         for (int i = 0; i < FORBIDDEN_INSTANCE_OF_CHECKS.length; i++) {
             bailoutType[i] = context.getMetaAccess().lookupJavaType(FORBIDDEN_INSTANCE_OF_CHECKS[i]);
@@ -77,7 +77,6 @@
                 }
             }
         }
-        return true;
     }
 
     private static boolean isTrustedInterface(ResolvedJavaType declaringClass, MetaAccessProvider metaAccess) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifySystemPropertyUsage.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,125 @@
+/*
+ * 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 org.graalvm.compiler.core.test;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.graalvm.compiler.nodes.StructuredGraph;
+import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
+import org.graalvm.compiler.phases.VerifyPhase;
+import org.graalvm.compiler.phases.tiers.PhaseContext;
+
+import jdk.vm.ci.meta.MetaAccessProvider;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.meta.ResolvedJavaType;
+import jdk.vm.ci.services.Services;
+
+/**
+ * Checks against calls to {@link System#getProperty(String)},
+ * {@link System#getProperty(String, String)} and {@link System#getProperties()}. System properties
+ * can be modified by application code so {@link Services#getSavedProperties()} should be used
+ * instead.
+ */
+public class VerifySystemPropertyUsage extends VerifyPhase<PhaseContext> {
+
+    static final Class<?>[] BOXES = {Integer.class, Long.class, Boolean.class, Float.class, Double.class};
+    static final int JVMCI_VERSION_MAJOR;
+    static final int JVMCI_VERSION_MINOR;
+    static {
+        int major = -1;
+        int minor = -1;
+        String vmVersion = System.getProperty("java.vm.version");
+        if (System.getProperty("java.specification.version").compareTo("1.9") < 0) {
+            Pattern re = Pattern.compile(".*-jvmci-(\\d+)\\.(\\d+).*");
+            Matcher matcher = re.matcher(vmVersion);
+            if (matcher.matches()) {
+                major = Integer.parseInt(matcher.group(1));
+                minor = Integer.parseInt(matcher.group(2));
+            }
+        }
+        JVMCI_VERSION_MAJOR = major;
+        JVMCI_VERSION_MINOR = minor;
+    }
+
+    @Override
+    protected void verify(StructuredGraph graph, PhaseContext context) {
+        MetaAccessProvider metaAccess = context.getMetaAccess();
+        final ResolvedJavaType systemType = metaAccess.lookupJavaType(System.class);
+        final ResolvedJavaType[] boxTypes = new ResolvedJavaType[BOXES.length];
+        for (int i = 0; i < boxTypes.length; i++) {
+            boxTypes[i] = metaAccess.lookupJavaType(BOXES[i]);
+        }
+
+        ResolvedJavaMethod caller = graph.method();
+        String holderQualified = caller.format("%H");
+        String holderUnqualified = caller.format("%h");
+        String packageName = holderQualified.equals(holderUnqualified) ? "" : holderQualified.substring(0, holderQualified.length() - holderUnqualified.length() - 1);
+        if (packageName.startsWith("jdk.vm.ci")) {
+            if (JVMCI_VERSION_MAJOR >= 0 && JVMCI_VERSION_MINOR > 56) {
+                // This JVMCI version should not use non-saved system properties
+            } else {
+                // This JVMCI version still has some calls that need to be removed
+                return;
+            }
+        } else if (holderQualified.equals("org.graalvm.compiler.hotspot.JVMCIVersionCheck") && caller.getName().equals("main")) {
+            // The main method in JVMCIVersionCheck is only called from the shell
+            return;
+        } else if (packageName.startsWith("com.oracle.truffle") || packageName.startsWith("org.graalvm.polyglot")) {
+            // Truffle and Polyglot do not depend on JVMCI so cannot use
+            // Services.getSavedProperties()
+            return;
+        } else if (packageName.startsWith("com.oracle.svm")) {
+            // SVM must read system properties in:
+            // * its JDK substitutions to mimic required JDK semantics
+            // * native-image for config info
+            return;
+        }
+        for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
+            ResolvedJavaMethod callee = t.targetMethod();
+            if (callee.getDeclaringClass().equals(systemType)) {
+                if (callee.getName().equals("getProperty") || callee.getName().equals("getProperties")) {
+                    throw new VerificationError("Call to %s at callsite %s is prohibited. Call Services.getSavedProperties().get(String) instead.",
+                                    callee.format("%H.%n(%p)"),
+                                    caller.format("%H.%n(%p)"));
+                }
+            } else {
+                for (int i = 0; i < boxTypes.length; i++) {
+                    ResolvedJavaType boxType = boxTypes[i];
+                    if (callee.getDeclaringClass().equals(boxType)) {
+                        String simpleName = boxType.toJavaName(false);
+                        if (callee.getName().equals("get" + simpleName)) {
+                            throw new VerificationError("Call to %s at callsite %s is prohibited. Call %s.parse%s(Services.getSavedProperties().get(String)) instead.",
+                                            callee.format("%H.%n(%p)"),
+                                            caller.format("%H.%n(%p)"),
+                                            simpleName, simpleName);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyUnsafeAccess.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,116 @@
+/*
+ * 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 org.graalvm.compiler.core.test;
+
+import static java.lang.reflect.Modifier.isProtected;
+import static java.lang.reflect.Modifier.isPublic;
+
+import java.lang.reflect.Field;
+
+import org.graalvm.compiler.core.common.type.TypeReference;
+import org.graalvm.compiler.nodes.StructuredGraph;
+import org.graalvm.compiler.nodes.java.InstanceOfNode;
+import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
+import org.graalvm.compiler.phases.VerifyPhase;
+import org.graalvm.compiler.phases.tiers.PhaseContext;
+import org.graalvm.compiler.serviceprovider.GraalUnsafeAccess;
+
+import jdk.vm.ci.meta.MetaAccessProvider;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.meta.ResolvedJavaType;
+import sun.misc.Unsafe;
+
+/**
+ * Checks that the {@link Unsafe} singleton instance is only accessed via well known classes such as
+ * {@link GraalUnsafeAccess}.
+ */
+public class VerifyUnsafeAccess extends VerifyPhase<PhaseContext> {
+
+    @Override
+    protected void verify(StructuredGraph graph, PhaseContext context) {
+        MetaAccessProvider metaAccess = context.getMetaAccess();
+        final ResolvedJavaType unsafeType = metaAccess.lookupJavaType(Unsafe.class);
+
+        ResolvedJavaMethod caller = graph.method();
+        String holderQualified = caller.format("%H");
+        String holderUnqualified = caller.format("%h");
+        String packageName = holderQualified.equals(holderUnqualified) ? "" : holderQualified.substring(0, holderQualified.length() - holderUnqualified.length() - 1);
+        if ((holderQualified.equals(GraalUnsafeAccess.class.getName()) ||
+                        holderQualified.equals("jdk.vm.ci.hotspot.UnsafeAccess")) &&
+                        caller.getName().equals("initUnsafe")) {
+            // This is the blessed way access Unsafe in Graal and JVMCI
+            return;
+        } else if (packageName.startsWith("com.oracle.truffle") || packageName.startsWith("org.graalvm.compiler.truffle.runtime")) {
+            // Truffle and GraalTruffleRuntime do not depend on Graal and so cannot use
+            // GraalUnsafeAccess
+            return;
+        }
+
+        if (caller.getSignature().getReturnType(caller.getDeclaringClass()).equals(unsafeType)) {
+            if (caller.isPublic()) {
+                if (holderQualified.equals(GraalUnsafeAccess.class.getName()) && caller.getName().equals("getUnsafe")) {
+                    // pass
+                } else {
+                    throw new VerificationError("Cannot leak Unsafe from public method %s",
+                                    caller.format("%H.%n(%p)"));
+                }
+            }
+        }
+
+        for (InstanceOfNode node : graph.getNodes().filter(InstanceOfNode.class)) {
+            TypeReference typeRef = node.type();
+            if (typeRef != null) {
+                if (unsafeType.isAssignableFrom(typeRef.getType())) {
+                    throw new VerificationError("Cast to %s in %s is prohibited as it implies accessing Unsafe.theUnsafe via reflection. Use %s.getUnsafe() instead.",
+                                    unsafeType.toJavaName(),
+                                    caller.format("%H.%n(%p)"),
+                                    GraalUnsafeAccess.class.getName());
+
+                }
+            }
+        }
+        for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
+            ResolvedJavaMethod callee = t.targetMethod();
+            if (callee.getDeclaringClass().equals(unsafeType)) {
+                if (callee.getName().equals("getUnsafe")) {
+                    throw new VerificationError("Call to %s at callsite %s is prohibited. Use %s.getUnsafe() instead.",
+                                    callee.format("%H.%n(%p)"),
+                                    caller.format("%H.%n(%p)"),
+                                    GraalUnsafeAccess.class.getName());
+                }
+            }
+        }
+    }
+
+    @Override
+    public void verifyClass(Class<?> c, MetaAccessProvider metaAccess) {
+        for (Field field : c.getDeclaredFields()) {
+            int modifiers = field.getModifiers();
+            if (field.getType() == Unsafe.class && (isPublic(modifiers) || isProtected(modifiers))) {
+                throw new VerificationError("Field of type %s must be private or package-private: %s", Unsafe.class.getName(), field);
+            }
+        }
+    }
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyUpdateUsages.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyUpdateUsages.java	Tue Apr 09 11:48:54 2019 +0100
@@ -56,9 +56,9 @@
     }
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         if (graph.method().isConstructor()) {
-            return true;
+            return;
         }
         /*
          * There are only two acceptable patterns for methods which update Node inputs, either a
@@ -78,35 +78,51 @@
                 } else if (storeField2 == null) {
                     storeField2 = store;
                 } else {
-                    return false;
+                    throw new VerificationError("More than 2 stores to %s or %s fields found in %s",
+                                    Input.class.getSimpleName(),
+                                    OptionalInput.class.getSimpleName(),
+                                    graph.method().format("%H.%n(%p)"));
                 }
             }
         }
         if (storeField1 == null) {
-            return true;
+            return;
         }
         if (storeField2 == null) {
-            // Single input field update so just check for updateUsages or updateUsagesInterface
-            // call
-            ResolvedJavaType node = context.getMetaAccess().lookupJavaType(Node.class);
+            // Single input field update so just check for updateUsages
+            // or updateUsagesInterface call
+            ResolvedJavaType nodeType = context.getMetaAccess().lookupJavaType(Node.class);
             for (MethodCallTargetNode call : graph.getNodes().filter(MethodCallTargetNode.class)) {
                 ResolvedJavaMethod callee = call.targetMethod();
-                if (callee.getDeclaringClass().equals(node) && (callee.getName().equals("updateUsages") || callee.getName().equals("updateUsagesInterface"))) {
-                    return true;
+                if (callee.getDeclaringClass().equals(nodeType) && (callee.getName().equals("updateUsages") || callee.getName().equals("updateUsagesInterface"))) {
+                    return;
                 }
             }
+            throw new VerificationError("%s updates field '%s' without calling %s.updateUsages() or %s.updateUsagesInterface()",
+                            graph.method().format("%H.%n(%p)"),
+                            storeField1.field().getName(),
+                            Node.class.getName(),
+                            Node.class.getName());
         } else {
             if (storeField1.value() instanceof LoadFieldNode && storeField2.value() instanceof LoadFieldNode) {
                 LoadFieldNode load1 = (LoadFieldNode) storeField1.value();
                 LoadFieldNode load2 = (LoadFieldNode) storeField2.value();
                 // Check for swapping values within the same object
-                if (load1.object() == storeField1.object() && load2.object() == storeField2.object() && storeField1.object() == storeField2.object() &&
-                                load1.field().equals(storeField2.field()) && load2.field().equals(storeField1.field())) {
-                    return true;
+                if (load1.object() == storeField1.object() &&
+                                load2.object() == storeField2.object() &&
+                                storeField1.object() == storeField2.object() &&
+                                load1.field().equals(storeField2.field()) &&
+                                load2.field().equals(storeField1.field())) {
+                    return;
                 }
             }
+            throw new VerificationError("%s performs non-swap update to fields '%s' and '%s' without calling %s.updateUsages() or %s.updateUsagesInterface()",
+                            graph.method().format("%H.%n(%p)"),
+                            storeField1.field().getName(),
+                            storeField2.field().getName(),
+                            Node.class.getName(),
+                            Node.class.getName());
         }
-        return false;
     }
 
     boolean isNodeInput(ResolvedJavaField field, ResolvedJavaType declaringClass, ResolvedJavaType nodeInputList) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyUsageWithEquals.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyUsageWithEquals.java	Tue Apr 09 11:48:54 2019 +0100
@@ -143,7 +143,7 @@
     }
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         for (ObjectEqualsNode cn : graph.getNodes().filter(ObjectEqualsNode.class)) {
             // bail out if we compare an object of type klass with == or != (except null checks)
             ResolvedJavaMethod method = graph.method();
@@ -156,6 +156,5 @@
                                 " must use .equals() for object equality, not '==' or '!='");
             }
         }
-        return true;
     }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyVirtualizableUsage.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyVirtualizableUsage.java	Tue Apr 09 11:48:54 2019 +0100
@@ -53,7 +53,7 @@
     }
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         final ResolvedJavaType graphType = context.getMetaAccess().lookupJavaType(Graph.class);
         final ResolvedJavaType virtualizableType = context.getMetaAccess().lookupJavaType(Virtualizable.class);
         final ResolvedJavaType constantNodeType = context.getMetaAccess().lookupJavaType(ConstantNode.class);
@@ -70,7 +70,6 @@
                 }
             }
         }
-        return true;
     }
 
     private static void verifyVirtualizableEffectArguments(ResolvedJavaType constantNodeType, ResolvedJavaMethod caller, ResolvedJavaMethod callee, int bciCaller,
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/ea/EATestBase.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/ea/EATestBase.java	Tue Apr 09 11:48:54 2019 +0100
@@ -152,13 +152,17 @@
                 Assert.assertEquals(expectedConstantResult, returnNode.result().asConstant());
             }
         }
-        int newInstanceCount = graph.getNodes().filter(isA(NewInstanceNode.class).or(NewArrayNode.class).or(AllocatedObjectNode.class)).count();
+        int newInstanceCount = getAllocationCount();
         Assert.assertEquals("Expected allocation count does not match", expectedAllocationCount, newInstanceCount);
         if (expectedAllocationCount == 0) {
             Assert.assertTrue("Unexpected CommitAllocationNode", graph.getNodes().filter(CommitAllocationNode.class).isEmpty());
         }
     }
 
+    protected int getAllocationCount() {
+        return graph.getNodes().filter(isA(NewInstanceNode.class).or(NewArrayNode.class).or(AllocatedObjectNode.class)).count();
+    }
+
     @SuppressWarnings("try")
     protected void prepareGraph(String snippet, boolean iterativeEscapeAnalysis) {
         ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/tutorial/StaticAnalysis.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/tutorial/StaticAnalysis.java	Tue Apr 09 11:48:54 2019 +0100
@@ -34,8 +34,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.graalvm.compiler.debug.DebugContext;
 import org.graalvm.compiler.debug.DebugHandlersFactory;
-import org.graalvm.compiler.debug.DebugContext;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.graph.Node;
 import org.graalvm.compiler.graph.NodeMap;
@@ -58,7 +58,7 @@
 import org.graalvm.compiler.nodes.java.NewArrayNode;
 import org.graalvm.compiler.nodes.java.NewInstanceNode;
 import org.graalvm.compiler.nodes.java.StoreFieldNode;
-import org.graalvm.compiler.nodes.spi.StampProvider;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
 import org.graalvm.compiler.nodes.util.GraphUtil;
 import org.graalvm.compiler.options.OptionValues;
 import org.graalvm.compiler.phases.OptimisticOptimizations;
@@ -66,7 +66,6 @@
 
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
-import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.ResolvedJavaField;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaType;
@@ -89,18 +88,21 @@
  * {@link MethodState#formalReturn return value}.
  */
 public class StaticAnalysis {
-    /** Access to type, method, and fields using the Graal API. */
-    private final MetaAccessProvider metaAccess;
-    /** Access to platform dependent stamps. */
-    private final StampProvider stampProvider;
-    /** The results of the static analysis. */
+    /**
+     * Access to various builtin providers.
+     */
+    private final CoreProviders providers;
+    /**
+     * The results of the static analysis.
+     */
     private final Results results;
-    /** Worklist for fixpoint iteration. */
+    /**
+     * Worklist for fixpoint iteration.
+     */
     private final Deque<WorklistEntry> worklist;
 
-    public StaticAnalysis(MetaAccessProvider metaAccess, StampProvider stampProvider) {
-        this.metaAccess = metaAccess;
-        this.stampProvider = stampProvider;
+    public StaticAnalysis(CoreProviders providers) {
+        this.providers = providers;
         this.results = new Results();
         this.worklist = new ArrayDeque<>();
     }
@@ -273,7 +275,7 @@
                      */
                     OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
 
-                    GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(metaAccess, stampProvider, null, null, graphBuilderConfig, optimisticOpts, null);
+                    GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(providers, graphBuilderConfig, optimisticOpts, null);
                     graphBuilder.apply(graph);
                 } catch (Throwable ex) {
                     debug.handle(ex);
@@ -304,7 +306,9 @@
             uses = new HashSet<>();
         }
 
-        /** Returns the types of this element. */
+        /**
+         * Returns the types of this element.
+         */
         public Set<ResolvedJavaType> getTypes() {
             return types;
         }
@@ -349,7 +353,7 @@
      * Adding a new callee means linking the type flow of the actual parameters with the formal
      * parameters of the callee, and linking the return value of the callee with the return value
      * state of the invocation.
-     *
+     * <p>
      * Statically bindable methods calls ({@link InvokeKind#Static static} and
      * {@link InvokeKind#Special special} calls) have only one callee, but use the same code for
      * simplicity.
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/tutorial/StaticAnalysisTests.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/tutorial/StaticAnalysisTests.java	Tue Apr 09 11:48:54 2019 +0100
@@ -29,21 +29,18 @@
 import java.util.Arrays;
 import java.util.Collection;
 
-import jdk.vm.ci.meta.MetaAccessProvider;
-import jdk.vm.ci.meta.ResolvedJavaField;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
-import jdk.vm.ci.meta.ResolvedJavaType;
-
-import org.junit.Assert;
-import org.junit.Test;
-
 import org.graalvm.compiler.api.test.Graal;
 import org.graalvm.compiler.core.target.Backend;
 import org.graalvm.compiler.core.test.tutorial.StaticAnalysis.MethodState;
 import org.graalvm.compiler.core.test.tutorial.StaticAnalysis.TypeFlow;
-import org.graalvm.compiler.nodes.spi.StampProvider;
-import org.graalvm.compiler.phases.util.Providers;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
 import org.graalvm.compiler.runtime.RuntimeProvider;
+import org.junit.Assert;
+import org.junit.Test;
+
+import jdk.vm.ci.meta.ResolvedJavaField;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.meta.ResolvedJavaType;
 
 public class StaticAnalysisTests {
 
@@ -68,14 +65,11 @@
         Object f;
     }
 
-    private final MetaAccessProvider metaAccess;
-    private final StampProvider stampProvider;
+    private final CoreProviders providers;
 
     public StaticAnalysisTests() {
         Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
-        Providers providers = backend.getProviders();
-        this.metaAccess = providers.getMetaAccess();
-        this.stampProvider = providers.getStampProvider();
+        providers = backend.getProviders();
     }
 
     static void test01Entry() {
@@ -85,7 +79,7 @@
 
     @Test
     public void test01() {
-        StaticAnalysis sa = new StaticAnalysis(metaAccess, stampProvider);
+        StaticAnalysis sa = new StaticAnalysis(providers);
         sa.addMethod(findMethod(StaticAnalysisTests.class, "test01Entry"));
         sa.finish();
 
@@ -106,7 +100,7 @@
 
     @Test
     public void test02() {
-        StaticAnalysis sa = new StaticAnalysis(metaAccess, stampProvider);
+        StaticAnalysis sa = new StaticAnalysis(providers);
         sa.addMethod(findMethod(StaticAnalysisTests.class, "test02Entry"));
         sa.finish();
 
@@ -134,7 +128,7 @@
 
     @Test
     public void test03() {
-        StaticAnalysis sa = new StaticAnalysis(metaAccess, stampProvider);
+        StaticAnalysis sa = new StaticAnalysis(providers);
         sa.addMethod(findMethod(StaticAnalysisTests.class, "test03Entry"));
         sa.finish();
 
@@ -165,7 +159,7 @@
 
     @Test
     public void test04() {
-        StaticAnalysis sa = new StaticAnalysis(metaAccess, stampProvider);
+        StaticAnalysis sa = new StaticAnalysis(providers);
         sa.addMethod(findMethod(StaticAnalysisTests.class, "test04Entry"));
         sa.finish();
 
@@ -192,7 +186,7 @@
     }
 
     private ResolvedJavaType t(Class<?> clazz) {
-        return metaAccess.lookupJavaType(clazz);
+        return providers.getMetaAccess().lookupJavaType(clazz);
     }
 
     private ResolvedJavaMethod findMethod(Class<?> declaringClass, String name) {
@@ -204,7 +198,7 @@
             }
         }
         assert reflectionMethod != null : "No method with name " + name + " in class " + declaringClass.getName();
-        return metaAccess.lookupJavaMethod(reflectionMethod);
+        return providers.getMetaAccess().lookupJavaMethod(reflectionMethod);
     }
 
     private ResolvedJavaField findField(Class<?> declaringClass, String name) {
@@ -214,6 +208,6 @@
         } catch (NoSuchFieldException | SecurityException ex) {
             throw new AssertionError(ex);
         }
-        return metaAccess.lookupJavaField(reflectionField);
+        return providers.getMetaAccess().lookupJavaField(reflectionField);
     }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/LIRGenerationPhase.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/LIRGenerationPhase.java	Tue Apr 09 11:48:54 2019 +0100
@@ -67,7 +67,11 @@
         NodeLIRBuilderTool nodeLirBuilder = context.nodeLirBuilder;
         StructuredGraph graph = context.graph;
         ScheduleResult schedule = context.schedule;
-        for (AbstractBlockBase<?> b : lirGenRes.getLIR().getControlFlowGraph().getBlocks()) {
+        AbstractBlockBase<?>[] blocks = lirGenRes.getLIR().getControlFlowGraph().getBlocks();
+        for (AbstractBlockBase<?> b : blocks) {
+            matchBlock(nodeLirBuilder, (Block) b, graph, schedule);
+        }
+        for (AbstractBlockBase<?> b : blocks) {
             emitBlock(nodeLirBuilder, lirGenRes, (Block) b, graph, schedule.getBlockToNodesMap());
         }
         context.lirGen.beforeRegisterAllocation();
@@ -84,6 +88,10 @@
         instructionCounter.add(debug, lir.getLIRforBlock(b).size());
     }
 
+    private static void matchBlock(NodeLIRBuilderTool nodeLirGen, Block b, StructuredGraph graph, ScheduleResult schedule) {
+        nodeLirGen.matchBlock(b, graph, schedule);
+    }
+
     private static boolean verifyPredecessors(LIRGenerationResult lirGenRes, Block block) {
         for (Block pred : block.getPredecessors()) {
             if (!block.isLoopHeader() || !pred.isLoopEnd()) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/NodeLIRBuilder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/NodeLIRBuilder.java	Tue Apr 09 11:48:54 2019 +0100
@@ -48,6 +48,7 @@
 import org.graalvm.compiler.core.match.MatchPattern;
 import org.graalvm.compiler.core.match.MatchRuleRegistry;
 import org.graalvm.compiler.core.match.MatchStatement;
+import org.graalvm.compiler.debug.DebugCloseable;
 import org.graalvm.compiler.debug.DebugContext;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.debug.TTY;
@@ -255,7 +256,7 @@
 
             // get ValueKind for input
             final LIRKind valueKind;
-            if (value != null) {
+            if (value != null && !(value instanceof ComplexMatchValue)) {
                 valueKind = value.getValueKind(LIRKind.class);
             } else {
                 assert isPhiInputFromBackedge(phi, i) : String.format("Input %s to phi node %s is not yet available although it is not coming from a loop back edge", node, phi);
@@ -358,10 +359,6 @@
 
             List<Node> nodes = blockMap.get(block);
 
-            // Allow NodeLIRBuilder subclass to specialize code generation of any interesting groups
-            // of instructions
-            matchComplexExpressions(nodes);
-
             boolean trace = traceLIRGeneratorLevel >= 3;
             for (int i = 0; i < nodes.size(); i++) {
                 Node node = nodes.get(i);
@@ -419,11 +416,23 @@
         }
     }
 
+    @Override
     @SuppressWarnings("try")
-    protected void matchComplexExpressions(List<Node> nodes) {
+    public void matchBlock(Block block, StructuredGraph graph, StructuredGraph.ScheduleResult schedule) {
+        try (DebugCloseable matchScope = gen.getMatchScope(block)) {
+            // Allow NodeLIRBuilder subclass to specialize code generation of any interesting groups
+            // of instructions
+            matchComplexExpressions(block, schedule);
+        }
+    }
+
+    @SuppressWarnings("try")
+    protected void matchComplexExpressions(Block block, StructuredGraph.ScheduleResult schedule) {
+
         if (matchRules != null) {
             DebugContext debug = gen.getResult().getLIR().getDebug();
             try (DebugContext.Scope s = debug.scope("MatchComplexExpressions")) {
+                List<Node> nodes = schedule.getBlockToNodesMap().get(block);
                 if (LogVerbose.getValue(nodeOperands.graph().getOptions())) {
                     int i = 0;
                     for (Node node : nodes) {
@@ -441,7 +450,7 @@
                     List<MatchStatement> statements = matchRules.get(node.getClass());
                     if (statements != null) {
                         for (MatchStatement statement : statements) {
-                            if (statement.generate(this, index, node, nodes)) {
+                            if (statement.generate(this, index, node, block, schedule)) {
                                 // Found a match so skip to the next
                                 break;
                             }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/NodeMatchRules.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/NodeMatchRules.java	Tue Apr 09 11:48:54 2019 +0100
@@ -67,38 +67,38 @@
 
 import jdk.vm.ci.meta.Value;
 
-@MatchableNode(nodeClass = ConstantNode.class, shareable = true)
-@MatchableNode(nodeClass = FloatConvertNode.class, inputs = {"value"})
+@MatchableNode(nodeClass = ConstantNode.class, shareable = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = FloatConvertNode.class, inputs = {"value"}, ignoresSideEffects = true)
 @MatchableNode(nodeClass = FloatingReadNode.class, inputs = {"address"})
 @MatchableNode(nodeClass = IfNode.class, inputs = {"condition"})
-@MatchableNode(nodeClass = SubNode.class, inputs = {"x", "y"})
-@MatchableNode(nodeClass = LeftShiftNode.class, inputs = {"x", "y"})
-@MatchableNode(nodeClass = NarrowNode.class, inputs = {"value"})
+@MatchableNode(nodeClass = SubNode.class, inputs = {"x", "y"}, ignoresSideEffects = true)
+@MatchableNode(nodeClass = LeftShiftNode.class, inputs = {"x", "y"}, ignoresSideEffects = true)
+@MatchableNode(nodeClass = NarrowNode.class, inputs = {"value"}, ignoresSideEffects = true)
 @MatchableNode(nodeClass = ReadNode.class, inputs = {"address"})
-@MatchableNode(nodeClass = ReinterpretNode.class, inputs = {"value"})
-@MatchableNode(nodeClass = SignExtendNode.class, inputs = {"value"})
-@MatchableNode(nodeClass = UnsignedRightShiftNode.class, inputs = {"x", "y"})
+@MatchableNode(nodeClass = ReinterpretNode.class, inputs = {"value"}, ignoresSideEffects = true)
+@MatchableNode(nodeClass = SignExtendNode.class, inputs = {"value"}, ignoresSideEffects = true)
+@MatchableNode(nodeClass = UnsignedRightShiftNode.class, inputs = {"x", "y"}, ignoresSideEffects = true)
 @MatchableNode(nodeClass = WriteNode.class, inputs = {"address", "value"})
-@MatchableNode(nodeClass = ZeroExtendNode.class, inputs = {"value"})
-@MatchableNode(nodeClass = AndNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = NegateNode.class, inputs = {"value"})
-@MatchableNode(nodeClass = NotNode.class, inputs = {"value"})
-@MatchableNode(nodeClass = FloatEqualsNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = FloatLessThanNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = PointerEqualsNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = AddNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = IntegerBelowNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = IntegerEqualsNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = IntegerLessThanNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = MulNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = IntegerTestNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = ObjectEqualsNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = OrNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = XorNode.class, inputs = {"x", "y"}, commutative = true)
-@MatchableNode(nodeClass = PiNode.class, inputs = {"object"})
+@MatchableNode(nodeClass = ZeroExtendNode.class, inputs = {"value"}, ignoresSideEffects = true)
+@MatchableNode(nodeClass = AndNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = NegateNode.class, inputs = {"value"}, ignoresSideEffects = true)
+@MatchableNode(nodeClass = NotNode.class, inputs = {"value"}, ignoresSideEffects = true)
+@MatchableNode(nodeClass = FloatEqualsNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = FloatLessThanNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = PointerEqualsNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = AddNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = IntegerBelowNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = IntegerEqualsNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = IntegerLessThanNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = MulNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = IntegerTestNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = ObjectEqualsNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = OrNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = XorNode.class, inputs = {"x", "y"}, commutative = true, ignoresSideEffects = true)
+@MatchableNode(nodeClass = PiNode.class, inputs = {"object"}, ignoresSideEffects = true)
 @MatchableNode(nodeClass = LogicCompareAndSwapNode.class, inputs = {"address", "expectedValue", "newValue"})
 @MatchableNode(nodeClass = ValueCompareAndSwapNode.class, inputs = {"address", "expectedValue", "newValue"})
-@MatchableNode(nodeClass = RightShiftNode.class, inputs = {"x", "y"})
+@MatchableNode(nodeClass = RightShiftNode.class, inputs = {"x", "y"}, ignoresSideEffects = true)
 public abstract class NodeMatchRules {
 
     NodeLIRBuilder lirBuilder;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/match/MatchContext.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/match/MatchContext.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,40 +24,120 @@
 
 package org.graalvm.compiler.core.match;
 
+import static org.graalvm.compiler.core.common.cfg.AbstractControlFlowGraph.dominates;
+import static org.graalvm.compiler.core.common.cfg.AbstractControlFlowGraph.strictlyDominates;
 import static org.graalvm.compiler.debug.DebugOptions.LogVerbose;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Iterator;
 import java.util.List;
 
 import jdk.internal.vm.compiler.collections.EconomicMap;
 import jdk.internal.vm.compiler.collections.Equivalence;
+import org.graalvm.compiler.core.common.cfg.BlockMap;
 import org.graalvm.compiler.core.gen.NodeLIRBuilder;
 import org.graalvm.compiler.core.match.MatchPattern.Result;
+import org.graalvm.compiler.debug.CounterKey;
 import org.graalvm.compiler.debug.DebugContext;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.graph.Node;
+import org.graalvm.compiler.graph.NodeMap;
+import org.graalvm.compiler.nodes.PhiNode;
+import org.graalvm.compiler.nodes.StructuredGraph;
 import org.graalvm.compiler.nodes.calc.FloatingNode;
+import org.graalvm.compiler.nodes.cfg.Block;
 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
 
 /**
  * Container for state captured during a match.
  */
 public class MatchContext {
+    private static final CounterKey MatchContextSuccessDifferentBlocks = DebugContext.counter("MatchContextSuccessDifferentBlocks");
 
     private final Node root;
 
-    private final List<Node> nodes;
-
     private final MatchStatement rule;
+    private final StructuredGraph.ScheduleResult schedule;
 
     private EconomicMap<String, NamedNode> namedNodes;
 
-    private ArrayList<Node> consumed;
+    /**
+     * A node consumed by a match. Keeps track of whether side effects can be ignored.
+     */
+    static final class ConsumedNode {
+        final Node node;
+        final boolean ignoresSideEffects;
+
+        ConsumedNode(Node node, boolean ignoresSideEffects) {
+            this.node = node;
+            this.ignoresSideEffects = ignoresSideEffects;
+        }
+    }
+
+    /**
+     * The collection of nodes consumed by this match.
+     */
+    static final class ConsumedNodes implements Iterable<ConsumedNode> {
+        private ArrayList<ConsumedNode> nodes;
+
+        ConsumedNodes() {
+            this.nodes = null;
+        }
+
+        public void add(Node node, boolean ignoresSideEffects) {
+            if (nodes == null) {
+                nodes = new ArrayList<>(2);
+            }
+            nodes.add(new ConsumedNode(node, ignoresSideEffects));
+        }
 
-    private int startIndex;
+        public boolean contains(Node node) {
+            for (ConsumedNode c : nodes) {
+                if (c.node == node) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public ConsumedNode find(Node node) {
+            for (ConsumedNode c : nodes) {
+                if (c.node == node) {
+                    return c;
+                }
+            }
+            return null;
+        }
 
-    private int endIndex;
+        @Override
+        public String toString() {
+            Node[] arr = new Node[nodes.size()];
+            int i = 0;
+            for (ConsumedNode c : nodes) {
+                arr[i++] = c.node;
+            }
+            return Arrays.toString(arr);
+        }
+
+        @Override
+        public Iterator<ConsumedNode> iterator() {
+            return nodes.iterator();
+        }
+    }
+
+    private ConsumedNodes consumed = new ConsumedNodes();
+
+    private Block rootBlock;
+    private int rootIndex;
+
+    /**
+     * Block and index in the block at which the match should be emitted. Differs from
+     * rootBlock/rootIndex for (ZeroExtend Read=access) for instance: match should be emitted where
+     * the Read is.
+     */
+    private int emitIndex;
+    private Block emitBlock;
 
     private final NodeLIRBuilder builder;
 
@@ -71,14 +151,15 @@
         }
     }
 
-    public MatchContext(NodeLIRBuilder builder, MatchStatement rule, int index, Node node, List<Node> nodes) {
+    public MatchContext(NodeLIRBuilder builder, MatchStatement rule, int index, Node node, Block rootBlock, StructuredGraph.ScheduleResult schedule) {
         this.builder = builder;
         this.rule = rule;
         this.root = node;
-        this.nodes = nodes;
-        assert index == nodes.indexOf(node);
+        assert index == schedule.getBlockToNodesMap().get(rootBlock).indexOf(node);
+        this.schedule = schedule;
         // The root should be the last index since all the inputs must be scheduled before it.
-        startIndex = endIndex = index;
+        this.rootBlock = rootBlock;
+        rootIndex = index;
     }
 
     public Node getRoot() {
@@ -103,28 +184,177 @@
     }
 
     public Result validate() {
-        // Ensure that there's no unsafe work in between these operations.
-        for (int i = startIndex; i <= endIndex; i++) {
+        Result result = findEarlyPosition();
+        if (result != Result.OK) {
+            return result;
+        }
+        findLatePosition();
+        assert emitIndex == rootIndex || consumed.find(root).ignoresSideEffects;
+        return verifyInputs();
+    }
+
+    private Result findEarlyPosition() {
+        int startIndexSideEffect = -1;
+        int endIndexSideEffect = -1;
+        final NodeMap<Block> nodeToBlockMap = schedule.getNodeToBlockMap();
+        final BlockMap<List<Node>> blockToNodesMap = schedule.getBlockToNodesMap();
+
+        // Nodes affected by side effects must be in the same block
+        for (ConsumedNode cn : consumed) {
+            if (!cn.ignoresSideEffects) {
+                Block b = nodeToBlockMap.get(cn.node);
+                if (emitBlock == null) {
+                    emitBlock = b;
+                    startIndexSideEffect = endIndexSideEffect = blockToNodesMap.get(b).indexOf(cn.node);
+                } else if (emitBlock == b) {
+                    int index = blockToNodesMap.get(b).indexOf(cn.node);
+                    startIndexSideEffect = Math.min(startIndexSideEffect, index);
+                    endIndexSideEffect = Math.max(endIndexSideEffect, index);
+                } else {
+                    logFailedMatch("nodes affected by side effects in different blocks %s", cn.node);
+                    return Result.notInBlock(cn.node, rule.getPattern());
+                }
+            }
+        }
+        if (emitBlock != null) {
+            // There must be no side effects between nodes that are affected by side effects
+            assert startIndexSideEffect != -1 && endIndexSideEffect != -1;
+            final List<Node> nodes = blockToNodesMap.get(emitBlock);
+            for (int i = startIndexSideEffect; i <= endIndexSideEffect; i++) {
+                Node node = nodes.get(i);
+                if (!sideEffectFree(node) && !consumed.contains(node)) {
+                    logFailedMatch("unexpected side effect %s", node);
+                    return Result.notSafe(node, rule.getPattern());
+                }
+            }
+            // early position is at the node affected by side effects the closest to the root
+            emitIndex = endIndexSideEffect;
+        } else {
+            // Nodes not affected by side effect: early position is at the root
+            emitBlock = nodeToBlockMap.get(root);
+            emitIndex = rootIndex;
+        }
+        return Result.OK;
+    }
+
+    private static boolean sideEffectFree(Node node) {
+        // The order of evaluation of these nodes controlled by data dependence so they
+        // don't interfere with this match.
+        return node instanceof VirtualObjectNode || node instanceof FloatingNode;
+    }
+
+    private void findLatePosition() {
+        // If emit position is at a node affected by side effects that's followed by side effect
+        // free nodes, the node can be emitted later. This helps when the match has inputs that are
+        // late in the block.
+        int index = rootIndex;
+        if (emitBlock != rootBlock) {
+            index = schedule.getBlockToNodesMap().get(emitBlock).size() - 1;
+        }
+        final List<Node> emitBlockNodes = schedule.getBlockToNodesMap().get(emitBlock);
+        for (int i = emitIndex + 1; i <= index; i++) {
+            Node node = emitBlockNodes.get(i);
+            ConsumedNode cn = consumed.find(node);
+            if (cn == null) {
+                if (!sideEffectFree(node)) {
+                    return;
+                }
+            } else {
+                assert cn.ignoresSideEffects;
+                emitIndex = i;
+            }
+        }
+    }
+
+    private Result verifyInputs() {
+        DebugContext debug = root.getDebug();
+        if (emitBlock != rootBlock) {
+            assert consumed.find(root).ignoresSideEffects;
+            Result result = verifyInputsDifferentBlock(root);
+            if (result == Result.OK) {
+                MatchContextSuccessDifferentBlocks.increment(debug);
+            }
+            return result;
+        }
+        // We are going to emit the match at emitIndex. We need to make sure nodes of the match
+        // between emitIndex and rootIndex don't have inputs after position emitIndex that would
+        // make emitIndex an illegal position.
+        final List<Node> nodes = schedule.getBlockToNodesMap().get(rootBlock);
+        for (int i = emitIndex + 1; i <= rootIndex; i++) {
             Node node = nodes.get(i);
-            if (node instanceof VirtualObjectNode || node instanceof FloatingNode) {
-                // The order of evaluation of these nodes controlled by data dependence so they
-                // don't interfere with this match.
-                continue;
-            } else if ((consumed == null || !consumed.contains(node)) && node != root) {
-                if (LogVerbose.getValue(root.getOptions())) {
-                    DebugContext debug = root.getDebug();
-                    debug.log("unexpected node %s", node);
-                    for (int j = startIndex; j <= endIndex; j++) {
-                        Node theNode = nodes.get(j);
-                        debug.log("%s(%s) %1s", (consumed != null && consumed.contains(theNode) || theNode == root) ? "*" : " ", theNode.getUsageCount(), theNode);
+            ConsumedNode cn = consumed.find(node);
+            if (cn != null) {
+                assert cn.ignoresSideEffects;
+                for (Node in : node.inputs()) {
+                    if (!consumed.contains(in)) {
+                        for (int j = emitIndex + 1; j < i; j++) {
+                            if (nodes.get(j) == in) {
+                                logFailedMatch("Earliest position in block is too late %s", in);
+                                assert consumed.find(root).ignoresSideEffects;
+                                assert verifyInputsDifferentBlock(root) != Result.OK;
+                                return Result.tooLate(node, rule.getPattern());
+                            }
+                        }
                     }
                 }
-                return Result.notSafe(node, rule.getPattern());
+            }
+        }
+        assert verifyInputsDifferentBlock(root) == Result.OK;
+        return Result.OK;
+    }
+
+    private Result verifyInputsDifferentBlock(Node node) {
+        // Is there an input that's not part of the match that's after the emit position?
+        for (Node in : node.inputs()) {
+            if (in instanceof PhiNode) {
+                Block b = schedule.getNodeToBlockMap().get(((PhiNode) in).merge());
+                if (dominates(b, emitBlock)) {
+                    continue;
+                }
+            } else {
+                Block b = schedule.getNodeToBlockMap().get(in);
+                if (strictlyDominates(b, emitBlock) || (b == emitBlock && schedule.getBlockToNodesMap().get(emitBlock).indexOf(in) <= emitIndex)) {
+                    continue;
+                }
+            }
+            ConsumedNode cn = consumed.find(in);
+            if (cn == null) {
+                logFailedMatch("Earliest position in block is too late %s", in);
+                return Result.tooLate(node, rule.getPattern());
+            }
+            assert cn.ignoresSideEffects;
+            Result res = verifyInputsDifferentBlock(in);
+            if (res != Result.OK) {
+                return res;
             }
         }
         return Result.OK;
     }
 
+    private void logFailedMatch(String s, Node node) {
+        if (LogVerbose.getValue(root.getOptions())) {
+            DebugContext debug = root.getDebug();
+            debug.log(s, node);
+            int startIndex = emitIndex;
+            if (emitBlock != rootBlock) {
+                int endIndex = schedule.getBlockToNodesMap().get(emitBlock).size() - 1;
+                final List<Node> emitBlockNodes = schedule.getBlockToNodesMap().get(emitBlock);
+                debug.log("%s:", emitBlock);
+                for (int j = startIndex; j <= endIndex; j++) {
+                    Node theNode = emitBlockNodes.get(j);
+                    debug.log("%s(%s) %1s", consumed.contains(theNode) ? "*" : " ", theNode.getUsageCount(), theNode);
+                }
+                startIndex = 0;
+            }
+            debug.log("%s:", rootBlock);
+            final List<Node> nodes = schedule.getBlockToNodesMap().get(rootBlock);
+            for (int j = startIndex; j <= rootIndex; j++) {
+                Node theNode = nodes.get(j);
+                debug.log("%s(%s) %1s", consumed.contains(theNode) ? "*" : " ", theNode.getUsageCount(), theNode);
+            }
+        }
+    }
+
     /**
      * Mark the interior nodes with INTERIOR_MATCH and set the Value of the root to be the result.
      * During final LIR generation it will be evaluated to produce the actual LIR value.
@@ -133,20 +363,28 @@
      */
     public void setResult(ComplexMatchResult result) {
         ComplexMatchValue value = new ComplexMatchValue(result);
+        Node emitNode = schedule.getBlockToNodesMap().get(emitBlock).get(emitIndex);
         DebugContext debug = root.getDebug();
         if (debug.isLogEnabled()) {
-            debug.log("matched %s %s", rule.getName(), rule.getPattern());
+            debug.log("matched %s %s%s", rule.getName(), rule.getPattern(), emitIndex != rootIndex ? " skipping side effects" : "");
             debug.log("with nodes %s", rule.formatMatch(root));
         }
-        if (consumed != null) {
-            for (Node node : consumed) {
-                // All the interior nodes should be skipped during the normal doRoot calls in
-                // NodeLIRBuilder so mark them as interior matches. The root of the match will get a
-                // closure which will be evaluated to produce the final LIR.
-                builder.setMatchResult(node, ComplexMatchValue.INTERIOR_MATCH);
+        for (ConsumedNode cn : consumed) {
+            if (cn.node == root || cn.node == emitNode) {
+                continue;
             }
+            // All the interior nodes should be skipped during the normal doRoot calls in
+            // NodeLIRBuilder so mark them as interior matches. The root of the match will get a
+            // closure which will be evaluated to produce the final LIR.
+            builder.setMatchResult(cn.node, ComplexMatchValue.INTERIOR_MATCH);
         }
-        builder.setMatchResult(root, value);
+        builder.setMatchResult(emitNode, value);
+        if (root != emitNode) {
+            // Match is not emitted at the position of root in the block but the uses of root needs
+            // the result of the match so add a ComplexMatchValue that will simply return the result
+            // of the actual match above.
+            builder.setMatchResult(root, new ComplexMatchValue(gen -> gen.operand(emitNode)));
+        }
     }
 
     /**
@@ -154,24 +392,18 @@
      *
      * @return Result.OK if the node can be safely consumed.
      */
-    public Result consume(Node node) {
+    public Result consume(Node node, boolean ignoresSideEffects, boolean atRoot) {
+        if (atRoot) {
+            consumed.add(node, ignoresSideEffects);
+            return Result.OK;
+        }
         assert MatchPattern.isSingleValueUser(node) : "should have already been checked";
 
-        // Check NOT_IN_BLOCK first since that usually implies ALREADY_USED
-        int index = nodes.indexOf(node);
-        if (index == -1) {
-            return Result.notInBlock(node, rule.getPattern());
-        }
-
         if (builder.hasOperand(node)) {
             return Result.alreadyUsed(node, rule.getPattern());
         }
 
-        startIndex = Math.min(startIndex, index);
-        if (consumed == null) {
-            consumed = new ArrayList<>(2);
-        }
-        consumed.add(node);
+        consumed.add(node, ignoresSideEffects);
         return Result.OK;
     }
 
@@ -194,6 +426,6 @@
 
     @Override
     public String toString() {
-        return String.format("%s %s (%d, %d) consumed %s", rule, root, startIndex, endIndex, consumed != null ? Arrays.toString(consumed.toArray()) : "");
+        return String.format("%s %s (%s/%d, %s/%d) consumed %s", rule, root, rootBlock, rootIndex, emitBlock, emitIndex, consumed);
     }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/match/MatchPattern.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/match/MatchPattern.java	Tue Apr 09 11:48:54 2019 +0100
@@ -30,6 +30,7 @@
 import org.graalvm.compiler.graph.Position;
 import org.graalvm.compiler.nodeinfo.InputType;
 import org.graalvm.compiler.nodeinfo.Verbosity;
+import org.graalvm.compiler.nodes.calc.FloatingNode;
 
 /**
  * A simple recursive pattern matcher for a DAG of nodes.
@@ -45,6 +46,7 @@
         NOT_IN_BLOCK,
         NOT_SAFE,
         ALREADY_USED,
+        TOO_LATE,
     }
 
     /**
@@ -70,6 +72,7 @@
         private static final CounterKey MatchResult_NOT_IN_BLOCK = DebugContext.counter("MatchResult_NOT_IN_BLOCK");
         private static final CounterKey MatchResult_NOT_SAFE = DebugContext.counter("MatchResult_NOT_SAFE");
         private static final CounterKey MatchResult_ALREADY_USED = DebugContext.counter("MatchResult_ALREADY_USED");
+        private static final CounterKey MatchResult_TOO_LATE = DebugContext.counter("MatchResult_TOO_LATE");
 
         static final Result OK = new Result(MatchResultCode.OK, null, null);
         private static final Result CACHED_WRONG_CLASS = new Result(MatchResultCode.WRONG_CLASS, null, null);
@@ -78,6 +81,7 @@
         private static final Result CACHED_NOT_IN_BLOCK = new Result(MatchResultCode.NOT_IN_BLOCK, null, null);
         private static final Result CACHED_NOT_SAFE = new Result(MatchResultCode.NOT_SAFE, null, null);
         private static final Result CACHED_ALREADY_USED = new Result(MatchResultCode.ALREADY_USED, null, null);
+        private static final Result CACHED_TOO_LATE = new Result(MatchResultCode.TOO_LATE, null, null);
 
         static Result wrongClass(Node node, MatchPattern matcher) {
             MatchResult_WRONG_CLASS.increment(node.getDebug());
@@ -109,6 +113,11 @@
             return node.getDebug().isLogEnabled() ? new Result(MatchResultCode.ALREADY_USED, node, matcher) : CACHED_ALREADY_USED;
         }
 
+        static Result tooLate(Node node, MatchPattern matcher) {
+            MatchResult_TOO_LATE.increment(node.getDebug());
+            return node.getDebug().isLogEnabled() ? new Result(MatchResultCode.TOO_LATE, node, matcher) : CACHED_TOO_LATE;
+        }
+
         @Override
         public String toString() {
             if (code == MatchResultCode.OK) {
@@ -149,39 +158,49 @@
      */
     private final boolean singleUser;
 
+    /**
+     * Can this node be subsumed into a match even if there are side effecting nodes between this
+     * node and the match.
+     */
+    private final boolean ignoresSideEffects;
+
     private static final MatchPattern[] EMPTY_PATTERNS = new MatchPattern[0];
 
-    public MatchPattern(String name, boolean singleUser) {
-        this(null, name, singleUser);
+    public MatchPattern(String name, boolean singleUser, boolean ignoresSideEffects) {
+        this(null, name, singleUser, ignoresSideEffects);
     }
 
-    public MatchPattern(Class<? extends Node> nodeClass, String name, boolean singleUser) {
+    public MatchPattern(Class<? extends Node> nodeClass, String name, boolean singleUser, boolean ignoresSideEffects) {
         this.nodeClass = nodeClass;
         this.name = name;
         this.singleUser = singleUser;
+        this.ignoresSideEffects = ignoresSideEffects;
         this.patterns = EMPTY_PATTERNS;
         this.inputs = null;
+        assert !ignoresSideEffects || FloatingNode.class.isAssignableFrom(nodeClass);
     }
 
-    private MatchPattern(Class<? extends Node> nodeClass, String name, boolean singleUser, MatchPattern[] patterns, Position[] inputs) {
+    private MatchPattern(Class<? extends Node> nodeClass, String name, boolean singleUser, boolean ignoresSideEffects, MatchPattern[] patterns, Position[] inputs) {
         assert inputs == null || inputs.length == patterns.length;
         this.nodeClass = nodeClass;
         this.name = name;
         this.singleUser = singleUser;
+        this.ignoresSideEffects = ignoresSideEffects;
         this.patterns = patterns;
         this.inputs = inputs;
+        assert !ignoresSideEffects || FloatingNode.class.isAssignableFrom(nodeClass);
     }
 
-    public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, Position[] inputs, boolean singleUser) {
-        this(nodeClass, name, singleUser, new MatchPattern[]{first}, inputs);
+    public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, Position[] inputs, boolean singleUser, boolean ignoresSideEffects) {
+        this(nodeClass, name, singleUser, ignoresSideEffects, new MatchPattern[]{first}, inputs);
     }
 
-    public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, MatchPattern second, Position[] inputs, boolean singleUser) {
-        this(nodeClass, name, singleUser, new MatchPattern[]{first, second}, inputs);
+    public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, MatchPattern second, Position[] inputs, boolean singleUser, boolean ignoresSideEffects) {
+        this(nodeClass, name, singleUser, ignoresSideEffects, new MatchPattern[]{first, second}, inputs);
     }
 
-    public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, MatchPattern second, MatchPattern third, Position[] inputs, boolean singleUser) {
-        this(nodeClass, name, singleUser, new MatchPattern[]{first, second, third}, inputs);
+    public MatchPattern(Class<? extends Node> nodeClass, String name, MatchPattern first, MatchPattern second, MatchPattern third, Position[] inputs, boolean singleUser, boolean ignoresSideEffects) {
+        this(nodeClass, name, singleUser, ignoresSideEffects, new MatchPattern[]{first, second, third}, inputs);
     }
 
     Class<? extends Node> nodeClass() {
@@ -215,8 +234,8 @@
         if (result != Result.OK) {
             return result;
         }
-        if (singleUser && !atRoot) {
-            result = context.consume(node);
+        if (singleUser) {
+            result = context.consume(node, ignoresSideEffects, atRoot);
             if (result != Result.OK) {
                 return result;
             }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/match/MatchStatement.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/match/MatchStatement.java	Tue Apr 09 11:48:54 2019 +0100
@@ -26,8 +26,6 @@
 
 import static org.graalvm.compiler.debug.DebugOptions.LogVerbose;
 
-import java.util.List;
-
 import org.graalvm.compiler.core.gen.NodeLIRBuilder;
 import org.graalvm.compiler.core.match.MatchPattern.MatchResultCode;
 import org.graalvm.compiler.core.match.MatchPattern.Result;
@@ -38,6 +36,8 @@
 import org.graalvm.compiler.nodeinfo.Verbosity;
 
 import jdk.vm.ci.meta.Value;
+import org.graalvm.compiler.nodes.StructuredGraph;
+import org.graalvm.compiler.nodes.cfg.Block;
 
 /**
  * A named {@link MatchPattern} along with a {@link MatchGenerator} that can be evaluated to replace
@@ -80,20 +80,21 @@
      *
      * @param builder the current builder instance.
      * @param node the node to be matched
-     * @param nodes the nodes in the current block
+     * @param block the current block
+     * @param schedule the schedule that's being used
      * @return true if the statement matched something and set a {@link ComplexMatchResult} to be
      *         evaluated by the NodeLIRBuilder.
      */
-    public boolean generate(NodeLIRBuilder builder, int index, Node node, List<Node> nodes) {
+    public boolean generate(NodeLIRBuilder builder, int index, Node node, Block block, StructuredGraph.ScheduleResult schedule) {
         DebugContext debug = node.getDebug();
-        assert index == nodes.indexOf(node);
+        assert index == schedule.getBlockToNodesMap().get(block).indexOf(node);
         // Check that the basic shape matches
         Result result = pattern.matchShape(node, this);
         if (result != Result.OK) {
             return false;
         }
         // Now ensure that the other safety constraints are matched.
-        MatchContext context = new MatchContext(builder, this, index, node, nodes);
+        MatchContext context = new MatchContext(builder, this, index, node, block, schedule);
         result = pattern.matchUsage(node, context);
         if (result == Result.OK) {
             // Invoke the generator method and set the result if it's non null.
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/match/MatchableNode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/match/MatchableNode.java	Tue Apr 09 11:48:54 2019 +0100
@@ -64,4 +64,6 @@
      * Can a node with multiple uses be safely matched by a rule.
      */
     boolean shareable() default false;
+
+    boolean ignoresSideEffects() default false;
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/DebugContext.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/DebugContext.java	Tue Apr 09 11:48:54 2019 +0100
@@ -239,15 +239,9 @@
             this.unscopedTimers = parseUnscopedMetricSpec(Timers.getValue(options), "".equals(timeValue), true);
             this.unscopedMemUseTrackers = parseUnscopedMetricSpec(MemUseTrackers.getValue(options), "".equals(trackMemUseValue), true);
 
-            if (unscopedTimers != null || timeValue != null) {
-                if (!GraalServices.isCurrentThreadCpuTimeSupported()) {
-                    throw new IllegalArgumentException("Time and Timers options require VM support for querying CPU time");
-                }
-            }
-
             if (unscopedMemUseTrackers != null || trackMemUseValue != null) {
                 if (!GraalServices.isThreadAllocatedMemorySupported()) {
-                    throw new IllegalArgumentException("MemUseTrackers and TrackMemUse options require VM support for querying thread allocated memory");
+                    TTY.println("WARNING: Missing VM support for MemUseTrackers and TrackMemUse options so all reported memory usage will be 0");
                 }
             }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/LogStream.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/LogStream.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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,7 +87,7 @@
     /**
      * The system dependent line separator.
      */
-    public static final String LINE_SEPARATOR = System.getProperty("line.separator");
+    public static final String LINE_SEPARATOR = System.lineSeparator();
 
     /**
      * Creates a new log stream.
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/MemUseTrackerKey.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/MemUseTrackerKey.java	Tue Apr 09 11:48:54 2019 +0100
@@ -56,6 +56,6 @@
     MemUseTrackerKey doc(String string);
 
     static long getCurrentThreadAllocatedBytes() {
-        return GraalServices.getCurrentThreadAllocatedBytes();
+        return GraalServices.isThreadAllocatedMemorySupported() ? GraalServices.getCurrentThreadAllocatedBytes() : 0;
     }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/Versions.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/Versions.java	Tue Apr 09 11:48:54 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
@@ -32,11 +32,13 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import jdk.vm.ci.services.Services;
+
 /** Avoid using directly. Only public for the needs of unit testing. */
 public final class Versions {
     static final Versions VERSIONS;
     static {
-        String home = System.getProperty("java.home");
+        String home = Services.getSavedProperties().get("java.home");
         VERSIONS = new Versions(home == null ? null : new File(home).toPath());
     }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/Edges.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/Edges.java	Tue Apr 09 11:48:54 2019 +0100
@@ -26,7 +26,6 @@
 
 import static org.graalvm.compiler.graph.Graph.isModificationCountsEnabled;
 import static org.graalvm.compiler.graph.Node.NOT_ITERABLE;
-import static org.graalvm.compiler.graph.UnsafeAccess.UNSAFE;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -34,6 +33,9 @@
 import org.graalvm.compiler.core.common.Fields;
 import org.graalvm.compiler.core.common.FieldsScanner;
 import org.graalvm.compiler.graph.NodeClass.EdgeInfo;
+import org.graalvm.compiler.serviceprovider.GraalUnsafeAccess;
+
+import sun.misc.Unsafe;
 
 /**
  * Describes {@link Node} fields representing the set of inputs for the node or the set of the
@@ -41,6 +43,8 @@
  */
 public abstract class Edges extends Fields {
 
+    private static final Unsafe UNSAFE = GraalUnsafeAccess.getUnsafe();
+
     /**
      * Constants denoting whether a set of edges are inputs or successors.
      */
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/Node.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/Node.java	Tue Apr 09 11:48:54 2019 +0100
@@ -27,7 +27,7 @@
 import static org.graalvm.compiler.graph.Edges.Type.Inputs;
 import static org.graalvm.compiler.graph.Edges.Type.Successors;
 import static org.graalvm.compiler.graph.Graph.isModificationCountsEnabled;
-import static org.graalvm.compiler.graph.UnsafeAccess.UNSAFE;
+import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe;
 
 import java.lang.annotation.ElementType;
 import java.lang.annotation.RetentionPolicy;
@@ -61,6 +61,7 @@
 import org.graalvm.compiler.nodeinfo.Verbosity;
 import org.graalvm.compiler.options.OptionValues;
 
+import jdk.vm.ci.services.Services;
 import sun.misc.Unsafe;
 
 /**
@@ -86,9 +87,11 @@
 @NodeInfo
 public abstract class Node implements Cloneable, Formattable, NodeInterface {
 
+    private static final Unsafe UNSAFE = getUnsafe();
+
     public static final NodeClass<?> TYPE = null;
 
-    public static final boolean TRACK_CREATION_POSITION = Boolean.getBoolean("debug.graal.TrackNodeCreationPosition");
+    public static final boolean TRACK_CREATION_POSITION = Boolean.parseBoolean(Services.getSavedProperties().get("debug.graal.TrackNodeCreationPosition"));
 
     static final int DELETED_ID_START = -1000000000;
     static final int INITIAL_ID = -1;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeClass.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeClass.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,11 +24,13 @@
 
 package org.graalvm.compiler.graph;
 
+import static org.graalvm.compiler.core.common.Fields.translateInto;
 import static org.graalvm.compiler.debug.GraalError.shouldNotReachHere;
+import static org.graalvm.compiler.graph.Edges.translateInto;
 import static org.graalvm.compiler.graph.Graph.isModificationCountsEnabled;
 import static org.graalvm.compiler.graph.InputEdges.translateInto;
 import static org.graalvm.compiler.graph.Node.WithAllEdges;
-import static org.graalvm.compiler.graph.UnsafeAccess.UNSAFE;
+import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
@@ -69,6 +71,8 @@
 import org.graalvm.compiler.nodeinfo.NodeSize;
 import org.graalvm.compiler.nodeinfo.Verbosity;
 
+import sun.misc.Unsafe;
+
 /**
  * Metadata for every {@link Node} type. The metadata includes:
  * <ul>
@@ -79,6 +83,7 @@
  */
 public final class NodeClass<T> extends FieldIntrospection<T> {
 
+    private static final Unsafe UNSAFE = getUnsafe();
     // Timers for creation of a NodeClass instance
     private static final TimerKey Init_FieldScanning = DebugContext.timer("NodeClass.Init.FieldScanning");
     private static final TimerKey Init_FieldScanningInner = DebugContext.timer("NodeClass.Init.FieldScanning.Inner");
@@ -128,7 +133,7 @@
     public static <T> NodeClass<T> get(Class<T> clazz) {
         int numTries = 0;
         while (true) {
-            boolean shouldBeInitializedBefore = UnsafeAccess.UNSAFE.shouldBeInitialized(clazz);
+            boolean shouldBeInitializedBefore = UNSAFE.shouldBeInitialized(clazz);
 
             NodeClass<T> result = getUnchecked(clazz);
             if (result != null || clazz == NODE_CLASS) {
@@ -141,13 +146,13 @@
              * information without failing gates.
              */
             numTries++;
-            boolean shouldBeInitializedAfter = UnsafeAccess.UNSAFE.shouldBeInitialized(clazz);
+            boolean shouldBeInitializedAfter = UNSAFE.shouldBeInitialized(clazz);
             String msg = "GR-9537 Reflective field access of TYPE field returned null. This is probably a bug in HotSpot class initialization. " +
                             " clazz: " + clazz.getTypeName() + ", numTries: " + numTries +
                             ", shouldBeInitializedBefore: " + shouldBeInitializedBefore + ", shouldBeInitializedAfter: " + shouldBeInitializedAfter;
             if (numTries <= 100) {
                 TTY.println(msg);
-                UnsafeAccess.UNSAFE.ensureClassInitialized(clazz);
+                UNSAFE.ensureClassInitialized(clazz);
             } else {
                 throw GraalError.shouldNotReachHere(msg);
             }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeSourcePosition.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeSourcePosition.java	Tue Apr 09 11:48:54 2019 +0100
@@ -40,11 +40,12 @@
 import jdk.vm.ci.meta.JavaMethod;
 import jdk.vm.ci.meta.MetaUtil;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.services.Services;
 
 public class NodeSourcePosition extends BytecodePosition implements Iterable<NodeSourcePosition> {
 
-    private static final boolean STRICT_SOURCE_POSITION = Boolean.getBoolean("debug.graal.SourcePositionStrictChecks");
-    private static final boolean SOURCE_POSITION_BYTECODES = Boolean.getBoolean("debug.graal.SourcePositionDisassemble");
+    private static final boolean STRICT_SOURCE_POSITION = Boolean.parseBoolean(Services.getSavedProperties().get("debug.graal.SourcePositionStrictChecks"));
+    private static final boolean SOURCE_POSITION_BYTECODES = Boolean.parseBoolean(Services.getSavedProperties().get("debug.graal.SourcePositionDisassemble"));
 
     private final int hashCode;
     private final Marker marker;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/UnsafeAccess.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, 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
- * 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 org.graalvm.compiler.graph;
-
-import java.lang.reflect.Field;
-
-import sun.misc.Unsafe;
-
-/**
- * Package private access to the {@link Unsafe} capability.
- */
-class UnsafeAccess {
-
-    static final Unsafe UNSAFE = initUnsafe();
-
-    private static Unsafe initUnsafe() {
-        try {
-            // Fast path when we are trusted.
-            return Unsafe.getUnsafe();
-        } catch (SecurityException se) {
-            // Slow path when we are not trusted.
-            try {
-                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                return (Unsafe) theUnsafe.get(Unsafe.class);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to get Unsafe", e);
-            }
-        }
-    }
-}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotBackendFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotBackendFactory.java	Tue Apr 09 11:48:54 2019 +0100
@@ -166,7 +166,8 @@
                     HotSpotHostForeignCallsProvider foreignCalls, HotSpotMetaAccessProvider metaAccess, HotSpotSnippetReflectionProvider snippetReflection,
                     HotSpotReplacementsImpl replacements, HotSpotWordTypes wordTypes) {
         Plugins plugins = HotSpotGraphBuilderPlugins.create(compilerConfiguration, config, wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, replacements);
-        AArch64GraphBuilderPlugins.register(plugins, replacements.getDefaultReplacementBytecodeProvider(), false);
+        AArch64GraphBuilderPlugins.register(plugins, replacements.getDefaultReplacementBytecodeProvider(), false, //
+                        /* registerMathPlugins */true);
         return plugins;
     }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java	Tue Apr 09 11:48:54 2019 +0100
@@ -113,7 +113,7 @@
     private HotSpotDebugInfoBuilder debugInfoBuilder;
 
     protected AArch64HotSpotLIRGenerator(HotSpotProviders providers, GraalHotSpotVMConfig config, LIRGenerationResult lirGenRes) {
-        this(new AArch64LIRKindTool(), new AArch64ArithmeticLIRGenerator(), new AArch64HotSpotMoveFactory(), providers, config, lirGenRes);
+        this(new AArch64LIRKindTool(), new AArch64ArithmeticLIRGenerator(null), new AArch64HotSpotMoveFactory(), providers, config, lirGenRes);
     }
 
     protected AArch64HotSpotLIRGenerator(LIRKindTool lirKindTool, AArch64ArithmeticLIRGenerator arithmeticLIRGen, MoveFactory moveFactory, HotSpotProviders providers, GraalHotSpotVMConfig config,
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64IndirectCallOp.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64IndirectCallOp.java	Tue Apr 09 11:48:54 2019 +0100
@@ -73,7 +73,9 @@
         crb.recordMark(config.MARKID_INLINE_INVOKE);
         Register callReg = asRegister(targetAddress);
         assert !callReg.equals(METHOD);
+        int pcOffset = masm.position();
         AArch64Call.indirectCall(crb, masm, callReg, callTarget, state);
+        crb.recordInlineInvokeCallOp(pcOffset, getPosition());
     }
 
     @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64ArrayCompareToStub.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,72 @@
+/*
+ * 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 org.graalvm.compiler.hotspot.amd64;
+
+import org.graalvm.compiler.api.replacements.Snippet;
+import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
+import org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage;
+import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
+import org.graalvm.compiler.hotspot.stubs.SnippetStub;
+import org.graalvm.compiler.options.OptionValues;
+import org.graalvm.compiler.replacements.nodes.ArrayCompareToNode;
+import jdk.internal.vm.compiler.word.Pointer;
+
+import jdk.vm.ci.meta.JavaKind;
+
+public final class AMD64ArrayCompareToStub extends SnippetStub {
+
+    public static final ForeignCallDescriptor STUB_BYTE_ARRAY_COMPARE_TO_BYTE_ARRAY = new ForeignCallDescriptor(
+                    "byteArrayCompareToByteArray", int.class, Pointer.class, Pointer.class, int.class, int.class);
+    public static final ForeignCallDescriptor STUB_BYTE_ARRAY_COMPARE_TO_CHAR_ARRAY = new ForeignCallDescriptor(
+                    "byteArrayCompareToCharArray", int.class, Pointer.class, Pointer.class, int.class, int.class);
+    public static final ForeignCallDescriptor STUB_CHAR_ARRAY_COMPARE_TO_BYTE_ARRAY = new ForeignCallDescriptor(
+                    "charArrayCompareToByteArray", int.class, Pointer.class, Pointer.class, int.class, int.class);
+    public static final ForeignCallDescriptor STUB_CHAR_ARRAY_COMPARE_TO_CHAR_ARRAY = new ForeignCallDescriptor(
+                    "charArrayCompareToCharArray", int.class, Pointer.class, Pointer.class, int.class, int.class);
+
+    public AMD64ArrayCompareToStub(ForeignCallDescriptor foreignCallDescriptor, OptionValues options, HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
+        super(foreignCallDescriptor.getName(), options, providers, linkage);
+    }
+
+    @Snippet
+    private static int byteArrayCompareToByteArray(Pointer array1, Pointer array2, int length1, int length2) {
+        return ArrayCompareToNode.compareTo(array1, array2, length1, length2, JavaKind.Byte, JavaKind.Byte);
+    }
+
+    @Snippet
+    private static int byteArrayCompareToCharArray(Pointer array1, Pointer array2, int length1, int length2) {
+        return ArrayCompareToNode.compareTo(array1, array2, length1, length2, JavaKind.Byte, JavaKind.Char);
+    }
+
+    @Snippet
+    private static int charArrayCompareToByteArray(Pointer array1, Pointer array2, int length1, int length2) {
+        return ArrayCompareToNode.compareTo(array1, array2, length1, length2, JavaKind.Char, JavaKind.Byte);
+    }
+
+    @Snippet
+    private static int charArrayCompareToCharArray(Pointer array1, Pointer array2, int length1, int length2) {
+        return ArrayCompareToNode.compareTo(array1, array2, length1, length2, JavaKind.Char, JavaKind.Char);
+    }
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64ArrayEqualsStub.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64ArrayEqualsStub.java	Tue Apr 09 11:48:54 2019 +0100
@@ -31,6 +31,7 @@
 import org.graalvm.compiler.hotspot.stubs.SnippetStub;
 import org.graalvm.compiler.options.OptionValues;
 import org.graalvm.compiler.replacements.nodes.ArrayEqualsNode;
+import org.graalvm.compiler.replacements.nodes.ArrayRegionEqualsNode;
 import jdk.internal.vm.compiler.word.Pointer;
 
 import jdk.vm.ci.meta.JavaKind;
@@ -54,6 +55,13 @@
     public static final ForeignCallDescriptor STUB_DOUBLE_ARRAY_EQUALS = new ForeignCallDescriptor(
                     "doubleArraysEquals", boolean.class, Pointer.class, Pointer.class, int.class);
 
+    public static final ForeignCallDescriptor STUB_BYTE_ARRAY_EQUALS_DIRECT = new ForeignCallDescriptor(
+                    "byteArraysEqualsDirect", boolean.class, Pointer.class, Pointer.class, int.class);
+    public static final ForeignCallDescriptor STUB_CHAR_ARRAY_EQUALS_DIRECT = new ForeignCallDescriptor(
+                    "charArraysEqualsDirect", boolean.class, Pointer.class, Pointer.class, int.class);
+    public static final ForeignCallDescriptor STUB_CHAR_ARRAY_EQUALS_BYTE_ARRAY = new ForeignCallDescriptor(
+                    "charArrayEqualsByteArray", boolean.class, Pointer.class, Pointer.class, int.class);
+
     public AMD64ArrayEqualsStub(ForeignCallDescriptor foreignCallDescriptor, OptionValues options, HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
         super(foreignCallDescriptor.getName(), options, providers, linkage);
     }
@@ -97,4 +105,19 @@
     private static boolean doubleArraysEquals(Pointer array1, Pointer array2, int length) {
         return ArrayEqualsNode.equals(array1, array2, length, JavaKind.Double);
     }
+
+    @Snippet
+    private static boolean byteArraysEqualsDirect(Pointer array1, Pointer array2, int length) {
+        return ArrayRegionEqualsNode.regionEquals(array1, array2, length, JavaKind.Byte, JavaKind.Byte);
+    }
+
+    @Snippet
+    private static boolean charArraysEqualsDirect(Pointer array1, Pointer array2, int length) {
+        return ArrayRegionEqualsNode.regionEquals(array1, array2, length, JavaKind.Char, JavaKind.Char);
+    }
+
+    @Snippet
+    private static boolean charArrayEqualsByteArray(Pointer array1, Pointer array2, int length) {
+        return ArrayRegionEqualsNode.regionEquals(array1, array2, length, JavaKind.Char, JavaKind.Byte);
+    }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java	Tue Apr 09 11:48:54 2019 +0100
@@ -137,6 +137,22 @@
                         registerStubCall(AMD64ArrayEqualsStub.STUB_FLOAT_ARRAY_EQUALS, LEAF, REEXECUTABLE, NO_LOCATIONS)));
         link(new AMD64ArrayEqualsStub(AMD64ArrayEqualsStub.STUB_DOUBLE_ARRAY_EQUALS, options, providers,
                         registerStubCall(AMD64ArrayEqualsStub.STUB_DOUBLE_ARRAY_EQUALS, LEAF, REEXECUTABLE, NO_LOCATIONS)));
+        link(new AMD64ArrayEqualsStub(AMD64ArrayEqualsStub.STUB_BYTE_ARRAY_EQUALS_DIRECT, options, providers,
+                        registerStubCall(AMD64ArrayEqualsStub.STUB_BYTE_ARRAY_EQUALS_DIRECT, LEAF, REEXECUTABLE, NO_LOCATIONS)));
+        link(new AMD64ArrayEqualsStub(AMD64ArrayEqualsStub.STUB_CHAR_ARRAY_EQUALS_DIRECT, options, providers,
+                        registerStubCall(AMD64ArrayEqualsStub.STUB_CHAR_ARRAY_EQUALS_DIRECT, LEAF, REEXECUTABLE, NO_LOCATIONS)));
+        link(new AMD64ArrayEqualsStub(AMD64ArrayEqualsStub.STUB_CHAR_ARRAY_EQUALS_BYTE_ARRAY, options, providers,
+                        registerStubCall(AMD64ArrayEqualsStub.STUB_CHAR_ARRAY_EQUALS_BYTE_ARRAY, LEAF, REEXECUTABLE, NO_LOCATIONS)));
+
+        link(new AMD64ArrayCompareToStub(AMD64ArrayCompareToStub.STUB_BYTE_ARRAY_COMPARE_TO_BYTE_ARRAY, options, providers,
+                        registerStubCall(AMD64ArrayCompareToStub.STUB_BYTE_ARRAY_COMPARE_TO_BYTE_ARRAY, LEAF, REEXECUTABLE, NO_LOCATIONS)));
+        link(new AMD64ArrayCompareToStub(AMD64ArrayCompareToStub.STUB_BYTE_ARRAY_COMPARE_TO_CHAR_ARRAY, options, providers,
+                        registerStubCall(AMD64ArrayCompareToStub.STUB_BYTE_ARRAY_COMPARE_TO_CHAR_ARRAY, LEAF, REEXECUTABLE, NO_LOCATIONS)));
+        link(new AMD64ArrayCompareToStub(AMD64ArrayCompareToStub.STUB_CHAR_ARRAY_COMPARE_TO_BYTE_ARRAY, options, providers,
+                        registerStubCall(AMD64ArrayCompareToStub.STUB_CHAR_ARRAY_COMPARE_TO_BYTE_ARRAY, LEAF, REEXECUTABLE, NO_LOCATIONS)));
+        link(new AMD64ArrayCompareToStub(AMD64ArrayCompareToStub.STUB_CHAR_ARRAY_COMPARE_TO_CHAR_ARRAY, options, providers,
+                        registerStubCall(AMD64ArrayCompareToStub.STUB_CHAR_ARRAY_COMPARE_TO_CHAR_ARRAY, LEAF, REEXECUTABLE, NO_LOCATIONS)));
+
         super.initialize(providers, options);
     }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Tue Apr 09 11:48:54 2019 +0100
@@ -676,32 +676,4 @@
     protected StrategySwitchOp createStrategySwitchOp(SwitchStrategy strategy, LabelRef[] keyTargets, LabelRef defaultTarget, Variable key, AllocatableValue temp) {
         return new AMD64HotSpotStrategySwitchOp(strategy, keyTargets, defaultTarget, key, temp);
     }
-
-    @Override
-    public ForeignCallLinkage lookupArrayEqualsStub(JavaKind kind, int constantLength) {
-        if (constantLength >= 0 && constantLength * kind.getByteCount() < 2 * getMaxVectorSize()) {
-            // Yield constant-length arrays comparison assembly
-            return null;
-        }
-        switch (kind) {
-            case Boolean:
-                return getForeignCalls().lookupForeignCall(AMD64ArrayEqualsStub.STUB_BOOLEAN_ARRAY_EQUALS);
-            case Byte:
-                return getForeignCalls().lookupForeignCall(AMD64ArrayEqualsStub.STUB_BYTE_ARRAY_EQUALS);
-            case Char:
-                return getForeignCalls().lookupForeignCall(AMD64ArrayEqualsStub.STUB_CHAR_ARRAY_EQUALS);
-            case Short:
-                return getForeignCalls().lookupForeignCall(AMD64ArrayEqualsStub.STUB_SHORT_ARRAY_EQUALS);
-            case Int:
-                return getForeignCalls().lookupForeignCall(AMD64ArrayEqualsStub.STUB_INT_ARRAY_EQUALS);
-            case Long:
-                return getForeignCalls().lookupForeignCall(AMD64ArrayEqualsStub.STUB_LONG_ARRAY_EQUALS);
-            case Float:
-                return getForeignCalls().lookupForeignCall(AMD64ArrayEqualsStub.STUB_FLOAT_ARRAY_EQUALS);
-            case Double:
-                return getForeignCalls().lookupForeignCall(AMD64ArrayEqualsStub.STUB_DOUBLE_ARRAY_EQUALS);
-            default:
-                return null;
-        }
-    }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java	Tue Apr 09 11:48:54 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
@@ -28,9 +28,11 @@
 import static jdk.vm.ci.code.ValueUtil.isStackSlot;
 import static org.graalvm.compiler.hotspot.HotSpotBackend.EXCEPTION_HANDLER_IN_CALLER;
 
+import org.graalvm.compiler.api.replacements.Snippet;
 import org.graalvm.compiler.core.amd64.AMD64NodeLIRBuilder;
 import org.graalvm.compiler.core.amd64.AMD64NodeMatchRules;
 import org.graalvm.compiler.core.common.LIRKind;
+import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
 import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
 import org.graalvm.compiler.core.gen.DebugInfoBuilder;
 import org.graalvm.compiler.hotspot.HotSpotDebugInfoBuilder;
@@ -54,6 +56,8 @@
 import org.graalvm.compiler.nodes.StructuredGraph;
 import org.graalvm.compiler.nodes.ValueNode;
 import org.graalvm.compiler.nodes.spi.NodeValueMap;
+import org.graalvm.compiler.replacements.nodes.ArrayCompareToNode;
+import org.graalvm.compiler.replacements.nodes.ArrayEqualsNode;
 
 import jdk.vm.ci.amd64.AMD64;
 import jdk.vm.ci.amd64.AMD64Kind;
@@ -66,8 +70,11 @@
 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
 import jdk.vm.ci.meta.AllocatableValue;
+import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.JavaType;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.Value;
+import org.graalvm.compiler.replacements.nodes.ArrayRegionEqualsNode;
 
 /**
  * LIR generator specialized for AMD64 HotSpot.
@@ -196,4 +203,98 @@
         Value[] parameters = visitInvokeArguments(gen.getRegisterConfig().getCallingConvention(HotSpotCallingConventionType.JavaCall, null, sig, gen), node.arguments());
         append(new AMD64BreakpointOp(parameters));
     }
+
+    private ForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) {
+        return getGen().getForeignCalls().lookupForeignCall(descriptor);
+    }
+
+    @Override
+    public ForeignCallLinkage lookupGraalStub(ValueNode valueNode) {
+        ResolvedJavaMethod method = valueNode.graph().method();
+        if (method == null || method.getAnnotation(Snippet.class) != null) {
+            // Emit assembly for snippet stubs
+            return null;
+        }
+
+        if (valueNode instanceof ArrayEqualsNode) {
+            ArrayEqualsNode arrayEqualsNode = (ArrayEqualsNode) valueNode;
+            JavaKind kind = arrayEqualsNode.getKind();
+            ValueNode length = arrayEqualsNode.getLength();
+
+            if (length.isConstant()) {
+                int constantLength = length.asJavaConstant().asInt();
+                if (constantLength >= 0 && constantLength * kind.getByteCount() < 2 * getGen().getMaxVectorSize()) {
+                    // Yield constant-length arrays comparison assembly
+                    return null;
+                }
+            }
+
+            switch (kind) {
+                case Boolean:
+                    return lookupForeignCall(AMD64ArrayEqualsStub.STUB_BOOLEAN_ARRAY_EQUALS);
+                case Byte:
+                    return lookupForeignCall(AMD64ArrayEqualsStub.STUB_BYTE_ARRAY_EQUALS);
+                case Char:
+                    return lookupForeignCall(AMD64ArrayEqualsStub.STUB_CHAR_ARRAY_EQUALS);
+                case Short:
+                    return lookupForeignCall(AMD64ArrayEqualsStub.STUB_SHORT_ARRAY_EQUALS);
+                case Int:
+                    return lookupForeignCall(AMD64ArrayEqualsStub.STUB_INT_ARRAY_EQUALS);
+                case Long:
+                    return lookupForeignCall(AMD64ArrayEqualsStub.STUB_LONG_ARRAY_EQUALS);
+                case Float:
+                    return lookupForeignCall(AMD64ArrayEqualsStub.STUB_FLOAT_ARRAY_EQUALS);
+                case Double:
+                    return lookupForeignCall(AMD64ArrayEqualsStub.STUB_DOUBLE_ARRAY_EQUALS);
+                default:
+                    return null;
+            }
+        } else if (valueNode instanceof ArrayCompareToNode) {
+            ArrayCompareToNode arrayCompareToNode = (ArrayCompareToNode) valueNode;
+            JavaKind kind1 = arrayCompareToNode.getKind1();
+            JavaKind kind2 = arrayCompareToNode.getKind2();
+
+            if (kind1 == JavaKind.Byte) {
+                if (kind2 == JavaKind.Byte) {
+                    return lookupForeignCall(AMD64ArrayCompareToStub.STUB_BYTE_ARRAY_COMPARE_TO_BYTE_ARRAY);
+                } else if (kind2 == JavaKind.Char) {
+                    return lookupForeignCall(AMD64ArrayCompareToStub.STUB_BYTE_ARRAY_COMPARE_TO_CHAR_ARRAY);
+                }
+            } else if (kind1 == JavaKind.Char) {
+                if (kind2 == JavaKind.Byte) {
+                    return lookupForeignCall(AMD64ArrayCompareToStub.STUB_CHAR_ARRAY_COMPARE_TO_BYTE_ARRAY);
+                } else if (kind2 == JavaKind.Char) {
+                    return lookupForeignCall(AMD64ArrayCompareToStub.STUB_CHAR_ARRAY_COMPARE_TO_CHAR_ARRAY);
+                }
+            }
+        } else if (valueNode instanceof ArrayRegionEqualsNode) {
+            ArrayRegionEqualsNode arrayRegionEqualsNode = (ArrayRegionEqualsNode) valueNode;
+            JavaKind kind1 = arrayRegionEqualsNode.getKind1();
+            JavaKind kind2 = arrayRegionEqualsNode.getKind2();
+            ValueNode length = arrayRegionEqualsNode.getLength();
+
+            if (length.isConstant()) {
+                int constantLength = length.asJavaConstant().asInt();
+                if (constantLength >= 0 && constantLength * (Math.max(kind1.getByteCount(), kind2.getByteCount())) < 2 * getGen().getMaxVectorSize()) {
+                    // Yield constant-length arrays comparison assembly
+                    return null;
+                }
+            }
+
+            if (kind1 == kind2) {
+                switch (kind1) {
+                    case Byte:
+                        return lookupForeignCall(AMD64ArrayEqualsStub.STUB_BYTE_ARRAY_EQUALS_DIRECT);
+                    case Char:
+                        return lookupForeignCall(AMD64ArrayEqualsStub.STUB_CHAR_ARRAY_EQUALS_DIRECT);
+                    default:
+                        return null;
+                }
+            } else if (kind1 == JavaKind.Char && kind2 == JavaKind.Byte) {
+                return lookupForeignCall(AMD64ArrayEqualsStub.STUB_CHAR_ARRAY_EQUALS_BYTE_ARRAY);
+            }
+        }
+
+        return null;
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/NodeCostDumpUtil.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,237 @@
+/*
+ * 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
+ * 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 org.graalvm.compiler.hotspot.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+import java.util.stream.Collectors;
+
+import org.graalvm.compiler.debug.CSVUtil;
+import org.graalvm.compiler.debug.GraalError;
+import org.graalvm.compiler.graph.Node;
+import org.graalvm.compiler.graph.NodeClass;
+import org.graalvm.compiler.graph.spi.Canonicalizable;
+import org.graalvm.compiler.nodes.memory.MemoryCheckpoint;
+import org.graalvm.compiler.nodes.spi.Virtualizable;
+
+public class NodeCostDumpUtil {
+
+    private static final String prefix1 = "com.oracle.";
+    private static final String prefix2 = "org.graalvm.";
+    private static final String FMT = CSVUtil.buildFormatString("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s");
+
+    private static String getArgumentRegex(String arg) {
+        if (arg.length() == 0) {
+            return null;
+        }
+        try {
+            Pattern.compile(arg);
+            return arg;
+        } catch (PatternSyntaxException e) {
+            // silently ignore
+            System.err.println("Invalid regex given, defaulting to \".*\" regex..");
+            return null;
+        }
+    }
+
+    public static void main(String[] args) {
+        if (args.length != 1) {
+            System.err.println("NodeCostDumpUtil expects exactly one argument, the node name regex to match against.");
+            System.exit(-1);
+        }
+        final String pattern = getArgumentRegex(args[0]);
+        String version = System.getProperty("java.specification.version");
+        if (version.compareTo("1.9") >= 0) {
+            System.err.printf("NodeCostDumpUtil does not support JDK versions greater than 1.8, current version is %s.\n", version);
+            System.exit(-1);
+        }
+        String[] jvmciCP = System.getProperty("jvmci.class.path.append").split(File.pathSeparator);
+        String[] primarySuiteCP = System.getProperty("primary.suite.cp").split(File.pathSeparator);
+        ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader();
+        HashSet<Class<?>> classes = new HashSet<>();
+        try {
+            Set<String> uniquePaths = new HashSet<>(Arrays.asList(primarySuiteCP));
+            uniquePaths.addAll(Arrays.asList(jvmciCP));
+            for (String path : uniquePaths) {
+                if (new File(path).exists()) {
+                    if (path.endsWith(".jar")) {
+                        try (FileSystem jarFileSystem = FileSystems.newFileSystem(URI.create("jar:file:" + path), Collections.emptyMap())) {
+                            initAllClasses(jarFileSystem.getPath("/"), applicationClassLoader, classes);
+                        }
+                    } else {
+                        initAllClasses(FileSystems.getDefault().getPath(path), applicationClassLoader, classes);
+                    }
+                }
+            }
+        } catch (IOException ex) {
+            GraalError.shouldNotReachHere();
+        }
+        System.err.printf("Loaded %d classes...\n", classes.size());
+        List<Class<?>> nodeClasses = new ArrayList<>();
+        for (Class<?> loaded : classes) {
+            if (Node.class.isAssignableFrom(loaded) && !loaded.isArray()) {
+                nodeClasses.add(loaded);
+            }
+        }
+        System.err.printf("Loaded %s node classes...\n", nodeClasses.size());
+        List<NodeClass<?>> nc = new ArrayList<>();
+        for (Class<?> c : nodeClasses) {
+            try {
+                nc.add(NodeClass.get(c));
+            } catch (Throwable t) {
+                // Silently ignore problems here
+            }
+        }
+        System.err.printf("Read TYPE field from %s node classes...\n", nc.size());
+        nc = nc.stream().filter(x -> x != null).collect(Collectors.toList());
+        nc.sort((x, y) -> {
+            String a = x.getJavaClass().getName();
+            String b = y.getJavaClass().getName();
+            return a.compareTo(b);
+        });
+        CSVUtil.Escape.println(System.out, FMT, "NodeName", "Size", "Overrides Size Method", "Cycles", "Overrides Cycles Method", "Canonicalizable", "MemoryCheckPoint", "Virtualizable");
+        for (NodeClass<?> nodeclass : nc) {
+            String packageStrippedName = null;
+            try {
+                packageStrippedName = nodeclass.getJavaClass().getCanonicalName().replace(prefix1, "").replace(prefix2, "");
+            } catch (Throwable t) {
+                // do nothing
+                continue;
+            }
+            if (pattern != null && !packageStrippedName.matches(pattern)) {
+                continue;
+            }
+            boolean overridesSizeMethod = false;
+            boolean overridesCyclesMethod = false;
+            Class<?> c = nodeclass.getJavaClass();
+            try {
+                c.getDeclaredMethod("estimatedNodeSize");
+                overridesSizeMethod = true;
+            } catch (Throwable t) {
+                // do nothing
+            }
+            try {
+                c.getDeclaredMethod("estimatedNodeCycles");
+                overridesCyclesMethod = true;
+            } catch (Throwable t) {
+                // do nothing
+            }
+            CSVUtil.Escape.println(System.out, FMT, packageStrippedName, nodeclass.size(), overridesSizeMethod, nodeclass.cycles(), overridesCyclesMethod, canonicalizable(c), memoryCheckPoint(c),
+                            virtualizable(c));
+        }
+    }
+
+    private static boolean canonicalizable(Class<?> c) {
+        return Canonicalizable.class.isAssignableFrom(c);
+    }
+
+    private static boolean virtualizable(Class<?> c) {
+        return Virtualizable.class.isAssignableFrom(c);
+    }
+
+    private static boolean memoryCheckPoint(Class<?> c) {
+        return MemoryCheckpoint.class.isAssignableFrom(c);
+    }
+
+    private static void initAllClasses(final Path root, ClassLoader classLoader, HashSet<Class<?>> classes) {
+        try {
+            Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
+                @Override
+                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+                    String className = root.relativize(file).toString();
+                    ClassLoader c = classLoader;
+                    if (className.endsWith(".class")) {
+                        String prefix = prefixed(className);
+                        if (prefix != null) {
+                            String stripped = stripClassName(className);
+                            c = new URLClassLoader(new URL[]{new File(constructURLPart(stripped, className, prefix)).toURI().toURL()}, classLoader);
+                            className = constructClazzPart(stripped, prefix);
+                        } else {
+                            String clazzPart = className.replace('/', '.');
+                            className = clazzPart.substring(0, clazzPart.length() - ".class".length());
+                        }
+                        try {
+                            Class<?> systemClass = Class.forName(className, false, c);
+                            if (systemClass.getEnclosingClass() != null) {
+                                try {
+                                    classes.add(systemClass.getEnclosingClass());
+                                } catch (Throwable t) {
+                                    // do nothing
+                                }
+                            }
+                            classes.add(systemClass);
+                        } catch (Throwable ignored) {
+                        }
+                    }
+                    return FileVisitResult.CONTINUE;
+                }
+            });
+        } catch (IOException ex) {
+            GraalError.shouldNotReachHere();
+        }
+    }
+
+    private static String prefixed(String className) {
+        if (className.contains(prefix1) && className.indexOf(prefix1) > 0) {
+            return prefix1;
+        } else if (className.contains(prefix2) && className.indexOf(prefix2) > 0) {
+            return prefix2;
+        }
+        return null;
+    }
+
+    private static String stripClassName(String className) {
+        return className.replace('/', '.');
+    }
+
+    private static String constructClazzPart(String stripped, String prefix) {
+        String clazzPart = stripped.substring(stripped.lastIndexOf(prefix), stripped.length());
+        return clazzPart.substring(0, clazzPart.length() - ".class".length());
+    }
+
+    private static String constructURLPart(String stripped, String className, String prefix) {
+        return className.substring(0, stripped.lastIndexOf(prefix));
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/StringInternConstantTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,73 @@
+/*
+ * 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 org.graalvm.compiler.hotspot.test;
+
+import org.graalvm.compiler.core.test.GraalCompilerTest;
+import org.graalvm.compiler.nodes.ConstantNode;
+import org.graalvm.compiler.nodes.FixedNode;
+import org.graalvm.compiler.nodes.ReturnNode;
+import org.graalvm.compiler.nodes.StructuredGraph;
+import org.junit.Test;
+
+import jdk.vm.ci.hotspot.HotSpotObjectConstant;
+import jdk.vm.ci.meta.Constant;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import org.junit.Assert;
+
+/**
+ * Tests constant folding of {@link String#intern()}.
+ */
+public class StringInternConstantTest extends GraalCompilerTest {
+
+    private static final String A_CONSTANT_STRING = "a constant string";
+
+    @Test
+    public void test1() {
+        ResolvedJavaMethod method = getResolvedJavaMethod("constantIntern");
+        StructuredGraph graph = parseForCompile(method);
+
+        FixedNode firstFixed = graph.start().next();
+        Assert.assertThat(firstFixed, instanceOf(ReturnNode.class));
+
+        ReturnNode ret = (ReturnNode) firstFixed;
+        if (ret.result() instanceof ConstantNode) {
+            String expected = A_CONSTANT_STRING.intern();
+            Constant constant = ((ConstantNode) ret.result()).getValue();
+            if (constant instanceof HotSpotObjectConstant) {
+                String returnedString = ((HotSpotObjectConstant) constant).asObject(String.class);
+                Assert.assertSame("result", expected, returnedString);
+            } else {
+                Assert.fail("expected HotSpotObjectConstant, got: " + constant.getClass());
+            }
+        } else {
+            Assert.fail("result not constant: " + ret.result());
+        }
+    }
+
+    public static String constantIntern() {
+        return A_CONSTANT_STRING.intern();
+    }
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/BootstrapWatchDog.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/BootstrapWatchDog.java	Tue Apr 09 11:48:54 2019 +0100
@@ -39,6 +39,7 @@
 import org.graalvm.compiler.options.OptionValues;
 
 import jdk.vm.ci.code.CompilationRequest;
+import jdk.vm.ci.services.Services;
 
 /**
  * A watch dog that monitors the duration and compilation rate during a
@@ -108,7 +109,7 @@
     /**
      * Set to true to debug the watch dog.
      */
-    private static final boolean DEBUG = Boolean.getBoolean("debug.graal.BootstrapWatchDog");
+    private static final boolean DEBUG = Boolean.parseBoolean(Services.getSavedProperties().get("debug.graal.BootstrapWatchDog"));
 
     /**
      * Seconds to delay before starting to measure the compilation rate.
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationStatistics.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationStatistics.java	Tue Apr 09 11:48:54 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
@@ -48,6 +48,7 @@
 
 import jdk.vm.ci.hotspot.HotSpotInstalledCode;
 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
+import jdk.vm.ci.services.Services;
 
 @SuppressWarnings("unused")
 public final class CompilationStatistics {
@@ -189,7 +190,7 @@
                         timeLeft = RESOLUTION;
                     }
                 }
-                String timelineName = System.getProperty("stats.timeline.name");
+                String timelineName = Services.getSavedProperties().get("stats.timeline.name");
                 if (timelineName != null && !timelineName.isEmpty()) {
                     out.printf("%s%c", CSVUtil.Escape.escape(timelineName), CSVUtil.SEPARATOR);
                 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationTask.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationTask.java	Tue Apr 09 11:48:54 2019 +0100
@@ -57,7 +57,6 @@
 import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
 import jdk.vm.ci.hotspot.HotSpotCompilationRequestResult;
 import jdk.vm.ci.hotspot.HotSpotInstalledCode;
-import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
 import jdk.vm.ci.hotspot.HotSpotNmethod;
 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
@@ -93,6 +92,7 @@
     private final boolean installAsDefault;
 
     private final boolean useProfilingInfo;
+    private final boolean shouldRetainLocalVariables;
     private final OptionValues options;
 
     final class HotSpotCompilationWrapper extends CompilationWrapper<HotSpotCompilationRequestResult> {
@@ -187,7 +187,7 @@
             try (DebugContext.Scope s = debug.scope("Compiling", new DebugDumpScope(getIdString(), true))) {
                 // Begin the compilation event.
                 compilationEvent.begin();
-                result = compiler.compile(method, entryBCI, useProfilingInfo, compilationId, options, debug);
+                result = compiler.compile(method, entryBCI, useProfilingInfo, shouldRetainLocalVariables, compilationId, options, debug);
             } catch (Throwable e) {
                 throw debug.handle(e);
             } finally {
@@ -213,10 +213,16 @@
 
     public CompilationTask(HotSpotJVMCIRuntime jvmciRuntime, HotSpotGraalCompiler compiler, HotSpotCompilationRequest request, boolean useProfilingInfo, boolean installAsDefault,
                     OptionValues options) {
+        this(jvmciRuntime, compiler, request, useProfilingInfo, false, installAsDefault, options);
+    }
+
+    public CompilationTask(HotSpotJVMCIRuntime jvmciRuntime, HotSpotGraalCompiler compiler, HotSpotCompilationRequest request, boolean useProfilingInfo, boolean shouldRetainLocalVariables,
+                    boolean installAsDefault, OptionValues options) {
         this.jvmciRuntime = jvmciRuntime;
         this.compiler = compiler;
         this.compilationId = new HotSpotCompilationIdentifier(request);
         this.useProfilingInfo = useProfilingInfo;
+        this.shouldRetainLocalVariables = shouldRetainLocalVariables;
         this.installAsDefault = installAsDefault;
 
         /*
@@ -321,15 +327,14 @@
         // Log a compilation event.
         EventProvider.CompilationEvent compilationEvent = eventProvider.newCompilationEvent();
 
-        if (installAsDefault) {
+        if (installAsDefault || isOSR) {
             // If there is already compiled code for this method on our level we simply return.
             // JVMCI compiles are always at the highest compile level, even in non-tiered mode so we
             // only need to check for that value.
             if (method.hasCodeAtLevel(entryBCI, config.compilationLevelFullOptimization)) {
                 return HotSpotCompilationRequestResult.failure("Already compiled", false);
             }
-            if (HotSpotGraalCompilerFactory.checkGraalCompileOnlyFilter(method.getDeclaringClass().toJavaName(), method.getName(), method.getSignature().toString(),
-                            HotSpotJVMCICompilerFactory.CompilationLevel.FullOptimization) != HotSpotJVMCICompilerFactory.CompilationLevel.FullOptimization) {
+            if (HotSpotGraalCompilerFactory.shouldExclude(method)) {
                 return HotSpotCompilationRequestResult.failure("GraalCompileOnly excluded", false);
             }
         }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationWatchDog.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationWatchDog.java	Tue Apr 09 11:48:54 2019 +0100
@@ -35,6 +35,7 @@
 import org.graalvm.compiler.options.OptionValues;
 
 import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.services.Services;
 
 /**
  * A watch dog for reporting long running compilations. This is designed to be an always on
@@ -166,7 +167,7 @@
     /**
      * Set to true to debug the watch dog.
      */
-    private static final boolean DEBUG = Boolean.getBoolean("debug.graal.CompilationWatchDog");
+    private static final boolean DEBUG = Boolean.parseBoolean(Services.getSavedProperties().get("debug.graal.CompilationWatchDog"));
 
     private void trace(String format, Object... args) {
         if (DEBUG) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java	Tue Apr 09 11:48:54 2019 +0100
@@ -316,14 +316,16 @@
     public final int jvmAccWrittenFlags = getConstant("JVM_ACC_WRITTEN_FLAGS", Integer.class);
     public final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class);
 
-    public final int jvmciCompileStateCanPostOnExceptionsOffset = getJvmciCompileStateCanPostOnExceptionsOffset();
+    public final int jvmciCompileStateCanPostOnExceptionsOffset = getJvmciJvmtiCapabilityOffset("_jvmti_can_post_on_exceptions");
+    public final int jvmciCompileStateCanPopFrameOffset = getJvmciJvmtiCapabilityOffset("_jvmti_can_pop_frame");
+    public final int jvmciCompileStateCanAccessLocalVariablesOffset = getJvmciJvmtiCapabilityOffset("_jvmti_can_access_local_variables");
 
     // Integer.MIN_VALUE if not available
-    private int getJvmciCompileStateCanPostOnExceptionsOffset() {
-        int offset = getFieldOffset("JVMCICompileState::_jvmti_can_post_on_exceptions", Integer.class, "jbyte", Integer.MIN_VALUE);
+    private int getJvmciJvmtiCapabilityOffset(String name) {
+        int offset = getFieldOffset("JVMCICompileState::" + name, Integer.class, "jbyte", Integer.MIN_VALUE);
         if (offset == Integer.MIN_VALUE) {
             // JDK 12
-            offset = getFieldOffset("JVMCIEnv::_jvmti_can_post_on_exceptions", Integer.class, "jbyte", Integer.MIN_VALUE);
+            offset = getFieldOffset("JVMCIEnv::" + name, Integer.class, "jbyte", Integer.MIN_VALUE);
         }
         return offset;
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfigBase.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfigBase.java	Tue Apr 09 11:48:54 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
@@ -36,9 +36,10 @@
 import jdk.vm.ci.hotspot.HotSpotVMConfigAccess;
 import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
 import jdk.vm.ci.meta.MetaAccessProvider;
+import jdk.vm.ci.services.Services;
 
 /**
- * This is a source with different versions for various JDKs.
+ * Base class of class hierarchy for accessing HotSpot VM configuration.
  */
 public abstract class GraalHotSpotVMConfigBase extends HotSpotVMConfigAccess {
 
@@ -62,6 +63,18 @@
         return true;
     }
 
+    private static String getProperty(String name, String def) {
+        String value = Services.getSavedProperties().get(name);
+        if (value == null) {
+            return def;
+        }
+        return value;
+    }
+
+    private static String getProperty(String name) {
+        return getProperty(name, null);
+    }
+
     /**
      * Contains values that are different between JDK versions.
      */
@@ -78,14 +91,14 @@
 
     public final String osName = getHostOSName();
     public final String osArch = getHostArchitectureName();
-    public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows");
-    public final boolean linuxOs = System.getProperty("os.name", "").startsWith("Linux");
+    public final boolean windowsOs = getProperty("os.name", "").startsWith("Windows");
+    public final boolean linuxOs = getProperty("os.name", "").startsWith("Linux");
 
     /**
      * Gets the host operating system name.
      */
     private static String getHostOSName() {
-        String osName = System.getProperty("os.name");
+        String osName = getProperty("os.name");
         switch (osName) {
             case "Linux":
                 osName = "linux";
@@ -108,7 +121,7 @@
     }
 
     private static String getHostArchitectureName() {
-        String arch = System.getProperty("os.arch");
+        String arch = getProperty("os.arch");
         switch (arch) {
             case "x86_64":
                 arch = "amd64";
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalCompiler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalCompiler.java	Tue Apr 09 11:48:54 2019 +0100
@@ -25,6 +25,7 @@
 package org.graalvm.compiler.hotspot;
 
 import static org.graalvm.compiler.core.common.GraalOptions.OptAssumptions;
+import org.graalvm.compiler.serviceprovider.GraalUnsafeAccess;
 
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
@@ -71,9 +72,11 @@
 import jdk.vm.ci.meta.SpeculationLog;
 import jdk.vm.ci.meta.TriState;
 import jdk.vm.ci.runtime.JVMCICompiler;
+import sun.misc.Unsafe;
 
 public class HotSpotGraalCompiler implements GraalJVMCICompiler {
 
+    private static final Unsafe UNSAFE = GraalUnsafeAccess.getUnsafe();
     private final HotSpotJVMCIRuntime jvmciRuntime;
     private final HotSpotGraalRuntimeProvider graalRuntime;
     private final CompilationCounters compilationCounters;
@@ -131,7 +134,7 @@
             if (compilationCounters != null) {
                 compilationCounters.countCompilation(method);
             }
-            CompilationTask task = new CompilationTask(jvmciRuntime, this, hsRequest, true, installAsDefault, options);
+            CompilationTask task = new CompilationTask(jvmciRuntime, this, hsRequest, true, shouldRetainLocalVariables(hsRequest.getJvmciEnv()), installAsDefault, options);
             CompilationRequestResult r = null;
             try (DebugContext debug = graalRuntime.openDebugContext(options, task.getCompilationIdentifier(), method, getDebugHandlersFactories(), DebugContext.DEFAULT_LOG_STREAM);
                             Activation a = debug.activate()) {
@@ -142,6 +145,24 @@
         }
     }
 
+    private boolean shouldRetainLocalVariables(long envAddress) {
+        GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
+        if (envAddress == 0) {
+            return false;
+        }
+        if (config.jvmciCompileStateCanPopFrameOffset != Integer.MIN_VALUE) {
+            if ((UNSAFE.getByte(envAddress + config.jvmciCompileStateCanPopFrameOffset) & 0xFF) != 0) {
+                return true;
+            }
+        }
+        if (config.jvmciCompileStateCanAccessLocalVariablesOffset != Integer.MIN_VALUE) {
+            if ((UNSAFE.getByte(envAddress + config.jvmciCompileStateCanAccessLocalVariablesOffset) & 0xFF) != 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     public StructuredGraph createGraph(ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, CompilationIdentifier compilationId, OptionValues options, DebugContext debug) {
         HotSpotBackend backend = graalRuntime.getHostBackend();
         HotSpotProviders providers = backend.getProviders();
@@ -161,6 +182,11 @@
 
     public CompilationResult compileHelper(CompilationResultBuilderFactory crbf, CompilationResult result, StructuredGraph graph, ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo,
                     OptionValues options) {
+        return compileHelper(crbf, result, graph, method, entryBCI, useProfilingInfo, false, options);
+    }
+
+    public CompilationResult compileHelper(CompilationResultBuilderFactory crbf, CompilationResult result, StructuredGraph graph, ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo,
+                    boolean shouldRetainLocalVariables, OptionValues options) {
 
         HotSpotBackend backend = graalRuntime.getHostBackend();
         HotSpotProviders providers = backend.getProviders();
@@ -181,7 +207,7 @@
 
         result.setEntryBCI(entryBCI);
         boolean shouldDebugNonSafepoints = providers.getCodeCache().shouldDebugNonSafepoints();
-        PhaseSuite<HighTierContext> graphBuilderSuite = configGraphBuilderSuite(providers.getSuites().getDefaultGraphBuilderSuite(), shouldDebugNonSafepoints, isOSR);
+        PhaseSuite<HighTierContext> graphBuilderSuite = configGraphBuilderSuite(providers.getSuites().getDefaultGraphBuilderSuite(), shouldDebugNonSafepoints, shouldRetainLocalVariables, isOSR);
         GraalCompiler.compileGraph(graph, method, providers, backend, graphBuilderSuite, optimisticOpts, profilingInfo, suites, lirSuites, result, crbf, true);
 
         if (!isOSR && useProfilingInfo) {
@@ -193,9 +219,14 @@
     }
 
     public CompilationResult compile(ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, CompilationIdentifier compilationId, OptionValues options, DebugContext debug) {
+        return compile(method, entryBCI, useProfilingInfo, false, compilationId, options, debug);
+    }
+
+    public CompilationResult compile(ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, boolean shouldRetainLocalVariables, CompilationIdentifier compilationId, OptionValues options,
+                    DebugContext debug) {
         StructuredGraph graph = createGraph(method, entryBCI, useProfilingInfo, compilationId, options, debug);
         CompilationResult result = new CompilationResult(compilationId);
-        return compileHelper(CompilationResultBuilderFactory.Default, result, graph, method, entryBCI, useProfilingInfo, options);
+        return compileHelper(CompilationResultBuilderFactory.Default, result, graph, method, entryBCI, useProfilingInfo, shouldRetainLocalVariables, options);
     }
 
     protected OptimisticOptimizations getOptimisticOpts(ProfilingInfo profilingInfo, OptionValues options) {
@@ -217,27 +248,26 @@
      * @param suite the graph builder suite
      * @param shouldDebugNonSafepoints specifies if extra debug info should be generated (default is
      *            false)
+     * @param shouldRetainLocalVariables specifies if local variables should be retained for
+     *            debugging purposes (default is false)
      * @param isOSR specifies if extra OSR-specific post-processing is required (default is false)
      * @return a new suite derived from {@code suite} if any of the GBS parameters did not have a
      *         default value otherwise {@code suite}
      */
-    protected PhaseSuite<HighTierContext> configGraphBuilderSuite(PhaseSuite<HighTierContext> suite, boolean shouldDebugNonSafepoints, boolean isOSR) {
-        if (shouldDebugNonSafepoints || isOSR) {
+    protected PhaseSuite<HighTierContext> configGraphBuilderSuite(PhaseSuite<HighTierContext> suite, boolean shouldDebugNonSafepoints, boolean shouldRetainLocalVariables, boolean isOSR) {
+        if (shouldDebugNonSafepoints || shouldRetainLocalVariables || isOSR) {
             PhaseSuite<HighTierContext> newGbs = suite.copy();
-
+            GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
+            GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
             if (shouldDebugNonSafepoints) {
-                GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
-                GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
                 graphBuilderConfig = graphBuilderConfig.withNodeSourcePosition(true);
-                GraphBuilderPhase newGraphBuilderPhase = new GraphBuilderPhase(graphBuilderConfig);
-                newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
             }
+            if (shouldRetainLocalVariables) {
+                graphBuilderConfig = graphBuilderConfig.withRetainLocalVariables(true);
+            }
+            GraphBuilderPhase newGraphBuilderPhase = new GraphBuilderPhase(graphBuilderConfig);
+            newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
             if (isOSR) {
-                // We must not clear non liveness for OSR compilations.
-                GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
-                GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
-                GraphBuilderPhase newGraphBuilderPhase = new GraphBuilderPhase(graphBuilderConfig);
-                newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
                 newGbs.appendPhase(new OnStackReplacementPhase());
             }
             return newGbs;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalCompilerFactory.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalCompilerFactory.java	Tue Apr 09 11:48:54 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,7 +25,9 @@
 package org.graalvm.compiler.hotspot;
 
 import static jdk.vm.ci.common.InitTimer.timer;
+import static jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory.CompilationLevelAdjustment.None;
 import static jdk.vm.ci.services.Services.IS_BUILDING_NATIVE_IMAGE;
+import static jdk.vm.ci.services.Services.IS_IN_NATIVE_IMAGE;
 import static org.graalvm.compiler.hotspot.HotSpotGraalOptionValues.GRAAL_OPTION_PROPERTY_PREFIX;
 
 import java.io.PrintStream;
@@ -42,8 +44,10 @@
 import jdk.vm.ci.common.InitTimer;
 import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
-import jdk.vm.ci.hotspot.HotSpotSignature;
+import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
+import jdk.vm.ci.meta.Signature;
 import jdk.vm.ci.runtime.JVMCIRuntime;
+import jdk.vm.ci.services.Services;
 
 public final class HotSpotGraalCompilerFactory extends HotSpotJVMCICompilerFactory {
 
@@ -70,7 +74,7 @@
 
     @Override
     public void onSelection() {
-        JVMCIVersionCheck.check(false);
+        JVMCIVersionCheck.check(Services.getSavedProperties(), false);
         assert options == null : "cannot select " + getClass() + " service more than once";
         options = HotSpotGraalOptionValues.defaultOptions();
         initializeGraalCompilePolicyFields(options);
@@ -79,8 +83,10 @@
          * Exercise this code path early to encourage loading now. This doesn't solve problem of
          * deadlock during class loading but seems to eliminate it in practice.
          */
-        adjustCompilationLevelInternal(Object.class, "hashCode", "()I", CompilationLevel.FullOptimization);
-        adjustCompilationLevelInternal(Object.class, "hashCode", "()I", CompilationLevel.Simple);
+        if (isGraalPredicate != null && isGraalPredicate.getCompilationLevelAdjustment() != None) {
+            adjustCompilationLevelInternal(Object.class, CompilationLevel.FullOptimization);
+            adjustCompilationLevelInternal(Object.class, CompilationLevel.Simple);
+        }
         if (IS_BUILDING_NATIVE_IMAGE) {
             // Triggers initialization of all option descriptors
             Options.CompileGraalWithC1Only.getName();
@@ -88,7 +94,7 @@
     }
 
     private static void initializeGraalCompilePolicyFields(OptionValues options) {
-        compileGraalWithC1Only = Options.CompileGraalWithC1Only.getValue(options);
+        compileGraalWithC1Only = Options.CompileGraalWithC1Only.getValue(options) && !IS_IN_NATIVE_IMAGE;
         String optionValue = Options.GraalCompileOnly.getValue(options);
         if (optionValue != null) {
             MethodFilter[] filter = MethodFilter.parse(optionValue);
@@ -123,7 +129,7 @@
     public HotSpotGraalCompiler createCompiler(JVMCIRuntime runtime) {
         CompilerConfigurationFactory factory = CompilerConfigurationFactory.selectFactory(null, options);
         if (isGraalPredicate != null) {
-            isGraalPredicate.onCompilerConfigurationFactorySelection(factory);
+            isGraalPredicate.onCompilerConfigurationFactorySelection((HotSpotJVMCIRuntime) runtime, factory);
         }
         HotSpotGraalCompiler compiler = createCompiler("VM", runtime, options, factory);
         // Only the HotSpotGraalRuntime associated with the compiler created via
@@ -154,27 +160,13 @@
 
     @Override
     public CompilationLevelAdjustment getCompilationLevelAdjustment() {
-        if (graalCompileOnlyFilter != null) {
-            return CompilationLevelAdjustment.ByFullSignature;
-        }
-        if (compileGraalWithC1Only) {
-            // We only decide using the class declaring the method
-            // so no need to have the method name and signature
-            // symbols converted to a String.
-            return CompilationLevelAdjustment.ByHolder;
-        }
-        return CompilationLevelAdjustment.None;
+        return isGraalPredicate != null ? isGraalPredicate.getCompilationLevelAdjustment() : None;
     }
 
     @Override
     public CompilationLevel adjustCompilationLevel(Object declaringClassObject, String name, String signature, boolean isOsr, CompilationLevel level) {
-        if (declaringClassObject instanceof String) {
-            // This must be SVM mode in which case only GraalCompileC1Only matters since Graal and
-            // JVMCI are already compiled.
-            return checkGraalCompileOnlyFilter((String) declaringClassObject, name, signature, level);
-        }
         Class<?> declaringClass = (Class<?>) declaringClassObject;
-        return adjustCompilationLevelInternal(declaringClass, name, signature, level);
+        return adjustCompilationLevelInternal(declaringClass, level);
     }
 
     static {
@@ -184,32 +176,28 @@
         assert HotSpotGraalCompilerFactory.class.getName().equals("org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory");
     }
 
-    private CompilationLevel adjustCompilationLevelInternal(Class<?> declaringClass, String name, String signature, CompilationLevel level) {
-        if (compileGraalWithC1Only) {
-            if (level.ordinal() > CompilationLevel.Simple.ordinal()) {
-                if (isGraalPredicate.apply(declaringClass)) {
-                    return CompilationLevel.Simple;
-                }
-            }
-        }
-        return checkGraalCompileOnlyFilter(declaringClass.getName(), name, signature, level);
-    }
-
-    public static CompilationLevel checkGraalCompileOnlyFilter(String declaringClassName, String name, String signature, CompilationLevel level) {
-        if (graalCompileOnlyFilter != null) {
-            if (level == CompilationLevel.FullOptimization) {
-                HotSpotSignature sig = null;
-                for (MethodFilter filter : graalCompileOnlyFilter) {
-                    if (filter.hasSignature() && sig == null) {
-                        sig = new HotSpotSignature(HotSpotJVMCIRuntime.runtime(), signature);
-                    }
-                    if (filter.matches(declaringClassName, name, sig)) {
-                        return level;
-                    }
-                }
+    private CompilationLevel adjustCompilationLevelInternal(Class<?> declaringClass, CompilationLevel level) {
+        assert isGraalPredicate != null;
+        if (level.ordinal() > CompilationLevel.Simple.ordinal()) {
+            if (isGraalPredicate.apply(declaringClass)) {
                 return CompilationLevel.Simple;
             }
         }
         return level;
     }
+
+    static boolean shouldExclude(HotSpotResolvedJavaMethod method) {
+        if (graalCompileOnlyFilter != null) {
+            String javaClassName = method.getDeclaringClass().toJavaName();
+            String name = method.getName();
+            Signature signature = method.getSignature();
+            for (MethodFilter filter : graalCompileOnlyFilter) {
+                if (filter.matches(javaClassName, name, signature)) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalRuntime.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalRuntime.java	Tue Apr 09 11:48:54 2019 +0100
@@ -87,6 +87,7 @@
 import jdk.vm.ci.meta.ResolvedJavaType;
 import jdk.vm.ci.runtime.JVMCI;
 import jdk.vm.ci.runtime.JVMCIBackend;
+import jdk.vm.ci.services.Services;
 
 //JaCoCo Exclude
 
@@ -95,7 +96,7 @@
  */
 public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider {
 
-    private static final boolean IS_AOT = Boolean.getBoolean("com.oracle.graalvm.isaot");
+    private static final boolean IS_AOT = Boolean.parseBoolean(Services.getSavedProperties().get("com.oracle.graalvm.isaot"));
 
     private static boolean checkArrayIndexScaleInvariants(MetaAccessProvider metaAccess) {
         assert metaAccess.getArrayIndexScale(JavaKind.Byte) == 1;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotTTYStreamProvider.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotTTYStreamProvider.java	Tue Apr 09 11:48:54 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
@@ -44,6 +44,7 @@
 import org.graalvm.compiler.serviceprovider.ServiceProvider;
 
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
+import jdk.vm.ci.services.Services;
 
 @ServiceProvider(TTYStreamProvider.class)
 public class HotSpotTTYStreamProvider implements TTYStreamProvider {
@@ -151,7 +152,7 @@
                     if (inputArguments != null) {
                         ps.println("VM Arguments: " + String.join(" ", inputArguments));
                     }
-                    String cmd = System.getProperty("sun.java.command");
+                    String cmd = Services.getSavedProperties().get("sun.java.command");
                     if (cmd != null) {
                         ps.println("sun.java.command=" + cmd);
                     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/IsGraalPredicate.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/IsGraalPredicate.java	Tue Apr 09 11:48:54 2019 +0100
@@ -25,12 +25,13 @@
 package org.graalvm.compiler.hotspot;
 
 import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory;
+import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
 
 /**
  * Determines if a given class is a JVMCI or Graal class for the purpose of
  * {@link HotSpotGraalCompilerFactory.Options#CompileGraalWithC1Only}.
  */
-public class IsGraalPredicate {
+class IsGraalPredicate extends IsGraalPredicateBase {
     /**
      * Module containing {@link HotSpotJVMCICompilerFactory}.
      */
@@ -47,15 +48,17 @@
      */
     private Module compilerConfigurationModule;
 
-    public IsGraalPredicate() {
+    IsGraalPredicate() {
         jvmciModule = HotSpotJVMCICompilerFactory.class.getModule();
         graalModule = HotSpotGraalCompilerFactory.class.getModule();
     }
 
-    void onCompilerConfigurationFactorySelection(CompilerConfigurationFactory factory) {
+    @Override
+    void onCompilerConfigurationFactorySelection(HotSpotJVMCIRuntime runtime, CompilerConfigurationFactory factory) {
         compilerConfigurationModule = factory.getClass().getModule();
     }
 
+    @Override
     boolean apply(Class<?> declaringClass) {
         Module module = declaringClass.getModule();
         return jvmciModule == module || graalModule == module || compilerConfigurationModule == module;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/IsGraalPredicateBase.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2018, 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 org.graalvm.compiler.hotspot;
+
+import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory;
+import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
+
+/**
+ * Determines if a given class is a JVMCI or Graal class for the purpose of
+ * {@link HotSpotGraalCompilerFactory.Options#CompileGraalWithC1Only}.
+ */
+abstract class IsGraalPredicateBase {
+
+    @SuppressWarnings("unused")
+    void onCompilerConfigurationFactorySelection(HotSpotJVMCIRuntime runtime, CompilerConfigurationFactory factory) {
+    }
+
+    abstract boolean apply(Class<?> declaringClass);
+
+    HotSpotJVMCICompilerFactory.CompilationLevelAdjustment getCompilationLevelAdjustment() {
+        return HotSpotJVMCICompilerFactory.CompilationLevelAdjustment.ByHolder;
+    }
+}
+
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/JVMCIVersionCheck.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/JVMCIVersionCheck.java	Tue Apr 09 11:48:54 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
@@ -25,6 +25,9 @@
 package org.graalvm.compiler.hotspot;
 
 import java.util.Formatter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
 
 /**
  * Mechanism for checking that the current Java runtime environment supports the minimum JVMCI API
@@ -38,20 +41,22 @@
  */
 class JVMCIVersionCheck {
 
-    // 0.55 introduces new HotSpotSpeculationLog API
+    // 0.57 introduces HotSpotJVMCIRuntime.excludeFromJVMCICompilation
     private static final int JVMCI8_MIN_MAJOR_VERSION = 0;
-    private static final int JVMCI8_MIN_MINOR_VERSION = 55;
+    private static final int JVMCI8_MIN_MINOR_VERSION = 57;
 
-    private static void failVersionCheck(boolean exit, String reason, Object... args) {
+    private static void failVersionCheck(Map<String, String> props, boolean exit, String reason, Object... args) {
         Formatter errorMessage = new Formatter().format(reason, args);
-        String javaHome = System.getProperty("java.home");
-        String vmName = System.getProperty("java.vm.name");
+        String javaHome = props.get("java.home");
+        String vmName = props.get("java.vm.name");
         errorMessage.format("Set the JVMCI_VERSION_CHECK environment variable to \"ignore\" to suppress ");
         errorMessage.format("this error or to \"warn\" to emit a warning and continue execution.%n");
         errorMessage.format("Currently used Java home directory is %s.%n", javaHome);
         errorMessage.format("Currently used VM configuration is: %s%n", vmName);
-        if (System.getProperty("java.specification.version").compareTo("1.9") < 0) {
-            errorMessage.format("Download the latest JVMCI JDK 8 from http://www.oracle.com/technetwork/oracle-labs/program-languages/downloads/index.html");
+        if (props.get("java.specification.version").compareTo("1.9") < 0) {
+            errorMessage.format("Download the latest JVMCI JDK 8 from " +
+                            "http://www.oracle.com/technetwork/oracle-labs/program-languages/downloads/index.html or " +
+                            "https://github.com/graalvm/openjdk8-jvmci-builder/releases");
         } else {
             errorMessage.format("Download JDK 11 or later.");
         }
@@ -68,10 +73,10 @@
         }
     }
 
-    static void check(boolean exitOnFailure) {
+    static void check(Map<String, String> props, boolean exitOnFailure) {
         // Don't use regular expressions to minimize Graal startup time
-        String javaSpecVersion = System.getProperty("java.specification.version");
-        String vmVersion = System.getProperty("java.vm.version");
+        String javaSpecVersion = props.get("java.specification.version");
+        String vmVersion = props.get("java.vm.version");
         if (javaSpecVersion.compareTo("1.9") < 0) {
             int start = vmVersion.indexOf("-jvmci-");
             if (start >= 0) {
@@ -82,7 +87,7 @@
                     try {
                         major = Integer.parseInt(vmVersion.substring(start, end));
                     } catch (NumberFormatException e) {
-                        failVersionCheck(exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal.%n" +
+                        failVersionCheck(props, exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal.%n" +
                                         "Cannot read JVMCI major version from java.vm.version property: %s.%n", vmVersion);
                         return;
                     }
@@ -95,22 +100,22 @@
                     try {
                         minor = Integer.parseInt(vmVersion.substring(start, end));
                     } catch (NumberFormatException e) {
-                        failVersionCheck(exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal.%n" +
+                        failVersionCheck(props, exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal.%n" +
                                         "Cannot read JVMCI minor version from java.vm.version property: %s.%n", vmVersion);
                         return;
                     }
                     if (major >= JVMCI8_MIN_MAJOR_VERSION && minor >= JVMCI8_MIN_MINOR_VERSION) {
                         return;
                     }
-                    failVersionCheck(exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal: %d.%d < %d.%d.%n",
+                    failVersionCheck(props, exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal: %d.%d < %d.%d.%n",
                                     major, minor, JVMCI8_MIN_MAJOR_VERSION, JVMCI8_MIN_MINOR_VERSION);
                     return;
                 }
             }
-            failVersionCheck(exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal.%n" +
+            failVersionCheck(props, exitOnFailure, "The VM does not support the minimum JVMCI API version required by Graal.%n" +
                             "Cannot read JVMCI version from java.vm.version property: %s.%n", vmVersion);
         } else if (javaSpecVersion.compareTo("11") < 0) {
-            failVersionCheck(exitOnFailure, "Graal is not compatible with the JVMCI API in JDK 9 and 10.%n");
+            failVersionCheck(props, exitOnFailure, "Graal is not compatible with the JVMCI API in JDK 9 and 10.%n");
         } else {
             if (vmVersion.contains("SNAPSHOT")) {
                 return;
@@ -124,11 +129,11 @@
                 try {
                     int build = Integer.parseInt(buildString);
                     if (build < 20) {
-                        failVersionCheck(exitOnFailure, "Graal requires build 20 or later of JDK 11 early access binary, got build %d.%n", build);
+                        failVersionCheck(props, exitOnFailure, "Graal requires build 20 or later of JDK 11 early access binary, got build %d.%n", build);
                         return;
                     }
                 } catch (NumberFormatException e) {
-                    failVersionCheck(exitOnFailure, "Could not parse the JDK 11 early access build number from java.vm.version property: %s.%n", vmVersion);
+                    failVersionCheck(props, exitOnFailure, "Could not parse the JDK 11 early access build number from java.vm.version property: %s.%n", vmVersion);
                     return;
                 }
             } else {
@@ -141,6 +146,11 @@
      * Command line interface for performing the check.
      */
     public static void main(String[] args) {
-        check(true);
+        Properties sprops = System.getProperties();
+        Map<String, String> props = new HashMap<>(sprops.size());
+        for (String name : sprops.stringPropertyNames()) {
+            props.put(name, sprops.getProperty(name));
+        }
+        check(props, true);
     }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/NodeCostDumpUtil.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 2016, 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
- * 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 org.graalvm.compiler.hotspot;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-import java.util.stream.Collectors;
-
-import org.graalvm.compiler.debug.CSVUtil;
-import org.graalvm.compiler.debug.GraalError;
-import org.graalvm.compiler.graph.Node;
-import org.graalvm.compiler.graph.NodeClass;
-import org.graalvm.compiler.graph.spi.Canonicalizable;
-import org.graalvm.compiler.nodes.memory.MemoryCheckpoint;
-import org.graalvm.compiler.nodes.spi.Virtualizable;
-
-public class NodeCostDumpUtil {
-
-    private static final String prefix1 = "com.oracle.";
-    private static final String prefix2 = "org.graalvm.";
-    private static final String FMT = CSVUtil.buildFormatString("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s");
-
-    private static String getArgumentRegex(String arg) {
-        if (arg.length() == 0) {
-            return null;
-        }
-        try {
-            Pattern.compile(arg);
-            return arg;
-        } catch (PatternSyntaxException e) {
-            // silently ignore
-            System.err.println("Invalid regex given, defaulting to \".*\" regex..");
-            return null;
-        }
-    }
-
-    public static void main(String[] args) {
-        if (args.length != 1) {
-            System.err.println("NodeCostDumpUtil expects exactly one argument, the node name regex to match against.");
-            System.exit(-1);
-        }
-        final String pattern = getArgumentRegex(args[0]);
-        String version = System.getProperty("java.specification.version");
-        if (version.compareTo("1.9") >= 0) {
-            System.err.printf("NodeCostDumpUtil does not support JDK versions greater than 1.8, current version is %s.\n", version);
-            System.exit(-1);
-        }
-        String[] jvmciCP = System.getProperty("jvmci.class.path.append").split(File.pathSeparator);
-        String[] primarySuiteCP = System.getProperty("primary.suite.cp").split(File.pathSeparator);
-        ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader();
-        HashSet<Class<?>> classes = new HashSet<>();
-        try {
-            Set<String> uniquePaths = new HashSet<>(Arrays.asList(primarySuiteCP));
-            uniquePaths.addAll(Arrays.asList(jvmciCP));
-            for (String path : uniquePaths) {
-                if (new File(path).exists()) {
-                    if (path.endsWith(".jar")) {
-                        try (FileSystem jarFileSystem = FileSystems.newFileSystem(URI.create("jar:file:" + path), Collections.emptyMap())) {
-                            initAllClasses(jarFileSystem.getPath("/"), applicationClassLoader, classes);
-                        }
-                    } else {
-                        initAllClasses(FileSystems.getDefault().getPath(path), applicationClassLoader, classes);
-                    }
-                }
-            }
-        } catch (IOException ex) {
-            GraalError.shouldNotReachHere();
-        }
-        System.err.printf("Loaded %d classes...\n", classes.size());
-        List<Class<?>> nodeClasses = new ArrayList<>();
-        for (Class<?> loaded : classes) {
-            if (Node.class.isAssignableFrom(loaded) && !loaded.isArray()) {
-                nodeClasses.add(loaded);
-            }
-        }
-        System.err.printf("Loaded %s node classes...\n", nodeClasses.size());
-        List<NodeClass<?>> nc = new ArrayList<>();
-        for (Class<?> c : nodeClasses) {
-            try {
-                nc.add(NodeClass.get(c));
-            } catch (Throwable t) {
-                // Silently ignore problems here
-            }
-        }
-        System.err.printf("Read TYPE field from %s node classes...\n", nc.size());
-        nc = nc.stream().filter(x -> x != null).collect(Collectors.toList());
-        nc.sort((x, y) -> {
-            String a = x.getJavaClass().getName();
-            String b = y.getJavaClass().getName();
-            return a.compareTo(b);
-        });
-        CSVUtil.Escape.println(System.out, FMT, "NodeName", "Size", "Overrides Size Method", "Cycles", "Overrides Cycles Method", "Canonicalizable", "MemoryCheckPoint", "Virtualizable");
-        for (NodeClass<?> nodeclass : nc) {
-            String packageStrippedName = null;
-            try {
-                packageStrippedName = nodeclass.getJavaClass().getCanonicalName().replace(prefix1, "").replace(prefix2, "");
-            } catch (Throwable t) {
-                // do nothing
-                continue;
-            }
-            if (pattern != null && !packageStrippedName.matches(pattern)) {
-                continue;
-            }
-            boolean overridesSizeMethod = false;
-            boolean overridesCyclesMethod = false;
-            Class<?> c = nodeclass.getJavaClass();
-            try {
-                c.getDeclaredMethod("estimatedNodeSize");
-                overridesSizeMethod = true;
-            } catch (Throwable t) {
-                // do nothing
-            }
-            try {
-                c.getDeclaredMethod("estimatedNodeCycles");
-                overridesCyclesMethod = true;
-            } catch (Throwable t) {
-                // do nothing
-            }
-            CSVUtil.Escape.println(System.out, FMT, packageStrippedName, nodeclass.size(), overridesSizeMethod, nodeclass.cycles(), overridesCyclesMethod, canonicalizable(c), memoryCheckPoint(c),
-                            virtualizable(c));
-        }
-    }
-
-    private static boolean canonicalizable(Class<?> c) {
-        return Canonicalizable.class.isAssignableFrom(c);
-    }
-
-    private static boolean virtualizable(Class<?> c) {
-        return Virtualizable.class.isAssignableFrom(c);
-    }
-
-    private static boolean memoryCheckPoint(Class<?> c) {
-        return MemoryCheckpoint.class.isAssignableFrom(c);
-    }
-
-    private static void initAllClasses(final Path root, ClassLoader classLoader, HashSet<Class<?>> classes) {
-        try {
-            Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
-                @Override
-                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
-                    String className = root.relativize(file).toString();
-                    ClassLoader c = classLoader;
-                    if (className.endsWith(".class")) {
-                        String prefix = prefixed(className);
-                        if (prefix != null) {
-                            String stripped = stripClassName(className);
-                            c = new URLClassLoader(new URL[]{new File(constructURLPart(stripped, className, prefix)).toURI().toURL()}, classLoader);
-                            className = constructClazzPart(stripped, prefix);
-                        } else {
-                            String clazzPart = className.replace('/', '.');
-                            className = clazzPart.substring(0, clazzPart.length() - ".class".length());
-                        }
-                        try {
-                            Class<?> systemClass = Class.forName(className, false, c);
-                            if (systemClass.getEnclosingClass() != null) {
-                                try {
-                                    classes.add(systemClass.getEnclosingClass());
-                                } catch (Throwable t) {
-                                    // do nothing
-                                }
-                            }
-                            classes.add(systemClass);
-                        } catch (Throwable ignored) {
-                        }
-                    }
-                    return FileVisitResult.CONTINUE;
-                }
-            });
-        } catch (IOException ex) {
-            GraalError.shouldNotReachHere();
-        }
-    }
-
-    private static String prefixed(String className) {
-        if (className.contains(prefix1) && className.indexOf(prefix1) > 0) {
-            return prefix1;
-        } else if (className.contains(prefix2) && className.indexOf(prefix2) > 0) {
-            return prefix2;
-        }
-        return null;
-    }
-
-    private static String stripClassName(String className) {
-        return className.replace('/', '.');
-    }
-
-    private static String constructClazzPart(String stripped, String prefix) {
-        String clazzPart = stripped.substring(stripped.lastIndexOf(prefix), stripped.length());
-        return clazzPart.substring(0, clazzPart.length() - ".class".length());
-    }
-
-    private static String constructURLPart(String stripped, String className, String prefix) {
-        return className.substring(0, stripped.lastIndexOf(prefix));
-    }
-
-}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/SymbolicSnippetEncoder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/SymbolicSnippetEncoder.java	Tue Apr 09 11:48:54 2019 +0100
@@ -48,7 +48,6 @@
 import org.graalvm.compiler.api.runtime.GraalJVMCICompiler;
 import org.graalvm.compiler.api.runtime.GraalRuntime;
 import org.graalvm.compiler.bytecode.BytecodeProvider;
-import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
 import org.graalvm.compiler.core.common.type.AbstractObjectStamp;
 import org.graalvm.compiler.core.common.type.Stamp;
 import org.graalvm.compiler.core.common.type.StampPair;
@@ -88,7 +87,6 @@
 import org.graalvm.compiler.nodes.java.AccessFieldNode;
 import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
 import org.graalvm.compiler.nodes.spi.DelegatingReplacements;
-import org.graalvm.compiler.nodes.spi.StampProvider;
 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
 import org.graalvm.compiler.options.OptionValues;
 import org.graalvm.compiler.phases.OptimisticOptimizations;
@@ -112,7 +110,6 @@
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.JavaType;
 import jdk.vm.ci.meta.MemoryAccessProvider;
-import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.MethodHandleAccessProvider;
 import jdk.vm.ci.meta.ResolvedJavaField;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
@@ -311,10 +308,7 @@
                 PEGraphDecoder graphDecoder = new PEGraphDecoder(
                                 providers.getCodeCache().getTarget().arch,
                                 result,
-                                providers.getMetaAccess(),
-                                providers.getConstantReflection(),
-                                providers.getConstantFieldProvider(),
-                                providers.getStampProvider(),
+                                providers,
                                 null, // loopExplosionPlugin
                                 replacements.getGraphBuilderPlugins().getInvocationPlugins(),
                                 new InlineInvokePlugin[0],
@@ -407,10 +401,7 @@
                 PEGraphDecoder graphDecoder = new PEGraphDecoder(
                                 architecture,
                                 result,
-                                providers.getMetaAccess(),
-                                providers.getConstantReflection(),
-                                providers.getConstantFieldProvider(),
-                                providers.getStampProvider(),
+                                providers,
                                 null,
                                 replacements.getGraphBuilderPlugins().getInvocationPlugins(),
                                 new InlineInvokePlugin[0],
@@ -993,17 +984,15 @@
         }
 
         @Override
-        protected GraphBuilderPhase.Instance createGraphBuilder(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection,
-                        ConstantFieldProvider constantFieldProvider, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
-            return new HotSpotSnippetGraphBuilderPhase(metaAccess, stampProvider, constantReflection, constantFieldProvider, graphBuilderConfig, optimisticOpts,
-                            initialIntrinsicContext);
+        protected GraphBuilderPhase.Instance createGraphBuilder(Providers providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts,
+                        IntrinsicContext initialIntrinsicContext) {
+            return new HotSpotSnippetGraphBuilderPhase(providers, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
         }
     }
 
     static class HotSpotSnippetGraphBuilderPhase extends GraphBuilderPhase.Instance {
-        HotSpotSnippetGraphBuilderPhase(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
-                        GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
-            super(metaAccess, stampProvider, constantReflection, constantFieldProvider, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
+        HotSpotSnippetGraphBuilderPhase(Providers theProviders, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
+            super(theProviders, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
         }
 
         @Override
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/debug/BenchmarkCounters.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/debug/BenchmarkCounters.java	Tue Apr 09 11:48:54 2019 +0100
@@ -416,7 +416,9 @@
                         if (waitingForEnd) {
                             waitingForEnd = false;
                             running = false;
-                            BenchmarkCounters.dump(options, getPrintStream(options), (System.nanoTime() - startTime) / 1000000000d, jvmciRuntime.collectCounters(), 100);
+                            try (PrintStreamScope scope = getPrintStream(options)) {
+                                BenchmarkCounters.dump(options, scope.out, (System.nanoTime() - startTime) / 1000000000d, jvmciRuntime.collectCounters(), 100);
+                            }
                         }
                         break;
                 }
@@ -445,18 +447,19 @@
         if (Options.TimedDynamicCounters.getValue(options) > 0) {
             Thread thread = new Thread() {
                 long lastTime = System.nanoTime();
-                PrintStream out = getPrintStream(options);
 
                 @Override
                 public void run() {
-                    while (true) {
-                        try {
-                            Thread.sleep(Options.TimedDynamicCounters.getValue(options));
-                        } catch (InterruptedException e) {
+                    try (PrintStreamScope scope = getPrintStream(options)) {
+                        while (true) {
+                            try {
+                                Thread.sleep(Options.TimedDynamicCounters.getValue(options));
+                            } catch (InterruptedException e) {
+                            }
+                            long time = System.nanoTime();
+                            dump(options, scope.out, (time - lastTime) / 1000000000d, jvmciRuntime.collectCounters(), 10);
+                            lastTime = time;
                         }
-                        long time = System.nanoTime();
-                        dump(options, out, (time - lastTime) / 1000000000d, jvmciRuntime.collectCounters(), 10);
-                        lastTime = time;
                     }
                 }
             };
@@ -472,22 +475,39 @@
 
     public static void shutdown(HotSpotJVMCIRuntime jvmciRuntime, OptionValues options, long compilerStartTime) {
         if (Options.GenericDynamicCounters.getValue(options)) {
-            dump(options, getPrintStream(options), (System.nanoTime() - compilerStartTime) / 1000000000d, jvmciRuntime.collectCounters(), 100);
+            try (PrintStreamScope scope = getPrintStream(options)) {
+                dump(options, scope.out, (System.nanoTime() - compilerStartTime) / 1000000000d, jvmciRuntime.collectCounters(), 100);
+            }
         }
     }
 
-    private static PrintStream getPrintStream(OptionValues options) {
-        if (Options.BenchmarkCountersFile.getValue(options) != null) {
-            try {
+    static class PrintStreamScope implements AutoCloseable {
+        final PrintStream out;
 
-                File file = new File(Options.BenchmarkCountersFile.getValue(options));
-                TTY.println("Writing benchmark counters to '%s'", file.getAbsolutePath());
-                return new PrintStream(file);
-            } catch (IOException e) {
-                TTY.out().println(e.getMessage());
-                TTY.out().println("Fallback to default");
+        PrintStreamScope(OptionValues options) {
+            PrintStream ps = TTY.out;
+            if (Options.BenchmarkCountersFile.getValue(options) != null) {
+                try {
+                    File file = new File(Options.BenchmarkCountersFile.getValue(options));
+                    TTY.println("Writing benchmark counters to '%s'", file.getAbsolutePath());
+                    ps = new PrintStream(file);
+                } catch (IOException e) {
+                    TTY.out().println(e.getMessage());
+                    TTY.out().println("Fallback to default");
+                }
+            }
+            this.out = ps;
+        }
+
+        @Override
+        public void close() {
+            if (out != TTY.out) {
+                this.out.close();
             }
         }
-        return TTY.out;
+    }
+
+    private static PrintStreamScope getPrintStream(OptionValues options) {
+        return new PrintStreamScope(options);
     }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotNodePlugin.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotNodePlugin.java	Tue Apr 09 11:48:54 2019 +0100
@@ -28,8 +28,6 @@
 import static jdk.vm.ci.meta.DeoptimizationReason.TransferToInterpreter;
 import static org.graalvm.compiler.core.common.GraalOptions.ImmutableCode;
 
-import java.lang.reflect.Field;
-
 import org.graalvm.compiler.core.common.CompilationIdentifier;
 import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.core.common.type.StampPair;
@@ -56,6 +54,7 @@
 import org.graalvm.compiler.nodes.memory.address.AddressNode;
 import org.graalvm.compiler.nodes.memory.address.OffsetAddressNode;
 import org.graalvm.compiler.nodes.util.ConstantFoldUtil;
+import org.graalvm.compiler.serviceprovider.GraalUnsafeAccess;
 import org.graalvm.compiler.word.Word;
 import org.graalvm.compiler.word.WordOperationPlugin;
 import jdk.internal.vm.compiler.word.LocationIdentity;
@@ -83,6 +82,7 @@
  * </ul>
  */
 public final class HotSpotNodePlugin implements NodePlugin, TypePlugin {
+    private static final Unsafe UNSAFE = GraalUnsafeAccess.getUnsafe();
     protected final WordOperationPlugin wordOperationPlugin;
     private final GraalHotSpotVMConfig config;
     private final HotSpotWordTypes wordTypes;
@@ -243,21 +243,5 @@
     }
 
     private static final LocationIdentity JAVA_THREAD_SHOULD_POST_ON_EXCEPTIONS_FLAG_LOCATION = NamedLocationIdentity.mutable("JavaThread::_should_post_on_exceptions_flag");
-    static final Unsafe UNSAFE = initUnsafe();
+}
 
-    static Unsafe initUnsafe() {
-        try {
-            // Fast path when we are trusted.
-            return Unsafe.getUnsafe();
-        } catch (SecurityException se) {
-            // Slow path when we are not trusted.
-            try {
-                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                return (Unsafe) theUnsafe.get(Unsafe.class);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to get Unsafe", e);
-            }
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotObjdumpDisassemblerProvider.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,167 @@
+/*
+ * 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 org.graalvm.compiler.hotspot.meta;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.graalvm.compiler.code.CompilationResult;
+import org.graalvm.compiler.code.CompilationResult.CodeAnnotation;
+import org.graalvm.compiler.code.DisassemblerProvider;
+import org.graalvm.compiler.serviceprovider.ServiceProvider;
+
+import jdk.vm.ci.code.CodeCacheProvider;
+import jdk.vm.ci.code.CodeUtil;
+import jdk.vm.ci.code.CodeUtil.DefaultRefMapFormatter;
+import jdk.vm.ci.code.CodeUtil.RefMapFormatter;
+import jdk.vm.ci.code.InstalledCode;
+import jdk.vm.ci.code.Register;
+import jdk.vm.ci.code.RegisterConfig;
+import jdk.vm.ci.code.TargetDescription;
+import jdk.vm.ci.code.site.Call;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.Infopoint;
+import jdk.vm.ci.code.site.Mark;
+import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
+import jdk.vm.ci.services.Services;
+
+/**
+ * This disassembles the code immediatly with objdump.
+ */
+@ServiceProvider(DisassemblerProvider.class)
+public class HotSpotObjdumpDisassemblerProvider extends HotSpotDisassemblerProvider {
+
+    /**
+     * Uses objdump to disassemble the compiled code.
+     */
+    @Override
+    public String disassembleCompiledCode(CodeCacheProvider codeCache, CompilationResult compResult) {
+        File tmp = null;
+        try {
+            tmp = File.createTempFile("compiledBinary", ".bin");
+            try (FileOutputStream fos = new FileOutputStream(tmp)) {
+                fos.write(compResult.getTargetCode());
+            }
+            String[] cmdline;
+            String arch = Services.getSavedProperties().get("os.arch");
+            if (arch.equals("amd64")) {
+                cmdline = new String[]{"objdump", "-D", "-b", "binary", "-M", "x86-64", "-m", "i386", tmp.getAbsolutePath()};
+            } else if (arch.equals("aarch64")) {
+                cmdline = new String[]{"objdump", "-D", "-b", "binary", "-m", "aarch64", tmp.getAbsolutePath()};
+            } else {
+                return null;
+            }
+
+            Pattern p = Pattern.compile(" *(([0-9a-fA-F]+):\t.*)");
+
+            TargetDescription target = codeCache.getTarget();
+            RegisterConfig regConfig = codeCache.getRegisterConfig();
+            Register fp = regConfig.getFrameRegister();
+            RefMapFormatter slotFormatter = new DefaultRefMapFormatter(target.wordSize, fp, 0);
+
+            Map<Integer, String> annotations = new HashMap<>();
+            for (DataPatch site : compResult.getDataPatches()) {
+                putAnnotation(annotations, site.pcOffset, "{" + site.reference.toString() + "}");
+            }
+            for (Mark mark : compResult.getMarks()) {
+                putAnnotation(annotations, mark.pcOffset, codeCache.getMarkName(mark));
+            }
+            for (CodeAnnotation a : compResult.getCodeAnnotations()) {
+                putAnnotation(annotations, a.position, a.toString());
+            }
+            for (Infopoint infopoint : compResult.getInfopoints()) {
+                if (infopoint instanceof Call) {
+                    Call call = (Call) infopoint;
+                    if (call.debugInfo != null) {
+                        putAnnotation(annotations, call.pcOffset + call.size, CodeUtil.append(new StringBuilder(100), call.debugInfo, slotFormatter).toString());
+                    }
+                    putAnnotation(annotations, call.pcOffset, "{" + codeCache.getTargetName(call) + "}");
+                } else {
+                    if (infopoint.debugInfo != null) {
+                        putAnnotation(annotations, infopoint.pcOffset, CodeUtil.append(new StringBuilder(100), infopoint.debugInfo, slotFormatter).toString());
+                    }
+                    putAnnotation(annotations, infopoint.pcOffset, "{infopoint: " + infopoint.reason + "}");
+                }
+            }
+
+            Process proc = Runtime.getRuntime().exec(cmdline);
+            InputStream is = proc.getInputStream();
+
+            InputStreamReader isr = new InputStreamReader(is);
+            BufferedReader br = new BufferedReader(isr);
+            String line;
+
+            StringBuilder sb = new StringBuilder();
+            while ((line = br.readLine()) != null) {
+                Matcher m = p.matcher(line);
+                if (m.find()) {
+                    int address = Integer.parseInt(m.group(2), 16);
+                    String annotation = annotations.get(address);
+                    if (annotation != null) {
+                        annotation = annotation.replace("\n", "\n; ");
+                        sb.append("; ").append(annotation).append('\n');
+                    }
+                    line = m.replaceAll("0x$1");
+                }
+                sb.append(line).append("\n");
+            }
+            BufferedReader ebr = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
+            while ((line = ebr.readLine()) != null) {
+                System.err.println(line);
+            }
+            ebr.close();
+            return sb.toString();
+        } catch (IOException e) {
+            if (tmp != null) {
+                tmp.delete();
+            }
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    private static void putAnnotation(Map<Integer, String> annotations, int idx, String txt) {
+        String newAnnoation = annotations.getOrDefault(idx, "") + "\n" + txt;
+        annotations.put(idx, newAnnoation);
+    }
+
+    @Override
+    public String disassembleInstalledCode(CodeCacheProvider codeCache, CompilationResult compResult, InstalledCode code) {
+        return ((HotSpotCodeCacheProvider) codeCache).disassemble(code);
+    }
+
+    @Override
+    public String getName() {
+        return "hsdis-objdump";
+    }
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotSuitesProvider.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotSuitesProvider.java	Tue Apr 09 11:48:54 2019 +0100
@@ -142,8 +142,7 @@
 
                 StructuredGraph targetGraph = new StructuredGraph.Builder(graph.getOptions(), graph.getDebug(), AllowAssumptions.YES).method(graph.method()).trackNodeSourcePosition(
                                 graph.trackNodeSourcePosition()).build();
-                SimplifyingGraphDecoder graphDecoder = new SimplifyingGraphDecoder(runtime.getTarget().arch, targetGraph, context.getMetaAccess(), context.getConstantReflection(),
-                                context.getConstantFieldProvider(), context.getStampProvider(), !ImmutableCode.getValue(graph.getOptions()));
+                SimplifyingGraphDecoder graphDecoder = new SimplifyingGraphDecoder(runtime.getTarget().arch, targetGraph, context, !ImmutableCode.getValue(graph.getOptions()));
                 graphDecoder.decode(encodedGraph);
             }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/AheadOfTimeVerificationPhase.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/phases/AheadOfTimeVerificationPhase.java	Tue Apr 09 11:48:54 2019 +0100
@@ -44,17 +44,21 @@
 public class AheadOfTimeVerificationPhase extends VerifyPhase<PhaseContext> {
 
     @Override
-    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+    protected void verify(StructuredGraph graph, PhaseContext context) {
         for (ConstantNode node : getConstantNodes(graph)) {
             if (isIllegalObjectConstant(node)) {
                 throw new VerificationError("illegal object constant: " + node);
             }
         }
-        return true;
     }
 
     public static boolean isIllegalObjectConstant(ConstantNode node) {
-        return isObject(node) && !isNullReference(node) && !isInternedString(node) && !isDirectMethodHandle(node) && !isBoundMethodHandle(node);
+        return isObject(node) &&
+                        !isNullReference(node) &&
+                        !isInternedString(node) &&
+                        !isDirectMethodHandle(node) &&
+                        !isBoundMethodHandle(node) &&
+                        !isVarHandle(node);
     }
 
     private static boolean isObject(ConstantNode node) {
@@ -79,6 +83,14 @@
         return StampTool.typeOrNull(node).getName().startsWith("Ljava/lang/invoke/BoundMethodHandle");
     }
 
+    private static boolean isVarHandle(ConstantNode node) {
+        if (!isObject(node)) {
+            return false;
+        }
+        String name = StampTool.typeOrNull(node).getName();
+        return name.equals("Ljava/lang/invoke/VarHandle$AccessDescriptor;");
+    }
+
     private static boolean isInternedString(ConstantNode node) {
         if (!isObject(node)) {
             return false;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java	Tue Apr 09 11:48:54 2019 +0100
@@ -420,6 +420,8 @@
 import org.graalvm.compiler.nodes.java.RegisterFinalizerNode;
 import org.graalvm.compiler.nodes.java.StoreFieldNode;
 import org.graalvm.compiler.nodes.java.StoreIndexedNode;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
+import org.graalvm.compiler.nodes.spi.Replacements;
 import org.graalvm.compiler.nodes.spi.StampProvider;
 import org.graalvm.compiler.nodes.type.StampTool;
 import org.graalvm.compiler.nodes.util.GraphUtil;
@@ -714,10 +716,7 @@
         this.debug = graph.getDebug();
         this.graphBuilderConfig = graphBuilderInstance.graphBuilderConfig;
         this.optimisticOpts = graphBuilderInstance.optimisticOpts;
-        this.metaAccess = graphBuilderInstance.metaAccess;
-        this.stampProvider = graphBuilderInstance.stampProvider;
-        this.constantReflection = graphBuilderInstance.constantReflection;
-        this.constantFieldProvider = graphBuilderInstance.constantFieldProvider;
+        this.providers = graphBuilderInstance.providers;
         this.stream = new BytecodeStream(code.getCode());
         this.profilingInfo = graph.useProfilingInfo() ? code.getProfilingInfo() : null;
         this.constantPool = code.getConstantPool();
@@ -778,7 +777,7 @@
 
     @SuppressWarnings("try")
     protected void buildRootMethod() {
-        FrameStateBuilder startFrameState = new FrameStateBuilder(this, code, graph);
+        FrameStateBuilder startFrameState = new FrameStateBuilder(this, code, graph, graphBuilderConfig.retainLocalVariables());
         startFrameState.initializeForMethodStart(graph.getAssumptions(), graphBuilderConfig.eagerResolving() || intrinsicContext != null, graphBuilderConfig.getPlugins());
 
         try (IntrinsicScope s = intrinsicContext != null ? new IntrinsicScope(this) : null) {
@@ -1121,7 +1120,7 @@
 
         AbstractBeginNode dispatchBegin;
         if (exceptionObject == null) {
-            ExceptionObjectNode newExceptionObject = graph.add(new ExceptionObjectNode(metaAccess));
+            ExceptionObjectNode newExceptionObject = graph.add(new ExceptionObjectNode(getMetaAccess()));
             dispatchBegin = newExceptionObject;
             dispatchState.push(JavaKind.Object, dispatchBegin);
             dispatchState.setRethrowException(true);
@@ -1166,7 +1165,7 @@
     }
 
     protected ValueNode genLoadIndexed(ValueNode array, ValueNode index, GuardingNode boundsCheck, JavaKind kind) {
-        return LoadIndexedNode.create(graph.getAssumptions(), array, index, boundsCheck, kind, metaAccess, constantReflection);
+        return LoadIndexedNode.create(graph.getAssumptions(), array, index, boundsCheck, kind, getMetaAccess(), getConstantReflection());
     }
 
     protected void genStoreIndexed(ValueNode array, ValueNode index, GuardingNode boundsCheck, GuardingNode storeCheck, JavaKind kind, ValueNode value) {
@@ -1242,7 +1241,7 @@
     }
 
     protected ValueNode genNormalizeCompare(ValueNode x, ValueNode y, boolean isUnorderedLess) {
-        return NormalizeCompareNode.create(x, y, isUnorderedLess, JavaKind.Int, constantReflection);
+        return NormalizeCompareNode.create(x, y, isUnorderedLess, JavaKind.Int, getConstantReflection());
     }
 
     protected ValueNode genFloatConvert(FloatConvert op, ValueNode input) {
@@ -1273,15 +1272,15 @@
     }
 
     protected LogicNode genObjectEquals(ValueNode x, ValueNode y) {
-        return ObjectEqualsNode.create(constantReflection, metaAccess, options, x, y, NodeView.DEFAULT);
+        return ObjectEqualsNode.create(getConstantReflection(), getMetaAccess(), options, x, y, NodeView.DEFAULT);
     }
 
     protected LogicNode genIntegerEquals(ValueNode x, ValueNode y) {
-        return IntegerEqualsNode.create(constantReflection, metaAccess, options, null, x, y, NodeView.DEFAULT);
+        return IntegerEqualsNode.create(getConstantReflection(), getMetaAccess(), options, null, x, y, NodeView.DEFAULT);
     }
 
     protected LogicNode genIntegerLessThan(ValueNode x, ValueNode y) {
-        return IntegerLessThanNode.create(constantReflection, metaAccess, options, null, x, y, NodeView.DEFAULT);
+        return IntegerLessThanNode.create(getConstantReflection(), getMetaAccess(), options, null, x, y, NodeView.DEFAULT);
     }
 
     protected ValueNode genUnique(ValueNode x) {
@@ -1372,7 +1371,7 @@
             return null;
         }
         ValueNode length = append(genArrayLength(receiver));
-        LogicNode condition = genUnique(IntegerBelowNode.create(constantReflection, metaAccess, options, null, index, length, NodeView.DEFAULT));
+        LogicNode condition = genUnique(IntegerBelowNode.create(getConstantReflection(), getMetaAccess(), options, null, index, length, NodeView.DEFAULT));
         return emitBytecodeExceptionCheck(condition, true, BytecodeExceptionKind.OUT_OF_BOUNDS, index, length);
     }
 
@@ -1380,8 +1379,8 @@
         if (elementKind != JavaKind.Object || StampTool.isPointerAlwaysNull(value) || !needsExplicitStoreCheckException(array, value)) {
             return null;
         }
-        ValueNode arrayClass = genUnique(LoadHubNode.create(array, stampProvider, metaAccess, constantReflection));
-        ValueNode componentHub = append(LoadArrayComponentHubNode.create(arrayClass, stampProvider, metaAccess, constantReflection));
+        ValueNode arrayClass = genUnique(LoadHubNode.create(array, getStampProvider(), getMetaAccess(), getConstantReflection()));
+        ValueNode componentHub = append(LoadArrayComponentHubNode.create(arrayClass, getStampProvider(), getMetaAccess(), getConstantReflection()));
         LogicNode condition = genUnique(InstanceOfDynamicNode.create(graph.getAssumptions(), getConstantReflection(), componentHub, value, true));
         return emitBytecodeExceptionCheck(condition, true, BytecodeExceptionKind.ARRAY_STORE, value);
     }
@@ -1391,7 +1390,7 @@
             return null;
         }
         ConstantNode zero = ConstantNode.defaultForKind(y.getStackKind(), graph);
-        LogicNode condition = genUnique(IntegerEqualsNode.create(constantReflection, metaAccess, options, null, y, zero, NodeView.DEFAULT));
+        LogicNode condition = genUnique(IntegerEqualsNode.create(getConstantReflection(), getMetaAccess(), options, null, y, zero, NodeView.DEFAULT));
         return emitBytecodeExceptionCheck(condition, false, BytecodeExceptionKind.DIVISION_BY_ZERO);
     }
 
@@ -1400,7 +1399,7 @@
             return null;
         }
 
-        BytecodeExceptionNode exception = graph.add(new BytecodeExceptionNode(metaAccess, exceptionKind, arguments));
+        BytecodeExceptionNode exception = graph.add(new BytecodeExceptionNode(getMetaAccess(), exceptionKind, arguments));
         AbstractBeginNode passingSuccessor = graph.add(new BeginNode());
 
         FixedNode trueSuccessor = passingOnTrue ? passingSuccessor : exception;
@@ -1416,7 +1415,7 @@
     }
 
     protected ValueNode genArrayLength(ValueNode x) {
-        return ArrayLengthNode.create(x, constantReflection);
+        return ArrayLengthNode.create(x, getConstantReflection());
     }
 
     protected void genStoreField(ValueNode receiver, ResolvedJavaField field, ValueNode value) {
@@ -1567,7 +1566,7 @@
                 FrameState stateBefore = createCurrentFrameState();
                 appendixNode = invokeDynamicPlugin.genAppendixNode(this, cpi, opcode, appendix, stateBefore);
             } else {
-                appendixNode = ConstantNode.forConstant(appendix, metaAccess, graph);
+                appendixNode = ConstantNode.forConstant(appendix, getMetaAccess(), graph);
             }
 
             frameState.push(JavaKind.Object, appendixNode);
@@ -1629,10 +1628,7 @@
     protected final ProfilingInfo profilingInfo;
     protected final OptimisticOptimizations optimisticOpts;
     protected final ConstantPool constantPool;
-    protected final MetaAccessProvider metaAccess;
-    private final ConstantReflectionProvider constantReflection;
-    private final ConstantFieldProvider constantFieldProvider;
-    private final StampProvider stampProvider;
+    protected final CoreProviders providers;
     protected final IntrinsicContext intrinsicContext;
 
     @Override
@@ -1954,7 +1950,7 @@
         }
 
         String error(String format, Object... a) {
-            return String.format(format, a) + String.format("%n\tplugin at %s", plugin.getApplySourceLocation(metaAccess));
+            return String.format(format, a) + String.format("%n\tplugin at %s", plugin.getApplySourceLocation(getMetaAccess()));
         }
 
         boolean check(boolean pluginResult) {
@@ -2039,11 +2035,12 @@
             Mark mark = graph.getMark();
             FixedWithNextNode currentLastInstr = lastInstr;
             ValueNode nonNullReceiver = pluginReceiver.get();
-            Stamp methodStamp = stampProvider.createMethodStamp();
-            LoadHubNode hub = graph.unique(new LoadHubNode(stampProvider, nonNullReceiver));
+            Stamp methodStamp = getStampProvider().createMethodStamp();
+            LoadHubNode hub = graph.unique(new LoadHubNode(getStampProvider(), nonNullReceiver));
             LoadMethodNode actual = append(new LoadMethodNode(methodStamp, targetMethod, receiverType, method.getDeclaringClass(), hub));
             ConstantNode expected = graph.unique(ConstantNode.forConstant(methodStamp, targetMethod.getEncoding(), getMetaAccess()));
-            LogicNode compare = graph.addOrUniqueWithInputs(CompareNode.createCompareNode(constantReflection, metaAccess, options, null, CanonicalCondition.EQ, actual, expected, NodeView.DEFAULT));
+            LogicNode compare = graph.addOrUniqueWithInputs(
+                            CompareNode.createCompareNode(getConstantReflection(), getMetaAccess(), options, null, CanonicalCondition.EQ, actual, expected, NodeView.DEFAULT));
 
             JavaTypeProfile profile = null;
             if (profilingInfo != null && this.optimisticOpts.useTypeCheckHints(getOptions())) {
@@ -2321,7 +2318,7 @@
                         }
                         return false;
                     }
-                    if (canInlinePartialIntrinsicExit() && InlinePartialIntrinsicExitDuringParsing.getValue(options) && !IS_BUILDING_NATIVE_IMAGE) {
+                    if (canInlinePartialIntrinsicExit()) {
                         // Otherwise inline the original method. Any frame state created
                         // during the inlining will exclude frame(s) in the
                         // intrinsic method (see FrameStateBuilder.create(int bci)).
@@ -2384,7 +2381,7 @@
      * intrinsic) can be inlined.
      */
     protected boolean canInlinePartialIntrinsicExit() {
-        return true;
+        return InlinePartialIntrinsicExitDuringParsing.getValue(options) && !IS_BUILDING_NATIVE_IMAGE && method.getAnnotation(Snippet.class) == null;
     }
 
     private void printInlining(ResolvedJavaMethod targetMethod, ResolvedJavaMethod inlinedMethod, boolean success, String msg) {
@@ -2446,7 +2443,7 @@
 
         try (IntrinsicScope s = calleeIntrinsicContext != null && !parsingIntrinsic() ? new IntrinsicScope(this, targetMethod.getSignature().toParameterKinds(!targetMethod.isStatic()), args) : null) {
             BytecodeParser parser = graphBuilderInstance.createBytecodeParser(graph, this, targetMethod, INVOCATION_ENTRY_BCI, calleeIntrinsicContext);
-            FrameStateBuilder startFrameState = new FrameStateBuilder(parser, parser.code, graph);
+            FrameStateBuilder startFrameState = new FrameStateBuilder(parser, parser.code, graph, graphBuilderConfig.retainLocalVariables());
             if (!targetMethod.isStatic()) {
                 args[0] = nullCheckedValue(args[0]);
             }
@@ -2679,7 +2676,7 @@
         JsrScope scope = currentBlock.getJsrScope();
         int retAddress = scope.nextReturnAddress();
         ConstantNode returnBciNode = getJsrConstant(retAddress);
-        LogicNode guard = IntegerEqualsNode.create(constantReflection, metaAccess, options, null, local, returnBciNode, NodeView.DEFAULT);
+        LogicNode guard = IntegerEqualsNode.create(getConstantReflection(), getMetaAccess(), options, null, local, returnBciNode, NodeView.DEFAULT);
         guard = graph.addOrUniqueWithInputs(guard);
         append(new FixedGuardNode(guard, JavaSubroutineMismatch, InvalidateReprofile));
         if (!successor.getJsrScope().equals(scope.pop())) {
@@ -2731,7 +2728,7 @@
 
     protected ConstantNode appendConstant(JavaConstant constant) {
         assert constant != null;
-        return ConstantNode.forConstant(constant, metaAccess, graph);
+        return ConstantNode.forConstant(constant, getMetaAccess(), graph);
     }
 
     @Override
@@ -3602,12 +3599,17 @@
 
     @Override
     public StampProvider getStampProvider() {
-        return stampProvider;
+        return providers.getStampProvider();
     }
 
     @Override
     public MetaAccessProvider getMetaAccess() {
-        return metaAccess;
+        return providers.getMetaAccess();
+    }
+
+    @Override
+    public Replacements getReplacements() {
+        return providers.getReplacements();
     }
 
     @Override
@@ -3623,12 +3625,12 @@
 
     @Override
     public ConstantReflectionProvider getConstantReflection() {
-        return constantReflection;
+        return providers.getConstantReflection();
     }
 
     @Override
     public ConstantFieldProvider getConstantFieldProvider() {
-        return constantFieldProvider;
+        return providers.getConstantFieldProvider();
     }
 
     /**
@@ -3753,7 +3755,7 @@
 
     private JavaKind refineComponentType(ValueNode array, JavaKind kind) {
         if (kind == JavaKind.Byte) {
-            JavaType type = array.stamp(NodeView.DEFAULT).javaType(metaAccess);
+            JavaType type = array.stamp(NodeView.DEFAULT).javaType(getMetaAccess());
             if (type.isArray()) {
                 JavaType componentType = type.getComponentType();
                 if (componentType != null) {
@@ -4308,7 +4310,7 @@
     }
 
     private void genNewPrimitiveArray(int typeCode) {
-        ResolvedJavaType elementType = metaAccess.lookupJavaType(arrayTypeCodeToClass(typeCode));
+        ResolvedJavaType elementType = getMetaAccess().lookupJavaType(arrayTypeCodeToClass(typeCode));
         ValueNode length = frameState.pop(JavaKind.Int);
 
         for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
@@ -4492,7 +4494,7 @@
 
     @Override
     public AbstractBeginNode genExplicitExceptionEdge(BytecodeExceptionKind exceptionKind) {
-        BytecodeExceptionNode exceptionNode = graph.add(new BytecodeExceptionNode(metaAccess, exceptionKind));
+        BytecodeExceptionNode exceptionNode = graph.add(new BytecodeExceptionNode(getMetaAccess(), exceptionKind));
         exceptionNode.setStateAfter(createFrameState(bci(), exceptionNode));
         AbstractBeginNode exceptionDispatch = handleException(exceptionNode, bci(), false);
         exceptionNode.setNext(exceptionDispatch);
@@ -5113,3 +5115,4 @@
         return n == 0 ? "" : format("%" + n + "s", "");
     }
 }
+
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/FrameStateBuilder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/FrameStateBuilder.java	Tue Apr 09 11:48:54 2019 +0100
@@ -118,17 +118,18 @@
      * @param graph the target graph of Graal nodes created by the builder
      */
     public FrameStateBuilder(GraphBuilderTool tool, ResolvedJavaMethod method, StructuredGraph graph) {
-        this(tool, new ResolvedJavaMethodBytecode(method), graph);
+        this(tool, new ResolvedJavaMethodBytecode(method), graph, false);
     }
 
     /**
      * Creates a new frame state builder for the given code attribute, method and the given target
-     * graph.
+     * graph. Additionally specifies if nonLiveLocals should be retained.
      *
      * @param code the bytecode in which the frame exists
      * @param graph the target graph of Graal nodes created by the builder
+     * @param shouldRetainLocalVariables specifies if nonLiveLocals should be retained in state.
      */
-    public FrameStateBuilder(GraphBuilderTool tool, Bytecode code, StructuredGraph graph) {
+    public FrameStateBuilder(GraphBuilderTool tool, Bytecode code, StructuredGraph graph, boolean shouldRetainLocalVariables) {
         this.tool = tool;
         if (tool instanceof BytecodeParser) {
             this.parser = (BytecodeParser) tool;
@@ -144,7 +145,7 @@
 
         this.monitorIds = EMPTY_MONITOR_ARRAY;
         this.graph = graph;
-        this.clearNonLiveLocals = GraalOptions.OptClearNonLiveLocals.getValue(graph.getOptions());
+        this.clearNonLiveLocals = GraalOptions.OptClearNonLiveLocals.getValue(graph.getOptions()) && !shouldRetainLocalVariables;
         this.canVerifyKind = true;
     }
 
@@ -630,12 +631,12 @@
 
     public void clearNonLiveLocals(BciBlock block, LocalLiveness liveness, boolean liveIn) {
         /*
-         * (lstadler) if somebody is tempted to remove/disable this clearing code: it's possible to
-         * remove it for normal compilations, but not for OSR compilations - otherwise dead object
-         * slots at the OSR entry aren't cleared. it is also not enough to rely on PiNodes with
-         * Kind.Illegal, because the conflicting branch might not have been parsed.
+         * Non-live local clearing is mandatory for the entry block of an OSR compilation so that
+         * dead object slots at the OSR entry are cleared. It's not sufficient to rely on PiNodes
+         * with Kind.Illegal, because the conflicting branch might not have been parsed.
          */
-        if (!clearNonLiveLocals) {
+        boolean isOSREntryBlock = graph.isOSR() && getMethod().equals(graph.method()) && graph.getEntryBCI() == block.startBci;
+        if (!clearNonLiveLocals && !isOSREntryBlock) {
             return;
         }
         if (liveIn) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/GraphBuilderPhase.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/GraphBuilderPhase.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,17 +24,14 @@
 
 package org.graalvm.compiler.java;
 
-import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
 import org.graalvm.compiler.nodes.StructuredGraph;
 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
 import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext;
-import org.graalvm.compiler.nodes.spi.StampProvider;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
 import org.graalvm.compiler.phases.BasePhase;
 import org.graalvm.compiler.phases.OptimisticOptimizations;
 import org.graalvm.compiler.phases.tiers.HighTierContext;
 
-import jdk.vm.ci.meta.ConstantReflectionProvider;
-import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 
 /**
@@ -55,8 +52,7 @@
 
     @Override
     protected void run(StructuredGraph graph, HighTierContext context) {
-        new Instance(context.getMetaAccess(), context.getStampProvider(), context.getConstantReflection(), context.getConstantFieldProvider(), graphBuilderConfig, context.getOptimisticOptimizations(),
-                        null).run(graph);
+        new Instance(context, graphBuilderConfig, context.getOptimisticOptimizations(), null).run(graph);
     }
 
     public GraphBuilderConfiguration getGraphBuilderConfig() {
@@ -66,22 +62,15 @@
     // Fully qualified name is a workaround for JDK-8056066
     public static class Instance extends org.graalvm.compiler.phases.Phase {
 
-        protected final MetaAccessProvider metaAccess;
-        protected final StampProvider stampProvider;
-        protected final ConstantReflectionProvider constantReflection;
-        protected final ConstantFieldProvider constantFieldProvider;
+        protected final CoreProviders providers;
         protected final GraphBuilderConfiguration graphBuilderConfig;
         protected final OptimisticOptimizations optimisticOpts;
         private final IntrinsicContext initialIntrinsicContext;
 
-        public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
-                        GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
+        public Instance(CoreProviders providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
             this.graphBuilderConfig = graphBuilderConfig;
             this.optimisticOpts = optimisticOpts;
-            this.metaAccess = metaAccess;
-            this.stampProvider = stampProvider;
-            this.constantReflection = constantReflection;
-            this.constantFieldProvider = constantFieldProvider;
+            this.providers = providers;
             this.initialIntrinsicContext = initialIntrinsicContext;
         }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64ArithmeticLIRGeneratorTool.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64ArithmeticLIRGeneratorTool.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,10 +24,8 @@
 
 package org.graalvm.compiler.lir.aarch64;
 
-import org.graalvm.compiler.lir.Variable;
 import org.graalvm.compiler.lir.gen.ArithmeticLIRGeneratorTool;
 
-import jdk.vm.ci.aarch64.AArch64Kind;
 import jdk.vm.ci.meta.Value;
 
 /**
@@ -53,6 +51,4 @@
     }
 
     Value emitRound(Value value, RoundingMode mode);
-
-    void emitCompareOp(AArch64Kind cmpKind, Variable left, Value right);
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64Call.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64Call.java	Tue Apr 09 11:48:54 2019 +0100
@@ -215,7 +215,7 @@
                  * Offset might not fit into a 28-bit immediate, generate an indirect call with a
                  * 64-bit immediate address which is fixed up by HotSpot.
                  */
-                masm.movNativeAddress(scratch, 0L);
+                masm.movNativeAddress(scratch, 0L, true);
                 masm.blr(scratch);
             }
         } else {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64Compare.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64Compare.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,22 +24,21 @@
 
 package org.graalvm.compiler.lir.aarch64;
 
+import static jdk.vm.ci.code.ValueUtil.asRegister;
+import static jdk.vm.ci.code.ValueUtil.isRegister;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.CONST;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
 import static org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant;
 import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
-import static jdk.vm.ci.code.ValueUtil.asRegister;
-import static jdk.vm.ci.code.ValueUtil.isRegister;
 
-import org.graalvm.compiler.core.common.NumUtil;
 import org.graalvm.compiler.asm.aarch64.AArch64Assembler;
 import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;
+import org.graalvm.compiler.core.common.NumUtil;
 import org.graalvm.compiler.core.common.calc.Condition;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.lir.LIRInstructionClass;
 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
 
-import jdk.vm.ci.aarch64.AArch64Kind;
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.Value;
 
@@ -53,8 +52,7 @@
 
         public CompareOp(Value x, Value y) {
             super(TYPE);
-            assert ((AArch64Kind) x.getPlatformKind()).isInteger() && ((AArch64Kind) y.getPlatformKind()).isInteger();
-            assert x.getPlatformKind() == y.getPlatformKind();
+            assert x.getPlatformKind() == y.getPlatformKind() : x.getPlatformKind() + " " + y.getPlatformKind();
             this.x = x;
             this.y = y;
         }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64ControlFlow.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64ControlFlow.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,22 +24,24 @@
 
 package org.graalvm.compiler.lir.aarch64;
 
+import static jdk.vm.ci.aarch64.AArch64.lr;
 import static jdk.vm.ci.code.ValueUtil.asAllocatableValue;
 import static jdk.vm.ci.code.ValueUtil.asRegister;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.HINT;
+import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.ILLEGAL;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
 
 import java.util.function.Function;
 
 import jdk.vm.ci.meta.AllocatableValue;
 import org.graalvm.compiler.asm.Label;
-import org.graalvm.compiler.core.common.NumUtil;
 import org.graalvm.compiler.asm.aarch64.AArch64Assembler;
 import org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag;
 import org.graalvm.compiler.asm.aarch64.AArch64Assembler.ExtendType;
 import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;
 import org.graalvm.compiler.code.CompilationResult.JumpTable;
 import org.graalvm.compiler.core.common.LIRKind;
+import org.graalvm.compiler.core.common.NumUtil;
 import org.graalvm.compiler.core.common.calc.Condition;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.lir.ConstantValue;
@@ -47,6 +49,7 @@
 import org.graalvm.compiler.lir.LabelRef;
 import org.graalvm.compiler.lir.Opcode;
 import org.graalvm.compiler.lir.StandardOp;
+import org.graalvm.compiler.lir.StandardOp.BlockEndOp;
 import org.graalvm.compiler.lir.SwitchStrategy;
 import org.graalvm.compiler.lir.SwitchStrategy.BaseSwitchClosure;
 import org.graalvm.compiler.lir.Variable;
@@ -59,6 +62,21 @@
 import jdk.vm.ci.meta.Value;
 
 public class AArch64ControlFlow {
+    public static final class ReturnOp extends AArch64BlockEndOp implements BlockEndOp {
+        public static final LIRInstructionClass<ReturnOp> TYPE = LIRInstructionClass.create(ReturnOp.class);
+        @Use({REG, ILLEGAL}) protected Value x;
+
+        public ReturnOp(Value x) {
+            super(TYPE);
+            this.x = x;
+        }
+
+        @Override
+        protected void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
+            crb.frameContext.leave(crb);
+            masm.ret(lr);
+        }
+    }
 
     public abstract static class AbstractBranchOp extends AArch64BlockEndOp implements StandardOp.BranchOp {
         private final LabelRef trueDestination;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64MathIntrinsicBinaryOp.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,84 @@
+/*
+ * 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 org.graalvm.compiler.lir.aarch64;
+
+import static jdk.vm.ci.aarch64.AArch64.v0;
+import static jdk.vm.ci.aarch64.AArch64.v1;
+
+import org.graalvm.compiler.core.common.LIRKind;
+import org.graalvm.compiler.debug.GraalError;
+import org.graalvm.compiler.lir.LIRInstructionClass;
+import org.graalvm.compiler.lir.Variable;
+import org.graalvm.compiler.lir.gen.LIRGenerator;
+
+import jdk.vm.ci.aarch64.AArch64;
+import jdk.vm.ci.aarch64.AArch64Kind;
+import jdk.vm.ci.code.Register;
+import jdk.vm.ci.code.RegisterValue;
+import jdk.vm.ci.meta.Value;
+
+public abstract class AArch64MathIntrinsicBinaryOp extends AArch64LIRInstruction {
+
+    @Def protected Value output;
+    @Use protected Value input0;
+    @Use protected Value input1;
+    @Temp protected Value[] temps;
+
+    public AArch64MathIntrinsicBinaryOp(LIRInstructionClass<? extends AArch64LIRInstruction> type, Register... registers) {
+        super(type);
+        input0 = v0.asValue(LIRKind.value(AArch64Kind.V64_WORD));
+        input1 = v0.asValue(LIRKind.value(AArch64Kind.V64_WORD));
+        output = v0.asValue(LIRKind.value(AArch64Kind.V64_WORD));
+
+        temps = registersToValues(registers);
+    }
+
+    protected static Value[] registersToValues(Register[] registers) {
+        Value[] temps = new Value[registers.length];
+        for (int i = 0; i < registers.length; i++) {
+            Register register = registers[i];
+            if (AArch64.CPU.equals(register.getRegisterCategory())) {
+                temps[i] = register.asValue(LIRKind.value(AArch64Kind.V64_WORD));
+            } else if (AArch64.SIMD.equals(register.getRegisterCategory())) {
+                temps[i] = register.asValue(LIRKind.value(AArch64Kind.V64_WORD));
+            } else {
+                throw GraalError.shouldNotReachHere("Unsupported register type in math stubs.");
+            }
+        }
+        return temps;
+    }
+
+    public final Variable emitLIRWrapper(LIRGenerator gen, Value x, Value y) {
+        LIRKind kind = LIRKind.combine(x, y);
+        RegisterValue v0value = v0.asValue(kind);
+        gen.emitMove(v0value, x);
+        RegisterValue v1value = v1.asValue(kind);
+        gen.emitMove(v1value, y);
+        gen.append(this);
+        Variable result = gen.newVariable(kind);
+        gen.emitMove(result, v0value);
+        return result;
+    }
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64Move.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64Move.java	Tue Apr 09 11:48:54 2019 +0100
@@ -31,18 +31,25 @@
 import static jdk.vm.ci.code.ValueUtil.asStackSlot;
 import static jdk.vm.ci.code.ValueUtil.isRegister;
 import static jdk.vm.ci.code.ValueUtil.isStackSlot;
+import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.COMPOSITE;
+import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.CONST;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.HINT;
+import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.ILLEGAL;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.STACK;
 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.UNINITIALIZED;
 import static org.graalvm.compiler.lir.LIRValueUtil.asJavaConstant;
 import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
 
+import org.graalvm.compiler.asm.Label;
 import org.graalvm.compiler.asm.aarch64.AArch64Address;
+import org.graalvm.compiler.asm.aarch64.AArch64Assembler;
 import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;
 import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister;
+import org.graalvm.compiler.core.common.CompressEncoding;
 import org.graalvm.compiler.core.common.LIRKind;
+import org.graalvm.compiler.core.common.spi.LIRKindTool;
 import org.graalvm.compiler.core.common.type.DataPointerConstant;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.lir.LIRFrameState;
@@ -54,6 +61,7 @@
 import org.graalvm.compiler.lir.StandardOp.ValueMoveOp;
 import org.graalvm.compiler.lir.VirtualStackSlot;
 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
+import org.graalvm.compiler.options.OptionValues;
 
 import jdk.vm.ci.aarch64.AArch64Kind;
 import jdk.vm.ci.code.MemoryBarriers;
@@ -507,10 +515,14 @@
                 break;
             case Object:
                 if (input.isNull()) {
-                    masm.mov(dst, 0);
+                    if (crb.mustReplaceWithNullRegister(input)) {
+                        masm.mov(64, dst, crb.nullRegister);
+                    } else {
+                        masm.mov(dst, 0);
+                    }
                 } else if (crb.target.inlineObjects) {
                     crb.recordInlineDataInCode(input);
-                    masm.movNativeAddress(dst, 0xDEADDEADDEADDEADL);
+                    masm.mov(dst, 0xDEADDEADDEADDEADL, true);
                 } else {
                     masm.ldr(64, dst, (AArch64Address) crb.recordDataReferenceInCode(input, 8));
                 }
@@ -561,4 +573,131 @@
         return masm.makeAddress(sp, displacement, scratchReg, transferSize, /* allowOverwrite */false);
     }
 
+    public abstract static class PointerCompressionOp extends AArch64LIRInstruction {
+
+        @Def({REG, HINT}) private AllocatableValue result;
+        @Use({REG, CONST}) private Value input;
+        @Alive({REG, ILLEGAL, UNINITIALIZED}) private AllocatableValue baseRegister;
+
+        protected final CompressEncoding encoding;
+        protected final boolean nonNull;
+        protected final LIRKindTool lirKindTool;
+
+        protected PointerCompressionOp(LIRInstructionClass<? extends PointerCompressionOp> type, AllocatableValue result, Value input,
+                        AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull, LIRKindTool lirKindTool) {
+
+            super(type);
+            this.result = result;
+            this.input = input;
+            this.baseRegister = baseRegister;
+            this.encoding = encoding;
+            this.nonNull = nonNull;
+            this.lirKindTool = lirKindTool;
+        }
+
+        public static boolean hasBase(OptionValues options, CompressEncoding encoding) {
+            return GeneratePIC.getValue(options) || encoding.hasBase();
+        }
+
+        public final Value getInput() {
+            return input;
+        }
+
+        public final AllocatableValue getResult() {
+            return result;
+        }
+
+        protected final Register getResultRegister() {
+            return asRegister(result);
+        }
+
+        protected final Register getBaseRegister(CompilationResultBuilder crb) {
+            return hasBase(crb.getOptions(), encoding) ? asRegister(baseRegister) : Register.None;
+        }
+
+        protected final int getShift() {
+            return encoding.getShift();
+        }
+
+        protected final void move(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
+            AArch64Move.move(crb, masm, result, input);
+        }
+    }
+
+    public static class CompressPointerOp extends PointerCompressionOp {
+        public static final LIRInstructionClass<CompressPointerOp> TYPE = LIRInstructionClass.create(CompressPointerOp.class);
+
+        public CompressPointerOp(AllocatableValue result, Value input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull, LIRKindTool lirKindTool) {
+            this(TYPE, result, input, baseRegister, encoding, nonNull, lirKindTool);
+        }
+
+        private CompressPointerOp(LIRInstructionClass<? extends PointerCompressionOp> type, AllocatableValue result, Value input,
+                        AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull, LIRKindTool lirKindTool) {
+
+            super(type, result, input, baseRegister, encoding, nonNull, lirKindTool);
+        }
+
+        @Override
+        protected void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
+            Register resultRegister = getResultRegister();
+            Register ptr = asRegister(getInput());
+            Register base = getBaseRegister(crb);
+            // result = (ptr - base) >> shift
+            if (!encoding.hasBase()) {
+                if (encoding.hasShift()) {
+                    masm.lshr(64, resultRegister, ptr, encoding.getShift());
+                } else {
+                    masm.movx(resultRegister, ptr);
+                }
+            } else if (nonNull) {
+                masm.sub(64, resultRegister, ptr, base);
+                if (encoding.hasShift()) {
+                    masm.lshr(64, resultRegister, resultRegister, encoding.getShift());
+                }
+            } else {
+                // if ptr is null it still has to be null after compression
+                masm.cmp(64, ptr, 0);
+                masm.cmov(64, resultRegister, ptr, base, AArch64Assembler.ConditionFlag.NE);
+                masm.sub(64, resultRegister, resultRegister, base);
+                if (encoding.hasShift()) {
+                    masm.lshr(64, resultRegister, resultRegister, encoding.getShift());
+                }
+            }
+        }
+    }
+
+    public static class UncompressPointerOp extends PointerCompressionOp {
+        public static final LIRInstructionClass<UncompressPointerOp> TYPE = LIRInstructionClass.create(UncompressPointerOp.class);
+
+        public UncompressPointerOp(AllocatableValue result, Value input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull, LIRKindTool lirKindTool) {
+            this(TYPE, result, input, baseRegister, encoding, nonNull, lirKindTool);
+        }
+
+        private UncompressPointerOp(LIRInstructionClass<? extends PointerCompressionOp> type, AllocatableValue result, Value input,
+                        AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull, LIRKindTool lirKindTool) {
+            super(type, result, input, baseRegister, encoding, nonNull, lirKindTool);
+        }
+
+        @Override
+        protected void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
+            Register inputRegister = asRegister(getInput());
+            Register resultRegister = getResultRegister();
+            Register base = encoding.hasBase() ? getBaseRegister(crb) : null;
+
+            // result = base + (ptr << shift)
+            if (nonNull || base == null) {
+                masm.add(64, resultRegister, base == null ? zr : base, inputRegister, AArch64Assembler.ShiftType.LSL, encoding.getShift());
+            } else {
+                // if ptr is null it has to be null after decompression
+                Label done = new Label();
+                if (!resultRegister.equals(inputRegister)) {
+                    masm.mov(32, resultRegister, inputRegister);
+                }
+                masm.cbz(32, resultRegister, done);
+                masm.add(64, resultRegister, base, resultRegister, AArch64Assembler.ShiftType.LSL, encoding.getShift());
+                masm.bind(done);
+            }
+        }
+    }
+
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/AMD64ArrayIndexOfOp.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/AMD64ArrayIndexOfOp.java	Tue Apr 09 11:48:54 2019 +0100
@@ -655,3 +655,4 @@
         return ((AMD64) tool.target().arch).getFeatures().contains(cpuFeature);
     }
 }
+
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/AMD64Binary.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/AMD64Binary.java	Tue Apr 09 11:48:54 2019 +0100
@@ -137,6 +137,11 @@
                 opcode.emit(masm, size, asRegister(result), (AMD64Address) crb.asAddress(input));
             }
         }
+
+        public AMD64RMOp getOpcode() {
+            return opcode;
+        }
+
     }
 
     /**
@@ -263,6 +268,11 @@
             }
             return false;
         }
+
+        public AMD64RMOp getOpcode() {
+            return opcode;
+        }
+
     }
 
     /**
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/AMD64BinaryConsumer.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/AMD64BinaryConsumer.java	Tue Apr 09 11:48:54 2019 +0100
@@ -131,6 +131,10 @@
         protected boolean shouldAnnotate() {
             return false;
         }
+
+        public AMD64MIOp getOpcode() {
+            return opcode;
+        }
     }
 
     /**
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/LIRGenerator.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/LIRGenerator.java	Tue Apr 09 11:48:54 2019 +0100
@@ -46,6 +46,7 @@
 import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
 import org.graalvm.compiler.core.common.spi.LIRKindTool;
 import org.graalvm.compiler.core.common.type.Stamp;
+import org.graalvm.compiler.debug.DebugCloseable;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.debug.TTY;
 import org.graalvm.compiler.graph.NodeSourcePosition;
@@ -386,6 +387,24 @@
         return blockScope;
     }
 
+    private final class MatchScope implements DebugCloseable {
+
+        private MatchScope(AbstractBlockBase<?> block) {
+            currentBlock = block;
+        }
+
+        @Override
+        public void close() {
+            currentBlock = null;
+        }
+
+    }
+
+    public final DebugCloseable getMatchScope(AbstractBlockBase<?> block) {
+        MatchScope matchScope = new MatchScope(block);
+        return matchScope;
+    }
+
     @Override
     public void emitIncomingValues(Value[] params) {
         ((LabelOp) res.getLIR().getLIRforBlock(getCurrentBlock()).get(0)).setIncomingValues(params);
@@ -457,7 +476,8 @@
         double minDensity = 1 / Math.sqrt(strategy.getAverageEffort());
         Optional<Hasher> hasher = hasherFor(keyConstants, minDensity);
         double hashTableSwitchDensity = hasher.map(h -> keyCount / (double) h.cardinality()).orElse(0d);
-        long valueRange = keyConstants[keyCount - 1].asLong() - keyConstants[0].asLong() + 1;
+        // The value range computation below may overflow, so compute it as a long.
+        long valueRange = (long) keyConstants[keyCount - 1].asInt() - (long) keyConstants[0].asInt() + 1;
         double tableSwitchDensity = keyCount / (double) valueRange;
 
         /*
@@ -479,7 +499,7 @@
                     targets[i] = defaultTarget;
                 }
                 for (int i = 0; i < keyCount; i++) {
-                    int idx = h.hash(keyConstants[i].asLong());
+                    int idx = h.hash(keyConstants[i].asInt());
                     keys[idx] = keyConstants[i];
                     targets[idx] = keyTargets[i];
                 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/LIRGeneratorTool.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/LIRGeneratorTool.java	Tue Apr 09 11:48:54 2019 +0100
@@ -269,11 +269,6 @@
     Variable emitArrayEquals(JavaKind kind, Value array1, Value array2, Value length, int constantLength, boolean directPointers);
 
     @SuppressWarnings("unused")
-    default ForeignCallLinkage lookupArrayEqualsStub(JavaKind kind, int constantLength) {
-        return null;
-    }
-
-    @SuppressWarnings("unused")
     default Variable emitArrayEquals(JavaKind kind1, JavaKind kind2, Value array1, Value array2, Value length, int constantLength, boolean directPointers) {
         throw GraalError.unimplemented("Array.equals with different types substitution is not implemented on this architecture");
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/hashing/HashFunction.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/hashing/HashFunction.java	Tue Apr 09 11:48:54 2019 +0100
@@ -49,7 +49,7 @@
      * @param min {@code value} is guaranteed to be greater or equal to this minimum
      * @return the hash value within int range
      */
-    public abstract int apply(long value, long min);
+    public abstract int apply(int value, int min);
 
     /**
      * Generates LIR that implements the hash function in terms of value and min.
@@ -109,25 +109,25 @@
                       (gen, prime) -> (val, min) -> gen.emitShr(gen.emitMul(val, prime, false), min));
 
         addWithPrimes("rotateRight(val, prime)", 3,
-                      prime -> (val, min) -> Long.rotateRight(val, prime),
+                      prime -> (val, min) -> Integer.rotateRight(val, prime),
                       (gen, prime) -> (val, min) -> gen.emitRor(val, prime));
 
         addWithPrimes("rotateRight(val, prime) + val", 4,
-                      prime -> (val, min) -> Long.rotateRight(val, prime) + val,
+                      prime -> (val, min) -> Integer.rotateRight(val, prime) + val,
                       (gen, prime) -> (val, min) -> gen.emitAdd(gen.emitRor(val, prime), val, false));
 
         addWithPrimes("rotateRight(val, prime) ^ val", 4,
-                      prime -> (val, min) -> Long.rotateRight(val, prime) ^ val,
+                      prime -> (val, min) -> Integer.rotateRight(val, prime) ^ val,
                       (gen, prime) -> (val, min) -> gen.emitXor(gen.emitRor(val, prime), val));
       //@formatter:on
     }
 
-    private static void add(String toString, int effort, BiFunction<Long, Long, Long> f, Function<ArithmeticLIRGenerator, BiFunction<Value, Value, Value>> gen) {
+    private static void add(String toString, int effort, BiFunction<Integer, Integer, Integer> f, Function<ArithmeticLIRGenerator, BiFunction<Value, Value, Value>> gen) {
         instances.add(new HashFunction() {
 
             @Override
-            public int apply(long value, long min) {
-                return f.apply(value, min).intValue();
+            public int apply(int value, int min) {
+                return f.apply(value, min);
             }
 
             @Override
@@ -147,7 +147,7 @@
         });
     }
 
-    private static void addWithPrimes(String toString, int effort, Function<Integer, BiFunction<Long, Long, Long>> f,
+    private static void addWithPrimes(String toString, int effort, Function<Integer, BiFunction<Integer, Integer, Integer>> f,
                     BiFunction<ArithmeticLIRGenerator, Value, BiFunction<Value, Value, Value>> gen) {
         for (int p : mersennePrimes) {
             add(toString, effort, f.apply(p), g -> gen.apply(g, g.getLIRGen().emitJavaConstant(JavaConstant.forInt(p))));
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/hashing/Hasher.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/hashing/Hasher.java	Tue Apr 09 11:48:54 2019 +0100
@@ -30,6 +30,7 @@
 import java.util.Set;
 import java.util.TreeSet;
 
+import jdk.vm.ci.meta.JavaKind;
 import org.graalvm.compiler.lir.gen.ArithmeticLIRGenerator;
 
 import jdk.vm.ci.meta.JavaConstant;
@@ -51,11 +52,12 @@
      * @return an optional hasher
      */
     public static Optional<Hasher> forKeys(JavaConstant[] keys, double minDensity) {
+        assert checkKeyKind(keys);
         if (keys.length <= 2) {
             return Optional.empty();
         } else {
             int maxCardinality = (int) Math.round(keys.length / minDensity);
-            assertSorted(keys);
+            assert checkIfSorted(keys);
             TreeSet<Hasher> candidates = new TreeSet<>(new Comparator<Hasher>() {
                 @Override
                 public int compare(Hasher o1, Hasher o2) {
@@ -67,7 +69,7 @@
                     }
                 }
             });
-            long min = keys[0].asLong();
+            int min = keys[0].asInt();
             for (HashFunction f : HashFunction.instances()) {
                 for (int cardinality = keys.length; cardinality < maxCardinality; cardinality++) {
                     if (isValid(keys, min, f, cardinality)) {
@@ -84,16 +86,28 @@
         }
     }
 
-    private static void assertSorted(JavaConstant[] keys) {
-        for (int i = 1; i < keys.length; i++) {
-            assert keys[i - 1].asLong() < keys[i].asLong();
+    private static boolean checkKeyKind(JavaConstant[] keys) {
+        for (int i = 0; i < keys.length; i++) {
+            if (keys[i].getJavaKind() != JavaKind.Int) {
+                throw new AssertionError(String.format("Key at index %d is not an int: %s", i, keys[i]));
+            }
         }
+        return true;
     }
 
-    private static boolean isValid(JavaConstant[] keys, long min, HashFunction function, int cardinality) {
+    private static boolean checkIfSorted(JavaConstant[] keys) {
+        for (int i = 1; i < keys.length; i++) {
+            if (keys[i - 1].asInt() >= keys[i].asInt()) {
+                throw new AssertionError("Keys array is not sorted");
+            }
+        }
+        return true;
+    }
+
+    private static boolean isValid(JavaConstant[] keys, int min, HashFunction function, int cardinality) {
         Set<Integer> seen = new HashSet<>(keys.length);
         for (JavaConstant key : keys) {
-            int hash = function.apply(key.asLong(), min) & (cardinality - 1);
+            int hash = function.apply(key.asInt(), min) & (cardinality - 1);
             if (!seen.add(hash)) {
                 return false;
             }
@@ -103,9 +117,9 @@
 
     private final HashFunction function;
     private final int cardinality;
-    private final long min;
+    private final int min;
 
-    private Hasher(HashFunction function, int cardinality, long min) {
+    private Hasher(HashFunction function, int cardinality, int min) {
         this.function = function;
         this.cardinality = cardinality;
         this.min = min;
@@ -117,7 +131,7 @@
      * @param value the value to be hashed
      * @return the hash value
      */
-    public int hash(long value) {
+    public int hash(int value) {
         return function.apply(value, min) & (cardinality - 1);
     }
 
@@ -129,7 +143,7 @@
      * @return the hashed lir value
      */
     public Value hash(Value value, ArithmeticLIRGenerator gen) {
-        Value h = function.gen(value, gen.getLIRGen().emitJavaConstant(JavaConstant.forLong(min)), gen);
+        Value h = function.gen(value, gen.getLIRGen().emitJavaConstant(JavaConstant.forInt(min)), gen);
         return gen.emitAnd(h, gen.getLIRGen().emitJavaConstant(JavaConstant.forInt(cardinality - 1)));
     }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/SimplifyingGraphDecoder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/SimplifyingGraphDecoder.java	Tue Apr 09 11:48:54 2019 +0100
@@ -44,7 +44,7 @@
 import org.graalvm.compiler.nodes.java.ArrayLengthNode;
 import org.graalvm.compiler.nodes.java.LoadFieldNode;
 import org.graalvm.compiler.nodes.java.LoadIndexedNode;
-import org.graalvm.compiler.nodes.spi.StampProvider;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
 import org.graalvm.compiler.nodes.util.GraphUtil;
 import org.graalvm.compiler.options.OptionValues;
 
@@ -61,10 +61,7 @@
  */
 public class SimplifyingGraphDecoder extends GraphDecoder {
 
-    protected final MetaAccessProvider metaAccess;
-    protected final ConstantReflectionProvider constantReflection;
-    protected final ConstantFieldProvider constantFieldProvider;
-    protected final StampProvider stampProvider;
+    protected final CoreProviders providers;
     protected final boolean canonicalizeReads;
     protected final CanonicalizerTool canonicalizerTool;
 
@@ -85,17 +82,17 @@
 
         @Override
         public MetaAccessProvider getMetaAccess() {
-            return metaAccess;
+            return providers.getMetaAccess();
         }
 
         @Override
         public ConstantReflectionProvider getConstantReflection() {
-            return constantReflection;
+            return providers.getConstantReflection();
         }
 
         @Override
         public ConstantFieldProvider getConstantFieldProvider() {
-            return constantFieldProvider;
+            return providers.getConstantFieldProvider();
         }
 
         @Override
@@ -135,14 +132,9 @@
         }
     }
 
-    public SimplifyingGraphDecoder(Architecture architecture, StructuredGraph graph, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection,
-                    ConstantFieldProvider constantFieldProvider, StampProvider stampProvider,
-                    boolean canonicalizeReads) {
+    public SimplifyingGraphDecoder(Architecture architecture, StructuredGraph graph, CoreProviders providers, boolean canonicalizeReads) {
         super(architecture, graph);
-        this.metaAccess = metaAccess;
-        this.constantReflection = constantReflection;
-        this.constantFieldProvider = constantFieldProvider;
-        this.stampProvider = stampProvider;
+        this.providers = providers;
         this.canonicalizeReads = canonicalizeReads;
         this.canonicalizerTool = new PECanonicalizerTool(graph.getAssumptions(), graph.getOptions());
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/extended/JavaWriteNode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/extended/JavaWriteNode.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,6 +24,8 @@
 
 package org.graalvm.compiler.nodes.extended;
 
+import org.graalvm.compiler.core.common.type.Stamp;
+import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.graph.NodeClass;
 import org.graalvm.compiler.nodeinfo.NodeInfo;
 import org.graalvm.compiler.nodes.StateSplit;
@@ -72,4 +74,9 @@
     public boolean isCompressible() {
         return compressible;
     }
+
+    @Override
+    public Stamp getAccessStamp() {
+        return StampFactory.forKind(writeKind);
+    }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderConfiguration.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderConfiguration.java	Tue Apr 09 11:48:54 2019 +0100
@@ -201,6 +201,7 @@
     private final List<ResolvedJavaType> skippedExceptionTypes;
     private final boolean insertFullInfopoints;
     private final boolean trackNodeSourcePosition;
+    private final boolean retainLocalVariables;
     private final Plugins plugins;
 
     public enum BytecodeExceptionMode {
@@ -229,6 +230,7 @@
                     boolean omitAssertions,
                     boolean insertFullInfopoints,
                     boolean trackNodeSourcePosition,
+                    boolean retainLocalVariables,
                     List<ResolvedJavaType> skippedExceptionTypes,
                     Plugins plugins) {
         this.eagerResolving = eagerResolving;
@@ -237,6 +239,7 @@
         this.omitAssertions = omitAssertions;
         this.insertFullInfopoints = insertFullInfopoints;
         this.trackNodeSourcePosition = trackNodeSourcePosition;
+        this.retainLocalVariables = retainLocalVariables;
         this.skippedExceptionTypes = skippedExceptionTypes;
         this.plugins = plugins;
     }
@@ -255,6 +258,7 @@
                         omitAssertions,
                         insertFullInfopoints,
                         trackNodeSourcePosition,
+                        retainLocalVariables,
                         skippedExceptionTypes,
                         newPlugins);
         return result;
@@ -274,6 +278,7 @@
                         omitAssertions,
                         insertFullInfopoints,
                         trackNodeSourcePosition,
+                        retainLocalVariables,
                         skippedExceptionTypes,
                         plugins);
     }
@@ -286,6 +291,7 @@
                         omitAssertions,
                         insertFullInfopoints,
                         trackNodeSourcePosition,
+                        retainLocalVariables,
                         skippedExceptionTypes,
                         plugins);
     }
@@ -298,6 +304,7 @@
                         omitAssertions,
                         insertFullInfopoints,
                         trackNodeSourcePosition,
+                        retainLocalVariables,
                         Collections.unmodifiableList(Arrays.asList(newSkippedExceptionTypes)),
                         plugins);
     }
@@ -309,6 +316,7 @@
                         omitAssertions,
                         insertFullInfopoints,
                         trackNodeSourcePosition,
+                        retainLocalVariables,
                         skippedExceptionTypes,
                         plugins);
     }
@@ -321,6 +329,7 @@
                         newOmitAssertions,
                         insertFullInfopoints,
                         trackNodeSourcePosition,
+                        retainLocalVariables,
                         skippedExceptionTypes,
                         plugins);
     }
@@ -333,6 +342,7 @@
                         omitAssertions,
                         newInsertFullInfopoints,
                         trackNodeSourcePosition,
+                        retainLocalVariables,
                         skippedExceptionTypes,
                         plugins);
     }
@@ -345,6 +355,20 @@
                         omitAssertions,
                         insertFullInfopoints,
                         newTrackNodeSourcePosition,
+                        retainLocalVariables,
+                        skippedExceptionTypes,
+                        plugins);
+    }
+
+    public GraphBuilderConfiguration withRetainLocalVariables(boolean newRetainLocalVariables) {
+        return new GraphBuilderConfiguration(
+                        eagerResolving,
+                        unresolvedIsError,
+                        bytecodeExceptionMode,
+                        omitAssertions,
+                        insertFullInfopoints,
+                        trackNodeSourcePosition,
+                        newRetainLocalVariables,
                         skippedExceptionTypes,
                         plugins);
     }
@@ -369,6 +393,10 @@
         return trackNodeSourcePosition;
     }
 
+    public boolean retainLocalVariables() {
+        return retainLocalVariables;
+    }
+
     public boolean insertFullInfopoints() {
         return insertFullInfopoints;
     }
@@ -381,6 +409,7 @@
                         /* omitAssertions: */ false,
                         /* insertFullInfopoints: */ false,
                         /* trackNodeSourcePosition: */ false,
+                        /* retainLocalVariables */ false,
                         Collections.emptyList(),
                         plugins);
     }
@@ -393,6 +422,7 @@
                         /* omitAssertions: */ false,
                         /* insertFullInfopoints: */ false,
                         /* trackNodeSourcePosition: */ false,
+                        /* retainLocalVariables */ false,
                         Collections.emptyList(),
                         plugins);
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderTool.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/GraphBuilderTool.java	Tue Apr 09 11:48:54 2019 +0100
@@ -28,6 +28,7 @@
 import org.graalvm.compiler.debug.DebugContext;
 import org.graalvm.compiler.nodes.StructuredGraph;
 import org.graalvm.compiler.nodes.ValueNode;
+import org.graalvm.compiler.nodes.spi.Replacements;
 import org.graalvm.compiler.nodes.spi.StampProvider;
 import org.graalvm.compiler.options.OptionValues;
 
@@ -52,6 +53,8 @@
 
     MetaAccessProvider getMetaAccess();
 
+    Replacements getReplacements();
+
     default Assumptions getAssumptions() {
         return getGraph().getAssumptions();
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/NodePlugin.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/NodePlugin.java	Tue Apr 09 11:48:54 2019 +0100
@@ -243,3 +243,4 @@
         return false;
     }
 }
+
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/memory/AbstractWriteNode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/memory/AbstractWriteNode.java	Tue Apr 09 11:48:54 2019 +0100
@@ -27,6 +27,7 @@
 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_1;
 
+import org.graalvm.compiler.core.common.type.Stamp;
 import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.graph.Node;
 import org.graalvm.compiler.graph.NodeClass;
@@ -90,4 +91,6 @@
         updateUsages(lastLocationAccess, newLla);
         lastLocationAccess = newLla;
     }
+
+    public abstract Stamp getAccessStamp();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/spi/CoreProviders.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,48 @@
+/*
+ * 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 org.graalvm.compiler.nodes.spi;
+
+import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
+import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
+
+import jdk.vm.ci.meta.ConstantReflectionProvider;
+import jdk.vm.ci.meta.MetaAccessProvider;
+
+public interface CoreProviders {
+
+    MetaAccessProvider getMetaAccess();
+
+    ConstantReflectionProvider getConstantReflection();
+
+    ConstantFieldProvider getConstantFieldProvider();
+
+    LoweringProvider getLowerer();
+
+    Replacements getReplacements();
+
+    StampProvider getStampProvider();
+
+    ForeignCallsProvider getForeignCalls();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/spi/CoreProvidersImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,87 @@
+/*
+ * 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 org.graalvm.compiler.nodes.spi;
+
+import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
+import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
+
+import jdk.vm.ci.meta.ConstantReflectionProvider;
+import jdk.vm.ci.meta.MetaAccessProvider;
+
+public class CoreProvidersImpl implements CoreProviders {
+    protected final MetaAccessProvider metaAccess;
+    protected final ConstantReflectionProvider constantReflection;
+    protected final ConstantFieldProvider constantFieldProvider;
+    protected final LoweringProvider lowerer;
+    protected final Replacements replacements;
+    protected final StampProvider stampProvider;
+    protected final ForeignCallsProvider foreignCalls;
+
+    protected CoreProvidersImpl(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider, LoweringProvider lowerer,
+                    Replacements replacements, StampProvider stampProvider, ForeignCallsProvider foreignCalls) {
+        this.metaAccess = metaAccess;
+        this.constantReflection = constantReflection;
+        this.constantFieldProvider = constantFieldProvider;
+        this.lowerer = lowerer;
+        this.replacements = replacements;
+        this.stampProvider = stampProvider;
+        this.foreignCalls = foreignCalls;
+    }
+
+    @Override
+    public MetaAccessProvider getMetaAccess() {
+        return metaAccess;
+    }
+
+    @Override
+    public ConstantReflectionProvider getConstantReflection() {
+        return constantReflection;
+    }
+
+    @Override
+    public ConstantFieldProvider getConstantFieldProvider() {
+        return constantFieldProvider;
+    }
+
+    @Override
+    public LoweringProvider getLowerer() {
+        return lowerer;
+    }
+
+    @Override
+    public Replacements getReplacements() {
+        return replacements;
+    }
+
+    @Override
+    public StampProvider getStampProvider() {
+        return stampProvider;
+    }
+
+    @Override
+    public ForeignCallsProvider getForeignCalls() {
+        return foreignCalls;
+    }
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/spi/LoweringTool.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/spi/LoweringTool.java	Tue Apr 09 11:48:54 2019 +0100
@@ -40,6 +40,8 @@
 
 public interface LoweringTool {
 
+    CoreProviders getProviders();
+
     MetaAccessProvider getMetaAccess();
 
     LoweringProvider getLowerer();
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/spi/NodeLIRBuilderTool.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/spi/NodeLIRBuilderTool.java	Tue Apr 09 11:48:54 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
@@ -28,6 +28,7 @@
 import java.util.List;
 
 import org.graalvm.compiler.core.common.cfg.BlockMap;
+import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
 import org.graalvm.compiler.core.common.type.Stamp;
 import org.graalvm.compiler.graph.Node;
 import org.graalvm.compiler.graph.NodeSourcePosition;
@@ -96,4 +97,11 @@
     }
 
     void emitReadExceptionObject(ValueNode node);
+
+    @SuppressWarnings("unused")
+    default ForeignCallLinkage lookupGraalStub(ValueNode valueNode) {
+        return null;
+    }
+
+    void matchBlock(Block b, StructuredGraph graph, StructuredGraph.ScheduleResult blockMap);
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.options/src/org/graalvm/compiler/options/OptionsParser.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.options/src/org/graalvm/compiler/options/OptionsParser.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -36,6 +36,8 @@
 import jdk.internal.vm.compiler.collections.EconomicMap;
 import jdk.internal.vm.compiler.collections.MapCursor;
 
+import jdk.vm.ci.services.Services;
+
 /**
  * This class contains methods for parsing Graal options and matching them against a set of
  * {@link OptionDescriptors}. The {@link OptionDescriptors} are loaded via a {@link ServiceLoader}.
@@ -51,7 +53,7 @@
         if (IS_IN_NATIVE_IMAGE || cachedOptionDescriptors != null) {
             return cachedOptionDescriptors;
         }
-        boolean java8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0;
+        boolean java8OrEarlier = Services.getSavedProperties().get("java.specification.version").compareTo("1.9") < 0;
         ClassLoader loader;
         if (java8OrEarlier) {
             // On JDK 8, Graal and its extensions are loaded by same class loader.
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/LoweringPhase.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/LoweringPhase.java	Tue Apr 09 11:48:54 2019 +0100
@@ -38,6 +38,7 @@
 import java.util.List;
 
 import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
+import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
 import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.debug.DebugCloseable;
 import org.graalvm.compiler.debug.GraalError;
@@ -68,6 +69,7 @@
 import org.graalvm.compiler.nodes.extended.GuardedNode;
 import org.graalvm.compiler.nodes.extended.GuardingNode;
 import org.graalvm.compiler.nodes.memory.MemoryCheckpoint;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
 import org.graalvm.compiler.nodes.spi.Lowerable;
 import org.graalvm.compiler.nodes.spi.LoweringProvider;
 import org.graalvm.compiler.nodes.spi.LoweringTool;
@@ -144,6 +146,11 @@
         }
 
         @Override
+        public CoreProviders getProviders() {
+            return context;
+        }
+
+        @Override
         public ConstantReflectionProvider getConstantReflection() {
             return context.getConstantReflection();
         }
@@ -168,6 +175,10 @@
             return context.getReplacements();
         }
 
+        public ForeignCallsProvider getForeignCalls() {
+            return context.getForeignCalls();
+        }
+
         @Override
         public AnchoringNode getCurrentGuardAnchor() {
             return guardAnchor;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ProfileCompiledMethodsPhase.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ProfileCompiledMethodsPhase.java	Tue Apr 09 11:48:54 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
@@ -69,6 +69,8 @@
 import org.graalvm.compiler.phases.Phase;
 import org.graalvm.compiler.phases.schedule.SchedulePhase;
 
+import jdk.vm.ci.services.Services;
+
 /**
  * This phase add counters for the dynamically executed number of nodes. Incrementing the counter
  * for each node would be too costly, so this phase takes the compromise that it trusts split
@@ -87,9 +89,17 @@
     private static final String GROUP_NAME_WITHOUT = "~profiled weight (invoke-free sections)";
     private static final String GROUP_NAME_INVOKES = "~profiled invokes";
 
-    private static final boolean WITH_SECTION_HEADER = Boolean.parseBoolean(System.getProperty("ProfileCompiledMethodsPhase.WITH_SECTION_HEADER", "false"));
-    private static final boolean WITH_INVOKE_FREE_SECTIONS = Boolean.parseBoolean(System.getProperty("ProfileCompiledMethodsPhase.WITH_FREE_SECTIONS", "false"));
-    private static final boolean WITH_INVOKES = Boolean.parseBoolean(System.getProperty("ProfileCompiledMethodsPhase.WITH_INVOKES", "true"));
+    private static String getProperty(String name, String def) {
+        String value = Services.getSavedProperties().get(name);
+        if (value == null) {
+            return def;
+        }
+        return value;
+    }
+
+    private static final boolean WITH_SECTION_HEADER = Boolean.parseBoolean(getProperty("ProfileCompiledMethodsPhase.WITH_SECTION_HEADER", "false"));
+    private static final boolean WITH_INVOKE_FREE_SECTIONS = Boolean.parseBoolean(getProperty("ProfileCompiledMethodsPhase.WITH_FREE_SECTIONS", "false"));
+    private static final boolean WITH_INVOKES = Boolean.parseBoolean(getProperty("ProfileCompiledMethodsPhase.WITH_INVOKES", "true"));
 
     @Override
     protected void run(StructuredGraph graph) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java	Tue Apr 09 11:48:54 2019 +0100
@@ -154,6 +154,8 @@
             return "it is marked non-inlinable";
         } else if (countRecursiveInlining(method) > MaximumRecursiveInlining.getValue(options)) {
             return "it exceeds the maximum recursive inlining depth";
+        } else if (!method.hasBytecodes()) {
+            return "it has no bytecodes to inline";
         } else {
             if (new OptimisticOptimizations(rootGraph.getProfilingInfo(method), options).lessOptimisticThan(context.getOptimisticOptimizations())) {
                 return "the callee uses less optimistic optimizations than caller";
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases/src/org/graalvm/compiler/phases/VerifyPhase.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases/src/org/graalvm/compiler/phases/VerifyPhase.java	Tue Apr 09 11:48:54 2019 +0100
@@ -26,11 +26,12 @@
 
 import org.graalvm.compiler.nodes.StructuredGraph;
 
+import jdk.vm.ci.meta.MetaAccessProvider;
+import jdk.vm.ci.meta.ResolvedJavaType;
+
 /***
- * This phase serves as a verification, in order to check the graph for certain properties. The
- * {@link #verify(StructuredGraph, Object)} method will be used as an assertion, and implements the
- * actual check. Instead of returning false, it is also valid to throw an {@link VerificationError}
- * in the implemented {@link #verify(StructuredGraph, Object)} method.
+ * Verifies a {@linkplain #verify graph} or {@linkplain #verifyClass class} against one or more
+ * invariants.
  */
 public abstract class VerifyPhase<C> extends BasePhase<C> {
 
@@ -55,13 +56,23 @@
 
     @Override
     protected final void run(StructuredGraph graph, C context) {
-        assert verify(graph, context);
+        verify(graph, context);
     }
 
     /**
-     * Performs the actual verification.
+     * Checks {@code graph} against some invariants.
      *
      * @throws VerificationError if the verification fails
      */
-    protected abstract boolean verify(StructuredGraph graph, C context);
+    protected abstract void verify(StructuredGraph graph, C context);
+
+    /**
+     * Checks {@code clazz} against some invariants.
+     *
+     * @param clazz the class to verify
+     * @param metaAccess an object to get a {@link ResolvedJavaType} for {@code clazz}
+     * @throws VerificationError if the class violates some invariant
+     */
+    public void verifyClass(Class<?> clazz, MetaAccessProvider metaAccess) {
+    }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases/src/org/graalvm/compiler/phases/tiers/PhaseContext.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases/src/org/graalvm/compiler/phases/tiers/PhaseContext.java	Tue Apr 09 11:48:54 2019 +0100
@@ -25,66 +25,55 @@
 package org.graalvm.compiler.phases.tiers;
 
 import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
+import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
 import org.graalvm.compiler.nodes.spi.LoweringProvider;
 import org.graalvm.compiler.nodes.spi.Replacements;
 import org.graalvm.compiler.nodes.spi.StampProvider;
-import org.graalvm.compiler.phases.util.Providers;
 
 import jdk.vm.ci.meta.ConstantReflectionProvider;
 import jdk.vm.ci.meta.MetaAccessProvider;
-import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
 
-public class PhaseContext {
+public class PhaseContext implements CoreProviders {
 
-    private final MetaAccessProvider metaAccess;
-    private final ConstantReflectionProvider constantReflection;
-    private final ConstantFieldProvider constantFieldProvider;
-    private final LoweringProvider lowerer;
-    private final Replacements replacements;
-    private final StampProvider stampProvider;
-    private final ForeignCallsProvider foreignCalls;
+    private final CoreProviders providers;
 
-    public PhaseContext(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider, LoweringProvider lowerer, Replacements replacements,
-                    StampProvider stampProvider, ForeignCallsProvider foreignCalls) {
-        this.metaAccess = metaAccess;
-        this.constantReflection = constantReflection;
-        this.constantFieldProvider = constantFieldProvider;
-        this.lowerer = lowerer;
-        this.replacements = replacements;
-        this.stampProvider = stampProvider;
-        this.foreignCalls = foreignCalls;
+    public PhaseContext(CoreProviders providers) {
+        this.providers = providers;
     }
 
-    public PhaseContext(Providers providers) {
-        this(providers.getMetaAccess(), providers.getConstantReflection(), providers.getConstantFieldProvider(), providers.getLowerer(), providers.getReplacements(), providers.getStampProvider(),
-                        providers.getForeignCalls());
+    @Override
+    public MetaAccessProvider getMetaAccess() {
+        return providers.getMetaAccess();
+    }
+
+    @Override
+    public ConstantReflectionProvider getConstantReflection() {
+        return providers.getConstantReflection();
     }
 
-    public MetaAccessProvider getMetaAccess() {
-        return metaAccess;
+    @Override
+    public ConstantFieldProvider getConstantFieldProvider() {
+        return providers.getConstantFieldProvider();
     }
 
-    public ConstantReflectionProvider getConstantReflection() {
-        return constantReflection;
-    }
-
-    public ConstantFieldProvider getConstantFieldProvider() {
-        return constantFieldProvider;
+    @Override
+    public LoweringProvider getLowerer() {
+        return providers.getLowerer();
     }
 
-    public LoweringProvider getLowerer() {
-        return lowerer;
-    }
-
+    @Override
     public Replacements getReplacements() {
-        return replacements;
+        return providers.getReplacements();
     }
 
+    @Override
     public StampProvider getStampProvider() {
-        return stampProvider;
+        return providers.getStampProvider();
     }
 
+    @Override
     public ForeignCallsProvider getForeignCalls() {
-        return foreignCalls;
+        return providers.getForeignCalls();
     }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases/src/org/graalvm/compiler/phases/util/Providers.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases/src/org/graalvm/compiler/phases/util/Providers.java	Tue Apr 09 11:48:54 2019 +0100
@@ -27,6 +27,7 @@
 import org.graalvm.compiler.core.common.spi.CodeGenProviders;
 import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
 import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
+import org.graalvm.compiler.nodes.spi.CoreProvidersImpl;
 import org.graalvm.compiler.nodes.spi.LoweringProvider;
 import org.graalvm.compiler.nodes.spi.Replacements;
 import org.graalvm.compiler.nodes.spi.StampProvider;
@@ -39,27 +40,14 @@
 /**
  * A set of providers, some of which may not be present (i.e., null).
  */
-public class Providers implements CodeGenProviders {
+public class Providers extends CoreProvidersImpl implements CodeGenProviders {
 
-    private final MetaAccessProvider metaAccess;
     private final CodeCacheProvider codeCache;
-    private final LoweringProvider lowerer;
-    private final ConstantReflectionProvider constantReflection;
-    private final ConstantFieldProvider constantFieldProvider;
-    private final ForeignCallsProvider foreignCalls;
-    private final Replacements replacements;
-    private final StampProvider stampProvider;
 
     public Providers(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
                     ForeignCallsProvider foreignCalls, LoweringProvider lowerer, Replacements replacements, StampProvider stampProvider) {
-        this.metaAccess = metaAccess;
+        super(metaAccess, constantReflection, constantFieldProvider, lowerer, replacements, stampProvider, foreignCalls);
         this.codeCache = codeCache;
-        this.constantReflection = constantReflection;
-        this.constantFieldProvider = constantFieldProvider;
-        this.foreignCalls = foreignCalls;
-        this.lowerer = lowerer;
-        this.replacements = replacements;
-        this.stampProvider = stampProvider;
     }
 
     public Providers(Providers copyFrom) {
@@ -73,41 +61,10 @@
     }
 
     @Override
-    public MetaAccessProvider getMetaAccess() {
-        return metaAccess;
-    }
-
-    @Override
     public CodeCacheProvider getCodeCache() {
         return codeCache;
     }
 
-    @Override
-    public ForeignCallsProvider getForeignCalls() {
-        return foreignCalls;
-    }
-
-    public LoweringProvider getLowerer() {
-        return lowerer;
-    }
-
-    @Override
-    public ConstantReflectionProvider getConstantReflection() {
-        return constantReflection;
-    }
-
-    public ConstantFieldProvider getConstantFieldProvider() {
-        return constantFieldProvider;
-    }
-
-    public Replacements getReplacements() {
-        return replacements;
-    }
-
-    public StampProvider getStampProvider() {
-        return stampProvider;
-    }
-
     public Providers copyWith(MetaAccessProvider substitution) {
         assert this.getClass() == Providers.class : "must override";
         return new Providers(substitution, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, stampProvider);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/CFGPrinterObserver.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/CFGPrinterObserver.java	Tue Apr 09 11:48:54 2019 +0100
@@ -64,6 +64,7 @@
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.meta.JavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.services.Services;
 
 /**
  * Observes compilation events and uses {@link CFGPrinter} to produce a control flow graph for the
@@ -256,11 +257,19 @@
 
         static {
             DisassemblerProvider selected = null;
+            String arch = Services.getSavedProperties().get("os.arch");
             for (DisassemblerProvider d : GraalServices.load(DisassemblerProvider.class)) {
                 String name = d.getName().toLowerCase();
-                if (name.contains("hcf") || name.contains("hexcodefile")) {
-                    selected = d;
-                    break;
+                if (arch.equals("aarch64")) {
+                    if (name.contains("hsdis-objdump")) {
+                        selected = d;
+                        break;
+                    }
+                } else {
+                    if (name.contains("hcf") || name.contains("hexcodefile")) {
+                        selected = d;
+                        break;
+                    }
                 }
             }
             if (selected == null) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinterDumpHandler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinterDumpHandler.java	Tue Apr 09 11:48:54 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
@@ -52,6 +52,7 @@
 
 import jdk.vm.ci.meta.JavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.services.Services;
 
 //JaCoCo Exclude
 
@@ -86,7 +87,7 @@
         this.printerSupplier = printerSupplier;
         /* Add the JVM and Java arguments to the graph properties to help identify it. */
         this.jvmArguments = jvmArguments();
-        this.sunJavaCommand = System.getProperty("sun.java.command");
+        this.sunJavaCommand = Services.getSavedProperties().get("sun.java.command");
     }
 
     private static String jvmArguments() {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.aarch64/src/org/graalvm/compiler/replacements/aarch64/AArch64GraphBuilderPlugins.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.aarch64/src/org/graalvm/compiler/replacements/aarch64/AArch64GraphBuilderPlugins.java	Tue Apr 09 11:48:54 2019 +0100
@@ -59,14 +59,16 @@
 
 public class AArch64GraphBuilderPlugins {
 
-    public static void register(Plugins plugins, BytecodeProvider bytecodeProvider, boolean explicitUnsafeNullChecks) {
+    public static void register(Plugins plugins, BytecodeProvider bytecodeProvider, boolean explicitUnsafeNullChecks, boolean registerMathPlugins) {
         InvocationPlugins invocationPlugins = plugins.getInvocationPlugins();
         invocationPlugins.defer(new Runnable() {
             @Override
             public void run() {
                 registerIntegerLongPlugins(invocationPlugins, AArch64IntegerSubstitutions.class, JavaKind.Int, bytecodeProvider);
                 registerIntegerLongPlugins(invocationPlugins, AArch64LongSubstitutions.class, JavaKind.Long, bytecodeProvider);
-                registerMathPlugins(invocationPlugins);
+                if (registerMathPlugins) {
+                    registerMathPlugins(invocationPlugins);
+                }
                 registerStringLatin1Plugins(invocationPlugins, bytecodeProvider);
                 registerStringUTF16Plugins(invocationPlugins, bytecodeProvider);
                 registerUnsafePlugins(invocationPlugins, bytecodeProvider);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/CachingPEGraphDecoder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/CachingPEGraphDecoder.java	Tue Apr 09 11:48:54 2019 +0100
@@ -31,6 +31,7 @@
 import org.graalvm.compiler.debug.DebugContext;
 import org.graalvm.compiler.graph.SourceLanguagePositionProvider;
 import org.graalvm.compiler.java.GraphBuilderPhase;
+import org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase;
 import org.graalvm.compiler.nodes.EncodedGraph;
 import org.graalvm.compiler.nodes.GraphEncoder;
 import org.graalvm.compiler.nodes.StructuredGraph;
@@ -44,7 +45,6 @@
 import org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin;
 import org.graalvm.compiler.phases.OptimisticOptimizations;
 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
-import org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase;
 import org.graalvm.compiler.phases.tiers.PhaseContext;
 import org.graalvm.compiler.phases.util.Providers;
 
@@ -67,7 +67,7 @@
                     AllowAssumptions allowAssumptions, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins,
                     ParameterPlugin parameterPlugin,
                     NodePlugin[] nodePlugins, ResolvedJavaMethod callInlinedMethod, SourceLanguagePositionProvider sourceLanguagePositionProvider) {
-        super(architecture, graph, providers.getMetaAccess(), providers.getConstantReflection(), providers.getConstantFieldProvider(), providers.getStampProvider(), loopExplosionPlugin,
+        super(architecture, graph, providers, loopExplosionPlugin,
                         invocationPlugins, inlineInvokePlugins, parameterPlugin, nodePlugins, callInlinedMethod, sourceLanguagePositionProvider);
 
         this.providers = providers;
@@ -78,8 +78,7 @@
     }
 
     protected GraphBuilderPhase.Instance createGraphBuilderPhaseInstance(IntrinsicContext initialIntrinsicContext) {
-        return new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), graphBuilderConfig,
-                        optimisticOpts, initialIntrinsicContext);
+        return new GraphBuilderPhase.Instance(providers, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
     }
 
     @SuppressWarnings("try")
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/ConstantStringIndexOfSnippets.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/ConstantStringIndexOfSnippets.java	Tue Apr 09 11:48:54 2019 +0100
@@ -25,6 +25,7 @@
 package org.graalvm.compiler.replacements;
 
 import static org.graalvm.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER;
+import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe;
 
 import org.graalvm.compiler.api.replacements.Fold;
 import org.graalvm.compiler.api.replacements.Fold.InjectedParameter;
@@ -44,8 +45,11 @@
 import jdk.vm.ci.code.TargetDescription;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.MetaAccessProvider;
+import sun.misc.Unsafe;
 
 public class ConstantStringIndexOfSnippets implements Snippets {
+    private static final Unsafe UNSAFE = getUnsafe();
+
     public static class Templates extends AbstractTemplates {
 
         private final SnippetInfo indexOfConstant = snippet(ConstantStringIndexOfSnippets.class, "indexOfConstant");
@@ -157,10 +161,10 @@
             return 0;
         }
         long base = metaAccess.getArrayBaseOffset(JavaKind.Byte);
-        char lastChar = UnsafeAccess.UNSAFE.getChar(target, base + (c - 1) * 2);
+        char lastChar = UNSAFE.getChar(target, base + (c - 1) * 2);
         int md2 = c;
         for (int i = 0; i < c - 1; i++) {
-            char currChar = UnsafeAccess.UNSAFE.getChar(target, base + i * 2);
+            char currChar = UNSAFE.getChar(target, base + i * 2);
             if (currChar == lastChar) {
                 md2 = (c - 1) - i;
             }
@@ -174,7 +178,7 @@
         int i;
         long base = metaAccess.getArrayBaseOffset(JavaKind.Byte);
         for (i = 0; i < c - 1; i++) {
-            char currChar = UnsafeAccess.UNSAFE.getChar(s, base + i * 2);
+            char currChar = UNSAFE.getChar(s, base + i * 2);
             cache |= (1 << (currChar & 63));
         }
         return cache;
@@ -212,10 +216,10 @@
         int sourceEnd = sourceCount - targetCountLess1;
 
         long base = charArrayBaseOffset(INJECTED);
-        int lastChar = UnsafeAccess.UNSAFE.getChar(target, base + targetCountLess1 * 2);
+        int lastChar = UNSAFE.getChar(target, base + targetCountLess1 * 2);
 
         outer_loop: for (long i = sourceOffset + fromIndex; i < sourceEnd;) {
-            int src = UnsafeAccess.UNSAFE.getChar(source, base + (i + targetCountLess1) * 2);
+            int src = UNSAFE.getChar(source, base + (i + targetCountLess1) * 2);
             if (src == lastChar) {
                 // With random strings and a 4-character alphabet,
                 // reverse matching at this point sets up 0.8% fewer
@@ -229,8 +233,8 @@
                     ExplodeLoopNode.explodeLoop();
                 }
                 for (long j = 0; j < targetCountLess1; j++) {
-                    char sourceChar = UnsafeAccess.UNSAFE.getChar(source, base + (i + j) * 2);
-                    if (UnsafeAccess.UNSAFE.getChar(target, base + (targetOffset + j) * 2) != sourceChar) {
+                    char sourceChar = UNSAFE.getChar(source, base + (i + j) * 2);
+                    if (UNSAFE.getChar(target, base + (targetOffset + j) * 2) != sourceChar) {
                         if ((cache & (1 << sourceChar)) == 0) {
                             if (md2 < j + 1) {
                                 i += j + 1;
@@ -270,10 +274,10 @@
         int sourceEnd = sourceCount - targetCountLess1;
 
         long base = byteArrayBaseOffset(INJECTED);
-        int lastChar = UnsafeAccess.UNSAFE.getChar(target, base + targetCountLess1 * 2);
+        int lastChar = UNSAFE.getChar(target, base + targetCountLess1 * 2);
 
         outer_loop: for (long i = fromIndex; i < sourceEnd;) {
-            int src = UnsafeAccess.UNSAFE.getChar(source, base + (i + targetCountLess1) * 2);
+            int src = UNSAFE.getChar(source, base + (i + targetCountLess1) * 2);
             if (src == lastChar) {
                 // With random strings and a 4-character alphabet,
                 // reverse matching at this point sets up 0.8% fewer
@@ -287,8 +291,8 @@
                     ExplodeLoopNode.explodeLoop();
                 }
                 for (long j = 0; j < targetCountLess1; j++) {
-                    char sourceChar = UnsafeAccess.UNSAFE.getChar(source, base + (i + j) * 2);
-                    if (UnsafeAccess.UNSAFE.getChar(target, base + j * 2) != sourceChar) {
+                    char sourceChar = UNSAFE.getChar(source, base + (i + j) * 2);
+                    if (UNSAFE.getChar(target, base + j * 2) != sourceChar) {
                         if ((cache & (1 << sourceChar)) == 0) {
                             if (md2 < j + 1) {
                                 i += j + 1;
@@ -328,10 +332,10 @@
         int sourceEnd = sourceCount - targetCountLess1;
 
         long base = byteArrayBaseOffset(INJECTED);
-        int lastByte = UnsafeAccess.UNSAFE.getByte(target, base + targetCountLess1);
+        int lastByte = UNSAFE.getByte(target, base + targetCountLess1);
 
         outer_loop: for (long i = fromIndex; i < sourceEnd;) {
-            int src = UnsafeAccess.UNSAFE.getByte(source, base + i + targetCountLess1);
+            int src = UNSAFE.getByte(source, base + i + targetCountLess1);
             if (src == lastByte) {
                 // With random strings and a 4-character alphabet,
                 // reverse matching at this point sets up 0.8% fewer
@@ -345,8 +349,8 @@
                     ExplodeLoopNode.explodeLoop();
                 }
                 for (long j = 0; j < targetCountLess1; j++) {
-                    byte sourceByte = UnsafeAccess.UNSAFE.getByte(source, base + i + j);
-                    if (UnsafeAccess.UNSAFE.getByte(target, base + j) != sourceByte) {
+                    byte sourceByte = UNSAFE.getByte(source, base + i + j);
+                    if (UNSAFE.getByte(target, base + j) != sourceByte) {
                         if ((cache & (1 << sourceByte)) == 0) {
                             if (md2 < j + 1) {
                                 i += j + 1;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/GraphKit.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/GraphKit.java	Tue Apr 09 11:48:54 2019 +0100
@@ -68,6 +68,7 @@
 import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext;
 import org.graalvm.compiler.nodes.java.ExceptionObjectNode;
 import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
+import org.graalvm.compiler.nodes.spi.Replacements;
 import org.graalvm.compiler.nodes.spi.StampProvider;
 import org.graalvm.compiler.nodes.type.StampTool;
 import org.graalvm.compiler.phases.OptimisticOptimizations;
@@ -152,6 +153,11 @@
     }
 
     @Override
+    public Replacements getReplacements() {
+        return providers.getReplacements();
+    }
+
+    @Override
     public StampProvider getStampProvider() {
         return providers.getStampProvider();
     }
@@ -355,7 +361,6 @@
     public void inline(InvokeNode invoke, String reason, String phase) {
         ResolvedJavaMethod method = ((MethodCallTargetNode) invoke.callTarget()).targetMethod();
 
-        MetaAccessProvider metaAccess = providers.getMetaAccess();
         Plugins plugins = new Plugins(graphBuilderPlugins);
         GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
 
@@ -366,9 +371,7 @@
             calleeGraph = new StructuredGraph.Builder(invoke.getOptions(), invoke.getDebug()).method(method).trackNodeSourcePosition(invoke.graph().trackNodeSourcePosition()).setIsSubstitution(
                             true).build();
             IntrinsicContext initialReplacementContext = new IntrinsicContext(method, method, providers.getReplacements().getDefaultReplacementBytecodeProvider(), INLINE_AFTER_PARSING);
-            GraphBuilderPhase.Instance instance = createGraphBuilderInstance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), config,
-                            OptimisticOptimizations.NONE,
-                            initialReplacementContext);
+            GraphBuilderPhase.Instance instance = createGraphBuilderInstance(providers, config, OptimisticOptimizations.NONE, initialReplacementContext);
             instance.apply(calleeGraph);
         }
 
@@ -379,9 +382,9 @@
         InliningUtil.inline(invoke, calleeGraph, false, method, reason, phase);
     }
 
-    protected GraphBuilderPhase.Instance createGraphBuilderInstance(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection,
-                    ConstantFieldProvider constantFieldProvider, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
-        return new GraphBuilderPhase.Instance(metaAccess, stampProvider, constantReflection, constantFieldProvider, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
+    protected GraphBuilderPhase.Instance createGraphBuilderInstance(Providers theProviders, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts,
+                    IntrinsicContext initialIntrinsicContext) {
+        return new GraphBuilderPhase.Instance(theProviders, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
     }
 
     protected void pushStructure(Structure structure) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/InlineDuringParsingPlugin.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/InlineDuringParsingPlugin.java	Tue Apr 09 11:48:54 2019 +0100
@@ -35,17 +35,26 @@
 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin;
 
 import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.services.Services;
 
 public final class InlineDuringParsingPlugin implements InlineInvokePlugin {
 
+    private static int getInteger(String name, int def) {
+        String value = Services.getSavedProperties().get(name);
+        if (value != null) {
+            return Integer.parseInt(value);
+        }
+        return def;
+    }
+
     /**
      * Budget which when exceeded reduces the effective value of
      * {@link BytecodeParserOptions#InlineDuringParsingMaxDepth} to
      * {@link #MaxDepthAfterBudgetExceeded}.
      */
-    private static final int NodeBudget = Integer.getInteger("InlineDuringParsingPlugin.NodeBudget", 2000);
+    private static final int NodeBudget = getInteger("InlineDuringParsingPlugin.NodeBudget", 2000);
 
-    private static final int MaxDepthAfterBudgetExceeded = Integer.getInteger("InlineDuringParsingPlugin.MaxDepthAfterBudgetExceeded", 3);
+    private static final int MaxDepthAfterBudgetExceeded = getInteger("InlineDuringParsingPlugin.MaxDepthAfterBudgetExceeded", 3);
 
     @Override
     public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/IntrinsicGraphBuilder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/IntrinsicGraphBuilder.java	Tue Apr 09 11:48:54 2019 +0100
@@ -51,6 +51,8 @@
 import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext;
 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
+import org.graalvm.compiler.nodes.spi.Replacements;
 import org.graalvm.compiler.nodes.spi.StampProvider;
 import org.graalvm.compiler.options.OptionValues;
 
@@ -70,10 +72,7 @@
  */
 public class IntrinsicGraphBuilder implements GraphBuilderContext, Receiver {
 
-    protected final MetaAccessProvider metaAccess;
-    protected final ConstantReflectionProvider constantReflection;
-    protected final ConstantFieldProvider constantFieldProvider;
-    protected final StampProvider stampProvider;
+    protected final CoreProviders providers;
     protected final StructuredGraph graph;
     protected final Bytecode code;
     protected final ResolvedJavaMethod method;
@@ -82,17 +81,12 @@
     protected ValueNode[] arguments;
     protected ValueNode returnValue;
 
-    public IntrinsicGraphBuilder(OptionValues options, DebugContext debug, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
-                    StampProvider stampProvider, Bytecode code, int invokeBci) {
-        this(options, debug, metaAccess, constantReflection, constantFieldProvider, stampProvider, code, invokeBci, AllowAssumptions.YES);
+    public IntrinsicGraphBuilder(OptionValues options, DebugContext debug, CoreProviders providers, Bytecode code, int invokeBci) {
+        this(options, debug, providers, code, invokeBci, AllowAssumptions.YES);
     }
 
-    protected IntrinsicGraphBuilder(OptionValues options, DebugContext debug, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
-                    StampProvider stampProvider, Bytecode code, int invokeBci, AllowAssumptions allowAssumptions) {
-        this.metaAccess = metaAccess;
-        this.constantReflection = constantReflection;
-        this.constantFieldProvider = constantFieldProvider;
-        this.stampProvider = stampProvider;
+    protected IntrinsicGraphBuilder(OptionValues options, DebugContext debug, CoreProviders providers, Bytecode code, int invokeBci, AllowAssumptions allowAssumptions) {
+        this.providers = providers;
         this.code = code;
         this.method = code.getMethod();
         this.graph = new StructuredGraph.Builder(options, debug, allowAssumptions).method(method).setIsSubstitution(true).trackNodeSourcePosition(true).build();
@@ -133,7 +127,9 @@
     private <T extends ValueNode> void updateLastInstruction(T v) {
         if (v instanceof FixedNode) {
             FixedNode fixedNode = (FixedNode) v;
-            lastInstr.setNext(fixedNode);
+            if (lastInstr != null) {
+                lastInstr.setNext(fixedNode);
+            }
             if (fixedNode instanceof FixedWithNextNode) {
                 FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) fixedNode;
                 assert fixedWithNextNode.next() == null : "cannot append instruction to instruction which isn't end";
@@ -175,22 +171,27 @@
 
     @Override
     public StampProvider getStampProvider() {
-        return stampProvider;
+        return providers.getStampProvider();
     }
 
     @Override
     public MetaAccessProvider getMetaAccess() {
-        return metaAccess;
+        return providers.getMetaAccess();
     }
 
     @Override
     public ConstantReflectionProvider getConstantReflection() {
-        return constantReflection;
+        return providers.getConstantReflection();
     }
 
     @Override
     public ConstantFieldProvider getConstantFieldProvider() {
-        return constantFieldProvider;
+        return providers.getConstantFieldProvider();
+    }
+
+    @Override
+    public Replacements getReplacements() {
+        return providers.getReplacements();
     }
 
     @Override
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java	Tue Apr 09 11:48:54 2019 +0100
@@ -106,6 +106,8 @@
 import org.graalvm.compiler.nodes.java.NewMultiArrayNode;
 import org.graalvm.compiler.nodes.java.StoreFieldNode;
 import org.graalvm.compiler.nodes.java.StoreIndexedNode;
+import org.graalvm.compiler.nodes.spi.CoreProviders;
+import org.graalvm.compiler.nodes.spi.Replacements;
 import org.graalvm.compiler.nodes.spi.StampProvider;
 import org.graalvm.compiler.nodes.type.StampTool;
 import org.graalvm.compiler.nodes.util.GraphUtil;
@@ -309,22 +311,27 @@
 
         @Override
         public StampProvider getStampProvider() {
-            return stampProvider;
+            return providers.getStampProvider();
         }
 
         @Override
         public MetaAccessProvider getMetaAccess() {
-            return metaAccess;
+            return providers.getMetaAccess();
         }
 
         @Override
         public ConstantReflectionProvider getConstantReflection() {
-            return constantReflection;
+            return providers.getConstantReflection();
         }
 
         @Override
         public ConstantFieldProvider getConstantFieldProvider() {
-            return constantFieldProvider;
+            return providers.getConstantFieldProvider();
+        }
+
+        @Override
+        public Replacements getReplacements() {
+            return providers.getReplacements();
         }
 
         @Override
@@ -565,11 +572,11 @@
     private final ResolvedJavaMethod callInlinedMethod;
     protected final SourceLanguagePositionProvider sourceLanguagePositionProvider;
 
-    public PEGraphDecoder(Architecture architecture, StructuredGraph graph, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
-                    StampProvider stampProvider, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins,
+    public PEGraphDecoder(Architecture architecture, StructuredGraph graph, CoreProviders providers, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins,
+                    InlineInvokePlugin[] inlineInvokePlugins,
                     ParameterPlugin parameterPlugin,
                     NodePlugin[] nodePlugins, ResolvedJavaMethod callInlinedMethod, SourceLanguagePositionProvider sourceLanguagePositionProvider) {
-        super(architecture, graph, metaAccess, constantReflection, constantFieldProvider, stampProvider, true);
+        super(architecture, graph, providers, true);
         this.loopExplosionPlugin = loopExplosionPlugin;
         this.invocationPlugins = invocationPlugins;
         this.inlineInvokePlugins = inlineInvokePlugins;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/ReplacementsImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/ReplacementsImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -52,7 +52,6 @@
 import org.graalvm.compiler.bytecode.ResolvedJavaMethodBytecode;
 import org.graalvm.compiler.core.common.CompilationIdentifier;
 import org.graalvm.compiler.core.common.GraalOptions;
-import org.graalvm.compiler.core.common.spi.ConstantFieldProvider;
 import org.graalvm.compiler.debug.DebugCloseable;
 import org.graalvm.compiler.debug.DebugContext;
 import org.graalvm.compiler.debug.DebugContext.Description;
@@ -64,6 +63,7 @@
 import org.graalvm.compiler.graph.NodeSourcePosition;
 import org.graalvm.compiler.java.GraphBuilderPhase;
 import org.graalvm.compiler.java.GraphBuilderPhase.Instance;
+import org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase;
 import org.graalvm.compiler.nodes.CallTargetNode;
 import org.graalvm.compiler.nodes.Invoke;
 import org.graalvm.compiler.nodes.StateSplit;
@@ -80,14 +80,12 @@
 import org.graalvm.compiler.nodes.graphbuilderconf.MethodSubstitutionPlugin;
 import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
 import org.graalvm.compiler.nodes.spi.Replacements;
-import org.graalvm.compiler.nodes.spi.StampProvider;
 import org.graalvm.compiler.options.Option;
 import org.graalvm.compiler.options.OptionKey;
 import org.graalvm.compiler.options.OptionType;
 import org.graalvm.compiler.options.OptionValues;
 import org.graalvm.compiler.phases.OptimisticOptimizations;
 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
-import org.graalvm.compiler.loop.phases.ConvertDeoptimizeToGuardPhase;
 import org.graalvm.compiler.phases.common.DeadCodeEliminationPhase;
 import org.graalvm.compiler.phases.tiers.PhaseContext;
 import org.graalvm.compiler.phases.util.Providers;
@@ -95,7 +93,6 @@
 import org.graalvm.compiler.word.WordOperationPlugin;
 
 import jdk.vm.ci.code.TargetDescription;
-import jdk.vm.ci.meta.ConstantReflectionProvider;
 import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.ResolvedJavaType;
@@ -322,11 +319,8 @@
                 result = graph;
             } else {
                 Bytecode code = new ResolvedJavaMethodBytecode(method);
-                ConstantReflectionProvider constantReflection = providers.getConstantReflection();
-                ConstantFieldProvider constantFieldProvider = providers.getConstantFieldProvider();
-                StampProvider stampProvider = providers.getStampProvider();
                 try (DebugContext debug = openDebugContext("Substitution_", method)) {
-                    result = new IntrinsicGraphBuilder(options, debug, metaAccess, constantReflection, constantFieldProvider, stampProvider, code, invokeBci).buildGraph(plugin);
+                    result = new IntrinsicGraphBuilder(options, debug, providers, code, invokeBci).buildGraph(plugin);
                 }
             }
         } else {
@@ -355,8 +349,7 @@
                 Plugins plugins = new Plugins(getGraphBuilderPlugins());
                 GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
                 IntrinsicContext initialReplacementContext = new IntrinsicContext(method, substMethod, bytecodeProvider, ROOT_COMPILATION);
-                new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), config,
-                                OptimisticOptimizations.NONE, initialReplacementContext).apply(graph);
+                new GraphBuilderPhase.Instance(providers, config, OptimisticOptimizations.NONE, initialReplacementContext).apply(graph);
                 assert !graph.isFrozen();
                 return graph;
             } catch (Throwable e) {
@@ -521,8 +514,7 @@
                                     snippetAnnotation != null ? snippetAnnotation.allowPartialIntrinsicArgumentMismatch() : true);
                 }
 
-                createGraphBuilder(metaAccess, replacements.providers.getStampProvider(), replacements.providers.getConstantReflection(), replacements.providers.getConstantFieldProvider(), config,
-                                OptimisticOptimizations.NONE, initialIntrinsicContext).apply(graph);
+                createGraphBuilder(replacements.providers, config, OptimisticOptimizations.NONE, initialIntrinsicContext).apply(graph);
 
                 new CanonicalizerPhase().apply(graph, new PhaseContext(replacements.providers));
             } catch (Throwable e) {
@@ -531,10 +523,8 @@
             return graph;
         }
 
-        protected Instance createGraphBuilder(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
-                        GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
-            return new GraphBuilderPhase.Instance(metaAccess, stampProvider, constantReflection, constantFieldProvider, graphBuilderConfig, optimisticOpts,
-                            initialIntrinsicContext);
+        protected Instance createGraphBuilder(Providers providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
+            return new GraphBuilderPhase.Instance(providers, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
         }
     }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/SnippetCounterNode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/SnippetCounterNode.java	Tue Apr 09 11:48:54 2019 +0100
@@ -28,7 +28,6 @@
 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_IGNORED;
 import static org.graalvm.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER;
 
-import java.lang.reflect.Field;
 import java.util.Arrays;
 
 import org.graalvm.compiler.api.replacements.Fold;
@@ -51,6 +50,7 @@
 import org.graalvm.compiler.replacements.SnippetTemplate.AbstractTemplates;
 import org.graalvm.compiler.replacements.SnippetTemplate.Arguments;
 import org.graalvm.compiler.replacements.SnippetTemplate.SnippetInfo;
+import org.graalvm.compiler.serviceprovider.GraalUnsafeAccess;
 import org.graalvm.compiler.word.ObjectAccess;
 import jdk.internal.vm.compiler.word.LocationIdentity;
 
@@ -129,6 +129,8 @@
 
     static class SnippetCounterSnippets implements Snippets {
 
+        private static final Unsafe UNSAFE = GraalUnsafeAccess.getUnsafe();
+
         @Fold
         static int countOffset() {
             try {
@@ -162,20 +164,4 @@
             }
         }
     }
-
-    private static final Unsafe UNSAFE = initUnsafe();
-
-    private static Unsafe initUnsafe() {
-        try {
-            return Unsafe.getUnsafe();
-        } catch (SecurityException se) {
-            try {
-                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                return (Unsafe) theUnsafe.get(Unsafe.class);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to get Unsafe", e);
-            }
-        }
-    }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java	Tue Apr 09 11:48:54 2019 +0100
@@ -212,6 +212,20 @@
                 return false;
             }
         });
+        r.register1("intern", Receiver.class, new InvocationPlugin() {
+            @Override
+            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
+                if (receiver.isConstant()) {
+                    String s = snippetReflection.asObject(String.class, (JavaConstant) receiver.get().asConstant());
+                    if (s != null) {
+                        JavaConstant interned = snippetReflection.forObject(s.intern());
+                        b.addPush(JavaKind.Object, b.add(ConstantNode.forConstant(interned, b.getMetaAccess(), b.getGraph())));
+                        return true;
+                    }
+                }
+                return false;
+            }
+        });
 
         if (Java8OrEarlier) {
             r.registerMethodSubstitution(StringSubstitutions.class, "equals", Receiver.class, Object.class);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/UnsafeAccess.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2012, 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
- * 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 org.graalvm.compiler.replacements;
-
-import java.lang.reflect.Field;
-
-import sun.misc.Unsafe;
-
-/**
- * Package private access to the {@link Unsafe} capability.
- */
-class UnsafeAccess {
-
-    private static final Unsafe THE_UNSAFE = initUnsafe();
-
-    static final UnsafeAccess UNSAFE = new UnsafeAccess();
-
-    private static Unsafe initUnsafe() {
-        try {
-            // Fast path when we are trusted.
-            return Unsafe.getUnsafe();
-        } catch (SecurityException se) {
-            // Slow path when we are not trusted.
-            try {
-                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                return (Unsafe) theUnsafe.get(Unsafe.class);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to get Unsafe", e);
-            }
-        }
-    }
-
-    public char getChar(Object target, long l) {
-        return THE_UNSAFE.getChar(target, l);
-    }
-
-    public byte getByte(Object target, long l) {
-        return THE_UNSAFE.getByte(target, l);
-    }
-}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/ClassfileBytecodeProvider.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/ClassfileBytecodeProvider.java	Tue Apr 09 11:48:54 2019 +0100
@@ -108,12 +108,13 @@
         if (classfile == null) {
             try {
                 ResolvedJavaType type = metaAccess.lookupJavaType(c);
-                InputStream in = GraalServices.getClassfileAsStream(c);
-                if (in != null) {
-                    DataInputStream stream = new DataInputStream(in);
-                    classfile = new Classfile(type, stream, this);
-                    classfiles.put(c, classfile);
-                    return classfile;
+                try (InputStream in = GraalServices.getClassfileAsStream(c)) {
+                    if (in != null) {
+                        DataInputStream stream = new DataInputStream(in);
+                        classfile = new Classfile(type, stream, this);
+                        classfiles.put(c, classfile);
+                        return classfile;
+                    }
                 }
                 throw new NoClassDefFoundError(c.getName());
             } catch (IOException e) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/ArrayCompareToNode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/ArrayCompareToNode.java	Tue Apr 09 11:48:54 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,10 +24,12 @@
 
 package org.graalvm.compiler.replacements.nodes;
 
+import static org.graalvm.compiler.core.common.GraalOptions.UseGraalStubs;
 import static org.graalvm.compiler.nodeinfo.InputType.Memory;
 import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_1024;
 import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_1024;
 
+import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
 import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.graph.Node;
 import org.graalvm.compiler.graph.NodeClass;
@@ -117,8 +119,25 @@
     @NodeIntrinsic
     public static native int compareTo(Object array1, Object array2, int length1, int length2, @ConstantNodeParameter JavaKind kind1, @ConstantNodeParameter JavaKind kind2);
 
+    public JavaKind getKind1() {
+        return kind1;
+    }
+
+    public JavaKind getKind2() {
+        return kind2;
+    }
+
     @Override
     public void generate(NodeLIRBuilderTool gen) {
+        if (UseGraalStubs.getValue(graph().getOptions())) {
+            ForeignCallLinkage linkage = gen.lookupGraalStub(this);
+            if (linkage != null) {
+                Value result = gen.getLIRGeneratorTool().emitForeignCall(linkage, null, gen.operand(array1), gen.operand(array2), gen.operand(length1), gen.operand(length2));
+                gen.setResult(this, result);
+                return;
+            }
+        }
+
         Value result = gen.getLIRGeneratorTool().emitArrayCompareTo(kind1, kind2, gen.operand(array1), gen.operand(array2), gen.operand(length1), gen.operand(length2));
         gen.setResult(this, result);
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/ArrayEqualsNode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/ArrayEqualsNode.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,16 +24,15 @@
 
 package org.graalvm.compiler.replacements.nodes;
 
+import static org.graalvm.compiler.core.common.GraalOptions.UseGraalStubs;
 import static org.graalvm.compiler.nodeinfo.InputType.Memory;
 
-import org.graalvm.compiler.api.replacements.Snippet;
 import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
 import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.graph.Node;
 import org.graalvm.compiler.graph.NodeClass;
 import org.graalvm.compiler.graph.spi.Canonicalizable;
 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
-import org.graalvm.compiler.lir.gen.LIRGeneratorTool;
 import org.graalvm.compiler.nodeinfo.NodeCycles;
 import org.graalvm.compiler.nodeinfo.NodeInfo;
 import org.graalvm.compiler.nodeinfo.NodeSize;
@@ -51,14 +50,11 @@
 import org.graalvm.compiler.nodes.spi.VirtualizerTool;
 import org.graalvm.compiler.nodes.util.GraphUtil;
 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
-import org.graalvm.compiler.options.Option;
-import org.graalvm.compiler.options.OptionKey;
 import jdk.internal.vm.compiler.word.LocationIdentity;
 
 import jdk.vm.ci.meta.ConstantReflectionProvider;
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.Value;
 
 // JaCoCo Exclude
@@ -69,13 +65,6 @@
 @NodeInfo(cycles = NodeCycles.CYCLES_UNKNOWN, size = NodeSize.SIZE_128)
 public final class ArrayEqualsNode extends FixedWithNextNode implements LIRLowerable, Canonicalizable, Virtualizable, MemoryAccess {
 
-    public static class Options {
-        // @formatter:off
-        @Option(help = "Use Array equals stubs instead of embedding all the emitted code.")
-        public static final OptionKey<Boolean> ArrayEqualsStubs = new OptionKey<>(true);
-        // @formatter:on
-    }
-
     public static final NodeClass<ArrayEqualsNode> TYPE = NodeClass.create(ArrayEqualsNode.class);
     /** {@link JavaKind} of the arrays to compare. */
     protected final JavaKind kind;
@@ -225,27 +214,30 @@
         return equals(array1, array2, length, JavaKind.Double);
     }
 
+    public ValueNode getLength() {
+        return length;
+    }
+
+    public JavaKind getKind() {
+        return kind;
+    }
+
     @Override
     public void generate(NodeLIRBuilderTool gen) {
-        LIRGeneratorTool tool = gen.getLIRGeneratorTool();
+        if (UseGraalStubs.getValue(graph().getOptions())) {
+            ForeignCallLinkage linkage = gen.lookupGraalStub(this);
+            if (linkage != null) {
+                Value result = gen.getLIRGeneratorTool().emitForeignCall(linkage, null, gen.operand(array1), gen.operand(array2), gen.operand(length));
+                gen.setResult(this, result);
+                return;
+            }
+        }
+
         int constantLength = -1;
         if (length.isConstant()) {
             constantLength = length.asJavaConstant().asInt();
         }
-
-        if (Options.ArrayEqualsStubs.getValue(graph().getOptions())) {
-            ResolvedJavaMethod method = graph().method();
-            if (method != null && method.getAnnotation(Snippet.class) == null) {
-                ForeignCallLinkage linkage = tool.lookupArrayEqualsStub(kind, constantLength);
-                if (linkage != null) {
-                    Value result = tool.emitForeignCall(linkage, null, gen.operand(array1), gen.operand(array2), gen.operand(length));
-                    gen.setResult(this, result);
-                    return;
-                }
-            }
-        }
-
-        Value result = tool.emitArrayEquals(kind, gen.operand(array1), gen.operand(array2), gen.operand(length), constantLength, false);
+        Value result = gen.getLIRGeneratorTool().emitArrayEquals(kind, gen.operand(array1), gen.operand(array2), gen.operand(length), constantLength, false);
         gen.setResult(this, result);
     }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/ArrayRegionEqualsNode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/ArrayRegionEqualsNode.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -24,8 +24,10 @@
 
 package org.graalvm.compiler.replacements.nodes;
 
-import jdk.vm.ci.meta.JavaKind;
-import jdk.vm.ci.meta.Value;
+import static org.graalvm.compiler.core.common.GraalOptions.UseGraalStubs;
+import static org.graalvm.compiler.nodeinfo.InputType.Memory;
+
+import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
 import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.graph.NodeClass;
 import org.graalvm.compiler.nodeinfo.NodeCycles;
@@ -42,7 +44,8 @@
 import jdk.internal.vm.compiler.word.LocationIdentity;
 import jdk.internal.vm.compiler.word.Pointer;
 
-import static org.graalvm.compiler.nodeinfo.InputType.Memory;
+import jdk.vm.ci.meta.JavaKind;
+import jdk.vm.ci.meta.Value;
 
 // JaCoCo Exclude
 
@@ -85,8 +88,29 @@
     @NodeIntrinsic
     public static native boolean regionEquals(Pointer array1, Pointer array2, int length, @ConstantNodeParameter JavaKind kind1, @ConstantNodeParameter JavaKind kind2);
 
+    public JavaKind getKind1() {
+        return kind1;
+    }
+
+    public JavaKind getKind2() {
+        return kind2;
+    }
+
+    public ValueNode getLength() {
+        return length;
+    }
+
     @Override
     public void generate(NodeLIRBuilderTool gen) {
+        if (UseGraalStubs.getValue(graph().getOptions())) {
+            ForeignCallLinkage linkage = gen.lookupGraalStub(this);
+            if (linkage != null) {
+                Value result = gen.getLIRGeneratorTool().emitForeignCall(linkage, null, gen.operand(array1), gen.operand(array2), gen.operand(length));
+                gen.setResult(this, result);
+                return;
+            }
+        }
+
         int constantLength = -1;
         if (length.isConstant()) {
             constantLength = length.asJavaConstant().asInt();
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/MacroNode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/MacroNode.java	Tue Apr 09 11:48:54 2019 +0100
@@ -41,9 +41,9 @@
 import org.graalvm.compiler.nodeinfo.NodeInfo;
 import org.graalvm.compiler.nodes.CallTargetNode.InvokeKind;
 import org.graalvm.compiler.nodes.FixedNode;
-import org.graalvm.compiler.nodes.Invokable;
 import org.graalvm.compiler.nodes.FixedWithNextNode;
 import org.graalvm.compiler.nodes.FrameState;
+import org.graalvm.compiler.nodes.Invokable;
 import org.graalvm.compiler.nodes.InvokeNode;
 import org.graalvm.compiler.nodes.StructuredGraph;
 import org.graalvm.compiler.nodes.StructuredGraph.GuardsStage;
@@ -58,10 +58,10 @@
 import org.graalvm.compiler.phases.common.RemoveValueProxyPhase;
 import org.graalvm.compiler.phases.common.inlining.InliningUtil;
 import org.graalvm.compiler.phases.tiers.PhaseContext;
+import jdk.internal.vm.compiler.word.LocationIdentity;
 
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
-import jdk.internal.vm.compiler.word.LocationIdentity;
 
 /**
  * Macro nodes can be used to temporarily replace an invoke. They can, for example, be used to
@@ -160,8 +160,7 @@
      */
     @SuppressWarnings("try")
     protected StructuredGraph lowerReplacement(final StructuredGraph replacementGraph, LoweringTool tool) {
-        final PhaseContext c = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getConstantFieldProvider(), tool.getLowerer(), tool.getReplacements(),
-                        tool.getStampProvider(), null);
+        final PhaseContext c = new PhaseContext(tool.getProviders());
         if (!graph().hasValueProxies()) {
             new RemoveValueProxyPhase().apply(replacementGraph);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.serviceprovider/src/org/graalvm/compiler/serviceprovider/GraalUnsafeAccess.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,70 @@
+/*
+ * 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
+ * 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 org.graalvm.compiler.serviceprovider;
+
+import java.lang.reflect.Field;
+
+import sun.misc.Unsafe;
+
+/**
+ * Access to the {@link Unsafe} capability. Care must be taken not to leak the {@link #UNSAFE} value
+ * of out code loaded by the JVMCI class loader or encapsulated in the JVMCI or Graal modules into
+ * other code (e.g. via the Polyglot API).
+ */
+public class GraalUnsafeAccess {
+
+    private static final Unsafe UNSAFE = initUnsafe();
+
+    private static Unsafe initUnsafe() {
+        try {
+            // Fast path when we are trusted.
+            return Unsafe.getUnsafe();
+        } catch (SecurityException se) {
+            // Slow path when we are not trusted.
+            try {
+                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
+                theUnsafe.setAccessible(true);
+                return (Unsafe) theUnsafe.get(Unsafe.class);
+            } catch (Exception e) {
+                throw new RuntimeException("exception while trying to get Unsafe", e);
+            }
+        }
+    }
+
+    /**
+     * Gets the {@link Unsafe} singleton.
+     *
+     * @throws SecurityException if a security manager is present and it denies
+     *             {@link RuntimePermission}("accessUnsafe")
+     */
+    public static Unsafe getUnsafe() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(new RuntimePermission("accessUnsafe"));
+        }
+        return UNSAFE;
+    }
+}
+
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.serviceprovider/src/org/graalvm/compiler/serviceprovider/JavaVersionUtil.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.serviceprovider/src/org/graalvm/compiler/serviceprovider/JavaVersionUtil.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,13 +24,15 @@
 
 package org.graalvm.compiler.serviceprovider;
 
+import jdk.vm.ci.services.Services;
+
 /**
  * Interface to query which JDK version Graal is running on.
  */
 public final class JavaVersionUtil {
 
     private static int getJavaSpecificationVersion() {
-        String value = System.getProperty("java.specification.version");
+        String value = Services.getSavedProperties().get("java.specification.version");
         if (value.startsWith("1.")) {
             value = value.substring(2);
         }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.virtual/src/org/graalvm/compiler/virtual/phases/ea/EffectsClosure.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.virtual/src/org/graalvm/compiler/virtual/phases/ea/EffectsClosure.java	Tue Apr 09 11:48:54 2019 +0100
@@ -428,7 +428,7 @@
     protected abstract class MergeProcessor {
 
         private final Block mergeBlock;
-        private final AbstractMergeNode merge;
+        protected final AbstractMergeNode merge;
 
         protected final GraphEffectList mergeEffects;
         protected final GraphEffectList afterMergeEffects;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.virtual/src/org/graalvm/compiler/virtual/phases/ea/PartialEscapeClosure.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.virtual/src/org/graalvm/compiler/virtual/phases/ea/PartialEscapeClosure.java	Tue Apr 09 11:48:54 2019 +0100
@@ -59,6 +59,7 @@
 import org.graalvm.compiler.nodes.ProxyNode;
 import org.graalvm.compiler.nodes.StructuredGraph;
 import org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult;
+import org.graalvm.compiler.nodes.UnwindNode;
 import org.graalvm.compiler.nodes.ValueNode;
 import org.graalvm.compiler.nodes.ValuePhiNode;
 import org.graalvm.compiler.nodes.ValueProxyNode;
@@ -105,7 +106,6 @@
      * The indexes into this array correspond to {@link VirtualObjectNode#getObjectId()}.
      */
     public final ArrayList<VirtualObjectNode> virtualObjects = new ArrayList<>();
-    public final DebugContext debug;
 
     @Override
     public boolean needsApplyEffects() {
@@ -189,7 +189,6 @@
         super(schedule, schedule.getCFG());
         StructuredGraph graph = schedule.getCFG().graph;
         this.hasVirtualInputs = graph.createNodeBitMap();
-        this.debug = graph.getDebug();
         this.tool = new VirtualizerToolImpl(metaAccess, constantReflection, constantFieldProvider, this, graph.getAssumptions(), graph.getOptions(), debug, loweringProvider);
     }
 
@@ -687,16 +686,44 @@
             // calculate the set of virtual objects that exist in all predecessors
             int[] virtualObjTemp = intersectVirtualObjects(states);
 
+            boolean forceMaterialization = false;
+            ValueNode forcedMaterializationValue = null;
+            FrameState frameState = merge.stateAfter();
+            if (frameState != null && frameState.isExceptionHandlingBCI()) {
+                // We can not go below merges with an exception handling bci
+                // it could create allocations whose slow-path has an invalid framestate
+                forceMaterialization = true;
+                // check if we can reduce the scope of forced materialization to one phi node
+                if (frameState.stackSize() == 1 && merge.next() instanceof UnwindNode) {
+                    assert frameState.outerFrameState() == null;
+                    UnwindNode unwind = (UnwindNode) merge.next();
+                    if (unwind.exception() == frameState.stackAt(0)) {
+                        boolean nullLocals = true;
+                        for (int i = 0; i < frameState.localsSize(); i++) {
+                            if (frameState.localAt(i) != null) {
+                                nullLocals = false;
+                                break;
+                            }
+                        }
+                        if (nullLocals) {
+                            // We found that the merge is directly followed by an unwind
+                            // the Framestate only has the thrown value on the stack and no locals
+                            forcedMaterializationValue = unwind.exception();
+                        }
+                    }
+                }
+            }
+
             boolean materialized;
             do {
                 materialized = false;
 
-                if (PartialEscapeBlockState.identicalObjectStates(states)) {
+                if (!forceMaterialization && PartialEscapeBlockState.identicalObjectStates(states)) {
                     newState.adoptAddObjectStates(states[0]);
                 } else {
 
                     for (int object : virtualObjTemp) {
-                        if (PartialEscapeBlockState.identicalObjectStates(states, object)) {
+                        if (!forceMaterialization && PartialEscapeBlockState.identicalObjectStates(states, object)) {
                             newState.addObject(object, states[0].getObjectState(object).share());
                             continue;
                         }
@@ -710,6 +737,22 @@
                         for (int i = 0; i < states.length; i++) {
                             ObjectState obj = states[i].getObjectState(object);
                             ensureVirtual &= obj.getEnsureVirtualized();
+                            if (forceMaterialization) {
+                                if (forcedMaterializationValue == null) {
+                                    uniqueMaterializedValue = null;
+                                    continue;
+                                } else {
+                                    ValueNode value = forcedMaterializationValue;
+                                    if (merge.isPhiAtMerge(value)) {
+                                        value = ((ValuePhiNode) value).valueAt(i);
+                                    }
+                                    ValueNode alias = getAlias(value);
+                                    if (alias instanceof VirtualObjectNode && ((VirtualObjectNode) alias).getObjectId() == object) {
+                                        uniqueMaterializedValue = null;
+                                        continue;
+                                    }
+                                }
+                            }
                             if (obj.isVirtual()) {
                                 virtualCount++;
                                 uniqueMaterializedValue = null;
@@ -1029,6 +1072,7 @@
                              */
                             if (virtual.hasIdentity() && !isSingleUsageAllocation(getPhiValueAt(phi, i), virtualObjs, states[i])) {
                                 compatible = false;
+                                break;
                             }
                         }
                     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.word/src/org/graalvm/compiler/word/UnsafeAccess.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, 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
- * 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 org.graalvm.compiler.word;
-
-import java.lang.reflect.Field;
-
-import sun.misc.Unsafe;
-
-/**
- * Package private access to the {@link Unsafe} capability.
- */
-class UnsafeAccess {
-
-    static final Unsafe UNSAFE = initUnsafe();
-
-    private static Unsafe initUnsafe() {
-        try {
-            // Fast path when we are trusted.
-            return Unsafe.getUnsafe();
-        } catch (SecurityException se) {
-            // Slow path when we are not trusted.
-            try {
-                Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
-                theUnsafe.setAccessible(true);
-                return (Unsafe) theUnsafe.get(Unsafe.class);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to get Unsafe", e);
-            }
-        }
-    }
-}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.word/src/org/graalvm/compiler/word/Word.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.word/src/org/graalvm/compiler/word/Word.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,7 @@
 
 package org.graalvm.compiler.word;
 
-import static org.graalvm.compiler.word.UnsafeAccess.UNSAFE;
+import static org.graalvm.compiler.serviceprovider.GraalUnsafeAccess.getUnsafe;
 
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -59,8 +59,12 @@
 import jdk.internal.vm.compiler.word.WordFactory;
 import jdk.internal.vm.compiler.word.impl.WordBoxFactory;
 
+import sun.misc.Unsafe;
+
 public abstract class Word implements SignedWord, UnsignedWord, Pointer {
 
+    private static final Unsafe UNSAFE = getUnsafe();
+
     static {
         BoxFactoryImpl.initialize();
     }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java	Tue Apr 09 11:48:54 2019 +0100
@@ -62,7 +62,7 @@
  * <p>
  *
  * <a id="terminology"></a>
- * <h3>Terminology</h3>
+ * <h2>Terminology</h2>
  *
  * <dl>
  *   <dt><a id="selected"></a>Selected</dt>
@@ -88,7 +88,7 @@
  * </dl>
  * <p>
  * <a id="options"></a>
- * <h3>Options</h3>
+ * <h2>Options</h2>
  * Javadoc <em>selection control</em> can be specified with these options
  * as follows:
  * <ul>
@@ -132,7 +132,7 @@
  * </ul>
  * <p>
  * <a id="legacy-interactions"></a>
- * <h4>Interactions with older options.</h4>
+ * <h3>Interactions with older options.</h3>
  *
  * The new {@code --show-*} options provide a more detailed replacement
  * for the older options {@code -public}, {@code -protected}, {@code -package}, {@code -private}.
@@ -181,7 +181,7 @@
  * <p>
  *
  * <a id="example"></a>
- * <h3>Example</h3>
+ * <h2>Example</h2>
  *
  * The following is an example doclet that displays information of a class
  * and its members, supporting an option.
@@ -300,7 +300,7 @@
  *       source-location/Example.java
  * </pre>
  *
- * <h3><a id="migration">Migration Guide</a></h3>
+ * <h2><a id="migration">Migration Guide</a></h2>
  *
  * <p>Many of the types in the old {@code com.sun.javadoc} API do not have equivalents in this
  * package. Instead, types in the {@code javax.lang.model} and {@code com.sun.source} APIs
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -44,9 +44,7 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 
 /**
- * Abstract class to generate the module overview files in
- * Frame and Non-Frame format. This will be sub-classed to
- * generate module-overview-frame.html as well as module-overview-summary.html.
+ * Abstract class to generate the module overview files.
  *
  *  <p><b>This is NOT part of any supported API.
  *  If you write code that depends on this, you do so at your own risk.
@@ -118,19 +116,16 @@
             String tableSummary, Content main, ModuleElement mdle);
 
     /**
-     * Generate and prints the contents in the module index file. Call appropriate
-     * methods from the sub-class in order to generate Frame or Non
-     * Frame format.
+     * Generate and prints the contents in the module index file.
      *
      * @param title the title of the window
      * @param description the content for the description META tag
-     * @param includeScript boolean set true if windowtitle script is to be included
      * @throws DocFileIOException if there is a problem building the module index file
      */
-    protected void buildModuleIndexFile(String title, String description, boolean includeScript)
+    protected void buildModuleIndexFile(String title, String description)
             throws DocFileIOException {
         String windowOverview = resources.getText(title);
-        Content body = getBody(includeScript, getWindowTitle(windowOverview));
+        Content body = getBody(getWindowTitle(windowOverview));
         Content header = HtmlTree.HEADER();
         addNavigationBarHeader(header);
         Content main = HtmlTree.MAIN();
@@ -149,20 +144,17 @@
     }
 
     /**
-     * Generate and prints the contents in the module packages index file. Call appropriate
-     * methods from the sub-class in order to generate Frame or Non
-     * Frame format.
+     * Generate and prints the contents in the module packages index file.
      *
      * @param title the title of the window.
      * @param description the content for the description META tag
-     * @param includeScript boolean set true if windowtitle script is to be included
      * @param mdle the name of the module being documented
      * @throws DocFileIOException if there is an exception building the module packages index file
      */
     protected void buildModulePackagesIndexFile(String title, String description,
-            boolean includeScript, ModuleElement mdle) throws DocFileIOException {
+             ModuleElement mdle) throws DocFileIOException {
         String windowOverview = resources.getText(title);
-        Content body = getBody(includeScript, getWindowTitle(windowOverview));
+        Content body = getBody(getWindowTitle(windowOverview));
         Content header = HtmlTree.HEADER();
         addNavigationBarHeader(header);
         Content main = HtmlTree.MAIN();
@@ -188,7 +180,7 @@
     protected void addOverview(Content main) { }
 
     /**
-     * Adds the frame or non-frame module index to the documentation tree.
+     * Adds the module index to the documentation tree.
      *
      * @param header the document tree to which the navigational links will be added
      * @param main the document tree to which the modules list will be added
@@ -201,7 +193,7 @@
     }
 
     /**
-     * Adds the frame or non-frame module packages index to the documentation tree.
+     * Adds the module packages index to the documentation tree.
      *
      * @param header the document tree to which the navigational links will be added
      * @param main the document tree to which the module packages list will be added
@@ -226,13 +218,6 @@
      */
     protected void addIndexContents(Collection<ModuleElement> modules, String text,
             String tableSummary, Content header, Content main) {
-        HtmlTree htmlTree = HtmlTree.NAV();
-        htmlTree.setStyle(HtmlStyle.indexNav);
-        HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        addAllClassesLink(ul);
-        addAllPackagesLink(ul);
-        htmlTree.add(ul);
-        header.add(htmlTree);
         addModulesList(main);
     }
 
@@ -248,14 +233,6 @@
      */
     protected void addModulePackagesIndexContents(String text,
             String tableSummary, Content header, Content main, ModuleElement mdle) {
-        HtmlTree htmlTree = HtmlTree.NAV();
-        htmlTree.setStyle(HtmlStyle.indexNav);
-        HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        addAllClassesLink(ul);
-        addAllPackagesLink(ul);
-        addAllModulesLink(ul);
-        htmlTree.add(ul);
-        header.add(htmlTree);
         addModulePackagesList(modules, text, tableSummary, main, mdle);
     }
 
@@ -273,25 +250,4 @@
             body.add(div);
         }
     }
-
-    /**
-     * Do nothing. This will be overridden in ModuleIndexFrameWriter.
-     *
-     * @param div the document tree to which the all classes link will be added
-     */
-    protected void addAllClassesLink(Content div) { }
-
-    /**
-     * Do nothing. This will be overridden in ModuleIndexFrameWriter.
-     *
-     * @param div the document tree to which the all packages link will be added
-     */
-    protected void addAllPackagesLink(Content div) { }
-
-    /**
-     * Do nothing. This will be overridden in ModulePackageIndexFrameWriter.
-     *
-     * @param div the document tree to which the all modules link will be added
-     */
-    protected void addAllModulesLink(Content div) { }
 }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -40,9 +40,8 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 
 /**
- * Abstract class to generate the overview files in
- * Frame and Non-Frame format. This will be sub-classed by to
- * generate overview-frame.html as well as overview-summary.html.
+ * Abstract class to generate the overview files. This will be sub-classed to
+ * generate overview-summary.html.
  *
  *  <p><b>This is NOT part of any supported API.
  *  If you write code that depends on this, you do so at your own risk.
@@ -103,19 +102,16 @@
     protected abstract void addPackagesList(Content main);
 
     /**
-     * Generate and prints the contents in the package index file. Call appropriate
-     * methods from the sub-class in order to generate Frame or Non
-     * Frame format.
+     * Generate and prints the contents in the package index file.
      *
      * @param title the title of the window
      * @param description the content for the description META tag
-     * @param includeScript boolean set true if windowtitle script is to be included
      * @throws DocFileIOException if there is a problem building the package index file
      */
-    protected void buildPackageIndexFile(String title, String description, boolean includeScript)
+    protected void buildPackageIndexFile(String title, String description)
             throws DocFileIOException {
         String windowOverview = resources.getText(title);
-        Content body = getBody(includeScript, getWindowTitle(windowOverview));
+        Content body = getBody(getWindowTitle(windowOverview));
         Content header = HtmlTree.HEADER();
         addNavigationBarHeader(header);
         Content main = HtmlTree.MAIN();
@@ -140,7 +136,7 @@
     protected void addOverview(Content main) { }
 
     /**
-     * Adds the frame or non-frame package index to the documentation tree.
+     * Adds the package index to the documentation tree.
      *
      * @param header the document tree to which the navigation links will be added
      * @param main the document tree to which the packages list will be added
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*
- * 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
- * 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.javadoc.internal.doclets.formats.html;
-
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
-import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
-
-
-/**
- * Generate the file with list of all the classes in this run. This page will be
- * used in the left-hand bottom frame, when "All Classes" link is clicked in
- * the left-hand top frame. The name of the generated file is
- * "allclasses-frame.html".
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Atul M Dambalkar
- * @author Doug Kramer
- * @author Bhavesh Patel (Modified)
- */
-public class AllClassesFrameWriter extends HtmlDocletWriter {
-
-    /**
-     * Index of all the classes.
-     */
-    protected IndexBuilder indexbuilder;
-
-    /**
-     * BR tag to be used within a document tree.
-     */
-    final HtmlTree BR = new HtmlTree(HtmlTag.BR);
-
-    /**
-     * Construct AllClassesFrameWriter object. Also initializes the indexbuilder
-     * variable in this class.
-     * @param configuration  The current configuration
-     * @param filename       Path to the file which is getting generated.
-     * @param indexbuilder   Unicode based Index from {@link IndexBuilder}
-     */
-    public AllClassesFrameWriter(HtmlConfiguration configuration,
-                                 DocPath filename, IndexBuilder indexbuilder) {
-        super(configuration, filename);
-        this.indexbuilder = indexbuilder;
-    }
-
-    /**
-     * Create AllClassesFrameWriter object. Then use it to generate the
-     * "allclasses-frame.html" file. Generate the file in the current or the
-     * destination directory.
-     *
-     * @param configuration the configuration for this javadoc run
-     * @throws DocFileIOException
-     */
-    public static void generate(HtmlConfiguration configuration,
-            IndexBuilder indexBuilder) throws DocFileIOException {
-        if (configuration.frames) {
-            generate(configuration, indexBuilder, DocPaths.ALLCLASSES_FRAME, true);
-        }
-    }
-
-    private static void generate(HtmlConfiguration configuration, IndexBuilder indexBuilder,
-                                 DocPath fileName, boolean wantFrames) throws DocFileIOException {
-        AllClassesFrameWriter allclassgen = new AllClassesFrameWriter(configuration,
-                fileName, indexBuilder);
-        allclassgen.buildAllClassesFile(wantFrames);
-        allclassgen = new AllClassesFrameWriter(configuration,
-                                                fileName, indexBuilder);
-    }
-
-    /**
-     * Print all the classes in the file.
-     * @param wantFrames True if we want frames.
-     */
-    protected void buildAllClassesFile(boolean wantFrames) throws DocFileIOException {
-        String label = resources.getText("doclet.All_Classes");
-        Content body = getBody(false, getWindowTitle(label));
-        Content htmlTree = HtmlTree.MAIN();
-        Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING,
-                HtmlStyle.bar, contents.allClassesLabel);
-        htmlTree.add(heading);
-        Content ul = new HtmlTree(HtmlTag.UL);
-        // Generate the class links and add it to the tdFont tree.
-        addAllClasses(ul, wantFrames);
-        HtmlTree div = HtmlTree.DIV(HtmlStyle.indexContainer, ul);
-        htmlTree.add(div);
-        body.add(htmlTree);
-        printHtmlDocument(null, "all classes (frame)", body);
-    }
-
-    /**
-     * Use the sorted index of all the classes and add all the classes to the
-     * content list.
-     *
-     * @param content HtmlTree content to which all classes information will be added
-     * @param wantFrames True if we want frames.
-     */
-    protected void addAllClasses(Content content, boolean wantFrames) {
-        for (Character unicode : indexbuilder.index()) {
-            addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
-        }
-    }
-
-    /**
-     * Given a list of classes, generate links for each class or interface.
-     * If the class kind is interface, print it in the italics font. Also all
-     * links should target the right-hand frame. If clicked on any class name
-     * in this page, appropriate class page should get opened in the right-hand
-     * frame.
-     *
-     * @param classlist Sorted list of classes.
-     * @param wantFrames True if we want frames.
-     * @param content HtmlTree content to which the links will be added
-     */
-    protected void addContents(Iterable<? extends Element> classlist, boolean wantFrames,
-                               Content content) {
-        for (Element element : classlist) {
-            TypeElement typeElement = (TypeElement)element;
-            if (!utils.isCoreClass(typeElement)) {
-                continue;
-            }
-            Content label = interfaceName(typeElement, false);
-            Content linkContent;
-            if (wantFrames) {
-                linkContent = getLink(new LinkInfoImpl(configuration,
-                                                       LinkInfoImpl.Kind.ALL_CLASSES_FRAME, typeElement).label(label).target("classFrame"));
-            } else {
-                linkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, typeElement).label(label));
-            }
-            Content li = HtmlTree.LI(linkContent);
-            content.add(li);
-        }
-    }
-}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -63,7 +63,7 @@
     private final Navigation navBar;
 
     /**
-     * Construct AllClassesFrameWriter object. Also initializes the indexbuilder variable in this
+     * Construct AllClassesIndexWriter object. Also initializes the indexbuilder variable in this
      * class.
      *
      * @param configuration The current configuration
@@ -101,7 +101,7 @@
      */
     protected void buildAllClassesFile() throws DocFileIOException {
         String label = resources.getText("doclet.All_Classes");
-        HtmlTree bodyTree = getBody(true, getWindowTitle(label));
+        HtmlTree bodyTree = getBody(getWindowTitle(label));
         HtmlTree header = HtmlTree.HEADER();
         addTop(header);
         navBar.setUserHeader(getUserHeaderFooter(true));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -83,7 +83,7 @@
      */
     protected void buildAllPackagesFile() throws DocFileIOException {
         String label = resources.getText("doclet.All_Packages");
-        HtmlTree bodyTree = getBody(true, getWindowTitle(label));
+        HtmlTree bodyTree = getBody(getWindowTitle(label));
         HtmlTree header = HtmlTree.HEADER();
         addTop(header);
         navBar.setUserHeader(getUserHeaderFooter(true));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -84,7 +84,7 @@
      */
     @Override
     public Content getHeader(String header) {
-        HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getSimpleName(annotationType)));
+        HtmlTree bodyTree = getBody(getWindowTitle(utils.getSimpleName(annotationType)));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(annotationType),
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -434,7 +434,7 @@
         String clname = utils.getFullyQualifiedName(typeElement);
         String title = resources.getText("doclet.Window_ClassUse_Header",
                 cltype, clname);
-        HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+        HtmlTree bodyTree = getBody(getWindowTitle(title));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         Content mdleLinkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -105,7 +105,7 @@
      */
     @Override
     public Content getHeader(String header) {
-        HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getSimpleName(typeElement)));
+        HtmlTree bodyTree = getBody(getWindowTitle(utils.getSimpleName(typeElement)));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -105,7 +105,7 @@
     @Override
     public Content getHeader() {
         String label = resources.getText("doclet.Constants_Summary");
-        HtmlTree bodyTree = getBody(true, getWindowTitle(label));
+        HtmlTree bodyTree = getBody(getWindowTitle(label));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         navBar.setUserHeader(getUserHeaderFooter(true));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -369,7 +369,7 @@
      */
     public HtmlTree getHeader() {
         String title = resources.getText("doclet.Window_Deprecated_List");
-        HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+        HtmlTree bodyTree = getBody(getWindowTitle(title));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         navBar.setUserHeader(getUserHeaderFooter(true));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -179,7 +179,7 @@
         Content localTagsContent = docletWriter.commentTagsToContent(null, dfElement, localTags, false);
 
         String title = getWindowTitle(docletWriter, dfElement).trim();
-        HtmlTree htmlContent = docletWriter.getBody(true, title);
+        HtmlTree htmlContent = docletWriter.getBody(title);
         docletWriter.addTop(htmlContent);
         PackageElement pkg = (PackageElement) element;
         this.navBar = new Navigation(pkg, configuration, docletWriter.fixedNavDiv,
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,272 +0,0 @@
-/*
- * 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
- * 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.javadoc.internal.doclets.formats.html;
-
-import jdk.javadoc.internal.doclets.formats.html.markup.Head;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.Script;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
-
-
-/**
- * Generate the documentation in the Html "frame" format in the browser. The
- * generated documentation will have two or three frames depending upon the
- * number of packages on the command line. In general there will be three frames
- * in the output, a left-hand top frame will have a list of all packages with
- * links to target left-hand bottom frame. The left-hand bottom frame will have
- * the particular package contents or the all-classes list, where as the single
- * right-hand frame will have overview or package summary or class file. Also
- * take care of browsers which do not support Html frames.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Atul M Dambalkar
- */
-public class FrameOutputWriter extends HtmlDocletWriter {
-
-    /**
-     * Number of packages specified on the command line.
-     */
-    int noOfPackages;
-
-    /**
-     * Constructor to construct FrameOutputWriter object.
-     *
-     * @param configuration for this run
-     * @param filename File to be generated.
-     */
-    public FrameOutputWriter(HtmlConfiguration configuration, DocPath filename) {
-        super(configuration, filename);
-        noOfPackages = configuration.packages.size();
-    }
-
-    /**
-     * Construct FrameOutputWriter object and then use it to generate the Html
-     * file which will have the description of all the frames in the
-     * documentation. The name of the generated file is "index.html" which is
-     * the default first file for Html documents.
-     * @param configuration the configuration for this doclet
-     * @throws DocFileIOException if there is a problem generating the frame file
-     */
-    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
-        FrameOutputWriter framegen = new FrameOutputWriter(configuration, DocPaths.INDEX);
-        framegen.generateFrameFile();
-    }
-
-    /**
-     * Generate the constants in the "index.html" file. Print the frame details
-     * as well as warning if browser is not supporting the Html frames.
-     * @throws DocFileIOException if there is a problem generating the frame file
-     */
-    protected void generateFrameFile() throws DocFileIOException {
-        Content frame = getFrameDetails();
-        HtmlTree body = new HtmlTree(HtmlTag.BODY);
-        body.put(HtmlAttr.CLASS, "frames");
-        body.put(HtmlAttr.ONLOAD, "loadFrames()");
-        String topFilePath = configuration.topFile.getPath();
-        Script script = new Script(
-                "\nif (targetPage == \"\" || targetPage == \"undefined\")\n" +
-                "     window.location.replace(")
-                .appendStringLiteral(topFilePath, '\'')
-                .append(");\n");
-        body.add(script.asContent());
-        Content noScript = HtmlTree.NOSCRIPT(contents.noScriptMessage);
-        body.add(noScript);
-        HtmlTree main = HtmlTree.MAIN(frame);
-        body.add(main);
-        if (configuration.windowtitle.length() > 0) {
-            printFramesDocument(configuration.windowtitle, body);
-        } else {
-            printFramesDocument(resources.getText("doclet.Generated_Docs_Untitled"), body);
-        }
-    }
-
-    /**
-     * Print the frames version of the Html file header.
-     * Called only when generating an HTML frames file.
-     *
-     * @param title Title of this HTML document
-     * @param body the body content tree to be added to the HTML document
-     * @throws DocFileIOException if there is an error writing the frames document
-     */
-    private void printFramesDocument(String title, HtmlTree body) throws DocFileIOException {
-        Content htmlComment = contents.newPage;
-        Head head = new Head(path, configuration.docletVersion)
-                .setTimestamp(!configuration.notimestamp)
-                .setTitle(title)
-                .setDescription("frames")
-                .setGenerator(getGenerator(getClass()))
-                .setCharset(configuration.charset)
-                .setStylesheets(configuration.getMainStylesheet(), configuration.getAdditionalStylesheets())
-                .addDefaultScript(false)
-                .addScript(getFramesScript());
-
-        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head.toContent(), body);
-        HtmlDocument htmlDocument = new HtmlDocument(htmlComment, htmlTree);
-        htmlDocument.write(DocFile.createFileForOutput(configuration, path));
-   }
-
-    /**
-     * Get the frame sizes and their contents.
-     *
-     * @return a content tree for the frame details
-     */
-    protected Content getFrameDetails() {
-        HtmlTree leftContainerDiv = new HtmlTree(HtmlTag.DIV);
-        HtmlTree rightContainerDiv = new HtmlTree(HtmlTag.DIV);
-        leftContainerDiv.setStyle(HtmlStyle.leftContainer);
-        rightContainerDiv.setStyle(HtmlStyle.rightContainer);
-        if (configuration.showModules && configuration.modules.size() > 1) {
-            addAllModulesFrameTag(leftContainerDiv);
-        } else if (noOfPackages > 1) {
-            addAllPackagesFrameTag(leftContainerDiv);
-        }
-        addAllClassesFrameTag(leftContainerDiv);
-        addClassFrameTag(rightContainerDiv);
-        HtmlTree mainContainer = HtmlTree.DIV(HtmlStyle.mainContainer, leftContainerDiv);
-        mainContainer.add(rightContainerDiv);
-        return mainContainer;
-    }
-
-    /**
-     * Add the IFRAME tag for the frame that lists all modules.
-     *
-     * @param contentTree to which the information will be added
-     */
-    private void addAllModulesFrameTag(Content contentTree) {
-        HtmlTree frame = HtmlTree.IFRAME(DocPaths.MODULE_OVERVIEW_FRAME.getPath(),
-                "packageListFrame", resources.getText("doclet.All_Modules"));
-        HtmlTree leftTop = HtmlTree.DIV(HtmlStyle.leftTop, frame);
-        contentTree.add(leftTop);
-    }
-
-    /**
-     * Add the IFRAME tag for the frame that lists all packages.
-     *
-     * @param contentTree the content tree to which the information will be added
-     */
-    private void addAllPackagesFrameTag(Content contentTree) {
-        HtmlTree frame = HtmlTree.IFRAME(DocPaths.OVERVIEW_FRAME.getPath(),
-                "packageListFrame", resources.getText("doclet.All_Packages"));
-        HtmlTree leftTop = HtmlTree.DIV(HtmlStyle.leftTop, frame);
-        contentTree.add(leftTop);
-    }
-
-    /**
-     * Add the IFRAME tag for the frame that lists all classes.
-     *
-     * @param contentTree the content tree to which the information will be added
-     */
-    private void addAllClassesFrameTag(Content contentTree) {
-        HtmlTree frame = HtmlTree.IFRAME(DocPaths.ALLCLASSES_FRAME.getPath(),
-                "packageFrame", resources.getText("doclet.All_classes_and_interfaces"));
-        HtmlTree leftBottom = HtmlTree.DIV(HtmlStyle.leftBottom, frame);
-        contentTree.add(leftBottom);
-    }
-
-    /**
-     * Add the IFRAME tag for the frame that describes the class in detail.
-     *
-     * @param contentTree the content tree to which the information will be added
-     */
-    private void addClassFrameTag(Content contentTree) {
-        HtmlTree frame = HtmlTree.IFRAME(configuration.topFile.getPath(), "classFrame",
-                resources.getText("doclet.Package_class_and_interface_descriptions"));
-        frame.setStyle(HtmlStyle.rightIframe);
-        contentTree.add(frame);
-    }
-
-    /**
-     * Returns a content tree for the SCRIPT tag for the main page(index.html).
-     *
-     * @return a content for the SCRIPT tag
-     */
-    protected Script getFramesScript() {
-        return new Script("\n" +
-                "    tmpTargetPage = \"\" + window.location.search;\n" +
-                "    if (tmpTargetPage != \"\" && tmpTargetPage != \"undefined\")\n" +
-                "        tmpTargetPage = tmpTargetPage.substring(1);\n" +
-                "    if (tmpTargetPage.indexOf(\":\") != -1 || (tmpTargetPage != \"\" && !validURL(tmpTargetPage)))\n" +
-                "        tmpTargetPage = \"undefined\";\n" +
-                "    targetPage = tmpTargetPage;\n" +
-                "    function validURL(url) {\n" +
-                "        try {\n" +
-                "            url = decodeURIComponent(url);\n" +
-                "        }\n" +
-                "        catch (error) {\n" +
-                "            return false;\n" +
-                "        }\n" +
-                "        var pos = url.indexOf(\".html\");\n" +
-                "        if (pos == -1 || pos != url.length - 5)\n" +
-                "            return false;\n" +
-                "        var allowNumber = false;\n" +
-                "        var allowSep = false;\n" +
-                "        var seenDot = false;\n" +
-                "        for (var i = 0; i < url.length - 5; i++) {\n" +
-                "            var ch = url.charAt(i);\n" +
-                "            if ('a' <= ch && ch <= 'z' ||\n" +
-                "                    'A' <= ch && ch <= 'Z' ||\n" +
-                "                    ch == '$' ||\n" +
-                "                    ch == '_' ||\n" +
-                "                    ch.charCodeAt(0) > 127) {\n" +
-                "                allowNumber = true;\n" +
-                "                allowSep = true;\n" +
-                "            } else if ('0' <= ch && ch <= '9'\n" +
-                "                    || ch == '-') {\n" +
-                "                if (!allowNumber)\n" +
-                "                     return false;\n" +
-                "            } else if (ch == '/' || ch == '.') {\n" +
-                "                if (!allowSep)\n" +
-                "                    return false;\n" +
-                "                allowNumber = false;\n" +
-                "                allowSep = false;\n" +
-                "                if (ch == '.')\n" +
-                "                     seenDot = true;\n" +
-                "                if (ch == '/' && seenDot)\n" +
-                "                     return false;\n" +
-                "            } else {\n" +
-                "                return false;\n" +
-                "            }\n" +
-                "        }\n" +
-                "        return true;\n" +
-                "    }\n" +
-                "    function loadFrames() {\n" +
-                "        if (targetPage != \"\" && targetPage != \"undefined\")\n" +
-                "             top.classFrame.location = top.targetPage;\n" +
-                "    }\n");
-    }
-}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -87,7 +87,7 @@
      */
     protected void generateHelpFile() throws DocFileIOException {
         String title = resources.getText("doclet.Window_Help_title");
-        HtmlTree body = getBody(true, getWindowTitle(title));
+        HtmlTree body = getBody(getWindowTitle(title));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         navBar.setUserHeader(getUserHeaderFooter(true));
@@ -132,8 +132,7 @@
                     ? "doclet.help.overview.modules.body"
                     : "doclet.help.overview.packages.body";
             Content overviewLink = links.createLink(
-                    DocPaths.overviewSummary(configuration.frames),
-                    resources.getText("doclet.Overview"));
+                    DocPaths.INDEX, resources.getText("doclet.Overview"));
             Content overviewBody = contents.getContent(overviewKey, overviewLink);
             Content overviewPara = HtmlTree.P(overviewBody);
             htmlTree.add(overviewPara);
@@ -299,18 +298,6 @@
             ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
         }
 
-        // Frames
-        if (configuration.frames) {
-            Content frameHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
-                    contents.getContent("doclet.help.frames.head"));
-            htmlTree = HtmlTree.SECTION(frameHead);
-            Content framesBody = contents.getContent("doclet.help.frames.body");
-            Content framePara = HtmlTree.P(framesBody);
-            htmlTree.add(framePara);
-
-            ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
-        }
-
         // Serialized Form
         Content sHead = HtmlTree.HEADING(Headings.CONTENT_HEADING,
                 contents.serializedForm);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Tue Apr 09 11:48:54 2019 +0100
@@ -197,12 +197,6 @@
     public boolean createoverview = false;
 
     /**
-     * Specifies whether or not frames should be generated.
-     * Defaults to false; can be set to true by --frames; can be set to false by --no-frames; last one wins.
-     */
-    public boolean frames = false;
-
-    /**
      * Collected set of doclint options
      */
     public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
@@ -375,7 +369,7 @@
             return;
         }
         if (createoverview) {
-            topFile = DocPaths.overviewSummary(frames);
+            topFile = DocPaths.INDEX;
         } else {
             if (showModules) {
                 topFile = DocPath.empty.resolve(docPaths.moduleSummary(modules.first()));
@@ -640,21 +634,6 @@
                     return true;
                 }
             },
-            new Option(resources, "--frames") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    reporter.print(WARNING, resources.getText("doclet.Frames_specified", helpfile));
-                    frames = true;
-                    return true;
-                }
-            },
-            new Option(resources, "--no-frames") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    frames = false;
-                    return true;
-                }
-            },
             new Hidden(resources, "-packagesheader", 1) {
                 @Override
                 public boolean process(String opt,  List<String> args) {
@@ -749,6 +728,13 @@
                     }
                     return true;
                 }
+            },
+            new XOption(resources, "--no-frames") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    reporter.print(WARNING, resources.getText("doclet.NoFrames_specified"));
+                    return true;
+                }
             }
         };
         Set<Doclet.Option> oset = new TreeSet<>();
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Tue Apr 09 11:48:54 2019 +0100
@@ -144,13 +144,6 @@
             DeprecatedListWriter.generate(configuration);
         }
 
-        AllClassesFrameWriter.generate(configuration,
-            new IndexBuilder(configuration, nodeprecated, true));
-
-        if (configuration.frames) {
-            FrameOutputWriter.generate(configuration);
-        }
-
         if (configuration.createoverview) {
             if (configuration.showModules) {
                 ModuleIndexWriter.generate(configuration);
@@ -173,12 +166,10 @@
             }
         }
 
-        if (!configuration.frames) {
-            if (configuration.createoverview) {
-                IndexRedirectWriter.generate(configuration, DocPaths.OVERVIEW_SUMMARY, DocPaths.INDEX);
-            } else {
-                IndexRedirectWriter.generate(configuration);
-            }
+        if (configuration.createoverview) {
+            IndexRedirectWriter.generate(configuration, DocPaths.OVERVIEW_SUMMARY, DocPaths.INDEX);
+        } else {
+            IndexRedirectWriter.generate(configuration);
         }
 
         if (configuration.helpfile.isEmpty() && !configuration.nohelp) {
@@ -273,15 +264,8 @@
     @Override // defined by AbstractDoclet
     protected void generateModuleFiles() throws DocletException {
         if (configuration.showModules) {
-            if (configuration.frames  && configuration.modules.size() > 1) {
-                ModuleIndexFrameWriter.generate(configuration);
-            }
             List<ModuleElement> mdles = new ArrayList<>(configuration.modulePackages.keySet());
             for (ModuleElement mdle : mdles) {
-                if (configuration.frames && configuration.modules.size() > 1) {
-                    ModulePackageIndexFrameWriter.generate(configuration, mdle);
-                    ModuleFrameWriter.generate(configuration, mdle);
-                }
                 AbstractBuilder moduleSummaryBuilder =
                         configuration.getBuilderFactory().getModuleSummaryBuilder(mdle);
                 moduleSummaryBuilder.build();
@@ -295,18 +279,12 @@
     @Override // defined by AbstractDoclet
     protected void generatePackageFiles(ClassTree classtree) throws DocletException {
         Set<PackageElement> packages = configuration.packages;
-        if (packages.size() > 1 && configuration.frames) {
-            PackageIndexFrameWriter.generate(configuration);
-        }
         List<PackageElement> pList = new ArrayList<>(packages);
         for (PackageElement pkg : pList) {
             // if -nodeprecated option is set and the package is marked as
             // deprecated, do not generate the package-summary.html, package-frame.html
             // and package-tree.html pages for that package.
             if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
-                if (configuration.frames) {
-                    PackageFrameWriter.generate(configuration, pkg);
-                }
                 AbstractBuilder packageSummaryBuilder =
                         configuration.getBuilderFactory().getPackageSummaryBuilder(pkg);
                 packageSummaryBuilder.build();
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -202,6 +202,7 @@
         this.pathToRoot = path.parent().invert();
         this.filename = path.basename();
         this.docPaths = configuration.docPaths;
+        this.mainBodyScript = new Script();
 
         messages.notice("doclet.Generating_0",
             DocFile.createFileForOutput(configuration, path).getPath());
@@ -375,47 +376,6 @@
     }
 
     /**
-     * Get Package link, with target frame.
-     *
-     * @param pkg The link will be to the "package-summary.html" page for this package
-     * @param target name of the target frame
-     * @param label tag for the link
-     * @return a content for the target package link
-     */
-    public Content getTargetPackageLink(PackageElement pkg, String target,
-            Content label) {
-        return links.createLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY), label, "", target);
-    }
-
-    /**
-     * Get Module Package link, with target frame.
-     *
-     * @param pkg the PackageElement
-     * @param target name of the target frame
-     * @param label tag for the link
-     * @param mdle the module being documented
-     * @return a content for the target module packages link
-     */
-    public Content getTargetModulePackageLink(PackageElement pkg, String target,
-            Content label, ModuleElement mdle) {
-        return links.createLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
-                label, "", target);
-    }
-
-    /**
-     * Get Module link, with target frame.
-     *
-     * @param target name of the target frame
-     * @param label tag for the link
-     * @param mdle the module being documented
-     * @return a content for the target module link
-     */
-    public Content getTargetModuleLink(String target, Content label, ModuleElement mdle) {
-        return links.createLink(pathToRoot.resolve(
-                docPaths.moduleSummary(mdle)), label, "", target);
-    }
-
-    /**
      * Generates the HTML document tree and prints it out.
      *
      * @param metakeywords Array of String keywords for META tag. Each element
@@ -2190,24 +2150,19 @@
     /**
      * Returns an HtmlTree for the BODY tag.
      *
-     * @param includeScript  set true if printing windowtitle script
      * @param title title for the window
      * @return an HtmlTree for the BODY tag
      */
-    public HtmlTree getBody(boolean includeScript, String title) {
+    public HtmlTree getBody(String title) {
         HtmlTree body = new HtmlTree(HtmlTag.BODY);
         body.put(HtmlAttr.CLASS, getBodyClass());
 
-        // Set window title string which is later printed
         this.winTitle = title;
         // Don't print windowtitle script for overview-frame, allclasses-frame
         // and package-frame
-        if (includeScript) {
-            this.mainBodyScript = getWinTitleScript();
-            body.add(mainBodyScript.asContent());
-            Content noScript = HtmlTree.NOSCRIPT(HtmlTree.DIV(contents.noScriptMessage));
-            body.add(noScript);
-        }
+        body.add(mainBodyScript.asContent());
+        Content noScript = HtmlTree.NOSCRIPT(HtmlTree.DIV(contents.noScriptMessage));
+        body.add(noScript);
         return body;
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -75,7 +75,7 @@
     private void generateIndexFile() throws DocFileIOException {
         Content htmlComment = contents.newPage;
         Head head = new Head(path, configuration.docletVersion)
-                .setTimestamp(true)
+                .setTimestamp(!configuration.notimestamp)
                 .setDescription("index redirect")
                 .setGenerator(getGenerator(getClass()))
                 .setStylesheets(configuration.getMainStylesheet(), Collections.emptyList()) // avoid reference to default stylesheet
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,191 +0,0 @@
-/*
- * 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
- * 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.javadoc.internal.doclets.formats.html;
-
-import java.util.*;
-
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.ElementFilter;
-
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
-
-/**
- * Class to generate file for each module contents in the left-hand bottom
- * frame. This will list all the Class Kinds in the module. A click on any
- * class-kind will update the right-hand frame with the clicked class-kind page.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Bhavesh Patel
- */
-public class ModuleFrameWriter extends HtmlDocletWriter {
-
-    /**
-     * The module being documented.
-     */
-    private final ModuleElement mdle;
-
-    /**
-     * The classes to be documented.  Use this to filter out classes
-     * that will not be documented.
-     */
-    private SortedSet<TypeElement> documentedClasses;
-
-    /**
-     * Constructor to construct ModuleFrameWriter object and to generate
-     * "module_name-type-frame.html" file. For example for module "java.base" this will generate file
-     * "java.base-type-frame.html" file.
-     *
-     * @param configuration the configuration of the doclet.
-     * @param moduleElement moduleElement under consideration.
-     */
-    public ModuleFrameWriter(HtmlConfiguration configuration, ModuleElement moduleElement) {
-        super(configuration, configuration.docPaths.moduleTypeFrame(moduleElement));
-        this.mdle = moduleElement;
-        if (configuration.getSpecifiedPackageElements().isEmpty()) {
-            documentedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
-            documentedClasses.addAll(configuration.getIncludedTypeElements());
-        }
-    }
-
-    /**
-     * Generate a module type summary page for the left-hand bottom frame.
-     *
-     * @param configuration the current configuration of the doclet.
-     * @param moduleElement The package for which "module_name-type-frame.html" is to be generated.
-     * @throws DocFileIOException if there is a problem generating the module summary file
-     */
-    public static void generate(HtmlConfiguration configuration, ModuleElement moduleElement)
-            throws DocFileIOException {
-        ModuleFrameWriter mdlgen = new ModuleFrameWriter(configuration, moduleElement);
-        String mdlName = moduleElement.getQualifiedName().toString();
-        Content mdlLabel = new StringContent(mdlName);
-        HtmlTree body = mdlgen.getBody(false, mdlgen.getWindowTitle(mdlName));
-        HtmlTree htmlTree = HtmlTree.MAIN();
-        DocPath moduleSummary = configuration.useModuleDirectories
-                ? DocPaths.DOT_DOT.resolve(configuration.docPaths.moduleSummary(moduleElement))
-                : configuration.docPaths.moduleSummary(moduleElement);
-        Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.bar,
-                mdlgen.links.createLink(moduleSummary, mdlLabel, "", "classFrame"));
-        htmlTree.add(heading);
-        HtmlTree div = new HtmlTree(HtmlTag.DIV);
-        div.setStyle(HtmlStyle.indexContainer);
-        mdlgen.addClassListing(div);
-        htmlTree.add(div);
-        body.add(htmlTree);
-        mdlgen.printHtmlDocument(
-                configuration.metakeywords.getMetaKeywordsForModule(moduleElement),
-                "module summary (frame)",
-                body);
-    }
-
-    /**
-     * Add class listing for all the classes in this module. Divide class
-     * listing as per the class kind and generate separate listing for
-     * Classes, Interfaces, Exceptions and Errors.
-     *
-     * @param contentTree the content tree to which the listing will be added
-     */
-    protected void addClassListing(HtmlTree contentTree) {
-        List<PackageElement> packagesIn = ElementFilter.packagesIn(mdle.getEnclosedElements());
-        SortedSet<TypeElement> interfaces = new TreeSet<>(utils.makeGeneralPurposeComparator());
-        SortedSet<TypeElement> classes = new TreeSet<>(utils.makeGeneralPurposeComparator());
-        SortedSet<TypeElement> enums = new TreeSet<>(utils.makeGeneralPurposeComparator());
-        SortedSet<TypeElement> exceptions = new TreeSet<>(utils.makeGeneralPurposeComparator());
-        SortedSet<TypeElement> errors = new TreeSet<>(utils.makeGeneralPurposeComparator());
-        SortedSet<TypeElement> annotationTypes = new TreeSet<>(utils.makeGeneralPurposeComparator());
-        for (PackageElement pkg : packagesIn) {
-            if (utils.isIncluded(pkg)) {
-                interfaces.addAll(utils.getInterfaces(pkg));
-                classes.addAll(utils.getOrdinaryClasses(pkg));
-                enums.addAll(utils.getEnums(pkg));
-                exceptions.addAll(utils.getExceptions(pkg));
-                errors.addAll(utils.getErrors(pkg));
-                annotationTypes.addAll(utils.getAnnotationTypes(pkg));
-            }
-        }
-        addClassKindListing(interfaces, contents.interfaces, contentTree);
-        addClassKindListing(classes, contents.classes, contentTree);
-        addClassKindListing(enums, contents.enums, contentTree);
-        addClassKindListing(exceptions, contents.exceptions, contentTree);
-        addClassKindListing(errors, contents.errors, contentTree);
-        addClassKindListing(annotationTypes, contents.annotationTypes, contentTree);
-    }
-
-    /**
-     * Add specific class kind listing. Also add label to the listing.
-     *
-     * @param list Iterable list of TypeElements
-     * @param labelContent content tree of the label to be added
-     * @param contentTree the content tree to which the class kind listing will be added
-     */
-    protected void addClassKindListing(Iterable<TypeElement> list, Content labelContent,
-            HtmlTree contentTree) {
-        SortedSet<TypeElement> tset = utils.filterOutPrivateClasses(list, configuration.javafx);
-        if (!tset.isEmpty()) {
-            boolean printedHeader = false;
-            HtmlTree htmlTree = HtmlTree.SECTION();
-            HtmlTree ul = new HtmlTree(HtmlTag.UL);
-            ul.setTitle(labelContent);
-            for (TypeElement typeElement : tset) {
-                if (documentedClasses != null && !documentedClasses.contains(typeElement)) {
-                    continue;
-                }
-                if (!utils.isCoreClass(typeElement) || !configuration.isGeneratedDoc(typeElement)) {
-                    continue;
-                }
-                if (!printedHeader) {
-                    Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
-                            true, labelContent);
-                    htmlTree.add(heading);
-                    printedHeader = true;
-                }
-                Content arr_i_name = new StringContent(utils.getSimpleName(typeElement));
-                if (utils.isInterface(typeElement)) {
-                    arr_i_name = HtmlTree.SPAN(HtmlStyle.interfaceName, arr_i_name);
-                }
-                Content link = getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.Kind.ALL_CLASSES_FRAME, typeElement).label(arr_i_name).target("classFrame"));
-                Content li = HtmlTree.LI(link);
-                ul.add(li);
-            }
-            htmlTree.add(ul);
-            contentTree.add(htmlTree);
-        }
-    }
-}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +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.  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.javadoc.internal.doclets.formats.html;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.PackageElement;
-
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
-import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
-
-/**
- * Generate the module index for the left-hand frame in the generated output.
- * A click on the module name in this frame will update the page in the top
- * left hand frame with the listing of packages of the clicked module.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Bhavesh Patel
- */
-public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter {
-    /**
-     * The heading (h1 or h2) to use for the module list,
-     * set by addNavigationBarHeader depending on whether or not there
-     * is an additional initial heading.
-     */
-    private HtmlTag moduleListHeading;
-
-    /**
-     * Construct the ModuleIndexFrameWriter object.
-     *
-     * @param configuration the configuration object
-     * @param filename Name of the module index file to be generated.
-     */
-    public ModuleIndexFrameWriter(HtmlConfiguration configuration,
-                                   DocPath filename) {
-        super(configuration, filename);
-    }
-
-    /**
-     * Generate the module index file named "module-overview-frame.html".
-     * @throws DocFileIOException
-     * @param configuration the configuration object
-     */
-    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
-        DocPath filename = DocPaths.MODULE_OVERVIEW_FRAME;
-        ModuleIndexFrameWriter modulegen = new ModuleIndexFrameWriter(configuration, filename);
-        modulegen.buildModuleIndexFile("doclet.Window_Overview", "module overview (frame)", false);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addModulesList(Content main) {
-        Content heading = HtmlTree.HEADING(moduleListHeading, true,
-                contents.modulesLabel);
-        HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
-        HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.setTitle(contents.modulesLabel);
-        for (ModuleElement mdle: configuration.modules) {
-            ul.add(getModuleLink(mdle));
-        }
-        htmlTree.add(ul);
-        main.add(htmlTree);
-    }
-
-    /**
-     * Returns each module name as a separate link.
-     *
-     * @param mdle the module being documented
-     * @return content for the module link
-     */
-    protected Content getModuleLink(ModuleElement mdle) {
-        Content moduleLinkContent;
-        Content mdlLabel = new StringContent(mdle.getQualifiedName());
-        moduleLinkContent = getModuleFramesHyperLink(mdle, mdlLabel, "packageListFrame");
-        Content li = HtmlTree.LI(moduleLinkContent);
-        return li;
-    }
-
-    private Content getModuleFramesHyperLink(ModuleElement mdle, Content label, String target) {
-        DocLink mdlLink = new DocLink(docPaths.moduleFrame(mdle));
-        DocLink mtFrameLink = new DocLink(docPaths.moduleTypeFrame(mdle));
-        DocLink cFrameLink = new DocLink(docPaths.moduleSummary(mdle));
-        HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label);
-        String onclickStr = "updateModuleFrame('" + mtFrameLink + "','" + cFrameLink + "');";
-        anchor.put(HtmlAttr.TARGET, target);
-        anchor.put(HtmlAttr.ONCLICK, onclickStr);
-        return anchor;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void addNavigationBarHeader(Content header) {
-        String headerContent = !configuration.packagesheader.isEmpty() ? configuration.packagesheader
-                : configuration.header;
-        if (!headerContent.isEmpty()) {
-            Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
-                    HtmlStyle.bar, new RawHtml(replaceDocRootDir(headerContent)));
-            header.add(heading);
-            moduleListHeading = Headings.IndexFrames.MODULE_HEADING;
-        } else {
-            moduleListHeading = Headings.PAGE_TITLE_HEADING;
-        }
-    }
-
-    /**
-     * Do nothing as there is no overview information in this page.
-     */
-    protected void addOverviewHeader(Content body) {
-    }
-
-    /**
-     * Adds "All Classes" link for the top of the left-hand frame page to the
-     * documentation tree.
-     *
-     * @param ul the Content object to which the all classes link should be added
-     */
-    protected void addAllClassesLink(Content ul) {
-        Content linkContent = links.createLink(DocPaths.ALLCLASSES_FRAME,
-                contents.allClassesLabel, "", "packageFrame");
-        Content li = HtmlTree.LI(linkContent);
-        ul.add(li);
-    }
-
-    /**
-     * Adds "All Packages" link for the top of the left-hand frame page to the
-     * documentation tree.
-     *
-     * @param ul the Content object to which the all packages link should be added
-     */
-    protected void addAllPackagesLink(Content ul) {
-        Content linkContent = links.createLink(DocPaths.OVERVIEW_FRAME,
-                contents.allPackagesLabel, "", "packageListFrame");
-        Content li = HtmlTree.LI(linkContent);
-        ul.add(li);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void addNavigationBarFooter(Content footer) {
-        Content p = HtmlTree.P(Contents.SPACE);
-        footer.add(p);
-    }
-
-    protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
-            String tableSummary, Content main, ModuleElement mdle) {
-    }
-}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -44,8 +44,7 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 
 /**
- * Generate the module index page "overview-summary.html" for the right-hand
- * frame.
+ * Generate the module index page "index.html".
  *
  *  <p><b>This is NOT part of any supported API.
  *  If you write code that depends on this, you do so at your own risk.
@@ -66,15 +65,15 @@
     }
 
     /**
-     * Generate the module index page for the right-hand frame.
+     * Generate the module index page.
      *
      * @param configuration the current configuration of the doclet.
      * @throws DocFileIOException if there is a problem generating the module index page
      */
     public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
-        DocPath filename = DocPaths.overviewSummary(configuration.frames);
+        DocPath filename = DocPaths.INDEX;
         ModuleIndexWriter mdlgen = new ModuleIndexWriter(configuration, filename);
-        mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", "module index", true);
+        mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", "module index");
     }
 
     /**
@@ -95,15 +94,6 @@
      * @param main the document tree to which the modules list will be added
      */
     protected void addIndexContents(Content header, Content main) {
-        HtmlTree htmltree = HtmlTree.NAV();
-        htmltree.setStyle(HtmlStyle.indexNav);
-        HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        addAllClassesLink(ul);
-        if (configuration.showModules) {
-            addAllModulesLink(ul);
-        }
-        htmltree.add(ul);
-        header.add(htmltree);
         addModulesList(main);
     }
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +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.  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.javadoc.internal.doclets.formats.html;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.PackageElement;
-
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
-import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
-
-/**
- * Generate the module package index for the left-hand frame in the generated output.
- * A click on the package name in this frame will update the page in the bottom
- * left hand frame with the listing of contents of the clicked module package.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Bhavesh Patel
- */
-public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter {
-    /**
-     * The heading (h1 or h2) to use for the module packages list,
-     * set by addNavigationBarHeader depending on whether or not there
-     * is an additional initial heading.
-     */
-    private HtmlTag modulePackagesListHeading;
-
-    /**
-     * Construct the ModulePackageIndexFrameWriter object.
-     *
-     * @param configuration the configuration object
-     * @param filename Name of the package index file to be generated.
-     */
-    public ModulePackageIndexFrameWriter(HtmlConfiguration configuration, DocPath filename)  {
-        super(configuration, filename);
-    }
-
-    /**
-     * Generate the module package index file.
-     * @throws DocFileIOException
-     * @param configuration the configuration object
-     * @param mdle the module being documented
-     */
-    public static void generate(HtmlConfiguration configuration, ModuleElement mdle) throws DocFileIOException {
-        DocPath filename = configuration.docPaths.moduleFrame(mdle);
-        ModulePackageIndexFrameWriter modpackgen = new ModulePackageIndexFrameWriter(configuration, filename);
-        modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview",
-                getDescription("module package index", mdle) + " (frame)",
-                false,
-                mdle);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
-            String tableSummary, Content main, ModuleElement mdle) {
-        Content profNameContent = new StringContent(mdle.getQualifiedName().toString());
-        Content heading = HtmlTree.HEADING(modulePackagesListHeading, true,
-                getTargetModuleLink("classFrame", profNameContent, mdle));
-        heading.add(Contents.SPACE);
-        heading.add(contents.packagesLabel);
-        HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
-        HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.setTitle(contents.packagesLabel);
-        List<PackageElement> packages = new ArrayList<>(modules.get(mdle));
-        for (PackageElement pkg : packages) {
-            if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) {
-                ul.add(getPackage(pkg, mdle));
-            }
-        }
-        htmlTree.add(ul);
-        main.add(htmlTree);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void addModulePackagesList(Set<ModuleElement> modules, String text,
-            String tableSummary, Content body, ModuleElement mdle) {
-        Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString());
-        Content heading = HtmlTree.HEADING(modulePackagesListHeading, true,
-                getTargetModuleLink("classFrame", moduleNameContent, mdle));
-        heading.add(Contents.SPACE);
-        heading.add(contents.packagesLabel);
-        HtmlTree htmlTree = HtmlTree.MAIN(HtmlStyle.indexContainer, heading);
-        HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.setTitle(contents.packagesLabel);
-        Set<PackageElement> modulePackages = configuration.modulePackages.get(mdle);
-        for (PackageElement pkg: modulePackages) {
-            if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) {
-                ul.add(getPackage(pkg, mdle));
-            }
-        }
-        htmlTree.add(ul);
-        body.add(htmlTree);
-    }
-
-    /**
-     * Returns each package name as a separate link.
-     *
-     * @param pkg PackageElement
-     * @param mdle the module being documented
-     * @return content for the package link
-     */
-    protected Content getPackage(PackageElement pkg, ModuleElement mdle) {
-        Content packageLinkContent;
-        Content pkgLabel;
-        if (!pkg.isUnnamed()) {
-            pkgLabel = getPackageLabel(utils.getPackageName(pkg));
-            packageLinkContent = links.createLink(pathString(pkg,
-                     DocPaths.PACKAGE_FRAME), pkgLabel, "",
-                    "packageFrame");
-        } else {
-            pkgLabel = new StringContent("<unnamed package>");
-            packageLinkContent = links.createLink(DocPaths.PACKAGE_FRAME,
-                    pkgLabel, "", "packageFrame");
-        }
-        Content li = HtmlTree.LI(packageLinkContent);
-        return li;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void addNavigationBarHeader(Content header) {
-        String headerContent = !configuration.packagesheader.isEmpty() ? configuration.packagesheader
-                : configuration.header;
-        if (!headerContent.isEmpty()) {
-            Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
-                    HtmlStyle.bar, new RawHtml(replaceDocRootDir(headerContent)));
-            header.add(heading);
-            modulePackagesListHeading = Headings.IndexFrames.PACKAGE_HEADING;
-        } else {
-            modulePackagesListHeading = Headings.PAGE_TITLE_HEADING;
-        }
-    }
-
-    /**
-     * Do nothing as there is no overview information in this page.
-     */
-    protected void addOverviewHeader(Content body) {
-    }
-
-    /**
-     * Do nothing as there is no modules list on this page.
-     */
-    @Override
-    protected void addModulesList(Content body) {
-    }
-
-    /**
-     * Adds "All Classes" link for the top of the left-hand frame page to the
-     * documentation tree.
-     *
-     * @param ul the Content object to which the all classes link should be added
-     */
-    protected void addAllClassesLink(Content ul) {
-        DocPath allClassesFrame = configuration.useModuleDirectories
-                ? DocPaths.DOT_DOT.resolve(DocPaths.ALLCLASSES_FRAME)
-                : DocPaths.ALLCLASSES_FRAME;
-        Content linkContent = links.createLink(allClassesFrame,
-                contents.allClassesLabel, "", "packageFrame");
-        Content li = HtmlTree.LI(linkContent);
-        ul.add(li);
-    }
-
-    /**
-     * Adds "All Packages" link for the top of the left-hand frame page to the
-     * documentation tree.
-     *
-     * @param ul the Content object to which the all packages link should be added
-     */
-    protected void addAllPackagesLink(Content ul) {
-        DocPath overviewFrame = configuration.useModuleDirectories
-                ? DocPaths.DOT_DOT.resolve(DocPaths.OVERVIEW_FRAME)
-                : DocPaths.OVERVIEW_FRAME;
-        Content linkContent = links.createLink(overviewFrame,
-                contents.allPackagesLabel, "", "packageListFrame");
-        Content li = HtmlTree.LI(linkContent);
-        ul.add(li);
-    }
-
-    /**
-     * Adds "All Modules" link for the top of the left-hand frame page to the
-     * documentation tree.
-     *
-     * @param ul the Content object to which the all modules link should be added
-     */
-    protected void addAllModulesLink(Content ul) {
-        DocPath moduleOverviewFrame = configuration.useModuleDirectories
-                ? DocPaths.DOT_DOT.resolve(DocPaths.MODULE_OVERVIEW_FRAME)
-                : DocPaths.MODULE_OVERVIEW_FRAME;
-        Content linkContent = links.createLink(moduleOverviewFrame,
-                contents.allModulesLabel, "", "packageListFrame");
-        Content li = HtmlTree.LI(linkContent);
-        ul.add(li);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    protected void addNavigationBarFooter(Content footer) {
-        Content p = HtmlTree.P(Contents.SPACE);
-        footer.add(p);
-    }
-}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -194,7 +194,7 @@
      */
     @Override
     public Content getModuleHeader(String heading) {
-        HtmlTree bodyTree = getBody(true, getWindowTitle(mdle.getQualifiedName().toString()));
+        HtmlTree bodyTree = getBody(getWindowTitle(mdle.getQualifiedName().toString()));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         navBar.setDisplaySummaryModuleDescLink(!utils.getFullBody(mdle).isEmpty() && !configuration.nocomment);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-/*
- * 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
- * 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.javadoc.internal.doclets.formats.html;
-
-import java.util.*;
-
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
-import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
-
-/**
- * Class to generate file for each package contents in the left-hand bottom
- * frame. This will list all the Class Kinds in the package. A click on any
- * class-kind will update the right-hand frame with the clicked class-kind page.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Atul M Dambalkar
- * @author Bhavesh Patel (Modified)
- */
-public class PackageFrameWriter extends HtmlDocletWriter {
-
-    /**
-     * The package being documented.
-     */
-    private final PackageElement packageElement;
-
-    /**
-     * The classes to be documented.  Use this to filter out classes
-     * that will not be documented.
-     */
-    private SortedSet<TypeElement> documentedClasses;
-
-    /**
-     * Constructor to construct PackageFrameWriter object and to generate
-     * "package-frame.html" file in the respective package directory.
-     * For example for package "java.lang" this will generate file
-     * "package-frame.html" file in the "java/lang" directory. It will also
-     * create "java/lang" directory in the current or the destination directory
-     * if it doesn't exist.
-     *
-     * @param configuration the configuration of the doclet.
-     * @param packageElement PackageElement under consideration.
-     */
-    public PackageFrameWriter(HtmlConfiguration configuration, PackageElement packageElement) {
-        super(configuration,
-                configuration.docPaths.forPackage(packageElement).resolve(DocPaths.PACKAGE_FRAME));
-        this.packageElement = packageElement;
-        if (configuration.getSpecifiedPackageElements().isEmpty()) {
-            documentedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
-            documentedClasses.addAll(configuration.getIncludedTypeElements());
-        }
-    }
-
-    /**
-     * Generate a package summary page for the left-hand bottom frame. Construct
-     * the PackageFrameWriter object and then use it generate the file.
-     *
-     * @param configuration the current configuration of the doclet.
-     * @param packageElement The package for which "pacakge-frame.html" is to be generated.
-     * @throws DocFileIOException if there is a problem generating the package summary page
-     */
-    public static void generate(HtmlConfiguration configuration, PackageElement packageElement)
-            throws DocFileIOException {
-        PackageFrameWriter packgen = new PackageFrameWriter(configuration, packageElement);
-        String pkgName = configuration.utils.getPackageName(packageElement);
-        HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
-        Content pkgNameContent = new StringContent(pkgName);
-        HtmlTree htmlTree = HtmlTree.MAIN();
-        Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, HtmlStyle.bar,
-                packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent));
-        htmlTree.add(heading);
-        HtmlTree div = new HtmlTree(HtmlTag.DIV);
-        div.setStyle(HtmlStyle.indexContainer);
-        packgen.addClassListing(div);
-        htmlTree.add(div);
-        body.add(htmlTree);
-        packgen.printHtmlDocument(
-                configuration.metakeywords.getMetaKeywords(packageElement),
-                getDescription("package summary (frame)", packageElement),
-                body);
-    }
-
-    /**
-     * Add class listing for all the classes in this package. Divide class
-     * listing as per the class kind and generate separate listing for
-     * Classes, Interfaces, Exceptions and Errors.
-     *
-     * @param contentTree the content tree to which the listing will be added
-     */
-    protected void addClassListing(HtmlTree contentTree) {
-        BaseConfiguration config = configuration;
-        if (utils.isSpecified(packageElement)) {
-            addClassKindListing(utils.getInterfaces(packageElement),
-                contents.interfaces, contentTree);
-            addClassKindListing(utils.getOrdinaryClasses(packageElement),
-                contents.classes, contentTree);
-            addClassKindListing(utils.getEnums(packageElement),
-                contents.enums, contentTree);
-            addClassKindListing(utils.getExceptions(packageElement),
-                contents.exceptions, contentTree);
-            addClassKindListing(utils.getErrors(packageElement),
-                contents.errors, contentTree);
-            addClassKindListing(utils.getAnnotationTypes(packageElement),
-                contents.annotationTypes, contentTree);
-        } else {
-            addClassKindListing(config.typeElementCatalog.interfaces(packageElement),
-                contents.interfaces, contentTree);
-            addClassKindListing(config.typeElementCatalog.ordinaryClasses(packageElement),
-                contents.classes, contentTree);
-            addClassKindListing(config.typeElementCatalog.enums(packageElement),
-                contents.enums, contentTree);
-            addClassKindListing(config.typeElementCatalog.exceptions(packageElement),
-                contents.exceptions, contentTree);
-            addClassKindListing(config.typeElementCatalog.errors(packageElement),
-                contents.errors, contentTree);
-            addClassKindListing(config.typeElementCatalog.annotationTypes(packageElement),
-                contents.annotationTypes, contentTree);
-        }
-    }
-
-    /**
-     * Add specific class kind listing. Also add label to the listing.
-     *
-     * @param list list of specific class kinds, namely Class or Interface or Exception or Error
-     * @param labelContent content tree of the label to be added
-     * @param contentTree the content tree to which the class kind listing will be added
-     */
-    protected void addClassKindListing(Iterable<TypeElement> list, Content labelContent,
-            HtmlTree contentTree) {
-        SortedSet<TypeElement> tset = utils.filterOutPrivateClasses(list, configuration.javafx);
-        if(!tset.isEmpty()) {
-            boolean printedHeader = false;
-            HtmlTree htmlTree = HtmlTree.SECTION();
-            HtmlTree ul = new HtmlTree(HtmlTag.UL);
-            ul.setTitle(labelContent);
-            for (TypeElement typeElement : tset) {
-                if (documentedClasses != null && !documentedClasses.contains(typeElement)) {
-                    continue;
-                }
-                if (!utils.isCoreClass(typeElement) || !configuration.isGeneratedDoc(typeElement)) {
-                    continue;
-                }
-                if (!printedHeader) {
-                    Content heading = HtmlTree.HEADING(Headings.CONTENT_HEADING,
-                                                       true, labelContent);
-                    htmlTree.add(heading);
-                    printedHeader = true;
-                }
-                Content arr_i_name = new StringContent(utils.getSimpleName(typeElement));
-                if (utils.isInterface(typeElement))
-                    arr_i_name = HtmlTree.SPAN(HtmlStyle.interfaceName, arr_i_name);
-                Content link = getLink(new LinkInfoImpl(configuration,
-                                                        LinkInfoImpl.Kind.PACKAGE_FRAME, typeElement).label(arr_i_name).target("classFrame"));
-                Content li = HtmlTree.LI(link);
-                ul.add(li);
-            }
-            htmlTree.add(ul);
-            contentTree.add(htmlTree);
-        }
-    }
-}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,191 +0,0 @@
-/*
- * 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
- * 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.javadoc.internal.doclets.formats.html;
-
-import javax.lang.model.element.PackageElement;
-
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
-import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
-
-
-/**
- * Generate the package index for the left-hand frame in the generated output.
- * A click on the package name in this frame will update the page in the bottom
- * left hand frame with the listing of contents of the clicked package.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Atul M Dambalkar
- */
-public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
-    /**
-     * The heading (h1 or h2) to use for the module list,
-     * set by addNavigationBarHeader depending on whether or not there
-     * is an additional initial heading.
-     */
-    private HtmlTag packageListHeading;
-
-    /**
-     * Construct the PackageIndexFrameWriter object.
-     *
-     * @param filename Name of the package index file to be generated.
-     */
-    public PackageIndexFrameWriter(HtmlConfiguration configuration, DocPath filename) {
-        super(configuration, filename);
-    }
-
-    /**
-     * Generate the package index file named "overview-frame.html".
-     * @throws DocFileIOException
-     */
-    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
-        DocPath filename = DocPaths.OVERVIEW_FRAME;
-        PackageIndexFrameWriter packgen = new PackageIndexFrameWriter(configuration, filename);
-        packgen.buildPackageIndexFile("doclet.Window_Overview",
-                "package index (frame)",
-                false);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addPackagesList(Content main) {
-        Content heading = HtmlTree.HEADING(packageListHeading, true,
-                contents.packagesLabel);
-        HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
-        HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.setTitle(contents.packagesLabel);
-        for (PackageElement aPackage : packages) {
-            // Do not list the package if -nodeprecated option is set and the
-            // package is marked as deprecated.
-            if (aPackage != null &&
-                (!(configuration.nodeprecated && utils.isDeprecated(aPackage)))) {
-                ul.add(getPackage(aPackage));
-            }
-        }
-        htmlTree.add(ul);
-        main.add(htmlTree);
-    }
-
-    /**
-     * Returns each package name as a separate link.
-     *
-     * @param pe PackageElement
-     * @return content for the package link
-     */
-    protected Content getPackage(PackageElement pe) {
-        Content packageLinkContent;
-        Content packageLabel;
-        if (pe.isUnnamed()) {
-            packageLabel = new StringContent("<unnamed package>");
-            packageLinkContent = links.createLink(DocPaths.PACKAGE_FRAME,
-                    packageLabel, "", "packageFrame");
-        } else {
-            packageLabel = getPackageLabel(pe.getQualifiedName());
-            packageLinkContent = links.createLink(pathString(pe,
-                     DocPaths.PACKAGE_FRAME), packageLabel, "",
-                    "packageFrame");
-        }
-        Content li = HtmlTree.LI(packageLinkContent);
-        return li;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addNavigationBarHeader(Content header) {
-        Content headerContent;
-        if (configuration.packagesheader.length() > 0) {
-            headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
-        } else {
-            headerContent = new RawHtml(replaceDocRootDir(configuration.header));
-        }
-        if (!headerContent.isEmpty()) {
-            Content heading = HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, true,
-                    HtmlStyle.bar, headerContent);
-            header.add(heading);
-            packageListHeading = Headings.IndexFrames.PACKAGE_HEADING;
-        } else {
-            packageListHeading = Headings.PAGE_TITLE_HEADING;
-        }
-    }
-
-    /**
-     * Do nothing as there is no overview information in this page.
-     */
-    @Override
-    protected void addOverviewHeader(Content body) {
-    }
-
-    /**
-     * Adds "All Classes" link for the top of the left-hand frame page to the
-     * documentation tree.
-     *
-     * @param ul the Content object to which the "All Classes" link should be added
-     */
-    @Override
-    protected void addAllClassesLink(Content ul) {
-        Content linkContent = links.createLink(DocPaths.ALLCLASSES_FRAME,
-                contents.allClassesLabel, "", "packageFrame");
-        Content li = HtmlTree.LI(linkContent);
-        ul.add(li);
-    }
-
-    /**
-     * Adds "All Modules" link for the top of the left-hand frame page to the
-     * documentation tree.
-     *
-     * @param ul the Content object to which the "All Modules" link should be added
-     */
-    @Override
-    protected void addAllModulesLink(Content ul) {
-        Content linkContent = links.createLink(DocPaths.MODULE_OVERVIEW_FRAME,
-                contents.allModulesLabel, "", "packageListFrame");
-        Content li = HtmlTree.LI(linkContent);
-        ul.add(li);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected void addNavigationBarFooter(Content footer) {
-        Content p = HtmlTree.P(Contents.SPACE);
-        footer.add(p);
-    }
-}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -42,9 +42,7 @@
 import jdk.javadoc.internal.doclets.toolkit.util.Group;
 
 /**
- * Generate the package index page "overview-summary.html" for the right-hand
- * frame. A click on the package name on this page will update the same frame
- * with the "package-summary.html" file for the clicked package.
+ * Generate the package index page "index.html".
  *
  *  <p><b>This is NOT part of any supported API.
  *  If you write code that depends on this, you do so at your own risk.
@@ -70,15 +68,15 @@
     }
 
     /**
-     * Generate the package index page for the right-hand frame.
+     * Generate the package index page.
      *
      * @param configuration the current configuration of the doclet.
      * @throws DocFileIOException if there is a problem generating the package index page
      */
     public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
-        DocPath filename = DocPaths.overviewSummary(configuration.frames);
+        DocPath filename = DocPaths.INDEX;
         PackageIndexWriter packgen = new PackageIndexWriter(configuration, filename);
-        packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", "package index", true);
+        packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", "package index");
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -131,7 +131,7 @@
     protected HtmlTree getPackageTreeHeader() {
         String packageName = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
         String title = packageName + " " + resources.getText("doclet.Window_Class_Hierarchy");
-        HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+        HtmlTree bodyTree = getBody(getWindowTitle(title));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -237,7 +237,7 @@
         String packageText = resources.getText("doclet.Package");
         String name = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
         String title = resources.getText("doclet.Window_ClassUse_Header", packageText, name);
-        HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+        HtmlTree bodyTree = getBody(getWindowTitle(title));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -105,7 +105,7 @@
      */
     @Override
     public Content getPackageHeader(String heading) {
-        HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getPackageName(packageElement)));
+        HtmlTree bodyTree = getBody(getWindowTitle(utils.getPackageName(packageElement)));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Tue Apr 09 11:48:54 2019 +0100
@@ -78,7 +78,7 @@
      * @return the body content tree
      */
     public Content getHeader(String header) {
-        HtmlTree bodyTree = getBody(true, getWindowTitle(header));
+        HtmlTree bodyTree = getBody(getWindowTitle(header));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         navBar.setUserHeader(getUserHeaderFooter(true));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -92,7 +92,7 @@
      */
     protected void generateIndexFile() throws DocFileIOException {
         String title = resources.getText("doclet.Window_Single_Index");
-        HtmlTree body = getBody(true, getWindowTitle(title));
+        HtmlTree body = getBody(getWindowTitle(title));
         HtmlTree header = HtmlTree.HEADER();
         addTop(header);
         navBar.setUserHeader(getUserHeaderFooter(true));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -120,7 +120,7 @@
     protected void generateIndexFile(Character unicode) throws DocFileIOException {
         String title = resources.getText("doclet.Window_Split_Index",
                 unicode.toString());
-        HtmlTree body = getBody(true, getWindowTitle(title));
+        HtmlTree body = getBody(getWindowTitle(title));
         HtmlTree header = HtmlTree.HEADER();
         addTop(header);
         navBar.setUserHeader(getUserHeaderFooter(true));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -175,7 +175,7 @@
      */
     protected HtmlTree getTreeHeader() {
         String title = resources.getText("doclet.Window_Class_Hierarchy");
-        HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+        HtmlTree bodyTree = getBody(getWindowTitle(title));
         HtmlTree htmlTree = HtmlTree.HEADER();
         addTop(htmlTree);
         navBar.setUserHeader(getUserHeaderFooter(true));
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java	Tue Apr 09 11:48:54 2019 +0100
@@ -722,9 +722,7 @@
      * @return an HtmlTree object for the SECTION tag
      */
     public static HtmlTree SECTION() {
-        HtmlTree htmltree = new HtmlTree(HtmlTag.SECTION);
-        htmltree.setRole(Role.REGION);
-        return htmltree;
+        return new HtmlTree(HtmlTag.SECTION);
     }
 
     /**
@@ -734,9 +732,7 @@
      * @return an HtmlTree object for the SECTION tag
      */
     public static HtmlTree SECTION(Content body) {
-        HtmlTree htmltree = new HtmlTree(HtmlTag.SECTION, nullCheck(body));
-        htmltree.setRole(Role.REGION);
-        return htmltree;
+        return new HtmlTree(HtmlTag.SECTION, nullCheck(body));
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java	Tue Apr 09 11:48:54 2019 +0100
@@ -824,7 +824,7 @@
 
     private void addOverviewLink(Content tree) {
         if (configuration.createoverview) {
-            tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.overviewSummary(configuration.frames)),
+            tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.INDEX),
                     contents.overviewLabel, "", "")));
         }
     }
@@ -930,27 +930,6 @@
         }
     }
 
-    /**
-     * Add "FRAMES" link, to switch to the frame version of the output.
-     *
-     * @param tree the content tree to which the link will be added
-     */
-    private void addNavShowLists(Content tree) {
-        DocLink dl = new DocLink(pathToRoot.resolve(DocPaths.INDEX), path.getPath(), null);
-        Content framesContent = links.createLink(dl, contents.framesLabel, "", "_top");
-        tree.add(HtmlTree.LI(framesContent));
-    }
-
-    /**
-     * Add "NO FRAMES" link, to switch to the non-frame version of the output.
-     *
-     * @param tree the content tree to which the link will be added
-     */
-    private void addNavHideLists(Content tree) {
-        Content noFramesContent = links.createLink(path.basename(), contents.noFramesLabel, "", "_top");
-        tree.add(HtmlTree.LI(noFramesContent));
-    }
-
     private void addSearch(Content tree) {
         String searchValueId = "search";
         String reset = "reset";
@@ -1018,15 +997,6 @@
             ulNavDetail.setStyle(HtmlStyle.subNavList);
             addDetailLinks(ulNavDetail);
             div.add(ulNavDetail);
-            HtmlTree ulFrames = new HtmlTree(HtmlTag.UL);
-            ulFrames.setStyle(HtmlStyle.navList);
-            if (!configuration.nonavbar) {
-                if (configuration.frames) {
-                    addNavShowLists(ulFrames);
-                    addNavHideLists(ulFrames);
-                }
-            }
-            div.add(ulFrames);
             subDiv.add(div);
             if (top && configuration.createindex) {
                 addSearch(subDiv);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Tue Apr 09 11:48:54 2019 +0100
@@ -77,7 +77,7 @@
             $(this).val(watermark).addClass('watermark');
         }
     });
-    $("#search").on('click keydown', function() {
+    $("#search").on('click keydown paste', function() {
         if ($(this).val() == watermark) {
             $(this).val('').removeClass('watermark');
         }
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Tue Apr 09 11:48:54 2019 +0100
@@ -1,7 +1,6 @@
 doclet.build_version=Standard Doclet version {0}
 doclet.Contents=Contents
 doclet.Overview=Overview
-doclet.Window_Overview=Overview List
 doclet.Window_Overview_Summary=Overview
 doclet.Element=Element
 doclet.Package=Package
@@ -167,10 +166,6 @@
 doclet.help.index.body=\
     The {0} contains an alphabetic index of all classes, interfaces, constructors, methods, \
     and fields, as well as lists of all packages and all classes.
-doclet.help.frames.head=\
-    Frames/No Frames
-doclet.help.frames.body=\
-    These links show and hide the HTML frames.  All pages are available with or without frames.
 doclet.help.serial_form.body=\
     Each serializable or externalizable class has a description of its serialization fields and \
     methods. This information is of interest to re-implementors, not to developers using the API. \
@@ -446,9 +441,7 @@
     of the given package. Prefix the package specifier with - to\n\
     disable checks for the specified packages.
 
-# L10N: do not localize the option names --frames
-doclet.Frames_specified=\
-    You have specified to generate frames, by using the --frames option.\n\
-    The default is currently to not generate frames and the support for \n\
-    frames will be removed in a future release.\n\
-    To suppress this warning, remove the --frames option and avoid the use of frames.
+# L10N: do not localize the option names --no-frames
+doclet.NoFrames_specified=\
+    The --no-frames option is no longer required and may be removed\n\
+    in a future release.
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties	Tue Apr 09 11:48:54 2019 +0100
@@ -124,8 +124,6 @@
 doclet.All_Classes=All Classes
 doclet.All_Superinterfaces=All Superinterfaces:
 doclet.All_Implemented_Interfaces=All Implemented Interfaces:
-doclet.All_classes_and_interfaces=All classes and interfaces (except non-static nested types)
-doclet.Package_class_and_interface_descriptions=Package, class and interface descriptions
 doclet.Interface=Interface
 doclet.Class=Class
 doclet.AnnotationType=Annotation Type
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/script.js	Tue Apr 09 11:48:54 2019 +0100
@@ -150,10 +150,6 @@
     }
 }
 
-function updateModuleFrame(pFrame, cFrame) {
-    top.packageFrame.location = pFrame;
-    top.classFrame.location = cFrame;
-}
 function switchTab(e) {
     if (e.keyCode == 37 || e.keyCode == 38) {
         $("[aria-selected=true]").prev().click().focus();
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/stylesheet.css	Tue Apr 09 11:48:54 2019 +0100
@@ -59,7 +59,6 @@
 }
 h3 {
     font-size:16px;
-    font-style:italic;
 }
 h4 {
     font-size:13px;
@@ -296,32 +295,21 @@
 /*
  * Styles for headings.
  */
-div.details ul.blockList ul.blockList ul.blockList li.blockList h3,
-div.details ul.blockList ul.blockList ul.blockListLast li.blockList h3,
-div.serializedFormContainer ul.blockList ul.blockList ul.blockList li.blockList h4 {
+body.class-declaration .summary h2,
+body.class-declaration .details h2,
+body.class-use h2,
+body.module-declaration .blockList h2 {
+    font-style: italic;
+    padding:0;
+    margin:15px 0;
+}
+body.class-declaration .summary h3,
+body.class-declaration .details h3 {
     background-color:#dee3e9;
     border:1px solid #d0d9e0;
     margin:0 0 6px -8px;
     padding:7px 5px;
 }
-div.details h2,
-div.summary h2 {
-    font-style: italic;
-}
-div.details h3,
-div.summary h3 {
-    font-style: normal;
-}
-ul.blockList ul.blockList ul.blockList li.blockList h2 {
-    background-color:#dee3e9;
-    border:1px solid #d0d9e0;
-    margin:0 0 6px -8px;
-    padding:7px 5px;
-}
-ul.blockList ul.blockList li.blockList h2 {
-    padding:0;
-    margin:15px 0;
-}
 /*
  * Styles for page layout containers.
  */
@@ -604,10 +592,6 @@
 .docSummary {
     padding:0;
 }
-ul.blockList ul.blockList ul.blockList li.blockList h3,
-ul.blockList ul.blockList ul.blockListLast li.blockList h3 {
-    font-style:normal;
-}
 div.block {
     font-size:14px;
     font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif;
@@ -659,9 +643,6 @@
 div.block div.block span.interfaceName {
     font-style:normal;
 }
-div.contentContainer ul.blockList li.blockList h2 {
-    padding-bottom:0px;
-}
 /*
  * Styles for IFRAME.
  */
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Tue Apr 09 11:48:54 2019 +0100
@@ -51,25 +51,12 @@
 
     public static final DocPath DOT_DOT = DocPath.create("..");
 
-    /** The name of the file for all classes, without using frames, when --no-frames is specified. */
-    public static final DocPath ALLCLASSES = DocPath.create("allclasses.html");
-
-    /** The name of the file for all classes, using frames. */
-    public static final DocPath ALLCLASSES_FRAME = DocPath.create("allclasses-frame.html");
-
     /** The name of the file for all classes index. */
     public static final DocPath ALLCLASSES_INDEX = DocPath.create("allclasses-index.html");
 
     /** The name of the file for all packages index. */
     public static final DocPath ALLPACKAGES_INDEX = DocPath.create("allpackages-index.html");
 
-    /** The name of the file for all classes, without using frames. */
-    public static final DocPath ALLCLASSES_NOFRAME = DocPath.create("allclasses-noframe.html");
-
-    public static DocPath AllClasses(boolean frames) {
-        return frames ? ALLCLASSES_NOFRAME : ALLCLASSES;
-    }
-
     /** The name of the sub-directory for storing class usage info. */
     public static final DocPath CLASS_USE = DocPath.create("class-use");
 
@@ -163,22 +150,12 @@
     /** The name of the module search index js file. */
     public static final DocPath MODULE_SEARCH_INDEX_JS = DocPath.create("module-search-index.js");
 
-    /** The name of the file for the overview frame. */
-    public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html");
-
     /** The name of the file for the overview summary. */
     public static final DocPath OVERVIEW_SUMMARY = DocPath.create("overview-summary.html");
 
-    public static DocPath overviewSummary(boolean frames) {
-        return frames ? OVERVIEW_SUMMARY : INDEX;
-    }
-
     /** The name of the file for the overview tree. */
     public static final DocPath OVERVIEW_TREE = DocPath.create("overview-tree.html");
 
-    /** The name of the file for the package frame. */
-    public static final DocPath PACKAGE_FRAME = DocPath.create("package-frame.html");
-
     /** The name of the file for the package list. This is to support the legacy mode. */
     public static final DocPath PACKAGE_LIST = DocPath.create("package-list");
 
@@ -306,15 +283,6 @@
     }
 
     /**
-     * The path for the file for a module's frame page.
-     * @param mdle the module
-     * @return the path
-     */
-    public DocPath moduleFrame(ModuleElement mdle) {
-        return createModulePath(mdle, "frame.html");
-    }
-
-    /**
      * The path for the file for a module's summary page.
      * @param mdle the module
      * @return the path
@@ -332,15 +300,6 @@
         return createModulePath(mdleName, "summary.html");
     }
 
-    /**
-     * The path for the file for a module's type frame page.
-     * @param mdle the module
-     * @return the path
-     */
-    public DocPath moduleTypeFrame(ModuleElement mdle) {
-        return createModulePath(mdle, "type-frame.html");
-    }
-
     private DocPath createModulePath(ModuleElement mdle, String path) {
         return DocPath.create(mdle.getQualifiedName() + moduleSeparator + path);
     }
@@ -349,9 +308,6 @@
         return DocPath.create(moduleName + moduleSeparator + path);
     }
 
-    /** The name of the file for the module overview frame. */
-    public static final DocPath MODULE_OVERVIEW_FRAME = DocPath.create("module-overview-frame.html");
-
     /** The name of the sub-package from which resources are read. */
     public static final DocPath RESOURCES = DocPath.create("resources");
 
--- a/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.jcmd/linux/classes/sun/tools/ProcessHelper.java	Tue Apr 09 11:48:54 2019 +0100
@@ -31,7 +31,6 @@
 import java.nio.file.Paths;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
-import java.util.jar.Manifest;
 import java.util.stream.Stream;
 
 /**
@@ -50,9 +49,12 @@
 
     /**
      * Gets the main class name for the given Java process by parsing the
-     * process command line.
+     * process command line. If the application was started with the <em>-jar</em>
+     * option this method returns the name of the jar file. If the application
+     * was started with <em>-m</em> or <em>--module</em> option, the method returns
+     * the module name and the main class name.
      * @param pid - process ID (pid)
-     * @return main class name or null if the process no longer exists or
+     * @return the main class name or null if the process no longer exists or
      * was started with a native launcher (e.g. jcmd etc)
      */
 
@@ -81,20 +83,16 @@
             }
         }
 
-        // If -jar option is used then read the main class name from the manifest file.
-        // Otherwise, the main class name is either specified in -m or --module options or it
-        // is the first part that is not a Java option (doesn't start with '-' and is not a
-        // classpath or a module path).
+        // To be consistent with the behavior on other platforms, if -jar, -m, or --module
+        // options are used then just return the value (the path to the jar file or module
+        // name with a main class). Otherwise, the main class name is the first part that
+        // is not a Java option (doesn't start with '-' and is not a classpath or a module
+        // path).
 
         for (int i = 1; i < parts.length && mainClass == null; i++) {
             if (i < parts.length - 1) {
-                // Check if the module is executed with explicitly specified main class
-                if ((parts[i].equals("-m") || parts[i].equals("--module"))) {
-                    return getMainClassFromModuleArg(parts[i + 1]);
-                }
-                // Check if the main class needs to be read from the manifest.mf in a JAR file
-                if (parts[i].equals("-jar")) {
-                    return getMainClassFromJar(parts[i + 1], pid);
+                if (parts[i].equals("-m") || parts[i].equals("--module") || parts[i].equals("-jar")) {
+                    return parts[i + 1];
                 }
             }
             // If this is a classpath or a module path option then skip the next part
@@ -114,34 +112,6 @@
 
     }
 
-    private String getMainClassFromModuleArg(String moduleArg) {
-        int pos = moduleArg.lastIndexOf("/");
-        return (pos > 0 && pos < moduleArg.length()-1) ? moduleArg.substring(pos + 1) : null;
-    }
-
-    private String getMainClassFromJar(String jar, String pid) {
-        if (!jar.startsWith("/")) {
-            String cwd = getCurrentWorkingDir(pid);
-            if (cwd != null) {
-                jar = cwd + "/" + jar;
-            }
-        }
-        try (JarFile jarFile = new JarFile(jar)) {
-            Manifest mf = jarFile.getManifest();
-            if (mf != null) {
-                Attributes mainAttributes = mf.getMainAttributes();
-                return mainAttributes.getValue("Main-Class");
-            }
-        } catch (IOException e) {
-            return null;
-        }
-        return null;
-    }
-
-    private static String getCurrentWorkingDir(String pid) {
-        return ("/proc/" + pid + "/cwd");
-    }
-
     private static String getCommandLine(String pid) {
         try (Stream<String> lines =
                      Files.lines(Paths.get("/proc/" + pid + "/cmdline"))) {
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ja.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_ja.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -91,7 +91,7 @@
             "\u5927\u6b63", // Taisho
             "\u662d\u548c", // Showa
             "\u5e73\u6210", // Heisei
-            "\u5143\u53f7", // NewEra
+            "\u4ee4\u548c", // Reiwa
         };
         final String[] rocEras = {
             "\u6c11\u56fd\u524d",
--- a/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ja.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/src/jdk.localedata/share/classes/sun/text/resources/ext/JavaTimeSupplementary_ja.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -154,7 +154,7 @@
             "\u5927\u6b63",
             "\u662d\u548c",
             "\u5e73\u6210",
-            "\u5143\u53f7", // NewEra
+            "\u4ee4\u548c",
         };
 
         final String[] sharedJavaTimeShortEras = {
--- a/test/hotspot/gtest/gc/z/test_zForwarding.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/gtest/gc/z/test_zForwarding.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -70,10 +70,8 @@
     for (uint32_t i = 0; i < entries_to_check; i++) {
       uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
 
-      EXPECT_TRUE(forwarding->find(from_index).is_empty()) << CAPTURE2(from_index, size);
+      EXPECT_FALSE(forwarding->find(from_index).populated()) << CAPTURE2(from_index, size);
     }
-
-    EXPECT_TRUE(forwarding->find(uintptr_t(-1)).is_empty()) << CAPTURE(size);
   }
 
   static void find_full(ZForwarding* forwarding) {
@@ -86,7 +84,7 @@
 
       ZForwardingCursor cursor;
       ZForwardingEntry entry = forwarding->find(from_index, &cursor);
-      ASSERT_TRUE(entry.is_empty()) << CAPTURE2(from_index, size);
+      ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size);
 
       forwarding->insert(from_index, from_index, &cursor);
     }
@@ -96,7 +94,7 @@
       uintptr_t from_index = SequenceToFromIndex::one_to_one(i);
 
       ZForwardingEntry entry = forwarding->find(from_index);
-      ASSERT_FALSE(entry.is_empty()) << CAPTURE2(from_index, size);
+      ASSERT_TRUE(entry.populated()) << CAPTURE2(from_index, size);
 
       ASSERT_EQ(entry.from_index(), from_index) << CAPTURE(size);
       ASSERT_EQ(entry.to_offset(), from_index) << CAPTURE(size);
@@ -113,7 +111,7 @@
 
       ZForwardingCursor cursor;
       ZForwardingEntry entry = forwarding->find(from_index, &cursor);
-      ASSERT_TRUE(entry.is_empty()) << CAPTURE2(from_index, size);
+      ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size);
 
       forwarding->insert(from_index, from_index, &cursor);
     }
@@ -124,7 +122,7 @@
 
       ZForwardingCursor cursor;
       ZForwardingEntry entry = forwarding->find(from_index, &cursor);
-      ASSERT_FALSE(entry.is_empty()) << CAPTURE2(from_index, size);
+      ASSERT_TRUE(entry.populated()) << CAPTURE2(from_index, size);
 
       ASSERT_EQ(entry.from_index(), from_index) << CAPTURE(size);
       ASSERT_EQ(entry.to_offset(), from_index) << CAPTURE(size);
@@ -139,7 +137,7 @@
 
       ZForwardingEntry entry = forwarding->find(from_index);
 
-      ASSERT_TRUE(entry.is_empty()) << CAPTURE2(from_index, size);
+      ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size);
     }
   }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/gtest/memory/test_is_metaspace_obj.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2016, 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
+ * 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 "memory/allocation.inline.hpp"
+#include "memory/metaspace.hpp"
+#include "memory/metaspace/virtualSpaceList.hpp"
+#include "runtime/mutex.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/os.hpp"
+#include "unittest.hpp"
+
+using namespace metaspace;
+
+
+// Test the cheerful multitude of metaspace-contains-functions.
+class MetaspaceIsMetaspaceObjTest : public ::testing::Test {
+  Mutex* _lock;
+  ClassLoaderMetaspace* _ms;
+
+public:
+
+  MetaspaceIsMetaspaceObjTest() : _lock(NULL), _ms(NULL) {}
+
+  virtual void SetUp() {
+  }
+
+  virtual void TearDown() {
+    delete _ms;
+    delete _lock;
+  }
+
+  void do_test(Metaspace::MetadataType mdType) {
+    _lock = new Mutex(Monitor::native, "gtest-IsMetaspaceObjTest-lock", false, Monitor::_safepoint_check_never);
+    {
+      MutexLockerEx ml(_lock, Mutex::_no_safepoint_check_flag);
+      _ms = new ClassLoaderMetaspace(_lock, Metaspace::StandardMetaspaceType);
+    }
+
+    const MetaspaceObj* p = (MetaspaceObj*) _ms->allocate(42, mdType);
+
+    // Test MetaspaceObj::is_metaspace_object
+    ASSERT_TRUE(MetaspaceObj::is_valid(p));
+
+    // A misaligned object shall not be recognized
+    const MetaspaceObj* p_misaligned = (MetaspaceObj*)((address)p) + 1;
+    ASSERT_FALSE(MetaspaceObj::is_valid(p_misaligned));
+
+    // Test VirtualSpaceList::contains and find_enclosing_space
+    VirtualSpaceList* list = Metaspace::space_list();
+    if (mdType == Metaspace::ClassType && Metaspace::using_class_space()) {
+      list = Metaspace::class_space_list();
+    }
+    ASSERT_TRUE(list->contains(p));
+    VirtualSpaceNode* const n = list->find_enclosing_space(p);
+    ASSERT_TRUE(n != NULL);
+    ASSERT_TRUE(n->contains(p));
+
+    // A misaligned pointer shall be recognized by list::contains
+    ASSERT_TRUE(list->contains((address)p) + 1);
+
+    // Now for some bogus values
+    ASSERT_FALSE(MetaspaceObj::is_valid((MetaspaceObj*)NULL));
+
+    // Should exercise various paths in MetaspaceObj::is_valid()
+    ASSERT_FALSE(MetaspaceObj::is_valid((MetaspaceObj*)1024));
+    ASSERT_FALSE(MetaspaceObj::is_valid((MetaspaceObj*)8192));
+
+    MetaspaceObj* p_stack = (MetaspaceObj*) &_lock;
+    ASSERT_FALSE(MetaspaceObj::is_valid(p_stack));
+
+    MetaspaceObj* p_heap = (MetaspaceObj*) os::malloc(41, mtInternal);
+    ASSERT_FALSE(MetaspaceObj::is_valid(p_heap));
+    os::free(p_heap);
+
+    // Test Metaspace::contains_xxx
+    ASSERT_TRUE(Metaspace::contains(p));
+    ASSERT_TRUE(Metaspace::contains_non_shared(p));
+
+    delete _ms;
+    _ms = NULL;
+    delete _lock;
+    _lock = NULL;
+  }
+
+};
+
+TEST_VM_F(MetaspaceIsMetaspaceObjTest, non_class_space) {
+  do_test(Metaspace::NonClassType);
+}
+
+TEST_VM_F(MetaspaceIsMetaspaceObjTest, class_space) {
+  do_test(Metaspace::ClassType);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/gtest/runtime/test_threads.cpp	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,178 @@
+/*
+ * 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 "memory/allocation.hpp"
+#include "runtime/interfaceSupport.inline.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/thread.hpp"
+#include "runtime/vmOperations.hpp"
+#include "runtime/vmThread.hpp"
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/ostream.hpp"
+#include "unittest.hpp"
+
+struct Threads::Test : public AllStatic {
+  class VM_TestClaimOverflow;
+  class CountThreads;
+  class CheckClaims;
+};
+
+class Threads::Test::CountThreads : public ThreadClosure {
+  uintx _claim_token;
+  uint _java_threads_count;
+  uint _non_java_threads_count;
+  bool _need_claim;
+
+public:
+  CountThreads(uintx claim_token, bool need_claim) :
+    _claim_token(claim_token),
+    _java_threads_count(0),
+    _non_java_threads_count(0),
+    _need_claim(need_claim)
+  {}
+
+  virtual void do_thread(Thread* t) {
+    if (!_need_claim || t->claim_threads_do(true, _claim_token)) {
+      if (t->is_Java_thread()) {
+        ++_java_threads_count;
+      } else {
+        ++_non_java_threads_count;
+      }
+    }
+  }
+
+  uint java_threads_count() const { return _java_threads_count; }
+  uint non_java_threads_count() const { return _non_java_threads_count; }
+  uint count() const { return _java_threads_count + _non_java_threads_count; }
+};
+
+class Threads::Test::CheckClaims : public ThreadClosure {
+  uintx _claim_token;
+  uint _java_threads_claimed;
+  uint _java_threads_unclaimed;
+  uint _non_java_threads_claimed;
+  uint _non_java_threads_unclaimed;
+
+public:
+  CheckClaims(uintx claim_token) :
+    _claim_token(claim_token),
+    _java_threads_claimed(0),
+    _java_threads_unclaimed(0),
+    _non_java_threads_claimed(0),
+    _non_java_threads_unclaimed(0)
+  {}
+
+  virtual void do_thread(Thread* t) {
+    uintx thread_token = t->threads_do_token();
+    if (thread_token == _claim_token) {
+      if (t->is_Java_thread()) {
+        ++_java_threads_claimed;
+      } else {
+        ++_non_java_threads_claimed;
+      }
+    } else {
+      if (t->is_Java_thread()) {
+        ++_java_threads_unclaimed;
+      } else {
+        ++_non_java_threads_unclaimed;
+      }
+    }
+  }
+
+  uint java_threads_claimed() const { return _java_threads_claimed; }
+  uint java_threads_unclaimed() const { return _java_threads_unclaimed; }
+
+  uint non_java_threads_claimed() const { return _non_java_threads_claimed; }
+  uint non_java_threads_unclaimed() const { return _non_java_threads_unclaimed; }
+
+  uint claimed() const {
+    return _java_threads_claimed + _non_java_threads_claimed;
+  }
+
+  uint unclaimed() const {
+    return _java_threads_unclaimed + _non_java_threads_unclaimed;
+  }
+};
+
+class Threads::Test::VM_TestClaimOverflow : public VM_GTestExecuteAtSafepoint {
+public:
+  void doit() {
+    // Prevent changes to the NJT list while we're conducting our test.
+    MutexLockerEx ml(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag);
+
+    _thread_claim_token = max_uintx - 1;
+
+    ASSERT_EQ(max_uintx - 1, thread_claim_token());
+    CountThreads count1(thread_claim_token(), true);
+    threads_do(&count1);
+    tty->print_cr("Testing claim overflow with %u threads", count1.count());
+    // At least the main thread and the VM thread.
+    ASSERT_LE(2u, count1.count());
+    ASSERT_LE(1u, count1.java_threads_count());
+    ASSERT_LE(1u, count1.non_java_threads_count());
+
+    ASSERT_EQ(max_uintx - 1, thread_claim_token());
+    CheckClaims check1(thread_claim_token());
+    threads_do(&check1);
+    ASSERT_EQ(count1.count(), check1.claimed());
+    ASSERT_EQ(count1.java_threads_count(), check1.java_threads_claimed());
+    ASSERT_EQ(0u, check1.java_threads_unclaimed());
+    ASSERT_EQ(count1.non_java_threads_count(), check1.non_java_threads_claimed());
+    ASSERT_EQ(0u, check1.non_java_threads_unclaimed());
+
+    change_thread_claim_token(); // No overflow yet.
+    ASSERT_EQ(max_uintx, thread_claim_token());
+
+    CountThreads count2(thread_claim_token(), false); // Claimed by PPTD below
+    possibly_parallel_threads_do(true, &count2);
+    ASSERT_EQ(count1.java_threads_count(), count2.java_threads_count());
+    ASSERT_EQ(1u, count2.non_java_threads_count()); // Only VM thread
+
+    CheckClaims check2(thread_claim_token());
+    threads_do(&check2);
+    ASSERT_EQ(count2.java_threads_count(), check2.java_threads_claimed());
+    ASSERT_EQ(0u, check2.java_threads_unclaimed());
+    ASSERT_EQ(1u, check2.non_java_threads_claimed()); // Only VM thread
+    ASSERT_EQ(count1.non_java_threads_count(),
+              check2.non_java_threads_claimed() +
+              check2.non_java_threads_unclaimed());
+
+    change_thread_claim_token(); // Expect overflow.
+    ASSERT_EQ(uintx(1), thread_claim_token());
+
+    // Verify all threads have claim value of 0 after change overflow.
+    CheckClaims check3(0);
+    threads_do(&check3);
+    ASSERT_EQ(count1.count(), check3.claimed());
+    ASSERT_EQ(0u, check3.unclaimed());
+  }
+};
+
+// Test overflow handling in Threads::change_thread_claim_token().
+TEST_VM(ThreadsTest, claim_overflow) {
+  Threads::Test::VM_TestClaimOverflow op;
+  ThreadInVMfromNative invm(JavaThread::current());
+  VMThread::execute(&op);
+}
--- a/test/hotspot/gtest/threadHelper.inline.hpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/gtest/threadHelper.inline.hpp	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -66,7 +66,7 @@
   // Override as JavaThread::post_run() calls JavaThread::exit which
   // expects a valid thread object oop.
   virtual void post_run() {
-    Threads::remove(this);
+    Threads::remove(this, false);
     this->smr_delete();
   }
 
@@ -118,7 +118,7 @@
   // Override as JavaThread::post_run() calls JavaThread::exit which
   // expects a valid thread object oop. And we need to call signal.
   void post_run() {
-    Threads::remove(this);
+    Threads::remove(this, false);
     _post->signal();
     this->smr_delete();
   }
--- a/test/hotspot/jtreg/ProblemList-graal.txt	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/ProblemList-graal.txt	Tue Apr 09 11:48:54 2019 +0100
@@ -53,8 +53,16 @@
 
 gc/arguments/TestNewSizeFlags.java                              8196611   generic-all
 gc/arguments/TestVerifyBeforeAndAfterGCFlags.java               8196611   generic-all
+gc/g1/mixedgc/TestOldGenCollectionUsage.java                    8196611   generic-all
 gc/g1/TestConcurrentSystemGC.java                               8196611   generic-all
+gc/g1/TestPeriodicCollection.java                               8196611   generic-all
+gc/parallel/TestPrintGCDetailsVerbose.java                      8196611   generic-all
 vmTestbase/gc/lock/malloc/malloclock03/TestDescription.java     8196611   macosx-all
+vmTestbase/nsk/stress/except/except004.java                     8196611   generic-all
+vmTestbase/nsk/stress/except/except007.java                     8196611   generic-all
+vmTestbase/nsk/stress/except/except008.java                     8196611   generic-all
+vmTestbase/nsk/stress/except/except011.java                     8196611   generic-all
+serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorMultiArrayTest.java 8196611   generic-all
 
 gc/g1/ihop/TestIHOPErgo.java                                    8191048   generic-all
 gc/g1/plab/TestPLABEvacuationFailure.java                       8191048   generic-all
@@ -65,8 +73,6 @@
 
 compiler/compilercontrol/directives/LogTest.java                8181753   generic-all
 
-gc/parallel/TestPrintGCDetailsVerbose.java                      8196611   macosx-all
-
 compiler/jvmci/compilerToVM/ReprofileTest.java                  8201333   generic-all
 
 compiler/tiered/LevelTransitionTest.java                         8202124   generic-all
--- a/test/hotspot/jtreg/ProblemList.txt	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/ProblemList.txt	Tue Apr 09 11:48:54 2019 +0100
@@ -67,8 +67,6 @@
 
 gc/epsilon/TestMemoryMXBeans.java 8206434 generic-all
 gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java 8156755 generic-all
-gc/survivorAlignment/TestPromotionToSurvivor.java 8218049 generic-all
-gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java 8218049 generic-all
 gc/g1/logging/TestG1LoggingFailure.java 8169634 generic-all
 gc/g1/humongousObjects/TestHeapCounters.java 8178918 generic-all
 gc/stress/gclocker/TestGCLockerWithParallel.java 8180622 generic-all
@@ -80,9 +78,9 @@
 
 # :hotspot_runtime
 
-runtime/NMT/CheckForProperDetailStackTrace.java 8218458 generic-all
 runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all
 runtime/containers/docker/TestCPUSets.java 8220672 generic-all
+runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64
 
 #############################################################################
 
@@ -172,6 +170,9 @@
 vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted004/TestDescription.java 6606767 generic-all
 vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/TestDescription.java 8173658 generic-all
 vmTestbase/nsk/jvmti/AttachOnDemand/attach045/TestDescription.java 8202971 generic-all
+vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/TestDescription.java 8219652 aix-ppc64
+vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/TestDescription.java 8219652 aix-ppc64
+vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/TestDescription.java 8219652 aix-ppc64
 
 vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8208243,8192647 generic-all
 
--- a/test/hotspot/jtreg/TEST.groups	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/TEST.groups	Tue Apr 09 11:48:54 2019 +0100
@@ -321,6 +321,21 @@
   runtime/appcds/ \
   -:tier1_runtime_appcds
 
+# This group should be executed with "jtreg -Dtest.cds.run.with.jfr=true ..."
+# to test interaction between AppCDS and JFR. It also has the side effect of
+# testing JVMTI ClassFileLoadHook.
+#
+# The excluded tests disallow the jdk.jfr module, which is required to
+# run with JFR.
+hotspot_appcds_with_jfr = \
+  runtime/appcds/ \
+ -runtime/appcds/cacheObject/ArchivedModuleCompareTest.java \
+ -runtime/appcds/jigsaw/classpathtests/BootAppendTests.java \
+ -runtime/appcds/jigsaw/classpathtests/ClassPathTests.java \
+ -runtime/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java \
+ -runtime/appcds/jigsaw/JigsawOptionsCombo.java \
+ -runtime/appcds/jigsaw/modulepath/MainModuleOnly.java
+
 tier1_serviceability = \
   serviceability/dcmd/compiler \
   -serviceability/dcmd/compiler/CompilerQueueTest.java \
--- a/test/hotspot/jtreg/applications/ctw/modules/generate.bash	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/generate.bash	Tue Apr 09 11:48:54 2019 +0100
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-#  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
@@ -30,7 +30,7 @@
     echo creating $file for $module...
     cat > $file <<EOF
 /*
- * 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
@@ -66,7 +66,7 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox\$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:$module
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:$module
  */
 EOF
 
--- a/test/hotspot/jtreg/applications/ctw/modules/java_base.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_base.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.base 0% 50%
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.base 0% 50%
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_base_2.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_base_2.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.base 50% 100%
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.base 50% 100%
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_compiler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_compiler.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.compiler
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.compiler
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_datatransfer.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_datatransfer.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.datatransfer
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.datatransfer
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_desktop.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_desktop.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.desktop 0% 50%
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.desktop 0% 50%
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_desktop_2.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_desktop_2.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.desktop 50% 100%
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.desktop 50% 100%
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_instrument.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_instrument.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.instrument
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.instrument
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_logging.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_logging.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.logging
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.logging
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_management.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_management.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.management
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.management
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_management_rmi.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_management_rmi.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.management.rmi
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.management.rmi
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_naming.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_naming.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.naming
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.naming
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_net_http.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,39 @@
+/*
+ * 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
+ * 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 run CTW for all classes from java.net.http module
+ *
+ * @library /test/lib / /testlibrary/ctw/src
+ * @modules java.base/jdk.internal.access
+ *          java.base/jdk.internal.jimage
+ *          java.base/jdk.internal.misc
+ *          java.base/jdk.internal.reflect
+ * @modules java.net.http
+ *
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.net.http
+ */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_prefs.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_prefs.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.prefs
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.prefs
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_rmi.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_rmi.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.rmi
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.rmi
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_scripting.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_scripting.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.scripting
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.scripting
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_security_jgss.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_security_jgss.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.security.jgss
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.security.jgss
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_security_sasl.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_security_sasl.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.security.sasl
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.security.sasl
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_smartcardio.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_smartcardio.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.smartcardio
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.smartcardio
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_sql.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_sql.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.sql
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.sql
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_sql_rowset.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_sql_rowset.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.sql.rowset
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.sql.rowset
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_transaction_xa.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,39 @@
+/*
+ * 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
+ * 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 run CTW for all classes from java.transaction.xa module
+ *
+ * @library /test/lib / /testlibrary/ctw/src
+ * @modules java.base/jdk.internal.access
+ *          java.base/jdk.internal.jimage
+ *          java.base/jdk.internal.misc
+ *          java.base/jdk.internal.reflect
+ * @modules java.transaction.xa
+ *
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.transaction.xa
+ */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_xml.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_xml.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.xml
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.xml
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/java_xml_crypto.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/java_xml_crypto.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.xml.crypto
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:java.xml.crypto
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_accessibility.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_accessibility.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.accessibility
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.accessibility
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_aot.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_aot.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.aot
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.aot
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_attach.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_attach.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.attach
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.attach
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_charsets.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_charsets.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.charsets
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.charsets
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_compiler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_compiler.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.compiler
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.compiler
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_cryptoki.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_cryptoki.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.crypto.cryptoki
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.crypto.cryptoki
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_ec.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_ec.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.crypto.ec
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.crypto.ec
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_mscapi.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_mscapi.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.crypto.mscapi
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.crypto.mscapi
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_ucrypto.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_ucrypto.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.crypto.ucrypto
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.crypto.ucrypto
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_dynalink.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_dynalink.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.dynalink
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.dynalink
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_editpad.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_editpad.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.editpad
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.editpad
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_hotspot_agent.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_hotspot_agent.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.hotspot.agent
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.hotspot.agent
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_httpserver.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_httpserver.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.httpserver
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.httpserver
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_incubator_httpclient.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2017, 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
- * 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 run CTW for all classes from jdk.incubator.httpclient module
- *
- * @library /test/lib / /testlibrary/ctw/src
- * @modules java.base/jdk.internal.access
- *          java.base/jdk.internal.jimage
- *          java.base/jdk.internal.misc
- *          java.base/jdk.internal.reflect
- * @modules jdk.incubator.httpclient
- *
- * @build sun.hotspot.WhiteBox
- * @run driver ClassFileInstaller sun.hotspot.WhiteBox
- *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.incubator.httpclient
- */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_ed.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_ed.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.ed
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.ed
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_jvmstat.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_jvmstat.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.jvmstat
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.jvmstat
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_le.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_le.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.le
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.le
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_opt.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_opt.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.opt
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.opt
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_ci.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_ci.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.vm.ci
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.vm.ci
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_compiler.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_compiler.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.vm.compiler
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.vm.compiler
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_compiler_management.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_compiler_management.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.vm.compiler.management
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.vm.compiler.management
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jartool.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jartool.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jartool
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jartool
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_javadoc.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_javadoc.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.javadoc
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.javadoc
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jcmd.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jcmd.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jcmd
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jcmd
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jconsole.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jconsole.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jconsole
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jconsole
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jdeps.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jdeps.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jdeps
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jdeps
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jdi.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jdi.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jdi
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jdi
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jfr.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jfr.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jfr
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jfr
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jlink.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jlink.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jlink
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jlink
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jshell.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jshell.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jshell
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jshell
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jsobject.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jsobject.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jsobject
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jsobject
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jstatd.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jstatd.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jstatd
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.jstatd
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_localedata.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_localedata.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.localedata
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.localedata
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_management.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_management.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.management
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.management
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_management_agent.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_management_agent.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.management.agent
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.management.agent
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_management_jfr.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_management_jfr.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.management.jfr
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.management.jfr
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_naming_dns.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_naming_dns.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.naming.dns
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.naming.dns
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_naming_rmi.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_naming_rmi.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.naming.rmi
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.naming.rmi
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_net.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_net.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.net
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.net
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_packager.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2017, 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
- * 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 run CTW for all classes from jdk.packager module
- *
- * @library /test/lib / /testlibrary/ctw/src
- * @modules java.base/jdk.internal.access
- *          java.base/jdk.internal.jimage
- *          java.base/jdk.internal.misc
- *          java.base/jdk.internal.reflect
- * @modules jdk.packager
- *
- * @build sun.hotspot.WhiteBox
- * @run driver ClassFileInstaller sun.hotspot.WhiteBox
- *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.packager
- */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_packager_services.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2017, 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
- * 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 run CTW for all classes from jdk.packager.services module
- *
- * @library /test/lib / /testlibrary/ctw/src
- * @modules java.base/jdk.internal.access
- *          java.base/jdk.internal.jimage
- *          java.base/jdk.internal.misc
- *          java.base/jdk.internal.reflect
- * @modules jdk.packager.services
- *
- * @build sun.hotspot.WhiteBox
- * @run driver ClassFileInstaller sun.hotspot.WhiteBox
- *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.packager.services
- */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_rmic.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_rmic.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.rmic
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.rmic
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_scripting_nashorn.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_scripting_nashorn.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.scripting.nashorn
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.scripting.nashorn
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_scripting_nashorn_shell.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_scripting_nashorn_shell.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.scripting.nashorn.shell
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.scripting.nashorn.shell
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_sctp.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_sctp.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.sctp
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.sctp
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_security_auth.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_security_auth.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.security.auth
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.security.auth
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_security_jgss.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_security_jgss.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.security.jgss
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.security.jgss
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_unsupported.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_unsupported.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.unsupported
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.unsupported
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_unsupported_desktop.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,39 @@
+/*
+ * 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
+ * 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 run CTW for all classes from jdk.unsupported.desktop module
+ *
+ * @library /test/lib / /testlibrary/ctw/src
+ * @modules java.base/jdk.internal.access
+ *          java.base/jdk.internal.jimage
+ *          java.base/jdk.internal.misc
+ *          java.base/jdk.internal.reflect
+ * @modules jdk.unsupported.desktop
+ *
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.unsupported.desktop
+ */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_xml_dom.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_xml_dom.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.xml.dom
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.xml.dom
  */
--- a/test/hotspot/jtreg/applications/ctw/modules/jdk_zipfs.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_zipfs.java	Tue Apr 09 11:48:54 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
@@ -35,5 +35,5 @@
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.zipfs
+ * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.zipfs
  */
--- a/test/hotspot/jtreg/compiler/graalunit/ApiDirectivesTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/ApiDirectivesTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.api.directives.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.api.directives.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/ApiTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/ApiTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.api.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.api.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/AsmAarch64Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/AsmAarch64Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.aarch64.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.aarch64.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/AsmAmd64Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/AsmAmd64Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.amd64.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.amd64.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/AsmSparcTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/AsmSparcTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.sparc.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.asm.sparc.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/CollectionsTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/CollectionsTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix jdk.internal.vm.compiler.collections.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix jdk.internal.vm.compiler.collections.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/CoreAmd64Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/CoreAmd64Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.amd64.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.amd64.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/CoreTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/CoreTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/DebugTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/DebugTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.debug.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.debug.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/EA9Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/EA9Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.jdk9.test.ea -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.jdk9.test.ea -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/EATest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/EATest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.test.ea -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.core.test.ea -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/GraphTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/GraphTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.graph.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.graph.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/HotspotAmd64Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/HotspotAmd64Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.amd64.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.amd64.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/HotspotJdk9Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/HotspotJdk9Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.jdk9.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.jdk9.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/HotspotLirTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/HotspotLirTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.lir.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.lir.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/HotspotSparcTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/HotspotSparcTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.sparc.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.sparc.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/HotspotTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/HotspotTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.hotspot.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/Jtt.MicroTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/Jtt.MicroTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.micro -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.micro -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttBackendTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttBackendTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.backend -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.backend -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttBytecodeTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttBytecodeTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.bytecode -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.bytecode -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttExceptTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttExceptTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.except -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.except -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttHotpathTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttHotpathTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.hotpath -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.hotpath -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttHotspotTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttHotspotTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.hotspot -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.hotspot -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttJdkTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttJdkTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.jdk -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.jdk -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttLangALTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttLangALTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.[a-lA-L] -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.[a-lA-L] -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttLangMathALTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttLangMathALTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,6 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm/timeout=300 compiler.graalunit.common.GraalUnitTestLauncher
- *     -prefix org.graalvm.compiler.jtt.lang.Math_[a-lA-L] -exclude ExcludeList.txt
+ * @run main/timeout=300 compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.Math_[a-lA-L] -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttLangMathMZTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttLangMathMZTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,6 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm/timeout=300 compiler.graalunit.common.GraalUnitTestLauncher
- *     -prefix org.graalvm.compiler.jtt.lang.Math_[m-zM-Z] -exclude ExcludeList.txt
+ * @run main/timeout=300 compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.Math_[m-zM-Z] -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttLangNZTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttLangNZTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.[n-zN-Z] -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.lang.[n-zN-Z] -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttLoopTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttLoopTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.loop -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.loop -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttOptimizeTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttOptimizeTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.optimize -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.optimize -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttReflectAETest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttReflectAETest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.[a-eA-E] -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.[a-eA-E] -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttReflectFieldGetTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttReflectFieldGetTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.Field_get -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.Field_get -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttReflectFieldSetTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttReflectFieldSetTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.Field_set -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.Field_set -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttReflectGZTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttReflectGZTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.[g-zG-Z] -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.reflect.[g-zG-Z] -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/JttThreadsTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/JttThreadsTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.threads -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.jtt.threads -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/LirJttTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/LirJttTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.lir.jtt -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.lir.jtt -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/LirTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/LirTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.lir.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.lir.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/LoopTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/LoopTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.loop.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.loop.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/NodesTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/NodesTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.nodes.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.nodes.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/OptionsTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/OptionsTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.options.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.options.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/PhasesCommonTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/PhasesCommonTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.phases.common.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.phases.common.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/Replacements12Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/Replacements12Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.replacements.jdk12.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.replacements.jdk12.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/Replacements9Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/Replacements9Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.replacements.jdk9.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.replacements.jdk9.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/ReplacementsTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/ReplacementsTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.replacements.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.compiler.replacements.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/TestPackages.txt	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/TestPackages.txt	Tue Apr 09 11:48:54 2019 +0100
@@ -30,8 +30,8 @@
 JttHotspot    org.graalvm.compiler.jtt.hotspot
 JttJdk        org.graalvm.compiler.jtt.jdk
 JttLangAL     org.graalvm.compiler.jtt.lang.[a-lA-L]
-JttLangMathAL org.graalvm.compiler.jtt.lang.Math_[a-lA-L]
-JttLangMathMZ org.graalvm.compiler.jtt.lang.Math_[m-zM-Z]
+JttLangMathAL org.graalvm.compiler.jtt.lang.Math_[a-lA-L] timeout=300
+JttLangMathMZ org.graalvm.compiler.jtt.lang.Math_[m-zM-Z] timeout=300
 JttLangNZ     org.graalvm.compiler.jtt.lang.[n-zN-Z]
 JttLoop       org.graalvm.compiler.jtt.loop
 Jtt.Micro     org.graalvm.compiler.jtt.micro
--- a/test/hotspot/jtreg/compiler/graalunit/UtilTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/UtilTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,5 +34,7 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.util.test -exclude ExcludeList.txt
+ * @run main compiler.graalunit.common.GraalUnitTestLauncher -prefix org.graalvm.util.test -exclude ExcludeList.txt
  */
+
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
--- a/test/hotspot/jtreg/compiler/graalunit/generateTests.sh	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/compiler/graalunit/generateTests.sh	Tue Apr 09 11:48:54 2019 +0100
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2018, 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,14 +22,22 @@
 # questions.
 #
 
-while read -r fName pName requireInfo
+while read -r fName pName timeoutInfo requireInfo
 do
   fName="${fName}Test.java"
   echo "Generate $fName for $pName ..."
 
+  action="main"
+  if [[ $timeoutInfo == timeout* ]] ; then
+     action="$action/$timeoutInfo"  
+  else
+     requireInfo="$timeoutInfo $requireInfo"
+  fi
+
+  
   cat << EOF | sed 's/[[:blank:]]*$//' > $fName
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,8 +72,10 @@
  *
  * @run driver jdk.test.lib.FileInstaller ../../ProblemList-graal.txt ExcludeList.txt
  *
- * @run main/othervm compiler.graalunit.common.GraalUnitTestLauncher -prefix $pName -exclude ExcludeList.txt
+ * @run $action compiler.graalunit.common.GraalUnitTestLauncher -prefix $pName -exclude ExcludeList.txt
  */
+ 
+/* DO NOT MODIFY THIS FILE. GENERATED BY generateTests.sh */
 EOF
 
 done < TestPackages.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/g1/TestLargePageUseForHeap.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,152 @@
+/*
+ * 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 gc.g1;
+
+/*
+ * @test TestLargePageUseForHeap.java
+ * @summary Test that Java heap is allocated using large pages of the appropriate size if available.
+ * @bug 8221517
+ * @key gc
+ * @modules java.base/jdk.internal.misc
+ * @library /test/lib
+ * @requires vm.gc.G1
+ * @requires os.family != "solaris"
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+        -XX:+IgnoreUnrecognizedVMOptions -XX:+UseLargePages gc.g1.TestLargePageUseForHeap
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jtreg.SkippedException;
+import sun.hotspot.WhiteBox;
+
+public class TestLargePageUseForHeap {
+    static long largePageSize;
+    static long smallPageSize;
+
+    static void checkSize(OutputAnalyzer output, long expectedSize, String pattern) {
+        String pageSizeStr = output.firstMatch(pattern, 1);
+
+        if (pageSizeStr == null) {
+            output.reportDiagnosticSummary();
+            throw new RuntimeException("Match from '" + pattern + "' got 'null' expected: " + expectedSize);
+        }
+
+        long size = parseMemoryString(pageSizeStr);
+        if (size != expectedSize) {
+            output.reportDiagnosticSummary();
+            throw new RuntimeException("Match from '" + pattern + "' got " + size + " expected: " + expectedSize);
+        }
+    }
+
+    static boolean checkLargePageEnabled(OutputAnalyzer output) {
+        // This message is printed when tried to reserve a memory with large page but it failed.
+        String errorStr = "Reserve regular memory without large pages";
+        String heapPattern = ".*Heap: ";
+        // If errorStr is printed just before heap page log, reservation for Java Heap is failed.
+        String result = output.firstMatch(errorStr + "\n" + heapPattern);
+        if (result != null) {
+            return false;
+        }
+        return true;
+    }
+
+    static void checkHeap(OutputAnalyzer output, long expectedPageSize) throws Exception {
+        checkSize(output, expectedPageSize, "Heap: .*page_size=([^ ]+)");
+    }
+
+    static void testVM(long regionSize) throws Exception {
+        ProcessBuilder pb;
+        // Test with large page enabled.
+        pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
+                                                   "-XX:G1HeapRegionSize=" + regionSize,
+                                                   "-Xmx128m",
+                                                   "-Xlog:pagesize,gc+heap+coops=debug",
+                                                   "-XX:+UseLargePages",
+                                                   "-version");
+
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        boolean largePageEnabled = checkLargePageEnabled(output);
+        checkHeap(output, largePageEnabled ? largePageSize : smallPageSize);
+        output.shouldHaveExitValue(0);
+
+        // Test with large page disabled.
+        pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
+                                                   "-XX:G1HeapRegionSize=" + regionSize,
+                                                   "-Xmx128m",
+                                                   "-Xlog:pagesize,gc+heap+coops=debug",
+                                                   "-XX:-UseLargePages",
+                                                   "-version");
+
+        output = new OutputAnalyzer(pb.start());
+        checkHeap(output, smallPageSize);
+        output.shouldHaveExitValue(0);
+    }
+
+    public static void main(String[] args) throws Exception {
+        WhiteBox wb = WhiteBox.getWhiteBox();
+        smallPageSize = wb.getVMPageSize();
+        largePageSize = wb.getVMLargePageSize();
+
+        if (largePageSize == 0) {
+            throw new SkippedException("Large page support does not seem to be available on this platform.");
+        }
+        if (largePageSize == smallPageSize) {
+            throw new SkippedException("Large page support does not seem to be available on this platform."
+                    + "Small and large page size are the same.");
+        }
+
+        // G1HeapRegionSize=1MB
+        testVM(1 * 1024 * 1024);
+
+        // G1HeapRegionSize=2MB
+        testVM(2 * 1024 * 1024);
+
+        // G1HeapRegionSize=8MB
+        testVM(8 * 1024 * 1024);
+    }
+
+    public static long parseMemoryString(String value) {
+        long multiplier = 1;
+
+        if (value.endsWith("B")) {
+            multiplier = 1;
+        } else if (value.endsWith("K")) {
+            multiplier = 1024;
+        } else if (value.endsWith("M")) {
+            multiplier = 1024 * 1024;
+        } else if (value.endsWith("G")) {
+            multiplier = 1024 * 1024 * 1024;
+        } else {
+            throw new IllegalArgumentException("Expected memory string '" + value + "'to end with either of: B, K, M, G");
+        }
+
+        long longValue = Long.parseUnsignedLong(value.substring(0, value.length() - 1));
+
+        return longValue * multiplier;
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/shenandoah/options/TestSafepointWorkers.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
+ *
+ * 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 TestSingleSafepointWorker
+ * @key gc
+ * @requires vm.gc.Shenandoah
+ *
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahParallelSafepointThreads=1 -Xmx128m TestSafepointWorkers
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahParallelSafepointThreads=2 -Xmx128m TestSafepointWorkers
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahParallelSafepointThreads=4 -Xmx128m TestSafepointWorkers
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahParallelSafepointThreads=8 -Xmx128m TestSafepointWorkers
+ */
+
+public class TestSafepointWorkers {
+    static final long TARGET_MB = Long.getLong("target", 1000); // 1 Gb allocation
+
+    static volatile Object sink;
+
+    public static void main(String[] args) throws Exception {
+        long count = TARGET_MB * 1024 * 1024 / 16;
+        for (long c = 0; c < count; c++) {
+            sink = new Object();
+        }
+    }
+}
--- a/test/hotspot/jtreg/gc/shenandoah/options/TestSelectiveBarrierFlags.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/gc/shenandoah/options/TestSelectiveBarrierFlags.java	Tue Apr 09 11:48:54 2019 +0100
@@ -43,13 +43,9 @@
     public static void main(String[] args) throws Exception {
         String[][] opts = {
                 new String[] { "ShenandoahKeepAliveBarrier" },
-                new String[] { "ShenandoahWriteBarrier" },
-                new String[] { "ShenandoahReadBarrier" },
-                // StoreValRead+SATB are actually compatible, but we need to protect against
-                // StorveValEnqueue+SATB. TODO: Make it better.
-                new String[] { "ShenandoahSATBBarrier", "ShenandoahStoreValReadBarrier", "ShenandoahStoreValEnqueueBarrier" },
+                new String[] { "ShenandoahLoadRefBarrier" },
+                new String[] { "ShenandoahSATBBarrier", "ShenandoahStoreValEnqueueBarrier" },
                 new String[] { "ShenandoahCASBarrier" },
-                new String[] { "ShenandoahAcmpBarrier" },
                 new String[] { "ShenandoahCloneBarrier" },
         };
 
--- a/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierDisable.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierDisable.java	Tue Apr 09 11:48:54 2019 +0100
@@ -38,21 +38,16 @@
 
     public static void main(String[] args) throws Exception {
         String[] concurrent = {
-                "ShenandoahReadBarrier",
-                "ShenandoahWriteBarrier",
+                "ShenandoahLoadRefBarrier",
                 "ShenandoahCASBarrier",
-                "ShenandoahAcmpBarrier",
                 "ShenandoahCloneBarrier",
                 "ShenandoahSATBBarrier",
                 "ShenandoahKeepAliveBarrier",
-                "ShenandoahStoreValReadBarrier",
         };
 
         String[] traversal = {
-                "ShenandoahReadBarrier",
-                "ShenandoahWriteBarrier",
+                "ShenandoahLoadRefBarrier",
                 "ShenandoahCASBarrier",
-                "ShenandoahAcmpBarrier",
                 "ShenandoahCloneBarrier",
         };
 
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestAllocationInEden.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestAllocationInEden.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,7 @@
 package gc.survivorAlignment;
 
 /**
- * @test
+ * @test gc.survivorAlignment.TestAllocationInEden
  * @bug 8031323
  * @summary Verify that object's alignment in eden space is not affected by
  *          SurvivorAlignmentInBytes option.
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromEdenToTenured.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromEdenToTenured.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,7 @@
 package gc.survivorAlignment;
 
 /**
- * @test
+ * @test gc.survivorAlignment.TestPromotionFromEdenToTenured
  * @bug 8031323
  * @summary Verify that objects promoted from eden space to tenured space during
  *          full GC are not aligned to SurvivorAlignmentInBytes value.
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,7 @@
 package gc.survivorAlignment;
 
 /**
- * @test
+ * @test gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterFullGC
  * @bug 8031323
  * @summary Verify that objects promoted from survivor space to tenured space
  *          during full GC are not aligned to SurvivorAlignmentInBytes value.
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,13 +24,14 @@
 package gc.survivorAlignment;
 
 /**
- * @test
+ * @test gc.survivorAlignment.TestPromotionFromSurvivorToTenuredAfterMinorGC
  * @bug 8031323
  * @summary Verify that objects promoted from survivor space to tenured space
  *          when their age exceeded tenuring threshold are not aligned to
  *          SurvivorAlignmentInBytes value.
  * @requires vm.gc != "Z" & vm.gc != "Shenandoah"
  * @library /test/lib
+ * @library /
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionLABLargeSurvivorAlignment.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionLABLargeSurvivorAlignment.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,7 @@
 package gc.survivorAlignment;
 
 /**
- * @test
+ * @test gc.survivorAlignment.TestPromotionLABLargeSurvivorAlignment
  * @bug 8060463
  * @summary Verify that objects promoted from eden space to survivor space
  *          with large values for SurvivorAlignmentInBytes succeed.
--- a/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionToSurvivor.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/gc/survivorAlignment/TestPromotionToSurvivor.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,12 +24,13 @@
 package gc.survivorAlignment;
 
 /**
- * @test
+ * @test gc.survivorAlignment.TestPromotionToSurvivor
  * @bug 8031323
  * @summary Verify that objects promoted from eden space to survivor space after
  *          minor GC are aligned to SurvivorAlignmentInBytes.
  * @requires vm.gc != "Z" & vm.gc != "Shenandoah"
  * @library /test/lib
+ * @library /
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @build sun.hotspot.WhiteBox
--- a/test/hotspot/jtreg/runtime/CreateMirror/ArraysNewInstanceBug.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/CreateMirror/ArraysNewInstanceBug.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 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
@@ -31,6 +31,7 @@
 
 // This test crashes in compiled code with race, because the compiler generates code that assumes this ordering.
 import java.lang.reflect.Array;
+import java.io.File;
 import java.net.URL;
 import java.net.URLClassLoader;
 
@@ -55,13 +56,13 @@
 
     public static void main(String[] args) throws Throwable {
         Class<?> c = ArraysNewInstanceBug.class;
-        ClassLoader apploader =  c.getClassLoader();
+        ClassLoader apploader = c.getClassLoader();
+        File testClasses = new File(System.getProperty("test.classes"));
         for (int iter = 0; iter < 10 ; iter++) {  // 10 is enough to get it to crash on my machine.
             System.err.print('[');
             classes = new Class<?>[1000];
-            String urlpath = "file://" + System.getProperty("test.classes") + "/";
             for (int i = 0; i < classes.length; i++) {
-                ClassLoader loader = new URLClassLoader(new URL[] { new URL(urlpath) }, apploader.getParent());
+                ClassLoader loader = new URLClassLoader(new URL[] { testClasses.toURI().toURL() }, apploader.getParent());
                 classes[i] = loader.loadClass(c.getSimpleName());
             }
             System.err.print(']');
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, SAP. 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 8220786
+ * @summary Test ErrorFileToStderr and ErrorFileToStdout
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * @requires (vm.debug == true)
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class ErrorFileRedirectTest {
+
+  public static void do_test(boolean redirectStdout, boolean redirectStderr) throws Exception {
+
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+            "-Xmx64M",
+            "-XX:-CreateCoredumpOnCrash",
+            "-XX:ErrorHandlerTest=14",
+            "-XX:" + (redirectStdout ? "+" : "-") + "ErrorFileToStdout",
+            "-XX:" + (redirectStderr ? "+" : "-") + "ErrorFileToStderr",
+            "-version");
+
+    OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
+
+    // we should have crashed with a SIGSEGV
+    output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
+    output_detail.shouldMatch("# +(?:SIGSEGV|EXCEPTION_ACCESS_VIOLATION).*");
+
+    // If no redirection happened, we should find a mention of the file in the output.
+    String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
+    if (redirectStdout == false && redirectStderr == false) {
+      if (hs_err_file == null) {
+        throw new RuntimeException("Expected hs-err file but none found.");
+      } else {
+        System.out.println("Found hs error file mentioned as expected: " + hs_err_file);
+      }
+    } else {
+      if (hs_err_file != null) {
+        throw new RuntimeException("Found unexpected mention of hs-err file (we did redirect the output so no file should have been written).");
+      } else {
+        System.out.println("No mention of an hs-err file - ok! ");
+      }
+    }
+
+    // Check the output. Note that since stderr was specified last it has preference if both are set.
+    if (redirectStdout == true && redirectStderr == false) {
+      output_detail.stdoutShouldContain("---------------  S U M M A R Y ------------");
+      output_detail.stderrShouldNotContain("---------------  S U M M A R Y ------------");
+      System.out.println("Found report on stderr - ok! ");
+    } else if (redirectStderr == true) {
+      output_detail.stderrShouldContain("---------------  S U M M A R Y ------------");
+      output_detail.stdoutShouldNotContain("---------------  S U M M A R Y ------------");
+      System.out.println("Found report on stdout - ok! ");
+    }
+
+    System.out.println("OK.");
+
+  }
+
+  public static void main(String[] args) throws Exception {
+    do_test(false, false);
+    do_test(false, true);
+    do_test(true, false);
+    do_test(true, true);
+  }
+
+}
+
+
--- a/test/hotspot/jtreg/runtime/LoaderConstraints/itableLdrConstraint/Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/LoaderConstraints/itableLdrConstraint/Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -38,19 +38,19 @@
     // Break expected error messages into 3 parts since the loader name includes its identity
     // hash which is unique and can't be compared against.
     static String expectedErrorMessage1_part1 = "loader constraint violation in interface itable initialization for " +
-                                                "class test.C: when selecting method test.I.m()Ltest/Foo; the class loader " +
+                                                "class test.C: when selecting method 'test.Foo test.I.m()' the class loader " +
                                                 "PreemptingClassLoader @";
     static String expectedErrorMessage1_part2 = " for super interface test.I, and the class loader 'app' of the " +
-                                                "selected method's type, test.J have different Class objects for the " +
+                                                "selected method's interface, test.J have different Class objects for the " +
                                                 "type test.Foo used in the signature (test.I is in unnamed module of loader " +
                                                 "PreemptingClassLoader @";
     static String expectedErrorMessage1_part3 = ", parent loader 'app'; test.J is in unnamed module of loader 'app')";
 
     static String expectedErrorMessage2_part1 = "loader constraint violation in interface itable initialization for " +
-                                                "class test.C: when selecting method test.I.m()Ltest/Foo; the class loader " +
+                                                "class test.C: when selecting method 'test.Foo test.I.m()' the class loader " +
                                                 "'ItableLdrCnstrnt_Test_Loader' @";
     static String expectedErrorMessage2_part2 = " for super interface test.I, and the class loader 'app' of the " +
-                                                "selected method's type, test.J have different Class objects for the " +
+                                                "selected method's interface, test.J have different Class objects for the " +
                                                 "type test.Foo used in the signature (test.I is in unnamed module of loader " +
                                                 "'ItableLdrCnstrnt_Test_Loader' @";
     static String expectedErrorMessage2_part3 = ", parent loader 'app'; test.J is in unnamed module of loader 'app')";
@@ -79,7 +79,9 @@
             if (!errorMsg.contains(expectedErrorMessage_part1) ||
                 !errorMsg.contains(expectedErrorMessage_part2) ||
                 !errorMsg.contains(expectedErrorMessage_part3)) {
-                System.out.println("Expected: " + expectedErrorMessage_part1 + "<id>" + expectedErrorMessage_part2 + "\n" +
+                System.out.println("Expected: " + expectedErrorMessage_part1 + "<id>" +
+                                                  expectedErrorMessage_part2 + "<id>" +
+                                                  expectedErrorMessage_part3 + "\n" +
                                    "but got:  " + errorMsg);
                 throw new RuntimeException("Wrong LinkageError exception thrown: " + errorMsg);
             }
--- a/test/hotspot/jtreg/runtime/LoaderConstraints/vtableLdrConstraint/Test.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/LoaderConstraints/vtableLdrConstraint/Test.java	Tue Apr 09 11:48:54 2019 +0100
@@ -38,7 +38,7 @@
     // Break expected error messages into 3 parts since the loader name includes its identity
     // hash which is unique and can't be compared against.
     static String expectedErrorMessage1_part1 = "loader constraint violation for class test.Task: when " +
-                                                "selecting overriding method test.Task.m()Ltest/Foo; the " +
+                                                "selecting overriding method 'test.Foo test.Task.m()' the " +
                                                 "class loader PreemptingClassLoader @";
     static String expectedErrorMessage1_part2 = " of the selected method's type test.Task, and the class " +
                                                 "loader 'app' for its super type test.J have different Class objects " +
@@ -47,7 +47,7 @@
     static String expectedErrorMessage1_part3 = ", parent loader 'app'; test.J is in unnamed module of loader 'app')";
 
     static String expectedErrorMessage2_part1 = "loader constraint violation for class test.Task: when " +
-                                                "selecting overriding method test.Task.m()Ltest/Foo; the " +
+                                                "selecting overriding method 'test.Foo test.Task.m()' the " +
                                                 "class loader 'VtableLdrCnstrnt_Test_Loader' @";
     static String expectedErrorMessage2_part2 = " of the selected method's type test.Task, and the class " +
                                                 "loader 'app' for its super type test.J have different Class objects " +
--- a/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/Metaspace/PrintMetaspaceDcmd.java	Tue Apr 09 11:48:54 2019 +0100
@@ -67,7 +67,7 @@
         }
         output.shouldContain("Virtual space:");
         output.shouldContain("Chunk freelists:");
-
+        output.shouldMatch("MaxMetaspaceSize:.*201.00.*MB");
 
         pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace"});
         output = new OutputAnalyzer(pb.start());
--- a/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java	Tue Apr 09 11:48:54 2019 +0100
@@ -23,6 +23,7 @@
 
  /*
  * @test
+ * @bug 8133747 8218458
  * @key nmt
  * @summary Running with NMT detail should produce expected stack traces.
  * @library /test/lib
@@ -36,26 +37,50 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+/**
+ * We are checking for details that should be seen with NMT detail enabled.
+ * In particular the stack traces from os::malloc call sites should have 4
+ * (based on NMT detail stack depth setting) 'interesting' frames and skip
+ * the higher-level allocation frames and frames specific to the NMT logic.
+ * The actual stack trace is affected by the native compiler's inlining ability
+ * and the type of build, so we need to check for a number of possible stacks.
+ * This information does not change often enough that we are concerned about the
+ * stability of this test - rather we prefer to detect changes in compiler behaviour
+ * through this test and update it accordingly.
+ */
 public class CheckForProperDetailStackTrace {
+
     /* The stack trace we look for by default. Note that :: has been replaced by .*
-       to make sure it maches even if the symbol is not unmangled. */
-    public static String stackTraceDefault =
+       to make sure it matches even if the symbol is not unmangled.
+    */
+    private static String stackTraceDefault =
         ".*Hashtable.*allocate_new_entry.*\n" +
         ".*ModuleEntryTable.*new_entry.*\n" +
         ".*ModuleEntryTable.*locked_create_entry.*\n" +
         ".*Modules.*define_module.*\n";
 
-    /* The stack trace we look for on Solaris and Windows slowdebug builds. For some
-       reason ALWAYSINLINE for AllocateHeap is ignored, so it appears in the stack strace. */
-    public static String stackTraceAllocateHeap =
+    /* Alternate stacktrace that we check if the default fails, because
+       new_entry may be inlined.
+    */
+    private static String stackTraceAlternate =
+        ".*Hashtable.*allocate_new_entry.*\n" +
+        ".*ModuleEntryTable.*locked_create_entry.*\n" +
+        ".*Modules.*define_module.*\n" +
+        ".*JVM_DefineModule.*\n";
+
+    /* The stack trace we look for on AIX, Solaris and Windows slowdebug builds.
+       ALWAYSINLINE is only a hint and is ignored for AllocateHeap on the
+       aforementioned platforms. When that happens allocate_new_entry is
+       inlined instead.
+    */
+    private static String stackTraceAllocateHeap =
         ".*AllocateHeap.*\n" +
         ".*ModuleEntryTable.*new_entry.*\n" +
         ".*ModuleEntryTable.*locked_create_entry.*\n" +
         ".*Modules.*define_module.*\n";
 
     /* A symbol that should always be present in NMT detail output. */
-    private static String expectedSymbol =
-        "locked_create_entry";
+    private static String expectedSymbol = "locked_create_entry";
 
     public static void main(String args[]) throws Exception {
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
@@ -67,23 +92,22 @@
 
         output.shouldHaveExitValue(0);
 
-        // We should never see either of these frames because they are supposed to be skipped. */
+        // We should never see either of these frames because they are supposed to be skipped.
         output.shouldNotContain("NativeCallStack::NativeCallStack");
         output.shouldNotContain("os::get_native_stack");
 
         // AllocateHeap shouldn't be in the output because it is supposed to always be inlined.
         // We check for that here, but allow it for Aix, Solaris and Windows slowdebug builds
         // because the compiler ends up not inlining AllocateHeap.
-        Boolean okToHaveAllocateHeap =
-            Platform.isSlowDebugBuild() &&
-            (Platform.isAix() || Platform.isSolaris() || Platform.isWindows());
+        Boolean okToHaveAllocateHeap = Platform.isSlowDebugBuild() &&
+                                       (Platform.isAix() || Platform.isSolaris() || Platform.isWindows());
         if (!okToHaveAllocateHeap) {
             output.shouldNotContain("AllocateHeap");
         }
 
         // See if we have any stack trace symbols in the output
-        boolean hasSymbols =
-            output.getStdout().contains(expectedSymbol) || output.getStderr().contains(expectedSymbol);
+        boolean hasSymbols = output.getStdout().contains(expectedSymbol) ||
+                             output.getStderr().contains(expectedSymbol);
         if (!hasSymbols) {
             // It's ok for ARM not to have symbols, because it does not support NMT detail
             // when targeting thumb2. It's also ok for Windows not to have symbols, because
@@ -92,21 +116,37 @@
                 return; // we are done
             }
             output.reportDiagnosticSummary();
-            throw new RuntimeException("Expected symbol missing missing from output: " + expectedSymbol);
+            throw new RuntimeException("Expected symbol missing from output: " + expectedSymbol);
         }
 
-        /* Make sure the expected NMT detail stack trace is found. */
-        String expectedStackTrace =
-            (okToHaveAllocateHeap ? stackTraceAllocateHeap : stackTraceDefault);
-        if (!stackTraceMatches(expectedStackTrace, output)) {
-            output.reportDiagnosticSummary();
-            throw new RuntimeException("Expected stack trace missing missing from output: " + expectedStackTrace);
+        // Make sure the expected NMT detail stack trace is found
+        System.out.println("Looking for a stack matching:");
+        if (okToHaveAllocateHeap) {
+            System.out.print(stackTraceAllocateHeap);
+            if (stackTraceMatches(stackTraceAllocateHeap, output)) {
+                return;
+            }
+        } else {
+            System.out.print(stackTraceDefault);
+            if (!stackTraceMatches(stackTraceDefault, output)) {
+                System.out.println("Looking for alternate stack matching:");
+                System.out.print(stackTraceAlternate);
+                if (stackTraceMatches(stackTraceAlternate, output)) {
+                    return;
+                }
+            } else {
+                return;
+            }
         }
+        // Failed to match so dump all the output
+        output.reportDiagnosticSummary();
+        throw new RuntimeException("Expected stack trace missing from output");
     }
 
     public static boolean stackTraceMatches(String stackTrace, OutputAnalyzer output) {
-        Matcher stdoutMatcher = Pattern.compile(stackTrace, Pattern.MULTILINE).matcher(output.getStdout());
-        Matcher stderrMatcher = Pattern.compile(stackTrace, Pattern.MULTILINE).matcher(output.getStderr());
+        Pattern p = Pattern.compile(stackTrace, Pattern.MULTILINE);
+        Matcher stdoutMatcher = p.matcher(output.getStdout());
+        Matcher stderrMatcher = p.matcher(output.getStderr());
         return (stdoutMatcher.find() || stderrMatcher.find());
     }
 }
--- a/test/hotspot/jtreg/runtime/Nestmates/membership/TestNestmateMembership.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/Nestmates/membership/TestNestmateMembership.java	Tue Apr 09 11:48:54 2019 +0100
@@ -671,7 +671,7 @@
     static void test_NoHostInvoke() throws Throwable {
         System.out.println("Testing for missing nest-host attribute");
         String msg = "class TestNestmateMembership$Caller tried to access " +
-            "private method TestNestmateMembership$TargetNoHost.m()V";
+            "private method 'void TestNestmateMembership$TargetNoHost.m()'";
         try {
             Caller.invokeTargetNoHost();
             throw new Error("Missing IllegalAccessError: " + msg);
@@ -698,7 +698,7 @@
         }
 
         msg = "class TestNestmateMembership$CallerNoHost tried to access " +
-            "private method TestNestmateMembership$Target.m()V";
+            "private method 'void TestNestmateMembership$Target.m()'";
         try {
             CallerNoHost.invokeTarget();
             throw new Error("Missing IllegalAccessError: " + msg);
@@ -707,7 +707,7 @@
             check_expected(expected, msg);
         }
         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
-            "method TestNestmateMembership$TargetNoHost.m()V";
+            "method 'void TestNestmateMembership$TargetNoHost.m()'";
         try {
             CallerNoHost.invokeTargetNoHost();
             throw new Error("Missing IllegalAccessError: " + msg);
@@ -950,7 +950,7 @@
     static void test_NoHostConstruct() throws Throwable {
         System.out.println("Testing for missing nest-host attribute");
         String msg = "class TestNestmateMembership$Caller tried to access private " +
-            "method TestNestmateMembership$TargetNoHost.<init>()V";
+            "method 'void TestNestmateMembership$TargetNoHost.<init>()'";
         try {
             Caller.newTargetNoHost();
             throw new Error("Missing IncompatibleClassChangeError: " + msg);
@@ -977,7 +977,7 @@
         }
 
         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
-            "method TestNestmateMembership$Target.<init>()V";
+            "method 'void TestNestmateMembership$Target.<init>()'";
         try {
             CallerNoHost.newTarget();
             throw new Error("Missing IncompatibleClassChangeError: " + msg);
@@ -986,7 +986,7 @@
             check_expected(expected, msg);
         }
         msg = "class TestNestmateMembership$CallerNoHost tried to access private " +
-            "method TestNestmateMembership$TargetNoHost.<init>()V";
+            "method 'void TestNestmateMembership$TargetNoHost.<init>()'";
         try {
             CallerNoHost.newTargetNoHost();
             throw new Error("Missing IncompatibleClassChangeError: " + msg);
--- a/test/hotspot/jtreg/runtime/Nestmates/privateConstructors/TestConstructorHierarchy.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/Nestmates/privateConstructors/TestConstructorHierarchy.java	Tue Apr 09 11:48:54 2019 +0100
@@ -51,7 +51,7 @@
             throw new Error("Unexpected construction of ExternalSuper");
         }
         catch (IllegalAccessError iae) {
-            if (iae.getMessage().contains("class TestConstructorHierarchy tried to access private method ExternalSuper.<init>()V")) {
+            if (iae.getMessage().contains("class TestConstructorHierarchy tried to access private method 'void ExternalSuper.<init>()'")) {
                 System.out.println("Got expected exception constructing ExternalSuper: " + iae);
             }
             else throw new Error("Unexpected IllegalAccessError: " + iae);
@@ -61,7 +61,7 @@
             throw new Error("Unexpected construction of NestedA and supers");
         }
         catch (IllegalAccessError iae) {
-            if (iae.getMessage().contains("class TestConstructorHierarchy$NestedA tried to access private method ExternalSuper.<init>()V")) {
+            if (iae.getMessage().contains("class TestConstructorHierarchy$NestedA tried to access private method 'void ExternalSuper.<init>()'")) {
                 System.out.println("Got expected exception constructing NestedA: " + iae);
             }
             else throw new Error("Unexpected IllegalAccessError: " + iae);
@@ -71,7 +71,7 @@
             throw new Error("Unexpected construction of ExternalSub");
         }
         catch (IllegalAccessError iae) {
-            if (iae.getMessage().contains("class ExternalSub tried to access private method TestConstructorHierarchy$NestedA.<init>()V")) {
+            if (iae.getMessage().contains("class ExternalSub tried to access private method 'void TestConstructorHierarchy$NestedA.<init>()'")) {
                 System.out.println("Got expected exception constructing ExternalSub: " + iae);
             }
             else throw new Error("Unexpected IllegalAccessError: " + iae);
--- a/test/hotspot/jtreg/runtime/SharedArchiveFile/serviceability/ReplaceCriticalClasses.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/serviceability/ReplaceCriticalClasses.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,15 @@
 
     public void process(String args[]) throws Throwable {
         if (args.length == 0) {
+            // Dump the shared archive in case it was not generated during the JDK build.
+            // Put the archive at separate file to avoid clashes with concurrent tests.
+            CDSOptions opts = new CDSOptions()
+                .setXShareMode("dump")
+                .setArchiveName(ReplaceCriticalClasses.class.getName() + ".jsa")
+                .setUseVersion(false)
+                .addSuffix("-showversion");
+            CDSTestUtils.run(opts).assertNormalExit("");
+
             launchChildProcesses(getTests());
         } else if (args.length == 3 && args[0].equals("child")) {
             Class klass = Class.forName(args[2].replace("/", "."));
@@ -152,7 +161,7 @@
 
         CDSOptions opts = (new CDSOptions())
             .setXShareMode("auto")
-            .setUseSystemArchive(true)
+            .setArchiveName(ReplaceCriticalClasses.class.getName() + ".jsa")
             .setUseVersion(false)
             .addSuffix("-showversion",
                        "-Xlog:cds",
--- a/test/hotspot/jtreg/runtime/appcds/TestCommon.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/TestCommon.java	Tue Apr 09 11:48:54 2019 +0100
@@ -145,6 +145,15 @@
         return executeAndLog(pb, "dump");
     }
 
+    // This allows you to run the AppCDS tests with JFR enabled at runtime (though not at
+    // dump time, as that's uncommon for typical AppCDS users).
+    //
+    // To run in this special mode, add the following to your jtreg command-line
+    //    -Dtest.cds.run.with.jfr=true
+    //
+    // Some AppCDS tests are not compatible with this mode. See the group
+    // hotspot_appcds_with_jfr in ../../TEST.ROOT for details.
+    private static final boolean RUN_WITH_JFR = Boolean.getBoolean("test.cds.run.with.jfr");
 
     // Execute JVM using AppCDS archive with specified AppCDSOptions
     public static OutputAnalyzer runWithArchive(AppCDSOptions opts)
@@ -166,6 +175,22 @@
 
         for (String s : opts.suffix) cmd.add(s);
 
+        if (RUN_WITH_JFR) {
+            boolean usesJFR = false;
+            for (String s : cmd) {
+                if (s.startsWith("-XX:StartFlightRecording=") || s.startsWith("-XX:FlightRecorderOptions")) {
+                    System.out.println("JFR option might have been specified. Don't interfere: " + s);
+                    usesJFR = true;
+                    break;
+                }
+            }
+            if (!usesJFR) {
+                System.out.println("JFR option not specified. Enabling JFR ...");
+                cmd.add(0, "-XX:StartFlightRecording=dumponexit=true");
+                System.out.println(cmd);
+            }
+        }
+
         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
         return executeAndLog(pb, "exec");
--- a/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom.java	Tue Apr 09 11:48:54 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
@@ -28,8 +28,6 @@
  * @requires vm.cds
  * @requires vm.cds.custom.loaders
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
- * @modules java.base/jdk.internal.misc
- *          java.management
  * @compile test-classes/Hello.java test-classes/CustomLoadee.java
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller -jar hello.jar Hello
@@ -43,6 +41,9 @@
 
 public class HelloCustom {
     public static void main(String[] args) throws Exception {
+        run();
+    }
+    public static void run(String... extra_runtime_args) throws Exception {
         String wbJar = ClassFileInstaller.getJarPath("WhiteBox.jar");
         String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar;
 
@@ -62,11 +63,12 @@
                             use_whitebox_jar);
 
         output = TestCommon.exec(appJar,
-                                 // command-line arguments ...
-                                 use_whitebox_jar,
-                                 "-XX:+UnlockDiagnosticVMOptions",
-                                 "-XX:+WhiteBoxAPI",
-                                 "Hello", customJarPath);
+                                 TestCommon.concat(extra_runtime_args,
+                                     // command-line arguments ...
+                                     use_whitebox_jar,
+                                     "-XX:+UnlockDiagnosticVMOptions",
+                                     "-XX:+WhiteBoxAPI",
+                                     "Hello", customJarPath));
         TestCommon.checkExec(output);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/appcds/customLoader/HelloCustom_JFR.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,50 @@
+/*
+ * 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
+ * @summary Same as HelloCustom, but add -XX:StartFlightRecording=dumponexit=true to the runtime
+ *          options. This makes sure that the shared classes are compatible with both
+ *          JFR and JVMTI ClassFileLoadHook.
+ * @requires vm.hasJFR
+ * @requires vm.cds
+ * @requires vm.cds.custom.loaders
+ * @library /test/lib /test/hotspot/jtreg/runtime/appcds
+ * @compile test-classes/Hello.java test-classes/CustomLoadee.java
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller -jar hello.jar Hello
+ * @run driver ClassFileInstaller -jar hello_custom.jar CustomLoadee
+ * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
+ * @run driver HelloCustom_JFR
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import sun.hotspot.WhiteBox;
+
+public class HelloCustom_JFR {
+    public static void main(String[] args) throws Exception {
+        HelloCustom.run("-XX:StartFlightRecording=dumponexit=true", "-Xlog:cds+jvmti=debug");
+    }
+}
+
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java	Tue Apr 09 11:48:54 2019 +0100
@@ -93,6 +93,10 @@
     }
 
     public static void main(String... args) throws Exception {
+        run();
+    }
+
+    public static void run(String... extra_runtime_args) throws Exception {
         // compile the modules and create the modular jar files
         buildTestModule();
         String appClasses[] = {MAIN_CLASS, APP_CLASS};
@@ -104,6 +108,7 @@
                                         "-m", MAIN_MODULE);
         TestCommon.checkDump(output);
         String prefix[] = {"-Djava.class.path=", "-Xlog:class+load=trace"};
+        prefix = TestCommon.concat(prefix, extra_runtime_args);
 
         // run with the archive with the --module-path the same as the one during
         // dump time. The classes should be loaded from the archive.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP_JFR.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,43 @@
+/*
+ * 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 vm.hasJFR & vm.cds
+ * @library /test/lib /test/hotspot/jtreg/runtime/appcds
+ * @modules jdk.compiler
+ *          jdk.jartool/sun.tools.jar
+ *          jdk.jlink
+ * @run driver ModulePathAndCP_JFR
+ * @summary Same as ModulePathAndCP, but add -XX:StartFlightRecording=dumponexit=true to the runtime
+ *          options. This makes sure that the shared classes are compatible with both
+ *          JFR and JVMTI ClassFileLoadHook.
+ */
+
+public class ModulePathAndCP_JFR {
+    public static void main(String... args) throws Exception {
+        ModulePathAndCP.run("-XX:StartFlightRecording=dumponexit=true", "-Xlog:cds+jvmti=debug");
+    }
+}
+
--- a/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java	Tue Apr 09 11:48:54 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
@@ -41,8 +41,14 @@
         SHARING_ON_CFLH_ON
     }
 
-    public static void main(String args[]) {
+    public static void main(String args[]) throws Exception {
         TestCaseId testCase = TestCaseId.valueOf(args[0]);
+        test1(testCase);
+        test2(testCase);
+    }
+
+    // Test rewriting the classfile data using CFLH
+    static void test1(TestCaseId testCase) {
         WhiteBox wb = WhiteBox.getWhiteBox();
 
         System.out.println("====== ClassFileLoadHook.main():testCase = " + testCase);
@@ -81,6 +87,20 @@
         }
     }
 
+    // Test the loading of classfile data for non-boot shared classes from jrt:/xxx.
+    // See JDK-8221351.
+    static void test2(TestCaseId testCase) throws Exception {
+        WhiteBox wb = WhiteBox.getWhiteBox();
+        Class c = Class.forName("java.sql.SQLException"); // defined by platform class loader.
+
+        switch (testCase) {
+        case SHARING_ON_CFLH_OFF:
+        case SHARING_AUTO_CFLH_ON:
+        case SHARING_ON_CFLH_ON:
+            assertTrue(wb.isSharedClass(c), "must be shared");
+        }
+    }
+
     private static void assertTrue(boolean expr, String msg) {
         if (!expr)
             throw new RuntimeException(msg);
--- a/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java	Tue Apr 09 11:48:54 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
@@ -27,9 +27,6 @@
  * @summary Test jvmti class file loader hook interaction with AppCDS
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @requires vm.cds
- * @modules java.base/jdk.internal.misc
- *          jdk.jartool/sun.tools.jar
- *          java.management
  * @build ClassFileLoadHook
  * @run main/othervm/native ClassFileLoadHookTest
  */
@@ -46,7 +43,8 @@
         "ClassFileLoadHook",
         "ClassFileLoadHook$TestCaseId",
         "ClassFileLoadHook$1",
-        "LoadMe"
+        "LoadMe",
+        "java/sql/SQLException"
     };
 
     public static void main(String[] args) throws Exception {
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/HelloStringPlus.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/HelloStringPlus.java	Tue Apr 09 11:48:54 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
@@ -66,8 +66,8 @@
         // Check intern() method for "" string
         String empty = "";
         String empty_interned = empty.intern();
-        if (wb.isShared(empty)) {
-           throw new RuntimeException("Empty string should not be shared");
+        if (!wb.isShared(empty)) {
+           throw new RuntimeException("Empty string should be shared");
         }
         if (empty_interned != empty) {
             throw new RuntimeException("Different string is returned from intern() for empty string");
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/LockStringTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/LockStringTest.java	Tue Apr 09 11:48:54 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,19 +25,49 @@
 import sun.hotspot.WhiteBox;
 
 public class LockStringTest extends Thread {
-    static String lock = "StringLock";
-    static boolean done = false;
+    static String lock;
+    static boolean done;
+    static WhiteBox wb = WhiteBox.getWhiteBox();
 
     public static void main(String[] args) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
+
         if (wb.areSharedStringsIgnored()) {
             System.out.println("The shared strings are ignored");
             System.out.println("LockStringTest: PASS");
             return;
         }
 
+        if (!wb.isShared(LockStringTest.class)) {
+            throw new RuntimeException("Failed: LockStringTest class is not shared.");
+        }
+
+        // Note: This class is archived. All string literals (including the ones used in this class)
+        // in all archived classes are interned into the CDS shared string table.
+
+        doTest("StringLock", false);
+        doTest("", true);
+
+        // The following string has a 0 hashCode. Calling String.hashCode() could cause
+        // the String.hash field to be written into, if so make sure we don't functionally
+        // break.
+        doTest("\u0121\u0151\u00a2\u0001\u0001\udbb2", true);
+    }
+
+    private static void doTest(String s, boolean hasZeroHashCode) throws Exception {
+        lock = s;
+        done = false;
+
         if (!wb.isShared(lock)) {
-            throw new RuntimeException("Failed: String is not shared.");
+            throw new RuntimeException("Failed: String \"" + lock + "\" is not shared.");
+        }
+
+        if (hasZeroHashCode && lock.hashCode() != 0) {
+            throw new RuntimeException("Shared string \"" + lock + "\" should have 0 hashCode, but is instead " + lock.hashCode());
+        }
+
+        String copy = new String(lock);
+        if (lock.hashCode() != copy.hashCode()) {
+            throw new RuntimeException("Shared string \"" + lock + "\" does not have the same hashCode as its non-shared copy");
         }
 
         new LockStringTest().start();
--- a/test/hotspot/jtreg/runtime/containers/docker/DockerBasicTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/containers/docker/DockerBasicTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -42,8 +42,6 @@
 
 public class DockerBasicTest {
     private static final String imageNameAndTag = Common.imageName("basic");
-    // Diganostics: set to false to examine image after the test
-    private static final boolean removeImageAfterTest = true;
 
     public static void main(String[] args) throws Exception {
         if (!DockerTestUtils.canTestDocker()) {
@@ -56,8 +54,9 @@
             testJavaVersion();
             testHelloDocker();
         } finally {
-            if (removeImageAfterTest)
+            if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) {
                 DockerTestUtils.removeDockerImage(imageNameAndTag);
+            }
         }
     }
 
--- a/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -99,11 +99,11 @@
     }
 
     private static String expectedErrorMessageAME1_1 =
-        "Missing implementation of resolved method abstract " +
-        "anAbstractMethod()Ljava/lang/String; of abstract class AME1_B.";
+        "Missing implementation of resolved method 'abstract " +
+        "java.lang.String anAbstractMethod()' of abstract class AME1_B.";
     private static String expectedErrorMessageAME1_2 =
         "Receiver class AME1_E does not define or inherit an implementation of the " +
-        "resolved method abstract aFunctionOfMyInterface()Ljava/lang/String; of " +
+        "resolved method 'abstract java.lang.String aFunctionOfMyInterface()' of " +
         "interface AME1_C.";
 
     public static void test_ame1() {
@@ -158,11 +158,11 @@
     }
 
     private static String expectedErrorMessageAME2_Interpreted =
-        "Missing implementation of resolved method abstract " +
-        "aFunctionOfMyInterface()V of interface AME2_A.";
+        "Missing implementation of resolved method 'abstract " +
+        "void aFunctionOfMyInterface()' of interface AME2_A.";
     private static String expectedErrorMessageAME2_Compiled =
         "Receiver class AME2_C does not define or inherit an implementation of the resolved method " +
-        "abstract aFunctionOfMyInterface()V of interface AME2_A.";
+        "'abstract void aFunctionOfMyInterface()' of interface AME2_A.";
 
     public AbstractMethodErrorTest() throws InstantiationException, IllegalAccessException {
         try {
@@ -228,7 +228,7 @@
 
     private static String expectedErrorMessageAME3_1 =
         "Receiver class AME3_C does not define or inherit an implementation of the resolved method " +
-        "ma()V of class AME3_A. Selected method is abstract AME3_B.ma()V.";
+        "'void ma()' of class AME3_A. Selected method is 'abstract void AME3_B.ma()'.";
 
     // Testing abstract class that extends a class that has an implementation.
     // Loop so that method gets eventually compiled/osred.
@@ -259,7 +259,7 @@
 
     private static String expectedErrorMessageAME3_2 =
         "Receiver class AME3_C does not define or inherit an implementation of " +
-        "the resolved method abstract ma()V of abstract class AME3_B.";
+        "the resolved method 'abstract void ma()' of abstract class AME3_B.";
 
     // Testing abstract class that extends a class that has an implementation.
     // Loop so that method gets eventually compiled/osred.
@@ -289,7 +289,7 @@
     }
 
     private static String expectedErrorMessageAME4 =
-        "Missing implementation of resolved method abstract ma()V of " +
+        "Missing implementation of resolved method 'abstract void ma()' of " +
         "abstract class AME4_B.";
 
     // Testing abstract class that extends a class that has an implementation.
@@ -336,7 +336,7 @@
     }
 
     private static String expectedErrorMessageAME5_VtableStub =
-        "Receiver class AME5_B does not define or inherit an implementation of the resolved method abstract mc()V " +
+        "Receiver class AME5_B does not define or inherit an implementation of the resolved method 'abstract void mc()' " +
         "of abstract class AME5_A.";
 
     // AbstractMethodErrors detected in vtable stubs.
@@ -409,7 +409,7 @@
 
     private static String expectedErrorMessageAME6_ItableStub =
         "Receiver class AME6_B does not define or inherit an implementation of the resolved" +
-        " method abstract mc()V of interface AME6_A.";
+        " method 'abstract void mc()' of interface AME6_A.";
 
     // -------------------------------------------------------------------------
     // AbstractMethodErrors detected in itable stubs.
--- a/test/hotspot/jtreg/runtime/exceptionMsgs/IllegalAccessError/IllegalAccessErrorTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/IllegalAccessError/IllegalAccessErrorTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -141,7 +141,7 @@
     private static void iae4_m() { }
 
     private static String expectedErrorMessage4 =
-        "class test.Runner4 tried to access private method test.IllegalAccessErrorTest.iae4_m()V " +
+        "class test.Runner4 tried to access private method 'void test.IllegalAccessErrorTest.iae4_m()' " +
         "(test.Runner4 and test.IllegalAccessErrorTest are in unnamed module of loader 'app')";
 
     // Test according to java/lang/invoke/DefineClassTest.java
@@ -264,7 +264,7 @@
     }
 
     private static String expectedErrorMessage7_1 =
-        "class test.IAE78_B tried to access method test.IAE78_A.<init>()V " +
+        "class test.IAE78_B tried to access method 'void test.IAE78_A.<init>()' " +
         "(test.IAE78_B is in unnamed module of loader 'test7_method_CL' @";
     private static String expectedErrorMessage7_2 =
         "; test.IAE78_A is in unnamed module of loader 'app')";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/NoClassDefFoundError/NoClassDefFoundErrorTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,97 @@
+/*
+ * 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
+ * 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 8056900
+ * @summary Verifies message returned with NoClassDefFoundError exception.
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.compiler
+ * @run main/native NoClassDefFoundErrorTest
+ */
+
+import jdk.test.lib.compiler.InMemoryJavaCompiler;
+import jdk.internal.misc.Unsafe;
+
+public class NoClassDefFoundErrorTest {
+
+    static native void callDefineClass(String className);
+    static native void callFindClass(String className);
+    static {
+        System.loadLibrary("NoClassDefFoundErrorTest");
+    }
+
+
+    public static void main(String args[]) throws Exception {
+        Unsafe unsafe = Unsafe.getUnsafe();
+
+        byte klassbuf[] = InMemoryJavaCompiler.compile("TestClass", "class TestClass { }");
+
+        // Create a class name of length 65536.
+        StringBuilder tooBigClassName = new StringBuilder("z");
+        for (int x = 0; x < 16; x++) {
+            tooBigClassName = tooBigClassName.append(tooBigClassName);
+        }
+
+        // Test JVM_DefineClass() with long name.
+        try {
+            unsafe.defineClass(tooBigClassName.toString(), klassbuf, 4, klassbuf.length - 4, null, null);
+            throw new RuntimeException("defineClass did not throw expected NoClassDefFoundError");
+        } catch (NoClassDefFoundError e) {
+            if (!e.getMessage().contains("Class name exceeds maximum length of ")) {
+                throw new RuntimeException("Wrong NoClassDefFoundError: " + e.getMessage());
+            }
+        }
+
+        // Test JNI_DefineClass() with long name.
+        try {
+            callDefineClass(tooBigClassName.toString());
+            throw new RuntimeException("DefineClass did not throw expected NoClassDefFoundError");
+        } catch (NoClassDefFoundError e) {
+            if (!e.getMessage().contains("Class name exceeds maximum length of ")) {
+                throw new RuntimeException("Wrong NoClassDefFoundError: " + e.getMessage());
+            }
+        }
+
+        // Test JNI_FindClass() with long name.
+        try {
+            callFindClass(tooBigClassName.toString());
+            throw new RuntimeException("DefineClass did not throw expected NoClassDefFoundError");
+        } catch (NoClassDefFoundError e) {
+            if (!e.getMessage().contains("Class name exceeds maximum length of ")) {
+                throw new RuntimeException("Wrong NoClassDefFoundError: " + e.getMessage());
+            }
+        }
+
+        // Test JNI_FindClass() with null name.
+        try {
+            callFindClass(null);
+            throw new RuntimeException("FindClass did not throw expected NoClassDefFoundError");
+        } catch (NoClassDefFoundError e) {
+            if (!e.getMessage().contains("No class name given")) {
+                throw new RuntimeException("Wrong NoClassDefFoundError: " + e.getMessage());
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/NoClassDefFoundError/libNoClassDefFoundErrorTest.c	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * 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 <jni.h>
+
+JNIEXPORT void JNICALL
+Java_NoClassDefFoundErrorTest_callDefineClass(JNIEnv *env, jclass klass, jstring className) {
+    const char *c_name = (*env)->GetStringUTFChars(env, className, NULL);
+    (*env)->DefineClass(env, c_name, NULL, NULL, 0);
+}
+
+JNIEXPORT void JNICALL
+Java_NoClassDefFoundErrorTest_callFindClass(JNIEnv *env, jclass klass, jstring className) {
+    const char *c_name;
+    jclass cls;
+    if (className == NULL) {
+        c_name = NULL;
+    } else {
+        c_name = (*env)->GetStringUTFChars(env, className, NULL);
+    }
+    cls = (*env)->FindClass(env, c_name);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/methodPrinting/TeMe3_C.jasm	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+package test;
+
+/* Method ma() is missing in this implementation to cause error. */
+
+class TeMe3_C extends TeMe3_B {
+    public Method "<init>":"()V"
+        stack 1 locals 1
+    {
+        aload_0;
+        invokespecial Method TeMe3_B."<init>":()V;
+        return;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/methodPrinting/TestPrintingMethods.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,151 @@
+/*
+ * 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 Check that methods are printed properly.
+ * @compile -encoding UTF-8 TestPrintingMethods.java
+ * @compile TeMe3_C.jasm
+ * @run main/othervm -Xbootclasspath/a:. test.TestPrintingMethods
+ */
+
+package test;
+
+public class TestPrintingMethods {
+
+    private static String expectedErrorMessage_VV       = "void test.TeMe3_B.ma()";
+    private static String expectedErrorMessage_integral = "double[][] test.TeMe3_B.ma(int, boolean, byte[][], float)";
+    private static String expectedErrorMessage_classes  = "test.TeMe3_B[][] test.TeMe3_B.ma(java.lang.Object[][][])";
+    private static String expectedErrorMessage_unicode  = "java.lang.Object test.TeMe3_B.m\u20ac\u00a3a(java.lang.Object)";
+
+    static void checkMsg(Error e, String expected) throws Exception {
+        String errorMsg = e.getMessage();
+        if (errorMsg == null) {
+            throw new RuntimeException("Caught AbstractMethodError with empty message.");
+        } else if (errorMsg.contains(expected)) {
+            System.out.println("Passed with message: " + errorMsg);
+        } else {
+            System.out.println("Expected method to be printed as \"" + expected + "\"\n" +
+                               "in exception message:  " + errorMsg);
+            throw new RuntimeException("Method not printed as expected.");
+        }
+    }
+
+    // Call various missing methods to check that the exception
+    // message contains the proper string for the method name and
+    // signature. We expect Java-like printing of parameters etc.
+    static void test() throws Exception {
+        TeMe3_A c = new TeMe3_C();
+
+        try {
+            c.ma();
+            throw new RuntimeException("Expected AbstractMethodError was not thrown.");
+        } catch (AbstractMethodError e) {
+            checkMsg(e, expectedErrorMessage_VV);
+        }
+
+        try {
+            c.ma(2, true, new byte[2][3], 23.4f);
+            throw new RuntimeException("Expected AbstractMethodError was not thrown.");
+        } catch (AbstractMethodError e) {
+            checkMsg(e, expectedErrorMessage_integral);
+        }
+
+        try {
+            c.ma(new java.lang.Object[1][2][3]);
+            throw new RuntimeException("Expected AbstractMethodError was not thrown.");
+        } catch (AbstractMethodError e) {
+            checkMsg(e, expectedErrorMessage_classes);
+        }
+
+        try {
+            c.m\u20ac\u00a3a(new java.lang.Object());
+            throw new RuntimeException("Expected AbstractMethodError was not thrown.");
+        } catch (AbstractMethodError e) {
+            checkMsg(e, expectedErrorMessage_unicode);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        test();
+    }
+}
+
+// Helper classes to test abstract method error.
+//
+// Errorneous versions of these classes are implemented in java
+// assembler.
+
+
+// -----------------------------------------------------------------------
+// Test AbstractMethod error shadowing existing implementation.
+//
+// Class hierachy:
+//
+//           A           // A class implementing m() and similar.
+//           |
+//           B           // An abstract class defining m() abstract.
+//           |
+//           C           // An errorneous class lacking an implementation of m().
+//
+class TeMe3_A {
+    public void ma() {
+        System.out.print("A.ma()");
+    }
+    public double[][] ma(int i, boolean z, byte[][] b, float f) {
+        return null;
+    }
+    public TeMe3_B[][] ma(java.lang.Object[][][] o) {
+        return null;
+    }
+    public java.lang.Object m\u20ac\u00a3a(java.lang.Object s) {
+        return null;
+    }
+}
+
+abstract class TeMe3_B extends TeMe3_A {
+    public abstract void ma();
+    public abstract double[][] ma(int i, boolean z, byte[][] b, float f);
+    public abstract TeMe3_B[][] ma(java.lang.Object[][][] o);
+    public abstract java.lang.Object m\u20ac\u00a3a(java.lang.Object s);
+}
+
+// An errorneous version of this class is implemented in java
+// assembler.
+class TeMe3_C extends TeMe3_B {
+    // These methods are missing in the .jasm implementation.
+    public void ma() {
+        System.out.print("C.ma()");
+    }
+    public double[][] ma(int i, boolean z, byte[][] b, float f) {
+        return new double[2][2];
+    }
+    public TeMe3_B[][] ma(java.lang.Object[][][] o) {
+        return new TeMe3_C[3][3];
+    }
+    public java.lang.Object m\u20ac\u00a3a(java.lang.Object s) {
+        return new java.lang.Object();
+    }
+}
+
--- a/test/hotspot/jtreg/runtime/modules/AccessCheck/ExpQualToM1PrivateMethodIAE.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/runtime/modules/AccessCheck/ExpQualToM1PrivateMethodIAE.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -103,7 +103,7 @@
             // java.lang.IllegalAccessError:
             //   tried to access private method p2.c2.method2()V from class p1.c1 (p2.c2 is in module m2x of loader
             //   myloaders.MySameClassLoader @<id>; p1.c1 is in module m1x of loader myloaders.MySameClassLoader @<id>)
-            if (!message.contains("class p1.c1 tried to access private method p2.c2.method2()V " +
+            if (!message.contains("class p1.c1 tried to access private method 'void p2.c2.method2()' " +
                                   "(p1.c1 is in module m1x of loader myloaders.MySameClassLoader @") ||
                 !message.contains("; p2.c2 is in module m2x of loader myloaders.MySameClassLoader @")) {
               throw new RuntimeException("Test Failed, an IAE was thrown with the wrong message: " + e.toString());
--- a/test/hotspot/jtreg/runtime/noClassDefFoundMsg/NoClassDefFoundMsg.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2017, 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 8056900
- * @summary Verifies message returned with NoClassDefFoundError exception.
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.compiler
- * @run main/native NoClassDefFoundMsg
- */
-
-import jdk.test.lib.compiler.InMemoryJavaCompiler;
-import jdk.internal.misc.Unsafe;
-
-public class NoClassDefFoundMsg {
-
-    static native void callDefineClass(String className);
-    static native void callFindClass(String className);
-    static {
-        System.loadLibrary("NoClassDefFoundMsg");
-    }
-
-
-    public static void main(String args[]) throws Exception {
-        Unsafe unsafe = Unsafe.getUnsafe();
-
-        byte klassbuf[] = InMemoryJavaCompiler.compile("TestClass", "class TestClass { }");
-
-        // Create a class name of length 65536.
-        StringBuilder tooBigClassName = new StringBuilder("z");
-        for (int x = 0; x < 16; x++) {
-            tooBigClassName = tooBigClassName.append(tooBigClassName);
-        }
-
-        // Test JVM_DefineClass() with long name.
-        try {
-            unsafe.defineClass(tooBigClassName.toString(), klassbuf, 4, klassbuf.length - 4, null, null);
-            throw new RuntimeException("defineClass did not throw expected NoClassDefFoundError");
-        } catch (NoClassDefFoundError e) {
-            if (!e.getMessage().contains("Class name exceeds maximum length of ")) {
-                throw new RuntimeException("Wrong NoClassDefFoundError: " + e.getMessage());
-            }
-        }
-
-        // Test JNI_DefineClass() with long name.
-        try {
-            callDefineClass(tooBigClassName.toString());
-            throw new RuntimeException("DefineClass did not throw expected NoClassDefFoundError");
-        } catch (NoClassDefFoundError e) {
-            if (!e.getMessage().contains("Class name exceeds maximum length of ")) {
-                throw new RuntimeException("Wrong NoClassDefFoundError: " + e.getMessage());
-            }
-        }
-
-        // Test JNI_FindClass() with long name.
-        try {
-            callFindClass(tooBigClassName.toString());
-            throw new RuntimeException("DefineClass did not throw expected NoClassDefFoundError");
-        } catch (NoClassDefFoundError e) {
-            if (!e.getMessage().contains("Class name exceeds maximum length of ")) {
-                throw new RuntimeException("Wrong NoClassDefFoundError: " + e.getMessage());
-            }
-        }
-
-        // Test JNI_FindClass() with null name.
-        try {
-            callFindClass(null);
-            throw new RuntimeException("FindClass did not throw expected NoClassDefFoundError");
-        } catch (NoClassDefFoundError e) {
-            if (!e.getMessage().contains("No class name given")) {
-                throw new RuntimeException("Wrong NoClassDefFoundError: " + e.getMessage());
-            }
-        }
-    }
-}
--- a/test/hotspot/jtreg/runtime/noClassDefFoundMsg/libNoClassDefFoundMsg.c	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017, 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 <jni.h>
-
-JNIEXPORT void JNICALL
-Java_NoClassDefFoundMsg_callDefineClass(JNIEnv *env, jclass klass, jstring className) {
-    const char *c_name = (*env)->GetStringUTFChars(env, className, NULL);
-    (*env)->DefineClass(env, c_name, NULL, NULL, 0);
-}
-
-JNIEXPORT void JNICALL
-Java_NoClassDefFoundMsg_callFindClass(JNIEnv *env, jclass klass, jstring className) {
-    const char *c_name;
-    jclass cls;
-    if (className == NULL) {
-        c_name = NULL;
-    } else {
-        c_name = (*env)->GetStringUTFChars(env, className, NULL);
-    }
-    cls = (*env)->FindClass(env, c_name);
-}
-
-
--- a/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/serviceability/dcmd/framework/HelpTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -75,6 +75,6 @@
         run(new JMXExecutor());
     }
 
-    private static class Process extends TestJavaProcess {
+    private static class Process extends process.TestJavaProcess {
     }
 }
--- a/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/serviceability/dcmd/framework/InvalidCommandTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -73,6 +73,6 @@
         run(new JMXExecutor());
     }
 
-    private static class Process extends TestJavaProcess {
+    private static class Process extends process.TestJavaProcess {
     }
 }
--- a/test/hotspot/jtreg/serviceability/dcmd/framework/TestJavaProcess.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +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.
- */
-
-import nsk.share.jpda.*;
-import nsk.share.jdi.*;
-
-/**
- * A simple process that connects to a pipe and waits for command "quit" to
- * be received.
- *
- * Usage: java TestJavaProcess -pipe.port <PIPE_PORT_NUMBER>
- */
-
-public class TestJavaProcess {
-
-    static final int PASSED = 0;
-    static final int FAILED = 2;
-
-    public static void main(String argv[]) {
-
-        log("Test Java process started!");
-
-        ArgumentHandler argHandler = new ArgumentHandler(argv);
-        IOPipe pipe = argHandler.createDebugeeIOPipe();
-        pipe.println("ready");
-        log("Waiting for the quit command from the test ...");
-        String cmd = pipe.readln();
-        int exitCode = PASSED;
-        if (cmd.equals("quit")) {
-            log("'quit' received");
-        } else {
-            log("Invalid command received " + cmd);
-            exitCode = FAILED;
-        }
-        System.exit(exitCode);
-    }
-
-    private static void log(String message) {
-        System.out.println(message);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessJarLauncher.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,73 @@
+/*
+ * 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 jdk.test.lib.util.JarUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/**
+ * Launches a new Java process using -jar Java option.
+ */
+
+public class TestProcessJarLauncher extends TestProcessLauncher {
+
+    private static final String JAR_FILE = "testprocess.jar";
+
+
+    public TestProcessJarLauncher(String className) {
+        super(className);
+    }
+
+    protected String prepareLaunch(String javaExec, String pipePort) {
+        try {
+            File jarFile = prepareJar();
+            return javaExec + " -jar " + jarFile.getAbsolutePath() + " -pipe.port=" + pipePort;
+        } catch (IOException e) {
+            throw new RuntimeException("Failed to prepare a jar file", e);
+        }
+    }
+
+    private File prepareJar() throws IOException {
+        Path jarFile = USER_DIR.resolve(JAR_FILE);
+        Manifest manifest = createManifest();
+        Path testClass = TEST_CLASSES_DIR.resolve(className + ".class");
+        JarUtils.createJarFile(jarFile, manifest, TEST_CLASSES_DIR, Paths.get("."));
+        return jarFile.toFile();
+    }
+
+    private Manifest createManifest() {
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, className);
+        return manifest;
+    }
+
+    public String getJarFile() {
+        return JAR_FILE;
+    }
+}
--- a/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java	Tue Apr 09 11:48:54 2019 +0100
@@ -26,6 +26,9 @@
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
 
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+
 /**
  * Launches a new Java process that uses a communication pipe to interact
  * with the test.
@@ -33,7 +36,10 @@
 
 public class TestProcessLauncher {
 
-    private final String className;
+    protected static final Path USER_DIR = FileSystems.getDefault().getPath(System.getProperty("user.dir", "."));
+    protected static final Path TEST_CLASSES_DIR = FileSystems.getDefault().getPath(System.getProperty("test.classes"));
+
+    protected final String className;
     private final ArgumentHandler argHandler;
 
     private IOPipe pipe;
@@ -55,7 +61,7 @@
         Binder binder = new Binder(argHandler, log);
         binder.prepareForPipeConnection(argHandler);
 
-        String cmd = java + " " + className + " -pipe.port=" + argHandler.getPipePort();
+        String cmd = prepareLaunch(java, argHandler.getPipePort());
 
         Debugee debuggee = binder.startLocalDebugee(cmd);
         debuggee.redirectOutput(log);
@@ -75,4 +81,8 @@
         }
     }
 
+    protected String prepareLaunch(String javaExec, String pipePort) {
+        return  javaExec + " " + className + " -pipe.port=" + pipePort;
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,125 @@
+/*
+ * 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 jdk.internal.module.ModuleInfoWriter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.module.ModuleDescriptor;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.stream.Stream;
+
+/*
+ * Launches a new Java process with a main class packed inside a module.
+ */
+
+public class TestProcessModuleLauncher extends TestProcessLauncher {
+
+    private static final Path TEST_MODULES = USER_DIR.resolve("testmodules");
+    private static final String MODULE_NAME = "module1";
+
+    public TestProcessModuleLauncher(String className) {
+        super(className);
+    }
+
+    protected String prepareLaunch(String javaExec, String pipePort) {
+        try {
+            prepareModule();
+            return javaExec + " --module-path " + TEST_MODULES.toFile().getAbsolutePath() +
+                    " -m " + MODULE_NAME + "/" + className + " -pipe.port=" + pipePort;
+        } catch (IOException e) {
+            throw new RuntimeException("Failed to prepare a jar file", e);
+        }
+    }
+
+    private void prepareModule() throws IOException {
+        TEST_MODULES.toFile().mkdirs();
+        Path moduleJar = TEST_MODULES.resolve("mod1.jar");
+        ModuleDescriptor md = createModuleDescriptor();
+        createModuleJarFile(moduleJar, md, TEST_CLASSES_DIR, Paths.get("."));
+    }
+
+    private ModuleDescriptor createModuleDescriptor() {
+        ModuleDescriptor.Builder builder
+                = ModuleDescriptor.newModule(MODULE_NAME).requires("java.base");
+        return builder.build();
+    }
+
+    private static void createModuleJarFile(Path jarfile, ModuleDescriptor md, Path dir, Path... files)
+            throws IOException {
+
+        Path parent = jarfile.getParent();
+        if (parent != null) {
+            Files.createDirectories(parent);
+        }
+
+        List<Path> entries = findAllRegularFiles(dir, files);
+
+        try (OutputStream out = Files.newOutputStream(jarfile);
+             JarOutputStream jos = new JarOutputStream(out)) {
+            if (md != null) {
+                JarEntry je = new JarEntry("module-info.class");
+                jos.putNextEntry(je);
+                ModuleInfoWriter.write(md, jos);
+                jos.closeEntry();
+            }
+
+            for (Path entry : entries) {
+                String name = toJarEntryName(entry);
+                jos.putNextEntry(new JarEntry(name));
+                Files.copy(dir.resolve(entry), jos);
+                jos.closeEntry();
+            }
+        }
+    }
+
+    private static String toJarEntryName(Path file) {
+        Path normalized = file.normalize();
+        return normalized.subpath(0, normalized.getNameCount())
+                .toString()
+                .replace(File.separatorChar, '/');
+    }
+
+    private static List<Path> findAllRegularFiles(Path dir, Path[] files) throws IOException {
+        List<Path> entries = new ArrayList<>();
+        for (Path file : files) {
+            try (Stream<Path> stream = Files.find(dir.resolve(file), Integer.MAX_VALUE,
+                    (p, attrs) -> attrs.isRegularFile() && !p.getParent().equals(dir.resolve(".")))) {
+                stream.map(dir::relativize)
+                        .forEach(entries::add);
+            }
+        }
+        return entries;
+    }
+
+    public String getModuleName() {
+        return MODULE_NAME;
+    }
+}
--- a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -33,17 +33,21 @@
 
 /*
  * @test
+ * @bug 8221730
  * @summary Test of diagnostic command VM.version (tests all DCMD executors)
  * @library /test/lib
  *          /vmTestbase
- * @build   TestJavaProcess
  * @modules java.base/jdk.internal.misc
+ *          java.base/jdk.internal.module
  *          java.compiler
  *          java.management
  *          jdk.internal.jvmstat/sun.jvmstat.monitor
  * @run testng/othervm -XX:+UsePerfData VMVersionTest
  */
 public class VMVersionTest {
+
+    private static final String TEST_PROCESS_CLASS_NAME = process.TestJavaProcess.class.getName();
+
     public void run(CommandExecutor executor) {
         OutputAnalyzer output = executor.execute("VM.version");
         output.shouldMatch(".*(?:HotSpot|OpenJDK).*VM.*");
@@ -56,10 +60,34 @@
 
     @Test
     public void mainClass() {
-        TestProcessLauncher t = new TestProcessLauncher(Process.class.getName());
+        TestProcessLauncher t = new TestProcessLauncher(TEST_PROCESS_CLASS_NAME);
+        try {
+            t.launch();
+            run(new MainClassJcmdExecutor(TEST_PROCESS_CLASS_NAME));
+        } finally {
+            t.quit();
+        }
+    }
+
+    @Test
+    public void mainClassForJar() {
+        TestProcessJarLauncher t = new TestProcessJarLauncher(TEST_PROCESS_CLASS_NAME);
         try {
             t.launch();
-            run(new MainClassJcmdExecutor(Process.class.getName()));
+            String jarFile = t.getJarFile();
+            run(new MainClassJcmdExecutor(jarFile));
+        } finally {
+            t.quit();
+        }
+    }
+
+    @Test
+    public void mainClassForModule() {
+        TestProcessModuleLauncher t = new TestProcessModuleLauncher(TEST_PROCESS_CLASS_NAME);
+        try {
+            t.launch();
+            String moduleName = t.getModuleName();
+            run(new MainClassJcmdExecutor(moduleName));
         } finally {
             t.quit();
         }
@@ -75,5 +103,4 @@
         run(new JMXExecutor());
     }
 
-    private static class Process extends TestJavaProcess{}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/dcmd/framework/process/TestJavaProcess.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,63 @@
+/*
+ * 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 process;
+
+import nsk.share.jdi.ArgumentHandler;
+import nsk.share.jpda.IOPipe;
+
+/**
+ * A simple process that connects to a pipe and waits for command "quit" to
+ * be received.
+ *
+ * Usage: java TestJavaProcess -pipe.port <PIPE_PORT_NUMBER>
+ */
+
+public class TestJavaProcess {
+
+    static final int PASSED = 0;
+    static final int FAILED = 2;
+
+    public static void main(String argv[]) {
+
+        log("Test Java process started!");
+
+        ArgumentHandler argHandler = new ArgumentHandler(argv);
+        IOPipe pipe = argHandler.createDebugeeIOPipe();
+        pipe.println("ready");
+        log("Waiting for the quit command from the test ...");
+        String cmd = pipe.readln();
+        int exitCode = PASSED;
+        if (cmd.equals("quit")) {
+            log("'quit' received");
+        } else {
+            log("Invalid command received " + cmd);
+            exitCode = FAILED;
+        }
+        System.exit(exitCode);
+    }
+
+    private static void log(String message) {
+        System.out.println(message);
+    }
+}
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java	Tue Apr 09 11:48:54 2019 +0100
@@ -35,7 +35,6 @@
  * @bug 8191658
  * @summary Test clhsdb jhisto command
  * @requires vm.hasSA
- * @requires vm.gc != "Shenandoah"
  * @library /test/lib
  * @run main/othervm ClhsdbJhisto
  */
--- a/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForLargeArray.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForLargeArray.java	Tue Apr 09 11:48:54 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
@@ -47,7 +47,6 @@
  * @library /test/lib
  * @bug 8171084
  * @requires vm.hasSAandCanAttach & (vm.bits == "64" & os.maxMemory > 8g)
- * @requires vm.gc != "Shenandoah"
  * @modules java.base/jdk.internal.misc
  *          jdk.hotspot.agent/sun.jvm.hotspot
  *          jdk.hotspot.agent/sun.jvm.hotspot.utilities
@@ -96,10 +95,13 @@
         }
 
         try {
+            // Need to add the default arguments first to have explicit
+            // -Xmx8g last, otherwise test will fail if default
+            // arguments contain a smaller -Xmx.
             List<String> vmArgs = new ArrayList<String>();
+            vmArgs.addAll(Utils.getVmOptions());
             vmArgs.add("-XX:+UsePerfData");
             vmArgs.add("-Xmx8g");
-            vmArgs.addAll(Utils.getVmOptions());
 
             theApp = new LingeredAppWithLargeArray();
             LingeredApp.startApp(vmArgs, theApp);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM04/em04t001/em04t001.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM04/em04t001/em04t001.cpp	Tue Apr 09 11:48:54 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
@@ -29,7 +29,6 @@
 #include "jvmti_tools.h"
 #include "JVMTITools.h"
 #include "nsk_list.h"
-#include "nsk_mutex.h"
 
 extern "C" {
 
@@ -49,8 +48,8 @@
     int sign;
 } nsk_jvmti_DCG_params;
 
-static MUTEX* mutex = NULL;
-
+static jrawMonitorID syncLock = NULL;
+static volatile int callbacksEnabled = NSK_TRUE;
 /* ============================================================================= */
 
 /* callbacks */
@@ -60,6 +59,12 @@
     nsk_jvmti_DCG_params *rec;
     int b;
 
+    jvmti->RawMonitorEnter(syncLock);
+    if (!callbacksEnabled) {
+        jvmti->RawMonitorExit(syncLock);
+        return;
+    }
+
     rec = (nsk_jvmti_DCG_params *)malloc(sizeof(nsk_jvmti_DCG_params));
     strncpy(rec->name, name, NAME_LENGTH);
     rec->name[NAME_LENGTH - 1] = '\0';
@@ -69,16 +74,13 @@
 
     NSK_DISPLAY3("received: 0x%p %7d %s\n", rec->address, rec->length, rec->name);
 
-    MUTEX_acquire(mutex);
-
     b = NSK_VERIFY(nsk_list_add(plist, rec));
 
-    MUTEX_release(mutex);
-
     if (!b) {
         nsk_jvmti_setFailStatus();
         free((void *)rec);
     }
+    jvmti->RawMonitorExit(syncLock);
 }
 
 void JNICALL
@@ -87,6 +89,13 @@
 
     int i;
     nsk_jvmti_DCG_params *rec;
+
+    jvmti->RawMonitorEnter(syncLock);
+    if (!callbacksEnabled) {
+        jvmti->RawMonitorExit(syncLock);
+        return;
+    }
+
     int count = nsk_list_getCount(plist);
     int compLength = NAME_LENGTH - 1;
 
@@ -99,11 +108,13 @@
             if (strncmp(rec->name, name, compLength) != 0) {
                 NSK_DISPLAY2("\t<%s> was renamed to <%s>\n", rec->name, name);
             }
+            jvmti->RawMonitorExit(syncLock);
             return;
         }
 
     }
     NSK_DISPLAY3("NOT FOUND: 0x%p %7d %s\n", address, length, name);
+    jvmti->RawMonitorExit(syncLock);
 
 }
 
@@ -151,6 +162,9 @@
     if (!NSK_JVMTI_VERIFY(jvmti->GenerateEvents(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)))
         nsk_jvmti_setFailStatus();
 
+    jvmti->RawMonitorEnter(syncLock);
+    callbacksEnabled = NSK_FALSE;
+
     {
         int i;
         const nsk_jvmti_DCG_params *rec;
@@ -168,6 +182,8 @@
 
     }
 
+    jvmti->RawMonitorExit(syncLock);
+
     NSK_DISPLAY0("Let debuggee to finish\n");
     if (!nsk_jvmti_resumeSync())
         return;
@@ -190,10 +206,6 @@
 #endif
 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 
-    mutex = MUTEX_create();
-    if (!mutex)
-        return JNI_ERR;
-
     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
         return JNI_ERR;
 
@@ -203,6 +215,11 @@
     if (!NSK_VERIFY(jvmti != NULL))
         return JNI_ERR;
 
+    if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) {
+        nsk_jvmti_setFailStatus();
+        return JNI_ERR;
+    }
+
     plist = (const void *)nsk_list_create();
     if (!NSK_VERIFY(plist != NULL))
         return JNI_ERR;
@@ -239,9 +256,8 @@
         nsk_jvmti_setFailStatus();
     }
 
-    if (mutex) {
-        MUTEX_destroy(mutex);
-        mutex = NULL;
+    if (!NSK_JVMTI_VERIFY(jvmti->DestroyRawMonitor(syncLock))) {
+        nsk_jvmti_setFailStatus();
     }
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t002/em07t002.cpp	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM07/em07t002/em07t002.cpp	Tue Apr 09 11:48:54 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
@@ -44,6 +44,7 @@
 
 #define NAME_LENGTH 50
 const void *plist = NULL;
+static volatile int callbacksEnabled = NSK_TRUE;
 
 typedef struct nsk_jvmti_CompiledMethodIDStruct {
     jmethodID method;
@@ -63,8 +64,15 @@
     char *sign;
     char *genc;
 
+    jvmti->RawMonitorEnter(syncLock);
+    if (!callbacksEnabled) {
+        jvmti->RawMonitorExit(syncLock);
+        return;
+    }
+
     if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &name, &sign, &genc))) {
         nsk_jvmti_setFailStatus();
+        jvmti->RawMonitorExit(syncLock);
         return;
     }
 
@@ -105,6 +113,9 @@
         if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*)genc))) {
             nsk_jvmti_setFailStatus();
         }
+
+    jvmti->RawMonitorExit(syncLock);
+
 }
 
 void JNICALL
@@ -113,7 +124,13 @@
 
     nsk_jvmti_CompiledMethod *rec;
 
+    jvmti->RawMonitorEnter(syncLock);
+    if (!callbacksEnabled) {
+        jvmti->RawMonitorExit(syncLock);
+        return;
+    }
     int count = nsk_list_getCount(plist);
+
     int i;
 
     for (i = 0; i < count; i ++) {
@@ -122,21 +139,16 @@
             NSK_DISPLAY0(">>>JVMTI_EVENT_COMPILED_METHOD_UNLOAD received for\n");
             NSK_DISPLAY1("\t\tmethod: %s\n", rec->name);
 
-            if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(syncLock)))
-                nsk_jvmti_setFailStatus();
-
             methodUnloadCount++;
 
-            if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(syncLock)))
-                nsk_jvmti_setFailStatus();
-
             free(rec);
             nsk_list_remove(plist, i);
+            jvmti->RawMonitorExit(syncLock);
             return;
         }
 
     }
-
+    jvmti->RawMonitorExit(syncLock);
 }
 
 /* ============================================================================= */
@@ -210,6 +222,9 @@
             return;
     }
 
+    jvmti->RawMonitorEnter(syncLock);
+    callbacksEnabled = NSK_FALSE;
+
     {
         int count = nsk_list_getCount(plist);
 
@@ -221,6 +236,8 @@
 
     }
 
+    jvmti->RawMonitorExit(syncLock);
+
     if (!NSK_JVMTI_VERIFY(jvmti->DestroyRawMonitor(syncLock)))
         nsk_jvmti_setFailStatus();
 
--- a/test/jdk/ProblemList-graal.txt	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/ProblemList-graal.txt	Tue Apr 09 11:48:54 2019 +0100
@@ -29,6 +29,8 @@
 
 java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java           8185139   generic-all
 java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java            8185139   generic-all
+java/lang/ProcessBuilder/Basic.java#id0                                 8185139   generic-all
+java/lang/ProcessBuilder/Basic.java#id1                                 8185139   generic-all
 java/lang/ProcessBuilder/SecurityManagerClinit.java                     8185139   generic-all
 java/lang/reflect/Proxy/nonPublicProxy/NonPublicProxyClass.java         8185139   generic-all
 java/lang/StackWalker/CallerSensitiveMethod/Main.java                   8185139   generic-all
@@ -68,6 +70,7 @@
 java/lang/ref/OOMEInReferenceHandler.java                               8196611   generic-all
 java/lang/Runtime/exec/LotsOfOutput.java                                8196611   generic-all
 java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java   8196611   generic-all
+vm/gc/InfiniteList.java                                                 8196611   generic-all
 
 # tests require pop_frame and force_early_return capabilities
 com/sun/jdi/RedefineTTYLineNumber.java                                  8195635   generic-all
--- a/test/jdk/ProblemList.txt	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/ProblemList.txt	Tue Apr 09 11:48:54 2019 +0100
@@ -219,6 +219,7 @@
 java/awt/font/TextLayout/TextLayoutBounds.java 8169188 generic-all
 java/awt/font/StyledMetrics/BoldSpace.java 8198422 linux-all
 java/awt/FontMetrics/FontCrash.java 8198336 windows-all
+java/awt/FontMetrics/MaxAdvanceIsMax.java 8221305 solaris-all,macosx-all
 java/awt/image/DrawImage/IncorrectAlphaSurface2SW.java 8056077 generic-all
 java/awt/image/DrawImage/IncorrectClipXorModeSW2Surface.java 8196025 windows-all
 java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java 8196025 windows-all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/Robot/CheckCommonColors/CheckCommonColors.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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
+ * 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 java.awt.Color;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.util.List;
+
+/**
+ * @test
+ * @key headful
+ * @bug 8215105
+ * @summary tests that Robot can capture the common colors without artifacts
+ */
+public final class CheckCommonColors {
+
+    private static final Frame frame = new Frame();
+    private static Robot robot;
+
+    public static void main(final String[] args) throws Exception {
+        robot = new Robot();
+        try {
+            test();
+        } finally {
+            frame.dispose();
+        }
+    }
+
+    private static void test() {
+        frame.setSize(400, 400);
+        frame.setLocationRelativeTo(null);
+        frame.setUndecorated(true);
+        for (final Color color : List.of(Color.WHITE, Color.LIGHT_GRAY,
+                                         Color.GRAY, Color.DARK_GRAY,
+                                         Color.BLACK, Color.RED, Color.PINK,
+                                         Color.ORANGE, Color.YELLOW,
+                                         Color.GREEN, Color.MAGENTA, Color.CYAN,
+                                         Color.BLUE)) {
+            frame.dispose();
+            frame.setBackground(color);
+            frame.setVisible(true);
+            checkPixels(color);
+        }
+    }
+
+    private static void checkPixels(final Color color) {
+        int attempt = 0;
+        while (true) {
+            Point p = frame.getLocationOnScreen();
+            Color pixel = robot.getPixelColor(p.x + frame.getWidth() / 2,
+                                              p.y + frame.getHeight() / 2);
+            if (color.equals(pixel)) {
+                return;
+            }
+            if (attempt > 10) {
+                System.err.println("Expected: " + color);
+                System.err.println("Actual: " + pixel);
+                throw new RuntimeException("Too many attempts: " + attempt);
+            }
+            // skip Robot.waitForIdle to speedup the common case, but also take
+            // care about slow systems
+            robot.delay((int) Math.pow(2.2, attempt++));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/beans/Introspector/Test8221244.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,84 @@
+/*
+ * 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 8221244
+ * @summary Unexpected behavior of PropertyDescription.getReadMethod for boolean properties
+ */
+
+import java.beans.PropertyDescriptor;
+
+public class Test8221244 {
+
+    public static void main(String[] args) {
+        test("bv", "isBv"); // boolean value
+        test("bo", "getBo"); // Boolean object
+        test("io", "getIo"); // Integer object
+    }
+
+    private static void test(String propertyName, String expectedGetterName) {
+        PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(TestBean.class, propertyName);
+        String getterName = pd.getReadMethod().getName();
+        if (!getterName.equals(expectedGetterName)) {
+            throw new Error("unexpected getter: " + getterName);
+        }
+    }
+}
+
+/*
+ * Bean class with multiple properties (each property has "is"/"get" getters)
+ *
+ * For boolean properties, the "is" getter should be used
+ */
+class TestBean {
+
+    // boolean value
+    private boolean bv;
+
+    public boolean isBv() {
+        return bv;
+    }
+
+    public boolean getBv() {
+        return bv;
+    }
+
+    // Boolean object
+    private Boolean bo;
+    public Boolean isBo() {
+        return bo;
+    }
+    public Boolean getBo() {
+        return bo;
+    }
+
+    // Integer object
+    private Integer io;
+    public Integer isIo() {
+        return io;
+    }
+    public Integer getIo() {
+        return io;
+    }
+}
--- a/test/jdk/java/io/DataOutputStream/WriteUTF.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/io/DataOutputStream/WriteUTF.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,8 @@
 /* @test
  * @bug 4260284 8219196
  * @summary Test if DataOutputStream will overcount written field.
- * @run testng/othervm -Xmx2g WriteUTF
+ * @requires (sun.arch.data.model == "64" & os.maxMemory >= 3g)
+ * @run testng/othervm -Xmx3g WriteUTF
  */
 
 import java.io.ByteArrayOutputStream;
@@ -59,7 +60,7 @@
     }
 
     // Without 8219196 fix, throws ArrayIndexOutOfBoundsException instead of
-    // expected UTFDataFormatException. Requires 2GB of heap (-Xmx2g) to run
+    // expected UTFDataFormatException. Requires 3GB of heap (-Xmx3g) to run
     // without throwing an OutOfMemoryError.
     @Test(expectedExceptions = UTFDataFormatException.class)
     public void arrayIndexOutOfBoundsException() throws IOException {
--- a/test/jdk/java/lang/Character/UnicodeData.txt	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/lang/Character/UnicodeData.txt	Tue Apr 09 11:48:54 2019 +0100
@@ -11836,7 +11836,7 @@
 32FC;CIRCLED KATAKANA WI;So;0;L;<circle> 30F0;;;;N;;;;;
 32FD;CIRCLED KATAKANA WE;So;0;L;<circle> 30F1;;;;N;;;;;
 32FE;CIRCLED KATAKANA WO;So;0;L;<circle> 30F2;;;;N;;;;;
-32FF;SQUARE ERA NAME NEWERA;So;0;L;<square> 5143 53F7;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME NEWERA;;;;
+32FF;SQUARE ERA NAME REIWA;So;0;L;<square> 4EE4 548C;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME REIWA;;;;
 3300;SQUARE APAATO;So;0;L;<square> 30A2 30D1 30FC 30C8;;;;N;SQUARED APAATO;;;;
 3301;SQUARE ARUHUA;So;0;L;<square> 30A2 30EB 30D5 30A1;;;;N;SQUARED ARUHUA;;;;
 3302;SQUARE ANPEA;So;0;L;<square> 30A2 30F3 30DA 30A2;;;;N;SQUARED ANPEA;;;;
--- a/test/jdk/java/lang/invoke/MethodHandlesGeneralTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/lang/invoke/MethodHandlesGeneralTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -635,7 +635,7 @@
 
     public void testGetter(int testMode) throws Throwable {
         Lookup lookup = PRIVATE;  // FIXME: test more lookups than this one
-        for (Object[] c : HasFields.CASES) {
+        for (Object[] c : HasFields.testCasesFor(testMode)) {
             boolean positive = (c[1] != Error.class);
             testGetter(positive, lookup, c[0], c[1], testMode);
             if (positive)
@@ -665,7 +665,6 @@
         boolean testNPE  = ((testMode0 & TEST_NPE) != 0);
         int testMode = testMode0 & ~(TEST_SETTER | TEST_BOUND | TEST_NPE);
         boolean positive = positive0 && !testNPE;
-        boolean isFinal;
         boolean isStatic;
         Class<?> fclass;
         String   fname;
@@ -673,14 +672,12 @@
         Field f = (fieldRef instanceof Field ? (Field)fieldRef : null);
         if (f != null) {
             isStatic = Modifier.isStatic(f.getModifiers());
-            isFinal  = Modifier.isFinal(f.getModifiers());
             fclass   = f.getDeclaringClass();
             fname    = f.getName();
             ftype    = f.getType();
         } else {
             Object[] scnt = (Object[]) fieldRef;
             isStatic = (Boolean)  scnt[0];
-            isFinal  = false;
             fclass   = (Class<?>) scnt[1];
             fname    = (String)   scnt[2];
             ftype    = (Class<?>) scnt[3];
@@ -724,19 +721,21 @@
                 ?   NoSuchFieldException.class
                 :   IllegalAccessException.class,
                 noAccess);
-            if (((testMode0 & TEST_SETTER) != 0) && (isFinal && isStatic)) return; // Final static field setter test failed as intended.
             if (verbosity >= 5)  ex.printStackTrace(System.out);
         }
         if (verbosity >= 3)
-            System.out.println((((testMode0 & TEST_UNREFLECT) != 0)?"unreflect":"find")
-                              +(((testMode0 & TEST_FIND_STATIC) != 0)?"Static":"")
-                              +(isGetter?"Getter":"Setter")
-                              +" "+fclass.getName()+"."+fname+"/"+ftype
-                              +" => "+mh
-                              +(noAccess == null ? "" : " !! "+noAccess));
+            System.out.format("%s%s %s.%s/%s => %s %s%n",
+                              (testMode0 & TEST_UNREFLECT) != 0
+                                  ? "unreflect"
+                                  : "find" + ((testMode0 & TEST_FIND_STATIC) != 0 ? "Static" : ""),
+                              (isGetter ? "Getter" : "Setter"),
+                              fclass.getName(), fname, ftype, mh,
+                              (noAccess == null ? "" : " !! "+noAccess));
+        // negative test case and expected noAccess, then done.
+        if (!positive && noAccess != null) return;
+        // positive test case but found noAccess, then error
         if (positive && !testNPE && noAccess != null)  throw new RuntimeException(noAccess);
         assertEquals(positive0 ? "positive test" : "negative test erroneously passed", positive0, mh != null);
-        assertFalse("Setter methods should throw an exception if passed a final static field.", ((testMode0 & TEST_SETTER) != 0) && (isFinal && isStatic));
         if (!positive && !testNPE)  return; // negative access test failed as expected
         assertEquals((isStatic ? 0 : 1)+(isGetter ? 0 : 1), mh.type().parameterCount());
         assertSame(mh.type(), expType);
@@ -762,6 +761,9 @@
             assertEquals(f.get(fields), value);  // clean to start with
         }
         Throwable caughtEx = null;
+        // non-final field and setAccessible(true) on instance field will have write access
+        boolean writeAccess = !Modifier.isFinal(f.getModifiers()) ||
+                              (!Modifier.isStatic(f.getModifiers()) && f.isAccessible());
         if (isGetter) {
             Object expValue = value;
             for (int i = 0; i <= 1; i++) {
@@ -785,7 +787,7 @@
                     }
                 }
                 assertEquals(sawValue, expValue);
-                if (f != null && f.getDeclaringClass() == HasFields.class && !isFinal) {
+                if (f != null && f.getDeclaringClass() == HasFields.class && writeAccess) {
                     Object random = randomArg(ftype);
                     f.set(fields, random);
                     expValue = random;
@@ -819,8 +821,8 @@
                 }
             }
         }
-        if ((f != null) && (f.getDeclaringClass() == HasFields.class) && !isFinal) {
-            f.set(fields, value);  // put it back if we changed it.
+        if (f != null && f.getDeclaringClass() == HasFields.class && writeAccess) {
+            f.set(fields, value);  // put it back if it has write access
         }
         if (testNPE) {
             if (caughtEx == null || !(caughtEx instanceof NullPointerException))
@@ -868,7 +870,8 @@
 
     public void testSetter(int testMode) throws Throwable {
         Lookup lookup = PRIVATE;  // FIXME: test more lookups than this one
-        for (Object[] c : HasFields.CASES) {
+        startTest("testSetter");
+        for (Object[] c : HasFields.testCasesFor(testMode|TEST_SETTER)) {
             boolean positive = (c[1] != Error.class);
             testSetter(positive, lookup, c[0], c[1], testMode);
             if (positive)
--- a/test/jdk/java/lang/invoke/MethodHandlesTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/lang/invoke/MethodHandlesTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Stream;
 
 import static org.junit.Assert.*;
 
@@ -561,25 +562,37 @@
         static long sJ = 1+'J';
         static float sF = 1+'F';
         static double sD = 1+'D';
+
+        // final fields
+        final boolean fiZ = false;
+        final byte fiB = 2+(byte)'B';
+        final short fiS = 2+(short)'S';
+        final char fiC = 2+'C';
+        final int fiI = 2+'I';
+        final long fiJ = 2+'J';
+        final float fiF = 2+'F';
+        final double fiD = 2+'D';
         final static boolean fsZ = false;
-        final static byte fsB = 2+(byte)'B';
-        final static short fsS = 2+(short)'S';
-        final static char fsC = 2+'C';
-        final static int fsI = 2+'I';
-        final static long fsJ = 2+'J';
-        final static float fsF = 2+'F';
-        final static double fsD = 2+'D';
+        final static byte fsB = 3+(byte)'B';
+        final static short fsS = 3+(short)'S';
+        final static char fsC = 3+'C';
+        final static int fsI = 3+'I';
+        final static long fsJ = 3+'J';
+        final static float fsF = 3+'F';
+        final static double fsD = 3+'D';
 
         Object iL = 'L';
-        String iR = "R";
-        static Object sL = 'M';
-        static String sR = "S";
-        final static Object fsL = 'N';
-        final static String fsR = "T";
+        String iR = "iR";
+        static Object sL = 1+'L';
+        static String sR = "sR";
+        final Object fiL = 2+'L';
+        final String fiR = "fiR";
+        final static Object fsL = 3+'L';
+        final static String fsR = "fsR";
 
-        static final Object[][] CASES;
+        static final ArrayList<Object[]> STATIC_FIELD_CASES = new ArrayList<>();
+        static final ArrayList<Object[]> INSTANCE_FIELD_CASES = new ArrayList<>();
         static {
-            ArrayList<Object[]> cases = new ArrayList<>();
             Object types[][] = {
                 {'L',Object.class}, {'R',String.class},
                 {'I',int.class}, {'J',long.class},
@@ -589,42 +602,91 @@
             };
             HasFields fields = new HasFields();
             for (Object[] t : types) {
-                for (int kind = 0; kind <= 2; kind++) {
+                for (int kind = 0; kind <= 1; kind++) {
                     boolean isStatic = (kind != 0);
-                    boolean isFinal  = (kind == 2);
+                    ArrayList<Object[]> cases = isStatic ? STATIC_FIELD_CASES : INSTANCE_FIELD_CASES;
                     char btc = (Character)t[0];
-                    String name = (isStatic ? "s" : "i") + btc;
-                    if (isFinal) name = "f" + name;
+                    String fname = (isStatic ? "s" : "i") + btc;
+                    String finalFname = (isStatic ? "fs" : "fi") + btc;
                     Class<?> type = (Class<?>) t[1];
-                    Object value;
-                    Field field;
-                    try {
-                        field = HasFields.class.getDeclaredField(name);
-                    } catch (NoSuchFieldException | SecurityException ex) {
-                        throw new InternalError("no field HasFields."+name);
-                    }
-                    try {
-                        value = field.get(fields);
-                    } catch (IllegalArgumentException | IllegalAccessException ex) {
-                        throw new InternalError("cannot fetch field HasFields."+name);
-                    }
+                    // non-final field
+                    Field nonFinalField = getField(fname, type);
+                    Object value = getValue(fields, nonFinalField);
                     if (type == float.class) {
                         float v = 'F';
                         if (isStatic)  v++;
-                        if (isFinal)   v++;
                         assertTrue(value.equals(v));
                     }
-                    if (isFinal && isStatic) field.setAccessible(true);
-                    assertTrue(name.equals(field.getName()));
-                    assertTrue(type.equals(field.getType()));
-                    assertTrue(isStatic == (Modifier.isStatic(field.getModifiers())));
-                    assertTrue(isFinal  == (Modifier.isFinal(field.getModifiers())));
-                    cases.add(new Object[]{ field, value });
+                    assertTrue(isStatic == (Modifier.isStatic(nonFinalField.getModifiers())));
+                    cases.add(new Object[]{ nonFinalField, value });
+
+                    // setAccessible(true) on final field but static final field only has read access
+                    Field finalField = getField(finalFname, type);
+                    Object fvalue = getValue(fields, finalField);
+                    finalField.setAccessible(true);
+                    assertTrue(isStatic == (Modifier.isStatic(finalField.getModifiers())));
+                    cases.add(new Object[]{ finalField, fvalue, Error.class});
                 }
             }
-            cases.add(new Object[]{ new Object[]{ false, HasFields.class, "bogus_fD", double.class }, Error.class });
-            cases.add(new Object[]{ new Object[]{ true,  HasFields.class, "bogus_sL", Object.class }, Error.class });
-            CASES = cases.toArray(new Object[0][]);
+            INSTANCE_FIELD_CASES.add(new Object[]{ new Object[]{ false, HasFields.class, "bogus_fD", double.class }, Error.class });
+            STATIC_FIELD_CASES.add(new Object[]{ new Object[]{ true,  HasFields.class, "bogus_sL", Object.class }, Error.class });
+        }
+
+        private static Field getField(String name, Class<?> type) {
+            try {
+                Field field = HasFields.class.getDeclaredField(name);
+                assertTrue(name.equals(field.getName()));
+                assertTrue(type.equals(field.getType()));
+                return field;
+            } catch (NoSuchFieldException | SecurityException ex) {
+                throw new InternalError("no field HasFields."+name);
+            }
+        }
+
+        private static Object getValue(Object o, Field field) {
+            try {
+                return field.get(o);
+            } catch (IllegalArgumentException | IllegalAccessException ex) {
+                throw new InternalError("cannot fetch field HasFields."+field.getName());
+            }
+        }
+
+        static Object[][] testCasesFor(int testMode) {
+            Stream<Object[]> cases;
+            if ((testMode & TEST_UNREFLECT) != 0) {
+                cases = Stream.concat(STATIC_FIELD_CASES.stream(), INSTANCE_FIELD_CASES.stream());
+            } else if ((testMode & TEST_FIND_STATIC) != 0) {
+                cases = STATIC_FIELD_CASES.stream();
+            } else if ((testMode & TEST_FIND_FIELD) != 0) {
+                cases = INSTANCE_FIELD_CASES.stream();
+            } else {
+                throw new InternalError("unexpected test mode: " + testMode);
+            }
+            return cases.map(c -> mapTestCase(testMode, c)).toArray(Object[][]::new);
+
+        }
+
+        private static Object[] mapTestCase(int testMode, Object[] c) {
+            // non-final fields (2-element) and final fields (3-element) if not TEST_SETTER
+            if (c.length == 2 || (testMode & TEST_SETTER) == 0)
+                return c;
+
+            // final fields (3-element)
+            assertTrue((testMode & TEST_SETTER) != 0 && c[0] instanceof Field && c[2] == Error.class);
+            if ((testMode & TEST_UNREFLECT) == 0)
+                return new Object[]{ c[0], c[2]};   // negative test case; can't set on final fields
+
+            // unreflectSetter grants write access on instance final field if accessible flag is true
+            // hence promote the negative test case to positive test case
+            Field f = (Field) c[0];
+            int mods = f.getModifiers();
+            if (!Modifier.isFinal(mods) || (!Modifier.isStatic(mods) && f.isAccessible())) {
+                // positive test case
+                return new Object[]{ c[0], c[1] };
+            } else {
+                // otherwise, negative test case
+                return new Object[]{ c[0], c[2]};
+            }
         }
     }
 
--- a/test/jdk/java/lang/reflect/AccessibleObject/CanAccessTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/lang/reflect/AccessibleObject/CanAccessTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -94,7 +94,7 @@
      * for instance members
      */
     public void testInstanceMethod() throws Exception {
-        Method m = Unsafe.class.getDeclaredMethod("addressSize0");
+        Method m = Unsafe.class.getDeclaredMethod("allocateMemory0", long.class);
         assertFalse(m.canAccess(INSTANCE));
 
         try {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/reflect/exeCallerAccessTest/CallerAccessTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,67 @@
+/*
+ * 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 8221530
+ * @summary Test uses custom launcher that starts VM using JNI that verifies
+ *          reflection API with null caller class
+ * @library /test/lib
+ * @run main/native CallerAccessTest
+ */
+
+import java.io.File;
+import java.util.Map;
+import jdk.test.lib.Platform;
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class CallerAccessTest {
+    public static void main(String[] args) throws IOException {
+        Path launcher = Paths.get(System.getProperty("test.nativepath"), "CallerAccessTest");
+        ProcessBuilder pb = new ProcessBuilder(launcher.toString());
+        Map<String, String> env = pb.environment();
+
+        String libName = Platform.isWindows() ? "bin" : "lib";
+        Path libPath = Paths.get(Utils.TEST_JDK).resolve(libName);
+        String libDir = libPath.toAbsolutePath().toString();
+        String serverDir = libPath.resolve("server").toAbsolutePath().toString();
+
+        // set up shared library path
+        String sharedLibraryPathEnvName = Platform.sharedLibraryPathVariableName();
+        env.compute(sharedLibraryPathEnvName,
+                    (k, v) -> (v == null) ? libDir : v + File.pathSeparator + libDir);
+        env.compute(sharedLibraryPathEnvName,
+                    (k, v) -> (v == null) ? serverDir : v + File.pathSeparator + serverDir);
+
+        System.out.println("Launching: " + launcher + " shared library path: " +
+                           env.get(sharedLibraryPathEnvName));
+        new OutputAnalyzer(pb.start()).shouldHaveExitValue(0);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/reflect/exeCallerAccessTest/exeCallerAccessTest.c	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,129 @@
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+
+#include "jni.h"
+#include "assert.h"
+
+static jclass    classClass;
+static jclass    iaeClass;
+static jmethodID mid_Class_forName;
+static jmethodID mid_Class_getField;
+static jmethodID mid_Field_get;
+
+int getField(JNIEnv *env, char* declaringClass_name, char* field_name);
+int checkAndClearIllegalAccessExceptionThrown(JNIEnv *env);
+
+int main(int argc, char** args) {
+    JavaVM *jvm;
+    JNIEnv *env;
+    JavaVMInitArgs vm_args;
+    JavaVMOption options[1];
+    jint rc;
+
+    vm_args.version = JNI_VERSION_1_2;
+    vm_args.nOptions = 0;
+    vm_args.options = options;
+
+    if ((rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args)) != JNI_OK) {
+        printf("ERROR: cannot create VM.\n");
+        exit(-1);
+    }
+
+    classClass = (*env)->FindClass(env, "java/lang/Class");
+    iaeClass = (*env)->FindClass(env, "java/lang/IllegalAccessException");
+    mid_Class_forName = (*env)->GetStaticMethodID(env, classClass, "forName",
+                                                  "(Ljava/lang/String;)Ljava/lang/Class;");
+    assert(mid_Class_forName != NULL);
+
+    mid_Class_getField = (*env)->GetMethodID(env, classClass, "getField",
+                                             "(Ljava/lang/String;)Ljava/lang/reflect/Field;");
+    assert(mid_Class_getField != NULL);
+
+    jclass fieldClass = (*env)->FindClass(env, "java/lang/reflect/Field");
+    mid_Field_get = (*env)->GetMethodID(env, fieldClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
+    assert(mid_Class_getField != NULL);
+
+    // can access to public member of an exported type
+    if ((rc = getField(env, "java.lang.Integer", "TYPE")) != 0) {
+        printf("ERROR: fail to access java.lang.Integer::TYPE\n");
+        exit(-1);
+    }
+
+    // expect IAE to jdk.internal.misc.Unsafe class
+    if ((rc = getField(env, "jdk.internal.misc.Unsafe", "INVALID_FIELD_OFFSET")) == 0) {
+        printf("ERROR: IAE not thrown\n");
+        exit(-1);
+    }
+    if (checkAndClearIllegalAccessExceptionThrown(env) != JNI_TRUE) {
+        printf("ERROR: exception is not an instance of IAE\n");
+        exit(-1);
+    }
+
+    // expect IAE to jdk.internal.misc.Unsafe class
+    if ((rc = getField(env, "jdk.internal.misc.Unsafe", "INVALID_FIELD_OFFSET")) == 0) {
+        printf("ERROR: IAE not thrown\n");
+        exit(-1);
+    }
+    if (checkAndClearIllegalAccessExceptionThrown(env) != JNI_TRUE) {
+        printf("ERROR: exception is not an instance of IAE\n");
+        exit(-1);
+    }
+
+    (*jvm)->DestroyJavaVM(jvm);
+    return 0;
+}
+
+int checkAndClearIllegalAccessExceptionThrown(JNIEnv *env) {
+    jthrowable t = (*env)->ExceptionOccurred(env);
+    if ((*env)->IsInstanceOf(env, t, iaeClass) == JNI_TRUE) {
+        (*env)->ExceptionClear(env);
+        return JNI_TRUE;
+    }
+    return JNI_FALSE;
+}
+
+int getField(JNIEnv *env, char* declaringClass_name, char* field_name) {
+    jobject c = (*env)->CallStaticObjectMethod(env, classClass, mid_Class_forName,
+                                               (*env)->NewStringUTF(env, declaringClass_name));
+    if ((*env)->ExceptionOccurred(env) != NULL) {
+        (*env)->ExceptionDescribe(env);
+        return 1;
+    }
+
+    jobject f = (*env)->CallObjectMethod(env, c, mid_Class_getField, (*env)->NewStringUTF(env, field_name));
+    if ((*env)->ExceptionOccurred(env) != NULL) {
+        (*env)->ExceptionDescribe(env);
+        return 2;
+    }
+
+    jobject v = (*env)->CallObjectMethod(env, f, mid_Field_get, c);
+    if ((*env)->ExceptionOccurred(env) != NULL) {
+        (*env)->ExceptionDescribe(env);
+        return 3;
+    }
+    return 0;
+}
+
--- a/test/jdk/java/net/httpclient/whitebox/ConnectionPoolTestDriver.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/net/httpclient/whitebox/ConnectionPoolTestDriver.java	Tue Apr 09 11:48:54 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8187044 8187111
+ * @bug 8187044 8187111 8221395
  * @summary Verifies that the ConnectionPool correctly handle
  *          connection deadlines and purges the right connections
  *          from the cache.
@@ -35,4 +35,8 @@
  * @run main/othervm
  *       --add-reads java.net.http=java.management
  *       java.net.http/jdk.internal.net.http.ConnectionPoolTest testPoolSize
+ * @run main/othervm
+ *       --add-reads java.net.http=java.management
+ *       -Djdk.httpclient.HttpClient.log=errors,requests,headers,content,ssl,trace,channel
+ *       java.net.http/jdk.internal.net.http.ConnectionPoolTest testCloseOrReturnToPool
  */
--- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/ConnectionPoolTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/ConnectionPoolTest.java	Tue Apr 09 11:48:54 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
@@ -25,17 +25,25 @@
 
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
+import java.lang.ref.Reference;
 import java.net.Authenticator;
 import java.net.CookieHandler;
 import java.net.InetSocketAddress;
 import java.net.ProxySelector;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.SocketOption;
+import java.net.http.HttpHeaders;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
+import java.nio.channels.spi.SelectorProvider;
 import java.time.Duration;
-import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
 import java.util.Random;
+import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Flow;
@@ -53,7 +61,7 @@
  * @summary Verifies that the ConnectionPool correctly handle
  *          connection deadlines and purges the right connections
  *          from the cache.
- * @bug 8187044 8187111
+ * @bug 8187044 8187111 8221395
  * @author danielfuchs
  */
 public class ConnectionPoolTest {
@@ -78,7 +86,10 @@
             } else if ("testPoolSize".equals(arg)) {
                 assert args.length == 1 : "testPoolSize should be run in its own VM";
                 testPoolSize();
-            }
+            } else if ("testCloseOrReturnToPool".equals(arg)) {
+                assert args.length == 1 : "testCloseOrReturnToPool should be run in its own VM";
+                testCloseOrReturnToPool();
+            } else throw new RuntimeException("unknown test case: " + arg);
         }
     }
 
@@ -226,6 +237,113 @@
         }
     }
 
+    public static void testCloseOrReturnToPool() throws Exception {
+        HttpClientFacade facade = (HttpClientFacade)HttpClient.newHttpClient();
+        HttpClientImpl client = facade.impl;
+        ConnectionPool pool = client.connectionPool();
+        InetSocketAddress proxy = InetSocketAddress.createUnresolved("bar", 80);
+
+        InetSocketAddress addr = InetSocketAddress.createUnresolved("foo1", 80);
+        HttpConnectionStub conn1 = new HttpConnectionStub(facade, client, addr, proxy, true);
+        HttpHeaders hdrs = HttpHeaders.of(new HashMap<>(), (s1,s2) -> true);
+        HttpConnection conn;
+
+        conn1.reopen();
+        if (!conn1.isOpen()) {
+            throw new RuntimeException("conn1 finished");
+        }
+
+        conn1.closeOrReturnToCache(hdrs);
+
+        // Check we can find conn1 in the pool
+        if (conn1 != (conn = pool.getConnection(true, addr, proxy))) {
+            throw new RuntimeException("conn1 not returned, got: " + conn);
+        }
+        System.out.println("Found connection in the pool: " + conn );
+
+        // Try to return it with no headers: the connection should
+        // be closed and not returned to the pool (EOF).
+        conn.closeOrReturnToCache(null);
+        if ((conn = pool.getConnection(true, addr, proxy)) != null) {
+            throw new RuntimeException(conn + " found in the pool!");
+        }
+        if (!conn1.closed) {
+            throw new RuntimeException("conn1 not closed!");
+        }
+        System.out.println("EOF connection successfully closed when returned to pool");
+
+        // reopen the connection
+        conn1.reopen();
+        if (!conn1.isOpen()) {
+            throw new RuntimeException("conn1 finished");
+        }
+
+        // Try to return it with empty headers: the connection should
+        // be returned to the pool.
+        conn1.closeOrReturnToCache(hdrs);
+        if (conn1 != (conn = pool.getConnection(true, addr, proxy))) {
+            throw new RuntimeException("conn1 not returned to pool, got: " + conn);
+        }
+        if (conn1.closed) {
+            throw new RuntimeException("conn1 closed");
+        }
+        if (!conn1.isOpen()) {
+            throw new RuntimeException("conn1 finished");
+        }
+
+        System.out.println("Keep alive connection successfully returned to pool");
+
+        // Try to return it with connection: close headers: the connection should
+        // not be returned to the pool, and should be closed.
+        HttpHeaders hdrs2 = HttpHeaders.of(Map.of("connection", List.of("close")), (s1, s2) -> true);
+        conn1.closeOrReturnToCache(hdrs2);
+        if ((conn = pool.getConnection(true, addr, proxy)) != null) {
+            throw new RuntimeException(conn + " found in the pool!");
+        }
+        if (!conn1.closed) {
+            throw new RuntimeException("conn1 not closed!");
+        }
+        System.out.println("Close connection successfully closed when returned to pool");
+
+        // reopen and finish the connection.
+        conn1.reopen();
+        conn1.finish(true);
+        if (conn1.closed) {
+            throw new RuntimeException("conn1 closed");
+        }
+        if (conn1.isOpen()) {
+            throw new RuntimeException("conn1 is opened!");
+        }
+        conn1.closeOrReturnToCache(hdrs2);
+        if ((conn = pool.getConnection(true, addr, proxy)) != null) {
+            throw new RuntimeException(conn + " found in the pool!");
+        }
+        if (!conn1.closed) {
+            throw new RuntimeException("conn1 not closed!");
+        }
+        System.out.println("Finished 'close' connection successfully closed when returned to pool");
+
+        // reopen and finish the connection.
+        conn1.reopen();
+        conn1.finish(true);
+        if (conn1.closed) {
+            throw new RuntimeException("conn1 closed");
+        }
+        if (conn1.isOpen()) {
+            throw new RuntimeException("conn1 is opened!");
+        }
+        conn1.closeOrReturnToCache(hdrs);
+        if ((conn = pool.getConnection(true, addr, proxy)) != null) {
+            throw new RuntimeException(conn + " found in the pool!");
+        }
+        if (!conn1.closed) {
+            throw new RuntimeException("conn1 not closed!");
+        }
+        System.out.println("Finished keep-alive connection successfully closed when returned to pool");
+
+        Reference.reachabilityFence(facade);
+    }
+
     static <T> T error() {
         throw new InternalError("Should not reach here: wrong test assumptions!");
     }
@@ -241,22 +359,108 @@
         @Override
         public void subscribe(Flow.Subscriber<? super List<ByteBuffer>> subscriber) {
         }
-        @Override public boolean isFinished() { return conn.closed; }
+        @Override public boolean isFinished() { return conn.finished; }
+    }
+
+    static class SocketChannelStub extends SocketChannel {
+
+        SocketChannelStub() { super(SelectorProvider.provider()); }
+
+        @Override
+        public SocketChannel bind(SocketAddress local) throws IOException {
+            return error();
+        }
+        @Override
+        public <T> SocketChannel setOption(SocketOption<T> name, T value) throws IOException {
+            return error();
+        }
+        @Override
+        public SocketChannel shutdownInput() throws IOException {
+            return error();
+        }
+        @Override
+        public SocketChannel shutdownOutput() throws IOException {
+            return error();
+        }
+        @Override
+        public Socket socket() { return error(); }
+        @Override
+        public boolean isConnected() { return true; }
+        @Override
+        public boolean isConnectionPending() { return false; }
+        @Override
+        public boolean connect(SocketAddress remote) throws IOException {
+            return error();
+        }
+        @Override
+        public boolean finishConnect() throws IOException {
+            return error();
+        }
+        @Override
+        public SocketAddress getRemoteAddress() throws IOException {
+            return error();
+        }
+        @Override
+        public int read(ByteBuffer dst) throws IOException {
+            return error();
+        }
+        @Override
+        public long read(ByteBuffer[] dsts, int offset, int length) throws IOException {
+            return error();
+        }
+        @Override
+        public int write(ByteBuffer src) throws IOException {
+            return error();
+        }
+        @Override
+        public long write(ByteBuffer[] srcs, int offset, int length) throws IOException {
+            return 0;
+        }
+        @Override
+        public SocketAddress getLocalAddress() throws IOException {
+            return error();
+        }
+        @Override
+        public <T> T getOption(SocketOption<T> name) throws IOException {
+            return error();
+        }
+        @Override
+        public Set<SocketOption<?>> supportedOptions() {
+            return error();
+        }
+        @Override
+        protected void implCloseSelectableChannel() throws IOException {
+            error();
+        }
+        @Override
+        protected void implConfigureBlocking(boolean block) throws IOException {
+            error();
+        }
     }
 
     // Emulates an HttpConnection that has a strong reference to its HttpClient.
     static class HttpConnectionStub extends HttpConnection {
 
-        public HttpConnectionStub(HttpClient client,
+        public HttpConnectionStub(
+                HttpClient client,
                 InetSocketAddress address,
                 InetSocketAddress proxy,
                 boolean secured) {
-            super(address, null);
+            this(client, null, address, proxy, secured);
+        }
+        public HttpConnectionStub(
+                HttpClient client,
+                HttpClientImpl impl,
+                InetSocketAddress address,
+                InetSocketAddress proxy,
+                boolean secured) {
+            super(address, impl);
             this.key = ConnectionPool.cacheKey(address, proxy);
             this.address = address;
             this.proxy = proxy;
             this.secured = secured;
             this.client = client;
+            this.channel = new SocketChannelStub();
             this.flow = new FlowTubeStub(this);
         }
 
@@ -266,16 +470,23 @@
         final ConnectionPool.CacheKey key;
         final HttpClient client;
         final FlowTubeStub flow;
-        volatile boolean closed;
+        final SocketChannel channel;
+        volatile boolean closed, finished;
+
+        // Used for testing closeOrReturnToPool.
+        void finish(boolean finished) { this.finished = finished; }
+        void reopen() { closed = finished = false;}
 
         // All these return something
         @Override boolean connected() {return !closed;}
         @Override boolean isSecure() {return secured;}
         @Override boolean isProxied() {return proxy!=null;}
         @Override ConnectionPool.CacheKey cacheKey() {return key;}
+        @Override FlowTube getConnectionFlow() {return flow;}
+        @Override SocketChannel channel() {return channel;}
         @Override
         public void close() {
-            closed=true;
+            closed=finished=true;
             System.out.println("closed: " + this);
         }
         @Override
@@ -283,13 +494,11 @@
             return "HttpConnectionStub: " + address + " proxy: " + proxy;
         }
 
+
         // All these throw errors
         @Override public HttpPublisher publisher() {return error();}
         @Override public CompletableFuture<Void> connectAsync(Exchange<?> e) {return error();}
         @Override public CompletableFuture<Void> finishConnect() {return error();}
-        @Override SocketChannel channel() {return error();}
-        @Override
-        FlowTube getConnectionFlow() {return flow;}
     }
     // Emulates an HttpClient that has a strong reference to its connection pool.
     static class HttpClientStub extends HttpClient {
--- a/test/jdk/java/security/Signature/Offsets.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/security/Signature/Offsets.java	Tue Apr 09 11:48:54 2019 +0100
@@ -123,8 +123,13 @@
             throw new RuntimeException("Test doesn't support this signature "
                     + "algorithm: " + algorithm);
         }
-
-        KeyPairGenerator kpg = KeyPairGenerator.getInstance(keyAlgo, provider);
+        KeyPairGenerator kpg = null;
+        // first try matching provider, fallback to most preferred if none available
+        try {
+            kpg = KeyPairGenerator.getInstance(keyAlgo, provider);
+        } catch (NoSuchAlgorithmException nsae) {
+            kpg = KeyPairGenerator.getInstance(keyAlgo);
+        }
         kpg.initialize(keySize);
         KeyPair kp = kpg.generateKeyPair();
         PublicKey pubkey = kp.getPublic();
--- a/test/jdk/java/security/SignedObject/Chain.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/security/SignedObject/Chain.java	Tue Apr 09 11:48:54 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
@@ -21,13 +21,7 @@
  * questions.
  */
 
-import java.security.Signature;
-import java.security.SignedObject;
-import java.security.KeyPairGenerator;
-import java.security.KeyPair;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
+import java.security.*;
 import java.security.spec.*;
 import java.util.*;
 import jdk.test.lib.SigTestUtil;
@@ -197,8 +191,15 @@
             if (test.provider != Provider.Default) {
                 signature = Signature.getInstance(test.sigAlg.name,
                         test.provider.name);
-                kpg = KeyPairGenerator.getInstance(
-                    test.keyAlg.name, test.provider.name);
+                // try using the same provider first, if not, fallback
+                // to the first available impl
+                try {
+                    kpg = KeyPairGenerator.getInstance(
+                        test.keyAlg.name, test.provider.name);
+                } catch (NoSuchAlgorithmException nsae) {
+                    kpg = KeyPairGenerator.getInstance(
+                        test.keyAlg.name);
+                }
             } else {
                 signature = Signature.getInstance(test.sigAlg.name);
                 kpg = KeyPairGenerator.getInstance(test.keyAlg.name);
--- a/test/jdk/java/text/Format/DateFormat/WeekDateTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/text/Format/DateFormat/WeekDateTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -137,9 +137,9 @@
         Calendar jcal = Calendar.getInstance(TimeZone.getTimeZone("GMT"),
                                              new Locale("ja", "JP", "JP"));
 
-        String format = "2-W01-2"; // 2019-12-31 == N1-12-31
+        String format = "2-W01-2"; // 2019-12-31 == R1-12-31
         int expectedYear = 2019;
-        // Check the current era, Heisei or NewEra
+        // Check the current era, Heisei or Reiwa
         if (System.currentTimeMillis() < 1556668800000L) {
             format = "21-W01-3"; // 2008-12-31 == H20-12-31
             expectedYear = 2008;
--- a/test/jdk/java/time/tck/java/time/chrono/TCKJapaneseChronology.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/time/tck/java/time/chrono/TCKJapaneseChronology.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- o Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ o 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
@@ -111,7 +111,9 @@
  */
 @Test
 public class TCKJapaneseChronology {
-    private static final int YDIFF_NEWERA = 2018;
+
+    // Year differences from Gregorian years.
+    private static final int YDIFF_REIWA = 2018;
     private static final int YDIFF_HEISEI = 1988;
     private static final int YDIFF_MEIJI = 1867;
     private static final int YDIFF_SHOWA = 1925;
@@ -174,7 +176,7 @@
     @DataProvider(name="createByEra")
     Object[][] data_createByEra() {
         return new Object[][] {
-                {JapaneseEra.of(3), 2020 - YDIFF_NEWERA, 2, 29, 60, LocalDate.of(2020, 2, 29)}, // NEWERA
+                {JapaneseEra.REIWA, 2020 - YDIFF_REIWA, 2, 29, 60, LocalDate.of(2020, 2, 29)},
                 {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)},
                 {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)},
                 {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)},
@@ -367,8 +369,8 @@
     @DataProvider(name="prolepticYear")
     Object[][] data_prolepticYear() {
         return new Object[][] {
-                {3, JapaneseEra.of(3), 1, 1 + YDIFF_NEWERA, false}, // NEWERA
-                {3, JapaneseEra.of(3), 102, 102 + YDIFF_NEWERA, true}, // NEWERA
+                {3, JapaneseEra.REIWA, 1, 1 + YDIFF_REIWA, false},
+                {3, JapaneseEra.REIWA, 102, 102 + YDIFF_REIWA, true},
 
                 {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false},
                 {2, JapaneseEra.HEISEI, 4, 4 + YDIFF_HEISEI, true},
@@ -553,7 +555,7 @@
             { JapaneseEra.TAISHO, 0, "Taisho"},
             { JapaneseEra.SHOWA, 1, "Showa"},
             { JapaneseEra.HEISEI, 2, "Heisei"},
-            { JapaneseEra.of(3), 3, "NewEra"}, // NEWERA
+            { JapaneseEra.REIWA, 3, "Reiwa"},
         };
     }
 
@@ -689,7 +691,7 @@
             {JapaneseChronology.INSTANCE.date(1989,  1,  7), "Japanese Showa 64-01-07"},
             {JapaneseChronology.INSTANCE.date(1989,  1,  8), "Japanese Heisei 1-01-08"},
             {JapaneseChronology.INSTANCE.date(2012, 12,  6), "Japanese Heisei 24-12-06"},
-            {JapaneseChronology.INSTANCE.date(2020,  1,  6), "Japanese NewEra 2-01-06"},
+            {JapaneseChronology.INSTANCE.date(2020,  1,  6), "Japanese Reiwa 2-01-06"},
         };
     }
 
--- a/test/jdk/java/time/tck/java/time/chrono/TCKJapaneseEra.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/time/tck/java/time/chrono/TCKJapaneseEra.java	Tue Apr 09 11:48:54 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
@@ -79,7 +79,7 @@
     @DataProvider(name = "JapaneseEras")
     Object[][] data_of_eras() {
         return new Object[][] {
-                    {JapaneseEra.of(3), "NewEra", 3}, // NEWERA
+                    {JapaneseEra.REIWA, "Reiwa", 3},
                     {JapaneseEra.HEISEI, "Heisei", 2},
                     {JapaneseEra.SHOWA, "Showa", 1},
                     {JapaneseEra.TAISHO, "Taisho", 0},
--- a/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/time/test/java/time/chrono/TestEraDisplayName.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 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
@@ -69,26 +69,32 @@
             { JapaneseEra.TAISHO,   TextStyle.FULL,     Locale.US,      "Taisho" },
             { JapaneseEra.SHOWA,    TextStyle.FULL,     Locale.US,      "Showa" },
             { JapaneseEra.HEISEI,   TextStyle.FULL,     Locale.US,      "Heisei" },
+            { JapaneseEra.REIWA,    TextStyle.FULL,     Locale.US,      "Reiwa" },
             { JapaneseEra.MEIJI,    TextStyle.FULL,     Locale.JAPAN,   "\u660e\u6cbb" },
             { JapaneseEra.TAISHO,   TextStyle.FULL,     Locale.JAPAN,   "\u5927\u6b63" },
             { JapaneseEra.SHOWA,    TextStyle.FULL,     Locale.JAPAN,   "\u662d\u548c" },
             { JapaneseEra.HEISEI,   TextStyle.FULL,     Locale.JAPAN,   "\u5e73\u6210" },
+            { JapaneseEra.REIWA,    TextStyle.FULL,     Locale.JAPAN,   "\u4ee4\u548c" },
             { JapaneseEra.MEIJI,    TextStyle.SHORT,    Locale.US,      "Meiji" },
             { JapaneseEra.TAISHO,   TextStyle.SHORT,    Locale.US,      "Taisho" },
             { JapaneseEra.SHOWA,    TextStyle.SHORT,    Locale.US,      "Showa" },
             { JapaneseEra.HEISEI,   TextStyle.SHORT,    Locale.US,      "Heisei" },
+            { JapaneseEra.REIWA,    TextStyle.SHORT,    Locale.US,      "Reiwa" },
             { JapaneseEra.MEIJI,    TextStyle.SHORT,    Locale.JAPAN,   "\u660e\u6cbb" },
             { JapaneseEra.TAISHO,   TextStyle.SHORT,    Locale.JAPAN,   "\u5927\u6b63" },
             { JapaneseEra.SHOWA,    TextStyle.SHORT,    Locale.JAPAN,   "\u662d\u548c" },
             { JapaneseEra.HEISEI,   TextStyle.SHORT,    Locale.JAPAN,   "\u5e73\u6210" },
+            { JapaneseEra.REIWA,    TextStyle.SHORT,    Locale.JAPAN,   "\u4ee4\u548c" },
             { JapaneseEra.MEIJI,    TextStyle.NARROW,   Locale.US,      "M" },
             { JapaneseEra.TAISHO,   TextStyle.NARROW,   Locale.US,      "T" },
             { JapaneseEra.SHOWA,    TextStyle.NARROW,   Locale.US,      "S" },
             { JapaneseEra.HEISEI,   TextStyle.NARROW,   Locale.US,      "H" },
+            { JapaneseEra.REIWA,    TextStyle.NARROW,   Locale.US,      "R" },
             { JapaneseEra.MEIJI,    TextStyle.NARROW,   Locale.JAPAN,   "M" },
             { JapaneseEra.TAISHO,   TextStyle.NARROW,   Locale.JAPAN,   "T" },
             { JapaneseEra.SHOWA,    TextStyle.NARROW,   Locale.JAPAN,   "S" },
             { JapaneseEra.HEISEI,   TextStyle.NARROW,   Locale.JAPAN,   "H" },
+            { JapaneseEra.REIWA,    TextStyle.NARROW,   Locale.JAPAN,   "R" },
 
             // ThaiBuddhistEra
             { ThaiBuddhistEra.BEFORE_BE,    TextStyle.FULL, Locale.US,      "BC" },
--- a/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/time/test/java/time/chrono/TestJapaneseChronology.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -34,6 +34,7 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
 
 /**
  * Tests for the Japanese chronology
@@ -59,7 +60,7 @@
             { JapaneseEra.SHOWA,     64,  1,  7, 1989 },
             { JapaneseEra.HEISEI,     1,  1,  8, 1989 },
             { JapaneseEra.HEISEI,    31,  4, 30, 2019 },
-            { JapaneseEra.of(3),      1,  5,  1, 2019 }, // NEWERA
+            { JapaneseEra.REIWA,      1,  5,  1, 2019 },
         };
     }
 
@@ -77,7 +78,7 @@
             { JapaneseEra.HEISEI,  1,    1,  1,  8 },
             { JapaneseEra.HEISEI,  2,    8,  1,  8 },
             { JapaneseEra.HEISEI, 31,  120,  4, 30 },
-            { JapaneseEra.of(3),   1,    1,  5,  1 }, // NEWERA
+            { JapaneseEra.REIWA,   1,    1,  5,  1 },
         };
     }
 
@@ -110,8 +111,8 @@
             { JapaneseEra.HEISEI,     1,  1,  7 },
             { JapaneseEra.HEISEI,     1,  2, 29 },
             { JapaneseEra.HEISEI,    31,  5,  1 },
-            { JapaneseEra.of(3),      1,  4, 30 }, // NEWERA
-            { JapaneseEra.of(3), Year.MAX_VALUE,  12, 31 }, // NEWERA
+            { JapaneseEra.REIWA,      1,  4, 30 },
+            { JapaneseEra.REIWA, Year.MAX_VALUE,  12, 31 },
         };
     }
 
@@ -131,9 +132,9 @@
             { JapaneseEra.HEISEI,    -1 },
             { JapaneseEra.HEISEI,     0 },
             { JapaneseEra.HEISEI,    32 },
-            { JapaneseEra.of(3),     -1 }, // NEWERA
-            { JapaneseEra.of(3),      0 }, // NEWERA
-            { JapaneseEra.of(3), Year.MAX_VALUE }, // NEWERA
+            { JapaneseEra.REIWA,     -1 },
+            { JapaneseEra.REIWA,      0 },
+            { JapaneseEra.REIWA, Year.MAX_VALUE },
         };
     }
 
@@ -151,8 +152,21 @@
             { JapaneseEra.HEISEI,  1, 360 },
             { JapaneseEra.HEISEI,  2, 366 },
             { JapaneseEra.HEISEI, 31, 121 },
-            { JapaneseEra.of(3),   1, 246 }, // NEWERA
-            { JapaneseEra.of(3),   2, 367 }, // NEWERA
+            { JapaneseEra.REIWA,   1, 246 },
+            { JapaneseEra.REIWA,   2, 367 },
+        };
+    }
+
+    @DataProvider
+    Object[][] eraNameData() {
+        return new Object[][] {
+            // Japanese era, name, exception
+            { "Meiji",  JapaneseEra.MEIJI,      null },
+            { "Taisho", JapaneseEra.TAISHO,     null },
+            { "Showa",  JapaneseEra.SHOWA,      null },
+            { "Heisei", JapaneseEra.HEISEI,     null },
+            { "Reiwa", JapaneseEra.REIWA,       null },
+            { "NewEra", null,                   IllegalArgumentException.class},
         };
     }
 
@@ -204,4 +218,13 @@
         JapaneseDate date = JAPANESE.dateYearDay(era, yearOfEra, dayOfYear);
         System.out.printf("No DateTimeException with era=%s, year=%d, dayOfYear=%d%n", era, yearOfEra, dayOfYear);
     }
+
+    @Test(dataProvider="eraNameData")
+    public void test_eraName(String eraName, JapaneseEra era, Class expectedEx) {
+        try {
+            assertEquals(JapaneseEra.valueOf(eraName), era);
+        } catch (Exception ex) {
+            assertTrue(expectedEx.isInstance(ex));
+        }
+    }
 }
--- a/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -776,9 +776,9 @@
             {HijrahDate.of(1434,5,1), "Japanese Heisei 25-03-13"},
             {HijrahDate.of(1436,1,1), "Japanese Heisei 26-10-25"},
             {HijrahDate.of(1440,8,25), "Japanese Heisei 31-04-30"},
-            {HijrahDate.of(1440,8,26), "Japanese NewEra 1-05-01"},
-            {HijrahDate.of(1500,6,12), "Japanese NewEra 59-05-05"},
-            {HijrahDate.of(1550,3,11), "Japanese NewEra 107-08-11"},
+            {HijrahDate.of(1440,8,26), "Japanese Reiwa 1-05-01"},
+            {HijrahDate.of(1500,6,12), "Japanese Reiwa 59-05-05"},
+            {HijrahDate.of(1550,3,11), "Japanese Reiwa 107-08-11"},
         };
     }
 
--- a/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -143,7 +143,7 @@
             // Chronology, lenient era/year, strict era/year
             { JAPANESE, "Meiji 123", "Heisei 2" },
             { JAPANESE, "Showa 65", "Heisei 2" },
-            { JAPANESE, "Heisei 32", "NewEra 2" }, // NewEra
+            { JAPANESE, "Heisei 32", "Reiwa 2" },
         };
     }
 
--- a/test/jdk/java/util/Calendar/CalendarTestScripts/CalendarAdapter.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/CalendarTestScripts/CalendarAdapter.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -364,7 +364,7 @@
                 "Taisho",
                 "Showa",
                 "Heisei",
-                "NewEra"
+                "Reiwa"
             };
             break;
         }
--- a/test/jdk/java/util/Calendar/CalendarTestScripts/Symbol.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/CalendarTestScripts/Symbol.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -322,7 +322,7 @@
         put("taisho", new Symbol(Type.ERA, 2));
         put("showa", new Symbol(Type.ERA, 3));
         put("heisei", new Symbol(Type.ERA, 4));
-        put("newera", new Symbol(Type.ERA, 5));
+        put("reiwa", new Symbol(Type.ERA, 5));
 
     }
 }
--- a/test/jdk/java/util/Calendar/CalendarTestScripts/japanese/japanese.cts	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/CalendarTestScripts/japanese/japanese.cts	Tue Apr 09 11:48:54 2019 +0100
@@ -57,7 +57,7 @@
 	check millisecond 0
 
 	clear all
-	set era NewEra
+	set era Reiwa
 	check era Heisei
 	check datetime 31 Jan 1 0 0 0
 	check millisecond 0
--- a/test/jdk/java/util/Calendar/CalendarTestScripts/japanese/japanese_add.cts	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/CalendarTestScripts/japanese/japanese_add.cts	Tue Apr 09 11:48:54 2019 +0100
@@ -16,10 +16,10 @@
 test add ERA
     use jcal
 	clear all
-	set date NewEra 17 Mar 8
+	set date Reiwa 17 Mar 8
 	add era 10
-	# as of NewEra 17 March 8
-	check era NewEra
+	# as of Reiwa 17 March 8
+	check era Reiwa
 	add era -100
 	check era BeforeMeiji
 
@@ -342,12 +342,12 @@
 	check date BeforeMeiji $minyear May 18
 	check timeofday 1 47 4 191
 
-	set date NewEra 17 Jan 1
+	set date Reiwa 17 Jan 1
 	get max year
 	assign $result $max
-	set date NewEra $max Jul 17
+	set date Reiwa $max Jul 17
 	add month 1
-	check date NewEra $max Aug 17
+	check date Reiwa $max Aug 17
 #	set date Heisei $max Jul 28
 #	set timeofday 23 59 59 999
 #	add month 1
--- a/test/jdk/java/util/Calendar/CalendarTestScripts/japanese/japanese_minmax.cts	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/CalendarTestScripts/japanese/japanese_minmax.cts	Tue Apr 09 11:48:54 2019 +0100
@@ -14,10 +14,10 @@
 
 test Make sure that the maximum year value doesn't depent on era
     use jcal
-	# Note: the max year value is as of NewEra
+	# Note: the max year value is as of Reiwa
 	assign 292276976 $max
 	clear all
-	set date NewEra 1 May 1
+	set date Reiwa 1 May 1
 	get millis
 	check max year $max
 	assign $max $maxyear
@@ -39,9 +39,9 @@
 
 test Max of ERA
     use jcal
-	# Assumption: NewEra is the current era
-	check maximum era NewEra
-	check leastmax era NewEra
+	# Assumption: Reiwa is the current era
+	check maximum era Reiwa
+	check leastmax era Reiwa
 
 test Actual max MONTH
     use jcal
@@ -78,7 +78,7 @@
 	check actualmax month Apr
 
 	clear all
-	set date NewEra 2 Jan 1
+	set date Reiwa 2 Jan 1
 	set year $maxyear
 	check actualmax month Aug
 	get millis
@@ -133,8 +133,8 @@
    # time zone dependent
    use tokyocal
 	clear all
-	set date NewEra $maxyear Jan 1
-	# the last date of NewEra is N292276976.08.17T16:12:55.807+0900
+	set date Reiwa $maxyear Jan 1
+	# the last date of Reiwa is R292276976.08.17T16:12:55.807+0900
 	check actualmax day_of_year 229 # 31+28+31+30+31+30+31+17
 
 test Actual max WEEK_OF_YEAR
@@ -165,12 +165,12 @@
 	clear all
 	set date Heisei 31 Apr 28
 	check actualmax week_of_year 17
-	set date NewEra 1 Aug 9
+	set date Reiwa 1 Aug 9
 	check actualmax week_of_year 35
 
     use tokyocal
-	set date NewEra $maxyear Jan 1
-	# the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday)	
+	set date Reiwa $maxyear Jan 1
+	# the last date of Reiwa is R292276976.08.17T16:12:55.807+0900 (Sunday)	
 	# The year is equivalent to 2003 (Gregorian).
 	check actualmax week_of_year 34
 
@@ -197,12 +197,12 @@
 	clear all
 	set date Heisei 31 Apr 30
 	check actualmax week_of_month 5
-	set date NewEra 1 May 1
+	set date Reiwa 1 May 1
 	check actualmax week_of_month 5
 
     use tokyocal
-	set date NewEra $maxyear Jan 1
-	# the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday)	
+	set date Reiwa $maxyear Jan 1
+	# the last date of Reiwa is R292276976.08.17T16:12:55.807+0900 (Sunday)	
 	# The year is equivalent to 2003 (Gregorian).
 	check actualmax week_of_month 4
 	
@@ -229,13 +229,13 @@
 	clear all
 	set date Heisei 31 Apr 30
 	check actualmax week_of_month 5
-	set date NewEra 1 May 1
+	set date Reiwa 1 May 1
 	check actualmax week_of_month 5
 
     use tokyocal
 	clear all
-	set date NewEra $maxyear Jan 1
-	# the last date of NewEra is N292276976.08.17T16:12:55.807+0900 (Sunday)	
+	set date Reiwa $maxyear Jan 1
+	# the last date of Reiwa is R292276976.08.17T16:12:55.807+0900 (Sunday)	
 	# The year is equivalent to 2003 (Gregorian).
 	check actualmax week_of_month 4
 
@@ -269,11 +269,11 @@
 	set date Heisei 1 Aug 18
 	check actualmax year 30
 
-	set date NewEra 1 Apr 30
+	set date Reiwa 1 Apr 30
 	check actualmax year 31
 
 	# Date/time beyond the last date in the max year.
-	set date NewEra 1 Aug 18
+	set date Reiwa 1 Aug 18
 	check actualmax year 292276975
 	
 test Least max YEAR
--- a/test/jdk/java/util/Calendar/CalendarTestScripts/japanese/japanese_roll.cts	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/CalendarTestScripts/japanese/japanese_roll.cts	Tue Apr 09 11:48:54 2019 +0100
@@ -147,13 +147,13 @@
 	roll year -1
 	check date Heisei 31 Apr 30
 
-	set date NewEra 2 Apr 30
+	set date Reiwa 2 Apr 30
 	get max year
 	assign $result $hmax
 	roll year -1
-	check date NewEra $hmax Apr 30
+	check date Reiwa $hmax Apr 30
 	roll year 1
-	check date NewEra 2 Apr 30
+	check date Reiwa 2 Apr 30
 
 test roll MONTH
 	set date BeforeMeiji 1867 Dec 1
@@ -276,16 +276,16 @@
 	check date BeforeMeiji $minyear May 18
 	check timeofday 1 47 4 191
 
-	set date NewEra 17 Jan 1
+	set date Reiwa 17 Jan 1
 	get max year
 	assign $result $max
-	set date NewEra $max Jul 28
+	set date Reiwa $max Jul 28
 	roll month 1
-	check date NewEra $max Aug 17
-	set date NewEra $max Jul 28
+	check date Reiwa $max Aug 17
+	set date Reiwa $max Jul 28
 	set timeofday 23 59 59 999
 	roll month 1
-	check date NewEra $max Aug 16
+	check date Reiwa $max Aug 16
 	check timeofday 23 59 59 999
 
 test roll WEEK_OF_YEAR
--- a/test/jdk/java/util/Calendar/JapaneseEraNameTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/JapaneseEraNameTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -51,12 +51,12 @@
     Object[][] names() {
         return new Object[][] {
             // type,    locale,  name
-            { LONG,     JAPAN,   "\u5143\u53f7" }, // NewEra
-            { LONG,     US,      "NewEra" },
-            { LONG,     CHINA,   "NewEra" },
-            { SHORT,    JAPAN,   "\u5143\u53f7" },
-            { SHORT,    US,      "NewEra" },
-            { SHORT,    CHINA,   "N" },
+            { LONG,     JAPAN,   "\u4ee4\u548c" },
+            { LONG,     US,      "Reiwa" },
+            { LONG,     CHINA,   "Reiwa" },
+            { SHORT,    JAPAN,   "\u4ee4\u548c" },
+            { SHORT,    US,      "Reiwa" },
+            { SHORT,    CHINA,   "R" },
         };
     }
 
--- a/test/jdk/java/util/Calendar/JapaneseLenientEraTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/JapaneseLenientEraTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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,7 +47,7 @@
             // lenient era/year, strict era/year
             { "Meiji 123", "Heisei 2" },
             { "Sh\u014dwa 65", "Heisei 2" },
-            { "Heisei 32", "NewEra 2" }, // NewEra
+            { "Heisei 32", "Reiwa 2" },
         };
     }
 
--- a/test/jdk/java/util/Calendar/NarrowNamesTest.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/NarrowNamesTest.java	Tue Apr 09 11:48:54 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
@@ -68,7 +68,7 @@
              HOUR_OF_DAY, 23);
         test(JAJPJP, DAY_OF_WEEK,
              LocalDateTime.now().isBefore(LocalDateTime.of(2019, 5, 1, 0, 0)) ?
-                "\u65e5" : "\u706b", // "Sun" for HEISEI, "Tue" for NEWERA
+                "\u65e5" : "\u706b", // "Sun" for HEISEI, "Tue" for REIWA
              YEAR, 24, MONTH, DECEMBER, DAY_OF_MONTH, 23);
         test(THTH, MONTH, NARROW_STANDALONE, "\u0e18.\u0e04.",
              YEAR, 2555, MONTH, DECEMBER, DAY_OF_MONTH, 5);
--- a/test/jdk/java/util/Calendar/ZoneOffsets.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/Calendar/ZoneOffsets.java	Tue Apr 09 11:48:54 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
@@ -240,11 +240,11 @@
     }
 
     private static void adjustJapaneseEra(Calendar cal) {
-        // In case of Japanese calendar, explicitly set the last era; NEWERA so that
+        // In case of Japanese calendar, explicitly set the last era; REIWA so that
         // year 2005 won't throw exception
         if (!cal.isLenient() &&
                 cal.getCalendarType().equals("japanese") &&
-                System.currentTimeMillis() < 1556668800000L) { // Current time not in NEWERA
+                System.currentTimeMillis() < 1556668800000L) { // Current time not in REIWA
             cal.set(Calendar.ERA, 5);
             cal.add(Calendar.YEAR, -30); // -30: Subtract year-length of HEISEI era
         }
--- a/test/jdk/java/util/logging/LogManager/TestLoggerNames.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/java/util/logging/LogManager/TestLoggerNames.java	Tue Apr 09 11:48:54 2019 +0100
@@ -133,7 +133,8 @@
 
 
     public static void main(String[] args) throws InterruptedException {
-        LogManager.getLogManager().addLogger(new TestLogger("com.foo.bar.zzz", null));
+        TestLogger test = new TestLogger("com.foo.bar.zzz", null);
+        LogManager.getLogManager().addLogger(test);
         try {
             Logger.getLogger(null);
             throw new RuntimeException("Logger.getLogger(null) didn't throw expected NPE");
@@ -144,7 +145,9 @@
         loggers.add(Logger.getLogger("one.two.addMeAChild"));
         loggers.add(Logger.getLogger("aaa.bbb.replaceMe"));
         loggers.add(Logger.getLogger("bbb.aaa.addMeAChild"));
-        TestLogger test = (TestLogger)Logger.getLogger("com.foo.bar.zzz");
+        if (test != Logger.getLogger("com.foo.bar.zzz")) {
+            throw new AssertionError("wrong logger returned");
+        }
         loggers.add(Logger.getLogger("ddd.aaa.addMeAChild"));
 
         checkLoggerNames(loggers);
--- a/test/jdk/javax/net/ssl/sanity/ciphersuites/CheckCipherSuites.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/javax/net/ssl/sanity/ciphersuites/CheckCipherSuites.java	Tue Apr 09 11:48:54 2019 +0100
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug 4750141 4895631 8217579
+ * @bug 4750141 4895631 8217579 8163326
  * @summary Check enabled and supported ciphersuites are correct
- * @run main CheckCipherSuites default
+ * @run main/othervm CheckCipherSuites default
  * @run main/othervm CheckCipherSuites limited
  */
 
@@ -38,54 +38,97 @@
     // List of enabled cipher suites when the "crypto.policy" security
     // property is set to "unlimited" (the default value).
     private final static String[] ENABLED_DEFAULT = {
-        "TLS_AES_128_GCM_SHA256",
+        // TLS 1.3 cipher suites
         "TLS_AES_256_GCM_SHA384",
+        "TLS_AES_128_GCM_SHA256",
         "TLS_CHACHA20_POLY1305_SHA256",
+
+        // Suite B compliant cipher suites
         "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
         "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
+
+        // Not suite B, but we want it to position the suite early
         "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
+
+        // AES_256(GCM) - ECDHE - forward screcy
         "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
         "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
-        "TLS_RSA_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",
+
+        // AES_128(GCM) - ECDHE - forward screcy
+        "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+
+        // AES_256(GCM) - DHE - forward screcy
         "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
         "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
         "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
+
+        // AES_128(GCM) - DHE - forward screcy
         "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
         "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
+
+        // AES_256(CBC) - ECDHE - forward screcy
         "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
         "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
-        "TLS_RSA_WITH_AES_256_CBC_SHA256",
+
+        // AES_256(CBC) - ECDHE - forward screcy
+        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
+
+        // AES_256(CBC) - DHE - forward screcy
+        "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
+        "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
+
+        // AES_128(CBC) - DHE - forward screcy
+        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
+
+        // AES_256(GCM) - not forward screcy
+        "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",
+        "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",
+
+        // AES_128(GCM) - not forward screcy
+        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
+
+        // AES_256(CBC) - not forward screcy
         "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
         "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384",
-        "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
-        "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
+
+        // AES_128(CBC) - not forward screcy
+        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
+
+        // AES_256(CBC) - ECDHE - using SHA
         "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
         "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
-        "TLS_RSA_WITH_AES_256_CBC_SHA",
-        "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
-        "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
+
+        // AES_128(CBC) - ECDHE - using SHA
+        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
+        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
+
+        // AES_256(CBC) - DHE - using SHA
         "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
         "TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
-        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
-        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_RSA_WITH_AES_128_CBC_SHA",
+
+        // AES_128(CBC) - DHE - using SHA
+        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+
+        // AES_256(CBC) - using SHA, not forward screcy
+        "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
+        "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
+
+        // AES_128(CBC) - using SHA, not forward screcy
         "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
         "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+
+        // deprecated
+        "TLS_RSA_WITH_AES_256_GCM_SHA384",
+        "TLS_RSA_WITH_AES_128_GCM_SHA256",
+        "TLS_RSA_WITH_AES_256_CBC_SHA256",
+        "TLS_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_RSA_WITH_AES_256_CBC_SHA",
+        "TLS_RSA_WITH_AES_128_CBC_SHA",
         "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"
     };
 
@@ -95,79 +138,122 @@
         "TLS_AES_128_GCM_SHA256",
         "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
         "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
         "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
         "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
         "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
         "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
         "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
         "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
+        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
         "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
         "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
         "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
         "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+        "TLS_RSA_WITH_AES_128_GCM_SHA256",
+        "TLS_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_RSA_WITH_AES_128_CBC_SHA",
         "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"
     };
 
     // List of supported cipher suites when the "crypto.policy" security
     // property is set to "unlimited" (the default value).
     private final static String[] SUPPORTED_DEFAULT = {
-        "TLS_AES_128_GCM_SHA256",
+        // TLS 1.3 cipher suites
         "TLS_AES_256_GCM_SHA384",
+        "TLS_AES_128_GCM_SHA256",
         "TLS_CHACHA20_POLY1305_SHA256",
+
+        // Suite B compliant cipher suites
         "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
         "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
+
+        // Not suite B, but we want it to position the suite early
         "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
+
+        // AES_256(GCM) - ECDHE - forward screcy
         "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
         "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
-        "TLS_RSA_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",
+
+        // AES_128(GCM) - ECDHE - forward screcy
+        "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+
+        // AES_256(GCM) - DHE - forward screcy
         "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384",
         "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
         "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384",
-        "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
+
+        // AES_128(GCM) - DHE - forward screcy
         "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
         "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
+
+        // AES_256(CBC) - ECDHE - forward screcy
         "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
         "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
-        "TLS_RSA_WITH_AES_256_CBC_SHA256",
+
+        // AES_256(CBC) - ECDHE - forward screcy
+        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
+
+        // AES_256(CBC) - DHE - forward screcy
+        "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
+        "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
+
+        // AES_128(CBC) - DHE - forward screcy
+        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
+
+        // AES_256(GCM) - not forward screcy
+        "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384",
+        "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384",
+
+        // AES_128(GCM) - not forward screcy
+        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
+
+        // AES_256(CBC) - not forward screcy
         "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
         "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384",
-        "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
-        "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
+
+        // AES_128(CBC) - not forward screcy
+        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
+
+        // AES_256(CBC) - ECDHE - using SHA
         "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
         "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
-        "TLS_RSA_WITH_AES_256_CBC_SHA",
-        "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
-        "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
+
+        // AES_128(CBC) - ECDHE - using SHA
+        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
+        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
+
+        // AES_256(CBC) - DHE - using SHA
         "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
         "TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
-        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
-        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_RSA_WITH_AES_128_CBC_SHA",
+
+        // AES_128(CBC) - DHE - using SHA
+        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+
+        // AES_256(CBC) - using SHA, not forward screcy
+        "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
+        "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
+
+        // AES_128(CBC) - using SHA, not forward screcy
         "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
         "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+
+        // deprecated
+        "TLS_RSA_WITH_AES_256_GCM_SHA384",
+        "TLS_RSA_WITH_AES_128_GCM_SHA256",
+        "TLS_RSA_WITH_AES_256_CBC_SHA256",
+        "TLS_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_RSA_WITH_AES_256_CBC_SHA",
+        "TLS_RSA_WITH_AES_128_CBC_SHA",
         "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"
     };
 
@@ -177,25 +263,25 @@
         "TLS_AES_128_GCM_SHA256",
         "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
         "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_RSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
         "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
         "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
         "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
         "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_RSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
-        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
         "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
         "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256",
+        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
         "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
         "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
         "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
         "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
-        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+        "TLS_RSA_WITH_AES_128_GCM_SHA256",
+        "TLS_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_RSA_WITH_AES_128_CBC_SHA",
         "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"
     };
 
@@ -228,7 +314,8 @@
             throw new Exception("Illegal argument");
         }
 
-        SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
+        SSLSocketFactory factory =
+                (SSLSocketFactory)SSLSocketFactory.getDefault();
         SSLSocket socket = (SSLSocket)factory.createSocket();
         String[] enabled = socket.getEnabledCipherSuites();
 
@@ -257,5 +344,4 @@
         long end = System.currentTimeMillis();
         System.out.println("Done (" + (end - start) + " ms).");
     }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/sound/sampled/Lines/ToString.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,95 @@
+/*
+ * 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 bug.javax.sound.sampled;
+
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.DataLine;
+import javax.sound.sampled.Line;
+import javax.sound.sampled.Mixer;
+import javax.sound.sampled.Port;
+import javax.sound.sampled.SourceDataLine;
+import javax.sound.sampled.TargetDataLine;
+
+/**
+ * @test
+ * @bug 8221436
+ * @run main/othervm bug.javax.sound.sampled.ToString
+ */
+public final class ToString {
+
+    public static void main(final String[] args) {
+
+        // Behavior of toString() methods is not specified, the checks in
+        // this test just defends against accidental changes.
+
+        String custom = new Line.Info(ToString.class).toString();
+        if (!custom.contains("bug.javax.sound.sampled")) {
+            throw new RuntimeException("Package is missing: " + custom);
+        }
+        String ints = new Line.Info(int.class).toString();
+        if (ints.contains("javax.sound.sampled")) {
+            throw new RuntimeException("Package is present: " + ints);
+        }
+        String array = new Line.Info(int[].class).toString();
+        if (array.contains("javax.sound.sampled")) {
+            throw new RuntimeException("Package is present: " + array);
+        }
+
+        String line = new Line.Info(Line.class).toString();
+        if (!line.equals("interface Line")) {
+            throw new RuntimeException("Wrong string: " + line);
+        }
+        String target = new Line.Info(TargetDataLine.class).toString();
+        if (!target.equals("interface TargetDataLine")) {
+            throw new RuntimeException("Wrong string: " + target);
+        }
+        String source = new Line.Info(SourceDataLine.class).toString();
+        if (!source.equals("interface SourceDataLine")) {
+            throw new RuntimeException("Wrong string: " + source);
+        }
+        String port = new Line.Info(Port.class).toString();
+        if (!port.equals("interface Port")) {
+            throw new RuntimeException("Wrong string: " + port);
+        }
+        String data = new Line.Info(DataLine.class).toString();
+        if (!data.equals("interface DataLine")) {
+            throw new RuntimeException("Wrong string: " + data);
+        }
+        String mixer = new Line.Info(Mixer.class).toString();
+        if (!mixer.equals("interface Mixer")) {
+            throw new RuntimeException("Wrong string: " + mixer);
+        }
+        String clip = new Line.Info(Clip.class).toString();
+        if (!clip.equals("interface Clip")) {
+            throw new RuntimeException("Wrong string: " + clip);
+        }
+
+        String dataLine = new DataLine.Info(DataLine.class, null, 0).toString();
+        if (!dataLine.contains("interface DataLine")) {
+            throw new RuntimeException("Wrong string: " + dataLine);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/JMenuItem/8216971/DoubleActionTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,118 @@
+/*
+ * 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
+ * @key headful
+ * @bug 8216971
+ * @summary For JCheckBoxMenuItem actionPerformed() is called twice, when
+ *  apple.laf.useScreenMenuBar=true and modifier is InputEvent.META_DOWN_MASK
+ * @library /test/lib
+ * @run main DoubleActionTest
+ */
+
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.SwingUtilities;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.KeyStroke;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.Robot;
+import jdk.test.lib.Platform;
+
+public class DoubleActionTest {
+
+    private static int metaDownCount = 0;
+    private static JFrame frame;
+    private static final int ORIGIN_X = 200;
+    private static final int ORIGIN_Y = 200;
+
+    public static void main(String[] args) throws Exception {
+        if (!System.getProperty("os.name").startsWith("Mac")) {
+            System.out.println("This test is only for Mac OS, passed " +
+            "automatically on other platforms.");
+            return;
+        }
+
+        try {
+            System.setProperty("apple.laf.useScreenMenuBar", "true");
+
+            SwingUtilities.invokeAndWait(DoubleActionTest::createAndShowGUI);
+
+            Robot robot = new Robot();
+            robot.setAutoDelay(100);
+            testKeyPress(robot);
+            robot.delay(1000);
+
+        } finally {
+            SwingUtilities.invokeAndWait(()->frame.dispose());
+            if (metaDownCount != 1) {
+                throw new RuntimeException("Test Failed: actionPerformed is called twice");
+            }
+        }
+    }
+
+    private static void createAndShowGUI() {
+        frame = new JFrame();
+        final JMenuBar menubar = new JMenuBar();
+        final JMenu fileMenu = new JMenu("OPEN ME");
+        final MyAction myAction = new MyAction();
+        final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(myAction);
+
+        fileMenu.add(menuItem);
+        menubar.add(fileMenu);
+        frame.setJMenuBar(menubar);
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setBounds(ORIGIN_X, ORIGIN_X, 200, 200);
+        frame.setVisible(true);
+    }
+
+    private static class MyAction extends AbstractAction {
+
+        MyAction() {
+            putValue(Action.NAME, "HIT MY ACCELERATOR KEY");
+            putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_DOWN_MASK));
+        }
+
+        @Override
+        public void actionPerformed(final ActionEvent e) {
+            System.out.println("Action! called with modifiers: " + e.getModifiers() + "\n" + e);
+            metaDownCount++;
+        }
+    }
+
+    private static void testKeyPress(Robot robot) throws Exception {
+        robot.mouseMove(ORIGIN_X + 50, ORIGIN_Y + 50);
+        robot.waitForIdle();
+        robot.keyPress(KeyEvent.VK_META);
+        robot.keyPress(KeyEvent.VK_E);
+        robot.keyRelease(KeyEvent.VK_E);
+        robot.keyRelease(KeyEvent.VK_META);
+        robot.waitForIdle();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/JTextArea/JTextAreaWordWrapTest.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,116 @@
+/*
+ * 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
+ * @key headful
+ * @bug 8212904
+ * @summary Verifies JTextArea line wrapping using UI scale
+ * @run main JTextAreaWordWrapTest
+ */
+import java.awt.BorderLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.ScrollPaneConstants;
+import javax.swing.SwingUtilities;
+
+public class JTextAreaWordWrapTest {
+
+    static JFrame frame;
+    static JFrame frame1;
+    static JTextArea textArea;
+    static JTextArea textArea1;
+
+    public static void doWrapOnTest() {
+
+        frame = new JFrame();
+        frame.setSize( 720, 300 );
+        frame.setLayout( new BorderLayout() );
+
+        textArea = new JTextArea();
+        textArea.setLineWrap( true );
+        textArea.setWrapStyleWord( true );
+
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < 100; i++) {
+            sb.append( "zz zzz zzzz zz zz zz zzz xzzzz zzzzzzzzzzzzzzzzx yyyyyyy tttttttttt sssss hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n" );
+        }
+        textArea.setText( sb.toString() );
+        JScrollPane pane = new JScrollPane( textArea,
+                                            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
+                                            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED );
+        frame.add( pane, BorderLayout.CENTER );
+        frame.setVisible( true );
+
+    }
+
+    public static void doWrapOffTest() {
+        frame1 = new JFrame();
+        frame1.setSize( 720, 300 );
+        frame1.setLayout( new BorderLayout() );
+
+        textArea1 = new JTextArea();
+
+        StringBuffer sb1 = new StringBuffer();
+        for (int i = 0; i < 100; i++) {
+            sb1.append( "zz zzz zzzz zz zz zz zzz xzzzz zzzzzzzzzzzzzzzzx yyyyyyy tttttttttt sssss hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n" );
+        }
+        textArea1.setText( sb1.toString() );
+        JScrollPane pane1 = new JScrollPane( textArea1,
+                                             ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
+                                             ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED );
+        frame1.add( pane1, BorderLayout.CENTER );
+        frame1.setLocationRelativeTo(null);
+        frame1.setVisible( true );
+    }
+
+    public static void main( String[] args ) throws Exception {
+        System.setProperty( "sun.java2d.uiScale", "1.25" );
+        try {
+            SwingUtilities.invokeAndWait(() -> doWrapOnTest());
+            Thread.sleep(500);
+            SwingUtilities.invokeAndWait(() -> doWrapOffTest());
+            Thread.sleep(500);
+
+            SwingUtilities.invokeAndWait(() -> {
+
+                int wraponHeight = textArea.getHeight();
+                System.out.println("wraponheight " + wraponHeight);
+                int wrapoffHeight = textArea1.getHeight();
+                System.out.println("wrapoffheight " + wrapoffHeight);
+
+                if (wraponHeight == wrapoffHeight) {
+                    throw new RuntimeException("JTextArea line wrapping incorrect when using UI scale");
+                }
+            });
+
+        } finally {
+            SwingUtilities.invokeAndWait(() -> frame.dispose());
+            SwingUtilities.invokeAndWait(() -> frame1.dispose());
+        }
+    }
+}
--- a/test/jdk/jdk/internal/ref/Cleaner/ExitOnThrow.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/jdk/internal/ref/Cleaner/ExitOnThrow.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, 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
@@ -26,7 +26,6 @@
  * @bug 4954921 8009259
  * @library /test/lib
  * @modules java.base/jdk.internal.ref
- *          java.base/jdk.internal.misc
  * @build jdk.test.lib.Utils
  *        jdk.test.lib.Asserts
  *        jdk.test.lib.JDKToolFinder
@@ -36,38 +35,22 @@
  * @run main ExitOnThrow
  * @summary Ensure that if a cleaner throws an exception then the VM exits
  */
-import java.util.Arrays;
 
 import jdk.internal.ref.Cleaner;
-import jdk.test.lib.JDKToolLauncher;
-import jdk.test.lib.process.OutputAnalyzer;
+
 import jdk.test.lib.process.ProcessTools;
 
 public class ExitOnThrow {
 
-    static final String cp = System.getProperty("test.classes", ".");
-
     public static void main(String[] args) throws Exception {
         if (args.length == 0) {
-            String[] cmd = JDKToolLauncher.createUsingTestJDK("java")
-                                          .addToolArg("-cp")
-                                          .addToolArg(cp)
-                                          .addToolArg("ExitOnThrow")
-                                          .addToolArg("-executeCleaner")
-                                          .getCommand();
-            ProcessBuilder pb = new ProcessBuilder(cmd);
-            OutputAnalyzer out = ProcessTools.executeProcess(pb);
-            System.out.println("======================");
-            System.out.println(Arrays.toString(cmd));
-            String msg = " stdout: [" + out.getStdout() + "]\n" +
-                         " stderr: [" + out.getStderr() + "]\n" +
-                         " exitValue = " + out.getExitValue() + "\n";
-            System.out.println(msg);
-
-            if (out.getExitValue() != 1)
-                throw new RuntimeException("Unexpected exit code: " +
-                                           out.getExitValue());
-
+            ProcessTools.executeTestJvm("--add-exports", "java.base/jdk.internal.ref=ALL-UNNAMED",
+                                        "ExitOnThrow",
+                                        "-executeCleaner")
+                        .outputTo(System.out)
+                        .errorTo(System.out)
+                        .shouldHaveExitValue(1)
+                        .shouldContain("java.lang.RuntimeException: Foo!");
         } else {
             Cleaner.create(new Object(),
                            () -> { throw new RuntimeException("Foo!"); } );
--- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java	Tue Apr 09 11:48:54 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
@@ -25,7 +25,7 @@
 /**
  * @test
  * @bug 8189131 8198240 8191844 8189949 8191031 8196141 8204923 8195774 8199779
- *      8209452 8209506 8210432 8195793
+ *      8209452 8209506 8210432 8195793 8222089 8222133
  * @summary Check root CA entries in cacerts file
  */
 import java.io.File;
@@ -237,7 +237,22 @@
 
     // Exception list to 90 days expiry policy
     // No error will be reported if certificate in this list expires
-    private static final HashSet<String> EXPIRY_EXC_ENTRIES = new HashSet<>();
+    private static final HashSet<String> EXPIRY_EXC_ENTRIES = new HashSet<>() {
+        {
+            // Valid until: Sat Jul 06 19:59:59 EDT 2019
+            add("certplusclass2primaryca [jdk]");
+            // Valid until: Sat Jul 06 19:59:59 EDT 2019
+            add("certplusclass3pprimaryca [jdk]");
+            // Valid until: Tue Jul 09 14:40:36 EDT 2019
+            add("utnuserfirstobjectca [jdk]");
+            // Valid until: Tue Jul 09 19:59:00 EDT 2019
+            add("deutschetelekomrootca2 [jdk]");
+            // Valid until: Tue Jul 09 13:36:58 EDT 2019
+            add("utnuserfirstclientauthemailca [jdk]");
+            // Valid until: Tue Jul 09 14:19:22 EDT 2019
+            add("utnuserfirsthardwareca [jdk]");
+        }
+    };
 
     // Ninety days in milliseconds
     private static final long NINETY_DAYS = 7776000000L;
--- a/test/jdk/sun/security/pkcs11/KeyStore/Basic.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/sun/security/pkcs11/KeyStore/Basic.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, 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
@@ -111,7 +111,7 @@
         this.provider = p;
 
         // get private keys
-        KeyFactory kf = KeyFactory.getInstance("RSA", "SunJSSE");
+        KeyFactory kf = KeyFactory.getInstance("RSA");
         KeyFactory dsaKf = KeyFactory.getInstance("DSA", "SUN");
 
         ObjectInputStream ois1 = new ObjectInputStream
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/rsa/BrokenRSAPrivateCrtKey.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,67 @@
+/*
+ * 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
+ * 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 4503229 8220016
+ * @summary default RSA KeyFactory can return broken RSAPrivateCrtKey objects
+ *      This test was taken directly from the bug report, which
+ *      was fixed in the crippled JSAFE provider, and needed
+ *      to be brought forward into SunRsaSign (was JSSE).
+ * @author Brad Wetmore
+ */
+
+import java.security.*;
+import java.security.interfaces.*;
+import java.security.spec.*;
+import java.math.BigInteger;
+
+public class BrokenRSAPrivateCrtKey {
+    public static void main(String[] args) throws Exception {
+        KeyPairGenerator generator =
+                KeyPairGenerator.getInstance("RSA", "SunRsaSign");
+        generator.initialize(512);
+
+        KeyPair pair = generator.generateKeyPair();
+
+        RSAPrivateCrtKey privatekey = (RSAPrivateCrtKey) pair.getPrivate();
+
+        RSAPrivateCrtKeySpec spec =
+                new RSAPrivateCrtKeySpec(privatekey.getModulus(),
+                privatekey.getPublicExponent(),
+                privatekey.getPrivateExponent(),
+                privatekey.getPrimeP(), privatekey.getPrimeQ(),
+                privatekey.getPrimeExponentP(),
+                privatekey.getPrimeExponentQ(),
+                privatekey.getCrtCoefficient());
+
+        KeyFactory factory = KeyFactory.getInstance("RSA", "SunRsaSign");
+
+        PrivateKey privatekey2 = factory.generatePrivate(spec);
+
+        BigInteger pe =
+                ((RSAPrivateCrtKey) privatekey2).getPublicExponent();
+
+        System.out.println("public exponent: " + pe);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/ssl/SSLContextImpl/DefaultCipherSuitePreference.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+
+/*
+ * @test
+ * @bug 8168261
+ * @summary Use server cipher suites preference by default
+ * @run main/othervm DefaultCipherSuitePreference
+ */
+
+import javax.net.SocketFactory;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.TrustManager;
+
+public class DefaultCipherSuitePreference {
+    private static final String[] contextAlgorithms = {
+            "Default", "SSL", "TLS", "SSLv3", "TLSv1",
+            "TLSv1.1", "TLSv1.2", "TLSv1.3"
+        };
+
+    public static void main(String[] args) throws Exception {
+        for (String algorithm : contextAlgorithms) {
+            System.out.println("Checking SSLContext of " + algorithm);
+            SSLContext sslContext = SSLContext.getInstance(algorithm);
+
+            // Default SSLContext is initialized automatically.
+            if (!algorithm.equals("Default")) {
+                // Use default TK, KM and random.
+                sslContext.init((KeyManager[])null, (TrustManager[])null, null);
+            }
+
+            //
+            // Check SSLContext
+            //
+            // Check default SSLParameters of SSLContext
+            checkDefaultCipherSuitePreference(
+                    sslContext.getDefaultSSLParameters(),
+                    "SSLContext.getDefaultSSLParameters()");
+
+            // Check supported SSLParameters of SSLContext
+            checkDefaultCipherSuitePreference(
+                    sslContext.getSupportedSSLParameters(),
+                    "SSLContext.getSupportedSSLParameters()");
+
+            //
+            // Check SSLEngine
+            //
+            // Check SSLParameters of SSLEngine
+            SSLEngine engine = sslContext.createSSLEngine();
+            engine.setUseClientMode(true);
+            checkDefaultCipherSuitePreference(
+                    engine.getSSLParameters(),
+                    "client mode SSLEngine.getSSLParameters()");
+
+            engine.setUseClientMode(false);
+            checkDefaultCipherSuitePreference(
+                    engine.getSSLParameters(),
+                    "server mode SSLEngine.getSSLParameters()");
+
+            //
+            // Check SSLSocket
+            //
+            // Check SSLParameters of SSLSocket
+            SocketFactory fac = sslContext.getSocketFactory();
+            SSLSocket socket = (SSLSocket)fac.createSocket();
+            checkDefaultCipherSuitePreference(
+                    socket.getSSLParameters(),
+                    "SSLSocket.getSSLParameters()");
+
+            //
+            // Check SSLServerSocket
+            //
+            // Check SSLParameters of SSLServerSocket
+            SSLServerSocketFactory sf = sslContext.getServerSocketFactory();
+            SSLServerSocket ssocket = (SSLServerSocket)sf.createServerSocket();
+            checkDefaultCipherSuitePreference(
+                    ssocket.getSSLParameters(),
+                    "SSLServerSocket.getSSLParameters()");
+        }
+    }
+
+    private static void checkDefaultCipherSuitePreference(
+            SSLParameters parameters, String context) throws Exception {
+        if (!parameters.getUseCipherSuitesOrder()) {
+            throw new Exception(
+                    "The local cipher suite preference is not honored " +
+                    "in the connection populated SSLParameters object (" +
+                    context + ")");
+        }
+    }
+}
--- a/test/jdk/sun/security/ssl/rsa/BrokenRSAPrivateCrtKey.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, 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 4503229
- * @summary default RSA KeyFactory can return broken RSAPrivateCrtKey objects
- *      This test was taken directly from the bug report, which
- *      was fixed in the crippled JSAFE provider, and needed
- *      to be brought forward into JSSE.
- * @author Brad Wetmore
- */
-
-import java.security.*;
-import java.security.interfaces.*;
-import java.security.spec.*;
-import java.math.BigInteger;
-
-public class BrokenRSAPrivateCrtKey {
-    public static void main(String[] args) throws Exception {
-        KeyPairGenerator generator =
-                KeyPairGenerator.getInstance("RSA", "SunJSSE");
-        generator.initialize(512);
-
-        KeyPair pair = generator.generateKeyPair();
-
-        RSAPrivateCrtKey privatekey = (RSAPrivateCrtKey) pair.getPrivate();
-
-        RSAPrivateCrtKeySpec spec =
-                new RSAPrivateCrtKeySpec(privatekey.getModulus(),
-                privatekey.getPublicExponent(),
-                privatekey.getPrivateExponent(),
-                privatekey.getPrimeP(), privatekey.getPrimeQ(),
-                privatekey.getPrimeExponentP(),
-                privatekey.getPrimeExponentQ(),
-                privatekey.getCrtCoefficient());
-
-        KeyFactory factory = KeyFactory.getInstance("RSA", "SunJSSE");
-
-        PrivateKey privatekey2 = factory.generatePrivate(spec);
-
-        BigInteger pe =
-                ((RSAPrivateCrtKey) privatekey2).getPublicExponent();
-
-        System.out.println("public exponent: " + pe);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/ssl/rsa/CheckProviderEntries.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,71 @@
+/*
+ * 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 java.security.*;
+import java.util.Iterator;
+import java.security.Provider.Service;
+
+/*
+ * @test
+ * @bug 8220016
+ * @summary This test checks the RSA-related services in SunJSSE provider
+ */
+public class CheckProviderEntries {
+
+    private static boolean testResult = true;
+
+    private static void error(String msg) {
+        testResult = false;
+        System.out.println(msg);
+    }
+    public static void main(String[] args) throws NoSuchAlgorithmException,
+            InvalidKeyException, SignatureException {
+        Provider p = Security.getProvider("SunJSSE");
+        Iterator<Provider.Service> iter = p.getServices().iterator();
+        while (iter.hasNext()) {
+            Service s = iter.next();
+            String type = s.getType();
+            String algo = s.getAlgorithm();
+            System.out.println("Type: " + type + " " + algo);
+            try {
+                if (algo.indexOf("RSA") != -1) {
+                    // only MD5andSHA1withRSA signature support
+                    // error out on any other RSA support
+                    if (type.equals("Signature") &&
+                        algo.equals("MD5andSHA1withRSA")) {
+                        s.newInstance(null);
+                        continue;
+                    }
+                    error("Error: unexpected RSA services");
+                }
+            } catch (NoSuchAlgorithmException | InvalidParameterException e) {
+                error("Error: cannot create obj " + e);
+            }
+        }
+        if (testResult) {
+            System.out.println("Test Passed");
+        } else {
+            throw new RuntimeException("One or more tests failed");
+        }
+    }
+}
--- a/test/jdk/sun/security/ssl/rsa/SignatureOffsets.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/sun/security/ssl/rsa/SignatureOffsets.java	Tue Apr 09 11:48:54 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
@@ -27,7 +27,7 @@
 
 /*
  * @test
- * @bug 8050374
+ * @bug 8050374 8220016
  * @key randomness
  * @summary This test validates signature verification
  *          Signature.verify(byte[], int, int). The test uses RandomFactory to
@@ -37,10 +37,7 @@
  * @library /test/lib
  * @build jdk.test.lib.RandomFactory
  * @compile ../../../../java/security/Signature/Offsets.java
- * @run main SignatureOffsets SunJSSE MD2withRSA
- * @run main SignatureOffsets SunJSSE MD5withRSA
- * @run main SignatureOffsets SunJSSE SHA1withRSA
- * @run main SignatureOffsets SunJSSE MD5andSHA1withRSA
+ * @run main SignatureOffsets SunJSSE    MD5andSHA1withRSA
  */
 public class SignatureOffsets {
 
--- a/test/jdk/sun/security/ssl/rsa/SignedObjectChain.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/sun/security/ssl/rsa/SignedObjectChain.java	Tue Apr 09 11:48:54 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
@@ -30,6 +30,7 @@
  * @compile ../../../../java/security/SignedObject/Chain.java
  * @run main SignedObjectChain
  */
+
 public class SignedObjectChain {
 
     private static class Test extends Chain.Test {
@@ -40,9 +41,6 @@
     }
 
     private static final Test[] tests = {
-        new Test(Chain.SigAlg.MD2withRSA),
-        new Test(Chain.SigAlg.MD5withRSA),
-        new Test(Chain.SigAlg.SHA1withRSA),
         new Test(Chain.SigAlg.MD5andSHA1withRSA),
     };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/Serial64.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,95 @@
+/*
+ * 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 8221257
+ * @summary Improve serial number generation mechanism for keytool -gencert
+ * @library /test/lib
+ * @key randomness
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.math.BigInteger;
+import java.security.KeyStore;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Serial64 {
+
+    static List<BigInteger> numbers = new ArrayList<>();
+
+    public static void main(String[] args) throws Exception {
+
+        // 10 Self-signed certs and issued certs
+        genkeypair("ca");
+        genkeypair("user");
+        for (int i = 0; i < 8; i++) {
+            gencert("ca", "user");
+        }
+
+        numbers.forEach(b -> System.out.println(b.toString(16)));
+
+        // Must be positive, therefore never zero.
+        Asserts.assertTrue(numbers.stream()
+                .allMatch(b -> b.signum() == 1));
+
+        // At least one should be 64 bit. There is a chance of
+        // 2^-10 this would fail.
+        Asserts.assertTrue(numbers.stream()
+                .anyMatch(b -> b.bitLength() == 64));
+    }
+
+    static OutputAnalyzer keytool(String s) throws Exception {
+        return SecurityTools.keytool(
+                "-storepass changeit -keypass changeit "
+                        + "-keystore ks -keyalg rsa " + s);
+    }
+
+    static void genkeypair(String a) throws Exception {
+        keytool("-genkeypair -alias " + a + " -dname CN=" + a)
+                .shouldHaveExitValue(0);
+        numbers.add(((X509Certificate)KeyStore.getInstance(
+                new File("ks"), "changeit".toCharArray())
+                    .getCertificate(a)).getSerialNumber());
+    }
+
+    static void gencert(String signer, String owner)
+            throws Exception {
+        keytool("-certreq -alias " + owner + " -file req")
+                .shouldHaveExitValue(0);
+        keytool("-gencert -alias " + signer + " -infile req -outfile cert")
+                .shouldHaveExitValue(0);
+        try (FileInputStream fis = new FileInputStream("cert")) {
+            numbers.add(((X509Certificate)CertificateFactory.getInstance("X.509")
+                    .generateCertificate(fis)).getSerialNumber());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/util/RegisteredDomain/Versions.java	Tue Apr 09 11:48:54 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 8221801
+ * @library /test/lib
+ * @summary Update src/java.base/share/legal/public_suffix.md
+ */
+
+import jdk.test.lib.Asserts;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Versions {
+
+    public static void main(String[] args) throws Exception {
+
+        Path root = Path.of(System.getProperty("test.root"));
+        Path jdk = Path.of(System.getProperty("test.jdk"));
+
+        Path version = root.resolve("../../make/data/publicsuffixlist/VERSION");
+        Path mdSrc = root.resolve("../../src/java.base/share/legal/public_suffix.md");
+        Path mdImage = jdk.resolve("legal/java.base/public_suffix.md");
+
+        // Files in src should either both exist or not
+        if (!Files.exists(version) && !Files.exists(mdSrc)) {
+            System.out.println("Source not available. Cannot proceed.");
+            return;
+        }
+
+        String s1 = findURL(version);
+        String s2 = findURL(mdSrc);
+
+        Asserts.assertEQ(s1, s2);
+
+        String s3 = findURL(mdImage);
+        Asserts.assertEQ(s2, s3);
+    }
+
+    static Pattern URL_PATTERN = Pattern.compile(
+            "(https://raw.githubusercontent.com.*?public_suffix_list.dat)");
+
+    static String findURL(Path p) throws IOException  {
+        return Files.lines(p)
+                .map(Versions::matchURL)
+                .filter(Objects::nonNull)
+                .findFirst()
+                .orElseThrow();
+    }
+
+    static String matchURL(String input) {
+        Matcher m = URL_PATTERN.matcher(input);
+        return m.find() ? m.group(1) : null;
+    }
+}
--- a/test/jdk/sun/tools/jcmd/TestProcessHelper.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/sun/tools/jcmd/TestProcessHelper.java	Tue Apr 09 11:48:54 2019 +0100
@@ -108,7 +108,7 @@
                     for (String a : arg) {
                         cmd.add(a);
                     }
-                    testProcessHelper(cmd);
+                    testProcessHelper(cmd, TEST_PROCESS_MAIN_CLASS);
                 }
             }
         }
@@ -130,7 +130,7 @@
                 for (String a : arg) {
                     cmd.add(a);
                 }
-                testProcessHelper(cmd);
+                testProcessHelper(cmd, jarFile.getAbsolutePath());
             }
         }
 
@@ -156,7 +156,7 @@
                         for (String a : arg) {
                             cmd.add(a);
                         }
-                        testProcessHelper(cmd);
+                        testProcessHelper(cmd, MODULE_NAME + "/" + TEST_PROCESS_MAIN_CLASS);
                     }
                 }
             }
@@ -171,7 +171,7 @@
         }
     }
 
-    private void testProcessHelper(List<String> args) throws Exception {
+    private void testProcessHelper(List<String> args, String expectedValue) throws Exception {
         ProcessBuilder pb = new ProcessBuilder(args);
         String cmd = pb.command().stream().collect(Collectors.joining(" "));
         System.out.println("Starting the process:" + cmd);
@@ -179,7 +179,7 @@
         if (!p.isAlive()) {
             throw new RuntimeException("Cannot start the process: " + cmd);
         }
-        checkMainClass(p, TEST_PROCESS_MAIN_CLASS);
+        checkMainClass(p, expectedValue);
     }
 
     private File prepareJar() throws Exception {
--- a/test/jdk/sun/tools/jstat/lineCounts1.awk	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/sun/tools/jstat/lineCounts1.awk	Tue Apr 09 11:48:54 2019 +0100
@@ -18,7 +18,7 @@
 	    headerlines++;
 	}
 
-/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/	{
+/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+|-)[ ]*([0-9]+\.[0-9]+|-)[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/	{
 	    datalines++;
 	}
 
--- a/test/jdk/sun/tools/jstat/lineCounts2.awk	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/sun/tools/jstat/lineCounts2.awk	Tue Apr 09 11:48:54 2019 +0100
@@ -14,7 +14,7 @@
 	    headerlines++;
 	}
 
-/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/	{
+/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+|-)[ ]*([0-9]+\.[0-9]+|-)[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/	{
 	    datalines++;
 	}
 
--- a/test/jdk/tools/jar/modularJar/Basic.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/tools/jar/modularJar/Basic.java	Tue Apr 09 11:48:54 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
@@ -24,7 +24,9 @@
 import java.io.*;
 import java.lang.module.ModuleDescriptor;
 import java.lang.reflect.Method;
-import java.nio.file.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.*;
 import java.util.function.Consumer;
 import java.util.jar.JarEntry;
@@ -32,6 +34,7 @@
 import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 import java.util.regex.Pattern;
+import java.util.spi.ToolProvider;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -59,6 +62,16 @@
  */
 
 public class Basic {
+
+    private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+            .orElseThrow(()
+                    -> new RuntimeException("jar tool not found")
+            );
+    private static final ToolProvider JAVAC_TOOL = ToolProvider.findFirst("javac")
+            .orElseThrow(()
+                    -> new RuntimeException("javac tool not found")
+            );
+
     static final Path TEST_SRC = Paths.get(System.getProperty("test.src", "."));
     static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes", "."));
     static final Path MODULE_CLASSES = TEST_CLASSES.resolve("build");
@@ -977,13 +990,14 @@
         }
         Stream.of(args).forEach(commands::add);
         ProcessBuilder p = new ProcessBuilder(commands);
-        if (stdinSource != null)
+        if (stdinSource != null) {
             p.redirectInput(stdinSource);
+        }
         return run(p);
     }
 
     static Result jar(String... args) {
-        return jarWithStdin(null, args);
+        return run(JAR_TOOL, args);
     }
 
     static Path compileModule(String mn) throws IOException {
@@ -1071,10 +1085,8 @@
     static void javac(Path dest, Path modulePath, Path... sourceFiles)
         throws IOException
     {
-        String javac = getJDKTool("javac");
 
         List<String> commands = new ArrayList<>();
-        commands.add(javac);
         if (!TOOL_VM_OPTIONS.isEmpty()) {
             commands.addAll(Arrays.asList(TOOL_VM_OPTIONS.split("\\s+", -1)));
         }
@@ -1092,7 +1104,13 @@
         }
         Stream.of(sourceFiles).map(Object::toString).forEach(x -> commands.add(x));
 
-        quickFail(run(new ProcessBuilder(commands)));
+        StringWriter sw = new StringWriter();
+        try (PrintWriter pw = new PrintWriter(sw)) {
+            int rc = JAVAC_TOOL.run(pw, pw, commands.toArray(new String[0]));
+            if(rc != 0) {
+                throw new RuntimeException(sw.toString());
+            }
+        }
     }
 
     static Result java(Path modulePath, String entryPoint, String... args) {
@@ -1138,9 +1156,13 @@
         return false;
     }
 
-    static void quickFail(Result r) {
-        if (r.ec != 0)
-            throw new RuntimeException(r.output);
+    static Result run(ToolProvider tp, String[] commands) {
+        int rc = 0;
+        StringWriter sw = new StringWriter();
+        try (PrintWriter pw = new PrintWriter(sw)) {
+            rc = tp.run(pw, pw, commands);
+        }
+        return new Result(rc, sw.toString());
     }
 
     static Result run(ProcessBuilder pb) {
--- a/test/jdk/tools/launcher/Arrrghs.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/jdk/tools/launcher/Arrrghs.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,7 +24,7 @@
 /**
  * @test
  * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
- *      6894719 6968053 7151434 7146424 8007333 8077822 8143640 8132379
+ *      6894719 6968053 7151434 7146424 8007333 8077822 8143640 8132379 8218547
  * @summary Argument parsing validation.
  * @modules jdk.compiler
  *          jdk.zipfs
@@ -36,6 +36,9 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -55,20 +58,6 @@
      *
      */
 
-    /*
-     * SIGH, On Windows all strings are quoted, we need to unwrap it
-     */
-    private static String removeExtraQuotes(String in) {
-        if (isWindows) {
-            // Trim the string and remove the enclosed quotes if any.
-            in = in.trim();
-            if (in.startsWith("\"") && in.endsWith("\"")) {
-                return in.substring(1, in.length()-1);
-            }
-        }
-        return in;
-    }
-
     // the pattern we hope to see in the output
     static final Pattern ArgPattern = Pattern.compile("\\s*argv\\[[0-9]*\\].*=.*");
 
@@ -490,6 +479,27 @@
     }
 
     /*
+     * Tests -jar command on a jar file with "long" (> 260 chars) full path on Windows
+     */
+    @Test
+    void testLongPathJarFile() throws IOException {
+        if (!isWindows) {
+            return;
+        }
+        // put the jar file to a location with long path
+        String longPathPart = "longpathtest_longpathtest/";
+        String longPathStr = longPathPart.repeat(15);
+        Path longPath = Paths.get(longPathStr);
+        Path jarPath = Files.createDirectories(longPath).resolve("elp.jar");
+        File elp = jarPath.toFile();
+        createJar(elp, new File("Foo"), "public static void main(String[] args){ System.out.println(\"Hello from ELP\"); }");
+        System.out.println("execute " + elp.getAbsolutePath());
+        TestResult tr = doExec(javaCmd, "-jar", elp.getAbsolutePath());
+        tr.checkPositive();
+        tr.contains("Hello from ELP");
+    }
+
+    /*
      * Tests various dispositions of the main method, these tests are limited
      * to English locales as they check for error messages that are localized.
      */
--- a/test/langtools/jdk/javadoc/doclet/AccessFrameTitle/AccessFrameTitle.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2002, 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
- * 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 4636655 8196202
- * @summary  Add title attribute to <FRAME> tags for accessibility
- * @author dkramer
- * @library ../../lib
- * @modules jdk.javadoc/jdk.javadoc.internal.tool
- * @build javadoc.tester.*
- * @run main AccessFrameTitle
- */
-
-import javadoc.tester.JavadocTester;
-
-public class AccessFrameTitle extends JavadocTester {
-
-    public static void main(String... args) throws Exception {
-        AccessFrameTitle tester = new AccessFrameTitle();
-        tester.runTests();
-    }
-
-    @Test
-    public void test() {
-        javadoc("-d", "out",
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        // Testing only for the presence of the title attributes.
-        // To make this test more robust, only
-        // the initial part of each title string is tested for,
-        // in case the ending part of the string later changes
-        checkOutput("index.html", true,
-                "title=\"All classes and interfaces (except non-static nested types)\"",
-                "title=\"All Packages\"",
-                "title=\"Package, class and interface descriptions\"");
-    }
-}
--- a/test/langtools/jdk/javadoc/doclet/AccessFrameTitle/p1/C1.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2002, 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 p1;
-
-public class C1 {
-}
--- a/test/langtools/jdk/javadoc/doclet/AccessFrameTitle/p2/C2.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2002, 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 p2;
-
-public class C2 {
-}
--- a/test/langtools/jdk/javadoc/doclet/AccessH1/AccessH1.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/AccessH1/AccessH1.java	Tue Apr 09 11:48:54 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
@@ -46,7 +46,6 @@
     public void test() {
         javadoc("-d", "out",
                 "-doctitle", "Document Title",
-                "--frames",
                 "-sourcepath", testSrc,
                 "p1", "p2");
         checkExit(Exit.OK);
@@ -58,7 +57,7 @@
                 + "}");
 
         // Test the doc title in the overview page
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<h1 class=\"title\">Document Title</h1>");
     }
 }
--- a/test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java	Tue Apr 09 11:48:54 2019 +0100
@@ -48,7 +48,6 @@
     @Test
     public void testAccessSummary() {
         javadoc("-d", "out",
-                "--frames",
                 "-sourcepath", testSrc,
                 "p1", "p2");
         checkExit(Exit.OK);
@@ -56,7 +55,7 @@
     }
 
     void checkSummary(boolean found) {
-        checkOutput("overview-summary.html", found,
+        checkOutput("index.html", found,
                  "summary=\"Package Summary table, listing packages, and an explanation\"");
 
         // Test that the summary attribute appears or not
--- a/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java	Tue Apr 09 11:48:54 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
@@ -57,7 +57,6 @@
         javadoc("-d", "out",
                 "-Xdoclint:none",
                 "-overview", (srcdir + "/overview.html"),
-                "--frames",
                 "-header", "<A HREF=\"{@docroot}/element-list\">{&#064;docroot}</A> <A HREF=\"{@docRoot}/help-doc.html\">{&#064;docRoot}</A>",
                 "-sourcepath", srcdir,
                 "p1", "p2");
@@ -65,13 +64,7 @@
         checkFiles(
                 "p1/C1.html",
                 "p1/package-summary.html",
-                "overview-summary.html");
-
-        // Bug 4633447: Special test for overview-frame.html
-        // Find two strings in file "overview-frame.html"
-        checkOutput("overview-frame.html", true,
-                "<A HREF=\"./element-list\">",
-                "<A HREF=\"./help-doc.html\">");
+                "index.html");
     }
 
     void checkFiles(String... filenameArray) {
--- a/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java	Tue Apr 09 11:48:54 2019 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4645058 4747738 4855054 8024756 8141492 8196202 8205593
+ * @bug 4645058 4747738 4855054 8024756 8141492 8196202 8205593 8215599
  * @summary  Javascript IE load error when linked by -linkoffline
  *           Window title shouldn't change when loading left frames (javascript)
  * @author dkramer
@@ -46,7 +46,6 @@
     public void test() {
         javadoc("-d", "out",
                 "-source", "8",
-                "--frames",
                 "-doctitle", "Document Title",
                 "-windowtitle", "Window Title",
                 "-overview", testSrc("overview.html"),
@@ -54,26 +53,13 @@
                 "-sourcepath", testSrc,
                 "p1", "p2");
         checkExit(Exit.OK);
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<script type=\"text/javascript\">",
                 "<body class=\"package-index\">");
 
         // Test that "onload" is not present in BODY tag:
         checkOutput("p1/package-summary.html", true, "<body class=\"package-declaration\">");
-        checkOutput("overview-frame.html", true, "<body class=\"package-index-frame\">");
-        checkOutput("allclasses-frame.html", true, "<body class=\"all-classes-frame\">");
-        checkOutput("p1/package-frame.html", true, "<body class=\"package-frame\">");
 
-        // Test that win title javascript is followed by NOSCRIPT code.
-        checkOutput("p1/C.html", true,
-                "<script type=\"text/javascript\"><!--\n"
-                + "    try {\n"
-                + "        if (location.href.indexOf('is-external=true') == -1) {\n"
-                + "            parent.document.title=\"C (Window Title)\";\n"
-                + "        }\n"
-                + "    }\n"
-                + "    catch(err) {\n"
-                + "    }\n"
-                + "//-->\n");
+        checkOutput("p1/C.html", true, "<title>C (Window Title)</title>");
     }
 }
--- a/test/langtools/jdk/javadoc/doclet/MetaTag/MetaTag.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/MetaTag/MetaTag.java	Tue Apr 09 11:48:54 2019 +0100
@@ -55,7 +55,6 @@
         javadoc("-d", "out-1",
                 "-sourcepath", testSrc,
                 "-keywords",
-                "--frames",
                 "-doctitle", "Sample Packages",
                 "p1", "p2");
 
@@ -69,7 +68,6 @@
         javadoc("-d", "out-2",
                 "-sourcepath", testSrc,
                 "-notimestamp",
-                "--frames",
                 "-doctitle", "Sample Packages",
                 "p1", "p2");
         checkExit(Exit.OK);
@@ -89,7 +87,7 @@
         checkOutput("p1/package-summary.html", found,
                 "<meta name=\"keywords\" content=\"p1 package\">");
 
-        checkOutput("overview-summary.html", found,
+        checkOutput("index.html", found,
                 "<meta name=\"keywords\" content=\"Overview, Sample Packages\">");
 
         // NOTE: Hopefully, this regression test is not run at midnight.  If the output
@@ -97,7 +95,7 @@
         // so make sure the date has not changed since the test started
         String date = date();
         if (date.equals(startDate)) {
-            checkOutput("overview-summary.html", found,
+            checkOutput("index.html", found,
                     "<meta name=\"" + metaNameDate + "\" content=\"" + date + "\">");
         }
     }
--- a/test/langtools/jdk/javadoc/doclet/PackagesHeader/PackagesHeader.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2002, 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
- * 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      4766385 8196202
- * @summary  Test that the header option for upper left frame
- *           is present for three sets of options: (1) -header,
- *           (2) -packagesheader, and (3) -header -packagesheader
- * @author   dkramer
- * @library  ../../lib
- * @modules jdk.javadoc/jdk.javadoc.internal.tool
- * @build    javadoc.tester.*
- * @run main PackagesHeader
- */
-
-import javadoc.tester.JavadocTester;
-
-public class PackagesHeader extends JavadocTester {
-
-    public static void main(String... args) throws Exception {
-        JavadocTester tester = new PackagesHeader();
-        tester.runTests();
-    }
-
-    @Test
-    public void testHeader() {
-        // First test with -header only
-        javadoc("-d", "out-header",
-                "-header", "Main Frame Header",
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        // Test that the -header shows up in the packages frame
-        checkOutput("overview-frame.html", true,
-                "Main Frame Header");
-    }
-
-    @Test
-    public void testPackagesHeader() {
-        // Second test with -packagesheader only
-        javadoc("-d", "out-packages-header",
-                "-packagesheader", "Packages Frame Header",
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        // Test that the -packagesheader string shows
-        // up in the packages frame
-        checkOutput("overview-frame.html", true,
-                "Packages Frame Header");
-    }
-
-    @Test
-    public void testBothHeaders() {
-        // Third test with both -packagesheader and -header
-        javadoc("-d", "out-both",
-                "-packagesheader", "Packages Frame Header",
-                "-header", "Main Frame Header",
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        // Test that the both headers show up and are different
-        checkOutput("overview-frame.html", true,
-                "Packages Frame Header");
-
-        checkOutput("overview-summary.html", true,
-                "Main Frame Header");
-    }
-}
--- a/test/langtools/jdk/javadoc/doclet/PackagesHeader/p1/C1.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2002, 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 p1;
-
-public class C1 {
-}
--- a/test/langtools/jdk/javadoc/doclet/PackagesHeader/p2/C2.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2002, 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 p2;
-
-public class C2 {
-}
--- a/test/langtools/jdk/javadoc/doclet/ValidHtml/ValidHtml.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/ValidHtml/ValidHtml.java	Tue Apr 09 11:48:54 2019 +0100
@@ -51,14 +51,10 @@
                     "-doctitle", "Document Title",
                     "-windowtitle", "Window Title",
                     "-use",
-                    "--frames",
                     "-overview", testSrc("overview.html"),
                     "-sourcepath", testSrc,
                     "p1", "p2");
         checkExit(Exit.OK);
-        // Test for IFRAME element:
-        checkOutput("index.html", true,
-                "<iframe");
         // Test the table elements are in the correct order:
         checkOutput("p1/package-use.html", true,
                 "</td>\n"
@@ -73,8 +69,5 @@
         checkOutput("overview-summary.html", true, doctype);
         checkOutput("p1/package-summary.html", true, doctype);
         checkOutput("p1/C.html", true, doctype);
-        checkOutput("overview-frame.html", true, doctype);
-        checkOutput("allclasses-frame.html", true, doctype);
-        checkOutput("p1/package-frame.html", true, doctype);
     }
 }
--- a/test/langtools/jdk/javadoc/doclet/WindowTitles/WindowTitles.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/WindowTitles/WindowTitles.java	Tue Apr 09 11:48:54 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
@@ -49,21 +49,17 @@
         // Test for all cases except the split index page
         javadoc("-d", "out-1",
                 "-use",
-                "--frames",
                 "-sourcepath", testSrc,
                 "p1", "p2");
         checkExit(Exit.OK);
         checkFiles(false, "allclasses-noframe.html");
 
-        checkTitle("overview-summary.html",     "Overview");
+        checkTitle("index.html",                "Overview");
         checkTitle("overview-tree.html",        "Class Hierarchy");
-        checkTitle("overview-frame.html",       "Overview List");
         checkTitle("p1/package-summary.html",   "p1");
-        checkTitle("p1/package-frame.html",     "p1");
         checkTitle("p1/package-tree.html",      "p1 Class Hierarchy");
         checkTitle("p1/package-use.html",       "Uses of Package p1");
         checkTitle("p1/C1.html",                "C1");
-        checkTitle("allclasses-frame.html",     "All Classes");
         checkTitle("constant-values.html",      "Constant Field Values");
         checkTitle("deprecated-list.html",      "Deprecated List");
         checkTitle("serialized-form.html",      "Serialized Form");
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/TestClassDocCatalog.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2016, 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
- * 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 8071982 8196202
- * @summary Test for package-frame.html.
- * @library ../../lib
- * @modules jdk.javadoc/jdk.javadoc.internal.tool
- * @build javadoc.tester.*
- * @run main TestClassDocCatalog
- */
-
-import javadoc.tester.JavadocTester;
-
-public class TestClassDocCatalog extends JavadocTester {
-
-    public static void main(String... args) throws Exception {
-        TestClassDocCatalog tester = new TestClassDocCatalog();
-        tester.runTests();
-    }
-
-    @Test
-    public void test() {
-        javadoc("-d", "out",
-                "--frames",
-                testSrc("pkg1/EmptyAnnotation.java"),
-                testSrc("pkg1/EmptyClass.java"),
-                testSrc("pkg1/EmptyEnum.java"),
-                testSrc("pkg1/EmptyError.java"),
-                testSrc("pkg1/EmptyException.java"),
-                testSrc("pkg1/EmptyInterface.java"),
-                testSrc("pkg2/EmptyAnnotation.java"),
-                testSrc("pkg2/EmptyClass.java"),
-                testSrc("pkg2/EmptyEnum.java"),
-                testSrc("pkg2/EmptyError.java"),
-                testSrc("pkg2/EmptyException.java"),
-                testSrc("pkg2/EmptyInterface.java"));
-        checkExit(Exit.OK);
-
-        checkOutput("overview-frame.html", true,
-                "<li><a href=\"pkg1/package-frame.html\" target=\"packageFrame\">pkg1</a>"
-                + "</li>\n<li><a href=\"pkg2/package-frame.html\" target=\"packageFrame\">pkg2</a></li>");
-
-        checkOutput("pkg1/package-frame.html", true,
-                "<li><a href=\"EmptyInterface.html\" title=\"interface in pkg1\" "
-                + "target=\"classFrame\"><span class=\"interfaceName\">EmptyInterface"
-                + "</span></a></li>",
-                "<li><a href=\"EmptyClass.html\" title=\"class in pkg1\" "
-                + "target=\"classFrame\">EmptyClass</a></li>",
-                "<li><a href=\"EmptyEnum.html\" title=\"enum in pkg1\" "
-                + "target=\"classFrame\">EmptyEnum</a></li>",
-                "<li><a href=\"EmptyError.html\" title=\"class in pkg1\" "
-                + "target=\"classFrame\">EmptyError</a></li>",
-                "<li><a href=\"EmptyAnnotation.html\" title=\"annotation in pkg1\""
-                + " target=\"classFrame\">EmptyAnnotation</a></li>");
-    }
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyAnnotation.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg1;
-
-import java.lang.annotation.Documented;
-
-@Documented public @interface EmptyAnnotation {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyClass.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg1;
-
-public class EmptyClass {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyEnum.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg1;
-
-public enum EmptyEnum {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyError.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg1;
-
-public class EmptyError extends Error {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyException.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg1;
-
-public class EmptyException extends Exception {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg1/EmptyInterface.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg1;
-
-public interface EmptyInterface {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyAnnotation.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg2;
-
-import java.lang.annotation.Documented;
-
-@Documented public @interface EmptyAnnotation {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyClass.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg2;
-
-public class EmptyClass {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyEnum.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg2;
-
-public enum EmptyEnum {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyError.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg2;
-
-public class EmptyError extends Error {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyException.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg2;
-
-public class EmptyException extends Exception {
-}
--- a/test/langtools/jdk/javadoc/doclet/testClassDocCatalog/pkg2/EmptyInterface.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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 pkg2;
-
-public interface EmptyInterface {
-}
--- a/test/langtools/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,431 +0,0 @@
-/*
- * 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
- * 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 8162353 8164747 8173707 8196202 8204303 8184205
- * @summary javadoc should provide a way to disable use of frames
- * @library /tools/lib ../../lib
- * @modules
- *      jdk.compiler/com.sun.tools.javac.api
- *      jdk.compiler/com.sun.tools.javac.main
- *      jdk.javadoc/jdk.javadoc.internal.tool
- * @build toolbox.ModuleBuilder toolbox.ToolBox
- * @build javadoc.tester.*
- * @run main TestFramesNoFrames
- */
-
-import java.io.*;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.*;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import toolbox.ModuleBuilder;
-import toolbox.ToolBox;
-
-import javadoc.tester.JavadocTester;
-
-public class TestFramesNoFrames extends JavadocTester {
-
-    public static void main(String... args) throws Exception {
-        TestFramesNoFrames tester = new TestFramesNoFrames();
-        tester.generateSource();
-        tester.runTests();
-    }
-
-    ToolBox tb = new ToolBox();
-    Path gensrcModules = Paths.get("gensrc/modules");
-    Path gensrcPackages = Paths.get("gensrc/packages");
-
-    void generateSource() throws IOException {
-        String[] modules = { "", "m1", "m2", "m3" };
-        String[] packages = { "p1", "p2", "p3" };
-        String[] classes = { "C1", "C2", "C3" };
-        for (String m: modules) {
-            ModuleBuilder mb = m.equals("") ? null : new ModuleBuilder(tb, m);
-            for (String p: packages) {
-                Path pkgRoot;
-                if (m.equals("")) {
-                    pkgRoot = gensrcPackages;
-                } else {
-                    pkgRoot = gensrcModules.resolve(m);
-                    mb.exports(m + p);
-                }
-                for (String c: classes) {
-                    tb.writeJavaFiles(pkgRoot,
-                        "package " + (m + p) + ";\n"
-                        + "/** class " + (m + p + c).toUpperCase() + ". */\n"
-                        + "public class " + (m + p + c).toUpperCase() + " { }"
-                    );
-                }
-            }
-            if (!m.equals("")) {
-                mb.write(gensrcModules);
-            }
-        }
-        tb.writeFile("overview.html",
-                "<html><body>This is the overview file</body></html>");
-    }
-
-    enum FrameKind {
-        DEFAULT(),
-        FRAMES("--frames"),
-        NO_FRAMES("--no-frames");
-        FrameKind(String... opts) {
-            this.opts = Arrays.asList(opts);
-        }
-        final List<String> opts;
-    }
-
-    enum OverviewKind {
-        DEFAULT(),
-        OVERVIEW("-overview", "overview.html"),
-        NO_OVERVIEW("-nooverview");
-        OverviewKind(String... opts) {
-            this.opts = Arrays.asList(opts);
-        }
-        final List<String> opts;
-    }
-
-    enum HtmlKind {
-        HTML5("-html5");
-        HtmlKind(String... opts) {
-            this.opts = Arrays.asList(opts);
-        }
-        final List<String> opts;
-    }
-
-    @Override
-    public void runTests() throws Exception {
-        for (Method m : getClass().getDeclaredMethods()) {
-            Annotation a = m.getAnnotation(Test.class);
-            if (a != null) {
-                for (FrameKind fk : FrameKind.values()) {
-                    for (OverviewKind ok : OverviewKind.values()) {
-                        try {
-                            out.println("Running test " + m.getName() + " " + fk + " " + ok);
-                            Path base = Paths.get(m.getName() + "_" + fk + "_" + ok);
-                            Files.createDirectories(base);
-                            m.invoke(this, new Object[]{base, fk, ok});
-                        } catch (InvocationTargetException e) {
-                            Throwable cause = e.getCause();
-                            throw (cause instanceof Exception) ? ((Exception)cause) : e;
-                        }
-                        out.println();
-                    }
-                }
-            }
-        }
-        printSummary();
-    }
-
-    void javadoc(Path outDir, FrameKind fKind, OverviewKind oKind, String... rest) {
-        List<String> args = new ArrayList<>();
-        args.add("-d");
-        args.add(outDir.toString());
-        args.addAll(fKind.opts);
-        args.addAll(oKind.opts);
-        args.addAll(Arrays.asList(rest));
-        javadoc(args.toArray(new String[0]));
-        checkExit(Exit.OK);
-    }
-
-    @Test
-    public void testClass(Path base, FrameKind fKind, OverviewKind oKind) throws Exception {
-        javadoc(base, fKind, oKind, gensrcPackages.resolve("p1/P1C1.java").toString());
-
-        new Checker(fKind, oKind)
-            .classes("p1.P1C1")
-            .check();
-    }
-
-    @Test
-    public void testClasses(Path base, FrameKind fKind, OverviewKind oKind) throws IOException {
-        javadoc(base, fKind, oKind,
-            gensrcPackages.resolve("p1/P1C1.java").toString(),
-            gensrcPackages.resolve("p1/P1C2.java").toString(),
-            gensrcPackages.resolve("p1/P1C3.java").toString());
-
-        new Checker(fKind, oKind)
-            .classes("p1.P1C1", "p1.P1C2", "p1.P1C3")
-            .check();
-    }
-
-    @Test
-    public void testPackage(Path base, FrameKind fKind, OverviewKind oKind) throws IOException {
-        javadoc(base, fKind, oKind,
-            "-sourcepath", gensrcPackages.toString(),
-            "p1");
-
-        new Checker(fKind, oKind)
-            .classes("p1.P1C1", "p1.P1C2", "p1.P1C3")
-            .check();
-    }
-
-    @Test
-    public void testPackages(Path base, FrameKind fKind, OverviewKind oKind) throws IOException {
-        javadoc(base, fKind, oKind,
-            "-sourcepath", gensrcPackages.toString(),
-            "p1", "p2", "p3");
-
-        new Checker(fKind, oKind)
-            .classes("p1.P1C1", "p1.P1C2", "p1.P1C3",
-                    "p2.P2C1", "p2.P2C2", "p2.P2C3",
-                    "p3.P3C1", "p3.P3C2", "p3.P3C3")
-            .check();
-    }
-
-    @Test
-    public void testModules(Path base, FrameKind fKind, OverviewKind oKind) throws IOException {
-        javadoc(base, fKind, oKind,
-            "--module-source-path", gensrcModules.toString(),
-            "--module", "m1,m2,m3");
-
-        new Checker(fKind, oKind)
-            .classes("m1/m1p1.M1P1C1", "m1/m1p1.M1P1C2", "m1/m1p1.M1P1C3",
-                    "m2/m2p1.M2P1C1", "m2/m2p1.M2P1C2", "m2/m2p1.M2P1C3",
-                    "m3/m3p1.M3P1C1", "m3/m3p1.M3P1C2", "m3/m3p1.M3P1C3")
-            .check();
-    }
-
-    /**
-     * Check the contents of the generated output, according to the
-     * specified options.
-     */
-    class Checker {
-        private final FrameKind fKind;
-        private final OverviewKind oKind;
-        List<String> classes;
-
-        private boolean frames;
-        private boolean overview;
-        private static final String framesWarning
-                = "javadoc: warning - You have specified to generate frames, by using the --frames option.\n"
-                + "The default is currently to not generate frames and the support for \n"
-                + "frames will be removed in a future release.\n"
-                + "To suppress this warning, remove the --frames option and avoid the use of frames.";
-
-        Checker(FrameKind fKind, OverviewKind oKind) {
-            this.fKind = fKind;
-            this.oKind = oKind;
-        }
-
-        Checker classes(String... classes) {
-            this.classes = Arrays.asList(classes);
-            return this;
-        }
-
-        void check() throws IOException {
-            switch (fKind) {
-                case FRAMES:
-                    frames = true;
-                    break;
-
-                case DEFAULT:
-                case NO_FRAMES:
-                    frames = false;
-                    break;
-            }
-
-            switch (oKind) {
-                case DEFAULT:
-                    overview = (getPackageCount() > 1);
-                    break;
-
-                case OVERVIEW:
-                    overview = true;
-                    break;
-
-                case NO_OVERVIEW:
-                    overview = false;
-                    break;
-            }
-
-            out.println("Checker: " + fKind + " " + oKind
-                + ": frames:" + frames + " overview:" + overview);
-
-            checkAllClassesFiles();
-            checkFrameFiles();
-            checkOverviewSummary();
-
-            checkIndex();
-            checkNavBar();
-            checkHelpDoc();
-
-            checkWarning();
-
-        }
-
-        private void checkAllClassesFiles() {
-            // these files are only generated in frames mode
-            checkFiles(frames,
-                    "allclasses-frame.html");
-
-            checkFiles(false,
-                    "allclasses.html");
-
-            checkFiles(false,
-                    "allclasses-noframe.html");
-
-            if (frames) {
-                checkOutput("allclasses-frame.html", true,
-                        classes.stream()
-                            .map(c -> "title=\"class in " + packagePart(c) + "\" target=\"classFrame\">" + classPart(c) + "</a>")
-                            .toArray(String[]::new));
-            }
-        }
-
-        private void checkFrameFiles() {
-            // these files are all only generated in frames mode
-
-            // <module>/module-frame.html and <module>/module-type-frame.html files
-            checkFiles(frames, classes.stream()
-                .filter(c -> isInModule(c))
-                .map(c -> modulePart(c))
-                .flatMap(m -> Arrays.asList(
-                        m + "/module-frame.html",
-                        m + "/module-type-frame.html").stream())
-                .collect(Collectors.toSet()));
-
-            // <package>/package-frame.html files
-            checkFiles(frames, classes.stream()
-                    .map(c -> (isInModule(c) ? (modulePart(c) + "/") : "")
-                                + packagePart(c)
-                                + "/package-frame.html")
-                    .collect(Collectors.toSet()));
-        }
-
-        private void checkHelpDoc() {
-            // the Help page only describes Frame/NoFrames in frames mode
-            checkOutput("help-doc.html", frames,
-                        "<h2>Frames/No Frames</h2>");
-        }
-
-        private void checkIndex() {
-            // the index.html page only contains frames and Javascript to default to no-frames view,
-            // in frames mode
-            checkOutput("index.html", frames,
-                    "<iframe ",
-                    "</iframe>",
-                    "<body class=\"frames\" onload=\"loadFrames()\">\n"
-                    + "<script type=\"text/javascript\">\n"
-                    + "if (targetPage == \"\" || targetPage == \"undefined\")");
-
-            // the index.html contains the overview if one
-            // has been given, and not in frames mode
-            checkOutput("index.html", !frames && oKind == OverviewKind.OVERVIEW,
-                    "This is the overview file");
-
-            // the index.html file contains a summary table
-            // if an overview was generated and not in frames mode
-            checkOutput("index.html", !frames && overview,
-                    "<div class=\"overviewSummary\">\n<table");
-
-            // the index.html file contains a redirect if
-            // no frames and no overview
-            checkOutput("index.html", !frames && !overview,
-                    "<meta http-equiv=\"Refresh\" content=\"0;",
-                    "<script type=\"text/javascript\">window.location.replace(");
-
-            if (!frames && !overview) {
-                checkOutput("index.html", true,
-                        "<noscript>\n<meta http-equiv=\"Refresh\" content=\"0;");
-            }
-        }
-
-        private void checkNavBar() {
-            // the files containing a navigation bar should only
-            // contain FRAMES/NO-FRAMES links in frames mode
-            List<String> navbarFiles = new ArrayList<>();
-            navbarFiles.addAll(classes.stream()
-                    .map(c -> (isInModule(c) ? (modulePart(c) + "/") : "")
-                                + toHtml(packageClassPart(c)))
-                    .collect(Collectors.toSet()));
-            for (String f : navbarFiles) {
-                checkOutput(f, frames,
-                        "target=\"_top\">Frames</a>",
-                        "target=\"_top\">No&nbsp;Frames</a>");
-            }
-        }
-
-        private void checkOverviewSummary() {
-            // To accommodate the historical behavior of generating
-            // overview-summary.html in frames mode, the file
-            // will still be generated in no-frames mode,
-            // but will be a redirect to index.html
-            checkFiles(overview,
-                    "overview-summary.html");
-            if (overview) {
-                checkOutput("overview-summary.html",  !frames,
-                        "<link rel=\"canonical\" href=\"index.html\">",
-                        "<script type=\"text/javascript\">window.location.replace('index.html')</script>",
-                        "<meta http-equiv=\"Refresh\" content=\"0;index.html\">",
-                        "<p><a href=\"index.html\">index.html</a></p>");
-            }
-        }
-
-        private void checkWarning() {
-            checkOutput(Output.OUT, frames, framesWarning);
-        }
-
-        private long getPackageCount() {
-            return this.classes.stream()
-                .filter(name -> name.contains("."))
-                .map(name -> name.substring(0, name.lastIndexOf(".")))
-                .distinct()
-                .count();
-        }
-
-        private String classPart(String className) {
-            int lastDot = className.lastIndexOf(".");
-            return className.substring(lastDot + 1);
-        }
-
-        private String packagePart(String className) {
-            int slash = className.indexOf("/");
-            int lastDot = className.lastIndexOf(".");
-            return className.substring(slash + 1, lastDot);
-        }
-
-        private String packageClassPart(String className) {
-            int slash = className.indexOf("/");
-            return className.substring(slash + 1);
-        }
-
-        private boolean isInModule(String className) {
-            return className.contains("/");
-        }
-
-        private String modulePart(String className) {
-            int slash = className.indexOf("/");
-            return className.substring(0, slash);
-        }
-
-        private String toHtml(String className) {
-            return className.replace(".", "/") + ".html";
-        }
-    }
-}
--- a/test/langtools/jdk/javadoc/doclet/testGeneratedBy/TestGeneratedBy.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testGeneratedBy/TestGeneratedBy.java	Tue Apr 09 11:48:54 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
@@ -43,7 +43,6 @@
     @Test
     public void testTimestamp() {
         javadoc("-d", "out-timestamp",
-                "--frames",
             "-sourcepath", testSrc,
             "pkg");
         checkExit(Exit.OK);
@@ -56,7 +55,6 @@
     public void testNoTimestamp() {
         javadoc("-d", "out-notimestamp",
             "-notimestamp",
-                "--frames",
             "-sourcepath", testSrc,
             "pkg");
         checkExit(Exit.OK);
@@ -69,10 +67,8 @@
         checkTimestamps(timestamp,
         "pkg/MyClass.html",
         "pkg/package-summary.html",
-        "pkg/package-frame.html",
         "pkg/package-tree.html",
         "constant-values.html",
-        "allclasses-frame.html",
         "overview-tree.html",
         "deprecated-list.html",
         "serialized-form.html",
--- a/test/langtools/jdk/javadoc/doclet/testGroupName/TestGroupName.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testGroupName/TestGroupName.java	Tue Apr 09 11:48:54 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
@@ -59,13 +59,12 @@
                 "package p3; public class C3 { }");
 
         javadoc("-d", base.resolve("out").toString(),
-                "--frames",
                 "-sourcepath", src.toString(),
                 "-group", "abc < & > def", "p1",
                 "p1", "p2", "p3");
         checkExit(Exit.OK);
 
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<button role=\"tab\" aria-selected=\"false\" aria-controls=\"overviewSummary_tabpanel\""
                 + " tabindex=\"-1\" onkeydown=\"switchTab(event)\" id=\"t1\" class=\"tableTab\""
                 + " onclick=\"show(1);\">abc &lt; &amp; &gt; def</button>",
@@ -94,14 +93,13 @@
                 "package pc3; public class CC3 { }");
 
         javadoc("-d", base.resolve("out").toString(),
-                "--frames",
                 "--module-source-path", src.toString(),
                 "-group", "abc < & > def", "ma",
                 "--module", "ma,mb,mc");
 
         checkExit(Exit.OK);
 
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<button role=\"tab\" aria-selected=\"false\" aria-controls=\"overviewSummary_tabpanel\""
                 + " tabindex=\"-1\" onkeydown=\"switchTab(event)\" id=\"t2\" class=\"tableTab\""
                 + " onclick=\"show(2);\">Other Modules</button>",
--- a/test/langtools/jdk/javadoc/doclet/testGroupOption/TestGroupOption.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testGroupOption/TestGroupOption.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, 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
@@ -62,7 +62,6 @@
     // Make sure that the headers of group that is defined using patterns are printed.
     public void test2() {
         javadoc("-d", "out-2",
-                "--frames",
                 "-sourcepath", testSrc,
                 "-group", "Group pkg*", "pkg*",
                 "-group", "Group abc*", "abc*",
@@ -71,8 +70,8 @@
                 "pkg1", "pkg2", "pkg3", "abc1",  "abc2", "abc3", "other", testSrc("InUnnamedPackage.java"));
         checkExit(Exit.OK);
 
-        checkOutput("overview-summary.html", true, "Group pkg*", "Group abc*", "Other Packages");
-        checkOutput("overview-summary.html", false, "Empty group", "Group a*");
+        checkOutput("index.html", true, "Group pkg*", "Group abc*", "Other Packages");
+        checkOutput("index.html", false, "Empty group", "Group a*");
     }
 
     @Test
--- a/test/langtools/jdk/javadoc/doclet/testHeadings/TestHeadings.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHeadings/TestHeadings.java	Tue Apr 09 11:48:54 2019 +0100
@@ -47,7 +47,6 @@
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "-header", "Test Files",
                 "pkg1", "pkg2");
         checkExit(Exit.OK);
@@ -93,13 +92,8 @@
                 + "pkg1.C1</a> extends java.lang.Object implements Serializable</h3>",
                 "<h4>Serialized Fields</h4>");
 
-        // Overview Frame
-        checkOutput("overview-frame.html", true,
-                "<h1 title=\"Test Files\" class=\"bar\">Test Files</h1>",
-                "<title>Overview List</title>");
-
         // Overview Summary
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<title>Overview</title>");
     }
 }
--- a/test/langtools/jdk/javadoc/doclet/testHiddenTag/TestHiddenTag.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHiddenTag/TestHiddenTag.java	Tue Apr 09 11:48:54 2019 +0100
@@ -46,7 +46,6 @@
     @Test
     public void test1() {
         javadoc("-d", "out1",
-                "--frames",
                 "-sourcepath", testSrc,
                 "-package",
                 "pkg1");
@@ -91,8 +90,6 @@
                 "invisibleMethod",
                 "A.InvisibleInner");
 
-        checkOutput("pkg1/package-frame.html", false, "A.InvisibleInner");
-
         checkOutput("pkg1/package-summary.html", false, "A.InvisibleInner");
 
         checkOutput("pkg1/package-tree.html", false, "A.InvisibleInner");
--- a/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlLandmarkRegions/TestHtmlLandmarkRegions.java	Tue Apr 09 11:48:54 2019 +0100
@@ -69,32 +69,12 @@
         javadoc("-d", outDir.toString(),
                 "-doctitle", "Document Title",
                 "-header", "Test Header",
-                "--frames",
                 "--module-source-path", srcDir.toString(),
                 "--module", "m1,m2");
 
         checkExit(Exit.OK);
 
-        checkOrder("module-overview-frame.html",
-                "<header role=\"banner\">\n"
-                + "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
-                + "<nav role=\"navigation\" class=\"indexNav\">",
-                "<main role=\"main\">\n"
-                + "<div class=\"indexContainer\">\n"
-                + "<h2 title=\"Modules\">Modules</h2>\n"
-                + "<ul title=\"Modules\">",
-                "<footer role=\"contentinfo\">");
-
-        checkOrder("m1/module-frame.html",
-                "<header role=\"banner\">\n"
-                + "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
-                + "<nav role=\"navigation\" class=\"indexNav\">",
-                "<main role=\"main\">\n"
-                + "<div class=\"indexContainer\">\n"
-                + "<h2 title=\"m1\"><a href=\"module-summary.html\" target=\"classFrame\">m1</a>&nbsp;Packages</h2>",
-                "<footer role=\"contentinfo\">");
-
-        checkOrder("overview-summary.html",
+        checkOrder("index.html",
                 "<header role=\"banner\">\n"
                 + "<nav role=\"navigation\">",
                 "<main role=\"main\">\n"
@@ -113,13 +93,12 @@
         javadoc("-d", outDir.toString(),
                 "-doctitle", "Document Title",
                 "-header", "Test Header",
-                "--frames",
                 "-sourcepath", srcDir.toString(),
                 "pkg1", "pkg2");
 
         checkExit(Exit.OK);
 
-        checkOrder("overview-summary.html",
+        checkOrder("index.html",
                 "<header role=\"banner\">\n"
                 + "<nav role=\"navigation\">",
                 "<main role=\"main\">\n"
@@ -127,15 +106,6 @@
                 + "<h1 class=\"title\">Document Title</h1>",
                 "<footer role=\"contentinfo\">\n" +
                         "<nav role=\"navigation\">");
-
-        checkOrder("overview-frame.html",
-                "<header role=\"banner\">\n"
-                + "<h1 title=\"Test Header\" class=\"bar\">Test Header</h1>\n"
-                + "<nav role=\"navigation\" class=\"indexNav\">",
-                "<main role=\"main\">\n"
-                + "<div class=\"indexContainer\">\n"
-                + "<h2 title=\"Packages\">Packages</h2>",
-                "<footer role=\"contentinfo\">");
     }
 
     @Test
--- a/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java	Tue Apr 09 11:48:54 2019 +0100
@@ -46,7 +46,6 @@
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg1", "pkg2");
         checkExit(Exit.ERROR);
         checkOutput(Output.OUT, true,
@@ -68,7 +67,7 @@
         checkOutput("pkg1/class-use/TestTable.html", true,
                 "<div class=\"useSummary\">\n<table>");
 
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"overviewSummary\">\n<table>");
 
         checkOutput("deprecated-list.html", true,
--- a/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlTableTags/TestHtmlTableTags.java	Tue Apr 09 11:48:54 2019 +0100
@@ -52,7 +52,6 @@
         javadoc("-d", "out",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg1", "pkg2");
         checkExit(Exit.OK);
 
@@ -129,7 +128,7 @@
                 "<div class=\"constantsSummary\">\n<table>");
 
         // Overview Summary
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"overviewSummary\">\n<table>");
     }
 
@@ -240,7 +239,7 @@
                 + "constant fields, and values\">");
 
         // Overview Summary
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"overviewSummary\">\n"
                 + "<table summary=\"Package Summary table, listing packages, and an explanation\">");
     }
@@ -353,7 +352,7 @@
                 + "C1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>");
 
         // Overview Summary
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>");
     }
 
@@ -469,7 +468,7 @@
                 + "<th class=\"colLast\" scope=\"col\">Value</th>");
 
         // Overview Summary
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<th class=\"colFirst\" scope=\"col\">"
                 + "Package</th>\n"
                 + "<th class=\"colLast\" scope=\"col\""
--- a/test/langtools/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlTag/TestHtmlTag.java	Tue Apr 09 11:48:54 2019 +0100
@@ -109,7 +109,7 @@
 
         checkOutput("pkg3/package-summary.html", true,
                 "<div class=\"contentContainer\">\n"
-                + "<section role=\"region\"><a id=\"package.description\">\n"
+                + "<section><a id=\"package.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<div class=\"block\"><p>This is the first line. Note the newlines before the &lt;p&gt; is relevant.</div>\n"
--- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java	Tue Apr 09 11:48:54 2019 +0100
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 8072945 8081854 8141492 8148985 8150188 4649116 8173707 8151743 8169819 8183037 8182765 8196202
- *      8202624 8210047 8184205
+ *      8202624 8210047 8184205 8221871
  * @summary Test the version of HTML generated by the javadoc tool.
  * @author bpatel
  * @library ../../lib
@@ -47,7 +47,6 @@
         javadoc("-d", "out-1",
                 "-private",
                 "-linksource",
-                "--frames",
                 "-sourcepath", testSrc,
                 "-use",
                 "pkg", "pkg1", "pkg2", "pkg3");
@@ -69,29 +68,8 @@
     }
 
     void html5Output() {
-        // Test for overview-frame page
-        checkOutput("overview-frame.html", true,
-                "<!DOCTYPE HTML>",
-                "<meta name=\"dc.created\"",
-                "<nav role=\"navigation\" class=\"indexNav\">\n"
-                + "<ul>\n"
-                + "<li><a href=\"allclasses-frame.html\" target=\"packageFrame\">All&nbsp;Classes</a></li>",
-                "<main role=\"main\">\n"
-                + "<div class=\"indexContainer\">\n"
-                + "<h1 title=\"Packages\">Packages</h1>");
-
-        // Test for allclasses-frame page
-        checkOutput("allclasses-frame.html", true,
-                "<!DOCTYPE HTML>",
-                "<meta name=\"dc.created\"",
-                "<main role=\"main\">\n"
-                + "<h1 class=\"bar\">All&nbsp;Classes</h1>\n"
-                + "<div class=\"indexContainer\">\n"
-                + "<ul>\n"
-                + "<li>");
-
         // Test for overview-summary page
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<!DOCTYPE HTML>",
                 "<meta name=\"dc.created\"",
                 "<a id=\"navbar.top.firstrow\">\n"
@@ -108,25 +86,6 @@
                 + "<nav role=\"navigation\">\n"
                 + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
 
-        // Test for package-frame page
-        checkOutput("pkg/package-frame.html", true,
-                "<!DOCTYPE HTML>",
-                "<meta name=\"dc.created\"",
-                "<main role=\"main\">\n"
-                + "<h1 class=\"bar\"><a href=\"package-summary.html\" target=\"classFrame\">pkg</a></h1>",
-                "<section role=\"region\">\n"
-                + "<h2 title=\"Interfaces\">Interfaces</h2>",
-                "<section role=\"region\">\n"
-                + "<h2 title=\"Classes\">Classes</h2>",
-                "<section role=\"region\">\n"
-                + "<h2 title=\"Enums\">Enums</h2>",
-                "<section role=\"region\">\n"
-                + "<h2 title=\"Exceptions\">Exceptions</h2>",
-                "<section role=\"region\">\n"
-                + "<h2 title=\"Errors\">Errors</h2>",
-                "<section role=\"region\">\n"
-                + "<h2 title=\"Annotation Types\">Annotation Types</h2>");
-
         // Test for package-summary page
         checkOutput("pkg/package-summary.html", true,
                 "<!DOCTYPE HTML>",
@@ -141,7 +100,7 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\"><a id=\"package.description\">\n"
+                "<section><a id=\"package.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<div class=\"block\">Test package.</div>",
@@ -170,13 +129,13 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Class Hierarchy\">Class Hierarchy</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Interface Hierarchy\">Interface Hierarchy</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Annotation Type Hierarchy\">Annotation Type Hierarchy</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Enum Hierarchy\">Enum Hierarchy</h2>",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
@@ -214,9 +173,9 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Contents\">Contents</h2>\n",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"pkg\">pkg.*</h2>\n",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
@@ -253,7 +212,7 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Package\">Package&nbsp;pkg</h2>\n",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
@@ -273,13 +232,13 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Class Hierarchy\">Class Hierarchy</h2>\n",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Interface Hierarchy\">Interface Hierarchy</h2>\n",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Annotation Type Hierarchy\">Annotation Type Hierarchy</h2>\n",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Enum Hierarchy\">Enum Hierarchy</h2>\n",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
@@ -321,11 +280,11 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2>Overview</h2>\n",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2>Package</h2>\n",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2>Class or Interface</h2>\n",
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
@@ -344,46 +303,46 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"nested.class.summary\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Nested Class Summary</h2>\n"
                 + "<div class=\"memberSummary\">\n<table>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"field.summary\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Field Summary</h2>\n"
                 + "<div class=\"memberSummary\">\n<table>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"constructor.summary\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Constructor Summary</h2>\n"
                 + "<div class=\"memberSummary\">\n<table>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"method.summary\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Method Summary</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"field.detail\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Field Detail</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"constructor.detail\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Constructor Detail</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"method.detail\">\n"
                 + "<!--   -->\n"
@@ -406,7 +365,7 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"enum.constant.summary\">\n"
                 + "<!--   -->\n"
@@ -414,7 +373,7 @@
                 + "<h2>Enum Constant Summary</h2>\n"
                 + "<div class=\"memberSummary\">\n",
                 "<table aria-labelledby=\"t0\">\n",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"method.summary\">\n"
                 + "<!--   -->\n"
@@ -422,13 +381,13 @@
                 + "<h2>Method Summary</h2>\n"
                 + "<div class=\"memberSummary\">\n",
                 "<table aria-labelledby=\"t0\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"enum.constant.detail\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Enum Constant Detail</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"method.detail\">\n"
                 + "<!--   -->\n"
@@ -451,7 +410,7 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"method.summary\">\n"
                 + "<!--   -->\n"
@@ -459,7 +418,7 @@
                 + "<h2>Method Summary</h2>\n"
                 + "<div class=\"memberSummary\">\n",
                 "<table aria-labelledby=\"t0\">\n",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"method.detail\">\n"
                 + "<!--   -->\n"
@@ -482,13 +441,13 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"constructor.summary\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Constructor Summary</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"constructor.detail\">\n"
                 + "<!--   -->\n"
@@ -511,13 +470,13 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"constructor.summary\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Constructor Summary</h2>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"constructor.detail\">\n"
                 + "<!--   -->\n"
@@ -540,21 +499,21 @@
                 + "<!-- ========= START OF TOP NAVBAR ======= -->",
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"annotation.type.required.element.summary\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Required Element Summary</h2>\n"
                 + "<div class=\"memberSummary\">\n<table>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"annotation.type.optional.element.summary\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Optional Element Summary</h2>\n"
                 + "<div class=\"memberSummary\">\n<table>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<ul class=\"blockList\">\n"
                 + "<li class=\"blockList\"><a id=\"annotation.type.element.detail\">\n"
                 + "<!--   -->\n"
@@ -578,7 +537,7 @@
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">",
                 "<div class=\"useSummary\">\n<table>",
-                "<section role=\"region\"><a id=\"pkg\">\n"
+                "<section><a id=\"pkg\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<h2>Uses of <a href=\"../RegClass.html\" title=\"class in pkg1\">RegClass</a> in <a href=\"../../pkg/package-summary.html\">pkg</a></h2>\n"
@@ -586,44 +545,9 @@
                 "<footer role=\"contentinfo\">\n"
                 + "<nav role=\"navigation\">\n"
                 + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
-
-        // Test for main index page
-        checkOutput("index.html", true,
-                "<!DOCTYPE HTML>",
-                "<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" title=\"Style\">",
-                "<body class=\"frames\" onload=\"loadFrames()\">\n"
-                + "<script type=\"text/javascript\">\n"
-                + "if (targetPage == \"\" || targetPage == \"undefined\")\n"
-                + "     window.location.replace('overview-summary.html');\n"
-                + "</script>\n"
-                + "<noscript>JavaScript is disabled on your browser.</noscript>\n"
-                + "<main role=\"main\">\n"
-                + "<div class=\"mainContainer\">\n"
-                + "<div class=\"leftContainer\">\n"
-                + "<div class=\"leftTop\">\n"
-                + "<iframe src=\"overview-frame.html\" name=\"packageListFrame\" title=\"All Packages\"></iframe>\n"
-                + "</div>");
     }
 
     void html5NegatedOutput() {
-        // Negated test for overview-frame page
-        checkOutput("overview-frame.html", false,
-                "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
-                "<meta name=\"date\"",
-                "<div class=\"indexNav\">\n"
-                + "<ul>\n"
-                + "<li><a href=\"allclasses-frame.html\" target=\"packageFrame\">All&nbsp;Classes</a></li>",
-                "<main class=\"indexContainer\">\n"
-                + "<h2 title=\"Packages\">Packages</h2>");
-
-        // Negated test for allclasses-frame page
-        checkOutput("allclasses-frame.html", false,
-                "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
-                "<meta name=\"date\"",
-                "<main class=\"indexContainer\">\n"
-                + "<ul>\n"
-                + "<li>");
-
         // Negated test for overview-summary page
         checkOutput("overview-summary.html", false,
                 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
@@ -637,13 +561,6 @@
                 + "<div class=\"fixedNav\">\n"
                 + "<!-- ========= START OF TOP NAVBAR ======= -->");
 
-        // Negated test for package-frame page
-        checkOutput("pkg/package-frame.html", false,
-                "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
-                "<meta name=\"date\"",
-                "<body>\n"
-                + "<h1 class=\"bar\"><a href=\"package-summary.html\" target=\"classFrame\">pkg</a></h1>");
-
         // Negated test for package-summary page
         checkOutput("pkg/package-summary.html", false,
                 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
@@ -651,7 +568,7 @@
                 "<a name=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<h2 title=\"Package pkg Description\">Package pkg Description</h2>\n",
                 "<div class=\"typeSummary\">\n<table summary=\"Interface Summary table, listing interfaces, and an explanation\">",
                 "<div class=\"typeSummary\">\n<table summary=\"Class Summary table, listing classes, and an explanation\">",
--- a/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, 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
@@ -46,15 +46,10 @@
     @Test
     public void test() {
         javadoc("-d", "out",
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg", testSrc("NoPackage.java"));
         checkExit(Exit.OK);
 
-        checkOutput("index.html", true,
-                "<iframe src=\"overview-summary.html\" name=\"classFrame\" title=\""
-                + "Package, class and interface descriptions\" class=\"rightIframe\">");
-
         //Test index-all.html
         checkOutput("index-all.html", true,
                 "<a href=\"pkg/C.html\" title=\"class in pkg\"><span class=\"typeNameLink\">C</span></a>"
--- a/test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java	Tue Apr 09 11:48:54 2019 +0100
@@ -87,14 +87,13 @@
         Path out = base.resolve("out");
         javadoc("-d", out.toString(),
                 "--module-source-path", src.toString(),
-                "--module", "m1,m3,m4",
-                "--frames");
+                "--module", "m1,m3,m4");
 
         checkExit(Exit.OK);
 
-        checkOutput("index.html", true,
-                "window.location.replace('overview-summary.html')");
-        checkOrder("overview-summary.html",
+        checkOutput("overview-summary.html", true,
+                "window.location.replace('index.html')");
+        checkOrder("index.html",
                 "Modules",
                 "<a href=\"m1/module-summary.html\">m1</a>",
                 "<a href=\"m3/module-summary.html\">m3</a>",
--- a/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java	Tue Apr 09 11:48:54 2019 +0100
@@ -44,88 +44,20 @@
     @Test
     public void test() {
         javadoc("-d", "out",
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg", testSrc("TestJavascript.java"));
         checkExit(Exit.OK);
 
         checkOutput("pkg/C.html", true,
-                "<a href=\"../index.html?pkg/C.html\" target=\"_top\">Frames</a>",
                 "<script type=\"text/javascript\"><!--\n"
                 + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
                 + "//-->\n"
                 + "</script>");
 
-        checkOutput("TestJavascript.html", true,
-                "<a href=\"index.html?TestJavascript.html\" target=\"_top\">Frames</a>");
-
         checkOutput("index.html", true,
-                "<script type=\"text/javascript\">\n"
-                + "    tmpTargetPage = \"\" + window.location.search;\n"
-                + "    if (tmpTargetPage != \"\" && tmpTargetPage != \"undefined\")\n"
-                + "        tmpTargetPage = tmpTargetPage.substring(1);\n"
-                + "    if (tmpTargetPage.indexOf(\":\") != -1 || (tmpTargetPage != \"\" && !validURL(tmpTargetPage)))\n"
-                + "        tmpTargetPage = \"undefined\";\n"
-                + "    targetPage = tmpTargetPage;\n"
-                + "    function validURL(url) {\n"
-                + "        try {\n"
-                + "            url = decodeURIComponent(url);\n"
-                + "        }\n"
-                + "        catch (error) {\n"
-                + "            return false;\n"
-                + "        }\n"
-                + "        var pos = url.indexOf(\".html\");\n"
-                + "        if (pos == -1 || pos != url.length - 5)\n"
-                + "            return false;\n"
-                + "        var allowNumber = false;\n"
-                + "        var allowSep = false;\n"
-                + "        var seenDot = false;\n"
-                + "        for (var i = 0; i < url.length - 5; i++) {\n"
-                + "            var ch = url.charAt(i);\n"
-                + "            if ('a' <= ch && ch <= 'z' ||\n"
-                + "                    'A' <= ch && ch <= 'Z' ||\n"
-                + "                    ch == '$' ||\n"
-                + "                    ch == '_' ||\n"
-                + "                    ch.charCodeAt(0) > 127) {\n"
-                + "                allowNumber = true;\n"
-                + "                allowSep = true;\n"
-                + "            } else if ('0' <= ch && ch <= '9'\n"
-                + "                    || ch == '-') {\n"
-                + "                if (!allowNumber)\n"
-                + "                     return false;\n"
-                + "            } else if (ch == '/' || ch == '.') {\n"
-                + "                if (!allowSep)\n"
-                + "                    return false;\n"
-                + "                allowNumber = false;\n"
-                + "                allowSep = false;\n"
-                + "                if (ch == '.')\n"
-                + "                     seenDot = true;\n"
-                + "                if (ch == '/' && seenDot)\n"
-                + "                     return false;\n"
-                + "            } else {\n"
-                + "                return false;\n"
-                + "            }\n"
-                + "        }\n"
-                + "        return true;\n"
-                + "    }\n"
-                + "    function loadFrames() {\n"
-                + "        if (targetPage != \"\" && targetPage != \"undefined\")\n"
-                + "             top.classFrame.location = top.targetPage;\n"
-                + "    }\n"
-                + "</script>");
-
-        checkOutput("index.html", true,
-                "<body class=\"frames\" onload=\"loadFrames()\"");
-
-        //Make sure title javascript only runs if is-external is not true
-        checkOutput("pkg/C.html", true,
-                "    try {\n"
-                + "        if (location.href.indexOf('is-external=true') == -1) {\n"
-                + "            parent.document.title=\"C\";\n"
-                + "        }\n"
-                + "    }\n"
-                + "    catch(err) {\n"
-                + "    }");
+                "<script type=\"text/javascript\"><!--\n"
+                + "$('.navPadding').css('padding-top', $('.fixedNav').css(\"height\"));\n"
+                + "//-->\n");
 
         checkOutput("script.js", true,
                 "$(window).resize(function() {\n"
--- a/test/langtools/jdk/javadoc/doclet/testMetadata/TestMetadata.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testMetadata/TestMetadata.java	Tue Apr 09 11:48:54 2019 +0100
@@ -57,7 +57,6 @@
         tester.runTests();
     }
 
-    enum Frames { NO_FRAMES, FRAMES };
     enum Index  { SINGLE, SPLIT };
     enum Source { PACKAGES, MODULES };
 
@@ -68,16 +67,14 @@
     public void runTests() throws Exception {
         for (Source s : Source.values()) {
             Path src = genSource(s);
-            for (Frames f : Frames.values()) {
                  for (Index i : Index.values()) {
                      List<String> args = new ArrayList<>();
                      args.add("-d");
-                     args.add(String.format("out-%s-%s-%s", s, f, i));
+                     args.add(String.format("out-%s-%s", s, i));
                      args.add("-use");
                      if (s != Source.MODULES) {
                          args.add("-linksource"); // broken, with modules: JDK-8219060
                      }
-                     args.add(f == Frames.NO_FRAMES ? "--no-frames" : "--frames");
                      if (i == Index.SPLIT) {
                          args.add("-splitIndex");
                      }
@@ -116,7 +113,6 @@
                              break;
                      }
                  }
-            }
         }
 
         checking ("all generators");
@@ -143,7 +139,6 @@
     final Pattern nl = Pattern.compile("[\\r\\n]+");
     final Pattern bodyPattern = Pattern.compile("<body [^>]*class=\"([^\"]+)\"");
     final Set<String> allBodyClasses = Set.of(
-        "all-classes-frame",
         "all-classes-index",
         "all-packages-index",
         "class-declaration",
@@ -151,18 +146,12 @@
         "constants-summary",
         "deprecated-list",
         "doc-file",
-        "frames",
         "help",
         "index-redirect",
         "module-declaration",
-        "module-frame",
         "module-index",
-        "module-index-frame",
-        "module-package-index-frame",
         "package-declaration",
-        "package-frame",
         "package-index",
-        "package-index-frame",
         "package-tree",
         "package-use",
         "serialized-form",
@@ -216,7 +205,6 @@
     final Pattern contentPattern = Pattern.compile("content=\"([^\"]+)\">");
     final Pattern generatorPattern = Pattern.compile("content=\"javadoc/([^\"]+)\">");
     final Set<String> allGenerators = Set.of(
-            "AllClassesFrameWriter",
             "AllClassesIndexWriter",
             "AllPackagesIndexWriter",
             "AnnotationTypeWriterImpl",
@@ -225,16 +213,10 @@
             "ConstantsSummaryWriterImpl",
             "DeprecatedListWriter",
             "DocFileWriter",
-            "FrameOutputWriter",
             "HelpWriter",
             "IndexRedirectWriter",
-            "ModuleFrameWriter",
-            "ModuleIndexFrameWriter",
             "ModuleIndexWriter",
-            "ModulePackageIndexFrameWriter",
             "ModuleWriterImpl",
-            "PackageFrameWriter",
-            "PackageIndexFrameWriter",
             "PackageIndexWriter",
             "PackageTreeWriter",
             "PackageUseWriter",
@@ -323,16 +305,6 @@
         }
 
         switch (generator) {
-            case "AllClassesFrameWriter":
-            case "FrameOutputWriter":
-            case "ModuleFrameWriter":
-            case "ModuleIndexFrameWriter":
-            case "ModulePackageIndexFrameWriter":
-            case "PackageFrameWriter":
-            case "PackageIndexFrameWriter":
-                check(generator, content, content.contains("frame"));
-                break;
-
             case "AllClassesIndexWriter":
             case "AllPackagesIndexWriter":
             case "ModuleIndexWriter":
--- a/test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java	Tue Apr 09 11:48:54 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
@@ -83,26 +83,17 @@
 
         javadoc("-d", base.resolve("api").toString(),
                 "-quiet",
-                "--frames",
                 "--module-source-path", src.toString(),
                 "--no-module-directories",
                 "--module", "ma,mb");
 
         checkExit(Exit.OK);
         checkFiles(true,
-                "ma-frame.html",
                 "ma-summary.html",
                 "pa/package-summary.html");
         checkFiles(false,
-                "ma/module-frame.html",
                 "ma/module-summary.html",
                 "ma/pa/package-summary.html");
-        checkOutput("ma-frame.html", true,
-                "<ul>\n"
-                + "<li><a href=\"allclasses-frame.html\" target=\"packageFrame\">All&nbsp;Classes</a></li>\n"
-                + "<li><a href=\"overview-frame.html\" target=\"packageListFrame\">All&nbsp;Packages</a></li>\n"
-                + "<li><a href=\"module-overview-frame.html\" target=\"packageListFrame\">All&nbsp;Modules</a></li>\n"
-                + "</ul>\n");
         checkOutput("ma-summary.html", false,
                 "<ul class=\"navList\" id=\"allclasses_navbar_top\">\n"
                 + "<li><a href=\"allclasses-noframe.html\">All&nbsp;Classes</a></li>\n"
@@ -127,25 +118,16 @@
 
         javadoc("-d", base.resolve("api").toString(),
                 "-quiet",
-                "--frames",
                 "--module-source-path", src.toString(),
                 "--module", "ma,mb");
 
         checkExit(Exit.OK);
         checkFiles(false,
-                "ma-frame.html",
                 "ma-summary.html",
                 "pa/package-summary.html");
         checkFiles(true,
-                "ma/module-frame.html",
                 "ma/module-summary.html",
                 "ma/pa/package-summary.html");
-        checkOutput("ma/module-frame.html", true,
-                "<ul>\n"
-                + "<li><a href=\"../allclasses-frame.html\" target=\"packageFrame\">All&nbsp;Classes</a></li>\n"
-                + "<li><a href=\"../overview-frame.html\" target=\"packageListFrame\">All&nbsp;Packages</a></li>\n"
-                + "<li><a href=\"../module-overview-frame.html\" target=\"packageListFrame\">All&nbsp;Modules</a></li>\n"
-                + "</ul>\n");
         checkOutput("ma/module-summary.html", false,
                 "<ul class=\"navList\" id=\"allclasses_navbar_top\">\n"
                 + "<li><a href=\"../allclasses-noframe.html\">All&nbsp;Classes</a></li>\n"
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java	Tue Apr 09 11:48:54 2019 +0100
@@ -53,7 +53,6 @@
                 "-use",
                 "-Xdoclint:none",
                 "-overview", testSrc("overview.html"),
-                "--frames",
                 "--module-source-path", testSrc,
                 "--module", "moduleA,moduleB",
                 "testpkgmdlA", "testpkgmdlB");
@@ -62,11 +61,8 @@
         checkHtml5NoDescription(false);
         checkHtml5OverviewSummaryModules();
         checkModuleLink();
-        checkModuleClickThroughLinks();
-        checkModuleClickThrough(true);
         checkModuleFilesAndLinks(true);
         checkModulesInSearch(true);
-        checkOverviewFrame(true);
         checkAllPkgsAllClasses(true);
     }
 
@@ -79,7 +75,6 @@
                 "-nocomment",
                 "-use",
                 "-Xdoclint:none",
-                "--frames",
                 "-overview", testSrc("overview.html"),
                 "--module-source-path", testSrc,
                 "--module", "moduleA,moduleB",
@@ -89,7 +84,6 @@
         checkHtml5NoDescription(true);
         checkModuleLink();
         checkModuleFilesAndLinks(true);
-        checkOverviewFrame(true);
     }
 
     /**
@@ -99,7 +93,6 @@
     public void testHtml5UnnamedModule() {
         javadoc("-d", "out-html5-nomodule",
                 "-use",
-                "--frames",
                 "-overview", testSrc("overview.html"),
                 "-sourcepath", testSrc,
                 "testpkgnomodule", "testpkgnomodule1");
@@ -107,7 +100,6 @@
         checkHtml5OverviewSummaryPackages();
         checkModuleFilesAndLinks(false);
         checkModulesInSearch(false);
-        checkOverviewFrame(false);
     }
 
     /**
@@ -165,13 +157,11 @@
     public void testModuleFilesAndLinks() {
         javadoc("-d", "out-modulelinks",
                 "-Xdoclint:none",
-                "--frames",
                 "--module-source-path", testSrc,
                 "--module", "moduleA,moduleB",
                 "testpkgmdlA", "testpkgmdlB");
         checkExit(Exit.OK);
         checkModuleFilesAndLinks(true);
-        checkOverviewFrame(true);
     }
 
     /**
@@ -215,7 +205,6 @@
                 "-author",
                 "-version",
                 "-Xdoclint:none",
-                "--frames",
                 "-tag", "regular:a:Regular Tag:",
                 "-tag", "moduletag:s:Module Tag:",
                 "--module-source-path", testSrc,
@@ -225,8 +214,6 @@
         checkModuleModeCommon();
         checkModuleModeApi(true);
         checkModuleModeAll(false);
-        checkModuleFrameFiles(true);
-        checkAllModulesLink(true);
     }
 
     /**
@@ -240,7 +227,6 @@
                 "-author",
                 "-version",
                 "-Xdoclint:none",
-                "--frames",
                 "-tag", "regular:a:Regular Tag:",
                 "-tag", "moduletag:s:Module Tag:",
                 "--module-source-path", testSrc,
@@ -250,8 +236,6 @@
         checkModuleModeCommon();
         checkModuleModeApi(false);
         checkModuleModeAll(true);
-        checkModuleFrameFiles(true);
-        checkAllModulesLink(true);
     }
 
     /**
@@ -289,12 +273,10 @@
     @Test
     public void testSingleModuleSinglePkg() {
         javadoc("-d", "out-singlemod",
-                "--frames",
                 "--module-source-path", testSrc,
                 "--module", "moduleC",
                 "testpkgmdlC");
         checkExit(Exit.OK);
-        checkModuleFrameFiles(false);
     }
 
     /**
@@ -305,12 +287,10 @@
         javadoc("-d", "out-singlemodmultiplepkg",
                 "--show-module-contents=all",
                 "-Xdoclint:none",
-                "--frames",
                 "--module-source-path", testSrc,
                 "--module", "moduleB",
                 "testpkg2mdlB", "testpkgmdlB");
         checkExit(Exit.OK);
-        checkAllModulesLink(false);
     }
 
     /**
@@ -321,7 +301,6 @@
         javadoc("-d", "out-group",
                 "--show-module-contents=all",
                 "-Xdoclint:none",
-                "--frames",
                 "-tag", "regular:a:Regular Tag:",
                 "-tag", "moduletag:s:Module Tag:",
                 "--module-source-path", testSrc,
@@ -345,7 +324,6 @@
         javadoc("-d", "out-groupOrder",
                 "--show-module-contents=all",
                 "-Xdoclint:none",
-                "--frames",
                 "-tag", "regular:a:Regular Tag:",
                 "-tag", "moduletag:s:Module Tag:",
                 "--module-source-path", testSrc,
@@ -368,7 +346,6 @@
         javadoc("-d", "out-groupnomodule",
                 "-use",
                 "-Xdoclint:none",
-                "--frames",
                 "-overview", testSrc("overview.html"),
                 "-sourcepath", testSrc,
                 "-group", "Package Group 0", "testpkgnomodule",
@@ -388,7 +365,6 @@
         javadoc("-d", "out-groupPkgOrder",
                 "-use",
                 "-Xdoclint:none",
-                "--frames",
                 "-overview", testSrc("overview.html"),
                 "-sourcepath", testSrc,
                 "-group", "Z Group", "testpkgnomodule",
@@ -406,7 +382,6 @@
         javadoc("-d", "out-groupsinglemodule",
                 "-use",
                 "-Xdoclint:none",
-                "--frames",
                 "--module-source-path", testSrc,
                 "-group", "Module Group B", "moduleB*",
                 "--module", "moduleB",
@@ -423,7 +398,6 @@
         javadoc("-d", "out-modulename",
                 "-use",
                 "-Xdoclint:none",
-                "--frames",
                 "--module-source-path", testSrc,
                 "--module", "moduleB,test.moduleFullName",
                 "testpkg2mdlB", "testpkgmdlB", "testpkgmdlfullname");
@@ -464,7 +438,7 @@
                 + "</a>\n"
                 + "<div class=\"block\">This is a test description for the moduleB module. Search "
                 + "word <a id=\"search_word\" class=\"searchTagResult\">search_word</a> with no description.</div>");
-        checkOutput("overview-summary.html", found,
+        checkOutput("index.html", found,
                 "</script>\n"
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
@@ -473,7 +447,7 @@
                 + "<div class=\"overviewSummary\">\n"
                 + "<table summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>");
-        checkOutput("overview-summary.html", false,
+        checkOutput("index.html", false,
                 "</table>\n"
                 + "</div>\n"
                 + "<div class=\"contentContainer\">\n"
@@ -504,7 +478,7 @@
 
     void checkHtml5Description(boolean found) {
         checkOutput("moduleA/module-summary.html", found,
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<div class=\"deprecationBlock\"><span class=\"deprecatedLabel\">Deprecated, for removal:"
                 + " This API element is subject to removal in a future version.</span>\n"
                 + "<div class=\"deprecationComment\">This module is deprecated.</div>\n"
@@ -516,14 +490,14 @@
                 + "<div class=\"block\">This is a test description for the moduleA module with a Search "
                 + "phrase <a id=\"searchphrase\" class=\"searchTagResult\">search phrase</a>.</div>");
         checkOutput("moduleB/module-summary.html", found,
-                "<section role=\"region\">\n"
+                "<section>\n"
                 + "<!-- ============ MODULE DESCRIPTION =========== -->\n"
                 + "<a id=\"module.description\">\n"
                 + "<!--   -->\n"
                 + "</a>\n"
                 + "<div class=\"block\">This is a test description for the moduleB module. Search "
                 + "word <a id=\"search_word\" class=\"searchTagResult\">search_word</a> with no description.</div>");
-        checkOutput("overview-summary.html", found,
+        checkOutput("index.html", found,
                 "</nav>\n"
                 + "</header>\n"
                 + "<main role=\"main\">\n"
@@ -533,7 +507,7 @@
                 + "<div class=\"contentContainer\">\n"
                 + "<div class=\"overviewSummary\">\n<table>\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>");
-        checkOutput("overview-summary.html", false,
+        checkOutput("index.html", false,
                 "</table>\n"
                 + "</div>\n"
                 + "</main>\n"
@@ -564,7 +538,7 @@
     }
 
     void checkModuleLink() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<li>Module</li>");
         checkOutput("moduleA/module-summary.html", true,
                 "<li class=\"navBarCell1Rev\">Module</li>");
@@ -619,7 +593,7 @@
     }
 
     void checkOverviewSummaryModules() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"overviewSummary\">\n"
                 + "<table summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@@ -642,7 +616,7 @@
     }
 
     void checkOverviewSummaryPackages() {
-        checkOutput("overview-summary.html", false,
+        checkOutput("index.html", false,
                 "<div class=\"overviewSummary\">\n"
                 + "<table summary=\"Module Summary table, listing modules, and an explanation\">\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@@ -661,7 +635,7 @@
                 + "<div class=\"overviewSummary\">\n"
                 + "<table summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>");
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"overviewSummary\">\n"
                 + "<table summary=\"Package Summary table, listing packages, and an explanation\">\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@@ -682,7 +656,7 @@
     }
 
     void checkHtml5OverviewSummaryModules() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"overviewSummary\">\n"
                 + "<table>\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@@ -705,7 +679,7 @@
     }
 
     void checkHtml5OverviewSummaryPackages() {
-        checkOutput("overview-summary.html", false,
+        checkOutput("index.html", false,
                 "<div class=\"overviewSummary\">\n"
                 + "<table>\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
@@ -728,7 +702,7 @@
                 + "<div class=\"overviewSummary\">\n"
                 + "<table>\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>");
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"overviewSummary\">\n<table>\n"
                 + "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<thead>\n"
@@ -861,27 +835,6 @@
                 + "</a>");
     }
 
-    void checkModuleClickThroughLinks() {
-        checkOutput("module-overview-frame.html", true,
-                "<li><a href=\"moduleA/module-frame.html\" target=\"packageListFrame\" "
-                + "onclick=\"updateModuleFrame('moduleA/module-type-frame.html','moduleA/module-summary.html');"
-                + "\">moduleA</a></li>",
-                "<li><a href=\"moduleB/module-frame.html\" target=\"packageListFrame\" "
-                + "onclick=\"updateModuleFrame('moduleB/module-type-frame.html','moduleB/module-summary.html');"
-                + "\">moduleB</a></li>");
-        checkOutput("script.js", true,
-                "function updateModuleFrame(pFrame, cFrame) {\n"
-                + "    top.packageFrame.location = pFrame;\n"
-                + "    top.classFrame.location = cFrame;\n"
-                + "}");
-    }
-
-    void checkModuleClickThrough(boolean found) {
-        checkFiles(found,
-                "moduleA/module-type-frame.html",
-                "moduleB/module-type-frame.html");
-    }
-
     void checkModuleFilesAndLinks(boolean found) {
         checkFileAndOutput("moduleA/testpkgmdlA/package-summary.html", found,
                 "<li><a href=\"../module-summary.html\">Module</a></li>",
@@ -897,26 +850,7 @@
                 "<div class=\"subTitle\"><span class=\"packageLabelInType\">"
                 + "Package</span>&nbsp;<a href=\"package-summary.html\">testpkgmdlB</a></div>");
         checkFiles(found,
-                "moduleA/module-frame.html",
-                "moduleA/module-summary.html",
-                "module-overview-frame.html");
-    }
-
-    void checkModuleFrameFiles(boolean found) {
-        checkFiles(found,
-                "moduleC/module-frame.html",
-                "moduleC/module-type-frame.html",
-                "module-overview-frame.html");
-        checkFiles(true,
-                "moduleC/module-summary.html",
-                "allclasses-frame.html");
-        checkFiles(false,
-                "allclasses-noframe.html");
-    }
-
-    void checkAllModulesLink(boolean found) {
-        checkOutput("overview-frame.html", found,
-                "<li><a href=\"module-overview-frame.html\" target=\"packageListFrame\">All&nbsp;Modules</a></li>");
+                "moduleA/module-summary.html");
     }
 
     void checkModulesInSearch(boolean found) {
@@ -950,7 +884,7 @@
     }
 
     void checkModuleModeCommon() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"moduleA/module-summary.html\">moduleA</a></th>\n"
                 + "<td class=\"colLast\">\n"
                 + "<div class=\"block\">This is a test description for the moduleA module with a Search "
@@ -1155,13 +1089,6 @@
                 "@AnnotationTypeUndocumented");
     }
 
-    void checkOverviewFrame(boolean found) {
-        checkOutput("index.html", !found,
-                "<iframe src=\"overview-frame.html\" name=\"packageListFrame\" title=\"All Packages\"></iframe>");
-        checkOutput("index.html", found,
-                "<iframe src=\"module-overview-frame.html\" name=\"packageListFrame\" title=\"All Modules\"></iframe>");
-    }
-
     void checkModuleSummaryNoExported(boolean found) {
         checkOutput("moduleNoExport/module-summary.html", found,
                 "<!-- ============ PACKAGES SUMMARY =========== -->\n"
@@ -1172,7 +1099,7 @@
     }
 
     void checkGroupOption() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"contentContainer\">\n"
                 + "<div class=\"overviewSummary\">\n"
                 + "<div role=\"tablist\" aria-orientation=\"horizontal\"><button role=\"tab\""
@@ -1194,14 +1121,14 @@
                 + "var rowColor = \"rowColor\";\n"
                 + "var tableTab = \"tableTab\";\n"
                 + "var activeTableTab = \"activeTableTab\";");
-        checkOutput("overview-summary.html", false,
+        checkOutput("index.html", false,
                 "<div class=\"overviewSummary\">\n<table>\n"
                 + "<caption><span>Modules</span><span class=\"tabEnd\">&nbsp;</span></caption>",
                 "Java SE Modules");
     }
 
     void checkGroupOptionOrdering() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div role=\"tablist\" aria-orientation=\"horizontal\"><button role=\"tab\""
                 + " aria-selected=\"true\" aria-controls=\"overviewSummary_tabpanel\" tabindex=\"0\""
                 + " onkeydown=\"switchTab(event)\" id=\"t0\" class=\"activeTableTab\">All Modules</button>"
@@ -1217,7 +1144,7 @@
                 + "Other Modules</button></div>",
                 "var tabs = {65535:[\"t0\",\"All Modules\"],1:[\"t1\",\"B Group\"],2:[\"t2\",\"C Group\"],"
                 + "4:[\"t4\",\"A Group\"],8:[\"t8\",\"Other Modules\"]};");
-        checkOutput("overview-summary.html", false,
+        checkOutput("index.html", false,
                 "<div role=\"tablist\" aria-orientation=\"horizontal\"><button role=\"tab\""
                 + " aria-selected=\"true\" aria-controls=\"overviewSummary_tabpanel\" tabindex=\"0\""
                 + " onkeydown=\"switchTab(event)\" id=\"t0\" class=\"activeTableTab\">All Modules</button>"
@@ -1235,7 +1162,7 @@
     }
 
     void checkUnnamedModuleGroupOption() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"contentContainer\">\n"
                 + "<div class=\"block\">The overview summary page header.</div>\n"
                 + "</div>\n"
@@ -1260,7 +1187,7 @@
     }
 
     void checkGroupOptionPackageOrdering() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div role=\"tablist\" aria-orientation=\"horizontal\"><button role=\"tab\""
                 + " aria-selected=\"true\" aria-controls=\"overviewSummary_tabpanel\" tabindex=\"0\""
                 + " onkeydown=\"switchTab(event)\" id=\"t0\" class=\"activeTableTab\">All Packages</button>"
@@ -1289,12 +1216,6 @@
                 + "<dd>\n"
                 + "<div class=\"block\">This is a test description for the test.moduleFullName.</div>\n"
                 + "</dd>");
-        checkOutput("module-overview-frame.html", found,
-                "<h1 title=\"Modules\">Modules</h1>\n"
-                + "<ul title=\"Modules\">\n"
-                + "<li><a href=\"moduleB/module-frame.html\" target=\"packageListFrame\" onclick=\"updateModuleFrame('moduleB/module-type-frame.html','moduleB/module-summary.html');\">moduleB</a></li>\n"
-                + "<li><a href=\"test.moduleFullName/module-frame.html\" target=\"packageListFrame\" onclick=\"updateModuleFrame('test.moduleFullName/module-type-frame.html','test.moduleFullName/module-summary.html');\">test.moduleFullName</a></li>\n"
-                + "</ul>");
         checkOutput("test.moduleFullName/module-summary.html", !found,
                 "<div class=\"header\">\n"
                 + "<h1 title=\"Module\" class=\"title\">Module&nbsp;moduleFullName</h1>\n"
--- a/test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -76,12 +76,11 @@
 
         javadoc("-d", base.resolve("out").toString(), "-use",
                 "-quiet",
-                "--frames",
                 "--module-source-path", src.toString(),
                 "--module", "m,m2");
         checkExit(Exit.OK);
 
-        checkOutput("overview-summary.html", false,
+        checkOutput("index.html", false,
                 "Prev",
                 "Next",
                 "All&nbsp;Classes",
--- a/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testNavigation/TestNavigation.java	Tue Apr 09 11:48:54 2019 +0100
@@ -57,7 +57,6 @@
     public void test(Path ignore) {
         javadoc("-d", "out",
                 "-overview", testSrc("overview.html"),
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg");
         checkExit(Exit.OK);
@@ -65,15 +64,15 @@
 
         checkOutput("pkg/A.html", true,
                 "<ul class=\"navList\" title=\"Navigation\">\n" +
-                "<li><a href=\"../overview-summary.html\">Overview</a></li>");
+                "<li><a href=\"../index.html\">Overview</a></li>");
 
         checkOutput("pkg/C.html", true,
                 "<ul class=\"navList\" title=\"Navigation\">\n" +
-                "<li><a href=\"../overview-summary.html\">Overview</a></li>");
+                "<li><a href=\"../index.html\">Overview</a></li>");
 
         checkOutput("pkg/E.html", true,
                 "<ul class=\"navList\" title=\"Navigation\">\n" +
-                "<li><a href=\"../overview-summary.html\">Overview</a></li>");
+                "<li><a href=\"../index.html\">Overview</a></li>");
 
         checkOutput("pkg/I.html", true,
                 // Test for 4664607
@@ -81,7 +80,7 @@
                 + "<a id=\"navbar.top.firstrow\">\n"
                 + "<!--   -->\n"
                 + "</a>",
-                "<li><a href=\"../overview-summary.html\">Overview</a></li>");
+                "<li><a href=\"../index.html\">Overview</a></li>");
 
         // Remaining tests check for additional padding to offset the fixed navigation bar.
         checkOutput("pkg/A.html", true,
@@ -115,7 +114,6 @@
     public void test1(Path ignore) {
         javadoc("-d", "out-1",
                 "-html5",
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg");
         checkExit(Exit.OK);
@@ -149,7 +147,6 @@
     public void test2(Path ignore) {
         javadoc("-d", "out-2",
                 "-nonavbar",
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg");
         checkExit(Exit.OK);
--- a/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testNewLanguageFeatures/TestNewLanguageFeatures.java	Tue Apr 09 11:48:54 2019 +0100
@@ -49,7 +49,6 @@
         javadoc("-Xdoclint:none",
                 "-d", "out",
                 "-use",
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg", "pkg1", "pkg2");
         checkExit(Exit.OK);
@@ -465,13 +464,6 @@
                 + "method(Vector&lt;Object&gt;)</a></span>"
         );
 
-        // No type parameters in class frame.
-        checkOutput("allclasses-frame.html", false,
-                "<a href=\"../pkg/TypeParameters.html\" title=\"class in pkg\">"
-                + "TypeParameters</a>&lt;<a href=\"../pkg/TypeParameters.html\" "
-                + "title=\"type parameter in TypeParameters\">E</a>&gt;"
-        );
-
     }
 
     //=================================
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testNoFrames/TestNoFrames.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,64 @@
+/*
+ * 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 8215599
+ * @summary Remove support for javadoc "frames" mode
+ * @library ../../lib
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build javadoc.tester.*
+ * @run main TestNoFrames
+ */
+
+import javadoc.tester.JavadocTester;
+
+public class TestNoFrames extends JavadocTester {
+
+    public static void main(String... args) throws Exception {
+        TestNoFrames tester = new TestNoFrames();
+        tester.runTests();
+    }
+
+    @Test
+    public void testFrames() {
+        javadoc("-d", "out-1",
+                "--frames",
+                "-sourcepath",testSrc,
+                testSrc("TestNoFrames.java"));
+        checkExit(Exit.ERROR);
+    }
+
+    @Test
+    public void testDefault() {
+        javadoc("-d", "out-2",
+                "--no-frames",
+                "-sourcepath",testSrc,
+                testSrc("TestNoFrames.java"));
+        checkExit(Exit.OK);
+
+        checkOutput(Output.OUT, true,
+                "javadoc: warning - The --no-frames option is no longer required and may be removed\n"
+                + "in a future release.");
+    }
+}
--- a/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testOrdering/TestOrdering.java	Tue Apr 09 11:48:54 2019 +0100
@@ -121,10 +121,8 @@
             javadoc("-d", "out-1",
                     "-sourcepath", testSrc,
                     "-use",
-                    "--frames",
                     "pkg1");
             checkExit(Exit.OK);
-            checkFiles(false, "allclasses-noframe.html");
 
             checkClassUseOrdering("pkg1/class-use/UsedClass.html");
 
@@ -174,20 +172,6 @@
             checkOrder("pkg1/OverrideOrdering.html",
                     "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.util.Collection&lt;",
                     "<dd><code>iterator</code>&nbsp;in interface&nbsp;<code>java.lang.Iterable&lt;");
-
-            checkOrder("allclasses-frame.html",
-                    "pkg1/A.html\" title=\"class in pkg1",
-                    "pkg1/A.C.html\" title=\"class in pkg1",
-                    "pkg1/B.html\" title=\"class in pkg1",
-                    "pkg1/B.A.html\" title=\"class in pkg1",
-                    "pkg1/C1.html\" title=\"class in pkg1",
-                    "pkg1/C2.html\" title=\"class in pkg1",
-                    "pkg1/C3.html\" title=\"class in pkg1",
-                    "pkg1/C4.html\" title=\"class in pkg1",
-                    "pkg1/ImplementsOrdering.html\" title=\"interface in pkg1",
-                    "pkg1/MethodOrder.html\" title=\"class in pkg1",
-                    "pkg1/OverrideOrdering.html\" title=\"class in pkg1",
-                    "pkg1/UsedClass.html\" title=\"class in pkg1");
         }
 
         void checkClassUseOrdering(String usePage) {
@@ -359,7 +343,6 @@
             List<String> cmdArgs = new ArrayList();
             cmdArgs.add("-d");
             cmdArgs.add("out-2");
-            cmdArgs.add("--frames");
             cmdArgs.add("-sourcepath");
             cmdArgs.add("src");
             cmdArgs.add("-package");
@@ -419,25 +402,6 @@
                     "<a href=\"add3/add/Add.ADD.html\" title=\"enum in add3.add\">",
                     "<a href=\"add3/add/add/Add.ADD.html\" title=\"enum in add3.add.add\">",
                     "<a href=\"add3/add/add/add/Add.ADD.html\" title=\"enum in add3.add.add.add\">");
-
-            checkOrder("overview-frame.html",
-                    "<a href=\"package-frame.html\" target=\"packageFrame\">&lt;unnamed package&gt;</a>",
-                    "<a href=\"add0/package-frame.html\" target=\"packageFrame\">add0</a>",
-                    "<a href=\"add0/add/package-frame.html\" target=\"packageFrame\">add0.add</a>",
-                    "<a href=\"add0/add/add/package-frame.html\" target=\"packageFrame\">add0.add.add</a>",
-                    "<a href=\"add0/add/add/add/package-frame.html\" target=\"packageFrame\">add0.add.add.add</a>",
-                    "<a href=\"add1/package-frame.html\" target=\"packageFrame\">add1</a>",
-                    "<a href=\"add1/add/package-frame.html\" target=\"packageFrame\">add1.add</a>",
-                    "<a href=\"add1/add/add/package-frame.html\" target=\"packageFrame\">add1.add.add</a>",
-                    "<a href=\"add1/add/add/add/package-frame.html\" target=\"packageFrame\">add1.add.add.add</a>",
-                    "<a href=\"add2/package-frame.html\" target=\"packageFrame\">add2</a>",
-                    "<a href=\"add2/add/package-frame.html\" target=\"packageFrame\">add2.add</a>",
-                    "<a href=\"add2/add/add/package-frame.html\" target=\"packageFrame\">add2.add.add</a>",
-                    "<a href=\"add2/add/add/add/package-frame.html\" target=\"packageFrame\">add2.add.add.add</a>",
-                    "<a href=\"add3/package-frame.html\" target=\"packageFrame\">add3</a>",
-                    "<a href=\"add3/add/package-frame.html\" target=\"packageFrame\">add3.add</a>",
-                    "<a href=\"add3/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add</a>",
-                    "<a href=\"add3/add/add/add/package-frame.html\" target=\"packageFrame\">add3.add.add.add</a></li>");
         }
 
         void emitFile(String pkgname, String clsname, ListOrder order) throws IOException {
--- a/test/langtools/jdk/javadoc/doclet/testOverview/TestOverview.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testOverview/TestOverview.java	Tue Apr 09 11:48:54 2019 +0100
@@ -47,7 +47,6 @@
                     "-doctitle", "Document Title",
                     "-windowtitle", "Window Title",
                     "-overview", testSrc("overview.html"),
-                    "--frames",
                     "-sourcepath", testSrc("src"),
                     "p1", "p2");
         checkExit(Exit.OK);
@@ -60,7 +59,6 @@
                     "-doctitle", "Document Title",
                     "-windowtitle", "Window Title",
                     "-overview", testSrc("overview.html"),
-                    "--frames",
                     "-sourcepath", testSrc("msrc"),
                     "p1", "p2");
         checkExit(Exit.OK);
@@ -68,7 +66,7 @@
     }
 
     void checkOverview() {
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<main role=\"main\">\n"
                 + "<div class=\"header\">\n"
                 + "<h1 class=\"title\">Document Title</h1>\n"
--- a/test/langtools/jdk/javadoc/doclet/testPackageDeprecation/TestPackageDeprecation.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testPackageDeprecation/TestPackageDeprecation.java	Tue Apr 09 11:48:54 2019 +0100
@@ -46,7 +46,6 @@
         javadoc("-d", "out-default",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", testSrc("C2.java"), testSrc("FooDepr.java"));
         checkExit(Exit.OK);
 
@@ -66,14 +65,11 @@
                 "-sourcepath", testSrc,
                 "-use",
                 "-nodeprecated",
-                "--frames",
                 "pkg", "pkg1", testSrc("C2.java"), testSrc("FooDepr.java"));
         checkExit(Exit.OK);
 
-        checkOutput("overview-summary.html", false,
+        checkOutput("index.html", false,
                 "pkg1");
-        checkOutput("allclasses-frame.html", false,
-                "FooDepr");
         checkOutput("class-use/C2.ModalExclusionType.html", true,
                 "<th class=\"colFirst\" scope=\"row\"><a href=\"#unnamed.package\">&lt;Unnamed&gt;</a></th>");
 
--- a/test/langtools/jdk/javadoc/doclet/testRecurseSubPackages/TestRecurseSubPackages.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testRecurseSubPackages/TestRecurseSubPackages.java	Tue Apr 09 11:48:54 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
@@ -44,19 +44,15 @@
     @Test
     public void test() {
         javadoc("-d", "out",
-                "--frames",
                 "-sourcepath", testSrc,
                 "-subpackages", "pkg1",
                 "-exclude", "pkg1.pkg2.packageToExclude");
         checkExit(Exit.OK);
 
         for (int i = 1; i <= 6; i++) {
-            checkOutput("allclasses-frame.html", true,
+            checkOutput("allclasses-index.html", true,
                     "C" + i + ".html");
         }
-
-        checkOutput("allclasses-frame.html", false,
-                "DummyClass.html");
     }
 
 }
--- a/test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java	Tue Apr 09 11:48:54 2019 +0100
@@ -50,7 +50,6 @@
     public void test() {
         javadoc("-d", "out",
                 "-use",
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg", "pkg2");
         checkExit(Exit.ERROR);
@@ -98,7 +97,7 @@
             " <a href=\"../../pkg/relative-multi-line-link.html\">relative-multi-line-link</a>.");
 
         // PACKAGE OVERVIEW
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
             "<a href=\"./pkg/relative-package-link.html\">relative package link</a>");
     }
 
--- a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java	Tue Apr 09 11:48:54 2019 +0100
@@ -70,7 +70,6 @@
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
         checkExit(Exit.OK);
         checkInvalidUsageIndexTag();
@@ -97,7 +96,6 @@
                 "-Xdoclint:all",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
         checkExit(Exit.ERROR);
         checkDocLintErrors();
@@ -124,7 +122,6 @@
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
         checkExit(Exit.OK);
         checkSearchOutput(false);
@@ -150,7 +147,6 @@
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
         checkExit(Exit.OK);
         checkSearchOutput(true);
@@ -177,7 +173,6 @@
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
         checkExit(Exit.OK);
         checkSearchOutput(false);
@@ -201,7 +196,6 @@
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
         checkExit(Exit.OK);
         checkSearchOutput(true);
@@ -226,7 +220,6 @@
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
 
         checkExit(Exit.OK);
@@ -252,7 +245,6 @@
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
         checkExit(Exit.OK);
         checkInvalidUsageIndexTag();
@@ -280,7 +272,6 @@
                 "--disable-javafx-strict-checks",
                 "-package",
                 "-use",
-                "--frames",
                 "pkgfx", "pkg3");
         checkExit(Exit.OK);
         checkSearchOutput(true);
@@ -306,7 +297,6 @@
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg", "pkg1", "pkg2", "pkg3");
         checkExit(Exit.OK);
         checkSearchOutput(true, false);
@@ -373,7 +363,7 @@
     }
 
     void checkSearchOutput(boolean expectedOutput) {
-        checkSearchOutput("overview-summary.html", expectedOutput, true);
+        checkSearchOutput("index.html", expectedOutput, true);
     }
 
     void checkSearchIndex(boolean expectedOutput) {
@@ -390,7 +380,7 @@
     }
 
     void checkSearchOutput(boolean expectedOutput, boolean moduleDirectoriesVar) {
-        checkSearchOutput("overview-summary.html", expectedOutput, moduleDirectoriesVar);
+        checkSearchOutput("index.html", expectedOutput, moduleDirectoriesVar);
     }
 
     void checkSearchOutput(String fileName, boolean expectedOutput, boolean moduleDirectoriesVar) {
@@ -635,7 +625,7 @@
                 "function concatResults(a1, a2) {",
                 "if (exactMatcher.test(item.l)) {\n"
                 + "                        presult.push(item);",
-                "$(\"#search\").on('click keydown', function() {\n"
+                "$(\"#search\").on('click keydown paste', function() {\n"
                 + "        if ($(this).val() == watermark) {\n"
                 + "            $(this).val('').removeClass('watermark');\n"
                 + "        }\n"
--- a/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testSummaryTag/TestSummaryTag.java	Tue Apr 09 11:48:54 2019 +0100
@@ -113,13 +113,12 @@
     @Test
     public void test3() {
         javadoc("-d", "out3",
-                "--frames",
                 "-sourcepath", testSrc,
                 "-overview", testSrc("p3/overview.html"),
                 "p3");
         checkExit(Exit.OK);
 
-        checkOutput("overview-summary.html", true,
+        checkOutput("index.html", true,
                 "<div class=\"block\">The first... line second from ...</div>");
     }
 }
--- a/test/langtools/jdk/javadoc/doclet/testTopOption/TestTopOption.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testTopOption/TestTopOption.java	Tue Apr 09 11:48:54 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
@@ -47,7 +47,6 @@
                 "-use",
                 "-top", "TOP TEXT",
                 "-d", "out-1",
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg");
         checkExit(Exit.OK);
@@ -59,7 +58,7 @@
                 "pkg/class-use/Cl.html",
                 "pkg/package-summary.html",
                 "pkg/package-use.html",
-                "overview-summary.html",
+                "index.html",
                 "overview-tree.html",
                 "constant-values.html",
                 "help-doc.html");
@@ -71,7 +70,6 @@
                 "-use",
                 "-top", "\u0130{@docroot}TOP TEXT",
                 "-d", "out-2",
-                "--frames",
                 "-sourcepath", testSrc,
                 "pkg");
         checkExit(Exit.OK);
@@ -83,7 +81,7 @@
                 "pkg/class-use/Cl.html",
                 "pkg/package-summary.html",
                 "pkg/package-use.html",
-                "overview-summary.html",
+                "index.html",
                 "overview-tree.html",
                 "constant-values.html",
                 "help-doc.html");
--- a/test/langtools/jdk/javadoc/doclet/testUseOption/TestUseOption.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testUseOption/TestUseOption.java	Tue Apr 09 11:48:54 2019 +0100
@@ -47,7 +47,6 @@
         javadoc("-d", "out-1",
                 "-sourcepath", testSrc,
                 "-use",
-                "--frames",
                 "pkg1", "pkg2");
         checkExit(Exit.OK);
 
@@ -80,10 +79,6 @@
                 "Method in C8."
         );
 
-        checkOutput("pkg2/class-use/C3.html", true,
-                "<a href=\"../../index.html?pkg2/class-use/C3.html\" target=\"_top\">"
-                + "Frames</a></li>"
-        );
         checkOutput("pkg1/class-use/UsedClass.html", true,
           "that return types with arguments of type"
         );
@@ -156,7 +151,7 @@
         );
         checkOutput("class-use/UsedInC.html", true,
                 "<li class=\"blockList\">\n"
-                + "<section role=\"region\"><a id=\"unnamed.package\">"
+                + "<section><a id=\"unnamed.package\">"
         );
         checkOutput("package-use.html", true,
                 "<th class=\"colFirst\" scope=\"row\">"
--- a/test/langtools/jdk/javadoc/doclet/testWindowTitle/TestWindowTitle.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2013, 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
- * 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 8016675 8026736 8196202
- * @summary Test for window title.
- * @author Bhavesh Patel
- * @library ../../lib
- * @modules jdk.javadoc/jdk.javadoc.internal.tool
- * @build javadoc.tester.*
- * @run main TestWindowTitle
- */
-import javadoc.tester.JavadocTester;
-
-public class TestWindowTitle extends JavadocTester {
-
-    public static void main(String... args) throws Exception {
-        TestWindowTitle tester = new TestWindowTitle();
-        tester.runTests();
-        tester.printSummary();
-    }
-
-    @Test
-    public void testJavaScriptChars() {
-        // Window title with JavaScript special characters.
-        String title = "Testing \"Window 'Title'\" with a \\ backslash and a / "
-                + "forward slash and a \u00e8 unicode char also a    tab and also a "
-                + "\t special character another \u0002 unicode)";
-
-        javadoc("-d", "out-js-chars",
-                "-windowtitle", title,
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        checkOutput("overview-summary.html", true,
-                "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" "
-                + "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char "
-                + "also a    tab and also a \\t special character another \\u0002 unicode))\";"
-        );
-
-        checkOutput("overview-summary.html", false,
-                "parent.document.title=\"Overview (Testing \"Window \'Title\'\" "
-                + "with a \\ backslash and a / forward slash and a \u00E8 unicode char "
-                + "also a    tab and also a \t special character another \u0002 unicode))\";"
-        );
-    }
-
-    @Test
-    public void testScriptTag() {
-        // Window title with a script tag.
-        String title = "Testing script tag in title </title><script>alert(\"Should not pop up\")</script>.";
-
-        javadoc("-d", "out-script",
-                "-windowtitle", title,
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        checkOutput("overview-summary.html", true,
-                "parent.document.title=\"Overview (Testing script tag in title alert"
-                + "(\\\"Should not pop up\\\").)\";"
-        );
-
-        checkOutput("p2/C2.html", true,
-                "parent.document.title=\"C2 (Testing script tag in title alert"
-                + "(\\\"Should not pop up\\\").)\";"
-        );
-
-        checkOutput("overview-summary.html", false,
-                "parent.document.title=\"Overview (Testing script tag in title </title><script>"
-                + "alert(\\\"Should not pop up\\\")</script>.)\";"
-        );
-
-        checkOutput("p2/C2.html", false,
-                "parent.document.title=\"C2 (Testing script tag in title </title><script>"
-                + "alert(\\\"Should not pop up\\\")</script>.)\";"
-        );
-    }
-
-    @Test
-    public void testHtmlTags() {
-        // Window title with other HTML tags.
-        String title = "Testing another <p>HTML</p> tag. Another <h1>tag</h1>. A "
-                + "<span id=\"testTag\">tag with attributes</span>. <script and </p are not tags.";
-
-        javadoc("-d", "out-html-tags",
-                "-windowtitle", title,
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        checkOutput("overview-summary.html", true,
-            "parent.document.title=\"Overview (Testing another HTML tag. Another tag. A "
-            + "tag with attributes. <script and </p are not tags.)\";"
-        );
-
-        checkOutput("overview-summary.html", false,
-            "parent.document.title=\"Overview (Testing another <p>HTML</p> tag. Another "
-            + "<h1>tag</h1>. A <span id=\"testTag\">tag with attributes</span>. <script and "
-            + "</p are not tags.)\";"
-        );
-    }
-
-    @Test
-    public void testHtmlEntities() {
-        // Window title using entities.
-        String title = "Testing entities &lt;script&gt;alert(\"Should not pop up\")&lt;/script&gt;.";
-
-        javadoc("-d", "out-html-entities",
-                "-windowtitle", title,
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-
-        checkOutput("overview-summary.html", true,
-            "parent.document.title=\"Overview (Testing entities &lt;script&gt;alert(\\\"Should "
-            + "not pop up\\\")&lt;/script&gt;.)\";"
-        );
-
-        checkOutput("overview-summary.html", false,
-            "parent.document.title=\"Overview (Testing entities alert(\\\"Should not pop up\\\").)\";"
-        );
-    }
-
-    @Test
-    public void testEmptyTags() {
-        // Window title with just empty HTML tags.
-        String title = "</title><script></script>";
-
-        javadoc("-d", "out-empty-tags",
-                "-windowtitle", title,
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-
-        checkOutput("overview-summary.html", true,
-            "parent.document.title=\"Overview\";"
-        );
-
-        checkOutput("overview-summary.html", false,
-            "parent.document.title=\"Overview (</title><script></script>)\";"
-        );
-    }
-
-    @Test
-    public void testUnicode() {
-        //Window title with unicode characters.
-        String title = "Testing unicode \u003cscript\u003ealert(\"Should not pop up\")\u003c/script\u003e.";
-
-        javadoc("-d", "out-unicode",
-                "-windowtitle", title,
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        checkOutput("overview-summary.html", true,
-            "parent.document.title=\"Overview (Testing unicode alert(\\\"Should "
-            + "not pop up\\\").)\";"
-        );
-
-        checkOutput("overview-summary.html", false,
-            "parent.document.title=\"Overview (Testing unicode <script>alert(\\\"Should not pop up\\\")"
-            + "</script>.)\";"
-        );
-    }
-
-    @Test
-    public void testEmpty() {
-        // An empty window title.
-        String title = "";
-        javadoc("-d", "out-empty",
-                "-windowtitle", title,
-                "--frames",
-                "-sourcepath", testSrc, "p1", "p2");
-        checkExit(Exit.OK);
-
-        checkOutput("overview-summary.html", true,
-                "parent.document.title=\"Overview\";"
-        );
-    }
-
-    @Test
-    public void testDocTitle() {
-        // Window title with JavaScript special characters, specified with -doctitle
-        String title = "Testing \"Window 'Title'\" with a \\ backslash and a / "
-                + "forward slash and a \u00e8 unicode char also a    tab and also a "
-                + "\t special character another \u0002 unicode)";
-
-        javadoc("-d", "out-doctitle",
-                "-doctitle", title,
-                "--frames",
-                "-sourcepath", testSrc,
-                "p1", "p2");
-        checkExit(Exit.OK);
-
-        checkOutput("overview-summary.html", false,
-            "parent.document.title=\"Overview (Testing \\\"Window \\\'Title\\\'\\\" "
-            + "with a \\\\ backslash and a / forward slash and a \\u00E8 unicode char "
-            + "also a    tab and also a \\t special character another \\u0002 unicode)\";"
-        );
-    }
-}
--- a/test/langtools/jdk/javadoc/doclet/testWindowTitle/p1/C1.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-
-package p1;
-
-public class C1 {
-}
--- a/test/langtools/jdk/javadoc/doclet/testWindowTitle/p2/C2.java	Mon Apr 08 10:47:35 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-
-package p2;
-
-public class C2 {
-}
--- a/test/langtools/jdk/javadoc/tool/TestScriptInComment.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/jdk/javadoc/tool/TestScriptInComment.java	Tue Apr 09 11:48:54 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
@@ -240,7 +240,6 @@
         opts.add(srcDir.getPath());
         opts.add("-d");
         opts.add(outDir.getPath());
-        opts.add("--frames");
         if (option.text != null)
             opts.add(option.text);
         for (String opt: template.getOpts(srcDir)) {
--- a/test/langtools/tools/javac/defaultMethods/BadClassfile.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/tools/javac/defaultMethods/BadClassfile.java	Tue Apr 09 11:48:54 2019 +0100
@@ -79,7 +79,7 @@
 
             clazz.complete();
         } catch (BadClassFile f) {
-            JCDiagnostic embeddedDiag = (JCDiagnostic) f.diag.getArgs()[1];
+            JCDiagnostic embeddedDiag = (JCDiagnostic) f.getDiagnostic().getArgs()[1];
             assertEquals(expected, embeddedDiag.getCode());
             assertEquals(Integer.toString(Target.JDK1_7.majorVersion), embeddedDiag.getArgs()[0]);
             assertEquals(Integer.toString(Target.JDK1_7.minorVersion), embeddedDiag.getArgs()[1]);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/CountErrorRecompile.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019, Google LLC. 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.
+ */
+
+// key: compiler.err.cant.resolve.location
+// key: compiler.misc.count.error.recompile
+// key: compiler.err.error
+// key: compiler.misc.count.error
+// key: compiler.misc.kindname.class
+// key: compiler.misc.location
+// options: -Xmaxerrs 1
+// run: backdoor
+
+class CountErrorRecompile {
+
+    NoSuchSymbol1 f1;
+    NoSuchSymbol2 f2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/diags/examples/CountWarnRecompile.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019, Google LLC. 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.
+ */
+
+// key: compiler.warn.raw.class.use
+// key: compiler.misc.count.warn
+// key: compiler.misc.kindname.interface
+// key: compiler.misc.where.description.typevar
+// key: compiler.misc.where.typevar
+// key: compiler.warn.lintOption
+// key: compiler.warn.warning
+// key: compiler.misc.count.warn.recompile
+// options: -Xlint:all -Xmaxwarns 1
+// run: backdoor
+
+import java.util.List;
+
+class CountWarnRecompile {
+
+    List x1;
+    List x2;
+}
--- a/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/langtools/tools/javac/switchexpr/DefiniteAssignment1.java	Tue Apr 09 11:48:54 2019 +0100
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 8214031
+ * @bug 8214031 8221413
  * @summary Verify that definite assignment when true works (legal code)
  * @compile --enable-preview --source ${jdk.version} DefiniteAssignment1.java
  * @run main/othervm --enable-preview DefiniteAssignment1
@@ -395,6 +395,36 @@
             throw new IllegalStateException("Unexpected result.");
         }
         }
+
+        { //JDK-8221413: definite assignment for implicit default in switch expressions
+        int x;
+        E e = E.A;
+
+        int v = (switch(e) {
+            case A -> x = 0;
+            case B -> x = 0;
+            case C -> x = 0;
+        });
+
+        if (x != 0 || v != 0) {
+            throw new IllegalStateException("Unexpected result.");
+        }
+        }
+
+        { //JDK-8221413: definite assignment for implicit default in switch expressions
+        int x;
+        E e = E.A;
+
+        boolean tA = (switch(e) {
+            case A -> { x = 1; break true; }
+            case B -> { x = 1; break true; }
+            case C -> { x = 1; break true; }
+        }) && x == 1; //x is definitelly assigned here
+
+        if (!tA) {
+            throw new IllegalStateException("Unexpected result.");
+        }
+        }
     }
 
     private int id(int v) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/warnings/MaxDiagsRecompile.all.out	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,5 @@
+MaxDiagsRecompile.java:28:3: compiler.err.cant.resolve.location: kindname.class, NoSuchSymbol1, , , (compiler.misc.location: kindname.class, MaxDiagsRecompile, null)
+MaxDiagsRecompile.java:29:3: compiler.err.cant.resolve.location: kindname.class, NoSuchSymbol2, , , (compiler.misc.location: kindname.class, MaxDiagsRecompile, null)
+MaxDiagsRecompile.java:30:3: compiler.err.cant.resolve.location: kindname.class, NoSuchSymbol3, , , (compiler.misc.location: kindname.class, MaxDiagsRecompile, null)
+MaxDiagsRecompile.java:31:3: compiler.err.cant.resolve.location: kindname.class, NoSuchSymbol4, , , (compiler.misc.location: kindname.class, MaxDiagsRecompile, null)
+4 errors
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/warnings/MaxDiagsRecompile.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019, Google LLC. 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.
+ */
+
+/*
+ * @test
+ * @summary suggest recompiling with -Xmaxerrs
+ * @compile/fail/ref=MaxDiagsRecompile.max1.out -XDrawDiagnostics -Xmaxerrs 1 MaxDiagsRecompile.java
+ * @compile/fail/ref=MaxDiagsRecompile.all.out -XDrawDiagnostics -Xmaxerrs 4 MaxDiagsRecompile.java
+ */
+public class MaxDiagsRecompile {
+
+  NoSuchSymbol1 f1;
+  NoSuchSymbol2 f2;
+  NoSuchSymbol3 f3;
+  NoSuchSymbol4 f4;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/warnings/MaxDiagsRecompile.max1.out	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,3 @@
+MaxDiagsRecompile.java:28:3: compiler.err.cant.resolve.location: kindname.class, NoSuchSymbol1, , , (compiler.misc.location: kindname.class, MaxDiagsRecompile, null)
+1 error
+only showing the first 1 errors, of 4 total; use -Xmaxerrs if you would like to see more
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/warnings/MaxWarnsRecompile.all.out	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,5 @@
+MaxWarnsRecompile.java:30:3: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
+MaxWarnsRecompile.java:31:3: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
+MaxWarnsRecompile.java:32:3: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
+MaxWarnsRecompile.java:33:3: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
+4 warnings
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/warnings/MaxWarnsRecompile.java	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2019, Google LLC. 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.
+ */
+
+import java.util.List;
+
+/*
+ * @test
+ * @summary suggest recompiling with -Xmaxwarns
+ * @compile/ref=MaxWarnsRecompile.max1.out -XDrawDiagnostics -Xlint:all -Xmaxwarns 1 MaxWarnsRecompile.java
+ * @compile/ref=MaxWarnsRecompile.all.out -XDrawDiagnostics -Xlint:all -Xmaxwarns 4 MaxWarnsRecompile.java
+ */
+public class MaxWarnsRecompile {
+
+  List x1;
+  List x2;
+  List x3;
+  List x4;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/warnings/MaxWarnsRecompile.max1.out	Tue Apr 09 11:48:54 2019 +0100
@@ -0,0 +1,3 @@
+MaxWarnsRecompile.java:30:3: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
+1 warning
+only showing the first 1 warnings, of 4 total; use -Xmaxwarns if you would like to see more
--- a/test/lib/jdk/test/lib/apps/LingeredApp.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/lib/jdk/test/lib/apps/LingeredApp.java	Tue Apr 09 11:48:54 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
@@ -492,18 +492,22 @@
         }
 
         String theLockFileName = args[0];
+        Path path = Paths.get(theLockFileName);
 
         try {
-            Path path = Paths.get(theLockFileName);
-
             while (Files.exists(path)) {
                 // Touch the lock to indicate our readiness
                 setLastModified(theLockFileName, epoch());
                 Thread.sleep(spinDelay);
             }
-        } catch (NoSuchFileException ex) {
+        } catch (IOException ex) {
             // Lock deleted while we are setting last modified time.
-            // Ignore error and lets the app exits
+            // Ignore the error and let the app exit.
+            if (Files.exists(path)) {
+                // If the lock file was not removed, return an error.
+                System.err.println("LingeredApp IOException: lock file still exists");
+                System.exit(4);
+            }
         } catch (Exception ex) {
             System.err.println("LingeredApp ERROR: " + ex);
             // Leave exit_code = 1 to Java launcher
--- a/test/lib/jdk/test/lib/containers/docker/Common.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/lib/jdk/test/lib/containers/docker/Common.java	Tue Apr 09 11:48:54 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
@@ -30,6 +30,7 @@
 import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
 import jdk.test.lib.containers.docker.DockerRunOptions;
 import jdk.test.lib.containers.docker.DockerTestUtils;
 import jdk.test.lib.Utils;
@@ -46,7 +47,7 @@
 
     public static void prepareWhiteBox() throws Exception {
         Files.copy(Paths.get(new File("whitebox.jar").getAbsolutePath()),
-                   Paths.get(Utils.TEST_CLASSES, "whitebox.jar"));
+                   Paths.get(Utils.TEST_CLASSES, "whitebox.jar"), StandardCopyOption.REPLACE_EXISTING);
     }
 
 
--- a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java	Tue Apr 09 11:48:54 2019 +0100
@@ -38,6 +38,7 @@
 import jdk.test.lib.Utils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
+import jtreg.SkippedException;
 
 
 public class DockerTestUtils {
@@ -45,8 +46,23 @@
     private static boolean isDockerEngineAvailable = false;
     private static boolean wasDockerEngineChecked = false;
 
-    // Diagnostics: set to true to enable more diagnostic info
-    private static final boolean DEBUG = false;
+    // Use this property to specify docker location on your system.
+    // E.g.: "/usr/local/bin/docker".
+    private static final String DOCKER_COMMAND =
+        System.getProperty("jdk.test.docker.command", "docker");
+
+    // Set this property to true to retain image after test. By default
+    // images are removed after test execution completes.
+    // Retaining the image can be useful for diagnostics and image inspection.
+    // E.g.: start image interactively: docker run -it <IMAGE_NAME>.
+    public static final boolean RETAIN_IMAGE_AFTER_TEST =
+        Boolean.getBoolean("jdk.test.docker.retain.image");
+
+    // Path to a JDK under test.
+    // This may be useful when developing tests on non-Linux platforms.
+    public static final String JDK_UNDER_TEST =
+        System.getProperty("jdk.test.docker.jdk", Utils.TEST_JDK);
+
 
     /**
      * Optimized check of whether the docker engine is available in a given
@@ -76,9 +92,7 @@
         if (isDockerEngineAvailable()) {
             return true;
         } else {
-            System.out.println("Docker engine is not available on this system");
-            System.out.println("This test is SKIPPED");
-            return false;
+            throw new SkippedException("Docker engine is not available on this system");
         }
     }
 
@@ -94,7 +108,7 @@
      */
     private static boolean isDockerEngineAvailableCheck() throws Exception {
         try {
-            execute("docker", "ps")
+            execute(DOCKER_COMMAND, "ps")
                 .shouldHaveExitValue(0)
                 .shouldContain("CONTAINER")
                 .shouldContain("IMAGE");
@@ -126,7 +140,7 @@
             throw new RuntimeException("The docker build directory already exists: " + buildDir);
         }
 
-        Path jdkSrcDir = Paths.get(Utils.TEST_JDK);
+        Path jdkSrcDir = Paths.get(JDK_UNDER_TEST);
         Path jdkDstDir = buildDir.resolve("jdk");
 
         Files.createDirectories(jdkDstDir);
@@ -157,7 +171,7 @@
                            DockerfileConfig.getBaseImageVersion());
 
         // Build the docker
-        execute("docker", "build", "--no-cache", "--tag", imageName, buildDir.toString())
+        execute(DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString())
             .shouldHaveExitValue(0)
             .shouldContain("Successfully built");
     }
@@ -174,7 +188,7 @@
     public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Exception {
         ArrayList<String> cmd = new ArrayList<>();
 
-        cmd.add("docker");
+        cmd.add(DOCKER_COMMAND);
         cmd.add("run");
         if (opts.tty)
             cmd.add("--tty=true");
@@ -201,11 +215,10 @@
      * Remove docker image
      *
      * @param DockerRunOptions optins for running docker
-     * @return output of the command
      * @throws Exception
      */
-    public static OutputAnalyzer removeDockerImage(String imageNameAndTag) throws Exception {
-        return execute("docker", "rmi", "--force", imageNameAndTag);
+    public static void removeDockerImage(String imageNameAndTag) throws Exception {
+            execute(DOCKER_COMMAND, "rmi", "--force", imageNameAndTag);
     }
 
 
--- a/test/lib/jdk/test/lib/containers/docker/DockerfileConfig.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/lib/jdk/test/lib/containers/docker/DockerfileConfig.java	Tue Apr 09 11:48:54 2019 +0100
@@ -46,7 +46,7 @@
 
         switch (Platform.getOsArch()) {
             case "aarch64":
-                return "aarch64/ubuntu";
+                return "arm64v8/ubuntu";
             case "ppc64le":
                 return "ppc64le/ubuntu";
             case "s390x":
--- a/test/make/TestCopyFiles.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/make/TestCopyFiles.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2017, 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
@@ -63,7 +63,7 @@
 $(eval $(call SetupCopyFiles, COPY_1, \
     SRC := $(SRC_DIR), \
     DEST := $(DEST_DIR), \
-    FILES := $(call CacheFind, $(SRC_DIR)), \
+    FILES := $(call ShellFindFiles, $(SRC_DIR)), \
 ))
 
 # Optionally define a rule that deletes all the target files after the makefile
--- a/test/make/TestMakeBase.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/make/TestMakeBase.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -140,13 +140,13 @@
 ################################################################################
 # Test remove-prefixes
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call remove-prefixes, pre, prefix postfix), fix postfix, \
-    Prefixes not properly removed))
+    Prefixes not properly removed)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call remove-prefixes, pre post, prefix postfix), fix fix, \
-    Prefixes not properly removed))
+    Prefixes not properly removed)
 
 ################################################################################
 # Test ShellQuote
@@ -239,19 +239,19 @@
 VARDEP_TEST_VAR2 := value3
 
 VARDEP_RETURN_VALUE := $(call DependOnVariable, VARDEP_TEST_VAR2, $(VARDEP_VALUE_FILE))
-$(eval $(call assert-equals, $(VARDEP_RETURN_VALUE), $(VARDEP_VALUE_FILE), \
-    Wrong filename returned))
+$(call AssertEquals, $(VARDEP_RETURN_VALUE), $(VARDEP_VALUE_FILE), \
+    Wrong filename returned)
 -include $(VARDEP_VALUE_FILE)
-$(eval $(call assert-equals, $(VARDEP_TEST_VAR2_old), $(VARDEP_TEST_VAR2), \
-    Wrong contents in vardeps file))
+$(call AssertEquals, $(VARDEP_TEST_VAR2_old), $(VARDEP_TEST_VAR2), \
+    Wrong contents in vardeps file)
 
 # Test with a variable value containing some problematic characters
 VARDEP_TEST_VAR3 := foo '""' "''" bar \$$ORIGIN &\#x00a9
 VARDEP_VALUE_FILE := $(call DependOnVariable, VARDEP_TEST_VAR3)
 -include $(VARDEP_VALUE_FILE)
-$(eval $(call assert-equals, $(call EscapeHash,$(VARDEP_TEST_VAR3_old)), \
+$(call AssertEquals, $(call EscapeHash,$(VARDEP_TEST_VAR3_old)), \
     $(call EscapeHash,$(VARDEP_TEST_VAR3)), \
-    Wrong contents in vardep file))
+    Wrong contents in vardep file)
 
 TEST_TARGETS += test-vardep
 
@@ -280,85 +280,86 @@
 
 PATHLIST_INPUT := foo bar baz
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call PathList, $(call PathList, $(PATHLIST_INPUT))), \
     $(call PathList, $(PATHLIST_INPUT)), \
-    PathList call not safe for calling twice))
+    PathList call not safe for calling twice, \
+)
 
 ################################################################################
 # Test FindCommonPathPrefix
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/banan), \
     /foo/bar, \
     FindCommonPathPrefix, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar), \
     /foo/bar, \
     FindCommonPathPrefix, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/), \
     /foo/bar, \
     FindCommonPathPrefix, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, foo/bar/baz, foo/bar/banan), \
     foo/bar, \
     FindCommonPathPrefix, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call FindCommonPathPrefix, foo/bar/baz, /foo/bar/banan), \
     , \
     FindCommonPathPrefix, \
-))
+)
 
 ################################################################################
 # DirToDotDot
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call DirToDotDot, foo/bar/baz/), \
     ../../.., \
     DirToDotDot, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call DirToDotDot, foo/bar), \
     ../.., \
     DirToDotDot, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call DirToDotDot, /foo), \
     .., \
     DirToDotDot, \
-))
+)
 
 ################################################################################
 # RelativePath
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call RelativePath, foo/bar/baz, foo/bar/banan), \
     ../baz, \
     RelativePath, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call RelativePath, foo/bar/baz/banan/kung, foo/bar/banan/kung), \
     ../../baz/banan/kung, \
     RelativePath, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/banan/kung/), \
     ../../baz/banan/kung, \
     RelativePath, \
-))
+)
 
 ################################################################################
 # Test ParseKeywordVariable
@@ -370,29 +371,29 @@
     STRING_KEYWORDS := COUNT MANY_WORDS, \
 ))
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_APA), \
     banan, \
     ParseKeywordVariable failed to parse APA, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_COUNT), \
     1 2 3 4 5, \
     ParseKeywordVariable failed to parse COUNT, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_SUM), \
     1+2+3+4+5, \
     ParseKeywordVariable failed to parse SUM, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_MANY_WORDS), \
     I have the best words., \
     ParseKeywordVariable failed to parse MANY_WORDS, \
-))
+)
 
 # Simulate variable set from command line by using "override"
 override KWBASE_WEIRD_GURKA := paprika
@@ -403,17 +404,211 @@
     STRING_KEYWORDS := COUNT, \
 ))
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_WEIRD_APA), \
     skansen, \
     ParseKeywordVariable failed to overwrite APA, \
-))
+)
 
-$(eval $(call assert-equals, \
+$(call AssertEquals, \
     $(KWBASE_WEIRD_GURKA), \
     paprika, \
     ParseKeywordVariable failed to preserve GURKA, \
-))
+)
+
+################################################################################
+# Test recursive wildcard
+
+A_FOOBAR := $(OUTPUT_DIR)/wildcard/a/foo.bar
+A_B_DOOBAR := $(OUTPUT_DIR)/wildcard/a/b/doo.bar
+A_B_FOOBAR := $(OUTPUT_DIR)/wildcard/a/b/foo.bar
+A_B_FOOBAZ := $(OUTPUT_DIR)/wildcard/a/b/foo.baz
+X_Y_FOOBAR := $(OUTPUT_DIR)/wildcard/x/y/foo.bar
+X_Y_FOOBAZ := $(OUTPUT_DIR)/wildcard/x/y/foo.baz
+X_Y_FOODOLLAR := $(OUTPUT_DIR)/wildcard/x/y/foo$$foo
+
+$(call MakeDir, $(OUTPUT_DIR)/wildcard/a/b)
+$(call MakeDir, $(OUTPUT_DIR)/wildcard/x/y)
+$(shell $(TOUCH) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_DOOBAR) $(A_B_FOOBAZ) \
+    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(call ShellQuote, $(X_Y_FOODOLLAR)))
+
+ifeq ($(RWILDCARD_WORKS), true)
+  $(call AssertEquals, \
+      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, *.bar)), \
+      $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_FOOBAR) $(X_Y_FOOBAR)), \
+      Wrong files returned from rwildcard, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, doo.*)), \
+      $(A_B_DOOBAR), \
+      Wrong files returned from rwildcard, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, *.bar *.baz)), \
+      $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+      $(X_Y_FOOBAR) $(X_Y_FOOBAZ)), \
+      Wrong files returned from rwildcard, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard)), \
+      $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+      $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+      Wrong files returned from WildcardFindFiles, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
+      $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+      Wrong files returned from WildcardFindFiles, \
+  )
+
+  $(call AssertEquals, \
+      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/x)), \
+      $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+      $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+      Wrong files returned from WildcardFindFiles, \
+  )
+endif
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard)), \
+    $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
+    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/x)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, *.bar)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_FOOBAR) $(X_Y_FOOBAR)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, doo.*)), \
+    $(A_B_DOOBAR), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, *.bar *.baz)), \
+    $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
+    $(X_Y_FOOBAR) $(X_Y_FOOBAZ)), \
+    Wrong files returned from ShellFindFiles, \
+)
+
+################################################################################
+
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a/b)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
+    CacheFindFiles test 1, \
+)
+$(call FillFindCache, $(OUTPUT_DIR)/wildcard/a/b)
+$(call AssertEquals, \
+    $(CacheFindFiles_CACHED_DIRS), $(OUTPUT_DIR)/wildcard/a/b, \
+    Wrong files in find cache dirs, \
+)
+$(call AssertEquals, \
+    $(sort $(CacheFindFiles_CACHED_FILES)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a/b)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
+    CacheFindFiles test 1, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
+    CacheFindFiles test 2, \
+)
+$(call FillFindCache, $(OUTPUT_DIR)/wildcard/a)
+$(call AssertEquals, \
+    $(CacheFindFiles_CACHED_DIRS), \
+    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a, \
+    Wrong files in find cache dirs, \
+)
+$(call AssertEquals, \
+    $(sort $(CacheFindFiles_CACHED_FILES)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(words $(CacheFindFiles_CACHED_FILES)), 4, \
+    Wrong files in find cache files >$(CacheFindFiles_CACHED_FILES)<, \
+)
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
+    CacheFindFiles test 2, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x)), \
+    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    CacheFindFiles test 3, \
+)
+$(call FillFindCache, $(OUTPUT_DIR)/wildcard/x)
+$(call AssertEquals, \
+    $(CacheFindFiles_CACHED_DIRS), \
+    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a $(OUTPUT_DIR)/wildcard/x, \
+    Wrong files in find cache dirs, \
+)
+$(call AssertEquals, \
+    $(sort $(CacheFindFiles_CACHED_FILES)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR) \
+        $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(words $(CacheFindFiles_CACHED_FILES)), 7, \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x)), \
+    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    CacheFindFiles test 3, \
+)
+
+$(call AssertEquals, \
+    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
+    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    CacheFindFiles test 4, \
+)
+$(call FillFindCache, $(OUTPUT_DIR)/wildcard/x/y)
+$(call AssertEquals, \
+    $(CacheFindFiles_CACHED_DIRS), \
+    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a $(OUTPUT_DIR)/wildcard/x, \
+    Wrong files in find cache dirs, \
+)
+$(call AssertEquals, \
+    $(sort $(CacheFindFiles_CACHED_FILES)), \
+    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR) \
+        $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
+    Wrong files in find cache files, \
+)
+$(call AssertEquals, \
+    $(words $(CacheFindFiles_CACHED_FILES)), 7, \
+    Wrong files in find cache files, \
+)
 
 ################################################################################
 
--- a/test/make/UtilsForTests.gmk	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/make/UtilsForTests.gmk	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2017, 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
@@ -29,11 +29,16 @@
 # 1 - Tested value
 # 2 - Exepected value
 # 3 - Error message
-define assert-equals
-  ifneq ($$(strip $1),$$(strip $2))
-    $$(error $3 - Expected >$$(strip $2)< - Got >$$(strip $1)<)
-  endif
-endef
+AssertEquals = \
+    $(if $(call equals, $(strip $1), $(strip $2)), , \
+      $(info FAILURE: $3) \
+      $(info Expected: >$(strip $2)<) \
+      $(info Actual:   >$(strip $1)<) \
+      $(error $3) \
+    )
+
+CreateFile = $(shell $(MKDIR) -p $(call ShellQuote, $(dir $1)) \
+    && $(TOUCH) $(call ShellQuote, $1))
 
 # On macosx, file system timestamps only have 1 second resultion so must add
 # sleeps to properly test dependencies.
--- a/test/micro/org/openjdk/bench/java/lang/StringHashCode.java	Mon Apr 08 10:47:35 2019 +0100
+++ b/test/micro/org/openjdk/bench/java/lang/StringHashCode.java	Tue Apr 09 11:48:54 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -42,11 +42,13 @@
 
     private String hashcode;
     private String hashcode0;
+    private String empty;
 
     @Setup
     public void setup() {
         hashcode = "abcdefghijkl";
         hashcode0 = new String(new char[]{72, 90, 100, 89, 105, 2, 72, 90, 100, 89, 105, 2});
+        empty = new String();
     }
 
     /**
@@ -66,4 +68,13 @@
     public int notCached() {
         return hashcode0.hashCode();
     }
+
+    /**
+     * Benchmark testing String.hashCode() with the empty string. Since the
+     * empty String has hashCode = 0, this value is always recalculated.
+     */
+    @Benchmark
+    public int empty() {
+        return empty.hashCode();
+    }
 }