diff --git a/make/Bundles.gmk b/make/Bundles.gmk index 7d85b504429..0a193f3ad20 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -72,7 +72,7 @@ define SetupBundleFileBody $(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), \ @@ -166,11 +166,12 @@ endif ################################################################################ ifneq ($(filter product-bundles legacy-bundles, $(MAKECMDGOALS)), ) - $(eval $(call FillCacheFind, $(IMAGES_OUTPUTDIR))) 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 @@ -201,11 +202,11 @@ ifneq ($(filter product-bundles legacy-bundles, $(MAKECMDGOALS)), ) $(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 CacheFind, $(JRE_IMAGE_DIR)) + ALL_JRE_FILES := $(call ShellFindFiles, $(JRE_IMAGE_DIR)) # Create special filter rules when dealing with unzipped .dSYM directories on # macosx @@ -266,7 +267,7 @@ endif ################################################################################ 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), \ @@ -280,7 +281,7 @@ endif ################################################################################ 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), \ @@ -295,7 +296,7 @@ endif ################################################################################ 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), \ diff --git a/make/CompileDemos.gmk b/make/CompileDemos.gmk index 18f8593ce81..74c54ce0cf2 100644 --- a/make/CompileDemos.gmk +++ b/make/CompileDemos.gmk @@ -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 @@ $(eval $(call IncludeCustomExtension, CompileDemos-pre.gmk)) # 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 @@ $(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%: $(DEMO_SHARE_SRC)/nbproject/% 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 @@ ifneq ($(filter images, $(MAKECMDGOALS)), ) $(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) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 15910a27f24..38849f760e0 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -653,7 +653,7 @@ endif 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)/*)) diff --git a/make/CopyImportModules.gmk b/make/CopyImportModules.gmk index 9742e91fa78..34baaf9d37b 100644 --- a/make/CopyImportModules.gmk +++ b/make/CopyImportModules.gmk @@ -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 @@ LIBS_DIR := $(wildcard $(addsuffix /$(MODULE), $(IMPORT_MODULES_LIBS))) 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 @@ ifneq ($(LIBS_DIR), ) 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 @@ ifneq ($(LIBS_DIR), ) $(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 @@ ifneq ($(CMDS_DIR), ) $(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 @@ ifneq ($(CONF_DIR), ) $(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 diff --git a/make/CreateBuildJdkCopy.gmk b/make/CreateBuildJdkCopy.gmk index a3150d05617..2fd16c370d3 100644 --- a/make/CreateBuildJdkCopy.gmk +++ b/make/CreateBuildJdkCopy.gmk @@ -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 @@ MODULES_TO_COPY := $(sort \ 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 @@ TARGETS += $(COPY_CLASSES_TARGET) $(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)))), \ )) diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index 1037761d769..47a6b774bf1 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -53,33 +53,33 @@ INCLUDE_HEADERS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \ 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 := \ ) 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 @@ endif # 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 diff --git a/make/Docs.gmk b/make/Docs.gmk index fe5cd45e242..93e20d94461 100644 --- a/make/Docs.gmk +++ b/make/Docs.gmk @@ -337,7 +337,7 @@ define SetupApiDocsGenerationBody $$(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 @@ $(eval $(call SetupApiDocsGeneration, REFERENCE_API, \ 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 @@ COPY_SPEC_FILTER := %.html %.gif %.jpg %.mib %.css $(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 @@ ifeq ($(ENABLE_PANDOC), true) $(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 @@ ifeq ($(ENABLE_PANDOC), true) $(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), \ diff --git a/make/Images.gmk b/make/Images.gmk index ea40fc1c6f3..ee395a2e7b8 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -183,21 +183,14 @@ endif 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)))) + FILES := $(call FindFiles, $(HOTSPOT_OUTPUTDIR) \ + $(SUPPORT_OUTPUTDIR)/native, *.gcno) \ + )) - SYMBOLS_TARGETS += $(COPY_HOTSPOT_GCOV_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 @@ else # 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 diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk index 8e157839c2e..005d12dae63 100644 --- a/make/InitSupport.gmk +++ b/make/InitSupport.gmk @@ -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 @@ ifeq ($(HAS_SPEC),) 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 ) diff --git a/make/MacBundles.gmk b/make/MacBundles.gmk index eff09eb84d9..f2b7bbe97f4 100644 --- a/make/MacBundles.gmk +++ b/make/MacBundles.gmk @@ -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 @@ ifeq ($(call isTargetOs, macosx), true) $(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: diff --git a/make/RunTestsPrebuilt.gmk b/make/RunTestsPrebuilt.gmk index 5a40f42270c..76efac149ae 100644 --- a/make/RunTestsPrebuilt.gmk +++ b/make/RunTestsPrebuilt.gmk @@ -338,6 +338,12 @@ default: all 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)" diff --git a/make/ZipSource.gmk b/make/ZipSource.gmk index b7441afe628..b4aabdacbb6 100644 --- a/make/ZipSource.gmk +++ b/make/ZipSource.gmk @@ -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 @@ ifeq ($(SRC_GENERATED), true) EXCLUDE_FILES := $(SRC_ZIP_EXCLUDE_FILES), \ SUFFIXES := .java, \ ZIP := $(SUPPORT_OUTPUTDIR)/src.zip, \ + FOLLOW_SYMLINKS := true, \ )) do-zip: $(BUILD_SRC_ZIP) diff --git a/make/common/FindTests.gmk b/make/common/FindTests.gmk index acfdfb22d14..591241c1555 100644 --- a/make/common/FindTests.gmk +++ b/make/common/FindTests.gmk @@ -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,32 +45,40 @@ TEST_BASEDIRS += $(TOPDIR)/test $(TOPDIR) # 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 -# -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/^\#.*//g' \ - -e 's/\([^ ]*\)\w*=.*/\1/gp' $$(wildcard $$($1_JTREG_GROUP_FILES)) \ - | $$(SORT) -u)) - endif -endef +# 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)) \ +) -# Configure definitions for all available test components -$(foreach root, $(JTREG_TESTROOTS), $(eval $(call FindJtregGroups, $(root)))) +# 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. +# +# 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 \ + ) > $@ + +-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), \ @@ -70,18 +88,15 @@ JTREG_TEST_GROUPS += $(sort $(foreach root, $(JTREG_TESTROOTS), \ # 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 diff --git a/make/common/JarArchive.gmk b/make/common/JarArchive.gmk index 9e6e7010390..d2a4ec103c4 100644 --- a/make/common/JarArchive.gmk +++ b/make/common/JarArchive.gmk @@ -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 @@ define SetupJarArchiveBody 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 @@ define SetupJarArchiveBody $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 diff --git a/make/common/JavaCompilation.gmk b/make/common/JavaCompilation.gmk index 9a3bcf6ca03..cb071cae266 100644 --- a/make/common/JavaCompilation.gmk +++ b/make/common/JavaCompilation.gmk @@ -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 @@ define SetupJavaCompilationBody ) \ ) $$(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)) diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 8288474bd9f..44166ac3d3f 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -64,10 +64,12 @@ define NEWLINE 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 @@ endef ################################################################################ -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 - - # 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 - -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) ' ' '?') \ +# 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))))) \ ) - endef + +# 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) ' ' '?' \ + ) \ + ) \ + ) + +# 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 + FindFiles = $(CacheFindFiles) endif ################################################################################ diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index afdbb4d18e2..8c93d310cc4 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -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 @@ -505,7 +505,7 @@ define SetupNativeCompilationBody $$(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)) diff --git a/make/common/TestFilesCompilation.gmk b/make/common/TestFilesCompilation.gmk index ccbd9aa1483..1d4d9bec1bc 100644 --- a/make/common/TestFilesCompilation.gmk +++ b/make/common/TestFilesCompilation.gmk @@ -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 @@ define SetupTestFilesCompilationBody # 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)) diff --git a/make/common/TextFileProcessing.gmk b/make/common/TextFileProcessing.gmk index eefcc71e1c6..de6ca5cf99f 100644 --- a/make/common/TextFileProcessing.gmk +++ b/make/common/TextFileProcessing.gmk @@ -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 @@ define SetupTextFileProcessingBody $$(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)) diff --git a/make/common/Utils.gmk b/make/common/Utils.gmk index 726101693a4..e58e395ed7f 100644 --- a/make/common/Utils.gmk +++ b/make/common/Utils.gmk @@ -70,8 +70,8 @@ _sequence-do = \ ################################################################################ # 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)) diff --git a/make/common/ZipArchive.gmk b/make/common/ZipArchive.gmk index e8dd56f791b..afec320deda 100644 --- a/make/common/ZipArchive.gmk +++ b/make/common/ZipArchive.gmk @@ -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 @@ endif # 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 @@ define SetupZipArchiveBody $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),) diff --git a/make/copy/CopyCommon.gmk b/make/copy/CopyCommon.gmk index 656d21d5241..b8cf880d673 100644 --- a/make/copy/CopyCommon.gmk +++ b/make/copy/CopyCommon.gmk @@ -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 @@ ifneq ($(wildcard $(INCLUDE_SOURCE_DIR)/*), ) $(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 @@ ifneq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), ) $(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) diff --git a/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk b/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk index 1d3d78b2ac1..1a3f58a3d4e 100644 --- a/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk +++ b/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk @@ -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_SUBDIRS := \ 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)) diff --git a/make/gensrc/Gensrc-jdk.internal.vm.compiler.management.gmk b/make/gensrc/Gensrc-jdk.internal.vm.compiler.management.gmk index b3ab7512213..e7f02735661 100644 --- a/make/gensrc/Gensrc-jdk.internal.vm.compiler.management.gmk +++ b/make/gensrc/Gensrc-jdk.internal.vm.compiler.management.gmk @@ -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_SUBDIRS := \ 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)) diff --git a/make/gensrc/GensrcCommonLangtools.gmk b/make/gensrc/GensrcCommonLangtools.gmk index a2d4d519143..df8dcd9cd15 100644 --- a/make/gensrc/GensrcCommonLangtools.gmk +++ b/make/gensrc/GensrcCommonLangtools.gmk @@ -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 @@ endef 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) diff --git a/make/gensrc/GensrcLocaleData.gmk b/make/gensrc/GensrcLocaleData.gmk index df213b8a1f0..115d2efd5f2 100644 --- a/make/gensrc/GensrcLocaleData.gmk +++ b/make/gensrc/GensrcLocaleData.gmk @@ -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))))) diff --git a/make/gensrc/GensrcProperties.gmk b/make/gensrc/GensrcProperties.gmk index bf7384dc751..decd5dedd4c 100644 --- a/make/gensrc/GensrcProperties.gmk +++ b/make/gensrc/GensrcProperties.gmk @@ -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 @@ define SetupCompilePropertiesBody 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)) diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 6e63cc545d2..e9cb0422e92 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -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_OPTIMIZATION ?= HIGHEST_JVM 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 diff --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk index 24b8027e42d..ea4c84371f8 100644 --- a/make/hotspot/lib/JvmOverrideFiles.gmk +++ b/make/hotspot/lib/JvmOverrideFiles.gmk @@ -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 @@ ifeq ($(call isTargetOs, linux), true) # 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 diff --git a/make/lib/Lib-java.base.gmk b/make/lib/Lib-java.base.gmk index 68b4aa53819..42f1da6cfa5 100644 --- a/make/lib/Lib-java.base.gmk +++ b/make/lib/Lib-java.base.gmk @@ -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 @@ include LibCommon.gmk $(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 diff --git a/make/lib/Lib-java.desktop.gmk b/make/lib/Lib-java.desktop.gmk index 2c660cedd1c..6171b6566ce 100644 --- a/make/lib/Lib-java.desktop.gmk +++ b/make/lib/Lib-java.desktop.gmk @@ -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 @@ include LibCommon.gmk $(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 diff --git a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp index e4d4d7e6c8a..c063ce7afa2 100644 --- a/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/shenandoah/shenandoahBarrierSetAssembler_aarch64.cpp @@ -46,7 +46,18 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec 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 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec __ call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_array_pre_oop_entry), 2); } __ pop(saved_regs, sp); + __ bind(done); } } } diff --git a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp index 9dc94ef79fb..8cced4100b1 100644 --- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp @@ -66,26 +66,22 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec } #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 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec dst, count); #endif __ popa(); - __ bind(filtered); + __ bind(done); + NOT_LP64(__ pop(thread);) } } diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index dd38a149673..01641895780 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -761,10 +761,6 @@ struct CopyToArchive : StackObj { 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()); diff --git a/src/hotspot/share/compiler/compilerOracle.cpp b/src/hotspot/share/compiler/compilerOracle.cpp index e4525d4ca06..856f7e55d7e 100644 --- a/src/hotspot/share/compiler/compilerOracle.cpp +++ b/src/hotspot/share/compiler/compilerOracle.cpp @@ -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 @@ void CompilerOracle::parse_from_string(const char* str, void (*parse_line)(char* 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); diff --git a/src/hotspot/share/compiler/compilerOracle.hpp b/src/hotspot/share/compiler/compilerOracle.hpp index 1d13374725f..ec87725a3a2 100644 --- a/src/hotspot/share/compiler/compilerOracle.hpp +++ b/src/hotspot/share/compiler/compilerOracle.hpp @@ -83,10 +83,6 @@ class CompilerOracle : AllStatic { 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(); }; diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index fd07887d068..db01f8a7800 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -2731,7 +2731,7 @@ class RegisterHumongousWithInCSetFastTestClosure : public HeapRegionClosure { // 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); @@ -4608,11 +4608,6 @@ void G1CollectedHeap::rebuild_region_sets(bool free_list_only) { 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, diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp index a1915b68d19..b71a04047da 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -1119,8 +1119,6 @@ public: 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 { diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index ff8d2d5d012..68dbb29980d 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -1766,17 +1766,17 @@ class G1RemarkThreadsClosure : public ThreadClosure { 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()) { diff --git a/src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp b/src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp index d17c004a0a8..db8b94e85a8 100644 --- a/src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp +++ b/src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp @@ -61,7 +61,7 @@ template void G1VerifyOopClosure::do_oop_work(T* p) { _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 @@ template void G1VerifyOopClosure::do_oop_work(T* p) { 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)); diff --git a/src/hotspot/share/gc/g1/heapRegion.cpp b/src/hotspot/share/gc/g1/heapRegion.cpp index 3ad97f9d78a..b2565987434 100644 --- a/src/hotspot/share/gc/g1/heapRegion.cpp +++ b/src/hotspot/share/gc/g1/heapRegion.cpp @@ -514,7 +514,7 @@ public: 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 +522,7 @@ public: 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)); diff --git a/src/hotspot/share/gc/serial/serialHeap.hpp b/src/hotspot/share/gc/serial/serialHeap.hpp index 7a3ef05b698..3194ea0ec24 100644 --- a/src/hotspot/share/gc/serial/serialHeap.hpp +++ b/src/hotspot/share/gc/serial/serialHeap.hpp @@ -59,11 +59,6 @@ public: virtual GrowableArray memory_managers(); virtual GrowableArray 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(_young_gen); diff --git a/src/hotspot/share/gc/shared/collectedHeap.cpp b/src/hotspot/share/gc/shared/collectedHeap.cpp index 70a3a6aafc3..939cba5f502 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.cpp +++ b/src/hotspot/share/gc/shared/collectedHeap.cpp @@ -575,3 +575,8 @@ void CollectedHeap::deduplicate_string(oop str) { 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(obj); + return static_cast(addr >> LogMinObjAlignment); +} diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp index 0bff3f002cd..b0ea626198b 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.hpp +++ b/src/hotspot/share/gc/shared/collectedHeap.hpp @@ -239,37 +239,7 @@ class CollectedHeap : public CHeapObj { 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) { diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp index 0dae4fe391a..a3c1ed76161 100644 --- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp +++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp @@ -824,7 +824,6 @@ void GenCollectedHeap::process_roots(StrongRootsScope* scope, 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 diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.hpp b/src/hotspot/share/gc/shared/genCollectedHeap.hpp index 667b4208702..18e78249263 100644 --- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp +++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp @@ -234,10 +234,9 @@ public: 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 diff --git a/src/hotspot/share/gc/shared/strongRootsScope.cpp b/src/hotspot/share/gc/shared/strongRootsScope.cpp index a167ba48958..63a6d8feb52 100644 --- a/src/hotspot/share/gc/shared/strongRootsScope.cpp +++ b/src/hotspot/share/gc/shared/strongRootsScope.cpp @@ -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 @@ MarkScope::~MarkScope() { } StrongRootsScope::StrongRootsScope(uint n_threads) : _n_threads(n_threads) { - Threads::change_thread_claim_parity(); + Threads::change_thread_claim_token(); } StrongRootsScope::~StrongRootsScope() { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp index f2cd526d665..412df539aeb 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp @@ -132,12 +132,23 @@ void ShenandoahBarrierSet::write_ref_array(HeapWord* start, size_t count) { template 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); } } } @@ -309,11 +320,9 @@ oop ShenandoahBarrierSet::write_barrier(oop obj) { } oop ShenandoahBarrierSet::storeval_barrier(oop obj) { - if (ShenandoahStoreValEnqueueBarrier) { - if (!CompressedOops::is_null(obj)) { - obj = write_barrier(obj); - enqueue(obj); - } + if (ShenandoahStoreValEnqueueBarrier && !CompressedOops::is_null(obj) && _heap->is_concurrent_traversal_in_progress()) { + obj = write_barrier(obj); + enqueue(obj); } if (ShenandoahStoreValReadBarrier) { obj = resolve_forwarded(obj); @@ -329,14 +338,14 @@ void ShenandoahBarrierSet::keep_alive_barrier(oop obj) { 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(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) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp index 18377a64dc6..65ae19bfd3b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.hpp @@ -141,7 +141,7 @@ private: bool arraycopy_loop(T* src, T* dst, size_t length, Klass* bound, bool disjoint); template - 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. diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp index 65d4d021230..c6c0624c1f5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp @@ -28,6 +28,9 @@ #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahBrooksPointer.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" +#include "gc/shenandoah/shenandoahHeapRegion.hpp" +#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" +#include "gc/shenandoah/shenandoahThreadLocalData.hpp" bool ShenandoahBarrierSet::need_update_refs_barrier() { return _heap->is_update_refs_in_progress() || @@ -59,7 +62,8 @@ inline oop ShenandoahBarrierSet::AccessBarrier::oop_ato } 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)) { + if (keep_alive && ShenandoahSATBBarrier && !CompressedOops::is_null(compare_value) && + ShenandoahHeap::heap()->is_concurrent_mark_in_progress()) { ShenandoahBarrierSet::barrier_set()->enqueue(compare_value); } } @@ -72,7 +76,8 @@ inline oop ShenandoahBarrierSet::AccessBarrier::oop_ato 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)) { + if (keep_alive && !CompressedOops::is_null(previous) && + ShenandoahHeap::heap()->is_concurrent_mark_in_progress()) { ShenandoahBarrierSet::barrier_set()->enqueue(previous); } } @@ -134,7 +139,7 @@ bool ShenandoahBarrierSet::arraycopy_loop_3(T* src, T* dst, size_t length, Klass template 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 +166,7 @@ bool ShenandoahBarrierSet::arraycopy_loop(T* src, T* dst, size_t length, Klass* T* cur_dst = dst; T* src_end = src + length; for (; cur_src < src_end; cur_src++, cur_dst++) { - if (!arraycopy_element(cur_src, cur_dst, bound, thread)) { + if (!arraycopy_element(cur_src, cur_dst, bound, thread, ctx)) { return false; } } @@ -170,7 +175,7 @@ bool ShenandoahBarrierSet::arraycopy_loop(T* src, T* dst, size_t length, Klass* T* cur_src = src + length - 1; T* cur_dst = dst + length - 1; for (; cur_src >= src; cur_src--, cur_dst--) { - if (!arraycopy_element(cur_src, cur_dst, bound, thread)) { + if (!arraycopy_element(cur_src, cur_dst, bound, thread, ctx)) { return false; } } @@ -179,14 +184,26 @@ bool ShenandoahBarrierSet::arraycopy_loop(T* src, T* dst, size_t length, Klass* } template -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); + } } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp index 7d8d979c2d1..3ecbd9741b1 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp @@ -213,15 +213,15 @@ public: 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); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index e5cd812f81e..588f186c3f6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -436,6 +436,7 @@ ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) : _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), diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 4d882ea719f..2258448f95d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -505,6 +505,8 @@ private: 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; } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp index b7e37a12977..c011897b251 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRuntime.cpp @@ -51,7 +51,8 @@ JRT_LEAF(void, ShenandoahRuntime::write_ref_field_pre_entry(oopDesc* orig, JavaT } 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)) diff --git a/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp b/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp index d277a4c23c3..da3f0cec2d6 100644 --- a/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp +++ b/src/hotspot/share/gc/shenandoah/vmStructs_shenandoah.hpp @@ -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 diff --git a/src/hotspot/share/gc/z/zCollectedHeap.cpp b/src/hotspot/share/gc/z/zCollectedHeap.cpp index 14640ee431c..b79c3bd70dc 100644 --- a/src/hotspot/share/gc/z/zCollectedHeap.cpp +++ b/src/hotspot/share/gc/z/zCollectedHeap.cpp @@ -110,8 +110,8 @@ bool ZCollectedHeap::is_in(const void* p) const { 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) { diff --git a/src/hotspot/share/gc/z/zCollectedHeap.hpp b/src/hotspot/share/gc/z/zCollectedHeap.hpp index 389236a7030..22873b68747 100644 --- a/src/hotspot/share/gc/z/zCollectedHeap.hpp +++ b/src/hotspot/share/gc/z/zCollectedHeap.hpp @@ -72,7 +72,8 @@ public: 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, diff --git a/src/hotspot/share/gc/z/zHeap.hpp b/src/hotspot/share/gc/z/zHeap.hpp index 490f81741a9..2c0c40b1667 100644 --- a/src/hotspot/share/gc/z/zHeap.hpp +++ b/src/hotspot/share/gc/z/zHeap.hpp @@ -103,6 +103,7 @@ public: 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; diff --git a/src/hotspot/share/gc/z/zHeap.inline.hpp b/src/hotspot/share/gc/z/zHeap.inline.hpp index ade6f878174..a229e3a6179 100644 --- a/src/hotspot/share/gc/z/zHeap.inline.hpp +++ b/src/hotspot/share/gc/z/zHeap.inline.hpp @@ -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 @@ inline ReferenceDiscoverer* ZHeap::reference_discoverer() { 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); diff --git a/src/hotspot/share/gc/z/zRootsIterator.cpp b/src/hotspot/share/gc/z/zRootsIterator.cpp index 74d034aa425..fd638d27e8f 100644 --- a/src/hotspot/share/gc/z/zRootsIterator.cpp +++ b/src/hotspot/share/gc/z/zRootsIterator.cpp @@ -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 @@ ZRootsIterator::ZRootsIterator() : _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 @@ ZThreadRootsIterator::ZThreadRootsIterator() : _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() { diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index ec30aceecd9..0c76a335b00 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -565,12 +565,12 @@ JRT_END 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; diff --git a/src/hotspot/share/memory/iterator.inline.hpp b/src/hotspot/share/memory/iterator.inline.hpp index d1a91f99b2f..8ba29bb95f5 100644 --- a/src/hotspot/share/memory/iterator.inline.hpp +++ b/src/hotspot/share/memory/iterator.inline.hpp @@ -56,7 +56,7 @@ void OopIterateClosure::verify(T* p) { 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)); } } diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index 3bf8df05b3b..4815ed37d18 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -280,9 +280,7 @@ void ConstantPool::archive_resolved_references(Thread* THREAD) { 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 diff --git a/src/hotspot/share/oops/oop.cpp b/src/hotspot/share/oops/oop.cpp index ab0a89dce2a..1d890eedebe 100644 --- a/src/hotspot/share/oops/oop.cpp +++ b/src/hotspot/share/oops/oop.cpp @@ -122,12 +122,6 @@ bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) { } #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); diff --git a/src/hotspot/share/oops/oop.hpp b/src/hotspot/share/oops/oop.hpp index 42ce05dd187..624f266435f 100644 --- a/src/hotspot/share/oops/oop.hpp +++ b/src/hotspot/share/oops/oop.hpp @@ -256,7 +256,6 @@ class oopDesc { 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 diff --git a/src/hotspot/share/prims/jvmtiTagMap.cpp b/src/hotspot/share/prims/jvmtiTagMap.cpp index 8eca5c5b832..0d6132eac46 100644 --- a/src/hotspot/share/prims/jvmtiTagMap.cpp +++ b/src/hotspot/share/prims/jvmtiTagMap.cpp @@ -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 @@ class JvmtiTagHashmap : public CHeapObj { // 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(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) diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index 78a3ef1012f..c83e18b59c1 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -316,7 +316,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { } 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(); diff --git a/src/hotspot/share/runtime/sweeper.cpp b/src/hotspot/share/runtime/sweeper.cpp index 6e4846e673f..0e835eefe0b 100644 --- a/src/hotspot/share/runtime/sweeper.cpp +++ b/src/hotspot/share/runtime/sweeper.cpp @@ -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 @@ public: NMethodMarkingTask(NMethodMarkingThreadClosure* cl) : AbstractGangTask("Parallel NMethod Marking"), _cl(cl) { - Threads::change_thread_claim_parity(); + Threads::change_thread_claim_token(); } ~NMethodMarkingTask() { diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index 847688ea136..244054e70fc 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -238,8 +238,8 @@ Thread::Thread() { 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 @@ bool Thread::is_interrupted(Thread* thread, bool clear_interrupted) { // 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; } @@ -3472,7 +3470,7 @@ JavaThread* Threads::_thread_list = NULL; 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 @@ -3532,14 +3530,14 @@ void Threads::threads_do(ThreadClosure* tc) { } 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); } } @@ -4525,27 +4523,39 @@ void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) { 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); + assert_thread_claimed("Thread", p, _thread_claim_token); } - 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("VMThread", VMThread::vm_thread(), _thread_claim_token); } #endif // ASSERT diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index b71b28d21e4..ab0ba1d863a 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -338,9 +338,8 @@ class Thread: public ThreadShadow { // 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 @@ class Thread: public ThreadShadow { // 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 @@ protected: 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; } @@ -2223,7 +2222,7 @@ class Threads: AllStatic { 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 @@ -2256,21 +2255,23 @@ class Threads: AllStatic { // 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 @@ class Threads: AllStatic { // Deoptimizes all frames tied to marked nmethods static void deoptimized_wrt_marked_nmethods(); + + struct Test; // For private gtest access. }; diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index 1f2d8c5fa92..f4f11fc6a54 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1510,8 +1510,14 @@ public final class String 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; } diff --git a/src/java.base/share/lib/security/default.policy b/src/java.base/share/lib/security/default.policy index e944396370f..7f8cc00fe7a 100644 --- a/src/java.base/share/lib/security/default.policy +++ b/src/java.base/share/lib/security/default.policy @@ -160,6 +160,7 @@ grant codeBase "jrt:/jdk.internal.vm.compiler" { 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"; diff --git a/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c b/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c index 48a51dbec32..4dd52ee3691 100644 --- a/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c +++ b/src/java.base/windows/native/libnio/fs/WindowsNativeDispatcher.c @@ -1065,8 +1065,11 @@ Java_sun_nio_fs_WindowsNativeDispatcher_CreateSymbolicLink0(JNIEnv* env, // 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. - DWORD dwFlags = (DWORD)flags | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; + // 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 diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java index eaf6f4f9f69..11c6171660c 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java @@ -237,7 +237,7 @@ public abstract class BaseFileManager implements JavaFileManager { return true; } // where - private static final Set