changeset 7877:7bce4e135976

Merge
author kvn
date Thu, 11 Dec 2014 15:06:12 -0800
parents cc8363b030d5 65a9747147b8
children 73d7851fa9f2
files agent/src/share/classes/sun/jvm/hotspot/memory/OneContigSpaceCardGeneration.java make/linux/makefiles/gcc.make make/solaris/makefiles/add_gnu_debuglink.make make/solaris/makefiles/fix_empty_sec_hdr_flags.make src/os/linux/vm/os_linux.cpp src/os/solaris/add_gnu_debuglink/add_gnu_debuglink.c src/os/solaris/fix_empty_sec_hdr_flags/fix_empty_sec_hdr_flags.c src/share/vm/memory/generation.inline.hpp src/share/vm/memory/metaspace.cpp src/share/vm/opto/c2_globals.hpp src/share/vm/opto/graphKit.cpp src/share/vm/opto/memnode.hpp src/share/vm/prims/methodHandles.hpp src/share/vm/runtime/arguments.cpp src/share/vm/runtime/atomic.inline.hpp src/share/vm/runtime/globals.hpp src/share/vm/runtime/os.hpp src/share/vm/runtime/stubRoutines.hpp src/share/vm/runtime/thread.hpp src/share/vm/runtime/vmStructs.cpp test/compiler/5057225/Test5057225.java test/compiler/5091921/Test5091921.java test/compiler/5091921/Test6186134.java test/compiler/5091921/Test6196102.java test/compiler/5091921/Test6357214.java test/compiler/5091921/Test6559156.java test/compiler/5091921/Test6753639.java test/compiler/5091921/Test6850611.java test/compiler/5091921/Test6890943.java test/compiler/5091921/Test6897150.java test/compiler/5091921/Test6905845.java test/compiler/5091921/Test6931567.java test/compiler/5091921/Test6935022.java test/compiler/5091921/Test6959129.java test/compiler/5091921/Test6985295.java test/compiler/5091921/Test6992759.java test/compiler/5091921/Test7005594.java test/compiler/5091921/Test7005594.sh test/compiler/5091921/Test7020614.java test/compiler/5091921/input6890943.txt test/compiler/5091921/output6890943.txt test/compiler/6340864/TestByteVect.java test/compiler/6340864/TestDoubleVect.java test/compiler/6340864/TestFloatVect.java test/compiler/6340864/TestIntVect.java test/compiler/6340864/TestLongVect.java test/compiler/6340864/TestShortVect.java test/compiler/6378821/Test6378821.java test/compiler/6431242/Test.java test/compiler/6443505/Test6443505.java test/compiler/6478991/NullCheckTest.java test/compiler/6539464/Test.java test/compiler/6579789/Test6579789.java test/compiler/6589834/InlinedArrayCloneTestCase.java test/compiler/6589834/Test_ia32.java test/compiler/6603011/Test.java test/compiler/6636138/Test1.java test/compiler/6636138/Test2.java test/compiler/6646019/Test.java test/compiler/6646020/Tester.java test/compiler/6659207/Test.java test/compiler/6661247/Test.java test/compiler/6663621/IVTest.java test/compiler/6663848/Tester.java test/compiler/6663854/Test6663854.java test/compiler/6689060/Test.java test/compiler/6695810/Test.java test/compiler/6700047/Test6700047.java test/compiler/6711100/Test.java test/compiler/6711117/Test.java test/compiler/6712835/Test6712835.java test/compiler/6714694/Tester.java test/compiler/6716441/Tester.java test/compiler/6724218/Test.java test/compiler/6726999/Test.java test/compiler/6732154/Test6732154.java test/compiler/6741738/Tester.java test/compiler/6756768/Test6756768.java test/compiler/6756768/Test6756768_2.java test/compiler/6757316/Test6757316.java test/compiler/6758234/Test6758234.java test/compiler/6769124/TestArrayCopy6769124.java test/compiler/6769124/TestDeoptInt6769124.java test/compiler/6769124/TestUnalignedLoad6769124.java test/compiler/6772683/InterruptedTest.java test/compiler/6775880/Test.java test/compiler/6778657/Test.java test/compiler/6792161/Test6792161.java test/compiler/6795161/Test.java test/compiler/6795362/Test6795362.java test/compiler/6795465/Test6795465.java test/compiler/6796786/Test6796786.java test/compiler/6797305/Test6797305.java test/compiler/6799693/Test.java test/compiler/6800154/Test6800154.java test/compiler/6805724/Test6805724.java test/compiler/6814842/Test6814842.java test/compiler/6823354/Test6823354.java test/compiler/6823453/Test.java test/compiler/6826736/Test.java test/compiler/6832293/Test.java test/compiler/6833129/Test.java test/compiler/6837011/Test6837011.java test/compiler/6837094/Test.java test/compiler/6843752/Test.java test/compiler/6849574/Test.java test/compiler/6851282/Test.java test/compiler/6852078/Test6852078.java test/compiler/6855164/Test.java test/compiler/6855215/Test6855215.java test/compiler/6857159/Test6857159.java test/compiler/6857159/Test6857159.sh test/compiler/6859338/Test6859338.java test/compiler/6860469/Test.java test/compiler/6863155/Test6863155.java test/compiler/6863420/Test.java test/compiler/6865031/Test.java test/compiler/6865265/StackOverflowBug.java test/compiler/6866651/Test.java test/compiler/6875866/Test.java test/compiler/6877254/Test.java test/compiler/6879902/Test6879902.java test/compiler/6880034/Test6880034.java test/compiler/6885584/Test6885584.java test/compiler/6891750/Test6891750.java test/compiler/6892265/Test.java test/compiler/6894807/IsInstanceTest.java test/compiler/6894807/Test6894807.sh test/compiler/6895383/Test.java test/compiler/6896617/Test6896617.java test/compiler/6896727/Test.java test/compiler/6901572/Test.java test/compiler/6909839/Test6909839.java test/compiler/6910484/Test.java test/compiler/6910605/Test.java test/compiler/6910618/Test.java test/compiler/6912517/Test.java test/compiler/6916644/Test6916644.java test/compiler/6921969/TestMultiplyLongHiZero.java test/compiler/6930043/Test6930043.java test/compiler/6932496/Test6932496.java test/compiler/6934604/TestByteBoxing.java test/compiler/6934604/TestDoubleBoxing.java test/compiler/6934604/TestFloatBoxing.java test/compiler/6934604/TestIntBoxing.java test/compiler/6934604/TestLongBoxing.java test/compiler/6934604/TestShortBoxing.java test/compiler/6935535/Test.java test/compiler/6942326/Test.java test/compiler/6946040/TestCharShortByteSwap.java test/compiler/6956668/Test6956668.java test/compiler/6958485/Test.java test/compiler/6968348/Test6968348.java test/compiler/6973329/Test.java test/compiler/6982370/Test6982370.java test/compiler/6990212/Test6990212.java test/compiler/7002666/Test7002666.java test/compiler/7009231/Test7009231.java test/compiler/7009359/Test7009359.java test/compiler/7017746/Test.java test/compiler/7024475/Test7024475.java test/compiler/7029152/Test.java test/compiler/7041100/Test7041100.java test/compiler/7042153/Test7042153.java test/compiler/7044738/Test7044738.java test/compiler/7046096/Test7046096.java test/compiler/7047069/Test7047069.java test/compiler/7048332/Test7048332.java test/compiler/7052494/Test7052494.java test/compiler/7068051/Test7068051.java test/compiler/7070134/Stemmer.java test/compiler/7070134/Test7070134.sh test/compiler/7070134/words test/compiler/7082949/Test7082949.java test/compiler/7088020/Test7088020.java test/compiler/7088419/CRCTest.java test/compiler/7090976/Test7090976.java test/compiler/7100757/Test7100757.java test/compiler/7103261/Test7103261.java test/compiler/7110586/Test7110586.java test/compiler/7116216/LargeFrame.java test/compiler/7116216/StackOverflow.java test/compiler/7119644/TestBooleanVect.java test/compiler/7119644/TestByteDoubleVect.java test/compiler/7119644/TestByteFloatVect.java test/compiler/7119644/TestByteIntVect.java test/compiler/7119644/TestByteLongVect.java test/compiler/7119644/TestByteShortVect.java test/compiler/7119644/TestByteVect.java test/compiler/7119644/TestCharShortVect.java test/compiler/7119644/TestCharVect.java test/compiler/7119644/TestDoubleVect.java test/compiler/7119644/TestFloatDoubleVect.java test/compiler/7119644/TestFloatVect.java test/compiler/7119644/TestIntDoubleVect.java test/compiler/7119644/TestIntFloatVect.java test/compiler/7119644/TestIntLongVect.java test/compiler/7119644/TestIntVect.java test/compiler/7119644/TestLongDoubleVect.java test/compiler/7119644/TestLongFloatVect.java test/compiler/7119644/TestLongVect.java test/compiler/7119644/TestShortDoubleVect.java test/compiler/7119644/TestShortFloatVect.java test/compiler/7119644/TestShortIntVect.java test/compiler/7119644/TestShortLongVect.java test/compiler/7119644/TestShortVect.java test/compiler/7123108/Test7123108.java test/compiler/7125879/Test7125879.java test/compiler/7141637/SpreadNullArg.java test/compiler/7160610/Test7160610.java test/compiler/7169782/Test7169782.java test/compiler/7174363/Test7174363.java test/compiler/7177917/Test7177917.java test/compiler/7179138/Test7179138_1.java test/compiler/7179138/Test7179138_2.java test/compiler/7184394/TestAESBase.java test/compiler/7184394/TestAESDecode.java test/compiler/7184394/TestAESEncode.java test/compiler/7184394/TestAESMain.java test/compiler/7190310/Test7190310.java test/compiler/7190310/Test7190310_unsafe.java test/compiler/7192963/TestByteVect.java test/compiler/7192963/TestDoubleVect.java test/compiler/7192963/TestFloatVect.java test/compiler/7192963/TestIntVect.java test/compiler/7192963/TestLongVect.java test/compiler/7192963/TestShortVect.java test/compiler/7196199/Test7196199.java test/compiler/7199742/Test7199742.java test/compiler/7200264/Test7200264.sh test/compiler/7200264/TestIntVect.java test/compiler/8000805/Test8000805.java test/compiler/8001183/TestCharVect.java test/compiler/8002069/Test8002069.java test/compiler/8004051/Test8004051.java test/compiler/8004741/Test8004741.java test/compiler/8004867/TestIntAtomicCAS.java test/compiler/8004867/TestIntAtomicOrdered.java test/compiler/8004867/TestIntAtomicVolatile.java test/compiler/8004867/TestIntUnsafeCAS.java test/compiler/8004867/TestIntUnsafeOrdered.java test/compiler/8004867/TestIntUnsafeVolatile.java test/compiler/8005033/Test8005033.java test/compiler/8005419/Test8005419.java test/compiler/8005956/PolynomialRoot.java test/compiler/8007294/Test8007294.java test/compiler/8007722/Test8007722.java test/compiler/8009761/Test8009761.java test/compiler/8010927/Test8010927.java test/compiler/8011706/Test8011706.java test/compiler/8011771/Test8011771.java test/compiler/8011901/Test8011901.java test/compiler/8015436/Test8015436.java test/compiler/EliminateAutoBox/UnsignedLoads.java test/compiler/EscapeAnalysis/Test8020215.java test/compiler/EscapeAnalysis/TestAllocatedEscapesPtrComparison.java test/compiler/EscapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java test/compiler/IntegerArithmetic/TestIntegerComparison.java test/gc/concurrentMarkSweep/CheckAllocateAndSystemGC.java test/gc/concurrentMarkSweep/SystemGCOnForegroundCollector.java test/gc/startup_warnings/TestCMSForegroundFlags.java
diffstat 847 files changed, 169794 insertions(+), 167776 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Dec 11 13:11:53 2014 -0800
+++ b/.hgtags	Thu Dec 11 15:06:12 2014 -0800
@@ -443,3 +443,5 @@
 c363a8b87e477ee45d6d3cb2a36cb365141bc596 jdk9-b38
 9cb75e5e394827ccbaf2e15524108a412dc4ddc5 jdk9-b39
 6b09b3193d731e3288e2a240c504a20d0a06c766 jdk9-b40
+1d29b13e8a515a7ea3b882f140576d5d675bc11f jdk9-b41
+38cb4fbd47e3472bd1b5ebac83bda96fe4869c4f jdk9-b42
--- a/agent/src/share/classes/sun/jvm/hotspot/memory/Generation.java	Thu Dec 11 13:11:53 2014 -0800
+++ b/agent/src/share/classes/sun/jvm/hotspot/memory/Generation.java	Thu Dec 11 15:06:12 2014 -0800
@@ -37,10 +37,7 @@
       <ul>
       <li> CardGeneration
         <ul>
-        <li> OneContigSpaceCardGeneration
-          <ul>
-          <li> TenuredGeneration
-          </ul>
+        <li> TenuredGeneration
         </ul>
       <li> DefNewGeneration
       </ul>
--- a/agent/src/share/classes/sun/jvm/hotspot/memory/OneContigSpaceCardGeneration.java	Thu Dec 11 13:11:53 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.memory;
-
-import java.io.*;
-import java.util.*;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.types.*;
-
-/** <P> OneSpaceOldGeneration models a heap of old objects contained
-    in a single contiguous space. </P>
-
-    <P> Garbage collection is performed using mark-compact. </P> */
-
-public abstract class OneContigSpaceCardGeneration extends CardGeneration {
-  private static AddressField theSpaceField;
-
-  static {
-    VM.registerVMInitializedObserver(new Observer() {
-        public void update(Observable o, Object data) {
-          initialize(VM.getVM().getTypeDataBase());
-        }
-      });
-  }
-
-  private static synchronized void initialize(TypeDataBase db) {
-    Type type = db.lookupType("OneContigSpaceCardGeneration");
-
-    theSpaceField = type.getAddressField("_the_space");
-  }
-
-  public OneContigSpaceCardGeneration(Address addr) {
-    super(addr);
-  }
-
-  public ContiguousSpace theSpace() {
-    return (ContiguousSpace) VMObjectFactory.newObject(ContiguousSpace.class, theSpaceField.getValue(addr));
-  }
-
-  public boolean isIn(Address p) {
-    return theSpace().contains(p);
-  }
-
-  /** Space queries */
-  public long capacity()            { return theSpace().capacity();                                }
-  public long used()                { return theSpace().used();                                    }
-  public long free()                { return theSpace().free();                                    }
-  public long contiguousAvailable() { return theSpace().free() + virtualSpace().uncommittedSize(); }
-
-  public void spaceIterate(SpaceClosure blk, boolean usedOnly) {
-    blk.doSpace(theSpace());
-  }
-
-  public void printOn(PrintStream tty) {
-    tty.print("  old ");
-    theSpace().printOn(tty);
-  }
-}
--- a/agent/src/share/classes/sun/jvm/hotspot/memory/TenuredGeneration.java	Thu Dec 11 13:11:53 2014 -0800
+++ b/agent/src/share/classes/sun/jvm/hotspot/memory/TenuredGeneration.java	Thu Dec 11 15:06:12 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,62 @@
 
 package sun.jvm.hotspot.memory;
 
+import java.io.*;
+import java.util.*;
+
 import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
 
-public class TenuredGeneration extends OneContigSpaceCardGeneration {
+/** <P> TenuredGeneration models a heap of old objects contained
+    in a single contiguous space. </P>
+
+    <P> Garbage collection is performed using mark-compact. </P> */
+
+public class TenuredGeneration extends CardGeneration {
+  private static AddressField theSpaceField;
+
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) {
+    Type type = db.lookupType("TenuredGeneration");
+
+    theSpaceField = type.getAddressField("_the_space");
+  }
+
   public TenuredGeneration(Address addr) {
     super(addr);
   }
 
+  public ContiguousSpace theSpace() {
+    return (ContiguousSpace) VMObjectFactory.newObject(ContiguousSpace.class, theSpaceField.getValue(addr));
+  }
+
+  public boolean isIn(Address p) {
+    return theSpace().contains(p);
+  }
+
+  /** Space queries */
+  public long capacity()            { return theSpace().capacity();                                }
+  public long used()                { return theSpace().used();                                    }
+  public long free()                { return theSpace().free();                                    }
+  public long contiguousAvailable() { return theSpace().free() + virtualSpace().uncommittedSize(); }
+
+  public void spaceIterate(SpaceClosure blk, boolean usedOnly) {
+    blk.doSpace(theSpace());
+  }
+
+  public void printOn(PrintStream tty) {
+    tty.print("  old ");
+    theSpace().printOn(tty);
+  }
+
   public Generation.Name kind() {
     return Generation.Name.MARK_SWEEP_COMPACT;
   }
--- a/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Thu Dec 11 13:11:53 2014 -0800
+++ b/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Thu Dec 11 15:06:12 2014 -0800
@@ -219,7 +219,7 @@
     if (threadNameField == null) {
       SystemDictionary sysDict = VM.getVM().getSystemDictionary();
       InstanceKlass k = sysDict.getThreadKlass();
-      threadNameField  = (OopField) k.findField("name", "[C");
+      threadNameField  = (OopField) k.findField("name", "Ljava/lang/String;");
       threadGroupField = (OopField) k.findField("group", "Ljava/lang/ThreadGroup;");
       threadEETopField = (LongField) k.findField("eetop", "J");
       threadTIDField = (LongField) k.findField("tid", "J");
@@ -258,7 +258,7 @@
 
   public static String threadOopGetName(Oop threadOop) {
     initThreadFields();
-    return charArrayToString((TypeArray) threadNameField.getValue(threadOop));
+    return stringOopToString(threadNameField.getValue(threadOop));
   }
 
   /** May return null if, e.g., thread was not started */
--- a/make/bsd/makefiles/sa.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/bsd/makefiles/sa.make	Thu Dec 11 15:06:12 2014 -0800
@@ -40,6 +40,8 @@
 
 include $(GAMMADIR)/make/sa.files
 
+-include $(HS_ALT_MAKE)/bsd/makefiles/sa.make
+
 TOPDIR    = $(shell echo `pwd`)
 GENERATED = $(TOPDIR)/../generated
 
@@ -63,6 +65,10 @@
   SA_CLASSPATH=$(shell test -f $(ALT_SA_CLASSPATH) && echo $(ALT_SA_CLASSPATH))
 endif
 
+ifneq ($(SA_CLASSPATH),)
+  SA_CLASSPATH_ARG := -classpath $(SA_CLASSPATH)
+endif
+
 # TODO: if it's a modules image, check if SA module is installed.
 MODULELIB_PATH= $(BOOT_JAVA_HOME)/lib/modules
 
@@ -114,7 +120,7 @@
 # are in AGENT_FILES, so use the shell to expand them.
 # Be extra carefull to not produce too long command lines in the shell!
 	$(foreach file,$(AGENT_FILES),$(shell ls -1 $(file) >> $(AGENT_FILES_LIST)))
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) @$(AGENT_FILES_LIST)
+	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) $(SA_CLASSPATH_ARG) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) @$(AGENT_FILES_LIST)
 	$(QUIETLY) $(REMOTE) $(COMPILE.RMIC)  -classpath $(SA_CLASSDIR) -d $(SA_CLASSDIR) sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer
 	$(QUIETLY) echo "$(SA_BUILD_VERSION_PROP)" > $(SA_PROPERTIES)
 	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql/sa.js
--- a/make/linux/makefiles/gcc.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/linux/makefiles/gcc.make	Thu Dec 11 15:06:12 2014 -0800
@@ -215,7 +215,7 @@
   WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
 endif
 
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type
 
 ifeq ($(USE_CLANG),)
   # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
--- a/make/solaris/makefiles/add_gnu_debuglink.make	Thu Dec 11 13:11:53 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#  
-#
-
-# Rules to build add_gnu_debuglink, used by vm.make on Solaris
-
-# Allow $(ADD_GNU_DEBUGLINK) to be called from any directory.
-# We don't set or use the GENERATED macro to avoid affecting
-# other HotSpot Makefiles.
-TOPDIR                    = $(shell echo `pwd`)
-ADD_GNU_DEBUGLINK         = $(TOPDIR)/../generated/add_gnu_debuglink
-
-ADD_GNU_DEBUGLINK_DIR     = $(GAMMADIR)/src/os/solaris/add_gnu_debuglink
-ADD_GNU_DEBUGLINK_SRC     = $(ADD_GNU_DEBUGLINK_DIR)/add_gnu_debuglink.c
-ADD_GNU_DEBUGLINK_FLAGS   = 
-LIBS_ADD_GNU_DEBUGLINK   += -lelf
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-# Enable the following ADD_GNU_DEBUGLINK_FLAGS addition if you need to
-# compare the built ELF objects.
-#
-# The -g option makes static data global and the "-W0,-noglobal"
-# option tells the compiler to not globalize static data using a unique
-# globalization prefix. Instead force the use of a static globalization
-# prefix based on the source filepath so the objects from two identical
-# compilations are the same.
-#
-# Note: The blog says to use "-W0,-xglobalstatic", but that doesn't
-#       seem to work. I got "-W0,-noglobal" from Kelly and that works.
-#ADD_GNU_DEBUGLINK_FLAGS += -W0,-noglobal
-endif # Platform_compiler == sparcWorks
-
-$(ADD_GNU_DEBUGLINK): $(ADD_GNU_DEBUGLINK_SRC)
-	$(CC) -g -o $@ $< $(ADD_GNU_DEBUGLINK_FLAGS) $(LIBS_ADD_GNU_DEBUGLINK)
--- a/make/solaris/makefiles/defs.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/solaris/makefiles/defs.make	Thu Dec 11 15:06:12 2014 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -138,6 +138,55 @@
         OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
       endif
 
+      ifneq ($(OBJCOPY),)
+        # OBJCOPY version check:
+        # - version number is last blank separate word on first line
+        # - version number formats that have been seen:
+        #   - <major>.<minor>
+        #   - <major>.<minor>.<micro>
+        #
+        # Full Debug Symbols on Solaris needs version 2.21.1 or newer.
+        #
+        OBJCOPY_VERS_CHK := $(shell \
+          $(OBJCOPY) --version \
+            | sed -n \
+                  -e 's/.* //' \
+                  -e '/^[01]\./b bad' \
+                  -e '/^2\./{' \
+                  -e '  s/^2\.//' \
+                  -e '  /^[0-9]$$/b bad' \
+                  -e '  /^[0-9]\./b bad' \
+                  -e '  /^1[0-9]$$/b bad' \
+                  -e '  /^1[0-9]\./b bad' \
+                  -e '  /^20\./b bad' \
+                  -e '  /^21\.0$$/b bad' \
+                  -e '  /^21\.0\./b bad' \
+                  -e '}' \
+                  -e ':good' \
+                  -e 's/.*/VALID_VERSION/p' \
+                  -e 'q' \
+                  -e ':bad' \
+                  -e 's/.*/BAD_VERSION/p' \
+                  -e 'q' \
+          )
+        ifeq ($(OBJCOPY_VERS_CHK),BAD_VERSION)
+          _JUNK_ := $(shell \
+            echo >&2 "WARNING: $(OBJCOPY) --version info:"; \
+            $(OBJCOPY) --version | sed -n -e 's/^/WARNING: /p' -e 'q' >&2; \
+            echo >&2 "WARNING: an objcopy version of 2.21.1 or newer" \
+              "is needed to create valid .debuginfo files."; \
+            echo >&2 "WARNING: ignoring above objcopy command."; \
+            echo >&2 "WARNING: patch 149063-01 or newer contains the" \
+              "correct Solaris 10 SPARC version."; \
+            echo >&2 "WARNING: patch 149064-01 or newer contains the" \
+              "correct Solaris 10 X86 version."; \
+            echo >&2 "WARNING: Solaris 11 Update 1 contains the" \
+              "correct version."; \
+            )
+          OBJCOPY=
+        endif
+      endif
+
       ifeq ($(OBJCOPY),)
         $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files."))
         ENABLE_FULL_DEBUG_SYMBOLS=0
--- a/make/solaris/makefiles/dtrace.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/solaris/makefiles/dtrace.make	Thu Dec 11 15:06:12 2014 -0800
@@ -101,25 +101,16 @@
 XLIBJVM_DTRACE_DEBUGINFO   = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DEBUGINFO)
 XLIBJVM_DTRACE_DIZ         = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DIZ)
 
-$(XLIBJVM_DB): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
+$(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
 	@echo $(LOG_INFO) Making $@
 	$(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \
 	$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. -I$(GENERATED) \
 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
-# Clear the SHF_ALLOC flag (if set) from empty section headers.
-# An empty section header has sh_addr == 0 and sh_size == 0.
-# This problem has only been seen on Solaris X64, but we call this tool
-# on all Solaris builds just in case.
-	$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
 	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DB_DEBUGINFO)
-# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
-#         $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) ;
 # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not
 # in the link name:
-	( cd $(XLIBJVM_DIR) && $(ADD_GNU_DEBUGLINK) $(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) )
+	( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) )
   ifeq ($(STRIP_POLICY),all_strip)
 	$(QUIETLY) $(STRIP) $@
   else
@@ -136,20 +127,16 @@
   endif
 endif
 
-$(XLIBJVM_DTRACE): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
+$(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
 	@echo $(LOG_INFO) Making $@
 	$(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \
 	$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. \
 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-# Clear the SHF_ALLOC flag (if set) from empty section headers.
-	$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
 	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DTRACE_DEBUGINFO)
-# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-#         $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) ;
 # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not
 # in the link name:
-	( cd $(XLIBJVM_DIR) && $(ADD_GNU_DEBUGLINK) $(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) )
+	( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) )
   ifeq ($(STRIP_POLICY),all_strip)
 	$(QUIETLY) $(STRIP) $@
   else
@@ -206,17 +193,13 @@
 $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
 	$(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
 
-$(LIBJVM_DB): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
+$(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
 	@echo $(LOG_INFO) Making $@
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-# Clear the SHF_ALLOC flag (if set) from empty section headers.
-	$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
 	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DB_DEBUGINFO)
-# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-#	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@
-	$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJVM_DB_DEBUGINFO) $@
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@
   ifeq ($(STRIP_POLICY),all_strip)
 	$(QUIETLY) $(STRIP) $@
   else
@@ -231,17 +214,13 @@
   endif
 endif
 
-$(LIBJVM_DTRACE): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
+$(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
 	@echo $(LOG_INFO) Making $@
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I.  \
 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-# Clear the SHF_ALLOC flag (if set) from empty section headers.
-	$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
 	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DTRACE_DEBUGINFO)
-# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-#	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@
-	$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJVM_DTRACE_DEBUGINFO) $@
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@
   ifeq ($(STRIP_POLICY),all_strip)
 	$(QUIETLY) $(STRIP) $@
   else
--- a/make/solaris/makefiles/fix_empty_sec_hdr_flags.make	Thu Dec 11 13:11:53 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#  
-#
-
-# Rules to build fix_empty_sec_hdr_flags, used by vm.make on Solaris
-
-# Allow $(FIX_EMPTY_SEC_HDR_FLAGS) to be called from any directory.
-# We don't set or use the GENERATED macro to avoid affecting
-# other HotSpot Makefiles.
-TOPDIR                          = $(shell echo `pwd`)
-FIX_EMPTY_SEC_HDR_FLAGS         = $(TOPDIR)/../generated/fix_empty_sec_hdr_flags
-
-FIX_EMPTY_SEC_HDR_FLAGS_DIR     = $(GAMMADIR)/src/os/solaris/fix_empty_sec_hdr_flags
-FIX_EMPTY_SEC_HDR_FLAGS_SRC     = $(FIX_EMPTY_SEC_HDR_FLAGS_DIR)/fix_empty_sec_hdr_flags.c
-FIX_EMPTY_SEC_HDR_FLAGS_FLAGS   = 
-LIBS_FIX_EMPTY_SEC_HDR_FLAGS   += -lelf
-
-ifeq ("${Platform_compiler}", "sparcWorks")
-# Enable the following FIX_EMPTY_SEC_HDR_FLAGS_FLAGS addition if you need to
-# compare the built ELF objects.
-#
-# The -g option makes static data global and the "-W0,-noglobal"
-# option tells the compiler to not globalize static data using a unique
-# globalization prefix. Instead force the use of a static globalization
-# prefix based on the source filepath so the objects from two identical
-# compilations are the same.
-#
-# Note: The blog says to use "-W0,-xglobalstatic", but that doesn't
-#       seem to work. I got "-W0,-noglobal" from Kelly and that works.
-#FIX_EMPTY_SEC_HDR_FLAGS_FLAGS += -W0,-noglobal
-endif # Platform_compiler == sparcWorks
-
-$(FIX_EMPTY_SEC_HDR_FLAGS): $(FIX_EMPTY_SEC_HDR_FLAGS_SRC)
-	$(CC) -g -o $@ $< $(FIX_EMPTY_SEC_HDR_FLAGS_FLAGS) $(LIBS_FIX_EMPTY_SEC_HDR_FLAGS)
--- a/make/solaris/makefiles/gcc.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/solaris/makefiles/gcc.make	Thu Dec 11 15:06:12 2014 -0800
@@ -226,18 +226,8 @@
 # Allow no optimizations.
 DEBUG_CFLAGS=-O0
 
-# Use the stabs format for debugging information (this is the default
-# on gcc-2.91). It's good enough, has all the information about line
-# numbers and local variables, and libjvm.so is only about 16M.
-# Change this back to "-g" if you want the most expressive format.
-# (warning: that could easily inflate libjvm.so to 150M!)
-# Note: The Itanium gcc compiler crashes when using -gstabs.
-DEBUG_CFLAGS/ia64  = -g
-DEBUG_CFLAGS/amd64 = -g
-DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
-ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
-  DEBUG_CFLAGS += -gstabs
-endif
+# Enable debug symbols
+DEBUG_CFLAGS += -g
 
 # Enable bounds checking.
 ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1"
--- a/make/solaris/makefiles/jsig.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/solaris/makefiles/jsig.make	Thu Dec 11 15:06:12 2014 -0800
@@ -47,22 +47,13 @@
 LFLAGS_JSIG += -mt -xnolib
 endif
 
-$(LIBJSIG): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
+$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
 	@echo $(LOG_INFO) Making signal interposition lib...
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
                          $(LFLAGS_JSIG) -o $@ $(JSIGSRCDIR)/jsig.c -ldl
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
-# Clear the SHF_ALLOC flag (if set) from empty section headers.
-# An empty section header has sh_addr == 0 and sh_size == 0.
-# This problem has only been seen on Solaris X64, but we call this tool
-# on all Solaris builds just in case.
-	$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
 	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
-# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
-#	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
-	$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJSIG_DEBUGINFO) $@
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
   ifeq ($(STRIP_POLICY),all_strip)
 	$(QUIETLY) $(STRIP) $@
   else
--- a/make/solaris/makefiles/saproc.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/solaris/makefiles/saproc.make	Thu Dec 11 15:06:12 2014 -0800
@@ -90,7 +90,7 @@
 #SOLARIS_11_B159_OR_LATER=-DSOLARIS_11_B159_OR_LATER
 
 
-$(LIBSAPROC): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(SASRCFILES) $(SADISOBJ) $(SAMAPFILE)
+$(LIBSAPROC): $(SASRCFILES) $(SADISOBJ) $(SAMAPFILE)
 	$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
 	  echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
 	  exit 1; \
@@ -121,17 +121,8 @@
 	           -c -o $(SADISOBJ)
 
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
-# Clear the SHF_ALLOC flag (if set) from empty section headers.
-# An empty section header has sh_addr == 0 and sh_size == 0.
-# This problem has only been seen on Solaris X64, but we call this tool
-# on all Solaris builds just in case.
-	$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
 	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBSAPROC_DEBUGINFO)
-# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
-#	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@
-	$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBSAPROC_DEBUGINFO) $@
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@
   ifeq ($(STRIP_POLICY),all_strip)
 	$(QUIETLY) $(STRIP) $@
   else
--- a/make/solaris/makefiles/sparcWorks.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/solaris/makefiles/sparcWorks.make	Thu Dec 11 15:06:12 2014 -0800
@@ -496,15 +496,6 @@
   FASTDEBUG_CFLAGS += -xs
 endif
 
-# Special global options for SS12
-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
-  # There appears to be multiple issues with the new Dwarf2 debug format, so
-  #   we tell the compiler to use the older 'stabs' debug format all the time.
-  #   Note that this needs to be used in optimized compiles too to be 100%.
-  #   This is a workaround for SS12 (5.9) bug 6694600
-  CFLAGS += -xdebugformat=stabs
-endif
-
 # Enable the following CFLAGS additions if you need to compare the
 # built ELF objects.
 #
--- a/make/solaris/makefiles/vm.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/solaris/makefiles/vm.make	Thu Dec 11 15:06:12 2014 -0800
@@ -155,14 +155,6 @@
 include $(MAKEFILES_DIR)/dtrace.make
 
 #----------------------------------------------------------------------
-# add_gnu_debuglink tool
-include $(MAKEFILES_DIR)/add_gnu_debuglink.make
-
-#----------------------------------------------------------------------
-# fix_empty_sec_hdr_flags tool
-include $(MAKEFILES_DIR)/fix_empty_sec_hdr_flags.make
-
-#----------------------------------------------------------------------
 # JVM
 
 JVM      = jvm
@@ -302,7 +294,7 @@
 LINK_VM = $(LINK_LIB.CXX)
 endif
 # making the library:
-$(LIBJVM): $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS) $(LIBJVM.o) $(LIBJVM_MAPFILE)
+$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE)
 ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
 	@echo $(LOG_INFO) Linking vm...
 	$(QUIETLY) $(LINK_LIB.CXX/PRE_HOOK)
@@ -310,17 +302,8 @@
 	$(QUIETLY) $(LINK_LIB.CXX/POST_HOOK)
 	$(QUIETLY) rm -f $@.1 && ln -s $@ $@.1
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
-# Clear the SHF_ALLOC flag (if set) from empty section headers.
-# An empty section header has sh_addr == 0 and sh_size == 0.
-# This problem has only been seen on Solaris X64, but we call this tool
-# on all Solaris builds just in case.
-	$(QUIETLY) $(FIX_EMPTY_SEC_HDR_FLAGS) $@
 	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
-# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
-# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
-#	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
-	$(QUIETLY) $(ADD_GNU_DEBUGLINK) $(LIBJVM_DEBUGINFO) $@
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
   ifeq ($(STRIP_POLICY),all_strip)
 	$(QUIETLY) $(STRIP) $@
   else
--- a/make/windows/makefiles/vm.make	Thu Dec 11 13:11:53 2014 -0800
+++ b/make/windows/makefiles/vm.make	Thu Dec 11 15:06:12 2014 -0800
@@ -89,19 +89,24 @@
 
 # If you modify exports below please do the corresponding changes in
 # src/share/tools/ProjectCreator/WinGammaPlatformVC7.java
-LD_FLAGS=$(LD_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 \
-  /export:JNI_GetDefaultJavaVMInitArgs       \
-  /export:JNI_CreateJavaVM                   \
-  /export:JVM_FindClassFromBootLoader        \
-  /export:JNI_GetCreatedJavaVMs              \
-  /export:jio_snprintf                       \
-  /export:jio_printf                         \
-  /export:jio_fprintf                        \
-  /export:jio_vfprintf                       \
-  /export:jio_vsnprintf                      \
-  $(AGCT_EXPORT)                             \
-  /export:JVM_GetVersionInfo                 \
-  /export:JVM_InitAgentProperties
+!if "$(BUILDARCH)" == "amd64"
+EXPORT_LIST=
+!else
+EXPORT_LIST=/export:JNI_GetDefaultJavaVMInitArgs \
+            /export:JNI_CreateJavaVM             \
+            /export:JVM_FindClassFromBootLoader  \
+            /export:JNI_GetCreatedJavaVMs        \
+            /export:jio_snprintf                 \
+            /export:jio_printf                   \
+            /export:jio_fprintf                  \
+            /export:jio_vfprintf                 \
+            /export:jio_vsnprintf                \
+            $(AGCT_EXPORT)                       \
+            /export:JVM_GetVersionInfo           \
+            /export:JVM_InitAgentProperties
+!endif
+
+LD_FLAGS=$(LD_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 $(EXPORT_LIST)
 
 CXX_INCLUDE_DIRS=/I "..\generated"
 
--- a/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -27,6 +27,7 @@
 #define CPU_PPC_VM_MACROASSEMBLER_PPC_HPP
 
 #include "asm/assembler.hpp"
+#include "utilities/macros.hpp"
 
 // MacroAssembler extends Assembler by a few frequently used macros.
 
--- a/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -4813,6 +4813,7 @@
     StubRoutines::_atomic_add_entry          = generate_atomic_add();
     StubRoutines::_atomic_xchg_ptr_entry     = StubRoutines::_atomic_xchg_entry;
     StubRoutines::_atomic_cmpxchg_ptr_entry  = StubRoutines::_atomic_cmpxchg_entry;
+    StubRoutines::_atomic_cmpxchg_byte_entry = ShouldNotCallThisStub();
     StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long();
     StubRoutines::_atomic_add_ptr_entry      = StubRoutines::_atomic_add_entry;
 #endif  // COMPILER2 !=> _LP64
--- a/src/cpu/x86/vm/assembler_x86.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/x86/vm/assembler_x86.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1297,6 +1297,17 @@
   emit_operand(reg, adr);
 }
 
+// The 8-bit cmpxchg compares the value at adr with the contents of rax,
+// and stores reg into adr if so; otherwise, the value at adr is loaded into rax,.
+// The ZF is set if the compared values were equal, and cleared otherwise.
+void Assembler::cmpxchgb(Register reg, Address adr) { // cmpxchg
+  InstructionMark im(this);
+  prefix(adr, reg, true);
+  emit_int8(0x0F);
+  emit_int8((unsigned char)0xB0);
+  emit_operand(reg, adr);
+}
+
 void Assembler::comisd(XMMRegister dst, Address src) {
   // NOTE: dbx seems to decode this as comiss even though the
   // 0x66 is there. Strangly ucomisd comes out correct
--- a/src/cpu/x86/vm/assembler_x86.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/x86/vm/assembler_x86.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1006,6 +1006,7 @@
 
   void cmpxchg8 (Address adr);
 
+  void cmpxchgb(Register reg, Address adr);
   void cmpxchgl(Register reg, Address adr);
 
   void cmpxchgq(Register reg, Address adr);
--- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -594,9 +594,35 @@
     return start;
   }
 
-  // Support for jint atomic::atomic_cmpxchg_long(jlong exchange_value,
-  //                                             volatile jlong* dest,
-  //                                             jlong compare_value)
+  // Support for jbyte atomic::atomic_cmpxchg(jbyte exchange_value, volatile jbyte* dest,
+  //                                          jbyte compare_value)
+  //
+  // Arguments :
+  //    c_rarg0: exchange_value
+  //    c_rarg1: dest
+  //    c_rarg2: compare_value
+  //
+  // Result:
+  //    if ( compare_value == *dest ) {
+  //       *dest = exchange_value
+  //       return compare_value;
+  //    else
+  //       return *dest;
+  address generate_atomic_cmpxchg_byte() {
+    StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg_byte");
+    address start = __ pc();
+
+    __ movsbq(rax, c_rarg2);
+   if ( os::is_MP() ) __ lock();
+    __ cmpxchgb(c_rarg0, Address(c_rarg1, 0));
+    __ ret(0);
+
+    return start;
+  }
+
+  // Support for jlong atomic::atomic_cmpxchg(jlong exchange_value,
+  //                                          volatile jlong* dest,
+  //                                          jlong compare_value)
   // Arguments :
   //    c_rarg0: exchange_value
   //    c_rarg1: dest
@@ -3894,6 +3920,7 @@
     StubRoutines::_atomic_xchg_entry         = generate_atomic_xchg();
     StubRoutines::_atomic_xchg_ptr_entry     = generate_atomic_xchg_ptr();
     StubRoutines::_atomic_cmpxchg_entry      = generate_atomic_cmpxchg();
+    StubRoutines::_atomic_cmpxchg_byte_entry = generate_atomic_cmpxchg_byte();
     StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long();
     StubRoutines::_atomic_add_entry          = generate_atomic_add();
     StubRoutines::_atomic_add_ptr_entry      = generate_atomic_add_ptr();
--- a/src/cpu/x86/vm/vm_version_x86.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/x86/vm/vm_version_x86.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -570,10 +570,12 @@
   static uint cores_per_cpu()  {
     uint result = 1;
     if (is_intel()) {
-      if (supports_processor_topology()) {
+      bool supports_topology = supports_processor_topology();
+      if (supports_topology) {
         result = _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus /
                  _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus;
-      } else {
+      }
+      if (!supports_topology || result == 0) {
         result = (_cpuid_info.dcp_cpuid4_eax.bits.cores_per_cpu + 1);
       }
     } else if (is_amd()) {
--- a/src/cpu/x86/vm/x86_32.ad	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/x86/vm/x86_32.ad	Thu Dec 11 15:06:12 2014 -0800
@@ -1210,6 +1210,7 @@
 
 
   Unimplemented();
+  return 0; // Mute compiler
 }
 
 #ifndef PRODUCT
--- a/src/cpu/zero/vm/stack_zero.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/zero/vm/stack_zero.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -30,7 +30,9 @@
 
 int ZeroStack::suggest_size(Thread *thread) const {
   assert(needs_setup(), "already set up");
-  return align_size_down(abi_stack_available(thread) / 2, wordSize);
+  int abi_available = abi_stack_available(thread);
+  assert(abi_available >= 0, "available abi stack must be >= 0");
+  return align_size_down(abi_available / 2, wordSize);
 }
 
 void ZeroStack::handle_overflow(TRAPS) {
--- a/src/cpu/zero/vm/stack_zero.inline.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/zero/vm/stack_zero.inline.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -48,9 +48,11 @@
 // to use under normal circumstances.  Note that the returned
 // value can be negative.
 inline int ZeroStack::abi_stack_available(Thread *thread) const {
-  int stack_used = thread->stack_base() - (address) &stack_used;
+  guarantee(Thread::current() == thread, "should run in the same thread");
+  int stack_used = thread->stack_base() - (address) &stack_used
+    + (StackYellowPages+StackRedPages+StackShadowPages) * os::vm_page_size();
   int stack_free = thread->stack_size() - stack_used;
-  return stack_free - shadow_pages_size();
+  return stack_free;
 }
 
 #endif // CPU_ZERO_VM_STACK_ZERO_INLINE_HPP
--- a/src/cpu/zero/vm/stubGenerator_zero.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/cpu/zero/vm/stubGenerator_zero.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -207,6 +207,7 @@
     StubRoutines::_atomic_xchg_ptr_entry     = ShouldNotCallThisStub();
     StubRoutines::_atomic_cmpxchg_entry      = ShouldNotCallThisStub();
     StubRoutines::_atomic_cmpxchg_ptr_entry  = ShouldNotCallThisStub();
+    StubRoutines::_atomic_cmpxchg_byte_entry = ShouldNotCallThisStub();
     StubRoutines::_atomic_cmpxchg_long_entry = ShouldNotCallThisStub();
     StubRoutines::_atomic_add_entry          = ShouldNotCallThisStub();
     StubRoutines::_atomic_add_ptr_entry      = ShouldNotCallThisStub();
--- a/src/os/aix/vm/os_aix.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/aix/vm/os_aix.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -107,6 +107,12 @@
 #include <sys/vminfo.h>
 #include <sys/wait.h>
 
+// If RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
+// getrusage() is prepared to handle the associated failure.
+#ifndef RUSAGE_THREAD
+#define RUSAGE_THREAD   (1)               /* only the calling thread */
+#endif
+
 // Add missing declarations (should be in procinfo.h but isn't until AIX 6.1).
 #if !defined(_AIXVERSION_610)
 extern "C" {
@@ -512,15 +518,13 @@
 
 #define DEFAULT_LIBPATH "/usr/lib:/lib"
 #define EXTENSIONS_DIR  "/lib/ext"
-#define ENDORSED_DIR    "/lib/endorsed"
 
   // Buffer that fits several sprintfs.
   // Note that the space for the trailing null is provided
   // by the nulls included by the sizeof operator.
   const size_t bufsize =
-    MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
-         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR), // extensions dir
-         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+    MAX2((size_t)MAXPATHLEN,  // For dll_dir & friends.
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR)); // extensions dir
   char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
 
   // sysclasspath, java_home, dll_dir
@@ -565,21 +569,16 @@
   char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char, strlen(v) + 1 + sizeof(DEFAULT_LIBPATH) + 1, mtInternal);
   sprintf(ld_library_path, "%s%s" DEFAULT_LIBPATH, v, v_colon);
   Arguments::set_library_path(ld_library_path);
-  FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
+  FREE_C_HEAP_ARRAY(char, ld_library_path);
 
   // Extensions directories.
   sprintf(buf, "%s" EXTENSIONS_DIR, Arguments::get_java_home());
   Arguments::set_ext_dirs(buf);
 
-  // Endorsed standards default directory.
-  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
-  Arguments::set_endorsed_dirs(buf);
-
-  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, buf);
 
 #undef DEFAULT_LIBPATH
 #undef EXTENSIONS_DIR
-#undef ENDORSED_DIR
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1072,15 +1071,19 @@
   return (1000 * 1000);
 }
 
-// For now, we say that linux does not support vtime. I have no idea
-// whether it can actually be made to (DLD, 9/13/05).
-
-bool os::supports_vtime() { return false; }
+bool os::supports_vtime() { return true; }
 bool os::enable_vtime()   { return false; }
 bool os::vtime_enabled()  { return false; }
+
 double os::elapsedVTime() {
-  // better than nothing, but not much
-  return elapsedTime();
+  struct rusage usage;
+  int retval = getrusage(RUSAGE_THREAD, &usage);
+  if (retval == 0) {
+    return usage.ru_utime.tv_sec + usage.ru_stime.tv_sec + (usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / (1000.0 * 1000);
+  } else {
+    // better than nothing, but not much
+    return elapsedTime();
+  }
 }
 
 jlong os::javaTimeMillis() {
@@ -1297,11 +1300,11 @@
     // release the storage
     for (int i = 0; i < n; i++) {
       if (pelements[i] != NULL) {
-        FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal);
+        FREE_C_HEAP_ARRAY(char, pelements[i]);
       }
     }
     if (pelements != NULL) {
-      FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
+      FREE_C_HEAP_ARRAY(char*, pelements);
     }
   } else {
     snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
@@ -2778,6 +2781,10 @@
   return ::read(fd, buf, nBytes);
 }
 
+size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
+  return ::pread(fd, buf, nBytes, offset);
+}
+
 void os::naked_short_sleep(jlong ms) {
   struct timespec req;
 
@@ -4137,8 +4144,29 @@
 char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset,
                         char *addr, size_t bytes, bool read_only,
                         bool allow_exec) {
-  Unimplemented();
-  return NULL;
+  int prot;
+  int flags = MAP_PRIVATE;
+
+  if (read_only) {
+    prot = PROT_READ;
+  } else {
+    prot = PROT_READ | PROT_WRITE;
+  }
+
+  if (allow_exec) {
+    prot |= PROT_EXEC;
+  }
+
+  if (addr != NULL) {
+    flags |= MAP_FIXED;
+  }
+
+  char* mapped_address = (char*)mmap(addr, (size_t)bytes, prot, flags,
+                                     fd, file_offset);
+  if (mapped_address == MAP_FAILED) {
+    return NULL;
+  }
+  return mapped_address;
 }
 
 
--- a/src/os/aix/vm/perfMemory_aix.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/aix/vm/perfMemory_aix.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2012, 2013 SAP AG. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -127,7 +127,7 @@
       }
     }
   }
-  FREE_C_HEAP_ARRAY(char, destfile, mtInternal);
+  FREE_C_HEAP_ARRAY(char, destfile);
 }
 
 
@@ -279,14 +279,14 @@
                                      "pw_name zero length");
       }
     }
-    FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
+    FREE_C_HEAP_ARRAY(char, pwbuf);
     return NULL;
   }
 
   char* user_name = NEW_C_HEAP_ARRAY(char, strlen(p->pw_name) + 1, mtInternal);
   strcpy(user_name, p->pw_name);
 
-  FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, pwbuf);
   return user_name;
 }
 
@@ -347,7 +347,7 @@
     DIR* subdirp = os::opendir(usrdir_name);
 
     if (subdirp == NULL) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       continue;
     }
 
@@ -358,7 +358,7 @@
     // symlink can be exploited.
     //
     if (!is_directory_secure(usrdir_name)) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       os::closedir(subdirp);
       continue;
     }
@@ -382,13 +382,13 @@
         // don't follow symbolic links for the file
         RESTARTABLE(::lstat(filename, &statbuf), result);
         if (result == OS_ERR) {
-           FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+           FREE_C_HEAP_ARRAY(char, filename);
            continue;
         }
 
         // skip over files that are not regular files.
         if (!S_ISREG(statbuf.st_mode)) {
-          FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+          FREE_C_HEAP_ARRAY(char, filename);
           continue;
         }
 
@@ -398,7 +398,7 @@
           if (statbuf.st_ctime > oldest_ctime) {
             char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user, mtInternal);
+            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
             oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
             strcpy(oldest_user, user);
@@ -406,15 +406,15 @@
           }
         }
 
-        FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+        FREE_C_HEAP_ARRAY(char, filename);
       }
     }
     os::closedir(subdirp);
-    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
-    FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+    FREE_C_HEAP_ARRAY(char, udbuf);
+    FREE_C_HEAP_ARRAY(char, usrdir_name);
   }
   os::closedir(tmpdirp);
-  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, tdbuf);
 
   return(oldest_user);
 }
@@ -422,7 +422,7 @@
 // return the name of the user that owns the JVM indicated by the given vmid.
 //
 static char* get_user_name(int vmid, TRAPS) {
-  return get_user_name_slow(vmid, CHECK_NULL);
+  return get_user_name_slow(vmid, THREAD);
 }
 
 // return the file name of the backing store file for the named
@@ -481,7 +481,7 @@
 
   remove_file(path);
 
-  FREE_C_HEAP_ARRAY(char, path, mtInternal);
+  FREE_C_HEAP_ARRAY(char, path);
 }
 
 
@@ -558,7 +558,7 @@
     errno = 0;
   }
   os::closedir(dirp);
-  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, dbuf);
 }
 
 // make the user specific temporary directory. Returns true if
@@ -703,11 +703,11 @@
 
   fd = create_sharedmem_resources(dirname, filename, size);
 
-  FREE_C_HEAP_ARRAY(char, user_name, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+  FREE_C_HEAP_ARRAY(char, user_name);
+  FREE_C_HEAP_ARRAY(char, dirname);
 
   if (fd == -1) {
-    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+    FREE_C_HEAP_ARRAY(char, filename);
     return NULL;
   }
 
@@ -723,7 +723,7 @@
       warning("mmap failed -  %s\n", strerror(errno));
     }
     remove_file(filename);
-    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+    FREE_C_HEAP_ARRAY(char, filename);
     return NULL;
   }
 
@@ -769,7 +769,7 @@
     remove_file(backing_store_file_name);
     // Don't.. Free heap memory could deadlock os::abort() if it is called
     // from signal handler. OS will reclaim the heap memory.
-    // FREE_C_HEAP_ARRAY(char, backing_store_file_name, mtInternal);
+    // FREE_C_HEAP_ARRAY(char, backing_store_file_name);
     backing_store_file_name = NULL;
   }
 }
@@ -853,9 +853,9 @@
   // store file, we don't follow them when attaching either.
   //
   if (!is_directory_secure(dirname)) {
-    FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+    FREE_C_HEAP_ARRAY(char, dirname);
     if (luser != user) {
-      FREE_C_HEAP_ARRAY(char, luser, mtInternal);
+      FREE_C_HEAP_ARRAY(char, luser);
     }
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "Process not found");
@@ -871,9 +871,9 @@
   strcpy(rfilename, filename);
 
   // free the c heap resources that are no longer needed
-  if (luser != user) FREE_C_HEAP_ARRAY(char, luser, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
-  FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+  if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
+  FREE_C_HEAP_ARRAY(char, dirname);
+  FREE_C_HEAP_ARRAY(char, filename);
 
   // open the shared memory file for the give vmid
   fd = open_sharedmem_file(rfilename, file_flags, CHECK);
--- a/src/os/bsd/vm/os_bsd.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/bsd/vm/os_bsd.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -353,7 +353,6 @@
 // Base path of extensions installed on the system.
 #define SYS_EXT_DIR     "/usr/java/packages"
 #define EXTENSIONS_DIR  "/lib/ext"
-#define ENDORSED_DIR    "/lib/endorsed"
 
 #ifndef __APPLE__
 
@@ -361,9 +360,8 @@
   // Note that the space for the colon and the trailing null are provided
   // by the nulls included by the sizeof operator.
   const size_t bufsize =
-    MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
-         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR), // extensions dir
-         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+    MAX2((size_t)MAXPATHLEN,  // For dll_dir & friends.
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir
   char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
 
   // sysclasspath, java_home, dll_dir
@@ -418,18 +416,14 @@
                                                      mtInternal);
     sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch);
     Arguments::set_library_path(ld_library_path);
-    FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
+    FREE_C_HEAP_ARRAY(char, ld_library_path);
   }
 
   // Extensions directories.
   sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
   Arguments::set_ext_dirs(buf);
 
-  // Endorsed standards default directory.
-  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
-  Arguments::set_endorsed_dirs(buf);
-
-  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, buf);
 
 #else // __APPLE__
 
@@ -445,9 +439,8 @@
   // Note that the space for the colon and the trailing null are provided
   // by the nulls included by the sizeof operator.
   const size_t bufsize =
-    MAX3((size_t)MAXPATHLEN,  // for dll_dir & friends.
-         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + system_ext_size, // extensions dir
-         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+    MAX2((size_t)MAXPATHLEN,  // for dll_dir & friends.
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + system_ext_size); // extensions dir
   char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
 
   // sysclasspath, java_home, dll_dir
@@ -513,7 +506,7 @@
     sprintf(ld_library_path, "%s%s%s%s%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS ":.",
             v, v_colon, l, l_colon, user_home_dir);
     Arguments::set_library_path(ld_library_path);
-    FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
+    FREE_C_HEAP_ARRAY(char, ld_library_path);
   }
 
   // Extensions directories.
@@ -525,11 +518,7 @@
           user_home_dir, Arguments::get_java_home());
   Arguments::set_ext_dirs(buf);
 
-  // Endorsed standards default directory.
-  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
-  Arguments::set_endorsed_dirs(buf);
-
-  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, buf);
 
 #undef SYS_EXTENSIONS_DIR
 #undef SYS_EXTENSIONS_DIRS
@@ -538,7 +527,6 @@
 
 #undef SYS_EXT_DIR
 #undef EXTENSIONS_DIR
-#undef ENDORSED_DIR
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1315,11 +1303,11 @@
     // release the storage
     for (int i = 0; i < n; i++) {
       if (pelements[i] != NULL) {
-        FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal);
+        FREE_C_HEAP_ARRAY(char, pelements[i]);
       }
     }
     if (pelements != NULL) {
-      FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
+      FREE_C_HEAP_ARRAY(char*, pelements);
     }
   } else {
     snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pname, fname);
@@ -2576,6 +2564,10 @@
   RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes));
 }
 
+size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
+  RESTARTABLE_RETURN_INT(::pread(fd, buf, nBytes, offset));
+}
+
 void os::naked_short_sleep(jlong ms) {
   struct timespec req;
 
--- a/src/os/bsd/vm/perfMemory_bsd.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/bsd/vm/perfMemory_bsd.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -127,7 +127,7 @@
       }
     }
   }
-  FREE_C_HEAP_ARRAY(char, destfile, mtInternal);
+  FREE_C_HEAP_ARRAY(char, destfile);
 }
 
 
@@ -279,14 +279,14 @@
                                      "pw_name zero length");
       }
     }
-    FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
+    FREE_C_HEAP_ARRAY(char, pwbuf);
     return NULL;
   }
 
   char* user_name = NEW_C_HEAP_ARRAY(char, strlen(p->pw_name) + 1, mtInternal);
   strcpy(user_name, p->pw_name);
 
-  FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, pwbuf);
   return user_name;
 }
 
@@ -347,7 +347,7 @@
     DIR* subdirp = os::opendir(usrdir_name);
 
     if (subdirp == NULL) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       continue;
     }
 
@@ -358,7 +358,7 @@
     // symlink can be exploited.
     //
     if (!is_directory_secure(usrdir_name)) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       os::closedir(subdirp);
       continue;
     }
@@ -382,13 +382,13 @@
         // don't follow symbolic links for the file
         RESTARTABLE(::lstat(filename, &statbuf), result);
         if (result == OS_ERR) {
-           FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+           FREE_C_HEAP_ARRAY(char, filename);
            continue;
         }
 
         // skip over files that are not regular files.
         if (!S_ISREG(statbuf.st_mode)) {
-          FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+          FREE_C_HEAP_ARRAY(char, filename);
           continue;
         }
 
@@ -398,7 +398,7 @@
           if (statbuf.st_ctime > oldest_ctime) {
             char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user, mtInternal);
+            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
             oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
             strcpy(oldest_user, user);
@@ -406,15 +406,15 @@
           }
         }
 
-        FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+        FREE_C_HEAP_ARRAY(char, filename);
       }
     }
     os::closedir(subdirp);
-    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
-    FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+    FREE_C_HEAP_ARRAY(char, udbuf);
+    FREE_C_HEAP_ARRAY(char, usrdir_name);
   }
   os::closedir(tmpdirp);
-  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, tdbuf);
 
   return(oldest_user);
 }
@@ -422,7 +422,7 @@
 // return the name of the user that owns the JVM indicated by the given vmid.
 //
 static char* get_user_name(int vmid, TRAPS) {
-  return get_user_name_slow(vmid, CHECK_NULL);
+  return get_user_name_slow(vmid, THREAD);
 }
 
 // return the file name of the backing store file for the named
@@ -481,7 +481,7 @@
 
   remove_file(path);
 
-  FREE_C_HEAP_ARRAY(char, path, mtInternal);
+  FREE_C_HEAP_ARRAY(char, path);
 }
 
 
@@ -558,7 +558,7 @@
     errno = 0;
   }
   os::closedir(dirp);
-  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, dbuf);
 }
 
 // make the user specific temporary directory. Returns true if
@@ -725,11 +725,11 @@
 
   fd = create_sharedmem_resources(dirname, filename, size);
 
-  FREE_C_HEAP_ARRAY(char, user_name, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+  FREE_C_HEAP_ARRAY(char, user_name);
+  FREE_C_HEAP_ARRAY(char, dirname);
 
   if (fd == -1) {
-    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+    FREE_C_HEAP_ARRAY(char, filename);
     return NULL;
   }
 
@@ -743,7 +743,7 @@
       warning("mmap failed -  %s\n", strerror(errno));
     }
     remove_file(filename);
-    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+    FREE_C_HEAP_ARRAY(char, filename);
     return NULL;
   }
 
@@ -872,9 +872,9 @@
   // store file, we don't follow them when attaching either.
   //
   if (!is_directory_secure(dirname)) {
-    FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+    FREE_C_HEAP_ARRAY(char, dirname);
     if (luser != user) {
-      FREE_C_HEAP_ARRAY(char, luser, mtInternal);
+      FREE_C_HEAP_ARRAY(char, luser);
     }
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "Process not found");
@@ -890,9 +890,9 @@
   strcpy(rfilename, filename);
 
   // free the c heap resources that are no longer needed
-  if (luser != user) FREE_C_HEAP_ARRAY(char, luser, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
-  FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+  if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
+  FREE_C_HEAP_ARRAY(char, dirname);
+  FREE_C_HEAP_ARRAY(char, filename);
 
   // open the shared memory file for the give vmid
   fd = open_sharedmem_file(rfilename, file_flags, CHECK);
--- a/src/os/linux/vm/os_linux.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/linux/vm/os_linux.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -68,6 +68,7 @@
 #include "utilities/events.hpp"
 #include "utilities/elfFile.hpp"
 #include "utilities/growableArray.hpp"
+#include "utilities/macros.hpp"
 #include "utilities/vmError.hpp"
 
 // put OS-includes here
@@ -339,15 +340,13 @@
 // Base path of extensions installed on the system.
 #define SYS_EXT_DIR     "/usr/java/packages"
 #define EXTENSIONS_DIR  "/lib/ext"
-#define ENDORSED_DIR    "/lib/endorsed"
 
   // Buffer that fits several sprintfs.
   // Note that the space for the colon and the trailing null are provided
   // by the nulls included by the sizeof operator.
   const size_t bufsize =
-    MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
-         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR), // extensions dir
-         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+    MAX2((size_t)MAXPATHLEN,  // For dll_dir & friends.
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir
   char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
 
   // sysclasspath, java_home, dll_dir
@@ -405,23 +404,18 @@
                                                      mtInternal);
     sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch);
     Arguments::set_library_path(ld_library_path);
-    FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
+    FREE_C_HEAP_ARRAY(char, ld_library_path);
   }
 
   // Extensions directories.
   sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
   Arguments::set_ext_dirs(buf);
 
-  // Endorsed standards default directory.
-  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
-  Arguments::set_endorsed_dirs(buf);
-
-  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, buf);
 
 #undef DEFAULT_LIBPATH
 #undef SYS_EXT_DIR
 #undef EXTENSIONS_DIR
-#undef ENDORSED_DIR
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1622,11 +1616,11 @@
     // release the storage
     for (int i = 0; i < n; i++) {
       if (pelements[i] != NULL) {
-        FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal);
+        FREE_C_HEAP_ARRAY(char, pelements[i]);
       }
     }
     if (pelements != NULL) {
-      FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
+      FREE_C_HEAP_ARRAY(char*, pelements);
     }
   } else {
     snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
@@ -2943,7 +2937,7 @@
       }
     }
   }
-  FREE_C_HEAP_ARRAY(unsigned long, cpu_map, mtInternal);
+  FREE_C_HEAP_ARRAY(unsigned long, cpu_map);
 }
 
 int os::Linux::get_node_by_cpu(int cpu_id) {
@@ -3791,6 +3785,10 @@
   return ::read(fd, buf, nBytes);
 }
 
+size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
+  return ::pread(fd, buf, nBytes, offset);
+}
+
 // Short sleep, direct OS call.
 //
 // Note: certain versions of Linux CFS scheduler (since 2.6.23) do not guarantee
--- a/src/os/linux/vm/perfMemory_linux.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/linux/vm/perfMemory_linux.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -127,7 +127,7 @@
       }
     }
   }
-  FREE_C_HEAP_ARRAY(char, destfile, mtInternal);
+  FREE_C_HEAP_ARRAY(char, destfile);
 }
 
 
@@ -279,14 +279,14 @@
                                      "pw_name zero length");
       }
     }
-    FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
+    FREE_C_HEAP_ARRAY(char, pwbuf);
     return NULL;
   }
 
   char* user_name = NEW_C_HEAP_ARRAY(char, strlen(p->pw_name) + 1, mtInternal);
   strcpy(user_name, p->pw_name);
 
-  FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, pwbuf);
   return user_name;
 }
 
@@ -347,7 +347,7 @@
     DIR* subdirp = os::opendir(usrdir_name);
 
     if (subdirp == NULL) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       continue;
     }
 
@@ -358,7 +358,7 @@
     // symlink can be exploited.
     //
     if (!is_directory_secure(usrdir_name)) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       os::closedir(subdirp);
       continue;
     }
@@ -382,13 +382,13 @@
         // don't follow symbolic links for the file
         RESTARTABLE(::lstat(filename, &statbuf), result);
         if (result == OS_ERR) {
-           FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+           FREE_C_HEAP_ARRAY(char, filename);
            continue;
         }
 
         // skip over files that are not regular files.
         if (!S_ISREG(statbuf.st_mode)) {
-          FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+          FREE_C_HEAP_ARRAY(char, filename);
           continue;
         }
 
@@ -398,7 +398,7 @@
           if (statbuf.st_ctime > oldest_ctime) {
             char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user, mtInternal);
+            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
             oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
             strcpy(oldest_user, user);
@@ -406,15 +406,15 @@
           }
         }
 
-        FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+        FREE_C_HEAP_ARRAY(char, filename);
       }
     }
     os::closedir(subdirp);
-    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
-    FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+    FREE_C_HEAP_ARRAY(char, udbuf);
+    FREE_C_HEAP_ARRAY(char, usrdir_name);
   }
   os::closedir(tmpdirp);
-  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, tdbuf);
 
   return(oldest_user);
 }
@@ -422,7 +422,7 @@
 // return the name of the user that owns the JVM indicated by the given vmid.
 //
 static char* get_user_name(int vmid, TRAPS) {
-  return get_user_name_slow(vmid, CHECK_NULL);
+  return get_user_name_slow(vmid, THREAD);
 }
 
 // return the file name of the backing store file for the named
@@ -481,7 +481,7 @@
 
   remove_file(path);
 
-  FREE_C_HEAP_ARRAY(char, path, mtInternal);
+  FREE_C_HEAP_ARRAY(char, path);
 }
 
 
@@ -558,7 +558,7 @@
     errno = 0;
   }
   os::closedir(dirp);
-  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, dbuf);
 }
 
 // make the user specific temporary directory. Returns true if
@@ -725,11 +725,11 @@
 
   fd = create_sharedmem_resources(dirname, filename, size);
 
-  FREE_C_HEAP_ARRAY(char, user_name, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+  FREE_C_HEAP_ARRAY(char, user_name);
+  FREE_C_HEAP_ARRAY(char, dirname);
 
   if (fd == -1) {
-    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+    FREE_C_HEAP_ARRAY(char, filename);
     return NULL;
   }
 
@@ -743,7 +743,7 @@
       warning("mmap failed -  %s\n", strerror(errno));
     }
     remove_file(filename);
-    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+    FREE_C_HEAP_ARRAY(char, filename);
     return NULL;
   }
 
@@ -872,9 +872,9 @@
   // store file, we don't follow them when attaching either.
   //
   if (!is_directory_secure(dirname)) {
-    FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+    FREE_C_HEAP_ARRAY(char, dirname);
     if (luser != user) {
-      FREE_C_HEAP_ARRAY(char, luser, mtInternal);
+      FREE_C_HEAP_ARRAY(char, luser);
     }
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "Process not found");
@@ -890,9 +890,9 @@
   strcpy(rfilename, filename);
 
   // free the c heap resources that are no longer needed
-  if (luser != user) FREE_C_HEAP_ARRAY(char, luser, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
-  FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+  if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
+  FREE_C_HEAP_ARRAY(char, dirname);
+  FREE_C_HEAP_ARRAY(char, filename);
 
   // open the shared memory file for the give vmid
   fd = open_sharedmem_file(rfilename, file_flags, THREAD);
--- a/src/os/solaris/add_gnu_debuglink/add_gnu_debuglink.c	Thu Dec 11 13:11:53 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,285 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * 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.
- *
- */
-
-/*
- * Name:        add_gnu_debuglink.c
- *
- * Description: Add a ".gnu_debuglink" section that refers to the specified
- *     debug_info_path to the specified ELF object.
- *
- *     This program is adapted from the example program shown on the
- *     elf(3elf) man page and from code from the Solaris compiler
- *     driver.
- */
-
-/*
- * needed to define SHF_EXCLUDE
- */
-#define ELF_TARGET_ALL
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <libelf.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static void failure(void);
-static unsigned int gnu_debuglink_crc32(unsigned int crc, unsigned char *buf,
-                                        size_t len);
-
-void
-main(int argc, char ** argv) {
-                                 /* new ELF section name */
-    static char SEC_NAME[] = ".gnu_debuglink";
-
-    unsigned char buffer[8 * 1024];  /* I/O buffer */
-    int           buffer_len;        /* buffer length */
-    char *        debug_info_path;   /* debug info path */
-    void *        ehdr;              /* ELF header */
-    Elf *         elf;               /* ELF descriptor */
-    char *        elf_ident;         /* ELF identity string */
-    char *        elf_obj;           /* elf_obj file */
-    int           fd;                /* descriptor for files */
-    unsigned int  file_crc = 0;      /* CRC for debug info file */
-    int           is_elfclass64;     /* is an ELFCLASS64 file? */
-    Elf_Data *    link_dat;          /* ELF data for new debug info link */
-    Elf_Data *    name_dat;          /* ELF data for new section name */
-    Elf_Scn *     new_scn;           /* new ELF section descriptor */
-    void *        new_shdr;          /* new ELF section header */
-    Elf_Scn *     scn;               /* ELF section descriptor */
-    void *        shdr;              /* ELF section header */
-
-    if (argc != 3) {
-        (void) fprintf(stderr, "Usage: %s debug_info_path elf_obj\n", argv[0]);
-        exit(2);
-    }
-
-    debug_info_path = argv[1];  /* save for later */
-    if ((fd = open(debug_info_path, O_RDONLY)) == -1) {
-        (void) fprintf(stderr, "%s: cannot open file.\n", debug_info_path);
-        exit(3);
-    }
-
-    (void) printf("Computing CRC for '%s'\n", debug_info_path);
-    (void) fflush(stdout);
-    /* compute CRC for the debug info file */
-    for (;;) {
-        int len = read(fd, buffer, sizeof buffer);
-        if (len <= 0) {
-            break;
-        }
-        file_crc = gnu_debuglink_crc32(file_crc, buffer, len);
-    }
-    (void) close(fd);
-
-    /* open the elf_obj */
-    elf_obj = argv[2];
-    if ((fd = open(elf_obj, O_RDWR)) == -1) {
-        (void) fprintf(stderr, "%s: cannot open file.\n", elf_obj);
-        exit(4);
-    }
-
-    (void) printf("Opening '%s' for update\n", elf_obj);
-    (void) fflush(stdout);
-    (void) elf_version(EV_CURRENT);  /* coordinate ELF versions */
-
-    /* obtain the ELF descriptors from the input file */
-    if ((elf = elf_begin(fd, ELF_C_RDWR, NULL)) == NULL) {
-        failure();
-    }
-
-    /* determine if ELFCLASS64 or not? */
-    elf_ident = elf_getident(elf, NULL);
-    is_elfclass64 = (elf_ident[EI_CLASS] == ELFCLASS64);
-
-    /* get the ELF header */
-    if (is_elfclass64) {
-        ehdr = elf64_getehdr(elf);
-    } else {
-        ehdr = elf32_getehdr(elf);
-    }
-    if (ehdr == NULL) {
-        failure();
-    }
-
-    /* get the ELF section descriptor */
-    if (is_elfclass64) {
-        scn = elf_getscn(elf, ((Elf64_Ehdr *) ehdr)->e_shstrndx);
-    } else {
-        scn = elf_getscn(elf, ((Elf32_Ehdr *) ehdr)->e_shstrndx);
-    }
-    if (scn == NULL) {
-        failure();
-    }
-
-    /* get the section header */
-    if (is_elfclass64) {
-        shdr = elf64_getshdr(scn);
-    } else {
-        shdr = elf32_getshdr(scn);
-    }
-    if (shdr == NULL) {
-        failure();
-    }
-
-    (void) printf("Adding ELF data for new section name\n");
-    (void) fflush(stdout);
-    name_dat = elf_newdata(scn);
-    name_dat->d_buf = (void *) SEC_NAME;
-    if (is_elfclass64) {
-        name_dat->d_off = ((Elf64_Shdr *) shdr)->sh_size + 1;
-    } else {
-        name_dat->d_off = ((Elf32_Shdr *) shdr)->sh_size + 1;
-    }
-    name_dat->d_align = 1;
-    name_dat->d_size = strlen(SEC_NAME) + 1;
-
-    new_scn = elf_newscn(elf);
-
-    if (is_elfclass64) {
-        new_shdr = elf64_getshdr(new_scn);
-        ((Elf64_Shdr *) new_shdr)->sh_flags = SHF_EXCLUDE;
-        ((Elf64_Shdr *) new_shdr)->sh_type = SHT_PROGBITS;
-        ((Elf64_Shdr *) new_shdr)->sh_name = ((Elf64_Shdr *) shdr)->sh_size;
-        ((Elf64_Shdr *) new_shdr)->sh_addralign = 1;
-        ((Elf64_Shdr *) shdr)->sh_size += (strlen(SEC_NAME) + 1);
-    } else {
-        new_shdr = elf32_getshdr(new_scn);
-        ((Elf32_Shdr *) new_shdr)->sh_flags = SHF_EXCLUDE;
-        ((Elf32_Shdr *) new_shdr)->sh_type = SHT_PROGBITS;
-        ((Elf32_Shdr *) new_shdr)->sh_name = ((Elf32_Shdr *) shdr)->sh_size;
-        ((Elf32_Shdr *) new_shdr)->sh_addralign = 1;
-        ((Elf32_Shdr *) shdr)->sh_size += (strlen(SEC_NAME) + 1);
-    }
-
-    (void) printf("Adding ELF data for debug_info_path value\n");
-    (void) fflush(stdout);
-    (void) memset(buffer, 0, sizeof buffer);
-    buffer_len = strlen(debug_info_path) + 1;  /* +1 for NUL */
-    (void) strncpy((char *) buffer, debug_info_path, buffer_len);
-    if (buffer_len % 4 != 0) {
-        /* not on a 4 byte boundary so pad to the next one */
-        buffer_len += (4 - buffer_len % 4);
-    }
-    /* save the CRC */
-    (void) memcpy(&buffer[buffer_len], &file_crc, sizeof file_crc);
-    buffer_len += sizeof file_crc;
-
-    link_dat = elf_newdata(new_scn);
-    link_dat->d_type = ELF_T_BYTE;
-    link_dat->d_size = buffer_len;
-    link_dat->d_buf = buffer;
-    link_dat->d_align = 1;
-
-    (void) printf("Saving updates to '%s'\n", elf_obj);
-    (void) fflush(stdout);
-    (void) elf_update(elf, ELF_C_NULL);   /* recalc ELF memory structures */
-    (void) elf_update(elf, ELF_C_WRITE);  /* write out changes to ELF obj */
-    (void) elf_end(elf);                  /* done with ELF obj */
-    (void) close(fd);
-
-    (void) printf("Done updating '%s'\n", elf_obj);
-    (void) fflush(stdout);
-    exit(0);
-}  /* end main */
-
-
-static void
-failure() {
-    (void) fprintf(stderr, "%s\n", elf_errmsg(elf_errno()));
-    exit(5);
-}
-
-
-/*
- * The CRC used in gnu_debuglink, retrieved from
- * http://sourceware.org/gdb/current/onlinedocs/gdb/Separate-Debug-Files.html#Separate-Debug-Files.
- */
-
-static unsigned int
-gnu_debuglink_crc32(unsigned int crc, unsigned char *buf, size_t len) {
-    static const unsigned int crc32_table[256] = {
-        0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
-        0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
-        0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
-        0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
-        0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
-        0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
-        0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
-        0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
-        0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
-        0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
-        0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
-        0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
-        0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
-        0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
-        0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
-        0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
-        0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
-        0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
-        0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
-        0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
-        0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
-        0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
-        0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
-        0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-        0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
-        0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
-        0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
-        0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
-        0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
-        0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
-        0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
-        0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
-        0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
-        0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
-        0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
-        0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
-        0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
-        0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
-        0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
-        0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
-        0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
-        0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
-        0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
-        0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
-        0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
-        0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
-        0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
-        0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-        0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
-        0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
-        0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
-        0x2d02ef8d
-    };
-
-    unsigned char *end;
-
-    crc = ~crc & 0xffffffff;
-    for (end = buf + len; buf < end; ++buf) {
-        crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
-    }
-    return ~crc & 0xffffffff;
-}
--- a/src/os/solaris/fix_empty_sec_hdr_flags/fix_empty_sec_hdr_flags.c	Thu Dec 11 13:11:53 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * 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.
- *
- */
-
-/*
- * Name:        fix_empty_sec_hdr_flags.c
- *
- * Description: Remove the SHF_ALLOC flag from "empty" section headers.
- *     An "empty" section header has sh_addr == 0 and sh_size == 0.
- *
- *     This program is adapted from the example program shown on the
- *     elf(3elf) man page and from code from the Solaris compiler
- *     driver.
- */
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <libelf.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static void failure(void);
-
-void
-main(int argc, char ** argv) {
-    void *        ehdr;           /* ELF header */
-    unsigned int  i;              /* section counter */
-    int           fd;             /* descriptor for file */
-    Elf *         elf;            /* ELF descriptor */
-    char *        elf_ident;      /* ELF identity string */
-    char *        elf_obj;        /* elf_obj file */
-    int           fix_count;      /* number of flags fixed */
-    int           is_elfclass64;  /* is an ELFCLASS64 file? */
-    Elf_Scn *     scn;            /* ELF section descriptor */
-    void *        shdr;           /* ELF section header */
-    Elf_Data *    shstrtab;       /* ELF section header string table */
-
-    if (argc != 2) {
-        (void) fprintf(stderr, "Usage: %s elf_obj\n", argv[0]);
-        exit(2);
-    }
-
-    /* open the elf_obj */
-    elf_obj = argv[1];
-    if ((fd = open(elf_obj, O_RDWR)) == -1) {
-        (void) fprintf(stderr, "%s: cannot open file.\n", elf_obj);
-        exit(3);
-    }
-
-    (void) printf("Opening '%s' for update\n", elf_obj);
-    (void) fflush(stdout);
-    (void) elf_version(EV_CURRENT);  /* coordinate ELF versions */
-
-    /* obtain the ELF descriptors from the input file */
-    if ((elf = elf_begin(fd, ELF_C_RDWR, NULL)) == NULL) {
-        failure();
-    }
-
-    /* determine if ELFCLASS64 or not? */
-    elf_ident = elf_getident(elf, NULL);
-    is_elfclass64 = (elf_ident[EI_CLASS] == ELFCLASS64);
-
-    /* get the ELF header */
-    if (is_elfclass64) {
-        ehdr = elf64_getehdr(elf);
-    } else {
-        ehdr = elf32_getehdr(elf);
-    }
-    if (ehdr == NULL) {
-        failure();
-    }
-
-    /* get the ELF section descriptor */
-    if (is_elfclass64) {
-        scn = elf_getscn(elf, ((Elf64_Ehdr *) ehdr)->e_shstrndx);
-    } else {
-        scn = elf_getscn(elf, ((Elf32_Ehdr *) ehdr)->e_shstrndx);
-    }
-    if (scn == NULL) {
-        failure();
-    }
-
-    /* get the section header string table */
-    shstrtab = elf_getdata(scn, NULL);
-    if (shstrtab == NULL) {
-        failure();
-    }
-
-    fix_count = 0;
-
-    /* traverse the sections of the input file */
-    for (i = 1, scn = NULL; scn = elf_nextscn(elf, scn); i++) {
-        int    has_flag_set;  /* is SHF_ALLOC flag set? */
-        int    is_empty;      /* is section empty? */
-        char * name;          /* short hand pointer */
-
-        /* get the section header */
-        if (is_elfclass64) {
-            shdr = elf64_getshdr(scn);
-        } else {
-            shdr = elf32_getshdr(scn);
-        }
-        if (shdr == NULL) {
-            failure();
-        }
-
-        if (is_elfclass64) {
-            name = (char *)shstrtab->d_buf + ((Elf64_Shdr *) shdr)->sh_name;
-        } else {
-            name = (char *)shstrtab->d_buf + ((Elf32_Shdr *) shdr)->sh_name;
-        }
-
-        if (is_elfclass64) {
-            has_flag_set = ((Elf64_Shdr *) shdr)->sh_flags & SHF_ALLOC;
-            is_empty = ((Elf64_Shdr *) shdr)->sh_addr == 0 &&
-                ((Elf64_Shdr *) shdr)->sh_size == 0;
-        } else {
-            has_flag_set = ((Elf32_Shdr *) shdr)->sh_flags & SHF_ALLOC;
-            is_empty = ((Elf32_Shdr *) shdr)->sh_addr == 0 &&
-                ((Elf32_Shdr *) shdr)->sh_size == 0;
-        }
-
-        if (is_empty && has_flag_set) {
-            (void) printf("section[%u] '%s' is empty, "
-                "but SHF_ALLOC flag is set.\n", i, name);
-            (void) printf("Clearing the SHF_ALLOC flag.\n");
-
-            if (is_elfclass64) {
-                ((Elf64_Shdr *) shdr)->sh_flags &= ~SHF_ALLOC;
-            } else {
-                ((Elf32_Shdr *) shdr)->sh_flags &= ~SHF_ALLOC;
-            }
-            fix_count++;
-        }
-    }  /* end for each ELF section */
-
-    if (fix_count > 0) {
-        (void) printf("Saving %d updates to '%s'\n", fix_count, elf_obj);
-        (void) fflush(stdout);
-        (void) elf_update(elf, ELF_C_NULL);   /* recalc ELF memory structures */
-        (void) elf_update(elf, ELF_C_WRITE);  /* write out changes to ELF obj */
-    } else {
-        (void) printf("No SHF_ALLOC flags needed to be cleared.\n");
-    }
-
-    (void) elf_end(elf);                  /* done with ELF obj */
-    (void) close(fd);
-
-    (void) printf("Done %s '%s'\n",
-               (fix_count > 0) ? "updating" : "with", elf_obj);
-    (void) fflush(stdout);
-    exit(0);
-}  /* end main */
-
-
-static void
-failure() {
-    (void) fprintf(stderr, "%s\n", elf_errmsg(elf_errno()));
-    exit(6);
-}
--- a/src/os/solaris/vm/os_solaris.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/solaris/vm/os_solaris.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -506,7 +506,7 @@
     }
   }
   if (available_id != NULL) {
-    FREE_C_HEAP_ARRAY(bool, available_id, mtInternal);
+    FREE_C_HEAP_ARRAY(bool, available_id);
   }
   return true;
 }
@@ -538,7 +538,7 @@
     }
   }
   if (id_array != NULL) {
-    FREE_C_HEAP_ARRAY(processorid_t, id_array, mtInternal);
+    FREE_C_HEAP_ARRAY(processorid_t, id_array);
   }
   return result;
 }
@@ -609,17 +609,15 @@
 // Base path of extensions installed on the system.
 #define SYS_EXT_DIR     "/usr/jdk/packages"
 #define EXTENSIONS_DIR  "/lib/ext"
-#define ENDORSED_DIR    "/lib/endorsed"
 
   char cpu_arch[12];
   // Buffer that fits several sprintfs.
   // Note that the space for the colon and the trailing null are provided
   // by the nulls included by the sizeof operator.
   const size_t bufsize =
-    MAX4((size_t)MAXPATHLEN,  // For dll_dir & friends.
+    MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
          sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch), // invariant ld_library_path
-         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR), // extensions dir
-         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir
   char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
 
   // sysclasspath, java_home, dll_dir
@@ -675,7 +673,7 @@
 
     // Determine search path count and required buffer size.
     if (dlinfo(RTLD_SELF, RTLD_DI_SERINFOSIZE, (void *)info) == -1) {
-      FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+      FREE_C_HEAP_ARRAY(char, buf);
       vm_exit_during_initialization("dlinfo SERINFOSIZE request", dlerror());
     }
 
@@ -686,8 +684,8 @@
 
     // Obtain search path information.
     if (dlinfo(RTLD_SELF, RTLD_DI_SERINFO, (void *)info) == -1) {
-      FREE_C_HEAP_ARRAY(char, buf, mtInternal);
-      FREE_C_HEAP_ARRAY(char, info, mtInternal);
+      FREE_C_HEAP_ARRAY(char, buf);
+      FREE_C_HEAP_ARRAY(char, info);
       vm_exit_during_initialization("dlinfo SERINFO request", dlerror());
     }
 
@@ -757,23 +755,18 @@
     // Callee copies into its own buffer.
     Arguments::set_library_path(library_path);
 
-    FREE_C_HEAP_ARRAY(char, library_path, mtInternal);
-    FREE_C_HEAP_ARRAY(char, info, mtInternal);
+    FREE_C_HEAP_ARRAY(char, library_path);
+    FREE_C_HEAP_ARRAY(char, info);
   }
 
   // Extensions directories.
   sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
   Arguments::set_ext_dirs(buf);
 
-  // Endorsed standards default directory.
-  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
-  Arguments::set_endorsed_dirs(buf);
-
-  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, buf);
 
 #undef SYS_EXT_DIR
 #undef EXTENSIONS_DIR
-#undef ENDORSED_DIR
 }
 
 void os::breakpoint() {
@@ -1599,11 +1592,11 @@
     // release the storage
     for (int i = 0; i < n; i++) {
       if (pelements[i] != NULL) {
-        FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal);
+        FREE_C_HEAP_ARRAY(char, pelements[i]);
       }
     }
     if (pelements != NULL) {
-      FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
+      FREE_C_HEAP_ARRAY(char*, pelements);
     }
   } else {
     snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
@@ -3167,6 +3160,15 @@
   return res;
 }
 
+size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
+  size_t res;
+  JavaThread* thread = (JavaThread*)Thread::current();
+  assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
+  ThreadBlockInVM tbiv(thread);
+  RESTARTABLE(::pread(fd, buf, (size_t) nBytes, offset), res);
+  return res;
+}
+
 size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
   size_t res;
   assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
@@ -4681,7 +4683,7 @@
       size_t lgrp_limit = os::numa_get_groups_num();
       int *lgrp_ids = NEW_C_HEAP_ARRAY(int, lgrp_limit, mtInternal);
       size_t lgrp_num = os::numa_get_leaf_groups(lgrp_ids, lgrp_limit);
-      FREE_C_HEAP_ARRAY(int, lgrp_ids, mtInternal);
+      FREE_C_HEAP_ARRAY(int, lgrp_ids);
       if (lgrp_num < 2) {
         // There's only one locality group, disable NUMA.
         UseNUMA = false;
--- a/src/os/solaris/vm/perfMemory_solaris.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/solaris/vm/perfMemory_solaris.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -129,7 +129,7 @@
       }
     }
   }
-  FREE_C_HEAP_ARRAY(char, destfile, mtInternal);
+  FREE_C_HEAP_ARRAY(char, destfile);
 }
 
 
@@ -270,14 +270,14 @@
                                      "pw_name zero length");
       }
     }
-    FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
+    FREE_C_HEAP_ARRAY(char, pwbuf);
     return NULL;
   }
 
   char* user_name = NEW_C_HEAP_ARRAY(char, strlen(p->pw_name) + 1, mtInternal);
   strcpy(user_name, p->pw_name);
 
-  FREE_C_HEAP_ARRAY(char, pwbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, pwbuf);
   return user_name;
 }
 
@@ -338,7 +338,7 @@
     DIR* subdirp = os::opendir(usrdir_name);
 
     if (subdirp == NULL) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       continue;
     }
 
@@ -349,7 +349,7 @@
     // symlink can be exploited.
     //
     if (!is_directory_secure(usrdir_name)) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       os::closedir(subdirp);
       continue;
     }
@@ -373,13 +373,13 @@
         // don't follow symbolic links for the file
         RESTARTABLE(::lstat(filename, &statbuf), result);
         if (result == OS_ERR) {
-           FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+           FREE_C_HEAP_ARRAY(char, filename);
            continue;
         }
 
         // skip over files that are not regular files.
         if (!S_ISREG(statbuf.st_mode)) {
-          FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+          FREE_C_HEAP_ARRAY(char, filename);
           continue;
         }
 
@@ -389,7 +389,7 @@
           if (statbuf.st_ctime > oldest_ctime) {
             char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user, mtInternal);
+            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
             oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
             strcpy(oldest_user, user);
@@ -397,15 +397,15 @@
           }
         }
 
-        FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+        FREE_C_HEAP_ARRAY(char, filename);
       }
     }
     os::closedir(subdirp);
-    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
-    FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+    FREE_C_HEAP_ARRAY(char, udbuf);
+    FREE_C_HEAP_ARRAY(char, usrdir_name);
   }
   os::closedir(tmpdirp);
-  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, tdbuf);
 
   return(oldest_user);
 }
@@ -461,7 +461,7 @@
   // since the structured procfs and old procfs interfaces can't be
   // mixed, we attempt to find the file through a directory search.
 
-  return get_user_name_slow(vmid, CHECK_NULL);
+  return get_user_name_slow(vmid, THREAD);
 }
 
 // return the file name of the backing store file for the named
@@ -520,7 +520,7 @@
 
   remove_file(path);
 
-  FREE_C_HEAP_ARRAY(char, path, mtInternal);
+  FREE_C_HEAP_ARRAY(char, path);
 }
 
 
@@ -597,7 +597,7 @@
     errno = 0;
   }
   os::closedir(dirp);
-  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, dbuf);
 }
 
 // make the user specific temporary directory. Returns true if
@@ -742,11 +742,11 @@
 
   fd = create_sharedmem_resources(dirname, filename, size);
 
-  FREE_C_HEAP_ARRAY(char, user_name, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+  FREE_C_HEAP_ARRAY(char, user_name);
+  FREE_C_HEAP_ARRAY(char, dirname);
 
   if (fd == -1) {
-    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+    FREE_C_HEAP_ARRAY(char, filename);
     return NULL;
   }
 
@@ -760,7 +760,7 @@
       warning("mmap failed -  %s\n", strerror(errno));
     }
     remove_file(filename);
-    FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+    FREE_C_HEAP_ARRAY(char, filename);
     return NULL;
   }
 
@@ -890,9 +890,9 @@
   // store file, we don't follow them when attaching either.
   //
   if (!is_directory_secure(dirname)) {
-    FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+    FREE_C_HEAP_ARRAY(char, dirname);
     if (luser != user) {
-      FREE_C_HEAP_ARRAY(char, luser, mtInternal);
+      FREE_C_HEAP_ARRAY(char, luser);
     }
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "Process not found");
@@ -908,9 +908,9 @@
   strcpy(rfilename, filename);
 
   // free the c heap resources that are no longer needed
-  if (luser != user) FREE_C_HEAP_ARRAY(char, luser, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
-  FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+  if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
+  FREE_C_HEAP_ARRAY(char, dirname);
+  FREE_C_HEAP_ARRAY(char, filename);
 
   // open the shared memory file for the give vmid
   fd = open_sharedmem_file(rfilename, file_flags, THREAD);
--- a/src/os/windows/vm/os_windows.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/windows/vm/os_windows.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -211,7 +211,7 @@
     }
     strcpy(home_path, home_dir);
     Arguments::set_java_home(home_path);
-    FREE_C_HEAP_ARRAY(char, home_path, mtInternal);
+    FREE_C_HEAP_ARRAY(char, home_path);
 
     dll_path = NEW_C_HEAP_ARRAY(char, strlen(home_dir) + strlen(bin) + 1,
                                 mtInternal);
@@ -221,7 +221,7 @@
     strcpy(dll_path, home_dir);
     strcat(dll_path, bin);
     Arguments::set_dll_dir(dll_path);
-    FREE_C_HEAP_ARRAY(char, dll_path, mtInternal);
+    FREE_C_HEAP_ARRAY(char, dll_path);
 
     if (!set_boot_path('\\', ';')) {
       return;
@@ -276,7 +276,7 @@
     strcat(library_path, ";.");
 
     Arguments::set_library_path(library_path);
-    FREE_C_HEAP_ARRAY(char, library_path, mtInternal);
+    FREE_C_HEAP_ARRAY(char, library_path);
   }
 
   // Default extensions directory
@@ -292,19 +292,6 @@
   #undef BIN_DIR
   #undef PACKAGE_DIR
 
-  // Default endorsed standards directory.
-  {
-#define ENDORSED_DIR "\\lib\\endorsed"
-    size_t len = strlen(Arguments::get_java_home()) + sizeof(ENDORSED_DIR);
-    char * buf = NEW_C_HEAP_ARRAY(char, len, mtInternal);
-    sprintf(buf, "%s%s", Arguments::get_java_home(), ENDORSED_DIR);
-    Arguments::set_endorsed_dirs(buf);
-    // (Arguments::set_endorsed_dirs() calls SystemProperty::set_value(), which
-    //  duplicates the input.)
-    FREE_C_HEAP_ARRAY(char, buf, mtInternal);
-#undef ENDORSED_DIR
-  }
-
 #ifndef _WIN64
   // set our UnhandledExceptionFilter and save any previous one
   prev_uef_handler = SetUnhandledExceptionFilter(Handle_FLT_Exception);
@@ -1136,7 +1123,7 @@
 
   dirp->path = (char *)malloc(strlen(dirname) + 5, mtInternal);
   if (dirp->path == 0) {
-    free(dirp, mtInternal);
+    free(dirp);
     errno = ENOMEM;
     return 0;
   }
@@ -1144,13 +1131,13 @@
 
   fattr = GetFileAttributes(dirp->path);
   if (fattr == 0xffffffff) {
-    free(dirp->path, mtInternal);
-    free(dirp, mtInternal);
+    free(dirp->path);
+    free(dirp);
     errno = ENOENT;
     return 0;
   } else if ((fattr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
-    free(dirp->path, mtInternal);
-    free(dirp, mtInternal);
+    free(dirp->path);
+    free(dirp);
     errno = ENOTDIR;
     return 0;
   }
@@ -1168,8 +1155,8 @@
   dirp->handle = FindFirstFile(dirp->path, &dirp->find_data);
   if (dirp->handle == INVALID_HANDLE_VALUE) {
     if (GetLastError() != ERROR_FILE_NOT_FOUND) {
-      free(dirp->path, mtInternal);
-      free(dirp, mtInternal);
+      free(dirp->path);
+      free(dirp);
       errno = EACCES;
       return 0;
     }
@@ -1207,8 +1194,8 @@
     }
     dirp->handle = INVALID_HANDLE_VALUE;
   }
-  free(dirp->path, mtInternal);
-  free(dirp, mtInternal);
+  free(dirp->path);
+  free(dirp);
   return 0;
 }
 
@@ -1275,11 +1262,11 @@
     // release the storage
     for (int i = 0; i < n; i++) {
       if (pelements[i] != NULL) {
-        FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal);
+        FREE_C_HEAP_ARRAY(char, pelements[i]);
       }
     }
     if (pelements != NULL) {
-      FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
+      FREE_C_HEAP_ARRAY(char*, pelements);
     }
   } else {
     jio_snprintf(buffer, buflen, "%s\\%s.dll", pname, fname);
@@ -2745,7 +2732,7 @@
 
   void free_node_list() {
     if (_numa_used_node_list != NULL) {
-      FREE_C_HEAP_ARRAY(int, _numa_used_node_list, mtInternal);
+      FREE_C_HEAP_ARRAY(int, _numa_used_node_list);
     }
   }
 
@@ -3781,8 +3768,8 @@
   return NULL;
 }
 
-#define MAX_EXIT_HANDLES    16
-#define EXIT_TIMEOUT      1000 /* 1 sec */
+#define MAX_EXIT_HANDLES PRODUCT_ONLY(32)   NOT_PRODUCT(128)
+#define EXIT_TIMEOUT     PRODUCT_ONLY(1000) NOT_PRODUCT(4000) /* 1 sec in product, 4 sec in debug */
 
 static BOOL CALLBACK init_crit_sect_call(PINIT_ONCE, PVOID pcrit_sect, PVOID*) {
   InitializeCriticalSection((CRITICAL_SECTION*)pcrit_sect);
@@ -3833,6 +3820,9 @@
         // If there's no free slot in the array of the kept handles, we'll have to
         // wait until at least one thread completes exiting.
         if ((handle_count = j) == MAX_EXIT_HANDLES) {
+          // Raise the priority of the oldest exiting thread to increase its chances
+          // to complete sooner.
+          SetThreadPriority(handles[0], THREAD_PRIORITY_ABOVE_NORMAL);
           res = WaitForMultipleObjects(MAX_EXIT_HANDLES, handles, FALSE, EXIT_TIMEOUT);
           if (res >= WAIT_OBJECT_0 && res < (WAIT_OBJECT_0 + MAX_EXIT_HANDLES)) {
             i = (res - WAIT_OBJECT_0);
@@ -3841,7 +3831,8 @@
               handles[i] = handles[i + 1];
             }
           } else {
-            warning("WaitForMultipleObjects failed in %s: %d\n", __FILE__, __LINE__);
+            warning("WaitForMultipleObjects %s in %s: %d\n",
+                    (res == WAIT_FAILED ? "failed" : "timed out"), __FILE__, __LINE__);
             // Don't keep handles, if we failed waiting for them.
             for (i = 0; i < MAX_EXIT_HANDLES; ++i) {
               CloseHandle(handles[i]);
@@ -3867,9 +3858,20 @@
         if (handle_count > 0) {
           // Before ending the process, make sure all the threads that had called
           // _endthreadex() completed.
+
+          // Set the priority level of the current thread to the same value as
+          // the priority level of exiting threads.
+          // This is to ensure it will be given a fair chance to execute if
+          // the timeout expires.
+          hthr = GetCurrentThread();
+          SetThreadPriority(hthr, THREAD_PRIORITY_ABOVE_NORMAL);
+          for (i = 0; i < handle_count; ++i) {
+            SetThreadPriority(handles[i], THREAD_PRIORITY_ABOVE_NORMAL);
+          }
           res = WaitForMultipleObjects(handle_count, handles, TRUE, EXIT_TIMEOUT);
-          if (res == WAIT_FAILED) {
-            warning("WaitForMultipleObjects failed in %s: %d\n", __FILE__, __LINE__);
+          if (res < WAIT_OBJECT_0 || res >= (WAIT_OBJECT_0 + MAX_EXIT_HANDLES)) {
+            warning("WaitForMultipleObjects %s in %s: %d\n",
+                    (res == WAIT_FAILED ? "failed" : "timed out"), __FILE__, __LINE__);
           }
           for (i = 0; i < handle_count; ++i) {
             CloseHandle(handles[i]);
@@ -4376,6 +4378,23 @@
   return (jlong) ::_lseeki64(fd, offset, whence);
 }
 
+size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
+  OVERLAPPED ov;
+  DWORD nread;
+  BOOL result;
+
+  ZeroMemory(&ov, sizeof(ov));
+  ov.Offset = (DWORD)offset;
+  ov.OffsetHigh = (DWORD)(offset >> 32);
+
+  HANDLE h = (HANDLE)::_get_osfhandle(fd);
+
+  result = ReadFile(h, (LPVOID)buf, nBytes, &nread, &ov);
+
+  return result ? nread : 0;
+}
+
+
 // This method is a slightly reworked copy of JDK's sysNativePath
 // from src/windows/hpi/src/path_md.c
 
@@ -4627,7 +4646,7 @@
 
   error = ::PeekConsoleInput(han, lpBuffer, numEvents, &numEventsRead);
   if (error == 0) {
-    os::free(lpBuffer, mtInternal);
+    os::free(lpBuffer);
     return FALSE;
   }
 
@@ -4648,7 +4667,7 @@
   }
 
   if (lpBuffer != NULL) {
-    os::free(lpBuffer, mtInternal);
+    os::free(lpBuffer);
   }
 
   *pbytes = (long) actualLength;
--- a/src/os/windows/vm/perfMemory_windows.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os/windows/vm/perfMemory_windows.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -122,7 +122,7 @@
     }
   }
 
-  FREE_C_HEAP_ARRAY(char, destfile, mtInternal);
+  FREE_C_HEAP_ARRAY(char, destfile);
 }
 
 // Shared Memory Implementation Details
@@ -335,7 +335,7 @@
     DIR* subdirp = os::opendir(usrdir_name);
 
     if (subdirp == NULL) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       continue;
     }
 
@@ -346,7 +346,7 @@
     // symlink can be exploited.
     //
     if (!is_directory_secure(usrdir_name)) {
-      FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
       os::closedir(subdirp);
       continue;
     }
@@ -367,13 +367,13 @@
         strcat(filename, udentry->d_name);
 
         if (::stat(filename, &statbuf) == OS_ERR) {
-           FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+           FREE_C_HEAP_ARRAY(char, filename);
            continue;
         }
 
         // skip over files that are not regular files.
         if ((statbuf.st_mode & S_IFMT) != S_IFREG) {
-          FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+          FREE_C_HEAP_ARRAY(char, filename);
           continue;
         }
 
@@ -395,22 +395,22 @@
         if (statbuf.st_ctime > latest_ctime) {
           char* user = strchr(dentry->d_name, '_') + 1;
 
-          if (latest_user != NULL) FREE_C_HEAP_ARRAY(char, latest_user, mtInternal);
+          if (latest_user != NULL) FREE_C_HEAP_ARRAY(char, latest_user);
           latest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
           strcpy(latest_user, user);
           latest_ctime = statbuf.st_ctime;
         }
 
-        FREE_C_HEAP_ARRAY(char, filename, mtInternal);
+        FREE_C_HEAP_ARRAY(char, filename);
       }
     }
     os::closedir(subdirp);
-    FREE_C_HEAP_ARRAY(char, udbuf, mtInternal);
-    FREE_C_HEAP_ARRAY(char, usrdir_name, mtInternal);
+    FREE_C_HEAP_ARRAY(char, udbuf);
+    FREE_C_HEAP_ARRAY(char, usrdir_name);
   }
   os::closedir(tmpdirp);
-  FREE_C_HEAP_ARRAY(char, tdbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, tdbuf);
 
   return(latest_user);
 }
@@ -502,7 +502,7 @@
     }
   }
 
-  FREE_C_HEAP_ARRAY(char, path, mtInternal);
+  FREE_C_HEAP_ARRAY(char, path);
 }
 
 // returns true if the process represented by pid is alive, otherwise
@@ -683,7 +683,7 @@
     errno = 0;
   }
   os::closedir(dirp);
-  FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, dbuf);
 }
 
 // create a file mapping object with the requested name, and size
@@ -749,11 +749,11 @@
     // be an ACL we enlisted. free the resources.
     //
     if (success && exists && pACL != NULL && !isdefault) {
-      FREE_C_HEAP_ARRAY(char, pACL, mtInternal);
+      FREE_C_HEAP_ARRAY(char, pACL);
     }
 
     // free the security descriptor
-    FREE_C_HEAP_ARRAY(char, pSD, mtInternal);
+    FREE_C_HEAP_ARRAY(char, pSD);
   }
 }
 
@@ -768,7 +768,7 @@
     lpSA->lpSecurityDescriptor = NULL;
 
     // free the security attributes structure
-    FREE_C_HEAP_ARRAY(char, lpSA, mtInternal);
+    FREE_C_HEAP_ARRAY(char, lpSA);
   }
 }
 
@@ -815,7 +815,7 @@
       warning("GetTokenInformation failure: lasterror = %d,"
               " rsize = %d\n", GetLastError(), rsize);
     }
-    FREE_C_HEAP_ARRAY(char, token_buf, mtInternal);
+    FREE_C_HEAP_ARRAY(char, token_buf);
     CloseHandle(hAccessToken);
     return NULL;
   }
@@ -828,15 +828,15 @@
       warning("GetTokenInformation failure: lasterror = %d,"
               " rsize = %d\n", GetLastError(), rsize);
     }
-    FREE_C_HEAP_ARRAY(char, token_buf, mtInternal);
-    FREE_C_HEAP_ARRAY(char, pSID, mtInternal);
+    FREE_C_HEAP_ARRAY(char, token_buf);
+    FREE_C_HEAP_ARRAY(char, pSID);
     CloseHandle(hAccessToken);
     return NULL;
   }
 
   // close the access token.
   CloseHandle(hAccessToken);
-  FREE_C_HEAP_ARRAY(char, token_buf, mtInternal);
+  FREE_C_HEAP_ARRAY(char, token_buf);
 
   return pSID;
 }
@@ -920,7 +920,7 @@
     if (PrintMiscellaneous && Verbose) {
       warning("InitializeAcl failure: lasterror = %d \n", GetLastError());
     }
-    FREE_C_HEAP_ARRAY(char, newACL, mtInternal);
+    FREE_C_HEAP_ARRAY(char, newACL);
     return false;
   }
 
@@ -933,7 +933,7 @@
         if (PrintMiscellaneous && Verbose) {
           warning("InitializeAcl failure: lasterror = %d \n", GetLastError());
         }
-        FREE_C_HEAP_ARRAY(char, newACL, mtInternal);
+        FREE_C_HEAP_ARRAY(char, newACL);
         return false;
       }
       if (((ACCESS_ALLOWED_ACE *)ace)->Header.AceFlags && INHERITED_ACE) {
@@ -960,7 +960,7 @@
           if (PrintMiscellaneous && Verbose) {
             warning("AddAce failure: lasterror = %d \n", GetLastError());
           }
-          FREE_C_HEAP_ARRAY(char, newACL, mtInternal);
+          FREE_C_HEAP_ARRAY(char, newACL);
           return false;
         }
       }
@@ -976,7 +976,7 @@
         warning("AddAccessAllowedAce failure: lasterror = %d \n",
                 GetLastError());
       }
-      FREE_C_HEAP_ARRAY(char, newACL, mtInternal);
+      FREE_C_HEAP_ARRAY(char, newACL);
       return false;
     }
   }
@@ -991,7 +991,7 @@
         if (PrintMiscellaneous && Verbose) {
           warning("InitializeAcl failure: lasterror = %d \n", GetLastError());
         }
-        FREE_C_HEAP_ARRAY(char, newACL, mtInternal);
+        FREE_C_HEAP_ARRAY(char, newACL);
         return false;
       }
       if (!AddAce(newACL, ACL_REVISION, MAXDWORD, ace,
@@ -999,7 +999,7 @@
         if (PrintMiscellaneous && Verbose) {
           warning("AddAce failure: lasterror = %d \n", GetLastError());
         }
-        FREE_C_HEAP_ARRAY(char, newACL, mtInternal);
+        FREE_C_HEAP_ARRAY(char, newACL);
         return false;
       }
       ace_index++;
@@ -1012,7 +1012,7 @@
       warning("SetSecurityDescriptorDacl failure:"
               " lasterror = %d \n", GetLastError());
     }
-    FREE_C_HEAP_ARRAY(char, newACL, mtInternal);
+    FREE_C_HEAP_ARRAY(char, newACL);
     return false;
   }
 
@@ -1032,7 +1032,7 @@
         warning("SetSecurityDescriptorControl failure:"
                 " lasterror = %d \n", GetLastError());
       }
-      FREE_C_HEAP_ARRAY(char, newACL, mtInternal);
+      FREE_C_HEAP_ARRAY(char, newACL);
       return false;
     }
   }
@@ -1149,7 +1149,7 @@
   // create a security attributes structure with access control
   // entries as initialized above.
   LPSECURITY_ATTRIBUTES lpSA = make_security_attr(aces, 3);
-  FREE_C_HEAP_ARRAY(char, aces[0].pSid, mtInternal);
+  FREE_C_HEAP_ARRAY(char, aces[0].pSid);
   FreeSid(everybodySid);
   FreeSid(administratorsSid);
   return(lpSA);
@@ -1464,15 +1464,15 @@
   assert(((size != 0) && (size % os::vm_page_size() == 0)),
          "unexpected PerfMemry region size");
 
-  FREE_C_HEAP_ARRAY(char, user, mtInternal);
+  FREE_C_HEAP_ARRAY(char, user);
 
   // create the shared memory resources
   sharedmem_fileMapHandle =
                create_sharedmem_resources(dirname, filename, objectname, size);
 
-  FREE_C_HEAP_ARRAY(char, filename, mtInternal);
-  FREE_C_HEAP_ARRAY(char, objectname, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+  FREE_C_HEAP_ARRAY(char, filename);
+  FREE_C_HEAP_ARRAY(char, objectname);
+  FREE_C_HEAP_ARRAY(char, dirname);
 
   if (sharedmem_fileMapHandle == NULL) {
     return NULL;
@@ -1627,7 +1627,7 @@
   // store file, we also don't following them when attaching
   //
   if (!is_directory_secure(dirname)) {
-    FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
+    FREE_C_HEAP_ARRAY(char, dirname);
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "Process not found");
   }
@@ -1646,10 +1646,10 @@
   strcpy(robjectname, objectname);
 
   // free the c heap resources that are no longer needed
-  if (luser != user) FREE_C_HEAP_ARRAY(char, luser, mtInternal);
-  FREE_C_HEAP_ARRAY(char, dirname, mtInternal);
-  FREE_C_HEAP_ARRAY(char, filename, mtInternal);
-  FREE_C_HEAP_ARRAY(char, objectname, mtInternal);
+  if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
+  FREE_C_HEAP_ARRAY(char, dirname);
+  FREE_C_HEAP_ARRAY(char, filename);
+  FREE_C_HEAP_ARRAY(char, objectname);
 
   if (*sizep == 0) {
     size = sharedmem_filesize(rfilename, CHECK);
--- a/src/os_cpu/bsd_x86/vm/atomic_bsd_x86.inline.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/bsd_x86/vm/atomic_bsd_x86.inline.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -88,6 +88,15 @@
   return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
 }
 
+#define VM_HAS_SPECIALIZED_CMPXCHG_BYTE
+inline jbyte    Atomic::cmpxchg    (jbyte    exchange_value, volatile jbyte*    dest, jbyte    compare_value) {
+  int mp = os::is_MP();
+  __asm__ volatile (LOCK_IF_MP(%4) "cmpxchgb %1,(%3)"
+                    : "=a" (exchange_value)
+                    : "q" (exchange_value), "a" (compare_value), "r" (dest), "r" (mp)
+                    : "cc", "memory");
+  return exchange_value;
+}
 
 inline jint     Atomic::cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value) {
   int mp = os::is_MP();
--- a/src/os_cpu/linux_x86/vm/atomic_linux_x86.inline.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/linux_x86/vm/atomic_linux_x86.inline.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -88,6 +88,15 @@
   return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
 }
 
+#define VM_HAS_SPECIALIZED_CMPXCHG_BYTE
+inline jbyte    Atomic::cmpxchg    (jbyte    exchange_value, volatile jbyte*    dest, jbyte    compare_value) {
+  int mp = os::is_MP();
+  __asm__ volatile (LOCK_IF_MP(%4) "cmpxchgb %1,(%3)"
+                    : "=a" (exchange_value)
+                    : "q" (exchange_value), "a" (compare_value), "r" (dest), "r" (mp)
+                    : "cc", "memory");
+  return exchange_value;
+}
 
 inline jint     Atomic::cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value) {
   int mp = os::is_MP();
--- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -542,6 +542,7 @@
   err.report_and_die();
 
   ShouldNotReachHere();
+  return true; // Mute compiler
 }
 
 void os::Linux::init_thread_fpu_state(void) {
--- a/src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -68,6 +68,8 @@
 extern "C" {
   jint _Atomic_add(jint add_value, volatile jint* dest IS_MP_DECL());
   jint _Atomic_xchg(jint exchange_value, volatile jint* dest);
+  jbyte _Atomic_cmpxchg_byte(jbyte exchange_value, volatile jbyte* dest,
+                       jbyte compare_value IS_MP_DECL());
   jint _Atomic_cmpxchg(jint exchange_value, volatile jint* dest,
                        jint compare_value IS_MP_DECL());
   jlong _Atomic_cmpxchg_long(jlong exchange_value, volatile jlong* dest,
@@ -82,6 +84,11 @@
   return _Atomic_xchg(exchange_value, dest);
 }
 
+#define VM_HAS_SPECIALIZED_CMPXCHG_BYTE
+inline jbyte    Atomic::cmpxchg    (jbyte    exchange_value, volatile jbyte*    dest, jbyte    compare_value) {
+  return _Atomic_cmpxchg_byte(exchange_value, dest, compare_value IS_MP_ARG());
+}
+
 inline jint     Atomic::cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value) {
   return _Atomic_cmpxchg(exchange_value, dest, compare_value IS_MP_ARG());
 }
@@ -217,6 +224,15 @@
     return exchange_value;
   }
 
+
+  inline jbyte _Atomic_cmpxchg_byte(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value, int mp) {
+    __asm__ volatile (LOCK_IF_MP(%4) "cmpxchgb %1,(%3)"
+                    : "=a" (exchange_value)
+                    : "q" (exchange_value), "a" (compare_value), "r" (dest), "r" (mp)
+                    : "cc", "memory");
+    return exchange_value;
+  }
+
   // This is the interface to the atomic instruction in solaris_i486.s.
   jlong _Atomic_cmpxchg_long_gcc(jlong exchange_value, volatile jlong* dest, jlong compare_value, int mp);
 
--- a/src/os_cpu/solaris_x86/vm/solaris_x86_32.il	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/solaris_x86/vm/solaris_x86_32.il	Thu Dec 11 15:06:12 2014 -0800
@@ -76,6 +76,23 @@
       xchgl    (%ecx), %eax
       .end
 
+  // Support for jbyte Atomic::cmpxchg(jbyte exchange_value, 
+  //                                   volatile jbyte *dest, 
+  //                                   jbyte compare_value)
+  // An additional bool (os::is_MP()) is passed as the last argument.
+      .inline _Atomic_cmpxchg_byte,4
+      movb     8(%esp), %al   // compare_value
+      movb     0(%esp), %cl   // exchange_value
+      movl     4(%esp), %edx   // dest
+      cmp      $0, 12(%esp)    // MP test
+      jne      1f
+      cmpxchgb %cl, (%edx)
+      jmp      2f
+1:    lock
+      cmpxchgb %cl, (%edx)
+2:
+      .end
+
   // Support for jint Atomic::cmpxchg(jint exchange_value, 
   //                                  volatile jint *dest, 
   //                                  jint compare_value)
--- a/src/os_cpu/solaris_x86/vm/solaris_x86_64.il	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/solaris_x86/vm/solaris_x86_64.il	Thu Dec 11 15:06:12 2014 -0800
@@ -77,6 +77,15 @@
       movq     %rdi, %rax
       .end
 
+  // Support for jbyte Atomic::cmpxchg(jbyte exchange_value, 
+  //                                   volatile jbyte *dest, 
+  //                                   jbyte compare_value)
+      .inline _Atomic_cmpxchg_byte,3
+      movb     %dl, %al      // compare_value
+      lock
+      cmpxchgb %dil, (%rsi)
+      .end
+
   // Support for jint Atomic::cmpxchg(jint exchange_value, 
   //                                  volatile jint *dest, 
   //                                  jint compare_value)
--- a/src/os_cpu/windows_x86/vm/atomic_windows_x86.inline.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/windows_x86/vm/atomic_windows_x86.inline.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -123,6 +123,11 @@
   return (*os::atomic_cmpxchg_func)(exchange_value, dest, compare_value);
 }
 
+#define VM_HAS_SPECIALIZED_CMPXCHG_BYTE
+inline jbyte    Atomic::cmpxchg    (jbyte    exchange_value, volatile jbyte*    dest, jbyte    compare_value) {
+    return (*os::atomic_cmpxchg_byte_func)(exchange_value, dest, compare_value);
+}
+
 inline jlong    Atomic::cmpxchg    (jlong    exchange_value, volatile jlong*    dest, jlong    compare_value) {
   return (*os::atomic_cmpxchg_long_func)(exchange_value, dest, compare_value);
 }
@@ -212,6 +217,19 @@
   return (void*)xchg((jint)exchange_value, (volatile jint*)dest);
 }
 
+#define VM_HAS_SPECIALIZED_CMPXCHG_BYTE
+inline jbyte    Atomic::cmpxchg    (jbyte    exchange_value, volatile jbyte*    dest, jbyte    compare_value) {
+  // alternative for InterlockedCompareExchange
+  int mp = os::is_MP();
+  __asm {
+    mov edx, dest
+    mov cl, exchange_value
+    mov al, compare_value
+    LOCK_IF_MP(mp)
+    cmpxchg byte ptr [edx], cl
+  }
+}
+
 inline jint     Atomic::cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value) {
   // alternative for InterlockedCompareExchange
   int mp = os::is_MP();
--- a/src/os_cpu/windows_x86/vm/os_windows_x86.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/windows_x86/vm/os_windows_x86.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -220,6 +220,7 @@
 typedef jint      xchg_func_t            (jint,     volatile jint*);
 typedef intptr_t  xchg_ptr_func_t        (intptr_t, volatile intptr_t*);
 typedef jint      cmpxchg_func_t         (jint,     volatile jint*,  jint);
+typedef jbyte     cmpxchg_byte_func_t    (jbyte,    volatile jbyte*, jbyte);
 typedef jlong     cmpxchg_long_func_t    (jlong,    volatile jlong*, jlong);
 typedef jint      add_func_t             (jint,     volatile jint*);
 typedef intptr_t  add_ptr_func_t         (intptr_t, volatile intptr_t*);
@@ -272,6 +273,23 @@
     *dest = exchange_value;
   return old_value;
 }
+
+jbyte os::atomic_cmpxchg_byte_bootstrap(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value) {
+  // try to use the stub:
+  cmpxchg_byte_func_t* func = CAST_TO_FN_PTR(cmpxchg_byte_func_t*, StubRoutines::atomic_cmpxchg_byte_entry());
+
+  if (func != NULL) {
+    os::atomic_cmpxchg_byte_func = func;
+    return (*func)(exchange_value, dest, compare_value);
+  }
+  assert(Threads::number_of_threads() == 0, "for bootstrap only");
+
+  jbyte old_value = *dest;
+  if (old_value == compare_value)
+    *dest = exchange_value;
+  return old_value;
+}
+
 #endif // AMD64
 
 jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
@@ -321,6 +339,7 @@
 xchg_func_t*         os::atomic_xchg_func         = os::atomic_xchg_bootstrap;
 xchg_ptr_func_t*     os::atomic_xchg_ptr_func     = os::atomic_xchg_ptr_bootstrap;
 cmpxchg_func_t*      os::atomic_cmpxchg_func      = os::atomic_cmpxchg_bootstrap;
+cmpxchg_byte_func_t* os::atomic_cmpxchg_byte_func = os::atomic_cmpxchg_byte_bootstrap;
 add_func_t*          os::atomic_add_func          = os::atomic_add_bootstrap;
 add_ptr_func_t*      os::atomic_add_ptr_func      = os::atomic_add_ptr_bootstrap;
 
@@ -635,7 +654,11 @@
 #ifndef PRODUCT
 void os::verify_stack_alignment() {
 #ifdef AMD64
-  assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
+  // The current_stack_pointer() calls generated get_previous_sp stub routine.
+  // Only enable the assert after the routine becomes available.
+  if (StubRoutines::code1() != NULL) {
+    assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
+  }
 #endif
 }
 #endif
--- a/src/os_cpu/windows_x86/vm/os_windows_x86.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/os_cpu/windows_x86/vm/os_windows_x86.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -33,6 +33,7 @@
   static intptr_t  (*atomic_xchg_ptr_func)      (intptr_t,  volatile intptr_t*);
 
   static jint      (*atomic_cmpxchg_func)       (jint,      volatile jint*,  jint);
+  static jbyte     (*atomic_cmpxchg_byte_func)  (jbyte,     volatile jbyte*, jbyte);
   static jlong     (*atomic_cmpxchg_long_func)  (jlong,     volatile jlong*, jlong);
 
   static jint      (*atomic_add_func)           (jint,      volatile jint*);
@@ -42,6 +43,7 @@
   static intptr_t  atomic_xchg_ptr_bootstrap    (intptr_t,  volatile intptr_t*);
 
   static jint      atomic_cmpxchg_bootstrap     (jint,      volatile jint*,  jint);
+  static jbyte     atomic_cmpxchg_byte_bootstrap(jbyte,     volatile jbyte*, jbyte);
 #else
 
   static jlong (*atomic_cmpxchg_long_func)  (jlong, volatile jlong*, jlong);
--- a/src/share/tools/ProjectCreator/BuildConfig.java	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/tools/ProjectCreator/BuildConfig.java	Thu Dec 11 15:06:12 2014 -0800
@@ -512,7 +512,9 @@
 abstract class GenericDebugNonKernelConfig extends GenericDebugConfig {
     protected void init(Vector includes, Vector defines) {
         super.init(includes, defines);
-        getCI().getAdditionalNonKernelLinkerFlags(getV("LinkerFlags"));
+        if (get("PlatformName").equals("Win32")) {
+            getCI().getAdditionalNonKernelLinkerFlags(getV("LinkerFlags"));
+        }
    }
 }
 
--- a/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java	Thu Dec 11 15:06:12 2014 -0800
@@ -401,16 +401,18 @@
     Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
         Vector rv = new Vector();
 
-        addAttr(rv, "AdditionalOptions",
-                "/export:JNI_GetDefaultJavaVMInitArgs " +
-                "/export:JNI_CreateJavaVM " +
-                "/export:JVM_FindClassFromBootLoader "+
-                "/export:JNI_GetCreatedJavaVMs "+
-                "/export:jio_snprintf /export:jio_printf "+
-                "/export:jio_fprintf /export:jio_vfprintf "+
-                "/export:jio_vsnprintf "+
-                "/export:JVM_GetVersionInfo "+
-                "/export:JVM_InitAgentProperties");
+        if(platformName.equals("Win32")) {
+            addAttr(rv, "AdditionalOptions",
+                    "/export:JNI_GetDefaultJavaVMInitArgs " +
+                    "/export:JNI_CreateJavaVM " +
+                    "/export:JVM_FindClassFromBootLoader "+
+                    "/export:JNI_GetCreatedJavaVMs "+
+                    "/export:jio_snprintf /export:jio_printf "+
+                    "/export:jio_fprintf /export:jio_vfprintf "+
+                    "/export:jio_vsnprintf "+
+                    "/export:JVM_GetVersionInfo "+
+                    "/export:JVM_InitAgentProperties");
+        }
         addAttr(rv, "AdditionalDependencies", "kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;Wsock32.lib;winmm.lib;psapi.lib;version.lib");
         addAttr(rv, "OutputFile", outDll);
         addAttr(rv, "SuppressStartupBanner", "true");
--- a/src/share/vm/asm/codeBuffer.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/asm/codeBuffer.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1025,7 +1025,7 @@
 
   ~CodeString() {
     assert(_next == NULL, "wrong interface for freeing list");
-    os::free((void*)_string, mtCode);
+    os::free((void*)_string);
   }
 
   bool is_comment() const { return _offset >= 0; }
--- a/src/share/vm/ci/ciEnv.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/ci/ciEnv.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -53,6 +53,7 @@
 #include "runtime/reflection.hpp"
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/thread.inline.hpp"
+#include "trace/tracing.hpp"
 #include "utilities/dtrace.hpp"
 #include "utilities/macros.hpp"
 #ifdef COMPILER1
@@ -1141,6 +1142,16 @@
   }
 }
 
+void ciEnv::report_failure(const char* reason) {
+  // Create and fire JFR event
+  EventCompilerFailure event;
+  if (event.should_commit()) {
+    event.set_compileID(compile_id());
+    event.set_failure(reason);
+    event.commit();
+  }
+}
+
 // ------------------------------------------------------------------
 // ciEnv::record_method_not_compilable()
 void ciEnv::record_method_not_compilable(const char* reason, bool all_tiers) {
--- a/src/share/vm/ci/ciEnv.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/ci/ciEnv.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -450,7 +450,8 @@
   // Check for changes to the system dictionary during compilation
   bool system_dictionary_modification_counter_changed();
 
-  void record_failure(const char* reason);
+  void record_failure(const char* reason);      // Record failure and report later
+  void report_failure(const char* reason);      // Report failure immediately
   void record_method_not_compilable(const char* reason, bool all_tiers = true);
   void record_out_of_memory_failure();
 
--- a/src/share/vm/ci/ciObjectFactory.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/ci/ciObjectFactory.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -46,6 +46,7 @@
 #include "oops/oop.inline.hpp"
 #include "oops/oop.inline2.hpp"
 #include "runtime/fieldType.hpp"
+#include "utilities/macros.hpp"
 #if INCLUDE_ALL_GCS
 # include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
 #endif
--- a/src/share/vm/ci/ciReplay.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/ci/ciReplay.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -332,7 +332,7 @@
   // Lookup a klass
   Klass* resolve_klass(const char* klass, TRAPS) {
     Symbol* klass_name = SymbolTable::lookup(klass, (int)strlen(klass), CHECK_NULL);
-    return SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, CHECK_NULL);
+    return SystemDictionary::resolve_or_fail(klass_name, _loader, _protection_domain, true, THREAD);
   }
 
   // Parse the standard tuple of <klass> <name> <signature>
--- a/src/share/vm/ci/ciTypeFlow.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/ci/ciTypeFlow.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -35,6 +35,8 @@
 #include "interpreter/bytecode.hpp"
 #include "interpreter/bytecodes.hpp"
 #include "memory/allocation.inline.hpp"
+#include "opto/compile.hpp"
+#include "opto/node.hpp"
 #include "runtime/deoptimization.hpp"
 #include "utilities/growableArray.hpp"
 
@@ -2646,7 +2648,7 @@
       assert (!blk->has_pre_order(), "");
       blk->set_next_pre_order();
 
-      if (_next_pre_order >= MaxNodeLimit / 2) {
+      if (_next_pre_order >= (int)Compile::current()->max_node_limit() / 2) {
         // Too many basic blocks.  Bail out.
         // This can happen when try/finally constructs are nested to depth N,
         // and there is O(2**N) cloning of jsr bodies.  See bug 4697245!
--- a/src/share/vm/classfile/classFileParser.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/classFileParser.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -31,9 +31,6 @@
 #include "classfile/javaClasses.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
-#if INCLUDE_CDS
-#include "classfile/systemDictionaryShared.hpp"
-#endif
 #include "classfile/verificationType.hpp"
 #include "classfile/verifier.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -63,7 +60,11 @@
 #include "services/threadService.hpp"
 #include "utilities/array.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "utilities/macros.hpp"
 #include "utilities/ostream.hpp"
+#if INCLUDE_CDS
+#include "classfile/systemDictionaryShared.hpp"
+#endif
 
 // We generally try to create the oops directly when parsing, rather than
 // allocating temporary data structures and copying the bytes twice. A
--- a/src/share/vm/classfile/classLoader.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/classLoader.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -28,11 +28,8 @@
 #include "classfile/classLoader.hpp"
 #include "classfile/classLoaderExt.hpp"
 #include "classfile/classLoaderData.inline.hpp"
+#include "classfile/imageFile.hpp"
 #include "classfile/javaClasses.hpp"
-#if INCLUDE_CDS
-#include "classfile/sharedPathsMiscInfo.hpp"
-#include "classfile/sharedClassUtil.hpp"
-#endif
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "compiler/compileBroker.hpp"
@@ -64,10 +61,15 @@
 #include "services/management.hpp"
 #include "services/threadService.hpp"
 #include "utilities/events.hpp"
-#include "utilities/hashtable.hpp"
 #include "utilities/hashtable.inline.hpp"
+#include "utilities/macros.hpp"
+#if INCLUDE_CDS
+#include "classfile/sharedPathsMiscInfo.hpp"
+#include "classfile/sharedClassUtil.hpp"
+#endif
 
-// Entry points in zip.dll for loading zip/jar file entries
+
+// Entry points in zip.dll for loading zip/jar file entries and image file entries
 
 typedef void * * (JNICALL *ZipOpen_t)(const char *name, char **pmsg);
 typedef void (JNICALL *ZipClose_t)(jzfile *zip);
@@ -75,6 +77,7 @@
 typedef jboolean (JNICALL *ReadEntry_t)(jzfile *zip, jzentry *entry, unsigned char *buf, char *namebuf);
 typedef jboolean (JNICALL *ReadMappedEntry_t)(jzfile *zip, jzentry *entry, unsigned char **buf, char *namebuf);
 typedef jzentry* (JNICALL *GetNextEntry_t)(jzfile *zip, jint n);
+typedef jboolean (JNICALL *ZipInflateFully_t)(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg);
 typedef jint     (JNICALL *Crc32_t)(jint crc, const jbyte *buf, jint len);
 
 static ZipOpen_t         ZipOpen            = NULL;
@@ -84,6 +87,7 @@
 static ReadMappedEntry_t ReadMappedEntry    = NULL;
 static GetNextEntry_t    GetNextEntry       = NULL;
 static canonicalize_fn_t CanonicalizeEntry  = NULL;
+static ZipInflateFully_t ZipInflateFully    = NULL;
 static Crc32_t           Crc32              = NULL;
 
 // Globals
@@ -161,7 +165,7 @@
 
 
 MetaIndex::~MetaIndex() {
-  FREE_C_HEAP_ARRAY(char*, _meta_package_names, mtClass);
+  FREE_C_HEAP_ARRAY(char*, _meta_package_names);
 }
 
 
@@ -247,7 +251,7 @@
   if (ZipClose != NULL) {
     (*ZipClose)(_zip);
   }
-  FREE_C_HEAP_ARRAY(char, _zip_name, mtClass);
+  FREE_C_HEAP_ARRAY(char, _zip_name);
 }
 
 u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
@@ -322,6 +326,8 @@
 }
 
 bool LazyClassPathEntry::is_jar_file() {
+  size_t len = strlen(_path);
+  if (len < 4 || strcmp(_path + len - 4, ".jar") != 0) return false;
   return ((_st.st_mode & S_IFREG) == S_IFREG);
 }
 
@@ -385,6 +391,78 @@
   }
 }
 
+ClassPathImageEntry::ClassPathImageEntry(char* name) : ClassPathEntry(), _image(new ImageFile(name)) {
+  bool opened = _image->open();
+  if (!opened) {
+    _image = NULL;
+  }
+}
+
+ClassPathImageEntry::~ClassPathImageEntry() {
+  if (_image) {
+    _image->close();
+    _image = NULL;
+  }
+}
+
+const char* ClassPathImageEntry::name() {
+  return _image ? _image->name() : "";
+}
+
+ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) {
+  u1* buffer;
+  u8 size;
+  _image->get_resource(name, buffer, size);
+
+  if (buffer) {
+    if (UsePerfData) {
+      ClassLoader::perf_sys_classfile_bytes_read()->inc(size);
+    }
+    return new ClassFileStream(buffer, (int)size, (char*)name);  // Resource allocated
+  }
+
+  return NULL;
+}
+
+#ifndef PRODUCT
+void ClassPathImageEntry::compile_the_world(Handle loader, TRAPS) {
+  tty->print_cr("CompileTheWorld : Compiling all classes in %s", name());
+  tty->cr();
+  const ImageStrings strings = _image->get_strings();
+  // Retrieve each path component string.
+  u4 count = _image->get_location_count();
+  for (u4 i = 0; i < count; i++) {
+    u1* location_data = _image->get_location_data(i);
+
+    if (location_data) {
+       ImageLocation location(location_data);
+       const char* parent = location.get_attribute(ImageLocation::ATTRIBUTE_PARENT, strings);
+       const char* base = location.get_attribute(ImageLocation::ATTRIBUTE_BASE, strings);
+       const char* extension = location.get_attribute(ImageLocation::ATTRIBUTE_EXTENSION, strings);
+       assert((strlen(parent) + strlen(base) + strlen(extension)) < JVM_MAXPATHLEN, "path exceeds buffer");
+       char path[JVM_MAXPATHLEN];
+       strcpy(path, parent);
+       strcat(path, base);
+       strcat(path, extension);
+       ClassLoader::compile_the_world_in(path, loader, CHECK);
+    }
+  }
+  if (HAS_PENDING_EXCEPTION) {
+  if (PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) {
+    CLEAR_PENDING_EXCEPTION;
+    tty->print_cr("\nCompileTheWorld : Ran out of memory\n");
+    tty->print_cr("Increase class metadata storage if a limit was set");
+  } else {
+    tty->print_cr("\nCompileTheWorld : Unexpected exception occurred\n");
+  }
+  }
+}
+
+bool ClassPathImageEntry::is_jrt() {
+  return string_ends_with(name(), "bootmodules.jimage");
+}
+#endif
+
 static void print_meta_index(LazyClassPathEntry* entry,
                              GrowableArray<char*>& meta_packages) {
   tty->print("[Meta index for %s=", entry->name());
@@ -634,7 +712,7 @@
   }
   ClassPathEntry* new_entry = NULL;
   if ((st->st_mode & S_IFREG) == S_IFREG) {
-    // Regular file, should be a zip file
+    // Regular file, should be a zip or image file
     // Canonicalized filename
     char canonical_path[JVM_MAXPATHLEN];
     if (!get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
@@ -645,6 +723,11 @@
         return NULL;
       }
     }
+    // TODO - add proper criteria for selecting image file
+    ClassPathImageEntry* entry = new ClassPathImageEntry(canonical_path);
+    if (entry->is_open()) {
+      new_entry = entry;
+    } else {
     char* error_msg = NULL;
     jzfile* zip;
     {
@@ -655,9 +738,6 @@
     }
     if (zip != NULL && error_msg == NULL) {
       new_entry = new ClassPathZipEntry(zip, path);
-      if (TraceClassLoading || TraceClassPaths) {
-        tty->print_cr("[Opened %s]", path);
-      }
     } else {
       ResourceMark rm(thread);
       char *msg;
@@ -675,10 +755,14 @@
         return NULL;
       }
     }
+    }
+    if (TraceClassLoading || TraceClassPaths) {
+      tty->print_cr("[Opened %s]", path);
+    }
   } else {
     // Directory
     new_entry = new ClassPathDirEntry(path);
-    if (TraceClassLoading || TraceClassPaths) {
+    if (TraceClassLoading) {
       tty->print_cr("[Path %s]", path);
     }
   }
@@ -801,6 +885,7 @@
   ReadEntry    = CAST_TO_FN_PTR(ReadEntry_t, os::dll_lookup(handle, "ZIP_ReadEntry"));
   ReadMappedEntry = CAST_TO_FN_PTR(ReadMappedEntry_t, os::dll_lookup(handle, "ZIP_ReadMappedEntry"));
   GetNextEntry = CAST_TO_FN_PTR(GetNextEntry_t, os::dll_lookup(handle, "ZIP_GetNextEntry"));
+  ZipInflateFully = CAST_TO_FN_PTR(ZipInflateFully_t, os::dll_lookup(handle, "ZIP_InflateFully"));
   Crc32        = CAST_TO_FN_PTR(Crc32_t, os::dll_lookup(handle, "ZIP_CRC32"));
 
   // ZIP_Close is not exported on Windows in JDK5.0 so don't abort if ZIP_Close is NULL
@@ -809,12 +894,20 @@
     vm_exit_during_initialization("Corrupted ZIP library", path);
   }
 
+  if (ZipInflateFully == NULL) {
+    vm_exit_during_initialization("Corrupted ZIP library ZIP_InflateFully missing", path);
+  }
+
   // Lookup canonicalize entry in libjava.dll
   void *javalib_handle = os::native_java_library();
   CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, os::dll_lookup(javalib_handle, "Canonicalize"));
   // This lookup only works on 1.3. Do not check for non-null here
 }
 
+jboolean ClassLoader::decompress(void *in, u8 inSize, void *out, u8 outSize, char **pmsg) {
+  return (*ZipInflateFully)(in, inSize, out, outSize, pmsg);
+}
+
 int ClassLoader::crc32(int crc, const char* buf, int len) {
   assert(Crc32 != NULL, "ZIP_CRC32 is not found");
   return (*Crc32)(crc, (const jbyte*)buf, len);
@@ -1367,8 +1460,7 @@
   tty->cr();
 }
 
-
-bool ClassPathDirEntry::is_rt_jar() {
+bool ClassPathDirEntry::is_jrt() {
   return false;
 }
 
@@ -1393,13 +1485,13 @@
   }
 }
 
-bool ClassPathZipEntry::is_rt_jar() {
+bool ClassPathZipEntry::is_jrt() {
   real_jzfile* zip = (real_jzfile*) _zip;
   int len = (int)strlen(zip->name);
   // Check whether zip name ends in "rt.jar"
   // This will match other archives named rt.jar as well, but this is
   // only used for debugging.
-  return (len >= 6) && (strcasecmp(zip->name + len - 6, "rt.jar") == 0);
+  return string_ends_with(zip->name, "rt.jar");
 }
 
 void LazyClassPathEntry::compile_the_world(Handle loader, TRAPS) {
@@ -1409,7 +1501,7 @@
   }
 }
 
-bool LazyClassPathEntry::is_rt_jar() {
+bool LazyClassPathEntry::is_jrt() {
   Thread* THREAD = Thread::current();
   ClassPathEntry* cpe = resolve_entry(THREAD);
   return (cpe != NULL) ? cpe->is_jar_file() : false;
@@ -1428,7 +1520,7 @@
   jlong start = os::javaTimeMillis();
   while (e != NULL) {
     // We stop at rt.jar, unless it is the first bootstrap path entry
-    if (e->is_rt_jar() && e != _first_entry) break;
+    if (e->is_jrt() && e != _first_entry) break;
     e->compile_the_world(system_class_loader, CATCH);
     e = e->next();
   }
@@ -1476,9 +1568,9 @@
 }
 
 void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) {
-  int len = (int)strlen(name);
-  if (len > 6 && strcmp(".class", name + len - 6) == 0) {
+  if (string_ends_with(name, ".class")) {
     // We have a .class file
+    int len = (int)strlen(name);
     char buffer[2048];
     strncpy(buffer, name, len - 6);
     buffer[len-6] = 0;
--- a/src/share/vm/classfile/classLoader.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/classLoader.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -27,6 +27,7 @@
 
 #include "classfile/classFileParser.hpp"
 #include "runtime/perfData.hpp"
+#include "utilities/macros.hpp"
 
 // The VM class loader.
 #include <sys/stat.h>
@@ -66,7 +67,7 @@
   virtual ClassFileStream* open_stream(const char* name, TRAPS) = 0;
   // Debugging
   NOT_PRODUCT(virtual void compile_the_world(Handle loader, TRAPS) = 0;)
-  NOT_PRODUCT(virtual bool is_rt_jar() = 0;)
+  NOT_PRODUCT(virtual bool is_jrt() = 0;)
 };
 
 
@@ -80,7 +81,7 @@
   ClassFileStream* open_stream(const char* name, TRAPS);
   // Debugging
   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
-  NOT_PRODUCT(bool is_rt_jar();)
+  NOT_PRODUCT(bool is_jrt();)
 };
 
 
@@ -112,7 +113,7 @@
   void contents_do(void f(const char* name, void* context), void* context);
   // Debugging
   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
-  NOT_PRODUCT(bool is_rt_jar();)
+  NOT_PRODUCT(bool is_jrt();)
 };
 
 
@@ -138,7 +139,25 @@
   virtual bool is_lazy();
   // Debugging
   NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
-  NOT_PRODUCT(bool is_rt_jar();)
+  NOT_PRODUCT(bool is_jrt();)
+};
+
+// For java image files
+class ImageFile;
+class ClassPathImageEntry: public ClassPathEntry {
+private:
+  ImageFile *_image;
+public:
+  bool is_jar_file()  { return false;  }
+  bool is_open()  { return _image != NULL; }
+  const char* name();
+  ClassPathImageEntry(char* name);
+  ~ClassPathImageEntry();
+  ClassFileStream* open_stream(const char* name, TRAPS);
+
+  // Debugging
+  NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);)
+  NOT_PRODUCT(bool is_jrt();)
 };
 
 class PackageHashtable;
@@ -226,6 +245,7 @@
   // to avoid confusing the zip library
   static bool get_canonical_path(const char* orig, char* out, int len);
  public:
+  static jboolean decompress(void *in, u8 inSize, void *out, u8 outSize, char **pmsg);
   static int crc32(int crc, const char* buf, int len);
   static bool update_class_path_entry_list(const char *path,
                                            bool check_for_duplicates,
--- a/src/share/vm/classfile/classLoaderData.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/classLoaderData.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -65,9 +65,8 @@
 #include "utilities/growableArray.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ostream.hpp"
-
 #if INCLUDE_TRACE
- #include "trace/tracing.hpp"
+#include "trace/tracing.hpp"
 #endif
 
 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
@@ -472,7 +471,7 @@
 // These anonymous class loaders are to contain classes used for JSR292
 ClassLoaderData* ClassLoaderData::anonymous_class_loader_data(oop loader, TRAPS) {
   // Add a new class loader data to the graph.
-  return ClassLoaderDataGraph::add(loader, true, CHECK_NULL);
+  return ClassLoaderDataGraph::add(loader, true, THREAD);
 }
 
 const char* ClassLoaderData::loader_name() {
@@ -978,4 +977,4 @@
   event.commit();
 }
 
-#endif /* INCLUDE_TRACE */
+#endif // INCLUDE_TRACE
--- a/src/share/vm/classfile/classLoaderData.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/classLoaderData.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -31,8 +31,9 @@
 #include "memory/metaspaceCounters.hpp"
 #include "runtime/mutex.hpp"
 #include "utilities/growableArray.hpp"
+#include "utilities/macros.hpp"
 #if INCLUDE_TRACE
-# include "utilities/ticks.hpp"
+#include "utilities/ticks.hpp"
 #endif
 
 //
--- a/src/share/vm/classfile/classLoaderExt.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/classLoaderExt.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -63,6 +63,9 @@
                                    ClassPathEntry* new_entry) {
     ClassLoader::add_to_list(new_entry);
   }
+  static void append_boot_classpath(ClassPathEntry* new_entry) {
+    ClassLoader::add_to_list(new_entry);
+  }
   static void setup_search_paths() {}
 };
 
--- a/src/share/vm/classfile/defaultMethods.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/defaultMethods.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -493,7 +493,7 @@
 };
 
 Symbol* MethodFamily::generate_no_defaults_message(TRAPS) const {
-  return SymbolTable::new_symbol("No qualifying defaults found", CHECK_NULL);
+  return SymbolTable::new_symbol("No qualifying defaults found", THREAD);
 }
 
 Symbol* MethodFamily::generate_method_message(Symbol *klass_name, Method* method, TRAPS) const {
@@ -506,7 +506,7 @@
   ss.write((const char*)name->bytes(), name->utf8_length());
   ss.write((const char*)signature->bytes(), signature->utf8_length());
   ss.print(" is abstract");
-  return SymbolTable::new_symbol(ss.base(), (int)ss.size(), CHECK_NULL);
+  return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD);
 }
 
 Symbol* MethodFamily::generate_conflicts_message(GrowableArray<Method*>* methods, TRAPS) const {
@@ -521,7 +521,7 @@
     ss.print(".");
     ss.write((const char*)name->bytes(), name->utf8_length());
   }
-  return SymbolTable::new_symbol(ss.base(), (int)ss.size(), CHECK_NULL);
+  return SymbolTable::new_symbol(ss.base(), (int)ss.size(), THREAD);
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/classfile/imageFile.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "classfile/imageFile.hpp"
+#include "runtime/os.inline.hpp"
+#include "utilities/bytes.hpp"
+
+
+// Compute the Perfect Hashing hash code for the supplied string.
+u4 ImageStrings::hash_code(const char* string, u4 seed) {
+  u1* bytes = (u1*)string;
+
+  // Compute hash code.
+  for (u1 byte = *bytes++; byte; byte = *bytes++) {
+    seed = (seed * HASH_MULTIPLIER) ^ byte;
+  }
+
+  // Ensure the result is unsigned.
+  return seed & 0x7FFFFFFF;
+}
+
+// Test to see if string begins with start.  If so returns remaining portion
+// of string.  Otherwise, NULL.
+const char* ImageStrings::starts_with(const char* string, const char* start) {
+  char ch1, ch2;
+
+  // Match up the strings the best we can.
+  while ((ch1 = *string) && (ch2 = *start)) {
+    if (ch1 != ch2) {
+      // Mismatch, return NULL.
+      return NULL;
+    }
+
+    string++, start++;
+  }
+
+  // Return remainder of string.
+  return string;
+}
+
+ImageLocation::ImageLocation(u1* data) {
+  // Deflate the attribute stream into an array of attributes.
+  memset(_attributes, 0, sizeof(_attributes));
+  u1 byte;
+
+  while ((byte = *data) != ATTRIBUTE_END) {
+    u1 kind = attribute_kind(byte);
+    u1 n = attribute_length(byte);
+    assert(kind < ATTRIBUTE_COUNT, "invalid image location attribute");
+    _attributes[kind] = attribute_value(data + 1, n);
+    data += n + 1;
+  }
+}
+
+ImageFile::ImageFile(const char* name) {
+  // Copy the image file name.
+  _name = NEW_C_HEAP_ARRAY(char, strlen(name)+1, mtClass);
+  strcpy(_name, name);
+
+  // Initialize for a closed file.
+  _fd = -1;
+  _memory_mapped = true;
+  _index_data = NULL;
+}
+
+ImageFile::~ImageFile() {
+  // Ensure file is closed.
+  close();
+
+  // Free up name.
+  FREE_C_HEAP_ARRAY(char, _name);
+}
+
+bool ImageFile::open() {
+  // If file exists open for reading.
+  struct stat st;
+  if (os::stat(_name, &st) != 0 ||
+    (st.st_mode & S_IFREG) != S_IFREG ||
+    (_fd = os::open(_name, 0, O_RDONLY)) == -1) {
+    return false;
+  }
+
+  // Read image file header and verify.
+  u8 header_size = sizeof(ImageHeader);
+  if (os::read(_fd, &_header, header_size) != header_size ||
+    _header._magic != IMAGE_MAGIC ||
+    _header._major_version != MAJOR_VERSION ||
+    _header._minor_version != MINOR_VERSION) {
+    close();
+    return false;
+  }
+
+  // Memory map index.
+  _index_size = index_size();
+  _index_data = (u1*)os::map_memory(_fd, _name, 0, NULL, _index_size, true, false);
+
+  // Failing that, read index into C memory.
+  if (_index_data == NULL) {
+    _memory_mapped = false;
+    _index_data = NEW_RESOURCE_ARRAY(u1, _index_size);
+
+    if (os::seek_to_file_offset(_fd, 0) == -1) {
+      close();
+      return false;
+    }
+
+    if (os::read(_fd, _index_data, _index_size) != _index_size) {
+      close();
+      return false;
+    }
+
+    return true;
+  }
+
+// Used to advance a pointer, unstructured.
+#undef nextPtr
+#define nextPtr(base, fromType, count, toType) (toType*)((fromType*)(base) + (count))
+  // Pull tables out from the index.
+  _redirect_table = nextPtr(_index_data, u1, header_size, s4);
+  _offsets_table = nextPtr(_redirect_table, s4, _header._location_count, u4);
+  _location_bytes = nextPtr(_offsets_table, u4, _header._location_count, u1);
+  _string_bytes = nextPtr(_location_bytes, u1, _header._locations_size, u1);
+#undef nextPtr
+
+  // Successful open.
+  return true;
+}
+
+void ImageFile::close() {
+  // Dealllocate the index.
+  if (_index_data) {
+    if (_memory_mapped) {
+      os::unmap_memory((char*)_index_data, _index_size);
+    } else {
+      FREE_RESOURCE_ARRAY(u1, _index_data, _index_size);
+    }
+
+    _index_data = NULL;
+  }
+
+  // close file.
+  if (_fd != -1) {
+    os::close(_fd);
+    _fd = -1;
+  }
+
+}
+
+// Return the attribute stream for a named resourced.
+u1* ImageFile::find_location_data(const char* path) const {
+  // Compute hash.
+  u4 hash = ImageStrings::hash_code(path) % _header._location_count;
+  s4 redirect = _redirect_table[hash];
+
+  if (!redirect) {
+    return NULL;
+  }
+
+  u4 index;
+
+  if (redirect < 0) {
+    // If no collision.
+    index = -redirect - 1;
+  } else {
+    // If collision, recompute hash code.
+    index = ImageStrings::hash_code(path, redirect) % _header._location_count;
+  }
+
+  assert(index < _header._location_count, "index exceeds location count");
+  u4 offset = _offsets_table[index];
+  assert(offset < _header._locations_size, "offset exceeds location attributes size");
+
+  if (offset == 0) {
+    return NULL;
+  }
+
+  return _location_bytes + offset;
+}
+
+// Verify that a found location matches the supplied path.
+bool ImageFile::verify_location(ImageLocation& location, const char* path) const {
+  // Retrieve each path component string.
+  ImageStrings strings(_string_bytes, _header._strings_size);
+  // Match a path with each subcomponent without concatenation (copy).
+  // Match up path parent.
+  const char* parent = location.get_attribute(ImageLocation::ATTRIBUTE_PARENT, strings);
+  const char* next = ImageStrings::starts_with(path, parent);
+  // Continue only if a complete match.
+  if (!next) return false;
+  // Match up path base.
+  const char* base = location.get_attribute(ImageLocation::ATTRIBUTE_BASE, strings);
+  next = ImageStrings::starts_with(next, base);
+  // Continue only if a complete match.
+  if (!next) return false;
+  // Match up path extension.
+  const char* extension = location.get_attribute(ImageLocation::ATTRIBUTE_EXTENSION, strings);
+  next = ImageStrings::starts_with(next, extension);
+
+  // True only if complete match and no more characters.
+  return next && *next == '\0';
+}
+
+// Return the resource for the supplied location.
+u1* ImageFile::get_resource(ImageLocation& location) const {
+  // Retrieve the byte offset and size of the resource.
+  u8 offset = _index_size + location.get_attribute(ImageLocation::ATTRIBUTE_OFFSET);
+  u8 size = location.get_attribute(ImageLocation::ATTRIBUTE_UNCOMPRESSED);
+  u8 compressed_size = location.get_attribute(ImageLocation::ATTRIBUTE_COMPRESSED);
+  u8 read_size = compressed_size ? compressed_size : size;
+
+  // Allocate space for the resource.
+  u1* data = NEW_RESOURCE_ARRAY(u1, read_size);
+
+  bool is_read = os::read_at(_fd, data, read_size, offset) == read_size;
+  guarantee(is_read, "error reading from image or short read");
+
+  // If not compressed, just return the data.
+  if (!compressed_size) {
+    return data;
+  }
+
+  u1* uncompressed = NEW_RESOURCE_ARRAY(u1, size);
+  char* msg = NULL;
+  jboolean res = ClassLoader::decompress(data, compressed_size, uncompressed, size, &msg);
+  if (!res) warning("decompression failed due to %s\n", msg);
+  guarantee(res, "decompression failed");
+
+  return uncompressed;
+}
+
+void ImageFile::get_resource(const char* path, u1*& buffer, u8& size) const {
+  buffer = NULL;
+  size = 0;
+  u1* data = find_location_data(path);
+  if (data) {
+    ImageLocation location(data);
+    if (verify_location(location, path)) {
+      size = location.get_attribute(ImageLocation::ATTRIBUTE_UNCOMPRESSED);
+      buffer = get_resource(location);
+    }
+  }
+}
+
+GrowableArray<const char*>* ImageFile::packages(const char* name) {
+  char entry[JVM_MAXPATHLEN];
+  bool overflow = jio_snprintf(entry, sizeof(entry), "%s/packages.offsets", name) == -1;
+  guarantee(!overflow, "package name overflow");
+
+  u1* buffer;
+  u8 size;
+
+  get_resource(entry, buffer, size);
+  guarantee(buffer, "missing module packages reource");
+  ImageStrings strings(_string_bytes, _header._strings_size);
+  GrowableArray<const char*>* pkgs = new GrowableArray<const char*>();
+  int count = size / 4;
+  for (int i = 0; i < count; i++) {
+    u4 offset = Bytes::get_Java_u4(buffer + (i*4));
+    const char* p = strings.get(offset);
+    pkgs->append(p);
+  }
+
+  return pkgs;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/classfile/imageFile.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -0,0 +1,343 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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_CLASSFILE_IMAGEFILE_HPP
+#define SHARE_VM_CLASSFILE_IMAGEFILE_HPP
+
+#include "classfile/classLoader.hpp"
+#include "memory/allocation.hpp"
+#include "memory/allocation.inline.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+// Image files are an alternate file format for storing classes and resources. The
+// goal is to supply file access which is faster and smaller that the jar format.
+// It should be noted that unlike jars information stored in an image is in native
+// endian format. This allows the image to be memory mapped into memory without
+// endian translation.  This also means that images are platform dependent.
+//
+// Image files are structured as three sections;
+//
+//         +-----------+
+//         |  Header   |
+//         +-----------+
+//         |           |
+//         | Directory |
+//         |           |
+//         +-----------+
+//         |           |
+//         |           |
+//         | Resources |
+//         |           |
+//         |           |
+//         +-----------+
+//
+// The header contains information related to identification and description of
+// contents.
+//
+//         +-------------------------+
+//         |   Magic (0xCAFEDADA)    |
+//         +------------+------------+
+//         | Major Vers | Minor Vers |
+//         +------------+------------+
+//         |      Location Count     |
+//         +-------------------------+
+//         |      Attributes Size    |
+//         +-------------------------+
+//         |       Strings Size      |
+//         +-------------------------+
+//
+// Magic - means of identifying validity of the file.  This avoids requiring a
+//         special file extension.
+// Major vers, minor vers - differences in version numbers indicate structural
+//                          changes in the image.
+// Location count - number of locations/resources in the file.  This count is also
+//                  the length of lookup tables used in the directory.
+// Attributes size - number of bytes in the region used to store location attribute
+//                   streams.
+// Strings size - the size of the region used to store strings used by the
+//                directory and meta data.
+//
+// The directory contains information related to resource lookup. The algorithm
+// used for lookup is "A Practical Minimal Perfect Hashing Method"
+// (http://homepages.dcc.ufmg.br/~nivio/papers/wea05.pdf). Given a path string
+// in the form <package>/<base>.<extension>  return the resource location
+// information;
+//
+//     redirectIndex = hash(path, DEFAULT_SEED) % count;
+//     redirect = redirectTable[redirectIndex];
+//     if (redirect == 0) return not found;
+//     locationIndex = redirect < 0 ? -1 - redirect : hash(path, redirect) % count;
+//     location = locationTable[locationIndex];
+//     if (!verify(location, path)) return not found;
+//     return location;
+//
+// Note: The hash function takes an initial seed value.  A different seed value
+// usually returns a different result for strings that would otherwise collide with
+// other seeds. The verify function guarantees the found resource location is
+// indeed the resource we are looking for.
+//
+// The following is the format of the directory;
+//
+//         +-------------------+
+//         |   Redirect Table  |
+//         +-------------------+
+//         | Attribute Offsets |
+//         +-------------------+
+//         |   Attribute Data  |
+//         +-------------------+
+//         |      Strings      |
+//         +-------------------+
+//
+// Redirect Table - Array of 32-bit signed values representing actions that
+//                  should take place for hashed strings that map to that
+//                  value.  Negative values indicate no hash collision and can be
+//                  quickly converted to indices into attribute offsets.  Positive
+//                  values represent a new seed for hashing an index into attribute
+//                  offsets.  Zero indicates not found.
+// Attribute Offsets - Array of 32-bit unsigned values representing offsets into
+//                     attribute data.  Attribute offsets can be iterated to do a
+//                     full survey of resources in the image.
+// Attribute Data - Bytes representing compact attribute data for locations. (See
+//                  comments in ImageLocation.)
+// Strings - Collection of zero terminated UTF-8 strings used by the directory and
+//           image meta data.  Each string is accessed by offset.  Each string is
+//           unique.  Offset zero is reserved for the empty string.
+//
+// Note that the memory mapped directory assumes 32 bit alignment of the image
+// header, the redirect table and the attribute offsets.
+//
+
+
+// Manage image file string table.
+class ImageStrings {
+private:
+  // Data bytes for strings.
+  u1* _data;
+  // Number of bytes in the string table.
+  u4 _size;
+
+public:
+  // Prime used to generate hash for Perfect Hashing.
+  static const u4 HASH_MULTIPLIER = 0x01000193;
+
+  ImageStrings(u1* data, u4 size) : _data(data), _size(size) {}
+
+  // Return the UTF-8 string beginning at offset.
+  inline const char* get(u4 offset) const {
+    assert(offset < _size, "offset exceeds string table size");
+    return (const char*)(_data + offset);
+  }
+
+  // Compute the Perfect Hashing hash code for the supplied string.
+  inline static u4 hash_code(const char* string) {
+    return hash_code(string, HASH_MULTIPLIER);
+  }
+
+  // Compute the Perfect Hashing hash code for the supplied string, starting at seed.
+  static u4 hash_code(const char* string, u4 seed);
+
+  // Test to see if string begins with start.  If so returns remaining portion
+  // of string.  Otherwise, NULL.  Used to test sections of a path without
+  // copying.
+  static const char* starts_with(const char* string, const char* start);
+
+};
+
+// Manage image file location attribute streams.  Within an image, a location's
+// attributes are compressed into a stream of bytes.  An attribute stream is
+// composed of individual attribute sequences.  Each attribute sequence begins with
+// a header byte containing the attribute 'kind' (upper 5 bits of header) and the
+// 'length' less 1 (lower 3 bits of header) of bytes that follow containing the
+// attribute value.  Attribute values present as most significant byte first.
+//
+// Ex. Container offset (ATTRIBUTE_OFFSET) 0x33562 would be represented as 0x22
+// (kind = 4, length = 3), 0x03, 0x35, 0x62.
+//
+// An attribute stream is terminated with a header kind of ATTRIBUTE_END (header
+// byte of zero.)
+//
+// ImageLocation inflates the stream into individual values stored in the long
+// array _attributes. This allows an attribute value can be quickly accessed by
+// direct indexing. Unspecified values default to zero.
+//
+// Notes:
+//  - Even though ATTRIBUTE_END is used to mark the end of the attribute stream,
+//    streams will contain zero byte values to represent lesser significant bits.
+//    Thus, detecting a zero byte is not sufficient to detect the end of an attribute
+//    stream.
+//  - ATTRIBUTE_OFFSET represents the number of bytes from the beginning of the region
+//    storing the resources.  Thus, in an image this represents the number of bytes
+//    after the directory.
+//  - Currently, compressed resources are represented by having a non-zero
+//    ATTRIBUTE_COMPRESSED value.  This represents the number of bytes stored in the
+//    image, and the value of ATTRIBUTE_UNCOMPRESSED represents number of bytes of the
+//    inflated resource in memory. If the ATTRIBUTE_COMPRESSED is zero then the value
+//    of ATTRIBUTE_UNCOMPRESSED represents both the number of bytes in the image and
+//    in memory.  In the future, additional compression techniques will be used and
+//    represented differently.
+//  - Package strings include trailing slash and extensions include prefix period.
+//
+class ImageLocation {
+public:
+  // Attribute kind enumeration.
+  static const u1 ATTRIBUTE_END = 0; // End of attribute stream marker
+  static const u1 ATTRIBUTE_BASE = 1; // String table offset of resource path base
+  static const u1 ATTRIBUTE_PARENT = 2; // String table offset of resource path parent
+  static const u1 ATTRIBUTE_EXTENSION = 3; // String table offset of resource path extension
+  static const u1 ATTRIBUTE_OFFSET = 4; // Container byte offset of resource
+  static const u1 ATTRIBUTE_COMPRESSED = 5; // In image byte size of the compressed resource
+  static const u1 ATTRIBUTE_UNCOMPRESSED = 6; // In memory byte size of the uncompressed resource
+  static const u1 ATTRIBUTE_COUNT = 7; // Number of attribute kinds
+
+private:
+  // Values of inflated attributes.
+  u8 _attributes[ATTRIBUTE_COUNT];
+
+  // Return the attribute value number of bytes.
+  inline static u1 attribute_length(u1 data) {
+    return (data & 0x7) + 1;
+  }
+
+  // Return the attribute kind.
+  inline static u1 attribute_kind(u1 data) {
+    u1 kind = data >> 3;
+    assert(kind < ATTRIBUTE_COUNT, "invalid attribute kind");
+    return kind;
+  }
+
+  // Return the attribute length.
+  inline static u8 attribute_value(u1* data, u1 n) {
+    assert(0 < n && n <= 8, "invalid attribute value length");
+    u8 value = 0;
+
+    // Most significant bytes first.
+    for (u1 i = 0; i < n; i++) {
+      value <<= 8;
+      value |= data[i];
+    }
+
+    return value;
+  }
+
+public:
+  ImageLocation(u1* data);
+
+  // Retrieve an attribute value from the inflated array.
+  inline u8 get_attribute(u1 kind) const {
+    assert(ATTRIBUTE_END < kind && kind < ATTRIBUTE_COUNT, "invalid attribute kind");
+    return _attributes[kind];
+  }
+
+  // Retrieve an attribute string value from the inflated array.
+  inline const char* get_attribute(u4 kind, const ImageStrings& strings) const {
+    return strings.get((u4)get_attribute(kind));
+  }
+};
+
+// Manage the image file.
+class ImageFile: public CHeapObj<mtClass> {
+private:
+  // Image file marker.
+  static const u4 IMAGE_MAGIC = 0xCAFEDADA;
+  // Image file major version number.
+  static const u2 MAJOR_VERSION = 0;
+  // Image file minor version number.
+  static const u2 MINOR_VERSION = 1;
+
+  struct ImageHeader {
+    u4 _magic;          // Image file marker
+    u2 _major_version;  // Image file major version number
+    u2 _minor_version;  // Image file minor version number
+    u4 _location_count; // Number of locations managed in index.
+    u4 _locations_size; // Number of bytes in attribute table.
+    u4 _strings_size;   // Number of bytes in string table.
+  };
+
+  char* _name;          // Name of image
+  int _fd;              // File descriptor
+  bool _memory_mapped;  // Is file memory mapped
+  ImageHeader _header;  // Image header
+  u8 _index_size;       // Total size of index
+  u1* _index_data;      // Raw index data
+  s4* _redirect_table;  // Perfect hash redirect table
+  u4* _offsets_table;   // Location offset table
+  u1* _location_bytes;  // Location attributes
+  u1* _string_bytes;    // String table
+
+  // Compute number of bytes in image file index.
+  inline u8 index_size() {
+    return sizeof(ImageHeader) +
+    _header._location_count * sizeof(u4) * 2 +
+    _header._locations_size +
+    _header._strings_size;
+  }
+
+public:
+  ImageFile(const char* name);
+  ~ImageFile();
+
+  // Open image file for access.
+  bool open();
+  // Close image file.
+  void close();
+
+  // Retrieve name of image file.
+  inline const char* name() const {
+    return _name;
+  }
+
+  // Return a string table accessor.
+  inline const ImageStrings get_strings() const {
+    return ImageStrings(_string_bytes, _header._strings_size);
+  }
+
+  // Return number of locations in image file index.
+  inline u4 get_location_count() const {
+    return _header._location_count;
+  }
+
+  // Return location attribute stream for location i.
+  inline u1* get_location_data(u4 i) const {
+    u4 offset = _offsets_table[i];
+
+    return offset != 0 ? _location_bytes + offset : NULL;
+  }
+
+  // Return the attribute stream for a named resourced.
+  u1* find_location_data(const char* path) const;
+
+  // Verify that a found location matches the supplied path.
+  bool verify_location(ImageLocation& location, const char* path) const;
+
+  // Return the resource for the supplied location info.
+  u1* get_resource(ImageLocation& location) const;
+
+  // Return the resource associated with the path else NULL if not found.
+  void get_resource(const char* path, u1*& buffer, u8& size) const;
+
+  // Return an array of packages for a given module
+  GrowableArray<const char*>* packages(const char* name);
+};
+
+#endif // SHARE_VM_CLASSFILE_IMAGEFILE_HPP
--- a/src/share/vm/classfile/javaClasses.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/javaClasses.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -41,6 +41,7 @@
 #include "oops/method.hpp"
 #include "oops/symbol.hpp"
 #include "oops/typeArrayOop.hpp"
+#include "prims/jvmtiRedefineClassesTrace.hpp"
 #include "runtime/fieldDescriptor.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/interfaceSupport.hpp"
@@ -944,7 +945,7 @@
   assert(_group_offset == 0, "offsets should be initialized only once");
 
   Klass* k = SystemDictionary::Thread_klass();
-  compute_offset(_name_offset,      k, vmSymbols::name_name(),      vmSymbols::char_array_signature());
+  compute_offset(_name_offset,      k, vmSymbols::name_name(),      vmSymbols::string_signature());
   compute_offset(_group_offset,     k, vmSymbols::group_name(),     vmSymbols::threadgroup_signature());
   compute_offset(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), vmSymbols::classloader_signature());
   compute_offset(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), vmSymbols::accesscontrolcontext_signature());
@@ -974,15 +975,12 @@
 }
 
 
-typeArrayOop java_lang_Thread::name(oop java_thread) {
-  oop name = java_thread->obj_field(_name_offset);
-  assert(name == NULL || (name->is_typeArray() && TypeArrayKlass::cast(name->klass())->element_type() == T_CHAR), "just checking");
-  return typeArrayOop(name);
-}
-
-
-void java_lang_Thread::set_name(oop java_thread, typeArrayOop name) {
-  assert(java_thread->obj_field(_name_offset) == NULL, "name should be NULL");
+oop java_lang_Thread::name(oop java_thread) {
+  return java_thread->obj_field(_name_offset);
+}
+
+
+void java_lang_Thread::set_name(oop java_thread, oop name) {
   java_thread->obj_field_put(_name_offset, name);
 }
 
@@ -1952,7 +1950,7 @@
   // This class is eagerly initialized during VM initialization, since we keep a refence
   // to one of the methods
   assert(InstanceKlass::cast(klass)->is_initialized(), "must be initialized");
-  return InstanceKlass::cast(klass)->allocate_instance_handle(CHECK_NH);
+  return InstanceKlass::cast(klass)->allocate_instance_handle(THREAD);
 }
 
 oop java_lang_reflect_Method::clazz(oop reflect) {
@@ -2130,7 +2128,7 @@
   instanceKlassHandle klass (THREAD, k);
   // Ensure it is initialized
   klass->initialize(CHECK_NH);
-  return klass->allocate_instance_handle(CHECK_NH);
+  return klass->allocate_instance_handle(THREAD);
 }
 
 oop java_lang_reflect_Constructor::clazz(oop reflect) {
@@ -2270,7 +2268,7 @@
   instanceKlassHandle klass (THREAD, k);
   // Ensure it is initialized
   klass->initialize(CHECK_NH);
-  return klass->allocate_instance_handle(CHECK_NH);
+  return klass->allocate_instance_handle(THREAD);
 }
 
 oop java_lang_reflect_Field::clazz(oop reflect) {
@@ -2397,7 +2395,7 @@
   instanceKlassHandle klass (THREAD, k);
   // Ensure it is initialized
   klass->initialize(CHECK_NH);
-  return klass->allocate_instance_handle(CHECK_NH);
+  return klass->allocate_instance_handle(THREAD);
 }
 
 oop java_lang_reflect_Parameter::name(oop param) {
@@ -2447,7 +2445,7 @@
   instanceKlassHandle klass (THREAD, k);
   // Ensure it is initialized
   klass->initialize(CHECK_NH);
-  return klass->allocate_instance_handle(CHECK_NH);
+  return klass->allocate_instance_handle(THREAD);
 }
 
 
@@ -2797,12 +2795,35 @@
   return (Metadata*)mname->address_field(_vmtarget_offset);
 }
 
+bool java_lang_invoke_MemberName::is_method(oop mname) {
+  assert(is_instance(mname), "must be MemberName");
+  return (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0;
+}
+
 #if INCLUDE_JVMTI
 // Can be executed on VM thread only
-void java_lang_invoke_MemberName::adjust_vmtarget(oop mname, Metadata* ref) {
-  assert((is_instance(mname) && (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0), "wrong type");
+void java_lang_invoke_MemberName::adjust_vmtarget(oop mname, Method* old_method,
+                                                  Method* new_method, bool* trace_name_printed) {
+  assert(is_method(mname), "wrong type");
   assert(Thread::current()->is_VM_thread(), "not VM thread");
-  mname->address_field_put(_vmtarget_offset, (address)ref);
+
+  Method* target = (Method*)mname->address_field(_vmtarget_offset);
+  if (target == old_method) {
+    mname->address_field_put(_vmtarget_offset, (address)new_method);
+
+    if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) {
+      if (!(*trace_name_printed)) {
+        // RC_TRACE_MESG macro has an embedded ResourceMark
+        RC_TRACE_MESG(("adjust: name=%s",
+                       old_method->method_holder()->external_name()));
+        *trace_name_printed = true;
+      }
+      // RC_TRACE macro has an embedded ResourceMark
+      RC_TRACE(0x00400000, ("MemberName method update: %s(%s)",
+                            new_method->name()->as_C_string(),
+                            new_method->signature()->as_C_string()));
+    }
+  }
 }
 #endif // INCLUDE_JVMTI
 
--- a/src/share/vm/classfile/javaClasses.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/javaClasses.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -345,8 +345,8 @@
   // Set JavaThread for instance
   static void set_thread(oop java_thread, JavaThread* thread);
   // Name
-  static typeArrayOop name(oop java_thread);
-  static void set_name(oop java_thread, typeArrayOop name);
+  static oop name(oop java_thread);
+  static void set_name(oop java_thread, oop name);
   // Priority
   static ThreadPriority priority(oop java_thread);
   static void set_priority(oop java_thread, ThreadPriority priority);
@@ -1100,7 +1100,8 @@
   static Metadata*      vmtarget(oop mname);
   static void       set_vmtarget(oop mname, Metadata* target);
 #if INCLUDE_JVMTI
-  static void       adjust_vmtarget(oop mname, Metadata* target);
+  static void       adjust_vmtarget(oop mname, Method* old_method, Method* new_method,
+                                    bool* trace_name_printed);
 #endif // INCLUDE_JVMTI
 
   static intptr_t       vmindex(oop mname);
@@ -1114,6 +1115,8 @@
     return obj != NULL && is_subclass(obj->klass());
   }
 
+  static bool is_method(oop obj);
+
   // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants):
   enum {
     MN_IS_METHOD            = 0x00010000, // method (not constructor)
--- a/src/share/vm/classfile/loaderConstraints.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/loaderConstraints.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -164,7 +164,7 @@
 
         // Purge entry
         *p = probe->next();
-        FREE_C_HEAP_ARRAY(oop, probe->loaders(), mtClass);
+        FREE_C_HEAP_ARRAY(oop, probe->loaders());
         free_entry(probe);
       } else {
 #ifdef ASSERT
@@ -340,7 +340,7 @@
         ClassLoaderData** new_loaders = NEW_C_HEAP_ARRAY(ClassLoaderData*, n, mtClass);
         memcpy(new_loaders, p->loaders(), sizeof(ClassLoaderData*) * p->num_loaders());
         p->set_max_loaders(n);
-        FREE_C_HEAP_ARRAY(ClassLoaderData*, p->loaders(), mtClass);
+        FREE_C_HEAP_ARRAY(ClassLoaderData*, p->loaders());
         p->set_loaders(new_loaders);
     }
 }
@@ -422,7 +422,7 @@
   }
 
   *pp2 = p2->next();
-  FREE_C_HEAP_ARRAY(oop, p2->loaders(), mtClass);
+  FREE_C_HEAP_ARRAY(oop, p2->loaders());
   free_entry(p2);
   return;
 }
--- a/src/share/vm/classfile/sharedPathsMiscInfo.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/sharedPathsMiscInfo.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -110,7 +110,7 @@
 bool SharedPathsMiscInfo::check(jint type, const char* path) {
   switch (type) {
   case BOOT:
-    if (strcmp(path, Arguments::get_sysclasspath()) != 0) {
+    if (os::file_name_strcmp(path, Arguments::get_sysclasspath()) != 0) {
       return fail("[BOOT classpath mismatch, actual: -Dsun.boot.class.path=", Arguments::get_sysclasspath());
     }
     break;
--- a/src/share/vm/classfile/sharedPathsMiscInfo.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/sharedPathsMiscInfo.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -89,7 +89,7 @@
   }
   ~SharedPathsMiscInfo() {
     if (_allocated) {
-      FREE_C_HEAP_ARRAY(char, _buf_start, mtClass);
+      FREE_C_HEAP_ARRAY(char, _buf_start);
     }
   }
   int get_used_bytes() {
--- a/src/share/vm/classfile/stringTable.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/stringTable.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -36,6 +36,7 @@
 #include "runtime/atomic.inline.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "utilities/hashtable.inline.hpp"
+#include "utilities/macros.hpp"
 #if INCLUDE_ALL_GCS
 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
 #include "gc_implementation/g1/g1StringDedup.hpp"
--- a/src/share/vm/classfile/symbolTable.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/symbolTable.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -235,7 +235,7 @@
   MutexLocker ml(SymbolTable_lock, THREAD);
 
   // Otherwise, add to symbol to table
-  return the_table()->basic_add(index, (u1*)name, len, hashValue, true, CHECK_NULL);
+  return the_table()->basic_add(index, (u1*)name, len, hashValue, true, THREAD);
 }
 
 Symbol* SymbolTable::lookup(const Symbol* sym, int begin, int end, TRAPS) {
@@ -274,7 +274,7 @@
   // Grab SymbolTable_lock first.
   MutexLocker ml(SymbolTable_lock, THREAD);
 
-  return the_table()->basic_add(index, (u1*)buffer, len, hashValue, true, CHECK_NULL);
+  return the_table()->basic_add(index, (u1*)buffer, len, hashValue, true, THREAD);
 }
 
 Symbol* SymbolTable::lookup_only(const char* name, int len,
--- a/src/share/vm/classfile/systemDictionary.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/systemDictionary.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -31,10 +31,6 @@
 #include "classfile/resolutionErrors.hpp"
 #include "classfile/stringTable.hpp"
 #include "classfile/systemDictionary.hpp"
-#if INCLUDE_CDS
-#include "classfile/sharedClassUtil.hpp"
-#include "classfile/systemDictionaryShared.hpp"
-#endif
 #include "classfile/vmSymbols.hpp"
 #include "compiler/compileBroker.hpp"
 #include "interpreter/bytecodeStream.hpp"
@@ -65,9 +61,12 @@
 #include "services/threadService.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/ticks.hpp"
-
+#if INCLUDE_CDS
+#include "classfile/sharedClassUtil.hpp"
+#include "classfile/systemDictionaryShared.hpp"
+#endif
 #if INCLUDE_TRACE
- #include "trace/tracing.hpp"
+#include "trace/tracing.hpp"
 #endif
 
 Dictionary*            SystemDictionary::_dictionary          = NULL;
@@ -123,7 +122,7 @@
 
 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, TRAPS) {
   if (class_loader() == NULL) return ClassLoaderData::the_null_class_loader_data();
-  return ClassLoaderDataGraph::find_or_create(class_loader, CHECK_NULL);
+  return ClassLoaderDataGraph::find_or_create(class_loader, THREAD);
 }
 
 // ----------------------------------------------------------------------------
@@ -233,15 +232,15 @@
                  class_name->as_C_string(),
                  class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string()));
   if (FieldType::is_array(class_name)) {
-    return resolve_array_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL);
+    return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
   } else if (FieldType::is_obj(class_name)) {
     ResourceMark rm(THREAD);
     // Ignore wrapping L and ;.
     TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
                                    class_name->utf8_length() - 2, CHECK_NULL);
-    return resolve_instance_class_or_null(name, class_loader, protection_domain, CHECK_NULL);
+    return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
   } else {
-    return resolve_instance_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL);
+    return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD);
   }
 }
 
@@ -2660,7 +2659,7 @@
                                       class_loader->klass() : (Klass*)NULL);
     event.commit();
   }
-#endif /* INCLUDE_TRACE */
+#endif // INCLUDE_TRACE
 }
 
 #ifndef PRODUCT
--- a/src/share/vm/classfile/verificationType.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/verificationType.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -289,7 +289,7 @@
           if (is_reference() && from.is_reference()) {
             return is_reference_assignable_from(from, context,
                                                 from_field_is_protected,
-                                                CHECK_false);
+                                                THREAD);
           } else {
             return false;
           }
--- a/src/share/vm/classfile/verifier.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/classfile/verifier.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1927,7 +1927,7 @@
 
   return SystemDictionary::resolve_or_fail(
     name, Handle(THREAD, loader), Handle(THREAD, protection_domain),
-    true, CHECK_NULL);
+    true, THREAD);
 }
 
 bool ClassVerifier::is_protected_access(instanceKlassHandle this_class,
--- a/src/share/vm/code/codeBlob.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/code/codeBlob.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -168,7 +168,7 @@
 
 void CodeBlob::flush() {
   if (_oop_maps) {
-    FREE_C_HEAP_ARRAY(unsigned char, _oop_maps, mtCode);
+    FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);
     _oop_maps = NULL;
   }
   _strings.free();
--- a/src/share/vm/code/codeCache.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/code/codeCache.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1190,7 +1190,7 @@
     }
   }
 
-  FREE_C_HEAP_ARRAY(int, buckets, mtCode);
+  FREE_C_HEAP_ARRAY(int, buckets);
   print_memory_overhead();
 }
 
--- a/src/share/vm/code/dependencies.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/code/dependencies.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -912,6 +912,8 @@
   bool is_witness(Klass* k) {
     if (doing_subtype_search()) {
       return Dependencies::is_concrete_klass(k);
+    } else if (!k->oop_is_instance()) {
+      return false; // no methods to find in an array type
     } else {
       Method* m = InstanceKlass::cast(k)->find_method(_name, _signature);
       if (m == NULL || !Dependencies::is_concrete_method(m))  return false;
@@ -1118,7 +1120,7 @@
   Klass* chain;       // scratch variable
 #define ADD_SUBCLASS_CHAIN(k)                     {  \
     assert(chaini < CHAINMAX, "oob");                \
-    chain = InstanceKlass::cast(k)->subklass();      \
+    chain = k->subklass();                           \
     if (chain != NULL)  chains[chaini++] = chain;    }
 
   // Look for non-abstract subclasses.
@@ -1129,35 +1131,37 @@
   // (Their subclasses are additional indirect implementors.
   // See InstanceKlass::add_implementor.)
   // (Note:  nof_implementors is always zero for non-interfaces.)
-  int nof_impls = InstanceKlass::cast(context_type)->nof_implementors();
-  if (nof_impls > 1) {
-    // Avoid this case: *I.m > { A.m, C }; B.m > C
-    // Here, I.m has 2 concrete implementations, but m appears unique
-    // as A.m, because the search misses B.m when checking C.
-    // The inherited method B.m was getting missed by the walker
-    // when interface 'I' was the starting point.
-    // %%% Until this is fixed more systematically, bail out.
-    // (Old CHA had the same limitation.)
-    return context_type;
-  }
-  if (nof_impls > 0) {
-    Klass* impl = InstanceKlass::cast(context_type)->implementor();
-    assert(impl != NULL, "just checking");
-    // If impl is the same as the context_type, then more than one
-    // implementor has seen. No exact info in this case.
-    if (impl == context_type) {
-      return context_type;  // report an inexact witness to this sad affair
+  if (top_level_call) {
+    int nof_impls = InstanceKlass::cast(context_type)->nof_implementors();
+    if (nof_impls > 1) {
+      // Avoid this case: *I.m > { A.m, C }; B.m > C
+      // Here, I.m has 2 concrete implementations, but m appears unique
+      // as A.m, because the search misses B.m when checking C.
+      // The inherited method B.m was getting missed by the walker
+      // when interface 'I' was the starting point.
+      // %%% Until this is fixed more systematically, bail out.
+      // (Old CHA had the same limitation.)
+      return context_type;
     }
-    if (do_counts)
-      { NOT_PRODUCT(deps_find_witness_steps++); }
-    if (is_participant(impl)) {
-      if (!participants_hide_witnesses) {
+    if (nof_impls > 0) {
+      Klass* impl = InstanceKlass::cast(context_type)->implementor();
+      assert(impl != NULL, "just checking");
+      // If impl is the same as the context_type, then more than one
+      // implementor has seen. No exact info in this case.
+      if (impl == context_type) {
+        return context_type;  // report an inexact witness to this sad affair
+      }
+      if (do_counts)
+        { NOT_PRODUCT(deps_find_witness_steps++); }
+      if (is_participant(impl)) {
+        if (!participants_hide_witnesses) {
+          ADD_SUBCLASS_CHAIN(impl);
+        }
+      } else if (is_witness(impl) && !ignore_witness(impl)) {
+        return impl;
+      } else {
         ADD_SUBCLASS_CHAIN(impl);
       }
-    } else if (is_witness(impl) && !ignore_witness(impl)) {
-      return impl;
-    } else {
-      ADD_SUBCLASS_CHAIN(impl);
     }
   }
 
--- a/src/share/vm/compiler/compileBroker.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/compiler/compileBroker.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -594,7 +594,7 @@
  * Add a CompileTask to a CompileQueue.
  */
 void CompileQueue::add(CompileTask* task) {
-  assert(lock()->owned_by_self(), "must own lock");
+  assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
 
   task->set_next(NULL);
   task->set_prev(NULL);
@@ -625,7 +625,7 @@
   }
 
   // Notify CompilerThreads that a task is available.
-  lock()->notify_all();
+  MethodCompileQueue_lock->notify_all();
 }
 
 /**
@@ -635,7 +635,7 @@
  * compilation is disabled.
  */
 void CompileQueue::free_all() {
-  MutexLocker mu(lock());
+  MutexLocker mu(MethodCompileQueue_lock);
   CompileTask* next = _first;
 
   // Iterate over all tasks in the compile queue
@@ -653,14 +653,14 @@
   _first = NULL;
 
   // Wake up all threads that block on the queue.
-  lock()->notify_all();
+  MethodCompileQueue_lock->notify_all();
 }
 
 /**
  * Get the next CompileTask from a CompileQueue
  */
 CompileTask* CompileQueue::get() {
-  MutexLocker locker(lock());
+  MutexLocker locker(MethodCompileQueue_lock);
   // If _first is NULL we have no more compile jobs. There are two reasons for
   // having no compile jobs: First, we compiled everything we wanted. Second,
   // we ran out of code cache so compilation has been disabled. In the latter
@@ -681,7 +681,7 @@
     // We need a timed wait here, since compiler threads can exit if compilation
     // is disabled forever. We use 5 seconds wait time; the exiting of compiler threads
     // is not critical and we do not want idle compiler threads to wake up too often.
-    lock()->wait(!Mutex::_no_safepoint_check_flag, 5*1000);
+    MethodCompileQueue_lock->wait(!Mutex::_no_safepoint_check_flag, 5*1000);
   }
 
   if (CompileBroker::is_compilation_disabled_forever()) {
@@ -701,7 +701,7 @@
 // Clean & deallocate stale compile tasks.
 // Temporarily releases MethodCompileQueue lock.
 void CompileQueue::purge_stale_tasks() {
-  assert(lock()->owned_by_self(), "must own lock");
+  assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
   if (_first_stale != NULL) {
     // Stale tasks are purged when MCQ lock is released,
     // but _first_stale updates are protected by MCQ lock.
@@ -710,7 +710,7 @@
     CompileTask* head = _first_stale;
     _first_stale = NULL;
     {
-      MutexUnlocker ul(lock());
+      MutexUnlocker ul(MethodCompileQueue_lock);
       for (CompileTask* task = head; task != NULL; ) {
         CompileTask* next_task = task->next();
         CompileTaskWrapper ctw(task); // Frees the task
@@ -722,7 +722,7 @@
 }
 
 void CompileQueue::remove(CompileTask* task) {
-   assert(lock()->owned_by_self(), "must own lock");
+   assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
   if (task->prev() != NULL) {
     task->prev()->set_next(task->next());
   } else {
@@ -742,7 +742,7 @@
 }
 
 void CompileQueue::remove_and_mark_stale(CompileTask* task) {
-  assert(lock()->owned_by_self(), "must own lock");
+  assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
   remove(task);
 
   // Enqueue the task for reclamation (should be done outside MCQ lock)
@@ -780,7 +780,7 @@
 }
 
 void CompileQueue::print(outputStream* st) {
-  assert(lock()->owned_by_self(), "must own lock");
+  assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
   st->print_cr("Contents of %s", name());
   st->print_cr("----------------------------");
   CompileTask* task = _first;
@@ -1066,11 +1066,11 @@
 #endif // !ZERO && !SHARK
   // Initialize the compilation queue
   if (c2_compiler_count > 0) {
-    _c2_compile_queue  = new CompileQueue("C2 compile queue",  MethodCompileQueue_lock);
+    _c2_compile_queue  = new CompileQueue("C2 compile queue");
     _compilers[1]->set_num_compiler_threads(c2_compiler_count);
   }
   if (c1_compiler_count > 0) {
-    _c1_compile_queue  = new CompileQueue("C1 compile queue",  MethodCompileQueue_lock);
+    _c1_compile_queue  = new CompileQueue("C1 compile queue");
     _compilers[0]->set_num_compiler_threads(c1_compiler_count);
   }
 
@@ -1214,7 +1214,7 @@
 
   // Acquire our lock.
   {
-    MutexLocker locker(queue->lock(), thread);
+    MutexLocker locker(MethodCompileQueue_lock, thread);
 
     // Make sure the method has not slipped into the queues since
     // last we checked; note that those checks were "fast bail-outs".
@@ -1807,7 +1807,7 @@
                      os::file_separator(), thread_id, os::current_process_id());
       }
 
-      fp = fopen(file_name, "at");
+      fp = fopen(file_name, "wt");
       if (fp != NULL) {
         if (LogCompilation && Verbose) {
           tty->print_cr("Opening compilation log %s", file_name);
@@ -1985,6 +1985,7 @@
 
     if (ci_env.failing()) {
       task->set_failure_reason(ci_env.failure_reason());
+      ci_env.report_failure(ci_env.failure_reason());
       const char* retry_message = ci_env.retry_message();
       if (_compilation_log != NULL) {
         _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message);
--- a/src/share/vm/compiler/compileBroker.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/compiler/compileBroker.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -195,7 +195,6 @@
 class CompileQueue : public CHeapObj<mtCompiler> {
  private:
   const char* _name;
-  Monitor*    _lock;
 
   CompileTask* _first;
   CompileTask* _last;
@@ -206,9 +205,8 @@
 
   void purge_stale_tasks();
  public:
-  CompileQueue(const char* name, Monitor* lock) {
+  CompileQueue(const char* name) {
     _name = name;
-    _lock = lock;
     _first = NULL;
     _last = NULL;
     _size = 0;
@@ -216,7 +214,6 @@
   }
 
   const char*  name() const                      { return _name; }
-  Monitor*     lock() const                      { return _lock; }
 
   void         add(CompileTask* task);
   void         remove(CompileTask* task);
@@ -418,6 +415,7 @@
     shutdown_compilaton = 2
   };
 
+  static jint get_compilation_activity_mode() { return _should_compile_new_jobs; }
   static bool should_compile_new_jobs() { return UseCompiler && (_should_compile_new_jobs == run_compilation); }
   static bool set_should_compile_new_jobs(jint new_state) {
     // Return success if the current caller set it
--- a/src/share/vm/compiler/compileLog.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/compiler/compileLog.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -56,10 +56,10 @@
 }
 
 CompileLog::~CompileLog() {
-  delete _out;
+  delete _out; // Close fd in fileStream::~fileStream()
   _out = NULL;
-  FREE_C_HEAP_ARRAY(char, _identities, mtCompiler);
-  FREE_C_HEAP_ARRAY(char, _file, mtCompiler);
+  FREE_C_HEAP_ARRAY(char, _identities);
+  FREE_C_HEAP_ARRAY(char, _file);
 }
 
 
@@ -278,10 +278,9 @@
       }
       file->print_raw_cr("</compilation_log>");
       close(partial_fd);
-      unlink(partial_file);
     }
     CompileLog* next_log = log->_next;
-    delete log;
+    delete log; // Removes partial file
     log = next_log;
   }
   _first = NULL;
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -52,21 +52,9 @@
 }
 
 void ConcurrentMarkSweepPolicy::initialize_generations() {
-  _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC,
-    CURRENT_PC, AllocFailStrategy::RETURN_NULL);
-  if (_generations == NULL)
-    vm_exit_during_initialization("Unable to allocate gen spec");
-
-  Generation::Name yg_name =
-    UseParNewGC ? Generation::ParNew : Generation::DefNew;
-  _generations[0] = new GenerationSpec(yg_name, _initial_young_size,
-                                       _max_young_size);
-  _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep,
-                                       _initial_old_size, _max_old_size);
-
-  if (_generations[0] == NULL || _generations[1] == NULL) {
-    vm_exit_during_initialization("Unable to allocate gen spec");
-  }
+  _generations = NEW_C_HEAP_ARRAY(GenerationSpecPtr, number_of_generations(), mtGC);
+  _generations[0] = new GenerationSpec(Generation::ParNew, _initial_young_size, _max_young_size);
+  _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, _initial_old_size, _max_old_size);
 }
 
 void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size,
@@ -82,10 +70,5 @@
 
 void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
   // initialize the policy counters - 2 collectors, 3 generations
-  if (UseParNewGC) {
-    _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3);
-  }
-  else {
-    _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3);
-  }
+  _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3);
 }
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -90,7 +90,8 @@
                     CMSRescanMultiple),
   _marking_task_size(CardTableModRefBS::card_size_in_words * BitsPerWord *
                     CMSConcMarkMultiple),
-  _collector(NULL)
+  _collector(NULL),
+  _preconsumptionDirtyCardClosure(NULL)
 {
   assert(sizeof(FreeChunk) / BytesPerWord <= MinChunkSize,
          "FreeChunk is larger than expected");
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -155,6 +155,9 @@
   // Used to keep track of limit of sweep for the space
   HeapWord* _sweep_limit;
 
+  // Used to make the young collector update the mod union table
+  MemRegionClosure* _preconsumptionDirtyCardClosure;
+
   // Support for compacting cms
   HeapWord* cross_threshold(HeapWord* start, HeapWord* end);
   HeapWord* forward(oop q, size_t size, CompactPoint* cp, HeapWord* compact_top);
@@ -356,6 +359,14 @@
   void initialize_sequential_subtasks_for_marking(int n_threads,
          HeapWord* low = NULL);
 
+  virtual MemRegionClosure* preconsumptionDirtyCardClosure() const {
+    return _preconsumptionDirtyCardClosure;
+  }
+
+  void setPreconsumptionDirtyCardClosure(MemRegionClosure* cl) {
+    _preconsumptionDirtyCardClosure = cl;
+  }
+
   // Space enquiries
   size_t used() const;
   size_t free() const;
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -192,7 +192,6 @@
      FreeBlockDictionary<FreeChunk>::DictionaryChoice dictionaryChoice) :
   CardGeneration(rs, initial_byte_size, level, ct),
   _dilatation_factor(((double)MinChunkSize)/((double)(CollectedHeap::min_fill_size()))),
-  _debug_collection_type(Concurrent_collection_type),
   _did_compact(false)
 {
   HeapWord* bottom = (HeapWord*) _virtual_space.low();
@@ -612,8 +611,6 @@
   // Clip CMSBootstrapOccupancy between 0 and 100.
   _bootstrap_occupancy = ((double)CMSBootstrapOccupancy)/(double)100;
 
-  _full_gcs_since_conc_gc = 0;
-
   // Now tell CMS generations the identity of their collector
   ConcurrentMarkSweepGeneration::set_collector(this);
 
@@ -626,7 +623,8 @@
 
   // Support for parallelizing young gen rescan
   GenCollectedHeap* gch = GenCollectedHeap::heap();
-  _young_gen = gch->prev_gen(_cmsGen);
+  assert(gch->prev_gen(_cmsGen)->kind() == Generation::ParNew, "CMS can only be used with ParNew");
+  _young_gen = (ParNewGeneration*)gch->prev_gen(_cmsGen);
   if (gch->supports_inline_contig_alloc()) {
     _top_addr = gch->top_addr();
     _end_addr = gch->end_addr();
@@ -653,15 +651,15 @@
         || _cursor == NULL) {
       warning("Failed to allocate survivor plab/chunk array");
       if (_survivor_plab_array  != NULL) {
-        FREE_C_HEAP_ARRAY(ChunkArray, _survivor_plab_array, mtGC);
+        FREE_C_HEAP_ARRAY(ChunkArray, _survivor_plab_array);
         _survivor_plab_array = NULL;
       }
       if (_survivor_chunk_array != NULL) {
-        FREE_C_HEAP_ARRAY(HeapWord*, _survivor_chunk_array, mtGC);
+        FREE_C_HEAP_ARRAY(HeapWord*, _survivor_chunk_array);
         _survivor_chunk_array = NULL;
       }
       if (_cursor != NULL) {
-        FREE_C_HEAP_ARRAY(size_t, _cursor, mtGC);
+        FREE_C_HEAP_ARRAY(size_t, _cursor);
         _cursor = NULL;
       }
     } else {
@@ -671,10 +669,10 @@
         if (vec == NULL) {
           warning("Failed to allocate survivor plab array");
           for (int j = i; j > 0; j--) {
-            FREE_C_HEAP_ARRAY(HeapWord*, _survivor_plab_array[j-1].array(), mtGC);
+            FREE_C_HEAP_ARRAY(HeapWord*, _survivor_plab_array[j-1].array());
           }
-          FREE_C_HEAP_ARRAY(ChunkArray, _survivor_plab_array, mtGC);
-          FREE_C_HEAP_ARRAY(HeapWord*, _survivor_chunk_array, mtGC);
+          FREE_C_HEAP_ARRAY(ChunkArray, _survivor_plab_array);
+          FREE_C_HEAP_ARRAY(HeapWord*, _survivor_chunk_array);
           _survivor_plab_array = NULL;
           _survivor_chunk_array = NULL;
           _survivor_chunk_capacity = 0;
@@ -1206,14 +1204,6 @@
 
 void
 ConcurrentMarkSweepGeneration::
-par_promote_alloc_undo(int thread_num,
-                       HeapWord* obj, size_t word_sz) {
-  // CMS does not support promotion undo.
-  ShouldNotReachHere();
-}
-
-void
-ConcurrentMarkSweepGeneration::
 par_promote_alloc_done(int thread_num) {
   CMSParGCThreadState* ps = _par_gc_thread_states[thread_num];
   ps->lab.retire(thread_num);
@@ -1247,20 +1237,6 @@
     return true;
   }
 
-  // For debugging purposes, change the type of collection.
-  // If the rotation is not on the concurrent collection
-  // type, don't start a concurrent collection.
-  NOT_PRODUCT(
-    if (RotateCMSCollectionTypes &&
-        (_cmsGen->debug_collection_type() !=
-          ConcurrentMarkSweepGeneration::Concurrent_collection_type)) {
-      assert(_cmsGen->debug_collection_type() !=
-        ConcurrentMarkSweepGeneration::Unknown_collection_type,
-        "Bad cms collection type");
-      return false;
-    }
-  )
-
   FreelistLocker x(this);
   // ------------------------------------------------------------------
   // Print out lots of information which affects the initiation of
@@ -1441,16 +1417,6 @@
                            size_t size,
                            bool   tlab)
 {
-  if (!UseCMSCollectionPassing && _collectorState > Idling) {
-    // For debugging purposes skip the collection if the state
-    // is not currently idle
-    if (TraceCMSState) {
-      gclog_or_tty->print_cr("Thread " INTPTR_FORMAT " skipped full:%d CMS state %d",
-        Thread::current(), full, _collectorState);
-    }
-    return;
-  }
-
   // The following "if" branch is present for defensive reasons.
   // In the current uses of this interface, it can be replaced with:
   // assert(!GC_locker.is_active(), "Can't be called otherwise");
@@ -1466,7 +1432,6 @@
     return;
   }
   acquire_control_and_collect(full, clear_all_soft_refs);
-  _full_gcs_since_conc_gc++;
 }
 
 void CMSCollector::request_full_gc(unsigned int full_gc_count, GCCause::Cause cause) {
@@ -1636,66 +1601,51 @@
     gclog_or_tty->print_cr("    gets control with state %d", _collectorState);
   }
 
-  // Check if we need to do a compaction, or if not, whether
-  // we need to start the mark-sweep from scratch.
-  bool should_compact    = false;
-  bool should_start_over = false;
-  decide_foreground_collection_type(clear_all_soft_refs,
-    &should_compact, &should_start_over);
-
-NOT_PRODUCT(
-  if (RotateCMSCollectionTypes) {
-    if (_cmsGen->debug_collection_type() ==
-        ConcurrentMarkSweepGeneration::MSC_foreground_collection_type) {
-      should_compact = true;
-    } else if (_cmsGen->debug_collection_type() ==
-               ConcurrentMarkSweepGeneration::MS_foreground_collection_type) {
-      should_compact = false;
-    }
-  }
-)
+  // Inform cms gen if this was due to partial collection failing.
+  // The CMS gen may use this fact to determine its expansion policy.
+  GenCollectedHeap* gch = GenCollectedHeap::heap();
+  if (gch->incremental_collection_will_fail(false /* don't consult_young */)) {
+    assert(!_cmsGen->incremental_collection_failed(),
+           "Should have been noticed, reacted to and cleared");
+    _cmsGen->set_incremental_collection_failed();
+  }
 
   if (first_state > Idling) {
     report_concurrent_mode_interruption();
   }
 
-  set_did_compact(should_compact);
-  if (should_compact) {
-    // If the collection is being acquired from the background
-    // collector, there may be references on the discovered
-    // references lists that have NULL referents (being those
-    // that were concurrently cleared by a mutator) or
-    // that are no longer active (having been enqueued concurrently
-    // by the mutator).
-    // Scrub the list of those references because Mark-Sweep-Compact
-    // code assumes referents are not NULL and that all discovered
-    // Reference objects are active.
-    ref_processor()->clean_up_discovered_references();
-
-    if (first_state > Idling) {
-      save_heap_summary();
-    }
-
-    do_compaction_work(clear_all_soft_refs);
-
-    // Has the GC time limit been exceeded?
-    DefNewGeneration* young_gen = _young_gen->as_DefNewGeneration();
-    size_t max_eden_size = young_gen->max_capacity() -
-                           young_gen->to()->capacity() -
-                           young_gen->from()->capacity();
-    GenCollectedHeap* gch = GenCollectedHeap::heap();
-    GCCause::Cause gc_cause = gch->gc_cause();
-    size_policy()->check_gc_overhead_limit(_young_gen->used(),
-                                           young_gen->eden()->used(),
-                                           _cmsGen->max_capacity(),
-                                           max_eden_size,
-                                           full,
-                                           gc_cause,
-                                           gch->collector_policy());
-  } else {
-    do_mark_sweep_work(clear_all_soft_refs, first_state,
-      should_start_over);
-  }
+  set_did_compact(true);
+
+  // If the collection is being acquired from the background
+  // collector, there may be references on the discovered
+  // references lists that have NULL referents (being those
+  // that were concurrently cleared by a mutator) or
+  // that are no longer active (having been enqueued concurrently
+  // by the mutator).
+  // Scrub the list of those references because Mark-Sweep-Compact
+  // code assumes referents are not NULL and that all discovered
+  // Reference objects are active.
+  ref_processor()->clean_up_discovered_references();
+
+  if (first_state > Idling) {
+    save_heap_summary();
+  }
+
+  do_compaction_work(clear_all_soft_refs);
+
+  // Has the GC time limit been exceeded?
+  size_t max_eden_size = _young_gen->max_capacity() -
+                         _young_gen->to()->capacity() -
+                         _young_gen->from()->capacity();
+  GCCause::Cause gc_cause = gch->gc_cause();
+  size_policy()->check_gc_overhead_limit(_young_gen->used(),
+                                         _young_gen->eden()->used(),
+                                         _cmsGen->max_capacity(),
+                                         max_eden_size,
+                                         full,
+                                         gc_cause,
+                                         gch->collector_policy());
+
   // Reset the expansion cause, now that we just completed
   // a collection cycle.
   clear_expansion_cause();
@@ -1713,68 +1663,6 @@
   _cmsGen->compute_new_size_free_list();
 }
 
-// A work method used by foreground collection to determine
-// what type of collection (compacting or not, continuing or fresh)
-// it should do.
-// NOTE: the intent is to make UseCMSCompactAtFullCollection
-// and CMSCompactWhenClearAllSoftRefs the default in the future
-// and do away with the flags after a suitable period.
-void CMSCollector::decide_foreground_collection_type(
-  bool clear_all_soft_refs, bool* should_compact,
-  bool* should_start_over) {
-  // Normally, we'll compact only if the UseCMSCompactAtFullCollection
-  // flag is set, and we have either requested a System.gc() or
-  // the number of full gc's since the last concurrent cycle
-  // has exceeded the threshold set by CMSFullGCsBeforeCompaction,
-  // or if an incremental collection has failed
-  GenCollectedHeap* gch = GenCollectedHeap::heap();
-  assert(gch->collector_policy()->is_generation_policy(),
-         "You may want to check the correctness of the following");
-  // Inform cms gen if this was due to partial collection failing.
-  // The CMS gen may use this fact to determine its expansion policy.
-  if (gch->incremental_collection_will_fail(false /* don't consult_young */)) {
-    assert(!_cmsGen->incremental_collection_failed(),
-           "Should have been noticed, reacted to and cleared");
-    _cmsGen->set_incremental_collection_failed();
-  }
-  *should_compact =
-    UseCMSCompactAtFullCollection &&
-    ((_full_gcs_since_conc_gc >= CMSFullGCsBeforeCompaction) ||
-     GCCause::is_user_requested_gc(gch->gc_cause()) ||
-     gch->incremental_collection_will_fail(true /* consult_young */));
-  *should_start_over = false;
-  if (clear_all_soft_refs && !*should_compact) {
-    // We are about to do a last ditch collection attempt
-    // so it would normally make sense to do a compaction
-    // to reclaim as much space as possible.
-    if (CMSCompactWhenClearAllSoftRefs) {
-      // Default: The rationale is that in this case either
-      // we are past the final marking phase, in which case
-      // we'd have to start over, or so little has been done
-      // that there's little point in saving that work. Compaction
-      // appears to be the sensible choice in either case.
-      *should_compact = true;
-    } else {
-      // We have been asked to clear all soft refs, but not to
-      // compact. Make sure that we aren't past the final checkpoint
-      // phase, for that is where we process soft refs. If we are already
-      // past that phase, we'll need to redo the refs discovery phase and
-      // if necessary clear soft refs that weren't previously
-      // cleared. We do so by remembering the phase in which
-      // we came in, and if we are past the refs processing
-      // phase, we'll choose to just redo the mark-sweep
-      // collection from scratch.
-      if (_collectorState > FinalMarking) {
-        // We are past the refs processing phase;
-        // start over and do a fresh synchronous CMS cycle
-        _collectorState = Resetting; // skip to reset to start new cycle
-        reset(false /* == !asynch */);
-        *should_start_over = true;
-      } // else we can continue a possibly ongoing current cycle
-    }
-  }
-}
-
 // A work method used by the foreground collector to do
 // a mark-sweep-compact.
 void CMSCollector::do_compaction_work(bool clear_all_soft_refs) {
@@ -1787,10 +1675,6 @@
   gc_tracer->report_gc_start(gch->gc_cause(), gc_timer->gc_start());
 
   GCTraceTime t("CMS:MSC ", PrintGCDetails && Verbose, true, NULL, gc_tracer->gc_id());
-  if (PrintGC && Verbose && !(GCCause::is_user_requested_gc(gch->gc_cause()))) {
-    gclog_or_tty->print_cr("Compact ConcurrentMarkSweepGeneration after %d "
-      "collections passed to foreground collector", _full_gcs_since_conc_gc);
-  }
 
   // Temporarily widen the span of the weak reference processing to
   // the entire heap.
@@ -1852,7 +1736,7 @@
   _collectorState = Resetting;
   assert(_restart_addr == NULL,
          "Should have been NULL'd before baton was passed");
-  reset(false /* == !asynch */);
+  reset(false /* == !concurrent */);
   _cmsGen->reset_after_compaction();
   _concurrent_cycles_since_last_unload = 0;
 
@@ -1875,45 +1759,10 @@
   // in the heap's do_collection() method.
 }
 
-// A work method used by the foreground collector to do
-// a mark-sweep, after taking over from a possibly on-going
-// concurrent mark-sweep collection.
-void CMSCollector::do_mark_sweep_work(bool clear_all_soft_refs,
-  CollectorState first_state, bool should_start_over) {
-  if (PrintGC && Verbose) {
-    gclog_or_tty->print_cr("Pass concurrent collection to foreground "
-      "collector with count %d",
-      _full_gcs_since_conc_gc);
-  }
-  switch (_collectorState) {
-    case Idling:
-      if (first_state == Idling || should_start_over) {
-        // The background GC was not active, or should
-        // restarted from scratch;  start the cycle.
-        _collectorState = InitialMarking;
-      }
-      // If first_state was not Idling, then a background GC
-      // was in progress and has now finished.  No need to do it
-      // again.  Leave the state as Idling.
-      break;
-    case Precleaning:
-      // In the foreground case don't do the precleaning since
-      // it is not done concurrently and there is extra work
-      // required.
-      _collectorState = FinalMarking;
-  }
-  collect_in_foreground(clear_all_soft_refs, GenCollectedHeap::heap()->gc_cause());
-
-  // For a mark-sweep, compute_new_size() will be called
-  // in the heap's do_collection() method.
-}
-
-
 void CMSCollector::print_eden_and_survivor_chunk_arrays() {
-  DefNewGeneration* dng = _young_gen->as_DefNewGeneration();
-  ContiguousSpace* eden_space = dng->eden();
-  ContiguousSpace* from_space = dng->from();
-  ContiguousSpace* to_space   = dng->to();
+  ContiguousSpace* eden_space = _young_gen->eden();
+  ContiguousSpace* from_space = _young_gen->from();
+  ContiguousSpace* to_space   = _young_gen->to();
   // Eden
   if (_eden_chunk_array != NULL) {
     gclog_or_tty->print_cr("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
@@ -1989,13 +1838,7 @@
   }
 };
 
-// There are separate collect_in_background and collect_in_foreground because of
-// the different locking requirements of the background collector and the
-// foreground collector.  There was originally an attempt to share
-// one "collect" method between the background collector and the foreground
-// collector but the if-then-else required made it cleaner to have
-// separate methods.
-void CMSCollector::collect_in_background(bool clear_all_soft_refs, GCCause::Cause cause) {
+void CMSCollector::collect_in_background(GCCause::Cause cause) {
   assert(Thread::current()->is_ConcurrentGC_thread(),
     "A CMS asynchronous collection is only allowed on a CMS thread.");
 
@@ -2036,7 +1879,7 @@
   // Used for PrintGC
   size_t prev_used;
   if (PrintGC && Verbose) {
-    prev_used = _cmsGen->used(); // XXXPERM
+    prev_used = _cmsGen->used();
   }
 
   // The change of the collection state is normally done at this level;
@@ -2116,7 +1959,7 @@
         break;
       case Marking:
         // initial marking in checkpointRootsInitialWork has been completed
-        if (markFromRoots(true)) { // we were successful
+        if (markFromRoots()) { // we were successful
           assert(_collectorState == Precleaning, "Collector state should "
             "have changed");
         } else {
@@ -2146,10 +1989,9 @@
         break;
       case Sweeping:
         // final marking in checkpointRootsFinal has been completed
-        sweep(true);
+        sweep();
         assert(_collectorState == Resizing, "Collector state change "
           "to Resizing must be done under the free_list_lock");
-        _full_gcs_since_conc_gc = 0;
 
       case Resizing: {
         // Sweeping has been completed...
@@ -2222,12 +2064,6 @@
   }
 }
 
-void CMSCollector::register_foreground_gc_start(GCCause::Cause cause) {
-  if (!_cms_start_registered) {
-    register_gc_start(cause);
-  }
-}
-
 void CMSCollector::register_gc_start(GCCause::Cause cause) {
   _cms_start_registered = true;
   _gc_timer_cm->register_gc_start();
@@ -2255,120 +2091,6 @@
   _gc_tracer_cm->report_metaspace_summary(when, _last_metaspace_summary);
 }
 
-void CMSCollector::collect_in_foreground(bool clear_all_soft_refs, GCCause::Cause cause) {
-  assert(_foregroundGCIsActive && !_foregroundGCShouldWait,
-         "Foreground collector should be waiting, not executing");
-  assert(Thread::current()->is_VM_thread(), "A foreground collection"
-    "may only be done by the VM Thread with the world stopped");
-  assert(ConcurrentMarkSweepThread::vm_thread_has_cms_token(),
-         "VM thread should have CMS token");
-
-  // The gc id is created in register_foreground_gc_start if this collection is synchronous
-  const GCId gc_id = _collectorState == InitialMarking ? GCId::peek() : _gc_tracer_cm->gc_id();
-  NOT_PRODUCT(GCTraceTime t("CMS:MS (foreground) ", PrintGCDetails && Verbose,
-    true, NULL, gc_id);)
-  COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact);
-
-  HandleMark hm;  // Discard invalid handles created during verification
-
-  if (VerifyBeforeGC &&
-      GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
-    Universe::verify();
-  }
-
-  // Snapshot the soft reference policy to be used in this collection cycle.
-  ref_processor()->setup_policy(clear_all_soft_refs);
-
-  // Decide if class unloading should be done
-  update_should_unload_classes();
-
-  bool init_mark_was_synchronous = false; // until proven otherwise
-  while (_collectorState != Idling) {
-    if (TraceCMSState) {
-      gclog_or_tty->print_cr("Thread " INTPTR_FORMAT " in CMS state %d",
-        Thread::current(), _collectorState);
-    }
-    switch (_collectorState) {
-      case InitialMarking:
-        register_foreground_gc_start(cause);
-        init_mark_was_synchronous = true;  // fact to be exploited in re-mark
-        checkpointRootsInitial(false);
-        assert(_collectorState == Marking, "Collector state should have changed"
-          " within checkpointRootsInitial()");
-        break;
-      case Marking:
-        // initial marking in checkpointRootsInitialWork has been completed
-        if (VerifyDuringGC &&
-            GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
-          Universe::verify("Verify before initial mark: ");
-        }
-        {
-          bool res = markFromRoots(false);
-          assert(res && _collectorState == FinalMarking, "Collector state should "
-            "have changed");
-          break;
-        }
-      case FinalMarking:
-        if (VerifyDuringGC &&
-            GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
-          Universe::verify("Verify before re-mark: ");
-        }
-        checkpointRootsFinal(false, clear_all_soft_refs,
-                             init_mark_was_synchronous);
-        assert(_collectorState == Sweeping, "Collector state should not "
-          "have changed within checkpointRootsFinal()");
-        break;
-      case Sweeping:
-        // final marking in checkpointRootsFinal has been completed
-        if (VerifyDuringGC &&
-            GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
-          Universe::verify("Verify before sweep: ");
-        }
-        sweep(false);
-        assert(_collectorState == Resizing, "Incorrect state");
-        break;
-      case Resizing: {
-        // Sweeping has been completed; the actual resize in this case
-        // is done separately; nothing to be done in this state.
-        _collectorState = Resetting;
-        break;
-      }
-      case Resetting:
-        // The heap has been resized.
-        if (VerifyDuringGC &&
-            GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
-          Universe::verify("Verify before reset: ");
-        }
-        save_heap_summary();
-        reset(false);
-        assert(_collectorState == Idling, "Collector state should "
-          "have changed");
-        break;
-      case Precleaning:
-      case AbortablePreclean:
-        // Elide the preclean phase
-        _collectorState = FinalMarking;
-        break;
-      default:
-        ShouldNotReachHere();
-    }
-    if (TraceCMSState) {
-      gclog_or_tty->print_cr("  Thread " INTPTR_FORMAT " done - next CMS state %d",
-        Thread::current(), _collectorState);
-    }
-  }
-
-  if (VerifyAfterGC &&
-      GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
-    Universe::verify();
-  }
-  if (TraceCMSState) {
-    gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT
-      " exiting collection CMS state %d",
-      Thread::current(), _collectorState);
-  }
-}
-
 bool CMSCollector::waitForForegroundGC() {
   bool res = false;
   assert(ConcurrentMarkSweepThread::cms_thread_has_cms_token(),
@@ -3090,7 +2812,7 @@
 }
 
 // YSR: All of this generation expansion/shrinking stuff is an exact copy of
-// OneContigSpaceCardGeneration, which makes me wonder if we should move this
+// TenuredGeneration, which makes me wonder if we should move this
 // to CardGeneration and share it...
 bool ConcurrentMarkSweepGeneration::expand(size_t bytes, size_t expand_bytes) {
   return CardGeneration::expand(bytes, expand_bytes);
@@ -3345,7 +3067,7 @@
 // Checkpoint the roots into this generation from outside
 // this generation. [Note this initial checkpoint need only
 // be approximate -- we'll do a catch up phase subsequently.]
-void CMSCollector::checkpointRootsInitial(bool asynch) {
+void CMSCollector::checkpointRootsInitial() {
   assert(_collectorState == InitialMarking, "Wrong collector state");
   check_correct_thread_executing();
   TraceCMSMemoryManagerStats tms(_collectorState,GenCollectedHeap::heap()->gc_cause());
@@ -3356,32 +3078,19 @@
   ReferenceProcessor* rp = ref_processor();
   SpecializationStats::clear();
   assert(_restart_addr == NULL, "Control point invariant");
-  if (asynch) {
+  {
     // acquire locks for subsequent manipulations
     MutexLockerEx x(bitMapLock(),
                     Mutex::_no_safepoint_check_flag);
-    checkpointRootsInitialWork(asynch);
+    checkpointRootsInitialWork();
     // enable ("weak") refs discovery
     rp->enable_discovery(true /*verify_disabled*/, true /*check_no_refs*/);
     _collectorState = Marking;
-  } else {
-    // (Weak) Refs discovery: this is controlled from genCollectedHeap::do_collection
-    // which recognizes if we are a CMS generation, and doesn't try to turn on
-    // discovery; verify that they aren't meddling.
-    assert(!rp->discovery_is_atomic(),
-           "incorrect setting of discovery predicate");
-    assert(!rp->discovery_enabled(), "genCollectedHeap shouldn't control "
-           "ref discovery for this generation kind");
-    // already have locks
-    checkpointRootsInitialWork(asynch);
-    // now enable ("weak") refs discovery
-    rp->enable_discovery(true /*verify_disabled*/, false /*verify_no_refs*/);
-    _collectorState = Marking;
   }
   SpecializationStats::print();
 }
 
-void CMSCollector::checkpointRootsInitialWork(bool asynch) {
+void CMSCollector::checkpointRootsInitialWork() {
   assert(SafepointSynchronize::is_at_safepoint(), "world should be stopped");
   assert(_collectorState == InitialMarking, "just checking");
 
@@ -3483,9 +3192,9 @@
   verify_overflow_empty();
 }
 
-bool CMSCollector::markFromRoots(bool asynch) {
+bool CMSCollector::markFromRoots() {
   // we might be tempted to assert that:
-  // assert(asynch == !SafepointSynchronize::is_at_safepoint(),
+  // assert(!SafepointSynchronize::is_at_safepoint(),
   //        "inconsistent argument?");
   // However that wouldn't be right, because it's possible that
   // a safepoint is indeed in progress as a younger generation
@@ -3494,37 +3203,28 @@
   check_correct_thread_executing();
   verify_overflow_empty();
 
-  bool res;
-  if (asynch) {
-    // Weak ref discovery note: We may be discovering weak
-    // refs in this generation concurrent (but interleaved) with
-    // weak ref discovery by a younger generation collector.
-
-    CMSTokenSyncWithLocks ts(true, bitMapLock());
-    TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-    CMSPhaseAccounting pa(this, "mark", _gc_tracer_cm->gc_id(), !PrintGCDetails);
-    res = markFromRootsWork(asynch);
-    if (res) {
-      _collectorState = Precleaning;
-    } else { // We failed and a foreground collection wants to take over
-      assert(_foregroundGCIsActive, "internal state inconsistency");
-      assert(_restart_addr == NULL,  "foreground will restart from scratch");
-      if (PrintGCDetails) {
-        gclog_or_tty->print_cr("bailing out to foreground collection");
-      }
-    }
-  } else {
-    assert(SafepointSynchronize::is_at_safepoint(),
-           "inconsistent with asynch == false");
-    // already have locks
-    res = markFromRootsWork(asynch);
-    _collectorState = FinalMarking;
+  // Weak ref discovery note: We may be discovering weak
+  // refs in this generation concurrent (but interleaved) with
+  // weak ref discovery by a younger generation collector.
+
+  CMSTokenSyncWithLocks ts(true, bitMapLock());
+  TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
+  CMSPhaseAccounting pa(this, "mark", _gc_tracer_cm->gc_id(), !PrintGCDetails);
+  bool res = markFromRootsWork();
+  if (res) {
+    _collectorState = Precleaning;
+  } else { // We failed and a foreground collection wants to take over
+    assert(_foregroundGCIsActive, "internal state inconsistency");
+    assert(_restart_addr == NULL,  "foreground will restart from scratch");
+    if (PrintGCDetails) {
+      gclog_or_tty->print_cr("bailing out to foreground collection");
+    }
   }
   verify_overflow_empty();
   return res;
 }
 
-bool CMSCollector::markFromRootsWork(bool asynch) {
+bool CMSCollector::markFromRootsWork() {
   // iterate over marked bits in bit map, doing a full scan and mark
   // from these roots using the following algorithm:
   // . if oop is to the right of the current scan pointer,
@@ -3549,9 +3249,9 @@
   verify_overflow_empty();
   bool result = false;
   if (CMSConcurrentMTEnabled && ConcGCThreads > 0) {
-    result = do_marking_mt(asynch);
+    result = do_marking_mt();
   } else {
-    result = do_marking_st(asynch);
+    result = do_marking_st();
   }
   return result;
 }
@@ -3591,7 +3291,6 @@
 class CMSConcMarkingTask: public YieldingFlexibleGangTask {
   CMSCollector* _collector;
   int           _n_workers;                  // requested/desired # workers
-  bool          _asynch;
   bool          _result;
   CompactibleFreeListSpace*  _cms_space;
   char          _pad_front[64];   // padding to ...
@@ -3612,13 +3311,12 @@
  public:
   CMSConcMarkingTask(CMSCollector* collector,
                  CompactibleFreeListSpace* cms_space,
-                 bool asynch,
                  YieldingFlexibleWorkGang* workers,
                  OopTaskQueueSet* task_queues):
     YieldingFlexibleGangTask("Concurrent marking done multi-threaded"),
     _collector(collector),
     _cms_space(cms_space),
-    _asynch(asynch), _n_workers(0), _result(true),
+    _n_workers(0), _result(true),
     _task_queues(task_queues),
     _term(_n_workers, task_queues, _collector),
     _bit_map_lock(collector->bitMapLock())
@@ -3645,8 +3343,7 @@
   void work(uint worker_id);
   bool should_yield() {
     return    ConcurrentMarkSweepThread::should_yield()
-           && !_collector->foregroundGCIsActive()
-           && _asynch;
+           && !_collector->foregroundGCIsActive();
   }
 
   virtual void coordinator_yield();  // stuff done by coordinator
@@ -3878,8 +3575,7 @@
         Par_MarkFromRootsClosure cl(this, _collector, my_span,
                                     &_collector->_markBitMap,
                                     work_queue(i),
-                                    &_collector->_markStack,
-                                    _asynch);
+                                    &_collector->_markStack);
         _collector->_markBitMap.iterate(&cl, my_span.start(), my_span.end());
       } // else nothing to do for this task
     }   // else nothing to do for this task
@@ -4084,7 +3780,7 @@
   _collector->startTimer();
 }
 
-bool CMSCollector::do_marking_mt(bool asynch) {
+bool CMSCollector::do_marking_mt() {
   assert(ConcGCThreads > 0 && conc_workers() != NULL, "precondition");
   int num_workers = AdaptiveSizePolicy::calc_active_conc_workers(
                                        conc_workers()->total_workers(),
@@ -4096,7 +3792,6 @@
 
   CMSConcMarkingTask tsk(this,
                          cms_space,
-                         asynch,
                          conc_workers(),
                          task_queues());
 
@@ -4125,7 +3820,7 @@
     // If _restart_addr is non-NULL, a marking stack overflow
     // occurred; we need to do a fresh marking iteration from the
     // indicated restart address.
-    if (_foregroundGCIsActive && asynch) {
+    if (_foregroundGCIsActive) {
       // We may be running into repeated stack overflows, having
       // reached the limit of the stack size, while making very
       // slow forward progress. It may be best to bail out and
@@ -4154,14 +3849,14 @@
   return true;
 }
 
-bool CMSCollector::do_marking_st(bool asynch) {
+bool CMSCollector::do_marking_st() {
   ResourceMark rm;
   HandleMark   hm;
 
   // Temporarily make refs discovery single threaded (non-MT)
   ReferenceProcessorMTDiscoveryMutator rp_mut_discovery(ref_processor(), false);
   MarkFromRootsClosure markFromRootsClosure(this, _span, &_markBitMap,
-    &_markStack, CMSYield && asynch);
+    &_markStack, CMSYield);
   // the last argument to iterate indicates whether the iteration
   // should be incremental with periodic yields.
   _markBitMap.iterate(&markFromRootsClosure);
@@ -4169,7 +3864,7 @@
   // occurred; we need to do a fresh iteration from the
   // indicated restart address.
   while (_restart_addr != NULL) {
-    if (_foregroundGCIsActive && asynch) {
+    if (_foregroundGCIsActive) {
       // We may be running into repeated stack overflows, having
       // reached the limit of the stack size, while making very
       // slow forward progress. It may be best to bail out and
@@ -4390,10 +4085,6 @@
   }
 
   if (clean_survivor) {  // preclean the active survivor space(s)
-    assert(_young_gen->kind() == Generation::DefNew ||
-           _young_gen->kind() == Generation::ParNew,
-         "incorrect type for cast");
-    DefNewGeneration* dng = (DefNewGeneration*)_young_gen;
     PushAndMarkClosure pam_cl(this, _span, ref_processor(),
                              &_markBitMap, &_modUnionTable,
                              &_markStack, true /* precleaning phase */);
@@ -4406,8 +4097,8 @@
     SurvivorSpacePrecleanClosure
       sss_cl(this, _span, &_markBitMap, &_markStack,
              &pam_cl, before_count, CMSYield);
-    dng->from()->object_iterate_careful(&sss_cl);
-    dng->to()->object_iterate_careful(&sss_cl);
+    _young_gen->from()->object_iterate_careful(&sss_cl);
+    _young_gen->to()->object_iterate_careful(&sss_cl);
   }
   MarkRefsIntoAndScanClosure
     mrias_cl(_span, ref_processor(), &_markBitMap, &_modUnionTable,
@@ -4703,8 +4394,7 @@
   verify_overflow_empty();
 }
 
-void CMSCollector::checkpointRootsFinal(bool asynch,
-  bool clear_all_soft_refs, bool init_mark_was_synchronous) {
+void CMSCollector::checkpointRootsFinal() {
   assert(_collectorState == FinalMarking, "incorrect state transition?");
   check_correct_thread_executing();
   // world is stopped at this checkpoint
@@ -4721,7 +4411,7 @@
                         _young_gen->used() / K,
                         _young_gen->capacity() / K);
   }
-  if (asynch) {
+  {
     if (CMSScavengeBeforeRemark) {
       GenCollectedHeap* gch = GenCollectedHeap::heap();
       // Temporarily set flag to false, GCH->do_collection will
@@ -4742,21 +4432,14 @@
     FreelistLocker x(this);
     MutexLockerEx y(bitMapLock(),
                     Mutex::_no_safepoint_check_flag);
-    assert(!init_mark_was_synchronous, "but that's impossible!");
-    checkpointRootsFinalWork(asynch, clear_all_soft_refs, false);
-  } else {
-    // already have all the locks
-    checkpointRootsFinalWork(asynch, clear_all_soft_refs,
-                             init_mark_was_synchronous);
+    checkpointRootsFinalWork();
   }
   verify_work_stacks_empty();
   verify_overflow_empty();
   SpecializationStats::print();
 }
 
-void CMSCollector::checkpointRootsFinalWork(bool asynch,
-  bool clear_all_soft_refs, bool init_mark_was_synchronous) {
-
+void CMSCollector::checkpointRootsFinalWork() {
   NOT_PRODUCT(GCTraceTime tr("checkpointRootsFinalWork", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());)
 
   assert(haveFreelistLocks(), "must have free list locks");
@@ -4773,60 +4456,54 @@
   assert(haveFreelistLocks(), "must have free list locks");
   assert_lock_strong(bitMapLock());
 
-  if (!init_mark_was_synchronous) {
-    // We might assume that we need not fill TLAB's when
-    // CMSScavengeBeforeRemark is set, because we may have just done
-    // a scavenge which would have filled all TLAB's -- and besides
-    // Eden would be empty. This however may not always be the case --
-    // for instance although we asked for a scavenge, it may not have
-    // happened because of a JNI critical section. We probably need
-    // a policy for deciding whether we can in that case wait until
-    // the critical section releases and then do the remark following
-    // the scavenge, and skip it here. In the absence of that policy,
-    // or of an indication of whether the scavenge did indeed occur,
-    // we cannot rely on TLAB's having been filled and must do
-    // so here just in case a scavenge did not happen.
-    gch->ensure_parsability(false);  // fill TLAB's, but no need to retire them
-    // Update the saved marks which may affect the root scans.
-    gch->save_marks();
-
-    if (CMSPrintEdenSurvivorChunks) {
-      print_eden_and_survivor_chunk_arrays();
-    }
-
-    {
-      COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
-
-      // Note on the role of the mod union table:
-      // Since the marker in "markFromRoots" marks concurrently with
-      // mutators, it is possible for some reachable objects not to have been
-      // scanned. For instance, an only reference to an object A was
-      // placed in object B after the marker scanned B. Unless B is rescanned,
-      // A would be collected. Such updates to references in marked objects
-      // are detected via the mod union table which is the set of all cards
-      // dirtied since the first checkpoint in this GC cycle and prior to
-      // the most recent young generation GC, minus those cleaned up by the
-      // concurrent precleaning.
-      if (CMSParallelRemarkEnabled && CollectedHeap::use_parallel_gc_threads()) {
-        GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());
-        do_remark_parallel();
-      } else {
-        GCTraceTime t("Rescan (non-parallel) ", PrintGCDetails, false,
-                    _gc_timer_cm, _gc_tracer_cm->gc_id());
-        do_remark_non_parallel();
-      }
-    }
-  } else {
-    assert(!asynch, "Can't have init_mark_was_synchronous in asynch mode");
-    // The initial mark was stop-world, so there's no rescanning to
-    // do; go straight on to the next step below.
+  // We might assume that we need not fill TLAB's when
+  // CMSScavengeBeforeRemark is set, because we may have just done
+  // a scavenge which would have filled all TLAB's -- and besides
+  // Eden would be empty. This however may not always be the case --
+  // for instance although we asked for a scavenge, it may not have
+  // happened because of a JNI critical section. We probably need
+  // a policy for deciding whether we can in that case wait until
+  // the critical section releases and then do the remark following
+  // the scavenge, and skip it here. In the absence of that policy,
+  // or of an indication of whether the scavenge did indeed occur,
+  // we cannot rely on TLAB's having been filled and must do
+  // so here just in case a scavenge did not happen.
+  gch->ensure_parsability(false);  // fill TLAB's, but no need to retire them
+  // Update the saved marks which may affect the root scans.
+  gch->save_marks();
+
+  if (CMSPrintEdenSurvivorChunks) {
+    print_eden_and_survivor_chunk_arrays();
+  }
+
+  {
+    COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
+
+    // Note on the role of the mod union table:
+    // Since the marker in "markFromRoots" marks concurrently with
+    // mutators, it is possible for some reachable objects not to have been
+    // scanned. For instance, an only reference to an object A was
+    // placed in object B after the marker scanned B. Unless B is rescanned,
+    // A would be collected. Such updates to references in marked objects
+    // are detected via the mod union table which is the set of all cards
+    // dirtied since the first checkpoint in this GC cycle and prior to
+    // the most recent young generation GC, minus those cleaned up by the
+    // concurrent precleaning.
+    if (CMSParallelRemarkEnabled && CollectedHeap::use_parallel_gc_threads()) {
+      GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());
+      do_remark_parallel();
+    } else {
+      GCTraceTime t("Rescan (non-parallel) ", PrintGCDetails, false,
+                  _gc_timer_cm, _gc_tracer_cm->gc_id());
+      do_remark_non_parallel();
+    }
   }
   verify_work_stacks_empty();
   verify_overflow_empty();
 
   {
     NOT_PRODUCT(GCTraceTime ts("refProcessingWork", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());)
-    refProcessingWork(asynch, clear_all_soft_refs);
+    refProcessingWork();
   }
   verify_work_stacks_empty();
   verify_overflow_empty();
@@ -5006,10 +4683,10 @@
 };
 
 void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl) {
-  DefNewGeneration* dng = _collector->_young_gen->as_DefNewGeneration();
-  ContiguousSpace* eden_space = dng->eden();
-  ContiguousSpace* from_space = dng->from();
-  ContiguousSpace* to_space   = dng->to();
+  ParNewGeneration* young_gen = _collector->_young_gen;
+  ContiguousSpace* eden_space = young_gen->eden();
+  ContiguousSpace* from_space = young_gen->from();
+  ContiguousSpace* to_space   = young_gen->to();
 
   HeapWord** eca = _collector->_eden_chunk_array;
   size_t     ect = _collector->_eden_chunk_index;
@@ -5478,11 +5155,10 @@
 CMSCollector::
 initialize_sequential_subtasks_for_young_gen_rescan(int n_threads) {
   assert(n_threads > 0, "Unexpected n_threads argument");
-  DefNewGeneration* dng = (DefNewGeneration*)_young_gen;
 
   // Eden space
-  if (!dng->eden()->is_empty()) {
-    SequentialSubTasksDone* pst = dng->eden()->par_seq_tasks();
+  if (!_young_gen->eden()->is_empty()) {
+    SequentialSubTasksDone* pst = _young_gen->eden()->par_seq_tasks();
     assert(!pst->valid(), "Clobbering existing data?");
     // Each valid entry in [0, _eden_chunk_index) represents a task.
     size_t n_tasks = _eden_chunk_index + 1;
@@ -5495,14 +5171,14 @@
 
   // Merge the survivor plab arrays into _survivor_chunk_array
   if (_survivor_plab_array != NULL) {
-    merge_survivor_plab_arrays(dng->from(), n_threads);
+    merge_survivor_plab_arrays(_young_gen->from(), n_threads);
   } else {
     assert(_survivor_chunk_index == 0, "Error");
   }
 
   // To space
   {
-    SequentialSubTasksDone* pst = dng->to()->par_seq_tasks();
+    SequentialSubTasksDone* pst = _young_gen->to()->par_seq_tasks();
     assert(!pst->valid(), "Clobbering existing data?");
     // Sets the condition for completion of the subtask (how many threads
     // need to finish in order to be done).
@@ -5513,7 +5189,7 @@
 
   // From space
   {
-    SequentialSubTasksDone* pst = dng->from()->par_seq_tasks();
+    SequentialSubTasksDone* pst = _young_gen->from()->par_seq_tasks();
     assert(!pst->valid(), "Clobbering existing data?");
     size_t n_tasks = _survivor_chunk_index + 1;
     assert(n_tasks == 1 || _survivor_chunk_array != NULL, "Error");
@@ -5872,8 +5548,7 @@
   workers->run_task(&enq_task);
 }
 
-void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) {
-
+void CMSCollector::refProcessingWork() {
   ResourceMark rm;
   HandleMark   hm;
 
@@ -5881,7 +5556,7 @@
   assert(rp->span().equals(_span), "Spans should be equal");
   assert(!rp->enqueuing_is_done(), "Enqueuing should not be complete");
   // Process weak references.
-  rp->setup_policy(clear_all_soft_refs);
+  rp->setup_policy(false);
   verify_work_stacks_empty();
 
   CMSKeepAliveClosure cmsKeepAliveClosure(this, _span, &_markBitMap,
@@ -6005,7 +5680,7 @@
 }
 #endif
 
-void CMSCollector::sweep(bool asynch) {
+void CMSCollector::sweep() {
   assert(_collectorState == Sweeping, "just checking");
   check_correct_thread_executing();
   verify_work_stacks_empty();
@@ -6019,14 +5694,14 @@
   assert(!_intra_sweep_timer.is_active(), "Should not be active");
   _intra_sweep_timer.reset();
   _intra_sweep_timer.start();
-  if (asynch) {
+  {
     TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
     CMSPhaseAccounting pa(this, "sweep", _gc_tracer_cm->gc_id(), !PrintGCDetails);
     // First sweep the old gen
     {
       CMSTokenSyncWithLocks ts(true, _cmsGen->freelistLock(),
                                bitMapLock());
-      sweepWork(_cmsGen, asynch);
+      sweepWork(_cmsGen);
     }
 
     // Update Universe::_heap_*_at_gc figures.
@@ -6040,13 +5715,6 @@
       Universe::update_heap_info_at_gc();
       _collectorState = Resizing;
     }
-  } else {
-    // already have needed locks
-    sweepWork(_cmsGen,  asynch);
-    // Update heap occupancy information which is used as
-    // input to soft ref clearing policy at the next gc.
-    Universe::update_heap_info_at_gc();
-    _collectorState = Resizing;
   }
   verify_work_stacks_empty();
   verify_overflow_empty();
@@ -6139,20 +5807,7 @@
   }
 }
 
-void ConcurrentMarkSweepGeneration::rotate_debug_collection_type() {
-  if (PrintGCDetails && Verbose) {
-    gclog_or_tty->print("Rotate from %d ", _debug_collection_type);
-  }
-  _debug_collection_type = (CollectionTypes) (_debug_collection_type + 1);
-  _debug_collection_type =
-    (CollectionTypes) (_debug_collection_type % Unknown_collection_type);
-  if (PrintGCDetails && Verbose) {
-    gclog_or_tty->print_cr("to %d ", _debug_collection_type);
-  }
-}
-
-void CMSCollector::sweepWork(ConcurrentMarkSweepGeneration* gen,
-  bool asynch) {
+void CMSCollector::sweepWork(ConcurrentMarkSweepGeneration* gen) {
   // We iterate over the space(s) underlying this generation,
   // checking the mark bit map to see if the bits corresponding
   // to specific blocks are marked or not. Blocks that are
@@ -6180,9 +5835,7 @@
 
   // check that we hold the requisite locks
   assert(have_cms_token(), "Should hold cms token");
-  assert(   (asynch && ConcurrentMarkSweepThread::cms_thread_has_cms_token())
-         || (!asynch && ConcurrentMarkSweepThread::vm_thread_has_cms_token()),
-        "Should possess CMS token to sweep");
+  assert(ConcurrentMarkSweepThread::cms_thread_has_cms_token(), "Should possess CMS token to sweep");
   assert_lock_strong(gen->freelistLock());
   assert_lock_strong(bitMapLock());
 
@@ -6194,8 +5847,7 @@
   gen->setNearLargestChunk();
 
   {
-    SweepClosure sweepClosure(this, gen, &_markBitMap,
-                            CMSYield && asynch);
+    SweepClosure sweepClosure(this, gen, &_markBitMap, CMSYield);
     gen->cmsSpace()->blk_iterate_careful(&sweepClosure);
     // We need to free-up/coalesce garbage/blocks from a
     // co-terminal free run. This is done in the SweepClosure
@@ -6213,8 +5865,8 @@
 
 // Reset CMS data structures (for now just the marking bit map)
 // preparatory for the next cycle.
-void CMSCollector::reset(bool asynch) {
-  if (asynch) {
+void CMSCollector::reset(bool concurrent) {
+  if (concurrent) {
     CMSTokenSyncWithLocks ts(true, bitMapLock());
 
     // If the state is not "Resetting", the foreground  thread
@@ -6275,17 +5927,10 @@
     _collectorState = Idling;
   }
 
-  NOT_PRODUCT(
-    if (RotateCMSCollectionTypes) {
-      _cmsGen->rotate_debug_collection_type();
-    }
-  )
-
   register_gc_end();
 }
 
 void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) {
-  gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
   TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
   GCTraceTime t(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer_cm->gc_id());
   TraceCollectorStats tcs(counters());
@@ -6293,7 +5938,7 @@
   switch (op) {
     case CMS_op_checkpointRootsInitial: {
       SvcGCMarker sgcm(SvcGCMarker::OTHER);
-      checkpointRootsInitial(true);       // asynch
+      checkpointRootsInitial();
       if (PrintGC) {
         _cmsGen->printOccupancy("initial-mark");
       }
@@ -6301,9 +5946,7 @@
     }
     case CMS_op_checkpointRootsFinal: {
       SvcGCMarker sgcm(SvcGCMarker::OTHER);
-      checkpointRootsFinal(true,    // asynch
-                           false,   // !clear_all_soft_refs
-                           false);  // !init_mark_was_synchronous
+      checkpointRootsFinal();
       if (PrintGC) {
         _cmsGen->printOccupancy("remark");
       }
@@ -7193,8 +6836,7 @@
                        CMSCollector* collector, MemRegion span,
                        CMSBitMap* bit_map,
                        OopTaskQueue* work_queue,
-                       CMSMarkStack*  overflow_stack,
-                       bool should_yield):
+                       CMSMarkStack*  overflow_stack):
   _collector(collector),
   _whole_span(collector->_span),
   _span(span),
@@ -7202,7 +6844,6 @@
   _mut(&collector->_modUnionTable),
   _work_queue(work_queue),
   _overflow_stack(overflow_stack),
-  _yield(should_yield),
   _skip_bits(0),
   _task(task)
 {
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -608,7 +608,6 @@
   GCHeapSummary _last_heap_summary;
   MetaspaceSummary _last_metaspace_summary;
 
-  void register_foreground_gc_start(GCCause::Cause cause);
   void register_gc_start(GCCause::Cause cause);
   void register_gc_end();
   void save_heap_summary();
@@ -695,8 +694,6 @@
   int    _numYields;
   size_t _numDirtyCards;
   size_t _sweep_count;
-  // Number of full gc's since the last concurrent gc.
-  uint   _full_gcs_since_conc_gc;
 
   // Occupancy used for bootstrapping stats
   double _bootstrap_occupancy;
@@ -724,7 +721,8 @@
 
  private:
   // Support for parallelizing young gen rescan in CMS remark phase
-  Generation* _young_gen;  // the younger gen
+  ParNewGeneration* _young_gen;  // the younger gen
+
   HeapWord** _top_addr;    // ... Top of Eden
   HeapWord** _end_addr;    // ... End of Eden
   Mutex*     _eden_chunk_lock;
@@ -760,14 +758,14 @@
   NOT_PRODUCT(bool par_simulate_overflow();)   // MT version
 
   // CMS work methods
-  void checkpointRootsInitialWork(bool asynch); // Initial checkpoint work
+  void checkpointRootsInitialWork(); // Initial checkpoint work
 
   // A return value of false indicates failure due to stack overflow
-  bool markFromRootsWork(bool asynch);  // Concurrent marking work
+  bool markFromRootsWork();  // Concurrent marking work
 
  public:   // FIX ME!!! only for testing
-  bool do_marking_st(bool asynch);      // Single-threaded marking
-  bool do_marking_mt(bool asynch);      // Multi-threaded  marking
+  bool do_marking_st();      // Single-threaded marking
+  bool do_marking_mt();      // Multi-threaded  marking
 
  private:
 
@@ -788,20 +786,19 @@
   void reset_survivor_plab_arrays();
 
   // Final (second) checkpoint work
-  void checkpointRootsFinalWork(bool asynch, bool clear_all_soft_refs,
-                                bool init_mark_was_synchronous);
+  void checkpointRootsFinalWork();
   // Work routine for parallel version of remark
   void do_remark_parallel();
   // Work routine for non-parallel version of remark
   void do_remark_non_parallel();
   // Reference processing work routine (during second checkpoint)
-  void refProcessingWork(bool asynch, bool clear_all_soft_refs);
+  void refProcessingWork();
 
   // Concurrent sweeping work
-  void sweepWork(ConcurrentMarkSweepGeneration* gen, bool asynch);
+  void sweepWork(ConcurrentMarkSweepGeneration* gen);
 
   // (Concurrent) resetting of support data structures
-  void reset(bool asynch);
+  void reset(bool concurrent);
 
   // Clear _expansion_cause fields of constituent generations
   void clear_expansion_cause();
@@ -810,22 +807,10 @@
   // used regions of each generation to limit the extent of sweep
   void save_sweep_limits();
 
-  // A work method used by foreground collection to determine
-  // what type of collection (compacting or not, continuing or fresh)
-  // it should do.
-  void decide_foreground_collection_type(bool clear_all_soft_refs,
-    bool* should_compact, bool* should_start_over);
-
   // A work method used by the foreground collector to do
   // a mark-sweep-compact.
   void do_compaction_work(bool clear_all_soft_refs);
 
-  // A work method used by the foreground collector to do
-  // a mark-sweep, after taking over from a possibly on-going
-  // concurrent mark-sweep collection.
-  void do_mark_sweep_work(bool clear_all_soft_refs,
-    CollectorState first_state, bool should_start_over);
-
   // Work methods for reporting concurrent mode interruption or failure
   bool is_external_interruption();
   void report_concurrent_mode_interruption();
@@ -868,15 +853,13 @@
   // Locking checks
   NOT_PRODUCT(static bool have_cms_token();)
 
-  // XXXPERM bool should_collect(bool full, size_t size, bool tlab);
   bool shouldConcurrentCollect();
 
   void collect(bool   full,
                bool   clear_all_soft_refs,
                size_t size,
                bool   tlab);
-  void collect_in_background(bool clear_all_soft_refs, GCCause::Cause cause);
-  void collect_in_foreground(bool clear_all_soft_refs, GCCause::Cause cause);
+  void collect_in_background(GCCause::Cause cause);
 
   // In support of ExplicitGCInvokesConcurrent
   static void request_full_gc(unsigned int full_gc_count, GCCause::Cause cause);
@@ -928,18 +911,16 @@
   void directAllocated(HeapWord* start, size_t size);
 
   // Main CMS steps and related support
-  void checkpointRootsInitial(bool asynch);
-  bool markFromRoots(bool asynch);  // a return value of false indicates failure
-                                    // due to stack overflow
+  void checkpointRootsInitial();
+  bool markFromRoots();  // a return value of false indicates failure
+                         // due to stack overflow
   void preclean();
-  void checkpointRootsFinal(bool asynch, bool clear_all_soft_refs,
-                            bool init_mark_was_synchronous);
-  void sweep(bool asynch);
+  void checkpointRootsFinal();
+  void sweep();
 
   // Check that the currently executing thread is the expected
   // one (foreground collector or background collector).
   static void check_correct_thread_executing() PRODUCT_RETURN;
-  // XXXPERM void print_statistics()           PRODUCT_RETURN;
 
   bool is_cms_reachable(HeapWord* addr);
 
@@ -1060,15 +1041,6 @@
   // In support of MinChunkSize being larger than min object size
   const double _dilatation_factor;
 
-  enum CollectionTypes {
-    Concurrent_collection_type          = 0,
-    MS_foreground_collection_type       = 1,
-    MSC_foreground_collection_type      = 2,
-    Unknown_collection_type             = 3
-  };
-
-  CollectionTypes _debug_collection_type;
-
   // True if a compacting collection was done.
   bool _did_compact;
   bool did_compact() { return _did_compact; }
@@ -1152,7 +1124,7 @@
   // hack to allow the collection of the younger gen first if the flag is
   // set.
   virtual bool full_collects_younger_generations() const {
-    return UseCMSCompactAtFullCollection && !ScavengeBeforeFullGC;
+    return !ScavengeBeforeFullGC;
   }
 
   void space_iterate(SpaceClosure* blk, bool usedOnly = false);
@@ -1180,9 +1152,6 @@
   // Overrides for parallel promotion.
   virtual oop par_promote(int thread_num,
                           oop obj, markOop m, size_t word_sz);
-  // This one should not be called for CMS.
-  virtual void par_promote_alloc_undo(int thread_num,
-                                      HeapWord* obj, size_t word_sz);
   virtual void par_promote_alloc_done(int thread_num);
   virtual void par_oop_since_save_marks_iterate_done(int thread_num);
 
@@ -1285,8 +1254,6 @@
   virtual const char* short_name() const { return "CMS"; }
   void        print() const;
   void printOccupancy(const char* s);
-  bool must_be_youngest() const { return false; }
-  bool must_be_oldest()   const { return true; }
 
   // Resize the generation after a compacting GC.  The
   // generation can be treated as a contiguous space
@@ -1295,9 +1262,6 @@
   // Resize the generation after a non-compacting
   // collection.
   void compute_new_size_free_list();
-
-  CollectionTypes debug_collection_type() { return _debug_collection_type; }
-  void rotate_debug_collection_type();
 };
 
 //
@@ -1344,7 +1308,6 @@
   CMSBitMap*     _mut;
   OopTaskQueue*  _work_queue;
   CMSMarkStack*  _overflow_stack;
-  bool           _yield;
   int            _skip_bits;
   HeapWord*      _finger;
   HeapWord*      _threshold;
@@ -1354,8 +1317,7 @@
                        MemRegion span,
                        CMSBitMap* bit_map,
                        OopTaskQueue* work_queue,
-                       CMSMarkStack*  overflow_stack,
-                       bool should_yield);
+                       CMSMarkStack*  overflow_stack);
   bool do_bit(size_t offset);
   inline void do_yield_check();
 
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -29,8 +29,9 @@
 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
+#include "gc_implementation/parNew/parNewGeneration.hpp"
 #include "gc_implementation/shared/gcUtil.hpp"
-#include "memory/defNewGeneration.hpp"
+#include "memory/genCollectedHeap.hpp"
 
 inline void CMSBitMap::clear_all() {
   assert_locked();
@@ -257,11 +258,11 @@
 }
 
 inline size_t CMSCollector::get_eden_used() const {
-  return _young_gen->as_DefNewGeneration()->eden()->used();
+  return _young_gen->eden()->used();
 }
 
 inline size_t CMSCollector::get_eden_capacity() const {
-  return _young_gen->as_DefNewGeneration()->eden()->capacity();
+  return _young_gen->eden()->capacity();
 }
 
 inline bool CMSStats::valid() const {
@@ -398,8 +399,7 @@
 
 inline void Par_MarkFromRootsClosure::do_yield_check() {
   if (ConcurrentMarkSweepThread::should_yield() &&
-      !_collector->foregroundGCIsActive() &&
-      _yield) {
+      !_collector->foregroundGCIsActive()) {
     do_yield_work();
   }
 }
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -134,7 +134,7 @@
     if (_should_terminate) break;
     GCCause::Cause cause = _collector->_full_gc_requested ?
       _collector->_full_gc_cause : GCCause::_cms_concurrent_mark;
-    _collector->collect_in_background(false, cause);
+    _collector->collect_in_background(cause);
   }
   assert(_should_terminate, "just checking");
   // Check that the state of any protocol for synchronization
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -42,8 +42,12 @@
 void VM_CMS_Operation::acquire_pending_list_lock() {
   // The caller may block while communicating
   // with the SLT thread in order to acquire/release the PLL.
-  ConcurrentMarkSweepThread::slt()->
-    manipulatePLL(SurrogateLockerThread::acquirePLL);
+  SurrogateLockerThread* slt = ConcurrentMarkSweepThread::slt();
+  if (slt != NULL) {
+    slt->manipulatePLL(SurrogateLockerThread::acquirePLL);
+  } else {
+    SurrogateLockerThread::report_missing_slt();
+  }
 }
 
 void VM_CMS_Operation::release_and_notify_pending_list_lock() {
--- a/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -107,7 +107,7 @@
     for (uint i = 0; i < _n_threads; i++) {
       delete _threads[i];
     }
-    FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads, mtGC);
+    FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads);
   }
 }
 
--- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -180,9 +180,32 @@
   }
 };
 
+class ParClearNextMarkBitmapTask : public AbstractGangTask {
+  ClearBitmapHRClosure* _cl;
+  HeapRegionClaimer     _hrclaimer;
+  bool                  _suspendible; // If the task is suspendible, workers must join the STS.
+
+public:
+  ParClearNextMarkBitmapTask(ClearBitmapHRClosure *cl, uint n_workers, bool suspendible) :
+      _cl(cl), _suspendible(suspendible), AbstractGangTask("Parallel Clear Bitmap Task"), _hrclaimer(n_workers) {}
+
+  void work(uint worker_id) {
+    if (_suspendible) {
+      SuspendibleThreadSet::join();
+    }
+    G1CollectedHeap::heap()->heap_region_par_iterate(_cl, worker_id, &_hrclaimer, true);
+    if (_suspendible) {
+      SuspendibleThreadSet::leave();
+    }
+  }
+};
+
 void CMBitMap::clearAll() {
+  G1CollectedHeap* g1h = G1CollectedHeap::heap();
   ClearBitmapHRClosure cl(NULL, this, false /* may_yield */);
-  G1CollectedHeap::heap()->heap_region_iterate(&cl);
+  uint n_workers = g1h->workers()->active_workers();
+  ParClearNextMarkBitmapTask task(&cl, n_workers, false);
+  g1h->workers()->run_task(&task);
   guarantee(cl.complete(), "Must have completed iteration.");
   return;
 }
@@ -861,7 +884,8 @@
   guarantee(!g1h->mark_in_progress(), "invariant");
 
   ClearBitmapHRClosure cl(this, _nextMarkBitMap, true /* may_yield */);
-  g1h->heap_region_iterate(&cl);
+  ParClearNextMarkBitmapTask task(&cl, parallel_marking_threads(), true);
+  _parallel_workers->run_task(&task);
 
   // Clear the liveness counting data. If the marking has been aborted, the abort()
   // call already did that.
@@ -2099,6 +2123,7 @@
   // We reclaimed old regions so we should calculate the sizes to make
   // sure we update the old gen/space data.
   g1h->g1mm()->update_sizes();
+  g1h->allocation_context_stats().update_after_mark();
 
   g1h->trace_heap_after_concurrent_cycle();
 }
@@ -3219,7 +3244,6 @@
   _g1h->set_par_threads(n_workers);
   _g1h->workers()->run_task(&g1_par_agg_task);
   _g1h->set_par_threads(0);
-  _g1h->allocation_context_stats().update_at_remark();
 }
 
 // Clear the per-worker arrays used to store the per-region counting data
--- a/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -280,7 +280,6 @@
       // We may have aborted just before the remark. Do not bother clearing the
       // bitmap then, as it has been done during mark abort.
       if (!cm()->has_aborted()) {
-        SuspendibleThreadSetJoiner sts;
         _cm->clearNextBitmap();
       } else {
         assert(!G1VerifyBitmaps || _cm->nextMarkBitmapIsClear(), "Next mark bitmap must be clear");
--- a/src/share/vm/gc_implementation/g1/g1AllocationContext.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1AllocationContext.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -45,7 +45,7 @@
 public:
   inline void clear() { }
   inline void update(bool full_gc) { }
-  inline void update_at_remark() { }
+  inline void update_after_mark() { }
   inline bool available() { return false; }
 };
 
--- a/src/share/vm/gc_implementation/g1/g1Allocator.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1Allocator.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -59,7 +59,7 @@
       !(retained_region->top() == retained_region->end()) &&
       !retained_region->is_empty() &&
       !retained_region->is_humongous()) {
-    retained_region->record_top_and_timestamp();
+    retained_region->record_timestamp();
     // The retained region was added to the old region set when it was
     // retired. We have to remove it now, since we don't allow regions
     // we allocate to in the region sets. We'll re-add it later, when
@@ -94,6 +94,9 @@
   // want either way so no reason to check explicitly for either
   // condition.
   _retained_old_gc_alloc_region = old_gc_alloc_region(context)->release();
+  if (_retained_old_gc_alloc_region != NULL) {
+    _retained_old_gc_alloc_region->record_retained_region();
+  }
 
   if (ResizePLAB) {
     _g1h->_survivor_plab_stats.adjust_desired_plab_sz(no_of_gc_workers);
--- a/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -111,13 +111,13 @@
       // read next before freeing.
       e = e->next();
       unlink_entry(to_remove);
-      FREE_C_HEAP_ARRAY(char, to_remove, mtGC);
+      FREE_C_HEAP_ARRAY(char, to_remove);
     }
   }
   assert(number_of_entries() == 0, "should have removed all entries");
   free_buckets();
   for (BasicHashtableEntry<mtGC>* e = new_entry_free_list(); e != NULL; e = new_entry_free_list()) {
-    FREE_C_HEAP_ARRAY(char, e, mtGC);
+    FREE_C_HEAP_ARRAY(char, e);
   }
 }
 
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1222,7 +1222,6 @@
 
     // Timing
     assert(gc_cause() != GCCause::_java_lang_system_gc || explicit_gc, "invariant");
-    gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps);
     TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
 
     {
@@ -1888,7 +1887,7 @@
   initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
 
   // Create the gen rem set (and barrier set) for the entire reserved region.
-  _rem_set = collector_policy()->create_rem_set(reserved_region(), 2);
+  _rem_set = collector_policy()->create_rem_set(reserved_region());
   set_barrier_set(rem_set()->bs());
   if (!barrier_set()->is_a(BarrierSet::G1SATBCTLogging)) {
     vm_exit_during_initialization("G1 requires a G1SATBLoggingCardTableModRefBS");
@@ -2258,6 +2257,7 @@
     case GCCause::_java_lang_system_gc:     return ExplicitGCInvokesConcurrent;
     case GCCause::_g1_humongous_allocation: return true;
     case GCCause::_update_allocation_context_stats_inc: return true;
+    case GCCause::_wb_conc_mark:            return true;
     default:                                return false;
   }
 }
@@ -2552,8 +2552,9 @@
 void
 G1CollectedHeap::heap_region_par_iterate(HeapRegionClosure* cl,
                                          uint worker_id,
-                                         HeapRegionClaimer *hrclaimer) const {
-  _hrm.par_iterate(cl, worker_id, hrclaimer);
+                                         HeapRegionClaimer *hrclaimer,
+                                         bool concurrent) const {
+  _hrm.par_iterate(cl, worker_id, hrclaimer, concurrent);
 }
 
 // Clear the cached CSet starting regions and (more importantly)
@@ -3561,7 +3562,7 @@
 void
 G1CollectedHeap::cleanup_surviving_young_words() {
   guarantee( _surviving_young_words != NULL, "pre-condition" );
-  FREE_C_HEAP_ARRAY(size_t, _surviving_young_words, mtGC);
+  FREE_C_HEAP_ARRAY(size_t, _surviving_young_words);
   _surviving_young_words = NULL;
 }
 
@@ -4270,10 +4271,11 @@
 
   if (state == G1CollectedHeap::InCSet) {
     oop forwardee;
-    if (obj->is_forwarded()) {
-      forwardee = obj->forwardee();
+    markOop m = obj->mark();
+    if (m->is_marked()) {
+      forwardee = (oop) m->decode_pointer();
     } else {
-      forwardee = _par_scan_state->copy_to_survivor_space(obj);
+      forwardee = _par_scan_state->copy_to_survivor_space(obj, m);
     }
     assert(forwardee != NULL, "forwardee should not be NULL");
     oopDesc::encode_store_heap_oop(p, forwardee);
@@ -6529,7 +6531,7 @@
       // We really only need to do this for old regions given that we
       // should never scan survivors. But it doesn't hurt to do it
       // for survivors too.
-      new_alloc_region->record_top_and_timestamp();
+      new_alloc_region->record_timestamp();
       if (survivor) {
         new_alloc_region->set_survivor();
         _hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor);
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1380,10 +1380,13 @@
   // in the range [0..max(ParallelGCThreads-1, 1)]. Applies "blk->doHeapRegion"
   // to each of the regions, by attempting to claim the region using the
   // HeapRegionClaimer and, if successful, applying the closure to the claimed
-  // region.
+  // region. The concurrent argument should be set to true if iteration is
+  // performed concurrently, during which no assumptions are made for consistent
+  // attributes of the heap regions (as they might be modified while iterating).
   void heap_region_par_iterate(HeapRegionClosure* cl,
                                uint worker_id,
-                               HeapRegionClaimer* hrclaimer) const;
+                               HeapRegionClaimer* hrclaimer,
+                               bool concurrent = false) const;
 
   // Clear the cached cset start regions and (more importantly)
   // the time stamps. Called when we reset the GC time stamp.
--- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1425,6 +1425,18 @@
 #endif // PRODUCT
 }
 
+bool G1CollectorPolicy::is_young_list_full() {
+  uint young_list_length = _g1->young_list()->length();
+  uint young_list_target_length = _young_list_target_length;
+  return young_list_length >= young_list_target_length;
+}
+
+bool G1CollectorPolicy::can_expand_young_list() {
+  uint young_list_length = _g1->young_list()->length();
+  uint young_list_max_length = _young_list_max_length;
+  return young_list_length < young_list_max_length;
+}
+
 uint G1CollectorPolicy::max_regions(int purpose) {
   switch (purpose) {
     case GCAllocForSurvived:
--- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -26,6 +26,7 @@
 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
 
 #include "gc_implementation/g1/collectionSetChooser.hpp"
+#include "gc_implementation/g1/g1Allocator.hpp"
 #include "gc_implementation/g1/g1MMUTracker.hpp"
 #include "memory/collectorPolicy.hpp"
 
@@ -807,7 +808,7 @@
 
   // If an expansion would be appropriate, because recent GC overhead had
   // exceeded the desired limit, return an amount to expand by.
-  size_t expansion_amount();
+  virtual size_t expansion_amount();
 
   // Print tracing information.
   void print_tracing_info() const;
@@ -826,17 +827,9 @@
 
   size_t young_list_target_length() const { return _young_list_target_length; }
 
-  bool is_young_list_full() {
-    uint young_list_length = _g1->young_list()->length();
-    uint young_list_target_length = _young_list_target_length;
-    return young_list_length >= young_list_target_length;
-  }
+  bool is_young_list_full();
 
-  bool can_expand_young_list() {
-    uint young_list_length = _g1->young_list()->length();
-    uint young_list_max_length = _young_list_max_length;
-    return young_list_length < young_list_max_length;
-  }
+  bool can_expand_young_list();
 
   uint young_list_max_length() {
     return _young_list_max_length;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy_ext.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_EXT_HPP
+#define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_EXT_HPP
+
+#include "gc_implementation/g1/g1CollectorPolicy.hpp"
+
+class G1CollectorPolicyExt : public G1CollectorPolicy { };
+
+#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_EXT_HPP
--- a/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -53,7 +53,7 @@
   }
 
   ~WorkerDataArray() {
-    FREE_C_HEAP_ARRAY(T, _data, mtGC);
+    FREE_C_HEAP_ARRAY(T, _data);
   }
 
   void set(uint worker_i, T value) {
--- a/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
 G1HotCardCache::~G1HotCardCache() {
   if (default_use_cache()) {
     assert(_hot_cache != NULL, "Logic");
-    FREE_C_HEAP_ARRAY(jbyte*, _hot_cache, mtGC);
+    FREE_C_HEAP_ARRAY(jbyte*, _hot_cache);
   }
 }
 
--- a/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -65,7 +65,7 @@
 G1ParScanThreadState::~G1ParScanThreadState() {
   _g1_par_allocator->retire_alloc_buffers();
   delete _g1_par_allocator;
-  FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base, mtGC);
+  FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base);
 }
 
 void
@@ -150,7 +150,8 @@
   } while (!_refs->is_empty());
 }
 
-oop G1ParScanThreadState::copy_to_survivor_space(oop const old) {
+oop G1ParScanThreadState::copy_to_survivor_space(oop const old,
+                                                 markOop const old_mark) {
   size_t word_sz = old->size();
   HeapRegion* from_region = _g1h->heap_region_containing_raw(old);
   // +1 to make the -1 indexes valid...
@@ -158,9 +159,8 @@
   assert( (from_region->is_young() && young_index >  0) ||
          (!from_region->is_young() && young_index == 0), "invariant" );
   G1CollectorPolicy* g1p = _g1h->g1_policy();
-  markOop m = old->mark();
-  int age = m->has_displaced_mark_helper() ? m->displaced_mark_helper()->age()
-                                           : m->age();
+  uint age = old_mark->has_displaced_mark_helper() ? old_mark->displaced_mark_helper()->age()
+                                                   : old_mark->age();
   GCAllocPurpose alloc_purpose = g1p->evacuation_destination(from_region, age,
                                                              word_sz);
   AllocationContext_t context = from_region->allocation_context();
@@ -196,30 +196,22 @@
     alloc_purpose = to_region->is_young() ? GCAllocForSurvived : GCAllocForTenured;
 
     if (g1p->track_object_age(alloc_purpose)) {
-      // We could simply do obj->incr_age(). However, this causes a
-      // performance issue. obj->incr_age() will first check whether
-      // the object has a displaced mark by checking its mark word;
-      // getting the mark word from the new location of the object
-      // stalls. So, given that we already have the mark word and we
-      // are about to install it anyway, it's better to increase the
-      // age on the mark word, when the object does not have a
-      // displaced mark word. We're not expecting many objects to have
-      // a displaced marked word, so that case is not optimized
-      // further (it could be...) and we simply call obj->incr_age().
-
-      if (m->has_displaced_mark_helper()) {
-        // in this case, we have to install the mark word first,
+      if (age < markOopDesc::max_age) {
+        age++;
+      }
+      if (old_mark->has_displaced_mark_helper()) {
+        // In this case, we have to install the mark word first,
         // otherwise obj looks to be forwarded (the old mark word,
         // which contains the forward pointer, was copied)
-        obj->set_mark(m);
-        obj->incr_age();
+        obj->set_mark(old_mark);
+        markOop new_mark = old_mark->displaced_mark_helper()->set_age(age);
+        old_mark->set_displaced_mark_helper(new_mark);
       } else {
-        m = m->incr_age();
-        obj->set_mark(m);
+        obj->set_mark(old_mark->set_age(age));
       }
-      age_table()->add(obj, word_sz);
+      age_table()->add(age, word_sz);
     } else {
-      obj->set_mark(m);
+      obj->set_mark(old_mark);
     }
 
     if (G1StringDedup::is_enabled()) {
--- a/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -195,7 +195,7 @@
   inline void dispatch_reference(StarTask ref);
  public:
 
-  oop copy_to_survivor_space(oop const obj);
+  oop copy_to_survivor_space(oop const obj, markOop const old_mark);
 
   void trim_queue();
 
--- a/src/share/vm/gc_implementation/g1/g1ParScanThreadState.inline.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1ParScanThreadState.inline.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -41,10 +41,11 @@
   G1CollectedHeap::in_cset_state_t in_cset_state = _g1h->in_cset_state(obj);
   if (in_cset_state == G1CollectedHeap::InCSet) {
     oop forwardee;
-    if (obj->is_forwarded()) {
-      forwardee = obj->forwardee();
+    markOop m = obj->mark();
+    if (m->is_marked()) {
+      forwardee = (oop) m->decode_pointer();
     } else {
-      forwardee = copy_to_survivor_space(obj);
+      forwardee = copy_to_survivor_space(obj, m);
     }
     oopDesc::encode_store_heap_oop(p, forwardee);
   } else if (in_cset_state == G1CollectedHeap::IsHumongous) {
--- a/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -94,7 +94,7 @@
   for (uint i = 0; i < n_workers(); i++) {
     assert(_cset_rs_update_cl[i] == NULL, "it should be");
   }
-  FREE_C_HEAP_ARRAY(OopsInHeapRegionClosure*, _cset_rs_update_cl, mtGC);
+  FREE_C_HEAP_ARRAY(OopsInHeapRegionClosure*, _cset_rs_update_cl);
 }
 
 class ScanRSClosure : public HeapRegionClosure {
@@ -140,11 +140,9 @@
 
     // Set the "from" region in the closure.
     _oc->set_region(r);
-    HeapWord* card_start = _bot_shared->address_for_index(index);
-    HeapWord* card_end = card_start + G1BlockOffsetSharedArray::N_words;
-    Space *sp = SharedHeap::heap()->space_containing(card_start);
-    MemRegion sm_region = sp->used_region_at_save_marks();
-    MemRegion mr = sm_region.intersection(MemRegion(card_start,card_end));
+    MemRegion card_region(_bot_shared->address_for_index(index), G1BlockOffsetSharedArray::N_words);
+    MemRegion pre_gc_allocated(r->bottom(), r->scan_top());
+    MemRegion mr = pre_gc_allocated.intersection(card_region);
     if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) {
       // We make the card as "claimed" lazily (so races are possible
       // but they're benign), which reduces the number of duplicate
@@ -353,7 +351,7 @@
   for (uint i = 0; i < n_workers(); ++i) {
     _total_cards_scanned += _cards_scanned[i];
   }
-  FREE_C_HEAP_ARRAY(size_t, _cards_scanned, mtGC);
+  FREE_C_HEAP_ARRAY(size_t, _cards_scanned);
   _cards_scanned = NULL;
   // Cleanup after copy
   _g1->set_refine_cte_cl_concurrency(true);
--- a/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1RemSetSummary.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@
 
   void free_and_null() {
     if (_rs_threads_vtimes) {
-      FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes, mtGC);
+      FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
       _rs_threads_vtimes = NULL;
       _num_vtimes = 0;
     }
--- a/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -32,9 +32,8 @@
 #include "runtime/orderAccess.inline.hpp"
 #include "runtime/thread.inline.hpp"
 
-G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(MemRegion whole_heap,
-                                                 int max_covered_regions) :
-    CardTableModRefBSForCTRS(whole_heap, max_covered_regions)
+G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(MemRegion whole_heap) :
+    CardTableModRefBSForCTRS(whole_heap)
 {
   _kind = G1SATBCT;
 }
@@ -132,9 +131,8 @@
 }
 
 G1SATBCardTableLoggingModRefBS::
-G1SATBCardTableLoggingModRefBS(MemRegion whole_heap,
-                               int max_covered_regions) :
-  G1SATBCardTableModRefBS(whole_heap, max_covered_regions),
+G1SATBCardTableLoggingModRefBS(MemRegion whole_heap) :
+  G1SATBCardTableModRefBS(whole_heap),
   _dcqs(JavaThread::dirty_card_queue_set()),
   _listener()
 {
--- a/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -50,8 +50,7 @@
   // pre-marking object graph.
   static void enqueue(oop pre_val);
 
-  G1SATBCardTableModRefBS(MemRegion whole_heap,
-                          int max_covered_regions);
+  G1SATBCardTableModRefBS(MemRegion whole_heap);
 
   bool is_a(BarrierSet::Name bsn) {
     return bsn == BarrierSet::G1SATBCT || CardTableModRefBS::is_a(bsn);
@@ -152,8 +151,7 @@
     return ReservedSpace::allocation_align_size_up(number_of_slots);
   }
 
-  G1SATBCardTableLoggingModRefBS(MemRegion whole_heap,
-                                 int max_covered_regions);
+  G1SATBCardTableLoggingModRefBS(MemRegion whole_heap);
 
   virtual void initialize() { }
   virtual void initialize(G1RegionToSpaceMapper* mapper);
--- a/src/share/vm/gc_implementation/g1/g1StringDedupTable.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/g1StringDedupTable.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -187,7 +187,7 @@
 }
 
 G1StringDedupTable::~G1StringDedupTable() {
-  FREE_C_HEAP_ARRAY(G1StringDedupEntry*, _buckets, mtGC);
+  FREE_C_HEAP_ARRAY(G1StringDedupEntry*, _buckets);
 }
 
 void G1StringDedupTable::create() {
--- a/src/share/vm/gc_implementation/g1/heapRegion.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -326,7 +326,7 @@
 
   hr_clear(false /*par*/, false /*clear_space*/);
   set_top(bottom());
-  record_top_and_timestamp();
+  record_timestamp();
 
   assert(mr.end() == orig_end(),
          err_msg("Given region end address " PTR_FORMAT " should match exactly "
@@ -416,9 +416,9 @@
 
   // If we're within a stop-world GC, then we might look at a card in a
   // GC alloc region that extends onto a GC LAB, which may not be
-  // parseable.  Stop such at the "saved_mark" of the region.
+  // parseable.  Stop such at the "scan_top" of the region.
   if (g1h->is_gc_active()) {
-    mr = mr.intersection(used_region_at_save_marks());
+    mr = mr.intersection(MemRegion(bottom(), scan_top()));
   } else {
     mr = mr.intersection(used_region());
   }
@@ -969,7 +969,7 @@
 
 void G1OffsetTableContigSpace::clear(bool mangle_space) {
   set_top(bottom());
-  set_saved_mark_word(bottom());
+  _scan_top = bottom();
   CompactibleSpace::clear(mangle_space);
   reset_bot();
 }
@@ -1001,38 +1001,42 @@
   return _offsets.threshold();
 }
 
-HeapWord* G1OffsetTableContigSpace::saved_mark_word() const {
+HeapWord* G1OffsetTableContigSpace::scan_top() const {
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  assert( _gc_time_stamp <= g1h->get_gc_time_stamp(), "invariant" );
-  if (_gc_time_stamp < g1h->get_gc_time_stamp())
-    return top();
-  else
-    return Space::saved_mark_word();
+  HeapWord* local_top = top();
+  OrderAccess::loadload();
+  const unsigned local_time_stamp = _gc_time_stamp;
+  assert(local_time_stamp <= g1h->get_gc_time_stamp(), "invariant");
+  if (local_time_stamp < g1h->get_gc_time_stamp()) {
+    return local_top;
+  } else {
+    return _scan_top;
+  }
 }
 
-void G1OffsetTableContigSpace::record_top_and_timestamp() {
+void G1OffsetTableContigSpace::record_timestamp() {
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   unsigned curr_gc_time_stamp = g1h->get_gc_time_stamp();
 
   if (_gc_time_stamp < curr_gc_time_stamp) {
-    // The order of these is important, as another thread might be
-    // about to start scanning this region. If it does so after
-    // set_saved_mark and before _gc_time_stamp = ..., then the latter
-    // will be false, and it will pick up top() as the high water mark
-    // of region. If it does so after _gc_time_stamp = ..., then it
-    // will pick up the right saved_mark_word() as the high water mark
-    // of the region. Either way, the behavior will be correct.
-    Space::set_saved_mark_word(top());
-    OrderAccess::storestore();
+    // Setting the time stamp here tells concurrent readers to look at
+    // scan_top to know the maximum allowed address to look at.
+
+    // scan_top should be bottom for all regions except for the
+    // retained old alloc region which should have scan_top == top
+    HeapWord* st = _scan_top;
+    guarantee(st == _bottom || st == _top, "invariant");
+
     _gc_time_stamp = curr_gc_time_stamp;
-    // No need to do another barrier to flush the writes above. If
-    // this is called in parallel with other threads trying to
-    // allocate into the region, the caller should call this while
-    // holding a lock and when the lock is released the writes will be
-    // flushed.
   }
 }
 
+void G1OffsetTableContigSpace::record_retained_region() {
+  // scan_top is the maximum address where it's safe for the next gc to
+  // scan this region.
+  _scan_top = top();
+}
+
 void G1OffsetTableContigSpace::safe_object_iterate(ObjectClosure* blk) {
   object_iterate(blk);
 }
@@ -1060,6 +1064,8 @@
 void G1OffsetTableContigSpace::initialize(MemRegion mr, bool clear_space, bool mangle_space) {
   CompactibleSpace::initialize(mr, clear_space, mangle_space);
   _top = bottom();
+  _scan_top = bottom();
+  set_saved_mark_word(NULL);
   reset_bot();
 }
 
--- a/src/share/vm/gc_implementation/g1/heapRegion.hpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/heapRegion.hpp	Thu Dec 11 15:06:12 2014 -0800
@@ -101,28 +101,25 @@
 // OffsetTableContigSpace.  If the two versions of BlockOffsetTable could
 // be reconciled, then G1OffsetTableContigSpace could go away.
 
-// The idea behind time stamps is the following. Doing a save_marks on
-// all regions at every GC pause is time consuming (if I remember
-// well, 10ms or so). So, we would like to do that only for regions
-// that are GC alloc regions. To achieve this, we use time
-// stamps. For every evacuation pause, G1CollectedHeap generates a
-// unique time stamp (essentially a counter that gets
-// incremented). Every time we want to call save_marks on a region,
-// we set the saved_mark_word to top and also copy the current GC
-// time stamp to the time stamp field of the space. Reading the
-// saved_mark_word involves checking the time stamp of the
-// region. If it is the same as the current GC time stamp, then we
-// can safely read the saved_mark_word field, as it is valid. If the
-// time stamp of the region is not the same as the current GC time
-// stamp, then we instead read top, as the saved_mark_word field is
-// invalid. Time stamps (on the regions and also on the
-// G1CollectedHeap) are reset at every cleanup (we iterate over
-// the regions anyway) and at the end of a Full GC. The current scheme
-// that uses sequential unsigned ints will fail only if we have 4b
+// The idea behind time stamps is the following. We want to keep track of
+// the highest address where it's safe to scan objects for each region.
+// This is only relevant for current GC alloc regions so we keep a time stamp
+// per region to determine if the region has been allocated during the current
+// GC or not. If the time stamp is current we report a scan_top value which
+// was saved at the end of the previous GC for retained alloc regions and which is
+// equal to the bottom for all other regions.
+// There is a race between card scanners and allocating gc workers where we must ensure
+// that card scanners do not read the memory allocated by the gc workers.
+// In order to enforce that, we must not return a value of _top which is more recent than the
+// time stamp. This is due to the fact that a region may become a gc alloc region at
+// some point after we've read the timestamp value as being < the current time stamp.
+// The time stamps are re-initialized to zero at cleanup and at Full GCs.
+// The current scheme that uses sequential unsigned ints will fail only if we have 4b
 // evacuation pauses between two cleanups, which is _highly_ unlikely.
 class G1OffsetTableContigSpace: public CompactibleSpace {
   friend class VMStructs;
   HeapWord* _top;
+  HeapWord* volatile _scan_top;
  protected:
   G1BlockOffsetArrayContigSpace _offsets;
   Mutex _par_alloc_lock;
@@ -166,10 +163,11 @@
   void set_bottom(HeapWord* value);
   void set_end(HeapWord* value);
 
-  virtual HeapWord* saved_mark_word() const;
-  void record_top_and_timestamp();
+  HeapWord* scan_top() const;
+  void record_timestamp();
   void reset_gc_time_stamp() { _gc_time_stamp = 0; }
   unsigned get_gc_time_stamp() { return _gc_time_stamp; }
+  void record_retained_region();
 
   // See the comment above in the declaration of _pre_dummy_top for an
   // explanation of what it is.
@@ -191,6 +189,8 @@
   virtual HeapWord* allocate(size_t word_size);
   HeapWord* par_allocate(size_t word_size);
 
+  HeapWord* saved_mark_word() const { ShouldNotReachHere(); return NULL; }
+
   // MarkSweep support phase3
   virtual HeapWord* initialize_threshold();
   virtual HeapWord* cross_threshold(HeapWord* start, HeapWord* end);
--- a/src/share/vm/gc_implementation/g1/heapRegionManager.cpp	Thu Dec 11 13:11:53 2014 -0800
+++ b/src/share/vm/gc_implementation/g1/heapRegionManager.cpp	Thu Dec 11 15:06:12 2014 -0800
@@ -260,7 +260,7 @@
   return num_regions;