changeset 2087:e1523f7fd848

Merge
author rottenha
date Fri, 11 Feb 2011 05:40:41 -0800
parents e9f24eebafd4 b83527d0482d
children 2a9f9f2200fa
files make/closed.make
diffstat 31 files changed, 764 insertions(+), 200 deletions(-) [+]
line wrap: on
line diff
--- a/make/Makefile	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/Makefile	Fri Feb 11 05:40:41 2011 -0800
@@ -73,7 +73,7 @@
   include defs.make
 endif
 
-include $(GAMMADIR)/make/closed.make
+include $(GAMMADIR)/make/altsrc.make
 
 ifneq ($(ALT_OUTPUTDIR),)
   ALT_OUT=ALT_OUTPUTDIR=$(ALT_OUTPUTDIR)
@@ -362,7 +362,8 @@
 $(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/prims/%
 	$(install-file)
 
-$(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h:  $(HS_JNI_ARCH_SRC)
+HS_JNI_ARCH_SRC=$(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(HS_ARCH)/vm/jni_$(HS_ARCH).h)
+$(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h: $(HS_JNI_ARCH_SRC)
 	$(install-file)
 
 $(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/services/%
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/altsrc.make	Fri Feb 11 05:40:41 2011 -0800
@@ -0,0 +1,92 @@
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# This file defines variables and macros which are used in the makefiles to 
+# allow distributions to augment or replace common hotspot code with 
+# distribution-specific source files.
+
+# Requires: GAMMADIR
+# Provides:
+#   variables: HS_COMMON_SRC, HS_ALT_SRC, HS_COMMON_SRC_REL, and HS_ALT_SRC_REL
+#   functions: altsrc-equiv, if-has-altsrc, altsrc, altsrc-replace
+
+HS_COMMON_SRC_REL=src
+
+# This needs to be changed to a more generic location, but we keep it as this 
+# for now for compatibility
+HS_ALT_SRC_REL=src/closed
+
+HS_COMMON_SRC=$(GAMMADIR)/$(HS_COMMON_SRC_REL)
+HS_ALT_SRC=$(GAMMADIR)/$(HS_ALT_SRC_REL)
+
+
+## altsrc-equiv 
+# 
+# Convert a common source path to an alternative source path
+#
+# Parameter: An absolute path into the common sources
+# Result: The matching path to the alternate-source location
+#
+altsrc-equiv=$(subst $(HS_COMMON_SRC)/,$(HS_ALT_SRC)/,$(1))
+
+
+## if-has-altsrc
+#
+# Conditional macro to test for the existence of an alternate source path
+#
+# Parameter: An absolute path into the common sources
+# Parameter: Result if the alternative-source location exists
+# Parameter: Result if the alternative-source location does not exist
+# Result: expands to parameter 2 or 3 depending on existence of alternate source
+#
+if-has-altsrc=$(if $(wildcard $(call altsrc-equiv,$(1))),$(2),$(3))
+
+
+## altsrc
+#
+# Converts common source path to alternate source path if the alternate 
+# path exists, otherwise evaluates to nul (empty string)
+# 
+# Parameter: An absolute path into the common sources
+# Result: The equivalent path to the alternate-source location, if such a 
+#         location exists on the filesystem.  Otherwise it expands to empty.
+# 
+altsrc=$(call if-has-altsrc,$(1),$(call altsrc-equiv,$(1)))
+
+## commonsrc
+# 
+# Returns parameter.
+#
+commonsrc=$(1)
+
+
+## altsrc-replace
+#
+# Converts a common source path to an alternate source path if the alternate
+# source path exists.  Otherwise it evaluates to the input common source path.
+#
+# Parameter: An absolute path into the common sources
+# Result: A path to either the common or alternate sources
+#
+altsrc-replace=$(call if-has-altsrc,$(1),$(call altsrc-equiv,$(1)),$(1))
--- a/make/closed.make	Mon Feb 07 08:40:30 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-#
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#  
-#
-
-# Support for setting HS_CLOSED_PATH, required GAMMADIR and SRCARCH
-
-CLOSED_DIR_EXISTS := $(shell                                \
-  if [ -d $(GAMMADIR)/src/closed ] ; then                   \
-    echo true;                                              \
-  else                                                      \
-    echo false;                                             \
-  fi)
-
-CLOSED_SRCARCH_DIR_EXISTS := $(shell                        \
-  if [ -d $(GAMMADIR)/src/closed/cpu/$(SRCARCH)/vm ] ; then \
-    echo true;                                              \
-  else                                                      \
-    echo false;                                             \
-  fi)
-
-ifeq ($(CLOSED_SRCARCH_DIR_EXISTS), true)
-  HS_CLOSED_PATH=closed/
-endif
-
-# Support for setting HS_JNI_ARCH_SRC, requires HS_SRC_DIR and HS_ARCH
-
-CLOSED_HS_ARCH_DIR_EXISTS := $(shell                        \
-  if [ -d $(HS_SRC_DIR)/closed/cpu/$(HS_ARCH)/vm ] ; then   \
-    echo true;                                              \
-  else                                                      \
-    echo false;                                             \
-  fi)
-
-ifeq ($(CLOSED_HS_ARCH_DIR_EXISTS), true)
-  HS_JNI_ARCH_SRC=$(HS_SRC_DIR)/closed/cpu/$(HS_ARCH)/vm/jni_$(HS_ARCH).h
-else
-  HS_JNI_ARCH_SRC=$(HS_SRC_DIR)/cpu/$(HS_ARCH)/vm/jni_$(HS_ARCH).h
-endif
-
--- a/make/linux/makefiles/adlc.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/linux/makefiles/adlc.make	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
 # 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,8 +39,9 @@
 
 SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 
 
-SOURCES.AD = $(GAMMADIR)/src/$(HS_CLOSED_PATH)cpu/$(ARCH)/vm/$(Platform_arch_model).ad \
-	     $(GAMMADIR)/src/$(HS_CLOSED_PATH)os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad 
+SOURCES.AD = \
+  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
+  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
 
 EXEC	= $(OUTDIR)/adlc
 
--- a/make/linux/makefiles/buildtree.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/linux/makefiles/buildtree.make	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@
 # having to read the dependency files for the vm.
 
 include $(GAMMADIR)/make/scm.make
-include $(GAMMADIR)/make/closed.make
+include $(GAMMADIR)/make/altsrc.make
 
 
 # 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
@@ -148,7 +148,7 @@
 # Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
 # or make/hotspot_distro.
 ifndef HOTSPOT_VM_DISTRO
-  ifeq ($(CLOSED_DIR_EXISTS), true)
+  ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
     include $(GAMMADIR)/make/hotspot_distro
   else
     include $(GAMMADIR)/make/openjdk_distro
@@ -173,6 +173,11 @@
 $(SIMPLE_DIRS):
 	$(QUIETLY) mkdir -p $@
 
+# Convenience macro which takes a source relative path, applies $(1) to the
+# absolute path, and then replaces $(GAMMADIR) in the result with a 
+# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.  
+gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
+
 flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 	@echo Creating $@ ...
 	$(QUIETLY) ( \
@@ -204,16 +209,28 @@
 	echo; \
 	echo "Src_Dirs_V = \\"; \
 	sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
-	echo "\$$(GAMMADIR)/src/$(HS_CLOSED_PATH)cpu/$(SRCARCH)/vm \\"; \
-	echo "\$$(GAMMADIR)/src/os/$(OS_FAMILY)/vm \\"; \
-	echo "\$$(GAMMADIR)/src/$(HS_CLOSED_PATH)os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm"; \
+	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 	echo; \
 	echo "Src_Dirs_I = \\"; \
-	echo "\$$(GAMMADIR)/src/share/vm \\"; \
-	echo "\$$(GAMMADIR)/src/share/vm/prims \\"; \
-	echo "\$$(GAMMADIR)/src/$(HS_CLOSED_PATH)cpu/$(SRCARCH)/vm \\"; \
-	echo "\$$(GAMMADIR)/src/os/$(OS_FAMILY)/vm \\"; \
-	echo "\$$(GAMMADIR)/src/$(HS_CLOSED_PATH)os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm"; \
+	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
+	echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
+	echo "$(call gamma-path,altsrc,share/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,share/vm) \\"; \
+	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 	[ -n "$(CFLAGS_BROWSE)" ] && \
 	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
@@ -237,9 +254,14 @@
 
 ../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
 	@echo Creating directory list $@
-	$(QUIETLY) find $(GAMMADIR)/src/share/vm/* -prune \
+	$(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
+          find $(HS_ALT_SRC)/share/vm/* -prune \
+	  -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
+          \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
+        fi;
+	$(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
 	-type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@
+        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
 
 Makefile: $(BUILDTREE_MAKE)
 	@echo Creating $@ ...
--- a/make/linux/makefiles/rules.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/linux/makefiles/rules.make	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -146,7 +146,7 @@
 include $(GAMMADIR)/make/pic.make
 endif
 
-include $(GAMMADIR)/make/closed.make
+include $(GAMMADIR)/make/altsrc.make
 
 # The non-PIC object files are only generated for 32 bit platforms.
 ifdef LP64
--- a/make/linux/makefiles/top.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/linux/makefiles/top.make	Fri Feb 11 05:40:41 2011 -0800
@@ -39,7 +39,7 @@
 # Instead, use "gmake" (or "gnumake") from the command line.  --Rose
 #MAKE = gmake
 
-include $(GAMMADIR)/make/closed.make
+include $(GAMMADIR)/make/altsrc.make
 
 TOPDIR      = $(shell echo `pwd`)
 GENERATED   = $(TOPDIR)/../generated
@@ -59,8 +59,8 @@
 
 AD_Dir   = $(GENERATED)/adfiles
 ADLC     = $(AD_Dir)/adlc
-AD_Spec  = $(GAMMADIR)/src/$(HS_CLOSED_PATH)cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad
-AD_Src   = $(GAMMADIR)/src/share/vm/adlc
+AD_Spec  = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad)
+AD_Src   = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc)
 AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp
 AD_Files = $(AD_Names:%=$(AD_Dir)/%)
 
--- a/make/linux/makefiles/vm.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/linux/makefiles/vm.make	Fri Feb 11 05:40:41 2011 -0800
@@ -28,6 +28,7 @@
 # Common build rules.
 MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
 include $(MAKEFILES_DIR)/rules.make
+include $(GAMMADIR)/make/altsrc.make
 
 default: build
 
@@ -119,17 +120,27 @@
 LIBJVM   = lib$(JVM).so
 LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
 
-CORE_PATHS := $(shell find $(GAMMADIR)/src/share/vm/* -type d \! \( -name adlc -o -name c1 -o -name gc_implementation -o -name opto -o -name shark -o -name libadt \))
-CORE_PATHS += $(GAMMADIR)/src/os/$(Platform_os_family)/vm
-CORE_PATHS += $(GAMMADIR)/src/$(HS_CLOSED_PATH)cpu/$(Platform_arch)/vm
-CORE_PATHS += $(GAMMADIR)/src/$(HS_CLOSED_PATH)os_cpu/$(Platform_os_arch)/vm
-CORE_PATHS += $(GENERATED)/jvmtifiles
+SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt
 
-COMPILER1_PATHS := $(GAMMADIR)/src/share/vm/c1
+SOURCE_PATHS=\
+  $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
+      \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
 
-COMPILER2_PATHS := $(GAMMADIR)/src/share/vm/opto
-COMPILER2_PATHS += $(GAMMADIR)/src/share/vm/libadt
-COMPILER2_PATHS +=  $(GENERATED)/adfiles
+CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
+CORE_PATHS+=$(GENERATED)/jvmtifiles
+
+COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
+COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
+
+COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
+COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
+COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
+COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
+COMPILER2_PATHS += $(GENERATED)/adfiles
 
 # Include dirs per type.
 Src_Dirs/CORE      := $(CORE_PATHS)
--- a/make/solaris/makefiles/adlc.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/solaris/makefiles/adlc.make	Fri Feb 11 05:40:41 2011 -0800
@@ -27,6 +27,7 @@
 # It knows how to compile, link, and run the adlc.
 
 include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
+include $(GAMMADIR)/make/altsrc.make
 
 # #########################################################################
 
@@ -39,8 +40,9 @@
 
 SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 
 
-SOURCES.AD = $(GAMMADIR)/src/cpu/$(ARCH)/vm/$(Platform_arch_model).ad \
-	     $(GAMMADIR)/src/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad 
+SOURCES.AD = \
+  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
+  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
 
 EXEC	= $(OUTDIR)/adlc
 
--- a/make/solaris/makefiles/buildtree.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/solaris/makefiles/buildtree.make	Fri Feb 11 05:40:41 2011 -0800
@@ -56,6 +56,7 @@
 # having to read the dependency files for the vm.
 
 include $(GAMMADIR)/make/scm.make
+include $(GAMMADIR)/make/altsrc.make
 
 # 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
 QUIETLY$(MAKE_VERBOSE)	= @
@@ -139,13 +140,7 @@
 # Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
 # or make/hotspot_distro.
 ifndef HOTSPOT_VM_DISTRO
-  CLOSED_DIR_EXISTS := $(shell                \
-    if [ -d $(GAMMADIR)/src/closed ] ; then \
-      echo true;                              \
-    else                                      \
-      echo false;                             \
-    fi)
-  ifeq ($(CLOSED_DIR_EXISTS), true)
+  ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
     include $(GAMMADIR)/make/hotspot_distro
   else
     include $(GAMMADIR)/make/openjdk_distro
@@ -170,6 +165,11 @@
 $(SIMPLE_DIRS):
 	$(QUIETLY) mkdir -p $@
 
+# Convenience macro which takes a source relative path, applies $(1) to the
+# absolute path, and then replaces $(GAMMADIR) in the result with a 
+# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.  
+gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
+
 flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
 	@echo Creating $@ ...
 	$(QUIETLY) ( \
@@ -202,16 +202,28 @@
 	echo; \
 	echo "Src_Dirs_V = \\"; \
 	sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
-	echo "\$$(GAMMADIR)/src/cpu/$(ARCH)/vm \\"; \
-	echo "\$$(GAMMADIR)/src/os/$(OS_FAMILY)/vm \\"; \
-	echo "\$$(GAMMADIR)/src/os_cpu/$(OS_FAMILY)_$(ARCH)/vm"; \
+	echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 	echo; \
 	echo "Src_Dirs_I = \\"; \
-	echo "\$$(GAMMADIR)/src/share/vm \\"; \
-	echo "\$$(GAMMADIR)/src/share/vm/prims \\"; \
-	echo "\$$(GAMMADIR)/src/cpu/$(ARCH)/vm \\"; \
-	echo "\$$(GAMMADIR)/src/os/$(OS_FAMILY)/vm \\"; \
-	echo "\$$(GAMMADIR)/src/os_cpu/$(OS_FAMILY)_$(ARCH)/vm"; \
+	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
+	echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
+	echo "$(call gamma-path,altsrc,share/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,share/vm) \\"; \
+	echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 	[ -n "$(CFLAGS_BROWSE)" ] && \
 	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
@@ -235,9 +247,14 @@
 
 ../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
 	@echo Creating directory list $@
-	$(QUIETLY) find $(GAMMADIR)/src/share/vm/* -prune \
+	$(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
+          find $(HS_ALT_SRC)/share/vm/* -prune \
+	  -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
+          \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
+        fi;
+	$(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
 	-type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
-        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@
+        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
 
 Makefile: $(BUILDTREE_MAKE)
 	@echo Creating $@ ...
--- a/make/solaris/makefiles/rules.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/solaris/makefiles/rules.make	Fri Feb 11 05:40:41 2011 -0800
@@ -146,6 +146,8 @@
 include $(GAMMADIR)/make/pic.make
 endif
 
+include $(GAMMADIR)/make/altsrc.make
+
 # Sun compiler for 64 bit Solaris does not support building non-PIC object files.
 ifdef LP64
 %.o: %.cpp
--- a/make/solaris/makefiles/top.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/solaris/makefiles/top.make	Fri Feb 11 05:40:41 2011 -0800
@@ -39,6 +39,8 @@
 # Instead, use "gmake" (or "gnumake") from the command line.  --Rose
 #MAKE = gmake
 
+include $(GAMMADIR)/make/altsrc.make
+
 GENERATED   = ../generated
 VM          = $(GAMMADIR)/src/share/vm
 Plat_File   = $(Platform_file)
@@ -48,8 +50,8 @@
 
 AD_Dir   = $(GENERATED)/adfiles
 ADLC     = $(AD_Dir)/adlc
-AD_Spec  = $(GAMMADIR)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad
-AD_Src   = $(GAMMADIR)/src/share/vm/adlc
+AD_Spec  = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad)
+AD_Src   = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc)
 AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp
 AD_Files = $(AD_Names:%=$(AD_Dir)/%)
 
--- a/make/solaris/makefiles/vm.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/solaris/makefiles/vm.make	Fri Feb 11 05:40:41 2011 -0800
@@ -28,6 +28,7 @@
 # Common build rules.
 MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
 include $(MAKEFILES_DIR)/rules.make
+include $(GAMMADIR)/make/altsrc.make
 
 default: build
 
@@ -139,16 +140,26 @@
 LIBJVM   = lib$(JVM).so
 LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
 
-CORE_PATHS := $(shell find $(GAMMADIR)/src/share/vm/* -type d \! \( -name adlc -o -name c1 -o -name gc_implementation -o -name opto -o -name shark -o -name libadt \))
-CORE_PATHS += $(GAMMADIR)/src/os/$(Platform_os_family)/vm
-CORE_PATHS += $(GAMMADIR)/src/cpu/$(Platform_arch)/vm
-CORE_PATHS += $(GAMMADIR)/src/os_cpu/$(Platform_os_arch)/vm
-CORE_PATHS += $(GENERATED)/jvmtifiles
+SPECIAL_PATHS:=adlc c1 dist gc_implementation opto shark libadt
 
-COMPILER1_PATHS := $(GAMMADIR)/src/share/vm/c1
+SOURCE_PATHS=\
+  $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
+      \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
 
-COMPILER2_PATHS := $(GAMMADIR)/src/share/vm/opto
-COMPILER2_PATHS += $(GAMMADIR)/src/share/vm/libadt
+CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
+CORE_PATHS+=$(GENERATED)/jvmtifiles
+
+COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
+COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
+
+COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
+COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
+COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
+COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
 COMPILER2_PATHS +=  $(GENERATED)/adfiles
 
 # Include dirs per type.
--- a/make/windows/create_obj_files.sh	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/windows/create_obj_files.sh	Fri Feb 11 05:40:41 2011 -0800
@@ -51,21 +51,48 @@
 WorkSpace=$4
 GENERATED=$5
 
-BASE_PATHS="` $FIND ${WorkSpace}/src/share/vm ! -name vm -prune -type d \! \( -name adlc -o -name c1 -o -name gc_implementation -o -name opto -o -name shark -o -name libadt \)`"
-BASE_PATHS="${BASE_PATHS} ${WorkSpace}/src/share/vm/gc_implementation/shared"
-BASE_PATHS="${BASE_PATHS} ${WorkSpace}/src/os/${Platform_os_family}/vm"
-BASE_PATHS="${BASE_PATHS} ${WorkSpace}/src/cpu/${Platform_arch}/vm"
-BASE_PATHS="${BASE_PATHS} ${WorkSpace}/src/os_cpu/${Platform_os_arch}/vm"
+COMMONSRC_REL=src
+ALTSRC_REL=src/closed # Change this to pick up alt sources from somewhere else
+
+COMMONSRC=${WorkSpace}/${COMMONSRC_REL}
+ALTSRC=${WorkSpace}/${ALTSRC_REL}
+
+BASE_PATHS="`if [ -d ${ALTSRC}/share/vm ]; then $FIND ${ALTSRC}/share/vm ! -name vm -prune -type d \! \( -name adlc -o -name c1 -o -name gc_implementation -o -name opto -o -name shark -o -name libadt \); fi`"
+BASE_PATHS="${BASE_PATHS} ` $FIND ${COMMONSRC}/share/vm ! -name vm -prune -type d \! \( -name adlc -o -name c1 -o -name gc_implementation -o -name opto -o -name shark -o -name libadt \)`"
+
+for sd in \
+    share/vm/gc_implementation/shared \
+    os/${Platform_os_family}/vm \
+    cpu/${Platform_arch}/vm \
+    os_cpu/${Platform_os_arch}/vm; do 
+  if [ -d "${ALTSRC}/${sd}" ]; then
+    BASE_PATHS="${BASE_PATHS} ${ALTSRC}/${sd}"
+  fi
+  BASE_PATHS="${BASE_PATHS} ${COMMONSRC}/${sd}"
+done
+
 BASE_PATHS="${BASE_PATHS} ${GENERATED}/jvmtifiles"
 
 CORE_PATHS="${BASE_PATHS}"
 # shared is already in BASE_PATHS. Should add vm/memory but that one is also in BASE_PATHS.
-CORE_PATHS="${CORE_PATHS} `$FIND ${WorkSpace}/src/share/vm/gc_implementation ! -name gc_implementation -prune -type d \! -name shared`"
+if [ -d "${ALTSRC}/share/vm/gc_implementation" ]; then
+  CORE_PATHS="${CORE_PATHS} `$FIND ${ALTSRC}/share/vm/gc_implementation ! -name gc_implementation -prune -type d \! -name shared`"
+fi
+CORE_PATHS="${CORE_PATHS} `$FIND ${COMMONSRC}/share/vm/gc_implementation ! -name gc_implementation -prune -type d \! -name shared`"
 
-COMPILER1_PATHS="${WorkSpace}/src/share/vm/c1"
+if [ -d "${ALTSRC}/share/vm/c1" ]; then
+  COMPILER1_PATHS="${ALTSRC}/share/vm/c1"
+fi
+COMPILER1_PATHS="${COMPILER1_PATHS} ${COMMONSRC}/share/vm/c1"
 
-COMPILER2_PATHS="${WorkSpace}/src/share/vm/opto"
-COMPILER2_PATHS="${COMPILER2_PATHS} ${WorkSpace}/src/share/vm/libadt"
+if [ -d "${ALTSRC}/share/vm/opto" ]; then
+  COMPILER2_PATHS="${ALTSRC}/share/vm/opto"
+fi
+COMPILER2_PATHS="${COMPILER2_PATHS} ${COMMONSRC}/share/vm/opto"
+if [ -d "${ALTSRC}/share/vm/libadt" ]; then
+  COMPILER2_PATHS="${COMPILER2_PATHS} ${ALTSRC}/share/vm/libadt"
+fi
+COMPILER2_PATHS="${COMPILER2_PATHS} ${COMMONSRC}/share/vm/libadt"
 COMPILER2_PATHS="${COMPILER2_PATHS} ${GENERATED}/adfiles"
 
 # Include dirs per type.
--- a/make/windows/makefiles/vm.make	Mon Feb 07 08:40:30 2011 -0800
+++ b/make/windows/makefiles/vm.make	Fri Feb 11 05:40:41 2011 -0800
@@ -27,6 +27,9 @@
 
 !include ..\generated\objfiles.make
 
+COMMONSRC=$(WorkSpace)\src
+ALTSRC=$(WorkSpace)\src\closed
+
 !ifdef RELEASE 
 !ifdef DEVELOP
 CPP_FLAGS=$(CPP_FLAGS) /D "DEBUG"
@@ -111,13 +114,30 @@
   /export:JVM_GetThreadStateValues           \
   /export:JVM_InitAgentProperties
 
-CPP_INCLUDE_DIRS=\
-  /I "..\generated" \
-  /I "$(WorkSpace)\src\share\vm" \
-  /I "$(WorkSpace)\src\share\vm\prims" \
-  /I "$(WorkSpace)\src\os\windows\vm" \
-  /I "$(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm" \
-  /I "$(WorkSpace)\src\cpu\$(Platform_arch)\vm"
+CPP_INCLUDE_DIRS=/I "..\generated"
+
+!if exists($(ALTSRC)\share\vm)
+CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\share\vm"
+!endif
+
+!if exists($(ALTSRC)\os\windows\vm)
+CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\os\windows\vm"
+!endif
+
+!if exists($(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm)
+CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm"
+!endif
+
+!if exists($(ALTSRC)\cpu\$(Platform_arch)\vm)
+CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\cpu\$(Platform_arch)\vm"
+!endif
+
+CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) \
+  /I "$(COMMONSRC)\share\vm" \
+  /I "$(COMMONSRC)\share\vm\prims" \
+  /I "$(COMMONSRC)\os\windows\vm" \
+  /I "$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm" \
+  /I "$(COMMONSRC)\cpu\$(Platform_arch)\vm"
 
 CPP_DONT_USE_PCH=/D DONT_USE_PRECOMPILED_HEADER
 
@@ -127,7 +147,7 @@
 CPP_USE_PCH=$(CPP_DONT_USE_PCH)
 !endif
 
-# Where to find the source code for the virtual machine
+# Where to find the source code for the virtual machine (is this used?)
 VM_PATH=../generated
 VM_PATH=$(VM_PATH);../generated/adfiles
 VM_PATH=$(VM_PATH);../generated/jvmtifiles
@@ -188,81 +208,157 @@
         $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c ..\generated\jvmtifiles\bytecodeInterpreterWithChecks.cpp
 
 # Default rules for the Virtual Machine
-{$(WorkSpace)\src\share\vm\c1}.cpp.obj::
+{$(COMMONSRC)\share\vm\c1}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\compiler}.cpp.obj::
+{$(COMMONSRC)\share\vm\compiler}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\code}.cpp.obj::
+{$(COMMONSRC)\share\vm\code}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\interpreter}.cpp.obj::
+{$(COMMONSRC)\share\vm\interpreter}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\ci}.cpp.obj::
+{$(COMMONSRC)\share\vm\ci}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\classfile}.cpp.obj::
+{$(COMMONSRC)\share\vm\classfile}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\gc_implementation\parallelScavenge}.cpp.obj::
+{$(COMMONSRC)\share\vm\gc_implementation\parallelScavenge}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\gc_implementation\shared}.cpp.obj::
+{$(COMMONSRC)\share\vm\gc_implementation\shared}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\gc_implementation\parNew}.cpp.obj::
+{$(COMMONSRC)\share\vm\gc_implementation\parNew}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\gc_implementation\concurrentMarkSweep}.cpp.obj::
+{$(COMMONSRC)\share\vm\gc_implementation\concurrentMarkSweep}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\gc_implementation\g1}.cpp.obj::
+{$(COMMONSRC)\share\vm\gc_implementation\g1}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\gc_interface}.cpp.obj::
+{$(COMMONSRC)\share\vm\gc_interface}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\asm}.cpp.obj::
+{$(COMMONSRC)\share\vm\asm}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\memory}.cpp.obj::
+{$(COMMONSRC)\share\vm\memory}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\oops}.cpp.obj::
+{$(COMMONSRC)\share\vm\oops}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\prims}.cpp.obj::
+{$(COMMONSRC)\share\vm\prims}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\runtime}.cpp.obj::
+{$(COMMONSRC)\share\vm\runtime}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\services}.cpp.obj::
+{$(COMMONSRC)\share\vm\services}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\utilities}.cpp.obj::
+{$(COMMONSRC)\share\vm\utilities}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\libadt}.cpp.obj::
+{$(COMMONSRC)\share\vm\libadt}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\share\vm\opto}.cpp.obj::
+{$(COMMONSRC)\share\vm\opto}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\os\windows\vm}.cpp.obj::
+{$(COMMONSRC)\os\windows\vm}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
 # This guy should remain a single colon rule because
 # otherwise we can't specify the output filename.
-{$(WorkSpace)\src\os\windows\vm}.rc.res:
+{$(COMMONSRC)\os\windows\vm}.rc.res:
         @$(RC) $(RC_FLAGS) /fo"$@" $<
 
-{$(WorkSpace)\src\cpu\$(Platform_arch)\vm}.cpp.obj::
+{$(COMMONSRC)\cpu\$(Platform_arch)\vm}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
-{$(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj::
+{$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\c1}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\compiler}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\code}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\interpreter}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\ci}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\classfile}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\gc_implementation\parallelScavenge}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\gc_implementation\shared}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\gc_implementation\parNew}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\gc_implementation\concurrentMarkSweep}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\gc_implementation\g1}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\gc_interface}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\asm}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\memory}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\oops}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\prims}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\runtime}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\services}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\utilities}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\libadt}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\share\vm\opto}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\os\windows\vm}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+# otherwise we can't specify the output filename.
+{$(ALTSRC)\os\windows\vm}.rc.res:
+        @$(RC) $(RC_FLAGS) /fo"$@" $<
+
+{$(ALTSRC)\cpu\$(Platform_arch)\vm}.cpp.obj::
+        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+
+{$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj::
         $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
 
 {..\generated\incls}.cpp.obj::
--- a/src/os/linux/vm/os_linux.cpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/os/linux/vm/os_linux.cpp	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -131,6 +131,7 @@
 #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
 #define SEC_IN_NANOSECS  1000000000LL
 
+#define LARGEPAGES_BIT (1 << 6)
 ////////////////////////////////////////////////////////////////////////////////
 // global variables
 julong os::Linux::_physical_memory = 0;
@@ -2817,6 +2818,43 @@
   return linux_mprotect(addr, size, PROT_READ|PROT_WRITE);
 }
 
+/*
+* Set the coredump_filter bits to include largepages in core dump (bit 6)
+*
+* From the coredump_filter documentation:
+*
+* - (bit 0) anonymous private memory
+* - (bit 1) anonymous shared memory
+* - (bit 2) file-backed private memory
+* - (bit 3) file-backed shared memory
+* - (bit 4) ELF header pages in file-backed private memory areas (it is
+*           effective only if the bit 2 is cleared)
+* - (bit 5) hugetlb private memory
+* - (bit 6) hugetlb shared memory
+*/
+static void set_coredump_filter(void) {
+  FILE *f;
+  long cdm;
+
+  if ((f = fopen("/proc/self/coredump_filter", "r+")) == NULL) {
+    return;
+  }
+
+  if (fscanf(f, "%lx", &cdm) != 1) {
+    fclose(f);
+    return;
+  }
+
+  rewind(f);
+
+  if ((cdm & LARGEPAGES_BIT) == 0) {
+    cdm |= LARGEPAGES_BIT;
+    fprintf(f, "%#lx", cdm);
+  }
+
+  fclose(f);
+}
+
 // Large page support
 
 static size_t _large_page_size = 0;
@@ -2874,6 +2912,8 @@
     _page_sizes[2] = 0;
   }
 
+  set_coredump_filter();
+
   // Large page support is available on 2.6 or newer kernel, some vendors
   // (e.g. Redhat) have backported it to their 2.4 based distributions.
   // We optimistically assume the support is available. If later it turns out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/os/posix/vm/os_posix.cpp	Fri Feb 11 05:40:41 2011 -0800
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* This code is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License version 2 only, as
+* published by the Free Software Foundation.
+*
+* This code is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+* version 2 for more details (a copy is included in the LICENSE file that
+* accompanied this code).
+*
+* You should have received a copy of the GNU General Public License version
+* 2 along with this work; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+*
+* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+* or visit www.oracle.com if you need additional information or have any
+* questions.
+*
+*/
+
+#include "prims/jvm.h"
+#include "runtime/os.hpp"
+#include "utilities/vmError.hpp"
+
+#include <unistd.h>
+#include <sys/resource.h>
+
+// Check core dump limit and report possible place where core can be found
+void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
+  struct rlimit rlim;
+  static char cwd[O_BUFLEN];
+  bool success;
+
+  get_current_directory(cwd, sizeof(cwd));
+
+  if (getrlimit(RLIMIT_CORE, &rlim) != 0) {
+    jio_snprintf(buffer, bufferSize, "%s/core or core.%d (may not exist)", cwd, current_process_id());
+    success = true;
+  } else {
+    switch(rlim.rlim_cur) {
+      case RLIM_INFINITY:
+        jio_snprintf(buffer, bufferSize, "%s/core or core.%d", cwd, current_process_id());
+        success = true;
+        break;
+      case 0:
+        jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again");
+        success = false;
+        break;
+      default:
+        jio_snprintf(buffer, bufferSize, "%s/core or core.%d (max size %lu kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", cwd, current_process_id(), (unsigned long)(rlim.rlim_cur >> 10));
+        success = true;
+        break;
+    }
+  }
+  VMError::report_coredump_status(buffer, success);
+}
+
--- a/src/os/windows/vm/os_windows.cpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/os/windows/vm/os_windows.cpp	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * CopyrighT (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -915,6 +915,85 @@
   }
 }
 
+
+static BOOL  (WINAPI *_MiniDumpWriteDump)  ( HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, PMINIDUMP_EXCEPTION_INFORMATION,
+                                            PMINIDUMP_USER_STREAM_INFORMATION, PMINIDUMP_CALLBACK_INFORMATION);
+
+void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
+  HINSTANCE dbghelp;
+  EXCEPTION_POINTERS ep;
+  MINIDUMP_EXCEPTION_INFORMATION mei;
+  HANDLE hProcess = GetCurrentProcess();
+  DWORD processId = GetCurrentProcessId();
+  HANDLE dumpFile;
+  MINIDUMP_TYPE dumpType;
+  static const char* cwd;
+
+  // If running on a client version of Windows and user has not explicitly enabled dumping
+  if (!os::win32::is_windows_server() && !CreateMinidumpOnCrash) {
+    VMError::report_coredump_status("Minidumps are not enabled by default on client versions of Windows", false);
+    return;
+    // If running on a server version of Windows and user has explictly disabled dumping
+  } else if (os::win32::is_windows_server() && !FLAG_IS_DEFAULT(CreateMinidumpOnCrash) && !CreateMinidumpOnCrash) {
+    VMError::report_coredump_status("Minidump has been disabled from the command line", false);
+    return;
+  }
+
+  dbghelp = LoadLibrary("DBGHELP.DLL");
+
+  if (dbghelp == NULL) {
+    VMError::report_coredump_status("Failed to load dbghelp.dll", false);
+    return;
+  }
+
+  _MiniDumpWriteDump = CAST_TO_FN_PTR(
+    BOOL(WINAPI *)( HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, PMINIDUMP_EXCEPTION_INFORMATION,
+    PMINIDUMP_USER_STREAM_INFORMATION, PMINIDUMP_CALLBACK_INFORMATION),
+    GetProcAddress(dbghelp, "MiniDumpWriteDump"));
+
+  if (_MiniDumpWriteDump == NULL) {
+    VMError::report_coredump_status("Failed to find MiniDumpWriteDump() in module dbghelp.dll", false);
+    return;
+  }
+
+  dumpType = (MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithHandleData);
+
+// Older versions of dbghelp.h doesn't contain all the dumptypes we want, dbghelp.h with
+// API_VERSION_NUMBER 11 or higher contains the ones we want though
+#if API_VERSION_NUMBER >= 11
+  dumpType = (MINIDUMP_TYPE)(dumpType | MiniDumpWithFullMemoryInfo | MiniDumpWithThreadInfo |
+    MiniDumpWithUnloadedModules);
+#endif
+
+  cwd = get_current_directory(NULL, 0);
+  jio_snprintf(buffer, bufferSize, "%s\\hs_err_pid%u.mdmp",cwd, current_process_id());
+  dumpFile = CreateFile(buffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+  if (dumpFile == INVALID_HANDLE_VALUE) {
+    VMError::report_coredump_status("Failed to create file for dumping", false);
+    return;
+  }
+
+  ep.ContextRecord = (PCONTEXT) contextRecord;
+  ep.ExceptionRecord = (PEXCEPTION_RECORD) exceptionRecord;
+
+  mei.ThreadId = GetCurrentThreadId();
+  mei.ExceptionPointers = &ep;
+
+  // Older versions of dbghelp.dll (the one shipped with Win2003 for example) may not support all
+  // the dump types we really want. If first call fails, lets fall back to just use MiniDumpWithFullMemory then.
+  if (_MiniDumpWriteDump(hProcess, processId, dumpFile, dumpType, &mei, NULL, NULL) == false &&
+      _MiniDumpWriteDump(hProcess, processId, dumpFile, (MINIDUMP_TYPE)MiniDumpWithFullMemory, &mei, NULL, NULL) == false) {
+    VMError::report_coredump_status("Call to MiniDumpWriteDump() failed", false);
+  } else {
+    VMError::report_coredump_status(buffer, true);
+  }
+
+  CloseHandle(dumpFile);
+}
+
+
+
 void os::abort(bool dump_core)
 {
   os::shutdown();
@@ -3274,7 +3353,7 @@
 
 bool   os::win32::_is_nt              = false;
 bool   os::win32::_is_windows_2003    = false;
-
+bool   os::win32::_is_windows_server  = false;
 
 void os::win32::initialize_system_info() {
   SYSTEM_INFO si;
@@ -3293,9 +3372,9 @@
   GlobalMemoryStatusEx(&ms);
   _physical_memory = ms.ullTotalPhys;
 
-  OSVERSIONINFO oi;
-  oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-  GetVersionEx(&oi);
+  OSVERSIONINFOEX oi;
+  oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+  GetVersionEx((OSVERSIONINFO*)&oi);
   switch(oi.dwPlatformId) {
     case VER_PLATFORM_WIN32_WINDOWS: _is_nt = false; break;
     case VER_PLATFORM_WIN32_NT:
@@ -3305,6 +3384,10 @@
         if (os_vers == 5002) {
           _is_windows_2003 = true;
         }
+        if (oi.wProductType == VER_NT_DOMAIN_CONTROLLER ||
+          oi.wProductType == VER_NT_SERVER) {
+            _is_windows_server = true;
+        }
       }
       break;
     default: fatal("Unknown platform");
--- a/src/os/windows/vm/os_windows.hpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/os/windows/vm/os_windows.hpp	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,7 @@
   static size_t _default_stack_size;
   static bool   _is_nt;
   static bool   _is_windows_2003;
+  static bool   _is_windows_server;
 
  public:
   // Windows-specific interface:
@@ -64,6 +65,9 @@
   // Tells whether the platform is NT or Windown95
   static bool is_nt() { return _is_nt; }
 
+  // Tells whether this is a server version of Windows
+  static bool is_windows_server() { return _is_windows_server; }
+
   // Tells whether the platform is Windows 2003
   static bool is_windows_2003() { return _is_windows_2003; }
 
--- a/src/share/vm/classfile/vmSymbols.hpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/classfile/vmSymbols.hpp	Fri Feb 11 05:40:41 2011 -0800
@@ -108,7 +108,6 @@
   template(java_lang_AssertionStatusDirectives,       "java/lang/AssertionStatusDirectives")      \
   template(sun_jkernel_DownloadManager,               "sun/jkernel/DownloadManager")              \
   template(getBootClassPathEntryForClass_name,        "getBootClassPathEntryForClass")            \
-  template(setBootClassLoaderHook_name,               "setBootClassLoaderHook")                   \
   template(sun_misc_PostVMInitHook,                   "sun/misc/PostVMInitHook")                  \
                                                                                                   \
   /* class file format tags */                                                                    \
--- a/src/share/vm/runtime/globals.hpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/runtime/globals.hpp	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -790,6 +790,9 @@
   product(bool, ShowMessageBoxOnError, false,                               \
           "Keep process alive on VM fatal error")                           \
                                                                             \
+  product(bool, CreateMinidumpOnCrash, false,                               \
+          "Create minidump on VM fatal error")                              \
+                                                                            \
   product_pd(bool, UseOSErrorReporting,                                     \
           "Let VM fatal error propagate to the OS (ie. WER on Windows)")    \
                                                                             \
@@ -3655,6 +3658,12 @@
   manageable(bool, PrintConcurrentLocks, false,                             \
           "Print java.util.concurrent locks in thread dump")                \
                                                                             \
+  diagnostic(bool, TransmitErrorReport, false,                              \
+          "Enable error report transmission on erroneous termination")      \
+                                                                            \
+  diagnostic(ccstr, ErrorReportServer, NULL,                                \
+          "Override built-in error report server address")                  \
+                                                                            \
   /* Shared spaces */                                                       \
                                                                             \
   product(bool, UseSharedSpaces, true,                                      \
--- a/src/share/vm/runtime/os.hpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/runtime/os.hpp	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -614,6 +614,9 @@
   // Structured OS Exception support
   static void os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread);
 
+  // On Windows this will create an actual minidump, on Linux/Solaris it will simply check core dump limits
+  static void check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize);
+
   // JVMTI & JVM monitoring and management support
   // The thread_cpu_time() and current_thread_cpu_time() are only
   // supported if is_thread_cpu_time_supported() returns true.
--- a/src/share/vm/runtime/thread.cpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/runtime/thread.cpp	Fri Feb 11 05:40:41 2011 -0800
@@ -962,22 +962,6 @@
                                          vmSymbols::void_method_signature(), CHECK);
 }
 
-#ifdef KERNEL
-static void set_jkernel_boot_classloader_hook(TRAPS) {
-  klassOop k = SystemDictionary::sun_jkernel_DownloadManager_klass();
-  instanceKlassHandle klass (THREAD, k);
-
-  if (k == NULL) {
-    // sun.jkernel.DownloadManager may not present in the JDK; just return
-    return;
-  }
-
-  JavaValue result(T_VOID);
-  JavaCalls::call_static(&result, klass, vmSymbols::setBootClassLoaderHook_name(),
-                                         vmSymbols::void_method_signature(), CHECK);
-}
-#endif // KERNEL
-
 // General purpose hook into Java code, run once when the VM is initialized.
 // The Java library method itself may be changed independently from the VM.
 static void call_postVMInitHook(TRAPS) {
@@ -1611,7 +1595,15 @@
                                   uncaught_exception,  // Arg 2
                                   THREAD);
         }
-        CLEAR_PENDING_EXCEPTION;
+        if (HAS_PENDING_EXCEPTION) {
+          ResourceMark rm(this);
+          jio_fprintf(defaultStream::error_stream(),
+                "\nException: %s thrown from the UncaughtExceptionHandler"
+                " in thread \"%s\"\n",
+                Klass::cast(pending_exception()->klass())->external_name(),
+                get_thread_name());
+          CLEAR_PENDING_EXCEPTION;
+        }
       }
     }
 
@@ -3284,12 +3276,6 @@
     vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
   }
 
-#ifdef KERNEL
-  if (JDK_Version::is_gte_jdk17x_version()) {
-    set_jkernel_boot_classloader_hook(THREAD);
-  }
-#endif // KERNEL
-
 #ifndef SERIALGC
   // Support for ConcurrentMarkSweep. This should be cleaned up
   // and better encapsulated. The ugly nested if test would go away
--- a/src/share/vm/runtime/vm_version.cpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/runtime/vm_version.cpp	Fri Feb 11 05:40:41 2011 -0800
@@ -245,6 +245,10 @@
          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER;
 }
 
+const char *Abstract_VM_Version::vm_build_user() {
+  return HOTSPOT_BUILD_USER;
+}
+
 unsigned int Abstract_VM_Version::jvm_version() {
   return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) |
          ((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) |
--- a/src/share/vm/runtime/vm_version.hpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/runtime/vm_version.hpp	Fri Feb 11 05:40:41 2011 -0800
@@ -59,6 +59,7 @@
   static const char* vm_info_string();
   static const char* vm_release();
   static const char* vm_platform_string();
+  static const char* vm_build_user();
 
   static int vm_major_version()               { assert(_initialized, "not initialized"); return _vm_major_version; }
   static int vm_minor_version()               { assert(_initialized, "not initialized"); return _vm_minor_version; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/utilities/errorReporter.cpp	Fri Feb 11 05:40:41 2011 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "utilities/errorReporter.hpp"
+
+ErrorReporter::ErrorReporter() {}
+
+void ErrorReporter::call(FILE* fd, char* buffer, int length) {
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/utilities/errorReporter.hpp	Fri Feb 11 05:40:41 2011 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_UTILITIES_ERRORREPORTER_HPP
+#define SHARE_VM_UTILITIES_ERRORREPORTER_HPP
+
+#include "utilities/globalDefinitions.hpp"
+
+class ErrorReporter : public StackObj {
+
+public:
+  ErrorReporter();
+  ~ErrorReporter(){};
+
+  void call(FILE* fd, char *buffer, int length);
+};
+
+#endif // ndef SHARE_VM_UTILITIES_ERRORREPORTER_HPP
--- a/src/share/vm/utilities/ostream.cpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/utilities/ostream.cpp	Fri Feb 11 05:40:41 2011 -0800
@@ -314,6 +314,11 @@
   _need_close = true;
 }
 
+fileStream::fileStream(const char* file_name, const char* opentype) {
+  _file = fopen(file_name, opentype);
+  _need_close = true;
+}
+
 void fileStream::write(const char* s, size_t len) {
   if (_file != NULL)  {
     // Make an unused local variable to avoid warning from gcc 4.x compiler.
@@ -322,6 +327,25 @@
   update_position(s, len);
 }
 
+long fileStream::fileSize() {
+  long size = -1;
+  if (_file != NULL) {
+    long pos  = ::ftell(_file);
+    if (::fseek(_file, 0, SEEK_END) == 0) {
+      size = ::ftell(_file);
+    }
+    ::fseek(_file, pos, SEEK_SET);
+  }
+  return size;
+}
+
+char* fileStream::readln(char *data, int count ) {
+  char * ret = ::fgets(data, count, _file);
+  //Get rid of annoying \n char
+  data[::strlen(data)-1] = '\0';
+  return ret;
+}
+
 fileStream::~fileStream() {
   if (_file != NULL) {
     if (_need_close) fclose(_file);
--- a/src/share/vm/utilities/ostream.hpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/utilities/ostream.hpp	Fri Feb 11 05:40:41 2011 -0800
@@ -159,10 +159,17 @@
   bool  _need_close;
  public:
   fileStream(const char* file_name);
+  fileStream(const char* file_name, const char* opentype);
   fileStream(FILE* file) { _file = file; _need_close = false; }
   ~fileStream();
   bool is_open() const { return _file != NULL; }
+  void set_need_close(bool b) { _need_close = b;}
   virtual void write(const char* c, size_t len);
+  size_t read(void *data, size_t size, size_t count) { return ::fread(data, size, count, _file); }
+  char* readln(char *data, int count);
+  int eof() { return feof(_file); }
+  long fileSize();
+  void rewind() { ::rewind(_file); }
   void flush();
 };
 
--- a/src/share/vm/utilities/vmError.cpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/utilities/vmError.cpp	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * 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,6 +35,7 @@
 #include "utilities/debug.hpp"
 #include "utilities/decoder.hpp"
 #include "utilities/defaultStream.hpp"
+#include "utilities/errorReporter.hpp"
 #include "utilities/top.hpp"
 #include "utilities/vmError.hpp"
 
@@ -200,6 +201,15 @@
   out->print_raw_cr("#");
 }
 
+bool VMError::coredump_status;
+char VMError::coredump_message[O_BUFLEN];
+
+void VMError::report_coredump_status(const char* message, bool status) {
+  coredump_status = status;
+  strncpy(coredump_message, message, sizeof(coredump_message));
+  coredump_message[sizeof(coredump_message)-1] = 0;
+}
+
 
 // Return a string to describe the error
 char* VMError::error_string(char* buf, int buflen) {
@@ -453,6 +463,15 @@
        st->cr();
        st->print_cr("#");
      }
+  STEP(63, "(printing core file information)")
+    st->print("# ");
+    if (coredump_status) {
+      st->print("Core dump written. Default location: %s", coredump_message);
+    } else {
+      st->print("Failed to write core dump. %s", coredump_message);
+    }
+    st->print_cr("");
+    st->print_cr("#");
 
   STEP(65, "(printing bug submit message)")
 
@@ -769,6 +788,7 @@
   // then save detailed information in log file (verbose = true).
   static bool out_done = false;         // done printing to standard out
   static bool log_done = false;         // done saving error log
+  static bool transmit_report_done = false; // done error reporting
   static fdStream log;                  // error log
 
   if (SuppressFatalErrorMessage) {
@@ -790,6 +810,9 @@
       ShowMessageBoxOnError = false;
     }
 
+    // Write a minidump on Windows, check core dump limits on Linux/Solaris
+    os::check_or_create_dump(_siginfo, _context, buffer, sizeof(buffer));
+
     // reset signal handlers or exception filter; make sure recursive crashes
     // are handled properly.
     reset_signal_handlers();
@@ -859,7 +882,7 @@
         bool copy_ok =
           Arguments::copy_expand_pid(ErrorFile, strlen(ErrorFile), buffer, sizeof(buffer));
         if (copy_ok) {
-          fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+          fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
         }
       }
 
@@ -870,7 +893,7 @@
         // so use the default name in the current directory
         jio_snprintf(&buffer[len], sizeof(buffer)-len, "%shs_err_pid%u.log",
                      os::file_separator(), os::current_process_id());
-        fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+        fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
       }
 
       if (fd == -1) {
@@ -879,7 +902,7 @@
         if (tmpdir != NULL && tmpdir[0] != '\0') {
           jio_snprintf(buffer, sizeof(buffer), "%s%shs_err_pid%u.log",
                        tmpdir, os::file_separator(), os::current_process_id());
-          fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+          fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
         }
       }
 
@@ -892,6 +915,9 @@
       } else {
         out.print_raw_cr("# Can not save log file, dump to screen..");
         log.set_fd(defaultStream::output_fd());
+        /* Error reporting currently needs dumpfile.
+         * Maybe implement direct streaming in the future.*/
+        transmit_report_done = true;
       }
     }
 
@@ -900,6 +926,16 @@
     first_error->_current_step = 0;         // reset current_step
     first_error->_current_step_info = "";   // reset current_step string
 
+    // Run error reporting to determine whether or not to report the crash.
+    if (!transmit_report_done && should_report_bug(first_error->_id)) {
+      transmit_report_done = true;
+      FILE* hs_err = ::fdopen(log.fd(), "r");
+      if (NULL != hs_err) {
+        ErrorReporter er;
+        er.call(hs_err, buffer, O_BUFLEN);
+      }
+    }
+
     if (log.fd() != defaultStream::output_fd()) {
       close(log.fd());
     }
--- a/src/share/vm/utilities/vmError.hpp	Mon Feb 07 08:40:30 2011 -0800
+++ b/src/share/vm/utilities/vmError.hpp	Fri Feb 11 05:40:41 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,6 +67,14 @@
   static VMError* volatile first_error;
   static volatile jlong    first_error_tid;
 
+  // Core dump status, false if we have been unable to write a core/minidump for some reason
+  static bool coredump_status;
+
+  // When coredump_status is set to true this will contain the name/path to the core/minidump,
+  // if coredump_status if false, this will (hopefully) contain a useful error explaining why
+  // no core/minidump has been written to disk
+  static char coredump_message[O_BUFLEN];
+
   // used by reporting about OOM
   size_t       _size;
 
@@ -106,6 +114,9 @@
   // return a string to describe the error
   char *error_string(char* buf, int buflen);
 
+  // Report status of core/minidump
+  static void report_coredump_status(const char* message, bool status);
+
   // main error reporting function
   void report_and_die();