6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
Summary: GC workers now recognize an intermediate transient state of blocks which are allocated but have not yet completed initialization. blk_start() calls do not attempt to determine the size of a block in the transient state, rather waiting for the block to become initialized so that it is safe to query its size. Audited and ensured the order of initialization of object fields (klass, free bit and size) to respect block state transition protocol. Also included some new assertion checking code enabled in debug mode.
Reviewed-by: chrisphi, johnc, poonam
#
# Copyright (c) 1995, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Common variables used by all the Java makefiles. This file should
# not contain rules.
#
# Indicate that we are visiting a separate repo or component
define MakeStart
$(PRINTF) "\n\n%s\n%s\n##### %-60.60s #####\n%s\n" \
"########################################################################" \
"########################################################################" \
"Entering $1 for target $2" \
"########################################################################"
endef
define MakeFinish
$(PRINTF) "%s\n##### %-60.60s #####\n%s\n%s\n\n" \
"########################################################################" \
"Leaving $1 for target $2" \
"########################################################################" \
"########################################################################"
endef
ifdef OPENJDK
ifneq ($(OPENJDK),true)
x:=$(error "OPENJDK (if defined) can only be set to true")
endif
endif
# Define absolute paths to TOPDIRs
ABS_LANGTOOLS_TOPDIR:=$(call OptFullPath,"$(LANGTOOLS_TOPDIR)")
ABS_CORBA_TOPDIR:=$(call OptFullPath,"$(CORBA_TOPDIR)")
ABS_JAXP_TOPDIR:=$(call OptFullPath,"$(JAXP_TOPDIR)")
ABS_JAXWS_TOPDIR:=$(call OptFullPath,"$(JAXWS_TOPDIR)")
ABS_JDK_TOPDIR:=$(call OptFullPath,"$(JDK_TOPDIR)")
ABS_HOTSPOT_TOPDIR:=$(call OptFullPath,"$(HOTSPOT_TOPDIR)")
ABS_INSTALL_TOPDIR:=$(call OptFullPath,"$(INSTALL_TOPDIR)")
ABS_SPONSORS_TOPDIR:=$(call OptFullPath,"$(SPONSORS_TOPDIR)")
ABS_DEPLOY_TOPDIR:=$(call OptFullPath,"$(DEPLOY_TOPDIR)")
# Macro to return true or false if a file exists and is readable
define MkExists
$(shell if [ -r $1 ]; then $(ECHO) true; else $(ECHO) false; fi)
endef
HOTSPOT_SRC_AVAILABLE := $(call MkExists,$(HOTSPOT_TOPDIR)/make/Makefile)
ifndef BUILD_HOTSPOT
ifdef ALT_HOTSPOT_IMPORT_PATH
BUILD_HOTSPOT := false
else
BUILD_HOTSPOT := $(HOTSPOT_SRC_AVAILABLE)
endif
endif
LANGTOOLS_SRC_AVAILABLE := $(call MkExists,$(LANGTOOLS_TOPDIR)/make/Makefile)
ifndef BUILD_LANGTOOLS
ifdef ALT_LANGTOOLS_DIST
BUILD_LANGTOOLS := false
else
BUILD_LANGTOOLS := $(LANGTOOLS_SRC_AVAILABLE)
endif
endif
CORBA_SRC_AVAILABLE := $(call MkExists,$(CORBA_TOPDIR)/make/Makefile)
ifndef BUILD_CORBA
ifdef ALT_CORBA_DIST
BUILD_CORBA := false
else
BUILD_CORBA := $(CORBA_SRC_AVAILABLE)
endif
endif
JAXP_SRC_AVAILABLE := $(call MkExists,$(JAXP_TOPDIR)/make/Makefile)
ifndef BUILD_JAXP
ifdef ALT_JAXP_DIST
BUILD_JAXP := false
else
BUILD_JAXP := $(JAXP_SRC_AVAILABLE)
endif
endif
JAXWS_SRC_AVAILABLE := $(call MkExists,$(JAXWS_TOPDIR)/make/Makefile)
ifndef BUILD_JAXWS
ifdef ALT_JAXWS_DIST
BUILD_JAXWS := false
else
BUILD_JAXWS := $(JAXWS_SRC_AVAILABLE)
endif
endif
JDK_SRC_AVAILABLE := $(call MkExists,$(JDK_TOPDIR)/make/Makefile)
ifndef BUILD_JDK
BUILD_JDK := $(JDK_SRC_AVAILABLE)
endif
ifeq ($(JDK_SRC_AVAILABLE),true)
JDK_CLOSED_SRC_AVAILABLE := $(call MkExists,$(JDK_TOPDIR)/src/closed)
ifeq ($(JDK_CLOSED_SRC_AVAILABLE),false)
OPENJDK = true
endif
endif
DEPLOY_SRC_AVAILABLE := $(call MkExists,$(DEPLOY_TOPDIR)/make/Makefile)
ifndef BUILD_DEPLOY
BUILD_DEPLOY := $(DEPLOY_SRC_AVAILABLE)
endif
INSTALL_SRC_AVAILABLE := $(call MkExists,$(INSTALL_TOPDIR)/make/Makefile)
ifndef BUILD_INSTALL
ifdef DEV_ONLY
BUILD_INSTALL := false
else
BUILD_INSTALL := $(INSTALL_SRC_AVAILABLE)
endif
endif
SPONSORS_SRC_AVAILABLE := $(call MkExists,$(SPONSORS_TOPDIR)/make/Makefile)
ifndef BUILD_SPONSORS
ifdef DEV_ONLY
BUILD_SPONSORS := false
else
BUILD_SPONSORS := $(SPONSORS_SRC_AVAILABLE)
endif
endif
# Do we build the source and openjdk binary plug bundles?
BUNDLE_RULES = $(JDK_TOPDIR)/make/closed/bundles.gmk
ifeq ($(SKIP_BUNDLES_BUILD), true)
BUNDLE_RULES_AVAILABLE := false
else
BUNDLE_RULES_AVAILABLE := $(call MkExists,$(BUNDLE_RULES))
endif
# Current things we do NOT build for OPENJDK
ifdef OPENJDK
BUILD_DEPLOY = false
BUILD_INSTALL = false
BUILD_SPONSORS = false
BUNDLE_RULES_AVAILABLE := false
# These could be over-ridden on the command line or in environment
ifndef SKIP_FASTDEBUG_BUILD
SKIP_FASTDEBUG_BUILD = true
endif
ifndef SKIP_DEBUG_BUILD
SKIP_DEBUG_BUILD = true
endif
ifndef SKIP_COMPARE_IMAGES
SKIP_COMPARE_IMAGES = true
endif
SKIP_OPENJDK_BUILD = true
else
# Various non-OPENJDK reasons to NOT build the deploy repository
ifeq ($(ARCH), ia64)
BUILD_DEPLOY=false
endif
ifeq ($(ARCH), sparcv9)
BUILD_DEPLOY=false
endif
ifeq ($(ARCH), amd64)
ifeq ($(PLATFORM), solaris)
BUILD_DEPLOY=false
endif
endif
ifndef SKIP_OPENJDK_BUILD
#SKIP_OPENJDK_BUILD = false
# Until 6675289 is resolved, or this feature is removed.
SKIP_OPENJDK_BUILD = true
endif
endif
ifndef SKIP_PRODUCT_BUILD
SKIP_PRODUCT_BUILD = false
endif
# Solaris 64 bit builds are not complete enough to ever do this
ifeq ($(PLATFORM)$(ARCH_DATA_MODEL),solaris64)
SKIP_OPENJDK_BUILD = true
endif
# Many reasons why we would want to skip the comparison to previous jdk
ifndef SKIP_COMPARE_IMAGES
ifeq ($(BUILD_JDK), false)
SKIP_COMPARE_IMAGES = true
endif
ifeq ($(BUILD_DEPLOY), false)
SKIP_COMPARE_IMAGES = true
endif
ifeq ($(BUILD_INSTALL), false)
SKIP_COMPARE_IMAGES = true
endif
ifdef DEV_ONLY
SKIP_COMPARE_IMAGES = true
endif
endif
# Select defaults if these are not set to true or false
ifndef SKIP_DEBUG_BUILD
SKIP_DEBUG_BUILD=true
endif
ifndef SKIP_FASTDEBUG_BUILD
SKIP_FASTDEBUG_BUILD=false
endif
# Select javadoc setting GENERATE_DOCS
ifndef NO_DOCS
# Default value (we want javadoc run)
GENERATE_DOCS=true
# No DOCS build when JDK_UPDATE_VERSION set on non-OPENJDK builds
ifndef OPENJDK
ifdef JDK_UPDATE_VERSION
GENERATE_DOCS=false
endif
endif
# If langtools, corba, jaxp, and jaxws are not being built,
# a full jdk javadoc is not possible
ifneq ($(BUILD_LANGTOOLS), true)
GENERATE_DOCS=false
endif
ifneq ($(BUILD_CORBA), true)
GENERATE_DOCS=false
endif
ifneq ($(BUILD_JAXP), true)
GENERATE_DOCS=false
endif
ifneq ($(BUILD_JAXWS), true)
GENERATE_DOCS=false
endif
ifeq ($(GENERATE_DOCS),false)
NO_DOCS=true
endif
else
GENERATE_DOCS=false
endif
# Output directory for hotspot build
HOTSPOT_DIR = $(ABS_OUTPUTDIR)/hotspot
# If we are building components
ifndef ALT_LANGTOOLS_DIST
LANGTOOLS_OUTPUTDIR = $(ABS_OUTPUTDIR)/langtools
ABS_LANGTOOLS_DIST = $(LANGTOOLS_OUTPUTDIR)/dist
endif
ifndef ALT_CORBA_DIST
CORBA_OUTPUTDIR = $(ABS_OUTPUTDIR)/corba
ABS_CORBA_DIST = $(CORBA_OUTPUTDIR)/dist
endif
ifndef ALT_JAXP_DIST
JAXP_OUTPUTDIR = $(ABS_OUTPUTDIR)/jaxp
ABS_JAXP_DIST = $(JAXP_OUTPUTDIR)/dist
endif
ifndef ALT_JAXWS_DIST
JAXWS_OUTPUTDIR = $(ABS_OUTPUTDIR)/jaxws
ABS_JAXWS_DIST = $(JAXWS_OUTPUTDIR)/dist
endif
# Common make arguments (supplied to all component builds)
COMMON_BUILD_ARGUMENTS = \
JDK_TOPDIR=$(ABS_JDK_TOPDIR) \
JDK_MAKE_SHARED_DIR=$(ABS_JDK_TOPDIR)/make/common/shared \
EXTERNALSANITYCONTROL=true \
SOURCE_LANGUAGE_VERSION=$(SOURCE_LANGUAGE_VERSION) \
TARGET_CLASS_VERSION=$(TARGET_CLASS_VERSION) \
MILESTONE=$(MILESTONE) \
BUILD_NUMBER=$(BUILD_NUMBER) \
JDK_BUILD_NUMBER=$(JDK_BUILD_NUMBER) \
FULL_VERSION=$(FULL_VERSION) \
PREVIOUS_JDK_VERSION=$(PREVIOUS_JDK_VERSION) \
JDK_VERSION=$(JDK_VERSION) \
JDK_MKTG_VERSION=$(JDK_MKTG_VERSION) \
JDK_MAJOR_VERSION=$(JDK_MAJOR_VERSION) \
JDK_MINOR_VERSION=$(JDK_MINOR_VERSION) \
JDK_MICRO_VERSION=$(JDK_MICRO_VERSION) \
PREVIOUS_MAJOR_VERSION=$(PREVIOUS_MAJOR_VERSION) \
PREVIOUS_MINOR_VERSION=$(PREVIOUS_MINOR_VERSION) \
PREVIOUS_MICRO_VERSION=$(PREVIOUS_MICRO_VERSION)
ifdef ARCH_DATA_MODEL
COMMON_BUILD_ARGUMENTS += ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)
endif
ifeq ($(DEBUG_NAME), debug)
COMMON_BUILD_ARGUMENTS += VARIANT=DBG DEBUG_CLASSFILES=true
endif
ifeq ($(DEBUG_NAME), fastdebug)
COMMON_BUILD_ARGUMENTS += VARIANT=DBG FASTDEBUG=true DEBUG_CLASSFILES=true
endif
ifdef COOKED_JDK_UPDATE_VERSION
COMMON_BUILD_ARGUMENTS += COOKED_JDK_UPDATE_VERSION=$(COOKED_JDK_UPDATE_VERSION)
endif
ifdef COOKED_BUILD_NUMBER
COMMON_BUILD_ARGUMENTS += COOKED_BUILD_NUMBER=$(COOKED_BUILD_NUMBER)
endif
ifdef ANT_HOME
COMMON_BUILD_ARGUMENTS += ANT_HOME="$(ANT_HOME)"
endif