Merge
authorlana
Wed, 26 Oct 2011 17:59:13 -0700
changeset 10864 17307b96ae38
parent 10779 5037da29fa26 (current diff)
parent 10762 cc1f5ce8e504 (diff)
child 10865 7f8dd1713604
Merge
hotspot/agent/src/os/solaris/dbx/Makefile
hotspot/agent/src/os/solaris/dbx/README
hotspot/agent/src/os/solaris/dbx/README-commands.txt
hotspot/agent/src/os/solaris/dbx/helloWorld.cpp
hotspot/agent/src/os/solaris/dbx/proc_service_2.h
hotspot/agent/src/os/solaris/dbx/shell_imp.h
hotspot/agent/src/os/solaris/dbx/svc_agent_dbx.cpp
hotspot/agent/src/os/solaris/dbx/svc_agent_dbx.hpp
hotspot/agent/src/os/win32/BasicList.hpp
hotspot/agent/src/os/win32/Buffer.cpp
hotspot/agent/src/os/win32/Buffer.hpp
hotspot/agent/src/os/win32/Dispatcher.cpp
hotspot/agent/src/os/win32/Dispatcher.hpp
hotspot/agent/src/os/win32/Handler.hpp
hotspot/agent/src/os/win32/IOBuf.cpp
hotspot/agent/src/os/win32/IOBuf.hpp
hotspot/agent/src/os/win32/LockableList.hpp
hotspot/agent/src/os/win32/Makefile
hotspot/agent/src/os/win32/Message.hpp
hotspot/agent/src/os/win32/Monitor.cpp
hotspot/agent/src/os/win32/Monitor.hpp
hotspot/agent/src/os/win32/README-commands.txt
hotspot/agent/src/os/win32/README.txt
hotspot/agent/src/os/win32/Reaper.cpp
hotspot/agent/src/os/win32/Reaper.hpp
hotspot/agent/src/os/win32/SwDbgSrv.cpp
hotspot/agent/src/os/win32/SwDbgSrv.dsp
hotspot/agent/src/os/win32/SwDbgSrv.dsw
hotspot/agent/src/os/win32/SwDbgSub.cpp
hotspot/agent/src/os/win32/SwDbgSub.dsp
hotspot/agent/src/os/win32/initWinsock.cpp
hotspot/agent/src/os/win32/initWinsock.hpp
hotspot/agent/src/os/win32/ioUtils.cpp
hotspot/agent/src/os/win32/ioUtils.hpp
hotspot/agent/src/os/win32/isNT4.cpp
hotspot/agent/src/os/win32/isNT4.hpp
hotspot/agent/src/os/win32/libInfo.cpp
hotspot/agent/src/os/win32/libInfo.hpp
hotspot/agent/src/os/win32/nt4internals.cpp
hotspot/agent/src/os/win32/nt4internals.hpp
hotspot/agent/src/os/win32/ports.h
hotspot/agent/src/os/win32/procList.cpp
hotspot/agent/src/os/win32/procList.hpp
hotspot/agent/src/os/win32/serverLists.cpp
hotspot/agent/src/os/win32/serverLists.hpp
hotspot/agent/src/os/win32/toolHelp.cpp
hotspot/agent/src/os/win32/toolHelp.hpp
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxAddress.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxDebugger.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxDebuggerLocal.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxOopHandle.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxThreadFactory.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/sparc/DbxSPARCThread.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/sparc/DbxSPARCThreadContext.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/sparc/DbxSPARCThreadFactory.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/x86/DbxX86Thread.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/x86/DbxX86ThreadContext.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/x86/DbxX86ThreadFactory.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/AddressDataSource.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/DLL.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/TestDebugger.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/TestHelloWorld.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32Address.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32CDebugInfoBuilder.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32CDebugger.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32Debugger.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32DebuggerLocal.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32LDTEntry.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32LDTEntryConstants.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32OopHandle.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32Thread.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32ThreadContext.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java
hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64RegisterMap.java
hotspot/make/solaris/makefiles/mapfile-vers-nonproduct
hotspot/make/templates/bsd-header
hotspot/src/share/vm/runtime/reflectionCompat.hpp
jdk/src/share/classes/java/util/XMLUtils.java
jdk/src/share/classes/sun/tools/jar/JarImageSource.java
langtools/src/share/classes/com/sun/tools/javac/Launcher.java
--- a/.hgtags	Mon Oct 24 09:58:47 2011 -0700
+++ b/.hgtags	Wed Oct 26 17:59:13 2011 -0700
@@ -127,3 +127,8 @@
 6815e85bf96d6d3875954f9777660372cd70d065 jdk8-b03
 31f5c34d78081572ad9a2401c0bb0c6b9711dd65 jdk8-b04
 c4f9ea1ecb55ff44e0dd21d2888ead308c86a3aa jdk8-b05
+429da7734bf491bccde2a752fae97e9f225896dc jdk8-b06
+bc5710332b294676661103bb20d47d2ea3ba8def jdk8-b07
+24ee504f80412770c6874836cd9e55b536427b1d jdk8-b08
+fbf3cabc9e3bb1fcf710941d777cb0400505fbe6 jdk8-b09
+f651ce87127980c58e3599daba964eba2f3b4026 jdk8-b10
--- a/.hgtags-top-repo	Mon Oct 24 09:58:47 2011 -0700
+++ b/.hgtags-top-repo	Wed Oct 26 17:59:13 2011 -0700
@@ -127,3 +127,8 @@
 587bb549dff83131b65f40aa51864f69562f34a7 jdk8-b03
 0b66a233bfb9ba2ebda1e5cdfdb0373d6c1e3c69 jdk8-b04
 b910aac18c772b823b1f7da03e2c6528725cc6de jdk8-b05
+28cf2aec4dd7c3c75efc1c15078522467c781a6d jdk8-b06
+0db7ae9f2b1017124c779bccd016c976928859a0 jdk8-b07
+fb1bc13260d76447e269e843859eb593fe2a8ab2 jdk8-b08
+8adb70647b5af5273dfe6a540f07be667cd50216 jdk8-b09
+a6c4c248e8fa350c35014fa94bab5ac1a1ac3299 jdk8-b10
--- a/corba/.hgtags	Mon Oct 24 09:58:47 2011 -0700
+++ b/corba/.hgtags	Wed Oct 26 17:59:13 2011 -0700
@@ -127,3 +127,8 @@
 cd0da00694fbce642db9be936d3e4909a71d911d jdk8-b03
 60a68d688e24473cf84dedd1e60901a61ab82555 jdk8-b04
 cc1b599b986a37cb57de4584c5e58169766ca535 jdk8-b05
+45c43dde7ba7f176333a51a98f086275478836fa jdk8-b06
+3d61f0856f349e2163bf98146465dab3b7437f63 jdk8-b07
+0d52b1c87aa8fdea7fdc9c4126ea58f95ca6b351 jdk8-b08
+a891732c1a83082177ff7a4cf1506068d9cc0a47 jdk8-b09
+cda87f7fefcee3b89742a57ce5ad9b03a54c210d jdk8-b10
--- a/hotspot/.hgignore	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/.hgignore	Wed Oct 26 17:59:13 2011 -0700
@@ -6,3 +6,4 @@
 ^src/share/tools/IdealGraphVisualizer/build/
 ^src/share/tools/IdealGraphVisualizer/dist/
 ^.hgtip
+.DS_Store
--- a/hotspot/.hgtags	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/.hgtags	Wed Oct 26 17:59:13 2011 -0700
@@ -179,3 +179,17 @@
 3a2fb61165dfc72e398179a2796d740c8da5b8c0 jdk8-b03
 0fa3ace511fe98fe948e751531f3e2b7c60c8376 jdk8-b04
 dce7d24674f4d0bed00de24f00119057fdce7cfb jdk8-b05
+0db80d8e77fccddf5e6fa49963226b54ac7d0f62 jdk8-b06
+3f0cf875af83f55ec5e1a5cea80455315f9322a2 jdk8-b07
+0cc8a70952c368e06de2adab1f2649a408f5e577 hs22-b01
+7c29742c41b44fb0cd5a13c7ac8834f3f2ca649e hs22-b02
+3a2fb61165dfc72e398179a2796d740c8da5b8c0 hs22-b03
+ce9bde819dcba4a5d2822229d9183e69c74326ca hs22-b04
+513a84dd0f8b56dc0836b4e0bdd5dd0a778fc634 hs22-b05
+650d15d8f37255d3b805aa00c5bd1c30984b203d hs22-b06
+da883b9e6d3788057f9577e72712998ed82c9b7e hs23-b01
+49ed7eacfd16616166ff066493143889741097af jdk8-b08
+7c20d272643f47195478708eff593a9cce40fec4 jdk8-b09
+e4f412d2b75d2c797acff965aa2c420e3d358f09 hs23-b02
+d815de2e85e511b7deab2a83cf80c0224d011da9 jdk8-b10
+4d3850d9d326ac3a9bee2d867727e954322d014e hs23-b03
--- a/hotspot/agent/make/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/make/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -48,17 +48,18 @@
 sun.jvm.hotspot.bugspot \
 sun.jvm.hotspot.bugspot.tree \
 sun.jvm.hotspot.c1 \
+sun.jvm.hotspot.ci \
 sun.jvm.hotspot.code \
 sun.jvm.hotspot.compiler \
 sun.jvm.hotspot.debugger \
 sun.jvm.hotspot.debugger.amd64 \
+sun.jvm.hotspot.debugger.bsd \
+sun.jvm.hotspot.debugger.bsd.amd64 \
+sun.jvm.hotspot.debugger.bsd.x86 \
 sun.jvm.hotspot.debugger.cdbg \
 sun.jvm.hotspot.debugger.cdbg.basic \
 sun.jvm.hotspot.debugger.cdbg.basic.amd64 \
 sun.jvm.hotspot.debugger.cdbg.basic.x86 \
-sun.jvm.hotspot.debugger.dbx \
-sun.jvm.hotspot.debugger.dbx.sparc \
-sun.jvm.hotspot.debugger.dbx.x86 \
 sun.jvm.hotspot.debugger.dummy \
 sun.jvm.hotspot.debugger.ia64 \
 sun.jvm.hotspot.debugger.linux \
@@ -76,7 +77,6 @@
 sun.jvm.hotspot.debugger.remote.sparc \
 sun.jvm.hotspot.debugger.remote.x86 \
 sun.jvm.hotspot.debugger.sparc \
-sun.jvm.hotspot.debugger.win32 \
 sun.jvm.hotspot.debugger.win32.coff \
 sun.jvm.hotspot.debugger.windbg \
 sun.jvm.hotspot.debugger.windbg.amd64 \
@@ -84,6 +84,7 @@
 sun.jvm.hotspot.debugger.windbg.x86 \
 sun.jvm.hotspot.debugger.x86 \
 sun.jvm.hotspot.gc_implementation \
+sun.jvm.hotspot.gc_implementation.g1 \
 sun.jvm.hotspot.gc_implementation.parallelScavenge \
 sun.jvm.hotspot.gc_implementation.shared \
 sun.jvm.hotspot.gc_interface \
@@ -91,9 +92,14 @@
 sun.jvm.hotspot.jdi \
 sun.jvm.hotspot.livejvm \
 sun.jvm.hotspot.memory \
+sun.jvm.hotspot.opto \
 sun.jvm.hotspot.oops \
+sun.jvm.hotspot.prims \
 sun.jvm.hotspot.runtime \
 sun.jvm.hotspot.runtime.amd64 \
+sun.jvm.hotspot.runtime.bsd \
+sun.jvm.hotspot.runtime.bsd_amd64 \
+sun.jvm.hotspot.runtime.bsd_x86 \
 sun.jvm.hotspot.runtime.ia64 \
 sun.jvm.hotspot.runtime.linux \
 sun.jvm.hotspot.runtime.linux_amd64 \
@@ -139,17 +145,18 @@
 sun/jvm/hotspot/bugspot/*.java \
 sun/jvm/hotspot/bugspot/tree/*.java \
 sun/jvm/hotspot/c1/*.java \
+sun/jvm/hotspot/ci/*.java \
 sun/jvm/hotspot/code/*.java \
 sun/jvm/hotspot/compiler/*.java \
 sun/jvm/hotspot/debugger/*.java \
 sun/jvm/hotspot/debugger/amd64/*.java \
+sun/jvm/hotspot/debugger/bsd/*.java \
+sun/jvm/hotspot/debugger/bsd/amd64/*.java \
+sun/jvm/hotspot/debugger/bsd/x86/*.java \
 sun/jvm/hotspot/debugger/cdbg/*.java \
 sun/jvm/hotspot/debugger/cdbg/basic/*.java \
 sun/jvm/hotspot/debugger/cdbg/basic/amd64/*.java \
 sun/jvm/hotspot/debugger/cdbg/basic/x86/*.java \
-sun/jvm/hotspot/debugger/dbx/*.java \
-sun/jvm/hotspot/debugger/dbx/sparc/*.java \
-sun/jvm/hotspot/debugger/dbx/x86/*.java \
 sun/jvm/hotspot/debugger/dummy/*.java \
 sun/jvm/hotspot/debugger/ia64/*.java \
 sun/jvm/hotspot/debugger/linux/*.java \
@@ -165,19 +172,26 @@
 sun/jvm/hotspot/debugger/remote/sparc/*.java \
 sun/jvm/hotspot/debugger/remote/x86/*.java \
 sun/jvm/hotspot/debugger/sparc/*.java \
-sun/jvm/hotspot/debugger/win32/*.java \
 sun/jvm/hotspot/debugger/win32/coff/*.java \
 sun/jvm/hotspot/debugger/windbg/*.java \
 sun/jvm/hotspot/debugger/windbg/ia64/*.java \
 sun/jvm/hotspot/debugger/windbg/x86/*.java \
 sun/jvm/hotspot/debugger/x86/*.java \
+sun/jvm/hotspot/gc_implementation/g1/*.java \
+sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
+sun/jvm/hotspot/gc_implementation/shared/*.java \
 sun/jvm/hotspot/interpreter/*.java \
 sun/jvm/hotspot/jdi/*.java \
 sun/jvm/hotspot/livejvm/*.java \
 sun/jvm/hotspot/memory/*.java \
 sun/jvm/hotspot/oops/*.java \
+sun/jvm/hotspot/opto/*.java \
+sun/jvm/hotspot/prims/*.java \
 sun/jvm/hotspot/runtime/*.java \
 sun/jvm/hotspot/runtime/amd64/*.java \
+sun/jvm/hotspot/runtime/bsd/*.java \
+sun/jvm/hotspot/runtime/bsd_amd64/*.java \
+sun/jvm/hotspot/runtime/bsd_x86/*.java \
 sun/jvm/hotspot/runtime/ia64/*.java \
 sun/jvm/hotspot/runtime/linux/*.java \
 sun/jvm/hotspot/runtime/linux_amd64/*.java \
--- a/hotspot/agent/make/saenv.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/make/saenv.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -70,6 +70,14 @@
 
 SA_CLASSPATH=$STARTDIR/../build/classes:$STARTDIR/../src/share/lib/js.jar:$STARTDIR/sa.jar:$STARTDIR/lib/js.jar
 
+if [ ! -z "$SA_TYPEDB" ]; then
+  if [ ! -f $SA_TYPEDB ]; then
+    echo "$SA_TYPEDB is unreadable"
+    exit 1
+  fi
+  OPTIONS="-Dsun.jvm.hotspot.typedb=$SA_TYPEDB ${OPTIONS}"
+fi
+
 OPTIONS="-Djava.system.class.loader=sun.jvm.hotspot.SALauncherLoader ${OPTIONS}"
 
 SA_JAVA_CMD="$SA_PREFIX_CMD $SA_JAVA -showversion ${OPTIONS} -cp $SA_CLASSPATH $SA_OPTIONS"
--- a/hotspot/agent/make/saenv64.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/make/saenv64.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -67,6 +67,14 @@
 
 SA_CLASSPATH=$STARTDIR/../build/classes:$STARTDIR/../src/share/lib/js.jar:$STARTDIR/sa.jar::$STARTDIR/lib/js.jar
 
+if [ ! -z "$SA_TYPEDB" ]; then
+  if [ ! -f $SA_TYPEDB ]; then
+    echo "$SA_TYPEDB is unreadable"
+    exit 1
+  fi
+  OPTIONS="-Dsun.jvm.hotspot.typedb=$SA_TYPEDB ${OPTIONS}"
+fi
+
 OPTIONS="-Djava.system.class.loader=sun.jvm.hotspot.SALauncherLoader ${OPTIONS}"
 
 SA_JAVA_CMD="$SA_PREFIX_CMD $SA_JAVA -d64 -showversion ${OPTIONS} -cp $SA_CLASSPATH $SA_OPTIONS"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/BsdDebuggerLocal.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,413 @@
+/*
+ * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
+ * 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 <stdlib.h>
+#include <jni.h>
+#include "libproc.h"
+
+#if defined(x86_64) && !defined(amd64)
+#define amd64 1
+#endif
+
+#ifdef i386
+#include "sun_jvm_hotspot_debugger_x86_X86ThreadContext.h"
+#endif
+
+#ifdef amd64
+#include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h"
+#endif
+
+#if defined(sparc) || defined(sparcv9)
+#include "sun_jvm_hotspot_debugger_sparc_SPARCThreadContext.h"
+#endif
+
+static jfieldID p_ps_prochandle_ID = 0;
+static jfieldID threadList_ID = 0;
+static jfieldID loadObjectList_ID = 0;
+
+static jmethodID createClosestSymbol_ID = 0;
+static jmethodID createLoadObject_ID = 0;
+static jmethodID getThreadForThreadId_ID = 0;
+static jmethodID listAdd_ID = 0;
+
+#define CHECK_EXCEPTION_(value) if ((*env)->ExceptionOccurred(env)) { return value; }
+#define CHECK_EXCEPTION if ((*env)->ExceptionOccurred(env)) { return;}
+#define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; }
+#define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;}
+
+static void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
+  (*env)->ThrowNew(env, (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException"), errMsg);
+}
+
+static struct ps_prochandle* get_proc_handle(JNIEnv* env, jobject this_obj) {
+  jlong ptr = (*env)->GetLongField(env, this_obj, p_ps_prochandle_ID);
+  return (struct ps_prochandle*)(intptr_t)ptr;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    init0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_init0
+  (JNIEnv *env, jclass cls) {
+  jclass listClass;
+
+  if (init_libproc(getenv("LIBSAPROC_DEBUG") != NULL) != true) {
+     THROW_NEW_DEBUGGER_EXCEPTION("can't initialize libproc");
+  }
+
+  // fields we use
+  p_ps_prochandle_ID = (*env)->GetFieldID(env, cls, "p_ps_prochandle", "J");
+  CHECK_EXCEPTION;
+  threadList_ID = (*env)->GetFieldID(env, cls, "threadList", "Ljava/util/List;");
+  CHECK_EXCEPTION;
+  loadObjectList_ID = (*env)->GetFieldID(env, cls, "loadObjectList", "Ljava/util/List;");
+  CHECK_EXCEPTION;
+
+  // methods we use
+  createClosestSymbol_ID = (*env)->GetMethodID(env, cls, "createClosestSymbol",
+                    "(Ljava/lang/String;J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;");
+  CHECK_EXCEPTION;
+  createLoadObject_ID = (*env)->GetMethodID(env, cls, "createLoadObject",
+                    "(Ljava/lang/String;JJ)Lsun/jvm/hotspot/debugger/cdbg/LoadObject;");
+  CHECK_EXCEPTION;
+  getThreadForThreadId_ID = (*env)->GetMethodID(env, cls, "getThreadForThreadId",
+                                                     "(J)Lsun/jvm/hotspot/debugger/ThreadProxy;");
+  CHECK_EXCEPTION;
+  // java.util.List method we call
+  listClass = (*env)->FindClass(env, "java/util/List");
+  CHECK_EXCEPTION;
+  listAdd_ID = (*env)->GetMethodID(env, listClass, "add", "(Ljava/lang/Object;)Z");
+  CHECK_EXCEPTION;
+}
+
+JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getAddressSize
+  (JNIEnv *env, jclass cls)
+{
+#ifdef _LP64
+ return 8;
+#else
+ return 4;
+#endif
+
+}
+
+
+static void fillThreadsAndLoadObjects(JNIEnv* env, jobject this_obj, struct ps_prochandle* ph) {
+  int n = 0, i = 0;
+
+  // add threads
+  n = get_num_threads(ph);
+  for (i = 0; i < n; i++) {
+    jobject thread;
+    jobject threadList;
+    lwpid_t lwpid;
+
+    lwpid = get_lwp_id(ph, i);
+    thread = (*env)->CallObjectMethod(env, this_obj, getThreadForThreadId_ID,
+                                      (jlong)lwpid);
+    CHECK_EXCEPTION;
+    threadList = (*env)->GetObjectField(env, this_obj, threadList_ID);
+    CHECK_EXCEPTION;
+    (*env)->CallBooleanMethod(env, threadList, listAdd_ID, thread);
+    CHECK_EXCEPTION;
+  }
+
+  // add load objects
+  n = get_num_libs(ph);
+  for (i = 0; i < n; i++) {
+     uintptr_t base;
+     const char* name;
+     jobject loadObject;
+     jobject loadObjectList;
+
+     base = get_lib_base(ph, i);
+     name = get_lib_name(ph, i);
+     loadObject = (*env)->CallObjectMethod(env, this_obj, createLoadObject_ID,
+                                   (*env)->NewStringUTF(env, name), (jlong)0, (jlong)base);
+     CHECK_EXCEPTION;
+     loadObjectList = (*env)->GetObjectField(env, this_obj, loadObjectList_ID);
+     CHECK_EXCEPTION;
+     (*env)->CallBooleanMethod(env, loadObjectList, listAdd_ID, loadObject);
+     CHECK_EXCEPTION;
+  }
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    attach0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__I
+  (JNIEnv *env, jobject this_obj, jint jpid) {
+
+  struct ps_prochandle* ph;
+  if ( (ph = Pgrab(jpid)) == NULL) {
+    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
+  }
+  (*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph);
+  fillThreadsAndLoadObjects(env, this_obj, ph);
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    attach0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2
+  (JNIEnv *env, jobject this_obj, jstring execName, jstring coreName) {
+  const char *execName_cstr;
+  const char *coreName_cstr;
+  jboolean isCopy;
+  struct ps_prochandle* ph;
+
+  execName_cstr = (*env)->GetStringUTFChars(env, execName, &isCopy);
+  CHECK_EXCEPTION;
+  coreName_cstr = (*env)->GetStringUTFChars(env, coreName, &isCopy);
+  CHECK_EXCEPTION;
+
+  if ( (ph = Pgrab_core(execName_cstr, coreName_cstr)) == NULL) {
+    (*env)->ReleaseStringUTFChars(env, execName, execName_cstr);
+    (*env)->ReleaseStringUTFChars(env, coreName, coreName_cstr);
+    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the core file");
+  }
+  (*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph);
+  (*env)->ReleaseStringUTFChars(env, execName, execName_cstr);
+  (*env)->ReleaseStringUTFChars(env, coreName, coreName_cstr);
+  fillThreadsAndLoadObjects(env, this_obj, ph);
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    detach0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_detach0
+  (JNIEnv *env, jobject this_obj) {
+  struct ps_prochandle* ph = get_proc_handle(env, this_obj);
+  if (ph != NULL) {
+     Prelease(ph);
+  }
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    lookupByName0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByName0
+  (JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) {
+  const char *objectName_cstr, *symbolName_cstr;
+  jlong addr;
+  jboolean isCopy;
+  struct ps_prochandle* ph = get_proc_handle(env, this_obj);
+
+  objectName_cstr = NULL;
+  if (objectName != NULL) {
+    objectName_cstr = (*env)->GetStringUTFChars(env, objectName, &isCopy);
+    CHECK_EXCEPTION_(0);
+  }
+  symbolName_cstr = (*env)->GetStringUTFChars(env, symbolName, &isCopy);
+  CHECK_EXCEPTION_(0);
+
+  addr = (jlong) lookup_symbol(ph, objectName_cstr, symbolName_cstr);
+
+  if (objectName_cstr != NULL) {
+    (*env)->ReleaseStringUTFChars(env, objectName, objectName_cstr);
+  }
+  (*env)->ReleaseStringUTFChars(env, symbolName, symbolName_cstr);
+  return addr;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    lookupByAddress0
+ * Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;
+ */
+JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByAddress0
+  (JNIEnv *env, jobject this_obj, jlong addr) {
+  uintptr_t offset;
+  const char* sym = NULL;
+
+  struct ps_prochandle* ph = get_proc_handle(env, this_obj);
+  sym = symbol_for_pc(ph, (uintptr_t) addr, &offset);
+  if (sym == NULL) return 0;
+  return (*env)->CallObjectMethod(env, this_obj, createClosestSymbol_ID,
+                          (*env)->NewStringUTF(env, sym), (jlong)offset);
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    readBytesFromProcess0
+ * Signature: (JJ)Lsun/jvm/hotspot/debugger/ReadResult;
+ */
+JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0
+  (JNIEnv *env, jobject this_obj, jlong addr, jlong numBytes) {
+
+  jboolean isCopy;
+  jbyteArray array;
+  jbyte *bufPtr;
+  ps_err_e err;
+
+  array = (*env)->NewByteArray(env, numBytes);
+  CHECK_EXCEPTION_(0);
+  bufPtr = (*env)->GetByteArrayElements(env, array, &isCopy);
+  CHECK_EXCEPTION_(0);
+
+  err = ps_pread(get_proc_handle(env, this_obj), (psaddr_t) (uintptr_t)addr, bufPtr, numBytes);
+  (*env)->ReleaseByteArrayElements(env, array, bufPtr, 0);
+  return (err == PS_OK)? array : 0;
+}
+
+JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0
+  (JNIEnv *env, jobject this_obj, jint lwp_id) {
+
+  struct reg gregs;
+  jboolean isCopy;
+  jlongArray array;
+  jlong *regs;
+
+  struct ps_prochandle* ph = get_proc_handle(env, this_obj);
+  if (get_lwp_regs(ph, lwp_id, &gregs) != true) {
+     THROW_NEW_DEBUGGER_EXCEPTION_("get_thread_regs failed for a lwp", 0);
+  }
+
+#undef NPRGREG
+#ifdef i386
+#define NPRGREG sun_jvm_hotspot_debugger_x86_X86ThreadContext_NPRGREG
+#endif
+#ifdef ia64
+#define NPRGREG IA64_REG_COUNT
+#endif
+#ifdef amd64
+#define NPRGREG sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_NPRGREG
+#endif
+#if defined(sparc) || defined(sparcv9)
+#define NPRGREG sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_NPRGREG
+#endif
+
+  array = (*env)->NewLongArray(env, NPRGREG);
+  CHECK_EXCEPTION_(0);
+  regs = (*env)->GetLongArrayElements(env, array, &isCopy);
+
+#undef REG_INDEX
+
+#ifdef i386
+#define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
+
+  regs[REG_INDEX(GS)]  = (uintptr_t) gregs.r_gs;
+  regs[REG_INDEX(FS)]  = (uintptr_t) gregs.r_fs;
+  regs[REG_INDEX(ES)]  = (uintptr_t) gregs.r_es;
+  regs[REG_INDEX(DS)]  = (uintptr_t) gregs.r_ds;
+  regs[REG_INDEX(EDI)] = (uintptr_t) gregs.r_edi;
+  regs[REG_INDEX(ESI)] = (uintptr_t) gregs.r_esi;
+  regs[REG_INDEX(FP)] = (uintptr_t) gregs.r_ebp;
+  regs[REG_INDEX(SP)] = (uintptr_t) gregs.r_isp;
+  regs[REG_INDEX(EBX)] = (uintptr_t) gregs.r_ebx;
+  regs[REG_INDEX(EDX)] = (uintptr_t) gregs.r_edx;
+  regs[REG_INDEX(ECX)] = (uintptr_t) gregs.r_ecx;
+  regs[REG_INDEX(EAX)] = (uintptr_t) gregs.r_eax;
+  regs[REG_INDEX(PC)] = (uintptr_t) gregs.r_eip;
+  regs[REG_INDEX(CS)]  = (uintptr_t) gregs.r_cs;
+  regs[REG_INDEX(SS)]  = (uintptr_t) gregs.r_ss;
+
+#endif /* i386 */
+
+#if ia64
+  regs = (*env)->GetLongArrayElements(env, array, &isCopy);
+  int i;
+  for (i = 0; i < NPRGREG; i++ ) {
+    regs[i] = 0xDEADDEAD;
+  }
+#endif /* ia64 */
+
+#ifdef amd64
+#define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg
+
+  regs[REG_INDEX(R15)] = gregs.r_r15;
+  regs[REG_INDEX(R14)] = gregs.r_r14;
+  regs[REG_INDEX(R13)] = gregs.r_r13;
+  regs[REG_INDEX(R12)] = gregs.r_r12;
+  regs[REG_INDEX(RBP)] = gregs.r_rbp;
+  regs[REG_INDEX(RBX)] = gregs.r_rbx;
+  regs[REG_INDEX(R11)] = gregs.r_r11;
+  regs[REG_INDEX(R10)] = gregs.r_r10;
+  regs[REG_INDEX(R9)] = gregs.r_r9;
+  regs[REG_INDEX(R8)] = gregs.r_r8;
+  regs[REG_INDEX(RAX)] = gregs.r_rax;
+  regs[REG_INDEX(RCX)] = gregs.r_rcx;
+  regs[REG_INDEX(RDX)] = gregs.r_rdx;
+  regs[REG_INDEX(RSI)] = gregs.r_rsi;
+  regs[REG_INDEX(RDI)] = gregs.r_rdi;
+  regs[REG_INDEX(RIP)] = gregs.r_rip;
+  regs[REG_INDEX(CS)] = gregs.r_cs;
+  regs[REG_INDEX(RSP)] = gregs.r_rsp;
+  regs[REG_INDEX(SS)] = gregs.r_ss;
+//  regs[REG_INDEX(FSBASE)] = gregs.fs_base;
+//  regs[REG_INDEX(GSBASE)] = gregs.gs_base;
+//  regs[REG_INDEX(DS)] = gregs.ds;
+//  regs[REG_INDEX(ES)] = gregs.es;
+//  regs[REG_INDEX(FS)] = gregs.fs;
+//  regs[REG_INDEX(GS)] = gregs.gs;
+
+#endif /* amd64 */
+
+#if defined(sparc) || defined(sparcv9)
+
+#define REG_INDEX(reg) sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_##reg
+
+#ifdef _LP64
+  regs[REG_INDEX(R_PSR)] = gregs.tstate;
+  regs[REG_INDEX(R_PC)]  = gregs.tpc;
+  regs[REG_INDEX(R_nPC)] = gregs.tnpc;
+  regs[REG_INDEX(R_Y)]   = gregs.y;
+#else
+  regs[REG_INDEX(R_PSR)] = gregs.psr;
+  regs[REG_INDEX(R_PC)]  = gregs.pc;
+  regs[REG_INDEX(R_nPC)] = gregs.npc;
+  regs[REG_INDEX(R_Y)]   = gregs.y;
+#endif
+  regs[REG_INDEX(R_G0)]  =            0 ;
+  regs[REG_INDEX(R_G1)]  = gregs.u_regs[0];
+  regs[REG_INDEX(R_G2)]  = gregs.u_regs[1];
+  regs[REG_INDEX(R_G3)]  = gregs.u_regs[2];
+  regs[REG_INDEX(R_G4)]  = gregs.u_regs[3];
+  regs[REG_INDEX(R_G5)]  = gregs.u_regs[4];
+  regs[REG_INDEX(R_G6)]  = gregs.u_regs[5];
+  regs[REG_INDEX(R_G7)]  = gregs.u_regs[6];
+  regs[REG_INDEX(R_O0)]  = gregs.u_regs[7];
+  regs[REG_INDEX(R_O1)]  = gregs.u_regs[8];
+  regs[REG_INDEX(R_O2)]  = gregs.u_regs[ 9];
+  regs[REG_INDEX(R_O3)]  = gregs.u_regs[10];
+  regs[REG_INDEX(R_O4)]  = gregs.u_regs[11];
+  regs[REG_INDEX(R_O5)]  = gregs.u_regs[12];
+  regs[REG_INDEX(R_O6)]  = gregs.u_regs[13];
+  regs[REG_INDEX(R_O7)]  = gregs.u_regs[14];
+#endif /* sparc */
+
+
+  (*env)->ReleaseLongArrayElements(env, array, regs, JNI_COMMIT);
+  return array;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/MacosxDebuggerLocal.m	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2002, 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include <objc/objc-runtime.h>
+#import <Foundation/Foundation.h>
+#import <JavaNativeFoundation/JavaNativeFoundation.h>
+
+#include <JavaVM/jni.h>
+
+#import <mach/mach.h>
+#import <mach/mach_types.h>
+#import <sys/sysctl.h>
+#import <stdlib.h>
+
+jboolean debug = JNI_FALSE;
+
+static jfieldID symbolicatorID = 0; // set in _init0
+static jfieldID taskID = 0; // set in _init0
+
+static void putSymbolicator(JNIEnv *env, jobject this_obj, id symbolicator) {
+  (*env)->SetLongField(env, this_obj, symbolicatorID, (jlong)(intptr_t)symbolicator);
+}
+
+static id getSymbolicator(JNIEnv *env, jobject this_obj) {
+  jlong ptr = (*env)->GetLongField(env, this_obj, symbolicatorID);
+  return (id)(intptr_t)ptr;
+}
+
+static void putTask(JNIEnv *env, jobject this_obj, task_t task) {
+  (*env)->SetLongField(env, this_obj, taskID, (jlong)task);
+}
+
+static task_t getTask(JNIEnv *env, jobject this_obj) {
+  jlong ptr = (*env)->GetLongField(env, this_obj, taskID);
+  return (task_t)ptr;
+}
+
+#define CHECK_EXCEPTION_(value) if ((*env)->ExceptionOccurred(env)) { return value; }
+#define CHECK_EXCEPTION if ((*env)->ExceptionOccurred(env)) { return;}
+#define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; }
+#define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;}
+
+static void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
+  (*env)->ThrowNew(env, (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException"), errMsg);
+}
+
+#if defined(__i386__)
+    #define hsdb_thread_state_t     x86_thread_state32_t
+    #define hsdb_float_state_t      x86_float_state32_t
+    #define HSDB_THREAD_STATE       x86_THREAD_STATE32
+    #define HSDB_FLOAT_STATE        x86_FLOAT_STATE32
+    #define HSDB_THREAD_STATE_COUNT x86_THREAD_STATE32_COUNT
+    #define HSDB_FLOAT_STATE_COUNT  x86_FLOAT_STATE32_COUNT
+#elif defined(__x86_64__)
+    #define hsdb_thread_state_t     x86_thread_state64_t
+    #define hsdb_float_state_t      x86_float_state64_t
+    #define HSDB_THREAD_STATE       x86_THREAD_STATE64
+    #define HSDB_FLOAT_STATE        x86_FLOAT_STATE64
+    #define HSDB_THREAD_STATE_COUNT x86_THREAD_STATE64_COUNT
+    #define HSDB_FLOAT_STATE_COUNT  x86_FLOAT_STATE64_COUNT
+#else
+    #error "Unsupported architecture"
+#endif
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    init0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_init0(JNIEnv *env, jclass cls) {
+  symbolicatorID = (*env)->GetFieldID(env, cls, "symbolicator", "J");
+  taskID = (*env)->GetFieldID(env, cls, "task", "J");
+  CHECK_EXCEPTION;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    lookupByName0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByName0(JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) {
+  jlong address = 0;
+
+JNF_COCOA_ENTER(env);
+  NSString *symbolNameString = JNFJavaToNSString(env, symbolName);
+
+  if (debug) {
+    printf("lookupInProcess called for %s\n", [symbolNameString UTF8String]);
+  }
+
+  id symbolicator = getSymbolicator(env, this_obj);
+  if (symbolicator != nil) {
+    uint64_t (*dynamicCall)(id, SEL, NSString *) = (uint64_t (*)(id, SEL, NSString *))&objc_msgSend;
+    address = (jlong) dynamicCall(symbolicator, @selector(addressForSymbol:), symbolNameString);
+  }
+
+  if (debug) {
+    printf("address of symbol %s = %llx\n", [symbolNameString UTF8String], address);
+  }
+JNF_COCOA_EXIT(env);
+
+  return address;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    readBytesFromProcess0
+ * Signature: (JJ)Lsun/jvm/hotspot/debugger/ReadResult;
+ */
+JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0(JNIEnv *env, jobject this_obj, jlong addr, jlong numBytes) {
+  if (debug) printf("readBytesFromProcess called. addr = %llx numBytes = %lld\n", addr, numBytes);
+
+  // must allocate storage instead of using former parameter buf
+  jboolean isCopy;
+  jbyteArray array;
+  jbyte *bufPtr;
+
+  array = (*env)->NewByteArray(env, numBytes);
+  CHECK_EXCEPTION_(0);
+
+  unsigned long alignedAddress;
+  unsigned long alignedLength;
+  kern_return_t result;
+  vm_offset_t *pages;
+  int *mapped;
+  long pageCount;
+  uint byteCount;
+  int i;
+  unsigned long remaining;
+
+  alignedAddress = trunc_page(addr);
+  if (addr != alignedAddress) {
+    alignedLength += addr - alignedAddress;
+  }
+  alignedLength = round_page(numBytes);
+  pageCount = alignedLength/vm_page_size;
+
+  // Allocate storage for pages and flags.
+  pages = malloc(pageCount * sizeof(vm_offset_t));
+  mapped = calloc(pageCount, sizeof(int));
+
+  task_t gTask = getTask(env, this_obj);
+  // Try to read each of the pages.
+  for (i = 0; i < pageCount; i++) {
+    result = vm_read(gTask, alignedAddress + i*vm_page_size, vm_page_size, 
+		     &pages[i], &byteCount);
+    mapped[i] = (result == KERN_SUCCESS); 
+    // assume all failures are unmapped pages
+  }
+
+  if (debug) fprintf(stderr, "%ld pages\n", pageCount);
+	
+  remaining = numBytes;
+	
+  for (i = 0; i < pageCount; i++) {
+    unsigned long len = vm_page_size;
+    unsigned long start = 0;
+
+    if (i == 0) {
+      start = addr - alignedAddress;
+      len = vm_page_size - start;
+    }
+
+    if (i == (pageCount - 1)) {
+      len = remaining;
+    }
+
+    if (mapped[i]) {
+      if (debug) fprintf(stderr, "page %d mapped (len %ld start %ld)\n", i, len, start);
+      (*env)->SetByteArrayRegion(env, array, 0, len, ((jbyte *) pages[i] + start));
+      vm_deallocate(mach_task_self(), pages[i], vm_page_size);
+    }
+
+    remaining -= len;
+  }
+
+  free (pages);
+  free (mapped);
+  return array;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_macosx_MacOSXDebuggerLocal
+ * Method:    getThreadIntegerRegisterSet0
+ * Signature: (I)[J
+ */
+JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0(JNIEnv *env, jobject this_obj, jint lwp_id) {
+  if (debug)
+    printf("getThreadRegisterSet0 called\n");
+
+  kern_return_t result;
+  thread_t tid;
+  mach_msg_type_number_t count = HSDB_THREAD_STATE_COUNT;
+  hsdb_thread_state_t state;
+  unsigned int *r;
+  int i;
+  jlongArray registerArray;
+  jlong *primitiveArray;
+
+  tid = lwp_id;
+
+  result = thread_get_state(tid, HSDB_THREAD_STATE, (thread_state_t)&state, &count);
+
+  if (result != KERN_SUCCESS) {
+    if (debug)
+      printf("getregs: thread_get_state(%d) failed (%d)\n", tid, result);
+    return NULL;
+  }
+
+  // 40 32-bit registers on ppc, 16 on x86. 
+  // Output order is the same as the order in the ppc_thread_state/i386_thread_state struct.
+#if defined(__i386__)
+	r = (unsigned int *)&state;
+	registerArray = (*env)->NewLongArray(env, 8);
+	primitiveArray = (*env)->GetLongArrayElements(env, registerArray, NULL);
+	primitiveArray[0] = r[0];  // eax
+	primitiveArray[1] = r[2];  // ecx
+	primitiveArray[2] = r[3];  // edx
+	primitiveArray[3] = r[1];  // ebx
+	primitiveArray[4] = r[7];  // esp
+	primitiveArray[5] = r[6];  // ebp
+	primitiveArray[6] = r[5];  // esi
+	primitiveArray[7] = r[4];  // edi
+	(*env)->ReleaseLongArrayElements(env, registerArray, primitiveArray, 0);
+#elif defined(__x86_64__)
+	/* From AMD64ThreadContext.java
+	   public static final int R15 = 0;
+	   public static final int R14 = 1;
+	   public static final int R13 = 2;
+	   public static final int R12 = 3;
+	   public static final int R11 = 4;
+	   public static final int R10 = 5;
+	   public static final int R9  = 6;
+	   public static final int R8  = 7;
+	   public static final int RDI = 8;
+	   public static final int RSI = 9;
+	   public static final int RBP = 10;
+	   public static final int RBX = 11;
+	   public static final int RDX = 12;
+	   public static final int RCX = 13;
+	   public static final int RAX = 14;
+	   public static final int TRAPNO = 15;
+	   public static final int ERR = 16;
+	   public static final int RIP = 17;
+	   public static final int CS = 18;
+	   public static final int RFL = 19;
+	   public static final int RSP = 20;
+	   public static final int SS = 21;
+	   public static final int FS = 22;
+	   public static final int GS = 23;
+	   public static final int ES = 24;
+	   public static final int DS = 25;
+	   public static final int FSBASE = 26;
+	   public static final int GSBASE = 27;
+	 */
+	// 64 bit
+	if (debug) printf("Getting threads for a 64-bit process\n");
+	registerArray = (*env)->NewLongArray(env, 28);
+	primitiveArray = (*env)->GetLongArrayElements(env, registerArray, NULL);
+
+	primitiveArray[0] = state.__r15;
+	primitiveArray[1] = state.__r14;
+	primitiveArray[2] = state.__r13;
+	primitiveArray[3] = state.__r12;
+	primitiveArray[4] = state.__r11;
+	primitiveArray[5] = state.__r10;
+	primitiveArray[6] = state.__r9;
+	primitiveArray[7] = state.__r8;
+	primitiveArray[8] = state.__rdi;
+	primitiveArray[9] = state.__rsi;
+	primitiveArray[10] = state.__rbp;
+	primitiveArray[11] = state.__rbx;
+	primitiveArray[12] = state.__rdx;
+	primitiveArray[13] = state.__rcx;
+	primitiveArray[14] = state.__rax;
+	primitiveArray[15] = 0;             // trapno ?
+	primitiveArray[16] = 0;             // err ?
+	primitiveArray[17] = state.__rip;
+	primitiveArray[18] = state.__cs;
+	primitiveArray[19] = state.__rflags;
+	primitiveArray[20] = state.__rsp;
+	primitiveArray[21] = 0;            // We don't have SS
+	primitiveArray[22] = state.__fs;
+	primitiveArray[23] = state.__gs;
+	primitiveArray[24] = 0;
+	primitiveArray[25] = 0;
+	primitiveArray[26] = 0;
+	primitiveArray[27] = 0;
+
+	if (debug) printf("set registers\n");
+
+	(*env)->ReleaseLongArrayElements(env, registerArray, primitiveArray, 0);
+#else
+#error Unsupported architecture
+#endif
+
+  return registerArray;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_macosx_MacOSXDebuggerLocal
+ * Method:    translateTID0
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL
+Java_sun_jvm_hotspot_debugger_macosx_MacOSXDebuggerLocal_translateTID0(JNIEnv *env, jobject this_obj, jint tid) {
+  if (debug)
+    printf("translateTID0 called on tid = 0x%x\n", (int)tid);
+
+  kern_return_t result;
+  thread_t foreign_tid, usable_tid;
+  mach_msg_type_name_t type;
+    
+  foreign_tid = tid;
+    
+  task_t gTask = getTask(env, this_obj);
+  result = mach_port_extract_right(gTask, foreign_tid, 
+				   MACH_MSG_TYPE_COPY_SEND, 
+				   &usable_tid, &type);
+  if (result != KERN_SUCCESS)
+    return -1;
+    
+  if (debug)
+    printf("translateTID0: 0x%x -> 0x%x\n", foreign_tid, usable_tid);
+    
+  return (jint) usable_tid;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    attach0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__I(JNIEnv *env, jobject this_obj, jint jpid) {
+JNF_COCOA_ENTER(env);
+  if (getenv("JAVA_SAPROC_DEBUG") != NULL)
+    debug = JNI_TRUE;
+  else
+    debug = JNI_FALSE;
+  if (debug) printf("attach0 called for jpid=%d\n", (int)jpid);
+
+  kern_return_t result;
+  task_t gTask = 0;
+  result = task_for_pid(mach_task_self(), jpid, &gTask);
+  if (result != KERN_SUCCESS) {
+    fprintf(stderr, "attach: task_for_pid(%d) failed (%d)\n", (int)jpid, result);
+    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
+  }
+  putTask(env, this_obj, gTask);
+
+  id symbolicator = nil;
+  id jrsSymbolicator = objc_lookUpClass("JRSSymbolicator");
+  if (jrsSymbolicator != nil) {
+    id (*dynamicCall)(id, SEL, pid_t) = (id (*)(id, SEL, pid_t))&objc_msgSend;
+    symbolicator = dynamicCall(jrsSymbolicator, @selector(symbolicatorForPid:), (pid_t)jpid);
+  }
+  if (symbolicator != nil) {
+    CFRetain(symbolicator); // pin symbolicator while in java heap
+  }
+
+  putSymbolicator(env, this_obj, symbolicator);
+  if (symbolicator == nil) {
+    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach symbolicator to the process");
+  }
+
+JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    detach0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_detach0(JNIEnv *env, jobject this_obj) {
+JNF_COCOA_ENTER(env);
+  if (debug) printf("detach0 called\n");
+
+  task_t gTask = getTask(env, this_obj);
+  mach_port_deallocate(mach_task_self(), gTask);
+  id symbolicator = getSymbolicator(env, this_obj);
+  if (symbolicator != nil) {
+    CFRelease(symbolicator);
+  }
+JNF_COCOA_EXIT(env);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,77 @@
+#
+# Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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.
+#  
+#
+
+ARCH := $(shell if ([ `uname -m` = "ia64" ])  ; then echo ia64 ; elif ([ `uname -m` = "amd64" ]) ; then echo amd64; elif ([ `uname -m` = "sparc64" ]) ; then echo sparc; else echo i386 ; fi )
+GCC      = gcc
+
+JAVAH    = ${JAVA_HOME}/bin/javah
+
+SOURCES  = salibelf.c   \
+        symtab.c        \
+	libproc_impl.c  \
+	ps_proc.c       \
+	ps_core.c       \
+	BsdDebuggerLocal.c
+
+INCLUDES = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/$(shell uname -s | tr "[:upper:]" "[:lower:]")
+
+OBJS     = $(SOURCES:.c=.o)
+
+LIBS     = -lutil -lthread_db
+
+CFLAGS   = -c -fPIC -g -Wall -D_ALLBSD_SOURCE -D_GNU_SOURCE -D$(ARCH) $(INCLUDES)
+
+LIBSA = $(ARCH)/libsaproc.so
+
+all: $(LIBSA)
+
+BsdDebuggerLocal.o: BsdDebuggerLocal.c
+	$(JAVAH) -jni -classpath ../../../../../build/bsd-i586/hotspot/outputdir/bsd_i486_compiler2/generated/saclasses  \
+		sun.jvm.hotspot.debugger.x86.X86ThreadContext \
+		sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext
+	$(GCC) $(CFLAGS) $<
+
+.c.obj:
+	$(GCC) $(CFLAGS)
+
+ifndef LDNOMAP
+  LFLAGS_LIBSA = -Xlinker --version-script=mapfile
+endif
+
+$(LIBSA): $(OBJS) mapfile
+	if [ ! -d $(ARCH) ] ; then mkdir $(ARCH) ; fi
+	$(GCC) -shared $(LFLAGS_LIBSA) -o $(LIBSA) $(OBJS) $(LIBS)
+
+test.o: $(LIBSA) test.c
+	$(GCC) -c -o test.o -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) test.c
+
+test: test.o
+	$(GCC) -o test test.o -L$(ARCH) -lsaproc $(LIBS)
+
+clean:
+	rm -f $(LIBSA)
+	rm -f $(OBJS)
+	rm -f test.o
+	-rmdir $(ARCH)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/StubDebuggerLocal.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 <stdlib.h>
+#include <jni.h>
+
+#define CHECK_EXCEPTION_(value) if ((*env)->ExceptionOccurred(env)) { return value; }
+#define CHECK_EXCEPTION if ((*env)->ExceptionOccurred(env)) { return;}
+#define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; }
+#define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;}
+
+static void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
+  (*env)->ThrowNew(env, (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException"), errMsg);
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    init0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_init0
+  (JNIEnv *env, jclass cls) {
+}
+
+JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getAddressSize
+  (JNIEnv *env, jclass cls)
+{
+#ifdef _LP64
+ return 8;
+#else
+ return 4;
+#endif
+
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    attach0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__I
+  (JNIEnv *env, jobject this_obj, jint jpid) {
+
+  THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    attach0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2
+  (JNIEnv *env, jobject this_obj, jstring execName, jstring coreName) {
+  THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the core file");
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    detach0
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_detach0
+  (JNIEnv *env, jobject this_obj) {
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    lookupByName0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByName0
+  (JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) {
+  return 0;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    lookupByAddress0
+ * Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;
+ */
+JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByAddress0
+  (JNIEnv *env, jobject this_obj, jlong addr) {
+  return 0;
+}
+
+/*
+ * Class:     sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal
+ * Method:    readBytesFromProcess0
+ * Signature: (JJ)Lsun/jvm/hotspot/debugger/ReadResult;
+ */
+JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0
+  (JNIEnv *env, jobject this_obj, jlong addr, jlong numBytes) {
+  return 0;
+}
+
+JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0
+  (JNIEnv *env, jobject this_obj, jint lwp_id) {
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/elfmacros.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * 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 _ELFMACROS_H_
+#define _ELFMACROS_H_
+
+#define ELF_NHDR        Elf_Note
+
+#if defined(_LP64)
+#define ELF_EHDR        Elf64_Ehdr
+#define ELF_SHDR        Elf64_Shdr
+#define ELF_PHDR        Elf64_Phdr
+#define ELF_SYM         Elf64_Sym
+#define ELF_DYN         Elf64_Dyn
+#define ELF_ADDR        Elf64_Addr
+
+#ifndef ELF_ST_TYPE
+#define ELF_ST_TYPE     ELF64_ST_TYPE
+#endif
+
+#else
+
+#define ELF_EHDR        Elf32_Ehdr
+#define ELF_SHDR        Elf32_Shdr
+#define ELF_PHDR        Elf32_Phdr
+#define ELF_SYM         Elf32_Sym
+#define ELF_DYN         Elf32_Dyn
+#define ELF_ADDR        Elf32_Addr
+
+#ifndef ELF_ST_TYPE
+#define ELF_ST_TYPE     ELF32_ST_TYPE
+#endif
+
+#endif
+
+
+#endif /* _ELFMACROS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/libproc.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * 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 _LIBPROC_H_
+#define _LIBPROC_H_
+
+#include <unistd.h>
+#include <stdint.h>
+#include <machine/reg.h>
+#include <proc_service.h>
+
+#if defined(sparc) || defined(sparcv9)
+/*
+  If _LP64 is defined ptrace.h should be taken from /usr/include/asm-sparc64
+  otherwise it should be from /usr/include/asm-sparc
+  These two files define pt_regs structure differently
+*/
+#ifdef _LP64
+#include "asm-sparc64/ptrace.h"
+#else
+#include "asm-sparc/ptrace.h"
+#endif
+
+#endif //sparc or sparcv9
+
+/************************************************************************************
+
+0. This is very minimal subset of Solaris libproc just enough for current application.
+Please note that the bulk of the functionality is from proc_service interface. This
+adds Pgrab__ and some missing stuff. We hide the difference b/w live process and core
+file by this interface.
+
+1. pthread_id is unique. We store this in OSThread::_pthread_id in JVM code.
+
+2. All threads see the same pid when they call getpid().
+We used to save the result of ::getpid() call in OSThread::_thread_id.
+Because gettid returns actual pid of thread (lwp id), this is
+unique again. We therefore use OSThread::_thread_id as unique identifier.
+
+3. There is a unique LWP id under both thread libraries. libthread_db  maps pthread_id
+to its underlying lwp_id under both the thread libraries. thread_info.lwp_id stores
+lwp_id of the thread. The lwp id is nothing but the actual pid of clone'd processes. But
+unfortunately libthread_db does not work very well for core dumps. So, we get pthread_id
+only for processes. For core dumps, we don't use libthread_db at all (like gdb).
+
+4. ptrace operates on this LWP id under both the thread libraries. When we say 'pid' for
+ptrace call, we refer to lwp_id of the thread.
+
+5. for core file, we parse ELF files and read data from them. For processes we  use
+combination of ptrace and /proc calls.
+
+*************************************************************************************/
+
+// This C bool type must be int for compatibility with BSD calls and
+// it would be a mistake to equivalence it to C++ bool on many platforms
+
+typedef int bool;
+#define true  1
+#define false 0
+
+struct ps_prochandle;
+
+// attach to a process
+struct ps_prochandle* Pgrab(pid_t pid);
+
+// attach to a core dump
+struct ps_prochandle* Pgrab_core(const char* execfile, const char* corefile);
+
+// release a process or core
+void Prelease(struct ps_prochandle* ph);
+
+// functions not directly available in Solaris libproc
+
+// initialize libproc (call this only once per app)
+// pass true to make library verbose
+bool init_libproc(bool verbose);
+
+// get number of threads
+int get_num_threads(struct ps_prochandle* ph);
+
+// get lwp_id of n'th thread
+lwpid_t get_lwp_id(struct ps_prochandle* ph, int index);
+
+// get regs for a given lwp
+bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lid, struct reg* regs);
+
+// get number of shared objects
+int get_num_libs(struct ps_prochandle* ph);
+
+// get name of n'th lib
+const char* get_lib_name(struct ps_prochandle* ph, int index);
+
+// get base of lib
+uintptr_t get_lib_base(struct ps_prochandle* ph, int index);
+
+// returns true if given library is found in lib list
+bool find_lib(struct ps_prochandle* ph, const char *lib_name);
+
+// symbol lookup
+uintptr_t lookup_symbol(struct ps_prochandle* ph,  const char* object_name,
+                       const char* sym_name);
+
+// address->nearest symbol lookup. return NULL for no symbol
+const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* poffset);
+
+#endif //__LIBPROC_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/libproc_impl.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,452 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <thread_db.h>
+#include "libproc_impl.h"
+
+static const char* alt_root = NULL;
+static int alt_root_len = -1;
+
+#define SA_ALTROOT "SA_ALTROOT"
+
+static void init_alt_root() {
+   if (alt_root_len == -1) {
+      alt_root = getenv(SA_ALTROOT);
+      if (alt_root) {
+         alt_root_len = strlen(alt_root);
+      } else {
+         alt_root_len = 0;
+      }
+   }
+}
+
+int pathmap_open(const char* name) {
+   int fd;
+   char alt_path[PATH_MAX + 1];
+
+   init_alt_root();
+   fd = open(name, O_RDONLY);
+   if (fd >= 0) {
+      return fd;
+   }
+
+   if (alt_root_len > 0) {
+      strcpy(alt_path, alt_root);
+      strcat(alt_path, name);
+      fd = open(alt_path, O_RDONLY);
+      if (fd >= 0) {
+         print_debug("path %s substituted for %s\n", alt_path, name);
+         return fd;
+      }
+
+      if (strrchr(name, '/')) {
+         strcpy(alt_path, alt_root);
+         strcat(alt_path, strrchr(name, '/'));
+         fd = open(alt_path, O_RDONLY);
+         if (fd >= 0) {
+            print_debug("path %s substituted for %s\n", alt_path, name);
+            return fd;
+         }
+      }
+   }
+
+   return -1;
+}
+
+static bool _libsaproc_debug;
+
+void print_debug(const char* format,...) {
+   if (_libsaproc_debug) {
+     va_list alist;
+
+     va_start(alist, format);
+     fputs("libsaproc DEBUG: ", stderr);
+     vfprintf(stderr, format, alist);
+     va_end(alist);
+   }
+}
+
+bool is_debug() {
+   return _libsaproc_debug;
+}
+
+// initialize libproc
+bool init_libproc(bool debug) {
+   // init debug mode
+   _libsaproc_debug = debug;
+
+   // initialize the thread_db library
+   if (td_init() != TD_OK) {
+     print_debug("libthread_db's td_init failed\n");
+     return false;
+   }
+
+   return true;
+}
+
+static void destroy_lib_info(struct ps_prochandle* ph) {
+   lib_info* lib = ph->libs;
+   while (lib) {
+     lib_info *next = lib->next;
+     if (lib->symtab) {
+        destroy_symtab(lib->symtab);
+     }
+     free(lib);
+     lib = next;
+   }
+}
+
+static void destroy_thread_info(struct ps_prochandle* ph) {
+   thread_info* thr = ph->threads;
+   while (thr) {
+     thread_info *next = thr->next;
+     free(thr);
+     thr = next;
+   }
+}
+
+// ps_prochandle cleanup
+
+// ps_prochandle cleanup
+void Prelease(struct ps_prochandle* ph) {
+   // do the "derived class" clean-up first
+   ph->ops->release(ph);
+   destroy_lib_info(ph);
+   destroy_thread_info(ph);
+   free(ph);
+}
+
+lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t base) {
+   return add_lib_info_fd(ph, libname, -1, base);
+}
+
+lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd, uintptr_t base) {
+   lib_info* newlib;
+
+   if ( (newlib = (lib_info*) calloc(1, sizeof(struct lib_info))) == NULL) {
+      print_debug("can't allocate memory for lib_info\n");
+      return NULL;
+   }
+
+   strncpy(newlib->name, libname, sizeof(newlib->name));
+   newlib->base = base;
+
+   if (fd == -1) {
+      if ( (newlib->fd = pathmap_open(newlib->name)) < 0) {
+         print_debug("can't open shared object %s\n", newlib->name);
+         free(newlib);
+         return NULL;
+      }
+   } else {
+      newlib->fd = fd;
+   }
+
+   // check whether we have got an ELF file. /proc/<pid>/map
+   // gives out all file mappings and not just shared objects
+   if (is_elf_file(newlib->fd) == false) {
+      close(newlib->fd);
+      free(newlib);
+      return NULL;
+   }
+
+   newlib->symtab = build_symtab(newlib->fd);
+   if (newlib->symtab == NULL) {
+      print_debug("symbol table build failed for %s\n", newlib->name);
+   }
+   else {
+      print_debug("built symbol table for %s\n", newlib->name);
+   }
+
+   // even if symbol table building fails, we add the lib_info.
+   // This is because we may need to read from the ELF file for core file
+   // address read functionality. lookup_symbol checks for NULL symtab.
+   if (ph->libs) {
+      ph->lib_tail->next = newlib;
+      ph->lib_tail = newlib;
+   }  else {
+      ph->libs = ph->lib_tail = newlib;
+   }
+   ph->num_libs++;
+
+   return newlib;
+}
+
+// lookup for a specific symbol
+uintptr_t lookup_symbol(struct ps_prochandle* ph,  const char* object_name,
+                       const char* sym_name) {
+   // ignore object_name. search in all libraries
+   // FIXME: what should we do with object_name?? The library names are obtained
+   // by parsing /proc/<pid>/maps, which may not be the same as object_name.
+   // What we need is a utility to map object_name to real file name, something
+   // dlopen() does by looking at LD_LIBRARY_PATH and /etc/ld.so.cache. For
+   // now, we just ignore object_name and do a global search for the symbol.
+
+   lib_info* lib = ph->libs;
+   while (lib) {
+      if (lib->symtab) {
+         uintptr_t res = search_symbol(lib->symtab, lib->base, sym_name, NULL);
+         if (res) return res;
+      }
+      lib = lib->next;
+   }
+
+   print_debug("lookup failed for symbol '%s' in obj '%s'\n",
+                          sym_name, object_name);
+   return (uintptr_t) NULL;
+}
+
+
+const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* poffset) {
+   const char* res = NULL;
+   lib_info* lib = ph->libs;
+   while (lib) {
+      if (lib->symtab && addr >= lib->base) {
+         res = nearest_symbol(lib->symtab, addr - lib->base, poffset);
+         if (res) return res;
+      }
+      lib = lib->next;
+   }
+   return NULL;
+}
+
+// add a thread to ps_prochandle
+thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
+   thread_info* newthr;
+   if ( (newthr = (thread_info*) calloc(1, sizeof(thread_info))) == NULL) {
+      print_debug("can't allocate memory for thread_info\n");
+      return NULL;
+   }
+
+   // initialize thread info
+   newthr->pthread_id = pthread_id;
+   newthr->lwp_id = lwp_id;
+
+   // add new thread to the list
+   newthr->next = ph->threads;
+   ph->threads = newthr;
+   ph->num_threads++;
+   return newthr;
+}
+
+
+// struct used for client data from thread_db callback
+struct thread_db_client_data {
+   struct ps_prochandle* ph;
+   thread_info_callback callback;
+};
+
+// callback function for libthread_db
+static int thread_db_callback(const td_thrhandle_t *th_p, void *data) {
+  struct thread_db_client_data* ptr = (struct thread_db_client_data*) data;
+  td_thrinfo_t ti;
+  td_err_e err;
+
+  memset(&ti, 0, sizeof(ti));
+  err = td_thr_get_info(th_p, &ti);
+  if (err != TD_OK) {
+    print_debug("libthread_db : td_thr_get_info failed, can't get thread info\n");
+    return err;
+  }
+
+  print_debug("thread_db : pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);
+
+  if (ptr->callback(ptr->ph, (pthread_t)ti.ti_tid, ti.ti_lid) != true)
+    return TD_ERR;
+
+  return TD_OK;
+}
+
+// read thread_info using libthread_db
+bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb) {
+  struct thread_db_client_data mydata;
+  td_thragent_t* thread_agent = NULL;
+  if (td_ta_new(ph, &thread_agent) != TD_OK) {
+     print_debug("can't create libthread_db agent\n");
+     return false;
+  }
+
+  mydata.ph = ph;
+  mydata.callback = cb;
+
+  // we use libthread_db iterator to iterate thru list of threads.
+  if (td_ta_thr_iter(thread_agent, thread_db_callback, &mydata,
+                 TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
+                 TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS) != TD_OK) {
+     td_ta_delete(thread_agent);
+     return false;
+  }
+
+  // delete thread agent
+  td_ta_delete(thread_agent);
+  return true;
+}
+
+
+// get number of threads
+int get_num_threads(struct ps_prochandle* ph) {
+   return ph->num_threads;
+}
+
+// get lwp_id of n'th thread
+lwpid_t get_lwp_id(struct ps_prochandle* ph, int index) {
+   int count = 0;
+   thread_info* thr = ph->threads;
+   while (thr) {
+      if (count == index) {
+         return thr->lwp_id;
+      }
+      count++;
+      thr = thr->next;
+   }
+   return -1;
+}
+
+// get regs for a given lwp
+bool get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs) {
+  return ph->ops->get_lwp_regs(ph, lwp_id, regs);
+}
+
+// get number of shared objects
+int get_num_libs(struct ps_prochandle* ph) {
+   return ph->num_libs;
+}
+
+// get name of n'th solib
+const char* get_lib_name(struct ps_prochandle* ph, int index) {
+   int count = 0;
+   lib_info* lib = ph->libs;
+   while (lib) {
+      if (count == index) {
+         return lib->name;
+      }
+      count++;
+      lib = lib->next;
+   }
+   return NULL;
+}
+
+// get base address of a lib
+uintptr_t get_lib_base(struct ps_prochandle* ph, int index) {
+   int count = 0;
+   lib_info* lib = ph->libs;
+   while (lib) {
+      if (count == index) {
+         return lib->base;
+      }
+      count++;
+      lib = lib->next;
+   }
+   return (uintptr_t)NULL;
+}
+
+bool find_lib(struct ps_prochandle* ph, const char *lib_name) {
+  lib_info *p = ph->libs;
+  while (p) {
+    if (strcmp(p->name, lib_name) == 0) {
+      return true;
+    }
+    p = p->next;
+  }
+  return false;
+}
+
+//--------------------------------------------------------------------------
+// proc service functions
+
+// ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
+// of the load object object_name in the target process identified by ph.
+// It returns the symbol's value as an address in the target process in
+// *sym_addr.
+
+ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
+                    const char *sym_name, psaddr_t *sym_addr) {
+  *sym_addr = (psaddr_t) lookup_symbol(ph, object_name, sym_name);
+  return (*sym_addr ? PS_OK : PS_NOSYM);
+}
+
+// read "size" bytes info "buf" from address "addr"
+ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t  addr,
+                  void *buf, size_t size) {
+  return ph->ops->p_pread(ph, (uintptr_t) addr, buf, size)? PS_OK: PS_ERR;
+}
+
+// write "size" bytes of data to debuggee at address "addr"
+ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr,
+                   const void *buf, size_t size) {
+  return ph->ops->p_pwrite(ph, (uintptr_t)addr, buf, size)? PS_OK: PS_ERR;
+}
+
+// fill in ptrace_lwpinfo for lid
+ps_err_e ps_linfo(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+  return ph->ops->get_lwp_info(ph, lwp_id, linfo)? PS_OK: PS_ERR;
+}
+
+// needed for when libthread_db is compiled with TD_DEBUG defined
+void
+ps_plog (const char *format, ...)
+{
+  va_list alist;
+
+  va_start(alist, format);
+  vfprintf(stderr, format, alist);
+  va_end(alist);
+}
+
+// ------------------------------------------------------------------------
+// Functions below this point are not yet implemented. They are here only
+// to make the linker happy.
+
+ps_err_e ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lid, const prfpregset_t *fpregs) {
+  print_debug("ps_lsetfpregs not implemented\n");
+  return PS_OK;
+}
+
+ps_err_e ps_lsetregs(struct ps_prochandle *ph, lwpid_t lid, const prgregset_t gregset) {
+  print_debug("ps_lsetregs not implemented\n");
+  return PS_OK;
+}
+
+ps_err_e  ps_lgetfpregs(struct  ps_prochandle  *ph,  lwpid_t lid, prfpregset_t *fpregs) {
+  print_debug("ps_lgetfpregs not implemented\n");
+  return PS_OK;
+}
+
+ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset) {
+  print_debug("ps_lgetfpregs not implemented\n");
+  return PS_OK;
+}
+
+ps_err_e ps_lstop(struct ps_prochandle *ph, lwpid_t lid) {
+  print_debug("ps_lstop not implemented\n");
+  return PS_OK;
+}
+
+ps_err_e ps_pcontinue(struct ps_prochandle *ph) {
+  print_debug("ps_pcontinue not implemented\n");
+  return PS_OK;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/libproc_impl.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * 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 _LIBPROC_IMPL_H_
+#define _LIBPROC_IMPL_H_
+
+#include <unistd.h>
+#include <limits.h>
+#include "libproc.h"
+#include "symtab.h"
+
+// data structures in this file mimic those of Solaris 8.0 - libproc's Pcontrol.h
+
+#define BUF_SIZE     (PATH_MAX + NAME_MAX + 1)
+
+// list of shared objects
+typedef struct lib_info {
+  char             name[BUF_SIZE];
+  uintptr_t        base;
+  struct symtab*   symtab;
+  int              fd;        // file descriptor for lib
+  struct lib_info* next;
+} lib_info;
+
+// list of threads
+typedef struct thread_info {
+   lwpid_t                  lwp_id;
+   pthread_t                pthread_id; // not used cores, always -1
+   struct reg               regs;       // not for process, core uses for caching regset
+   struct thread_info*      next;
+} thread_info;
+
+// list of virtual memory maps
+typedef struct map_info {
+   int              fd;       // file descriptor
+   off_t            offset;   // file offset of this mapping
+   uintptr_t        vaddr;    // starting virtual address
+   size_t           memsz;    // size of the mapping
+   struct map_info* next;
+} map_info;
+
+// vtable for ps_prochandle
+typedef struct ps_prochandle_ops {
+   // "derived class" clean-up
+   void (*release)(struct ps_prochandle* ph);
+   // read from debuggee
+   bool (*p_pread)(struct ps_prochandle *ph,
+            uintptr_t addr, char *buf, size_t size);
+   // write into debuggee
+   bool (*p_pwrite)(struct ps_prochandle *ph,
+            uintptr_t addr, const char *buf , size_t size);
+   // get integer regset of a thread
+   bool (*get_lwp_regs)(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs);
+   // get info on thread
+   bool (*get_lwp_info)(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo);
+} ps_prochandle_ops;
+
+// the ps_prochandle
+
+struct core_data {
+   int                core_fd;   // file descriptor of core file
+   int                exec_fd;   // file descriptor of exec file
+   int                interp_fd; // file descriptor of interpreter (ld-elf.so.1)
+   // part of the class sharing workaround
+   int                classes_jsa_fd; // file descriptor of class share archive
+   uintptr_t          dynamic_addr;  // address of dynamic section of a.out
+   uintptr_t          ld_base_addr;  // base address of ld.so
+   size_t             num_maps;  // number of maps.
+   map_info*          maps;      // maps in a linked list
+   // part of the class sharing workaround
+   map_info*          class_share_maps;// class share maps in a linked list
+   map_info**         map_array; // sorted (by vaddr) array of map_info pointers
+};
+
+struct ps_prochandle {
+   ps_prochandle_ops* ops;       // vtable ptr
+   pid_t              pid;
+   int                num_libs;
+   lib_info*          libs;      // head of lib list
+   lib_info*          lib_tail;  // tail of lib list - to append at the end
+   int                num_threads;
+   thread_info*       threads;   // head of thread list
+   struct core_data*  core;      // data only used for core dumps, NULL for process
+};
+
+int pathmap_open(const char* name);
+
+void print_debug(const char* format,...);
+bool is_debug();
+
+typedef bool (*thread_info_callback)(struct ps_prochandle* ph, pthread_t pid, lwpid_t lwpid);
+
+// reads thread info using libthread_db and calls above callback for each thread
+bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb);
+
+// adds a new shared object to lib list, returns NULL on failure
+lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t base);
+
+// adds a new shared object to lib list, supply open lib file descriptor as well
+lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
+                          uintptr_t base);
+
+// adds a new thread to threads list, returns NULL on failure
+thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id);
+
+// a test for ELF signature without using libelf
+bool is_elf_file(int fd);
+
+#endif //_LIBPROC_IMPL_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/mapfile	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,66 @@
+#
+
+#
+# Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Define public interface.
+
+SUNWprivate_1.1 {
+        global:
+
+		# native methods of BsdDebuggerLocal class
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_init0;
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getAddressSize;
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__I;
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2;
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_detach0;
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByName0;
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_lookupByAddress0;
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_readBytesFromProcess0;
+		Java_sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal_getThreadIntegerRegisterSet0;
+	
+		# proc_service.h functions - to be used by libthread_db
+		ps_getpid;
+		ps_pglobal_lookup;
+		ps_pread;
+		ps_pwrite;
+		ps_lsetfpregs;
+		ps_lsetregs;
+		ps_lgetfpregs;
+		ps_lgetregs;
+		ps_lcontinue;
+		ps_lgetxmmregs;
+		ps_lsetxmmregs;
+		ps_lstop;
+		ps_linfo;
+
+                # used by attach test program
+                init_libproc;
+                Pgrab;
+                Pgrab_core;
+                Prelease;
+	
+	local:
+		*;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/ps_core.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,1023 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include <jni.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <elf.h>
+#include <link.h>
+#include "libproc_impl.h"
+#include "salibelf.h"
+
+// This file has the libproc implementation to read core files.
+// For live processes, refer to ps_proc.c. Portions of this is adapted
+// /modelled after Solaris libproc.so (in particular Pcore.c)
+
+//----------------------------------------------------------------------
+// ps_prochandle cleanup helper functions
+
+// close all file descriptors
+static void close_elf_files(struct ps_prochandle* ph) {
+   lib_info* lib = NULL;
+
+   // close core file descriptor
+   if (ph->core->core_fd >= 0)
+     close(ph->core->core_fd);
+
+   // close exec file descriptor
+   if (ph->core->exec_fd >= 0)
+     close(ph->core->exec_fd);
+
+   // close interp file descriptor
+   if (ph->core->interp_fd >= 0)
+     close(ph->core->interp_fd);
+
+   // close class share archive file
+   if (ph->core->classes_jsa_fd >= 0)
+     close(ph->core->classes_jsa_fd);
+
+   // close all library file descriptors
+   lib = ph->libs;
+   while (lib) {
+      int fd = lib->fd;
+      if (fd >= 0 && fd != ph->core->exec_fd) close(fd);
+      lib = lib->next;
+   }
+}
+
+// clean all map_info stuff
+static void destroy_map_info(struct ps_prochandle* ph) {
+  map_info* map = ph->core->maps;
+  while (map) {
+     map_info* next = map->next;
+     free(map);
+     map = next;
+  }
+
+  if (ph->core->map_array) {
+     free(ph->core->map_array);
+  }
+
+  // Part of the class sharing workaround
+  map = ph->core->class_share_maps;
+  while (map) {
+     map_info* next = map->next;
+     free(map);
+     map = next;
+  }
+}
+
+// ps_prochandle operations
+static void core_release(struct ps_prochandle* ph) {
+   if (ph->core) {
+      close_elf_files(ph);
+      destroy_map_info(ph);
+      free(ph->core);
+   }
+}
+
+static map_info* allocate_init_map(int fd, off_t offset, uintptr_t vaddr, size_t memsz) {
+   map_info* map;
+   if ( (map = (map_info*) calloc(1, sizeof(map_info))) == NULL) {
+      print_debug("can't allocate memory for map_info\n");
+      return NULL;
+   }
+
+   // initialize map
+   map->fd     = fd;
+   map->offset = offset;
+   map->vaddr  = vaddr;
+   map->memsz  = memsz;
+   return map;
+}
+
+// add map info with given fd, offset, vaddr and memsz
+static map_info* add_map_info(struct ps_prochandle* ph, int fd, off_t offset,
+                             uintptr_t vaddr, size_t memsz) {
+   map_info* map;
+   if ((map = allocate_init_map(fd, offset, vaddr, memsz)) == NULL) {
+      return NULL;
+   }
+
+   // add this to map list
+   map->next  = ph->core->maps;
+   ph->core->maps   = map;
+   ph->core->num_maps++;
+
+   return map;
+}
+
+// Part of the class sharing workaround
+static map_info* add_class_share_map_info(struct ps_prochandle* ph, off_t offset,
+                             uintptr_t vaddr, size_t memsz) {
+   map_info* map;
+   if ((map = allocate_init_map(ph->core->classes_jsa_fd,
+                                offset, vaddr, memsz)) == NULL) {
+      return NULL;
+   }
+
+   map->next = ph->core->class_share_maps;
+   ph->core->class_share_maps = map;
+   return map;
+}
+
+// Return the map_info for the given virtual address.  We keep a sorted
+// array of pointers in ph->map_array, so we can binary search.
+static map_info* core_lookup(struct ps_prochandle *ph, uintptr_t addr)
+{
+   int mid, lo = 0, hi = ph->core->num_maps - 1;
+   map_info *mp;
+
+   while (hi - lo > 1) {
+     mid = (lo + hi) / 2;
+      if (addr >= ph->core->map_array[mid]->vaddr)
+         lo = mid;
+      else
+         hi = mid;
+   }
+
+   if (addr < ph->core->map_array[hi]->vaddr)
+      mp = ph->core->map_array[lo];
+   else
+      mp = ph->core->map_array[hi];
+
+   if (addr >= mp->vaddr && addr < mp->vaddr + mp->memsz)
+      return (mp);
+
+
+   // Part of the class sharing workaround
+   // Unfortunately, we have no way of detecting -Xshare state.
+   // Check out the share maps atlast, if we don't find anywhere.
+   // This is done this way so to avoid reading share pages
+   // ahead of other normal maps. For eg. with -Xshare:off we don't
+   // want to prefer class sharing data to data from core.
+   mp = ph->core->class_share_maps;
+   if (mp) {
+      print_debug("can't locate map_info at 0x%lx, trying class share maps\n",
+             addr);
+   }
+   while (mp) {
+      if (addr >= mp->vaddr && addr < mp->vaddr + mp->memsz) {
+         print_debug("located map_info at 0x%lx from class share maps\n",
+                  addr);
+         return (mp);
+      }
+      mp = mp->next;
+   }
+
+   print_debug("can't locate map_info at 0x%lx\n", addr);
+   return (NULL);
+}
+
+//---------------------------------------------------------------
+// Part of the class sharing workaround:
+//
+// With class sharing, pages are mapped from classes[_g].jsa file.
+// The read-only class sharing pages are mapped as MAP_SHARED,
+// PROT_READ pages. These pages are not dumped into core dump.
+// With this workaround, these pages are read from classes[_g].jsa.
+
+// FIXME: !HACK ALERT!
+// The format of sharing achive file header is needed to read shared heap
+// file mappings. For now, I am hard coding portion of FileMapHeader here.
+// Refer to filemap.hpp.
+
+// FileMapHeader describes the shared space data in the file to be
+// mapped.  This structure gets written to a file.  It is not a class,
+// so that the compilers don't add any compiler-private data to it.
+
+// Refer to CompactingPermGenGen::n_regions in compactingPermGenGen.hpp
+#define NUM_SHARED_MAPS 4
+
+// Refer to FileMapInfo::_current_version in filemap.hpp
+#define CURRENT_ARCHIVE_VERSION 1
+
+struct FileMapHeader {
+  int   _magic;              // identify file type.
+  int   _version;            // (from enum, above.)
+  size_t _alignment;         // how shared archive should be aligned
+
+  struct space_info {
+    int    _file_offset;     // sizeof(this) rounded to vm page size
+    char*  _base;            // copy-on-write base address
+    size_t _capacity;        // for validity checking
+    size_t _used;            // for setting space top on read
+
+    // 4991491 NOTICE These are C++ bool's in filemap.hpp and must match up with
+    // the C type matching the C++ bool type on any given platform. For
+    // Hotspot on BSD we assume the corresponding C type is char but
+    // licensees on BSD versions may need to adjust the type of these fields.
+    char   _read_only;       // read only space?
+    char   _allow_exec;      // executable code in space?
+
+  } _space[NUM_SHARED_MAPS]; // was _space[CompactingPermGenGen::n_regions];
+
+  // Ignore the rest of the FileMapHeader. We don't need those fields here.
+};
+
+static bool read_jboolean(struct ps_prochandle* ph, uintptr_t addr, jboolean* pvalue) {
+   jboolean i;
+   if (ps_pread(ph, (psaddr_t) addr, &i, sizeof(i)) == PS_OK) {
+      *pvalue = i;
+      return true;
+   } else {
+      return false;
+   }
+}
+
+static bool read_pointer(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* pvalue) {
+   uintptr_t uip;
+   if (ps_pread(ph, (psaddr_t) addr, &uip, sizeof(uip)) == PS_OK) {
+      *pvalue = uip;
+      return true;
+   } else {
+      return false;
+   }
+}
+
+// used to read strings from debuggee
+static bool read_string(struct ps_prochandle* ph, uintptr_t addr, char* buf, size_t size) {
+   size_t i = 0;
+   char  c = ' ';
+
+   while (c != '\0') {
+     if (ps_pread(ph, (psaddr_t) addr, &c, sizeof(char)) != PS_OK)
+         return false;
+      if (i < size - 1)
+         buf[i] = c;
+      else // smaller buffer
+         return false;
+      i++; addr++;
+   }
+
+   buf[i] = '\0';
+   return true;
+}
+
+#define USE_SHARED_SPACES_SYM "UseSharedSpaces"
+// mangled name of Arguments::SharedArchivePath
+#define SHARED_ARCHIVE_PATH_SYM "_ZN9Arguments17SharedArchivePathE"
+
+static bool init_classsharing_workaround(struct ps_prochandle* ph) {
+   lib_info* lib = ph->libs;
+   while (lib != NULL) {
+      // we are iterating over shared objects from the core dump. look for
+      // libjvm[_g].so.
+      const char *jvm_name = 0;
+      if ((jvm_name = strstr(lib->name, "/libjvm.so")) != 0 ||
+          (jvm_name = strstr(lib->name, "/libjvm_g.so")) != 0) {
+         char classes_jsa[PATH_MAX];
+         struct FileMapHeader header;
+         size_t n = 0;
+         int fd = -1, m = 0;
+         uintptr_t base = 0, useSharedSpacesAddr = 0;
+         uintptr_t sharedArchivePathAddrAddr = 0, sharedArchivePathAddr = 0;
+         jboolean useSharedSpaces = 0;
+
+         memset(classes_jsa, 0, sizeof(classes_jsa));
+         jvm_name = lib->name;
+         useSharedSpacesAddr = lookup_symbol(ph, jvm_name, USE_SHARED_SPACES_SYM);
+         if (useSharedSpacesAddr == 0) {
+            print_debug("can't lookup 'UseSharedSpaces' flag\n");
+            return false;
+         }
+
+         // Hotspot vm types are not exported to build this library. So
+         // using equivalent type jboolean to read the value of
+         // UseSharedSpaces which is same as hotspot type "bool".
+         if (read_jboolean(ph, useSharedSpacesAddr, &useSharedSpaces) != true) {
+            print_debug("can't read the value of 'UseSharedSpaces' flag\n");
+            return false;
+         }
+
+         if ((int)useSharedSpaces == 0) {
+            print_debug("UseSharedSpaces is false, assuming -Xshare:off!\n");
+            return true;
+         }
+
+         sharedArchivePathAddrAddr = lookup_symbol(ph, jvm_name, SHARED_ARCHIVE_PATH_SYM);
+         if (sharedArchivePathAddrAddr == 0) {
+            print_debug("can't lookup shared archive path symbol\n");
+            return false;
+         }
+
+         if (read_pointer(ph, sharedArchivePathAddrAddr, &sharedArchivePathAddr) != true) {
+            print_debug("can't read shared archive path pointer\n");
+            return false;
+         }
+
+         if (read_string(ph, sharedArchivePathAddr, classes_jsa, sizeof(classes_jsa)) != true) {
+            print_debug("can't read shared archive path value\n");
+            return false;
+         }
+
+         print_debug("looking for %s\n", classes_jsa);
+         // open the class sharing archive file
+         fd = pathmap_open(classes_jsa);
+         if (fd < 0) {
+            print_debug("can't open %s!\n", classes_jsa);
+            ph->core->classes_jsa_fd = -1;
+            return false;
+         } else {
+            print_debug("opened %s\n", classes_jsa);
+         }
+
+         // read FileMapHeader from the file
+         memset(&header, 0, sizeof(struct FileMapHeader));
+         if ((n = read(fd, &header, sizeof(struct FileMapHeader)))
+              != sizeof(struct FileMapHeader)) {
+            print_debug("can't read shared archive file map header from %s\n", classes_jsa);
+            close(fd);
+            return false;
+         }
+
+         // check file magic
+         if (header._magic != 0xf00baba2) {
+            print_debug("%s has bad shared archive file magic number 0x%x, expecing 0xf00baba2\n",
+                        classes_jsa, header._magic);
+            close(fd);
+            return false;
+         }
+
+         // check version
+         if (header._version != CURRENT_ARCHIVE_VERSION) {
+            print_debug("%s has wrong shared archive file version %d, expecting %d\n",
+                        classes_jsa, header._version, CURRENT_ARCHIVE_VERSION);
+            close(fd);
+            return false;
+         }
+
+         ph->core->classes_jsa_fd = fd;
+         // add read-only maps from classes[_g].jsa to the list of maps
+         for (m = 0; m < NUM_SHARED_MAPS; m++) {
+            if (header._space[m]._read_only) {
+               base = (uintptr_t) header._space[m]._base;
+               // no need to worry about the fractional pages at-the-end.
+               // possible fractional pages are handled by core_read_data.
+               add_class_share_map_info(ph, (off_t) header._space[m]._file_offset,
+                         base, (size_t) header._space[m]._used);
+               print_debug("added a share archive map at 0x%lx\n", base);
+            }
+         }
+         return true;
+      }
+      lib = lib->next;
+   }
+   return true;
+}
+
+
+//---------------------------------------------------------------------------
+// functions to handle map_info
+
+// Order mappings based on virtual address.  We use this function as the
+// callback for sorting the array of map_info pointers.
+static int core_cmp_mapping(const void *lhsp, const void *rhsp)
+{
+   const map_info *lhs = *((const map_info **)lhsp);
+   const map_info *rhs = *((const map_info **)rhsp);
+
+   if (lhs->vaddr == rhs->vaddr)
+      return (0);
+
+   return (lhs->vaddr < rhs->vaddr ? -1 : 1);
+}
+
+// we sort map_info by starting virtual address so that we can do
+// binary search to read from an address.
+static bool sort_map_array(struct ps_prochandle* ph) {
+   size_t num_maps = ph->core->num_maps;
+   map_info* map = ph->core->maps;
+   int i = 0;
+
+   // allocate map_array
+   map_info** array;
+   if ( (array = (map_info**) malloc(sizeof(map_info*) * num_maps)) == NULL) {
+      print_debug("can't allocate memory for map array\n");
+      return false;
+   }
+
+   // add maps to array
+   while (map) {
+      array[i] = map;
+      i++;
+      map = map->next;
+   }
+
+   // sort is called twice. If this is second time, clear map array
+   if (ph->core->map_array) free(ph->core->map_array);
+   ph->core->map_array = array;
+   // sort the map_info array by base virtual address.
+   qsort(ph->core->map_array, ph->core->num_maps, sizeof (map_info*),
+            core_cmp_mapping);
+
+   // print map
+   if (is_debug()) {
+      int j = 0;
+      print_debug("---- sorted virtual address map ----\n");
+      for (j = 0; j < ph->core->num_maps; j++) {
+        print_debug("base = 0x%lx\tsize = %d\n", ph->core->map_array[j]->vaddr,
+                                         ph->core->map_array[j]->memsz);
+      }
+   }
+
+   return true;
+}
+
+#ifndef MIN
+#define MIN(x, y) (((x) < (y))? (x): (y))
+#endif
+
+static bool core_read_data(struct ps_prochandle* ph, uintptr_t addr, char *buf, size_t size) {
+   ssize_t resid = size;
+   int page_size=sysconf(_SC_PAGE_SIZE);
+   while (resid != 0) {
+      map_info *mp = core_lookup(ph, addr);
+      uintptr_t mapoff;
+      ssize_t len, rem;
+      off_t off;
+      int fd;
+
+      if (mp == NULL)
+         break;  /* No mapping for this address */
+
+      fd = mp->fd;
+      mapoff = addr - mp->vaddr;
+      len = MIN(resid, mp->memsz - mapoff);
+      off = mp->offset + mapoff;
+
+      if ((len = pread(fd, buf, len, off)) <= 0)
+         break;
+
+      resid -= len;
+      addr += len;
+      buf = (char *)buf + len;
+
+      // mappings always start at page boundary. But, may end in fractional
+      // page. fill zeros for possible fractional page at the end of a mapping.
+      rem = mp->memsz % page_size;
+      if (rem > 0) {
+         rem = page_size - rem;
+         len = MIN(resid, rem);
+         resid -= len;
+         addr += len;
+         // we are not assuming 'buf' to be zero initialized.
+         memset(buf, 0, len);
+         buf += len;
+      }
+   }
+
+   if (resid) {
+      print_debug("core read failed for %d byte(s) @ 0x%lx (%d more bytes)\n",
+              size, addr, resid);
+      return false;
+   } else {
+      return true;
+   }
+}
+
+// null implementation for write
+static bool core_write_data(struct ps_prochandle* ph,
+                             uintptr_t addr, const char *buf , size_t size) {
+   return false;
+}
+
+static bool core_get_lwp_regs(struct ps_prochandle* ph, lwpid_t lwp_id,
+                          struct reg* regs) {
+   // for core we have cached the lwp regs from NOTE section
+   thread_info* thr = ph->threads;
+   while (thr) {
+     if (thr->lwp_id == lwp_id) {
+       memcpy(regs, &thr->regs, sizeof(struct reg));
+       return true;
+     }
+     thr = thr->next;
+   }
+   return false;
+}
+
+static bool core_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+   print_debug("core_get_lwp_info not implemented\n");
+   return false;
+}
+
+static ps_prochandle_ops core_ops = {
+   .release=  core_release,
+   .p_pread=  core_read_data,
+   .p_pwrite= core_write_data,
+   .get_lwp_regs= core_get_lwp_regs,
+   .get_lwp_info= core_get_lwp_info
+};
+
+// read regs and create thread from NT_PRSTATUS entries from core file
+static bool core_handle_prstatus(struct ps_prochandle* ph, const char* buf, size_t nbytes) {
+   // we have to read prstatus_t from buf
+   // assert(nbytes == sizeof(prstaus_t), "size mismatch on prstatus_t");
+   prstatus_t* prstat = (prstatus_t*) buf;
+   thread_info* newthr;
+   print_debug("got integer regset for lwp %d\n", prstat->pr_pid);
+   // we set pthread_t to -1 for core dump
+   if((newthr = add_thread_info(ph, (pthread_t) -1,  prstat->pr_pid)) == NULL)
+      return false;
+
+   // copy regs
+   memcpy(&newthr->regs, &prstat->pr_reg, sizeof(struct reg));
+
+   if (is_debug()) {
+      print_debug("integer regset\n");
+#ifdef i386
+      // print the regset
+      print_debug("\teax = 0x%x\n", newthr->regs.r_eax);
+      print_debug("\tebx = 0x%x\n", newthr->regs.r_ebx);
+      print_debug("\tecx = 0x%x\n", newthr->regs.r_ecx);
+      print_debug("\tedx = 0x%x\n", newthr->regs.r_edx);
+      print_debug("\tesp = 0x%x\n", newthr->regs.r_esp);
+      print_debug("\tebp = 0x%x\n", newthr->regs.r_ebp);
+      print_debug("\tesi = 0x%x\n", newthr->regs.r_esi);
+      print_debug("\tedi = 0x%x\n", newthr->regs.r_edi);
+      print_debug("\teip = 0x%x\n", newthr->regs.r_eip);
+#endif
+
+#if defined(amd64) || defined(x86_64)
+      // print the regset
+      print_debug("\tr15 = 0x%lx\n", newthr->regs.r_r15);
+      print_debug("\tr14 = 0x%lx\n", newthr->regs.r_r14);
+      print_debug("\tr13 = 0x%lx\n", newthr->regs.r_r13);
+      print_debug("\tr12 = 0x%lx\n", newthr->regs.r_r12);
+      print_debug("\trbp = 0x%lx\n", newthr->regs.r_rbp);
+      print_debug("\trbx = 0x%lx\n", newthr->regs.r_rbx);
+      print_debug("\tr11 = 0x%lx\n", newthr->regs.r_r11);
+      print_debug("\tr10 = 0x%lx\n", newthr->regs.r_r10);
+      print_debug("\tr9 = 0x%lx\n", newthr->regs.r_r9);
+      print_debug("\tr8 = 0x%lx\n", newthr->regs.r_r8);
+      print_debug("\trax = 0x%lx\n", newthr->regs.r_rax);
+      print_debug("\trcx = 0x%lx\n", newthr->regs.r_rcx);
+      print_debug("\trdx = 0x%lx\n", newthr->regs.r_rdx);
+      print_debug("\trsi = 0x%lx\n", newthr->regs.r_rsi);
+      print_debug("\trdi = 0x%lx\n", newthr->regs.r_rdi);
+      //print_debug("\torig_rax = 0x%lx\n", newthr->regs.orig_rax);
+      print_debug("\trip = 0x%lx\n", newthr->regs.r_rip);
+      print_debug("\tcs = 0x%lx\n", newthr->regs.r_cs);
+      //print_debug("\teflags = 0x%lx\n", newthr->regs.eflags);
+      print_debug("\trsp = 0x%lx\n", newthr->regs.r_rsp);
+      print_debug("\tss = 0x%lx\n", newthr->regs.r_ss);
+      //print_debug("\tfs_base = 0x%lx\n", newthr->regs.fs_base);
+      //print_debug("\tgs_base = 0x%lx\n", newthr->regs.gs_base);
+      //print_debug("\tds = 0x%lx\n", newthr->regs.ds);
+      //print_debug("\tes = 0x%lx\n", newthr->regs.es);
+      //print_debug("\tfs = 0x%lx\n", newthr->regs.fs);
+      //print_debug("\tgs = 0x%lx\n", newthr->regs.gs);
+#endif
+   }
+
+   return true;
+}
+
+#define ROUNDUP(x, y)  ((((x)+((y)-1))/(y))*(y))
+
+// read NT_PRSTATUS entries from core NOTE segment
+static bool core_handle_note(struct ps_prochandle* ph, ELF_PHDR* note_phdr) {
+   char* buf = NULL;
+   char* p = NULL;
+   size_t size = note_phdr->p_filesz;
+
+   // we are interested in just prstatus entries. we will ignore the rest.
+   // Advance the seek pointer to the start of the PT_NOTE data
+   if (lseek(ph->core->core_fd, note_phdr->p_offset, SEEK_SET) == (off_t)-1) {
+      print_debug("failed to lseek to PT_NOTE data\n");
+      return false;
+   }
+
+   // Now process the PT_NOTE structures.  Each one is preceded by
+   // an Elf{32/64}_Nhdr structure describing its type and size.
+   if ( (buf = (char*) malloc(size)) == NULL) {
+      print_debug("can't allocate memory for reading core notes\n");
+      goto err;
+   }
+
+   // read notes into buffer
+   if (read(ph->core->core_fd, buf, size) != size) {
+      print_debug("failed to read notes, core file must have been truncated\n");
+      goto err;
+   }
+
+   p = buf;
+   while (p < buf + size) {
+      ELF_NHDR* notep = (ELF_NHDR*) p;
+      char* descdata  = p + sizeof(ELF_NHDR) + ROUNDUP(notep->n_namesz, 4);
+      print_debug("Note header with n_type = %d and n_descsz = %u\n",
+                                   notep->n_type, notep->n_descsz);
+
+      if (notep->n_type == NT_PRSTATUS) {
+         if (core_handle_prstatus(ph, descdata, notep->n_descsz) != true)
+            return false;
+      }
+      p = descdata + ROUNDUP(notep->n_descsz, 4);
+   }
+
+   free(buf);
+   return true;
+
+err:
+   if (buf) free(buf);
+   return false;
+}
+
+// read all segments from core file
+static bool read_core_segments(struct ps_prochandle* ph, ELF_EHDR* core_ehdr) {
+   int i = 0;
+   ELF_PHDR* phbuf = NULL;
+   ELF_PHDR* core_php = NULL;
+
+   if ((phbuf =  read_program_header_table(ph->core->core_fd, core_ehdr)) == NULL)
+      return false;
+
+   /*
+    * Now iterate through the program headers in the core file.
+    * We're interested in two types of Phdrs: PT_NOTE (which
+    * contains a set of saved /proc structures), and PT_LOAD (which
+    * represents a memory mapping from the process's address space).
+    *
+    * Difference b/w Solaris PT_NOTE and BSD PT_NOTE:
+    *
+    *     In Solaris there are two PT_NOTE segments the first PT_NOTE (if present)
+    *     contains /proc structs in the pre-2.6 unstructured /proc format. the last
+    *     PT_NOTE has data in new /proc format.
+    *
+    *     In Solaris, there is only one pstatus (process status). pstatus contains
+    *     integer register set among other stuff. For each LWP, we have one lwpstatus
+    *     entry that has integer regset for that LWP.
+    *
+    *     Linux threads are actually 'clone'd processes. To support core analysis
+    *     of "multithreaded" process, Linux creates more than one pstatus (called
+    *     "prstatus") entry in PT_NOTE. Each prstatus entry has integer regset for one
+    *     "thread". Please refer to Linux kernel src file 'fs/binfmt_elf.c', in particular
+    *     function "elf_core_dump".
+    */
+
+    for (core_php = phbuf, i = 0; i < core_ehdr->e_phnum; i++) {
+      switch (core_php->p_type) {
+         case PT_NOTE:
+            if (core_handle_note(ph, core_php) != true) goto err;
+            break;
+
+         case PT_LOAD: {
+            if (core_php->p_filesz != 0) {
+               if (add_map_info(ph, ph->core->core_fd, core_php->p_offset,
+                  core_php->p_vaddr, core_php->p_filesz) == NULL) goto err;
+            }
+            break;
+         }
+      }
+
+      core_php++;
+   }
+
+   free(phbuf);
+   return true;
+err:
+   free(phbuf);
+   return false;
+}
+
+// read segments of a shared object
+static bool read_lib_segments(struct ps_prochandle* ph, int lib_fd, ELF_EHDR* lib_ehdr, uintptr_t lib_base) {
+   int i = 0;
+   ELF_PHDR* phbuf;
+   ELF_PHDR* lib_php = NULL;
+
+   if ((phbuf = read_program_header_table(lib_fd, lib_ehdr)) == NULL)
+      return false;
+
+   // we want to process only PT_LOAD segments that are not writable.
+   // i.e., text segments. The read/write/exec (data) segments would
+   // have been already added from core file segments.
+   for (lib_php = phbuf, i = 0; i < lib_ehdr->e_phnum; i++) {
+      if ((lib_php->p_type == PT_LOAD) && !(lib_php->p_flags & PF_W) && (lib_php->p_filesz != 0)) {
+         if (add_map_info(ph, lib_fd, lib_php->p_offset, lib_php->p_vaddr + lib_base, lib_php->p_filesz) == NULL)
+            goto err;
+      }
+      lib_php++;
+   }
+
+   free(phbuf);
+   return true;
+err:
+   free(phbuf);
+   return false;
+}
+
+// process segments from interpreter (ld-elf.so.1)
+static bool read_interp_segments(struct ps_prochandle* ph) {
+   ELF_EHDR interp_ehdr;
+
+   if (read_elf_header(ph->core->interp_fd, &interp_ehdr) != true) {
+       print_debug("interpreter is not a valid ELF file\n");
+       return false;
+   }
+
+   if (read_lib_segments(ph, ph->core->interp_fd, &interp_ehdr, ph->core->ld_base_addr) != true) {
+       print_debug("can't read segments of interpreter\n");
+       return false;
+   }
+
+   return true;
+}
+
+// process segments of a a.out
+static bool read_exec_segments(struct ps_prochandle* ph, ELF_EHDR* exec_ehdr) {
+   int i = 0;
+   ELF_PHDR* phbuf = NULL;
+   ELF_PHDR* exec_php = NULL;
+
+   if ((phbuf = read_program_header_table(ph->core->exec_fd, exec_ehdr)) == NULL)
+      return false;
+
+   for (exec_php = phbuf, i = 0; i < exec_ehdr->e_phnum; i++) {
+      switch (exec_php->p_type) {
+
+         // add mappings for PT_LOAD segments
+         case PT_LOAD: {
+            // add only non-writable segments of non-zero filesz
+            if (!(exec_php->p_flags & PF_W) && exec_php->p_filesz != 0) {
+               if (add_map_info(ph, ph->core->exec_fd, exec_php->p_offset, exec_php->p_vaddr, exec_php->p_filesz) == NULL) goto err;
+            }
+            break;
+         }
+
+         // read the interpreter and it's segments
+         case PT_INTERP: {
+            char interp_name[BUF_SIZE];
+
+            pread(ph->core->exec_fd, interp_name, MIN(exec_php->p_filesz, BUF_SIZE), exec_php->p_offset);
+            print_debug("ELF interpreter %s\n", interp_name);
+            // read interpreter segments as well
+            if ((ph->core->interp_fd = pathmap_open(interp_name)) < 0) {
+               print_debug("can't open runtime loader\n");
+               goto err;
+            }
+            break;
+         }
+
+         // from PT_DYNAMIC we want to read address of first link_map addr
+         case PT_DYNAMIC: {
+            ph->core->dynamic_addr = exec_php->p_vaddr;
+            print_debug("address of _DYNAMIC is 0x%lx\n", ph->core->dynamic_addr);
+            break;
+         }
+
+      } // switch
+      exec_php++;
+   } // for
+
+   free(phbuf);
+   return true;
+err:
+   free(phbuf);
+   return false;
+}
+
+
+#define FIRST_LINK_MAP_OFFSET offsetof(struct r_debug,  r_map)
+#define LD_BASE_OFFSET        offsetof(struct r_debug,  r_ldbase)
+#define LINK_MAP_ADDR_OFFSET  offsetof(struct link_map, l_addr)
+#define LINK_MAP_NAME_OFFSET  offsetof(struct link_map, l_name)
+#define LINK_MAP_NEXT_OFFSET  offsetof(struct link_map, l_next)
+
+// read shared library info from runtime linker's data structures.
+// This work is done by librtlb_db in Solaris
+static bool read_shared_lib_info(struct ps_prochandle* ph) {
+   uintptr_t addr = ph->core->dynamic_addr;
+   uintptr_t debug_base;
+   uintptr_t first_link_map_addr;
+   uintptr_t ld_base_addr;
+   uintptr_t link_map_addr;
+   uintptr_t lib_base_diff;
+   uintptr_t lib_base;
+   uintptr_t lib_name_addr;
+   char lib_name[BUF_SIZE];
+   ELF_DYN dyn;
+   ELF_EHDR elf_ehdr;
+   int lib_fd;
+
+   // _DYNAMIC has information of the form
+   //         [tag] [data] [tag] [data] .....
+   // Both tag and data are pointer sized.
+   // We look for dynamic info with DT_DEBUG. This has shared object info.
+   // refer to struct r_debug in link.h
+
+   dyn.d_tag = DT_NULL;
+   while (dyn.d_tag != DT_DEBUG) {
+      if (ps_pread(ph, (psaddr_t) addr, &dyn, sizeof(ELF_DYN)) != PS_OK) {
+         print_debug("can't read debug info from _DYNAMIC\n");
+         return false;
+      }
+      addr += sizeof(ELF_DYN);
+   }
+
+   // we have got Dyn entry with DT_DEBUG
+   debug_base = dyn.d_un.d_ptr;
+   // at debug_base we have struct r_debug. This has first link map in r_map field
+   if (ps_pread(ph, (psaddr_t) debug_base + FIRST_LINK_MAP_OFFSET,
+                 &first_link_map_addr, sizeof(uintptr_t)) != PS_OK) {
+      print_debug("can't read first link map address\n");
+      return false;
+   }
+
+   // read ld_base address from struct r_debug
+   // XXX: There is no r_ldbase member on BSD
+/*
+   if (ps_pread(ph, (psaddr_t) debug_base + LD_BASE_OFFSET, &ld_base_addr,
+                 sizeof(uintptr_t)) != PS_OK) {
+      print_debug("can't read ld base address\n");
+      return false;
+   }
+   ph->core->ld_base_addr = ld_base_addr;
+*/
+   ph->core->ld_base_addr = 0;
+
+   print_debug("interpreter base address is 0x%lx\n", ld_base_addr);
+
+   // now read segments from interp (i.e ld-elf.so.1)
+   if (read_interp_segments(ph) != true)
+      return false;
+
+   // after adding interpreter (ld.so) mappings sort again
+   if (sort_map_array(ph) != true)
+      return false;
+
+   print_debug("first link map is at 0x%lx\n", first_link_map_addr);
+
+   link_map_addr = first_link_map_addr;
+   while (link_map_addr != 0) {
+      // read library base address of the .so. Note that even though <sys/link.h> calls
+      // link_map->l_addr as "base address",  this is * not * really base virtual
+      // address of the shared object. This is actually the difference b/w the virtual
+      // address mentioned in shared object and the actual virtual base where runtime
+      // linker loaded it. We use "base diff" in read_lib_segments call below.
+
+      if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_ADDR_OFFSET,
+                   &lib_base_diff, sizeof(uintptr_t)) != PS_OK) {
+         print_debug("can't read shared object base address diff\n");
+         return false;
+      }
+
+      // read address of the name
+      if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_NAME_OFFSET,
+                    &lib_name_addr, sizeof(uintptr_t)) != PS_OK) {
+         print_debug("can't read address of shared object name\n");
+         return false;
+      }
+
+      // read name of the shared object
+      if (read_string(ph, (uintptr_t) lib_name_addr, lib_name, sizeof(lib_name)) != true) {
+         print_debug("can't read shared object name\n");
+         return false;
+      }
+
+      if (lib_name[0] != '\0') {
+         // ignore empty lib names
+         lib_fd = pathmap_open(lib_name);
+
+         if (lib_fd < 0) {
+            print_debug("can't open shared object %s\n", lib_name);
+            // continue with other libraries...
+         } else {
+            if (read_elf_header(lib_fd, &elf_ehdr)) {
+               lib_base = lib_base_diff + find_base_address(lib_fd, &elf_ehdr);
+               print_debug("reading library %s @ 0x%lx [ 0x%lx ]\n",
+                           lib_name, lib_base, lib_base_diff);
+               // while adding library mappings we need to use "base difference".
+               if (! read_lib_segments(ph, lib_fd, &elf_ehdr, lib_base_diff)) {
+                  print_debug("can't read shared object's segments\n");
+                  close(lib_fd);
+                  return false;
+               }
+               add_lib_info_fd(ph, lib_name, lib_fd, lib_base);
+               // Map info is added for the library (lib_name) so
+               // we need to re-sort it before calling the p_pdread.
+               if (sort_map_array(ph) != true)
+                  return false;
+            } else {
+               print_debug("can't read ELF header for shared object %s\n", lib_name);
+               close(lib_fd);
+               // continue with other libraries...
+            }
+         }
+      }
+
+      // read next link_map address
+      if (ps_pread(ph, (psaddr_t) link_map_addr + LINK_MAP_NEXT_OFFSET,
+                        &link_map_addr, sizeof(uintptr_t)) != PS_OK) {
+         print_debug("can't read next link in link_map\n");
+         return false;
+      }
+   }
+
+   return true;
+}
+
+// the one and only one exposed stuff from this file
+struct ps_prochandle* Pgrab_core(const char* exec_file, const char* core_file) {
+   ELF_EHDR core_ehdr;
+   ELF_EHDR exec_ehdr;
+
+   struct ps_prochandle* ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle));
+   if (ph == NULL) {
+      print_debug("can't allocate ps_prochandle\n");
+      return NULL;
+   }
+
+   if ((ph->core = (struct core_data*) calloc(1, sizeof(struct core_data))) == NULL) {
+      free(ph);
+      print_debug("can't allocate ps_prochandle\n");
+      return NULL;
+   }
+
+   // initialize ph
+   ph->ops = &core_ops;
+   ph->core->core_fd   = -1;
+   ph->core->exec_fd   = -1;
+   ph->core->interp_fd = -1;
+
+   // open the core file
+   if ((ph->core->core_fd = open(core_file, O_RDONLY)) < 0) {
+      print_debug("can't open core file\n");
+      goto err;
+   }
+
+   // read core file ELF header
+   if (read_elf_header(ph->core->core_fd, &core_ehdr) != true || core_ehdr.e_type != ET_CORE) {
+      print_debug("core file is not a valid ELF ET_CORE file\n");
+      goto err;
+   }
+
+   if ((ph->core->exec_fd = open(exec_file, O_RDONLY)) < 0) {
+      print_debug("can't open executable file\n");
+      goto err;
+   }
+
+   if (read_elf_header(ph->core->exec_fd, &exec_ehdr) != true || exec_ehdr.e_type != ET_EXEC) {
+      print_debug("executable file is not a valid ELF ET_EXEC file\n");
+      goto err;
+   }
+
+   // process core file segments
+   if (read_core_segments(ph, &core_ehdr) != true)
+      goto err;
+
+   // process exec file segments
+   if (read_exec_segments(ph, &exec_ehdr) != true)
+      goto err;
+
+   // exec file is also treated like a shared object for symbol search
+   if (add_lib_info_fd(ph, exec_file, ph->core->exec_fd,
+                       (uintptr_t)0 + find_base_address(ph->core->exec_fd, &exec_ehdr)) == NULL)
+      goto err;
+
+   // allocate and sort maps into map_array, we need to do this
+   // here because read_shared_lib_info needs to read from debuggee
+   // address space
+   if (sort_map_array(ph) != true)
+      goto err;
+
+   if (read_shared_lib_info(ph) != true)
+      goto err;
+
+   // sort again because we have added more mappings from shared objects
+   if (sort_map_array(ph) != true)
+      goto err;
+
+   if (init_classsharing_workaround(ph) != true)
+      goto err;
+
+   return ph;
+
+err:
+   Prelease(ph);
+   return NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/ps_proc.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,444 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/ptrace.h>
+#include <sys/param.h>
+#include <sys/user.h>
+#include <elf.h>
+#include <sys/elf_common.h>
+#include <sys/link_elf.h>
+#include <libutil.h>
+#include "libproc_impl.h"
+#include "elfmacros.h"
+
+// This file has the libproc implementation specific to live process
+// For core files, refer to ps_core.c
+
+static inline uintptr_t align(uintptr_t ptr, size_t size) {
+  return (ptr & ~(size - 1));
+}
+
+// ---------------------------------------------
+// ptrace functions
+// ---------------------------------------------
+
+// read "size" bytes of data from "addr" within the target process.
+// unlike the standard ptrace() function, process_read_data() can handle
+// unaligned address - alignment check, if required, should be done
+// before calling process_read_data.
+
+static bool process_read_data(struct ps_prochandle* ph, uintptr_t addr, char *buf, size_t size) {
+  int rslt;
+  size_t i, words;
+  uintptr_t end_addr = addr + size;
+  uintptr_t aligned_addr = align(addr, sizeof(int));
+
+  if (aligned_addr != addr) {
+    char *ptr = (char *)&rslt;
+    errno = 0;
+    rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
+    if (errno) {
+      print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
+      return false;
+    }
+    for (; aligned_addr != addr; aligned_addr++, ptr++);
+    for (; ((intptr_t)aligned_addr % sizeof(int)) && aligned_addr < end_addr;
+        aligned_addr++)
+       *(buf++) = *(ptr++);
+  }
+
+  words = (end_addr - aligned_addr) / sizeof(int);
+
+  // assert((intptr_t)aligned_addr % sizeof(int) == 0);
+  for (i = 0; i < words; i++) {
+    errno = 0;
+    rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
+    if (errno) {
+      print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
+      return false;
+    }
+    *(int *)buf = rslt;
+    buf += sizeof(int);
+    aligned_addr += sizeof(int);
+  }
+
+  if (aligned_addr != end_addr) {
+    char *ptr = (char *)&rslt;
+    errno = 0;
+    rslt = ptrace(PT_READ_D, ph->pid, (caddr_t) aligned_addr, 0);
+    if (errno) {
+      print_debug("ptrace(PT_READ_D, ..) failed for %d bytes @ %lx\n", size, addr);
+      return false;
+    }
+    for (; aligned_addr != end_addr; aligned_addr++)
+       *(buf++) = *(ptr++);
+  }
+  return true;
+}
+
+// null implementation for write
+static bool process_write_data(struct ps_prochandle* ph,
+                             uintptr_t addr, const char *buf , size_t size) {
+  return false;
+}
+
+// "user" should be a pointer to a reg
+static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct reg *user) {
+  // we have already attached to all thread 'pid's, just use ptrace call
+  // to get regset now. Note that we don't cache regset upfront for processes.
+ if (ptrace(PT_GETREGS, pid, (caddr_t) user, 0) < 0) {
+   print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid);
+   return false;
+ }
+ return true;
+}
+
+// fill in ptrace_lwpinfo for lid
+static bool process_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
+  errno = 0;
+  ptrace(PT_LWPINFO, lwp_id, linfo, sizeof(struct ptrace_lwpinfo));
+
+  return (errno == 0)? true: false;
+}
+
+// attach to a process/thread specified by "pid"
+static bool ptrace_attach(pid_t pid) {
+  if (ptrace(PT_ATTACH, pid, NULL, 0) < 0) {
+    print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
+    return false;
+  } else {
+    int ret;
+    int status;
+    do {
+      // Wait for debuggee to stop.
+      ret = waitpid(pid, &status, 0);
+      if (ret >= 0) {
+        if (WIFSTOPPED(status)) {
+          // Debuggee stopped.
+          return true;
+        } else {
+          print_debug("waitpid(): Child process exited/terminated (status = 0x%x)\n", status);
+          return false;
+        }
+      } else {
+        switch (errno) {
+          case EINTR:
+            continue;
+            break;
+          case ECHILD:
+            print_debug("waitpid() failed. Child process pid (%d) does not exist \n", pid);
+            break;
+          case EINVAL:
+            print_debug("waitpid() failed. Invalid options argument.\n");
+            break;
+          default:
+            print_debug("waitpid() failed. Unexpected error %d\n",errno);
+        }
+        return false;
+      }
+    } while(true);
+  }
+}
+
+// -------------------------------------------------------
+// functions for obtaining library information
+// -------------------------------------------------------
+
+// callback for read_thread_info
+static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
+  return add_thread_info(ph, pthread_id, lwp_id) != NULL;
+}
+
+#if defined(__FreeBSD__) && __FreeBSD_version < 701000
+/*
+ * TEXT_START_ADDR from binutils/ld/emulparams/<arch_spec>.sh
+ * Not the most robust but good enough.
+ */
+
+#if defined(amd64) || defined(x86_64)
+#define TEXT_START_ADDR 0x400000
+#elif defined(i386)
+#define TEXT_START_ADDR 0x8048000
+#else
+#error TEXT_START_ADDR not defined
+#endif
+
+#define BUF_SIZE (PATH_MAX + NAME_MAX + 1)
+
+uintptr_t linkmap_addr(struct ps_prochandle *ph) {
+  uintptr_t ehdr_addr, phdr_addr, dyn_addr, dmap_addr, lmap_addr;
+  ELF_EHDR ehdr;
+  ELF_PHDR *phdrs, *phdr;
+  ELF_DYN *dyns, *dyn;
+  struct r_debug dmap;
+  unsigned long hdrs_size;
+  unsigned int i;
+
+  /* read ELF_EHDR at TEXT_START_ADDR and validate */
+
+  ehdr_addr = (uintptr_t)TEXT_START_ADDR;
+
+  if (process_read_data(ph, ehdr_addr, (char *)&ehdr, sizeof(ehdr)) != true) {
+    print_debug("process_read_data failed for ehdr_addr %p\n", ehdr_addr);
+    return (0);
+  }
+
+  if (!IS_ELF(ehdr) ||
+        ehdr.e_ident[EI_CLASS] != ELF_TARG_CLASS ||
+        ehdr.e_ident[EI_DATA] != ELF_TARG_DATA ||
+        ehdr.e_ident[EI_VERSION] != EV_CURRENT ||
+        ehdr.e_phentsize != sizeof(ELF_PHDR) ||
+        ehdr.e_version != ELF_TARG_VER ||
+        ehdr.e_machine != ELF_TARG_MACH) {
+    print_debug("not an ELF_EHDR at %p\n", ehdr_addr);
+    return (0);
+  }
+
+  /* allocate space for all ELF_PHDR's and read */
+
+  phdr_addr = ehdr_addr + ehdr.e_phoff;
+  hdrs_size = ehdr.e_phnum * sizeof(ELF_PHDR);
+
+  if ((phdrs = malloc(hdrs_size)) == NULL)
+    return (0);
+
+  if (process_read_data(ph, phdr_addr, (char *)phdrs, hdrs_size) != true) {
+    print_debug("process_read_data failed for phdr_addr %p\n", phdr_addr);
+    return (0);
+  }
+
+  /* find PT_DYNAMIC section */
+
+  for (i = 0, phdr = phdrs; i < ehdr.e_phnum; i++, phdr++) {
+    if (phdr->p_type == PT_DYNAMIC)
+      break;
+  }
+
+  if (i >= ehdr.e_phnum) {
+    print_debug("PT_DYNAMIC section not found!\n");
+    free(phdrs);
+    return (0);
+  }
+
+  /* allocate space and read in ELF_DYN headers */
+
+  dyn_addr = phdr->p_vaddr;
+  hdrs_size = phdr->p_memsz;
+  free(phdrs);
+
+  if ((dyns = malloc(hdrs_size)) == NULL)
+    return (0);
+
+  if (process_read_data(ph, dyn_addr, (char *)dyns, hdrs_size) != true) {
+    print_debug("process_read_data failed for dyn_addr %p\n", dyn_addr);
+    free(dyns);
+    return (0);
+  }
+
+  /* find DT_DEBUG */
+
+  dyn = dyns;
+  while (dyn->d_tag != DT_DEBUG && dyn->d_tag != DT_NULL) {
+    dyn++;
+  }
+
+  if (dyn->d_tag != DT_DEBUG) {
+    print_debug("failed to find DT_DEBUG\n");
+    free(dyns);
+    return (0);
+  }
+
+  /* read struct r_debug into dmap */
+
+  dmap_addr = (uintptr_t)dyn->d_un.d_ptr;
+  free(dyns);
+
+  if (process_read_data(ph, dmap_addr, (char *)&dmap, sizeof(dmap)) != true) {
+    print_debug("process_read_data failed for dmap_addr %p\n", dmap_addr);
+    return (0);
+  }
+
+  lmap_addr = (uintptr_t)dmap.r_map;
+
+  return (lmap_addr);
+}
+#endif // __FreeBSD__ && __FreeBSD_version < 701000
+
+static bool read_lib_info(struct ps_prochandle* ph) {
+#if defined(__FreeBSD__) && __FreeBSD_version >= 701000
+  struct kinfo_vmentry *freep, *kve;
+  int i, cnt;
+
+  freep = kinfo_getvmmap(ph->pid, &cnt);
+  if (freep == NULL) {
+      print_debug("can't get vm map for pid\n", ph->pid);
+      return false;
+  }
+
+  for (i = 0; i < cnt; i++) {
+    kve = &freep[i];
+    if ((kve->kve_flags & KVME_FLAG_COW) &&
+        kve->kve_path != NULL &&
+        strlen(kve->kve_path) > 0) {
+
+      if (find_lib(ph, kve->kve_path) == false) {
+        lib_info* lib;
+        if ((lib = add_lib_info(ph, kve->kve_path,
+                                (uintptr_t) kve->kve_start)) == NULL)
+          continue; // ignore, add_lib_info prints error
+
+        // we don't need to keep the library open, symtab is already
+        // built. Only for core dump we need to keep the fd open.
+        close(lib->fd);
+        lib->fd = -1;
+      }
+    }
+  }
+
+  free(freep);
+
+  return true;
+#else
+  char *l_name;
+  struct link_map *lmap;
+  uintptr_t lmap_addr;
+
+  if ((l_name = malloc(BUF_SIZE)) == NULL)
+    return false;
+
+  if ((lmap = malloc(sizeof(*lmap))) == NULL) {
+    free(l_name);
+    return false;
+  }
+
+  lmap_addr = linkmap_addr(ph);
+
+  if (lmap_addr == 0) {
+    free(l_name);
+    free(lmap);
+    return false;
+  }
+
+  do {
+    if (process_read_data(ph, lmap_addr, (char *)lmap, sizeof(*lmap)) != true) {
+      print_debug("process_read_data failed for lmap_addr %p\n", lmap_addr);
+      free (l_name);
+      free (lmap);
+      return false;
+    }
+
+    if (process_read_data(ph, (uintptr_t)lmap->l_name, l_name,
+        BUF_SIZE) != true) {
+      print_debug("process_read_data failed for lmap->l_name %p\n",
+          lmap->l_name);
+      free (l_name);
+      free (lmap);
+      return false;
+    }
+
+    if (find_lib(ph, l_name) == false) {
+      lib_info* lib;
+      if ((lib = add_lib_info(ph, l_name,
+                              (uintptr_t) lmap->l_addr)) == NULL)
+        continue; // ignore, add_lib_info prints error
+
+      // we don't need to keep the library open, symtab is already
+      // built. Only for core dump we need to keep the fd open.
+      close(lib->fd);
+      lib->fd = -1;
+    }
+    lmap_addr = (uintptr_t)lmap->l_next;
+  } while (lmap->l_next != NULL);
+
+  free (l_name);
+  free (lmap);
+
+  return true;
+#endif
+}
+
+// detach a given pid
+static bool ptrace_detach(pid_t pid) {
+  if (pid && ptrace(PT_DETACH, pid, (caddr_t)1, 0) < 0) {
+    print_debug("ptrace(PTRACE_DETACH, ..) failed for %d\n", pid);
+    return false;
+  } else {
+    return true;
+  }
+}
+
+static void process_cleanup(struct ps_prochandle* ph) {
+  ptrace_detach(ph->pid);
+}
+
+static ps_prochandle_ops process_ops = {
+  .release=  process_cleanup,
+  .p_pread=  process_read_data,
+  .p_pwrite= process_write_data,
+  .get_lwp_regs= process_get_lwp_regs,
+  .get_lwp_info= process_get_lwp_info
+};
+
+// attach to the process. One and only one exposed stuff
+struct ps_prochandle* Pgrab(pid_t pid) {
+  struct ps_prochandle* ph = NULL;
+  thread_info* thr = NULL;
+
+  if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) {
+     print_debug("can't allocate memory for ps_prochandle\n");
+     return NULL;
+  }
+
+  if (ptrace_attach(pid) != true) {
+     free(ph);
+     return NULL;
+  }
+
+  // initialize ps_prochandle
+  ph->pid = pid;
+
+  // initialize vtable
+  ph->ops = &process_ops;
+
+  // read library info and symbol tables, must do this before attaching threads,
+  // as the symbols in the pthread library will be used to figure out
+  // the list of threads within the same process.
+  if (read_lib_info(ph) != true) {
+     ptrace_detach(pid);
+     free(ph);
+     return NULL;
+  }
+
+  // read thread info
+  read_thread_info(ph, add_new_thread);
+
+  return ph;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/salibelf.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * 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 "salibelf.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+extern void print_debug(const char*,...);
+
+// ELF file parsing helpers. Note that we do *not* use libelf here.
+int read_elf_header(int fd, ELF_EHDR* ehdr) {
+   if (pread(fd, ehdr, sizeof (ELF_EHDR), 0) != sizeof (ELF_EHDR) ||
+            memcmp(&ehdr->e_ident[EI_MAG0], ELFMAG, SELFMAG) != 0 ||
+            ehdr->e_version != EV_CURRENT) {
+        return 0;
+   }
+   return 1;
+}
+
+bool is_elf_file(int fd) {
+   ELF_EHDR ehdr;
+   return read_elf_header(fd, &ehdr);
+}
+
+// read program header table of an ELF file
+ELF_PHDR* read_program_header_table(int fd, ELF_EHDR* hdr) {
+   ELF_PHDR* phbuf = 0;
+   // allocate memory for program header table
+   size_t nbytes = hdr->e_phnum * hdr->e_phentsize;
+
+   if ((phbuf = (ELF_PHDR*) malloc(nbytes)) == NULL) {
+      print_debug("can't allocate memory for reading program header table\n");
+      return NULL;
+   }
+
+   if (pread(fd, phbuf, nbytes, hdr->e_phoff) != nbytes) {
+      print_debug("ELF file is truncated! can't read program header table\n");
+      free(phbuf);
+      return NULL;
+   }
+
+   return phbuf;
+}
+
+// read section header table of an ELF file
+ELF_SHDR* read_section_header_table(int fd, ELF_EHDR* hdr) {
+   ELF_SHDR* shbuf = 0;
+   // allocate memory for section header table
+   size_t nbytes = hdr->e_shnum * hdr->e_shentsize;
+
+   if ((shbuf = (ELF_SHDR*) malloc(nbytes)) == NULL) {
+      print_debug("can't allocate memory for reading section header table\n");
+      return NULL;
+   }
+
+   if (pread(fd, shbuf, nbytes, hdr->e_shoff) != nbytes) {
+      print_debug("ELF file is truncated! can't read section header table\n");
+      free(shbuf);
+      return NULL;
+   }
+
+   return shbuf;
+}
+
+// read a particular section's data
+void* read_section_data(int fd, ELF_EHDR* ehdr, ELF_SHDR* shdr) {
+  void *buf = NULL;
+  if (shdr->sh_type == SHT_NOBITS || shdr->sh_size == 0) {
+     return buf;
+  }
+  if ((buf = calloc(shdr->sh_size, 1)) == NULL) {
+     print_debug("can't allocate memory for reading section data\n");
+     return NULL;
+  }
+  if (pread(fd, buf, shdr->sh_size, shdr->sh_offset) != shdr->sh_size) {
+     free(buf);
+     print_debug("section data read failed\n");
+     return NULL;
+  }
+  return buf;
+}
+
+uintptr_t find_base_address(int fd, ELF_EHDR* ehdr) {
+  uintptr_t baseaddr = (uintptr_t)-1;
+  int cnt;
+  ELF_PHDR *phbuf, *phdr;
+
+  // read program header table
+  if ((phbuf = read_program_header_table(fd, ehdr)) == NULL) {
+    goto quit;
+  }
+
+  // the base address of a shared object is the lowest vaddr of
+  // its loadable segments (PT_LOAD)
+  for (phdr = phbuf, cnt = 0; cnt < ehdr->e_phnum; cnt++, phdr++) {
+    if (phdr->p_type == PT_LOAD && phdr->p_vaddr < baseaddr) {
+      baseaddr = phdr->p_vaddr;
+    }
+  }
+
+quit:
+  if (phbuf) free(phbuf);
+  return baseaddr;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/salibelf.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * 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 _SALIBELF_H_
+#define _SALIBELF_H_
+
+#include <elf.h>
+#include "elfmacros.h"
+#include "libproc_impl.h"
+
+// read ELF file header.
+int read_elf_header(int fd, ELF_EHDR* ehdr);
+
+// is given file descriptor corresponds to an ELF file?
+bool is_elf_file(int fd);
+
+// read program header table of an ELF file. caller has to
+// free the result pointer after use. NULL on failure.
+ELF_PHDR* read_program_header_table(int fd, ELF_EHDR* hdr);
+
+// read section header table of an ELF file. caller has to
+// free the result pointer after use. NULL on failure.
+ELF_SHDR* read_section_header_table(int fd, ELF_EHDR* hdr);
+
+// read a particular section's data. caller has to free the
+// result pointer after use. NULL on failure.
+void* read_section_data(int fd, ELF_EHDR* ehdr, ELF_SHDR* shdr);
+
+// find the base address at which the library wants to load itself
+uintptr_t find_base_address(int fd, ELF_EHDR* ehdr);
+#endif /* _SALIBELF_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/symtab.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 <unistd.h>
+#include <search.h>
+#include <stdlib.h>
+#include <string.h>
+#include <db.h>
+#include <fcntl.h>
+#include "symtab.h"
+#include "salibelf.h"
+
+
+// ----------------------------------------------------
+// functions for symbol lookups
+// ----------------------------------------------------
+
+struct elf_section {
+  ELF_SHDR   *c_shdr;
+  void       *c_data;
+};
+
+struct elf_symbol {
+  char *name;
+  uintptr_t offset;
+  uintptr_t size;
+};
+
+typedef struct symtab {
+  char *strs;
+  size_t num_symbols;
+  struct elf_symbol *symbols;
+  DB* hash_table;
+} symtab_t;
+
+// read symbol table from given fd.
+struct symtab* build_symtab(int fd) {
+  ELF_EHDR ehdr;
+  struct symtab* symtab = NULL;
+
+  // Reading of elf header
+  struct elf_section *scn_cache = NULL;
+  int cnt = 0;
+  ELF_SHDR* shbuf = NULL;
+  ELF_SHDR* cursct = NULL;
+  ELF_PHDR* phbuf = NULL;
+  int symtab_found = 0;
+  int dynsym_found = 0;
+  uint32_t symsection = SHT_SYMTAB;
+
+  uintptr_t baseaddr = (uintptr_t)-1;
+
+  lseek(fd, (off_t)0L, SEEK_SET);
+  if (! read_elf_header(fd, &ehdr)) {
+    // not an elf
+    return NULL;
+  }
+
+  // read ELF header
+  if ((shbuf = read_section_header_table(fd, &ehdr)) == NULL) {
+    goto quit;
+  }
+
+  baseaddr = find_base_address(fd, &ehdr);
+
+  scn_cache = calloc(ehdr.e_shnum, sizeof(*scn_cache));
+  if (scn_cache == NULL) {
+    goto quit;
+  }
+
+  for (cursct = shbuf, cnt = 0; cnt < ehdr.e_shnum; cnt++) {
+    scn_cache[cnt].c_shdr = cursct;
+    if (cursct->sh_type == SHT_SYMTAB ||
+        cursct->sh_type == SHT_STRTAB ||
+        cursct->sh_type == SHT_DYNSYM) {
+      if ( (scn_cache[cnt].c_data = read_section_data(fd, &ehdr, cursct)) == NULL) {
+         goto quit;
+      }
+    }
+
+    if (cursct->sh_type == SHT_SYMTAB)
+       symtab_found++;
+
+    if (cursct->sh_type == SHT_DYNSYM)
+       dynsym_found++;
+
+    cursct++;
+  }
+
+  if (!symtab_found && dynsym_found)
+     symsection = SHT_DYNSYM;
+
+  for (cnt = 1; cnt < ehdr.e_shnum; cnt++) {
+    ELF_SHDR *shdr = scn_cache[cnt].c_shdr;
+
+    if (shdr->sh_type == symsection) {
+      ELF_SYM  *syms;
+      int j, n;
+      size_t size;
+
+      // FIXME: there could be multiple data buffers associated with the
+      // same ELF section. Here we can handle only one buffer. See man page
+      // for elf_getdata on Solaris.
+
+      // guarantee(symtab == NULL, "multiple symtab");
+      symtab = calloc(1, sizeof(*symtab));
+      if (symtab == NULL) {
+         goto quit;
+      }
+      // the symbol table
+      syms = (ELF_SYM *)scn_cache[cnt].c_data;
+
+      // number of symbols
+      n = shdr->sh_size / shdr->sh_entsize;
+
+      // create hash table, we use berkeley db to
+      // manipulate the hash table.
+      symtab->hash_table = dbopen(NULL, O_CREAT | O_RDWR, 0600, DB_HASH, NULL);
+      // guarantee(symtab->hash_table, "unexpected failure: dbopen");
+      if (symtab->hash_table == NULL)
+        goto bad;
+
+      // shdr->sh_link points to the section that contains the actual strings
+      // for symbol names. the st_name field in ELF_SYM is just the
+      // string table index. we make a copy of the string table so the
+      // strings will not be destroyed by elf_end.
+      size = scn_cache[shdr->sh_link].c_shdr->sh_size;
+      symtab->strs = malloc(size);
+      if (symtab->strs == NULL)
+        goto bad;
+      memcpy(symtab->strs, scn_cache[shdr->sh_link].c_data, size);
+
+      // allocate memory for storing symbol offset and size;
+      symtab->num_symbols = n;
+      symtab->symbols = calloc(n , sizeof(*symtab->symbols));
+      if (symtab->symbols == NULL)
+        goto bad;
+
+      // copy symbols info our symtab and enter them info the hash table
+      for (j = 0; j < n; j++, syms++) {
+        DBT key, value;
+        char *sym_name = symtab->strs + syms->st_name;
+
+        // skip non-object and non-function symbols
+        int st_type = ELF_ST_TYPE(syms->st_info);
+        if ( st_type != STT_FUNC && st_type != STT_OBJECT)
+           continue;
+        // skip empty strings and undefined symbols
+        if (*sym_name == '\0' || syms->st_shndx == SHN_UNDEF) continue;
+
+        symtab->symbols[j].name   = sym_name;
+        symtab->symbols[j].offset = syms->st_value - baseaddr;
+        symtab->symbols[j].size   = syms->st_size;
+
+        key.data = sym_name;
+        key.size = strlen(sym_name) + 1;
+        value.data = &(symtab->symbols[j]);
+        value.size = sizeof(void *);
+        (*symtab->hash_table->put)(symtab->hash_table, &key, &value, 0);
+      }
+    }
+  }
+  goto quit;
+
+bad:
+  destroy_symtab(symtab);
+  symtab = NULL;
+
+quit:
+  if (shbuf) free(shbuf);
+  if (phbuf) free(phbuf);
+  if (scn_cache) {
+    for (cnt = 0; cnt < ehdr.e_shnum; cnt++) {
+      if (scn_cache[cnt].c_data != NULL) {
+        free(scn_cache[cnt].c_data);
+      }
+    }
+    free(scn_cache);
+  }
+  return symtab;
+}
+
+void destroy_symtab(struct symtab* symtab) {
+  if (!symtab) return;
+  if (symtab->strs) free(symtab->strs);
+  if (symtab->symbols) free(symtab->symbols);
+  if (symtab->hash_table) {
+    (*symtab->hash_table->close)(symtab->hash_table);
+  }
+  free(symtab);
+}
+
+uintptr_t search_symbol(struct symtab* symtab, uintptr_t base,
+                      const char *sym_name, int *sym_size) {
+  DBT key, value;
+  int ret;
+
+  // library does not have symbol table
+  if (!symtab || !symtab->hash_table)
+     return 0;
+
+  key.data = (char*)(uintptr_t)sym_name;
+  key.size = strlen(sym_name) + 1;
+  ret = (*symtab->hash_table->get)(symtab->hash_table, &key, &value, 0);
+  if (ret == 0) {
+    struct elf_symbol *sym = value.data;
+    uintptr_t rslt = (uintptr_t) ((char*)base + sym->offset);
+    if (sym_size) *sym_size = sym->size;
+    return rslt;
+  }
+
+  return 0;
+}
+
+const char* nearest_symbol(struct symtab* symtab, uintptr_t offset,
+                           uintptr_t* poffset) {
+  int n = 0;
+  if (!symtab) return NULL;
+  for (; n < symtab->num_symbols; n++) {
+    struct elf_symbol* sym = &(symtab->symbols[n]);
+    if (sym->name != NULL &&
+      offset >= sym->offset && offset < sym->offset + sym->size) {
+      if (poffset) *poffset = (offset - sym->offset);
+      return sym->name;
+    }
+  }
+  return NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/symtab.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 _SYMTAB_H_
+#define _SYMTAB_H_
+
+#include <stdint.h>
+
+// interface to manage ELF symbol tables
+
+struct symtab;
+
+// build symbol table for a given ELF file descriptor
+struct symtab* build_symtab(int fd);
+
+// destroy the symbol table
+void destroy_symtab(struct symtab* symtab);
+
+// search for symbol in the given symbol table. Adds offset
+// to the base uintptr_t supplied. Returns NULL if not found.
+uintptr_t search_symbol(struct symtab* symtab, uintptr_t base,
+                      const char *sym_name, int *sym_size);
+
+// look for nearest symbol for a given offset (not address - base
+// subtraction done by caller
+const char* nearest_symbol(struct symtab* symtab, uintptr_t offset,
+                      uintptr_t* poffset);
+
+#endif /*_SYMTAB_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/os/bsd/test.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "libproc.h"
+
+int main(int argc, char** argv) {
+   struct ps_prochandle* ph;
+
+   init_libproc(true);
+   switch (argc) {
+      case 2: {
+         // process
+         ph = Pgrab(atoi(argv[1]));
+         break;
+      }
+
+      case 3: {
+        // core
+        ph = Pgrab_core(argv[1], argv[2]);
+        break;
+      }
+
+      default: {
+        fprintf(stderr, "usage %s <pid> or %s <exec file> <core file>\n", argv[0], argv[0]);
+        return 1;
+      }
+   }
+
+   if (ph) {
+      Prelease(ph);
+      return 0;
+   } else {
+      printf("can't connect to debuggee\n");
+      return 1;
+   }
+}
--- a/hotspot/agent/src/os/solaris/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/os/solaris/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -24,9 +24,7 @@
 
 
 all:
-	cd dbx; $(MAKE) all
 	cd proc; $(MAKE) all
 
 clean:
-	cd dbx; $(MAKE) clean
 	cd proc; $(MAKE) clean
--- a/hotspot/agent/src/os/solaris/dbx/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-#
-# Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#  
-#
-
-
-# Targets are:
-#   32bit:  Build the 32 bit version in ./32bit
-#   64bit:  Build the 64 bit version in ./64bit
-#   helloWorld:  Build the helloWorld test program
-#   all:    Build all of the above.  This is the default.
-#
-# NOTE: This makefile uses IOBuf.cpp, IOBuf.hpp, Buffer.cpp, and
-#           Buffer.hpp from the src/os/win32/agent directory.
-
-.PHONY: 32bit 64bit
-
-ARCH_ORIG = $(shell uname -p)
-
-# C++    := /java/devtools/$(ARCH_ORIG)/SUNWspro/SC6.1/bin/CC
-
-C++    := CC
-RM     := /usr/bin/rm
-MKDIRS := /usr/bin/mkdir -p
-
-
-WIN32_DIR := ../../win32
-ARCH     := $(subst i386,i486,$(ARCH_ORIG))
-# INCLUDES := -I/net/sparcworks.eng/export/set/sparcworks5/dbx_62_intg/dev/src/dbx -I$(WIN32_DIR)
-INCLUDES := -I. -I$(WIN32_DIR)
-CFLAGS_32bit := -xarch=v8
-CFLAGS_64bit := -xarch=v9
-CFLAGS   := -PIC -xO3 $(INCLUDES)
-LIBS     := -lsocket -lnsl -lrtld_db
-LDFLAGS  := -G
-
-ifneq "$(ARCH)" "i486"
-    CFLAGS += $(CFLAGS_$(VERSION))
-    LDFLAGS += $(CFLAGS_$(VERSION))
-endif
-
-# We use IOBuf.hpp, IOBuf.cpp, Buffer.hpp, and Buffer.cpp from the win32 dir.
-vpath %.cpp .:$(WIN32_DIR)
-vpath %.hpp .:$(WIN32_DIR)
-
-OBJS = $(VERSION)/svc_agent_dbx.o $(VERSION)/IOBuf.o $(VERSION)/Buffer.o
-
-
-
-# The default is to make both 32 bit and 64 bit versions.
-all:: 32bit 64bit
-
-32bit 64bit:: 
-	$(MKDIRS) $@
-	$(MAKE) $@/libsvc_agent_dbx.so  helloWorld VERSION=$@
-
-$(VERSION)/IOBuf.o: IOBuf.hpp
-$(VERSION)/Buffer.o: Buffer.hpp
-$(VERSION)/svc_agent_dbx.o: svc_agent_dbx.hpp
-
-$(VERSION)/%.o: %.cpp
-	$(C++) $(CFLAGS) -c $< -o $@
-
-$(VERSION)/libsvc_agent_dbx.so:: $(OBJS)
-	$(C++) $(LDFLAGS) -o $(VERSION)/libsvc_agent_dbx.so $(OBJS) $(LIBS)
-
-# Would be nice to move this into a shared directory
-helloWorld:: helloWorld.cpp
-	$(C++) -g $< -o $@
-
-clean::
-	$(RM) -rf 32bit 64bit *.o helloWorld
--- a/hotspot/agent/src/os/solaris/dbx/README	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-shell_impl.h
-proc_service_2.h
-
-The above files are captured from the dbx build environment.
-Rather then use a -I that points to stuff in .eng domain that
-may not be accessible in other domains these files are just
-copied here so local builds in other domains will work.
-These files rarely change so the fact that we might have to
-strobe in new ones on rare occasions is no big deal.
--- a/hotspot/agent/src/os/solaris/dbx/README-commands.txt	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-This import module uses a largely text-based protocol, except for
-certain bulk data transfer operations. All text is in single-byte
-US-ASCII.
-
-Commands understood:
-
-address_size                  ::= <int result>
-
-    Returns 32 if attached to 32-bit process, 64 if 64-bit.
-
-peek_fail_fast <bool arg>     ::=
-
-    Indicates whether "peek" requests should "fail fast"; that is, if
-    any of the addresses in the requested range are unmapped, report
-    the entire range as unmapped. This is substantially faster than
-    the alternative, which is to read the entire range byte-by-byte.
-    However, it should only be used when it is guaranteed by the
-    client application that peeks come from at most one page. The
-    default is that peek_fast_fail is not enabled.
-
-peek <address addr> <unsigned int numBytes> ::=
-    B<binary char success>
-       [<binary unsigned int len> <binary char isMapped> [<binary char data>]...]...
-
-    NOTE that the binary portion of this message is prefixed by the
-    uppercase US-ASCII letter 'B', allowing easier synchronization by
-    clients. There is no data between the 'B' and the rest of the
-    message.
-
-    May only be called once attached. Reads the address space of the
-    target process starting at the given address (see below for format
-    specifications) and extending the given number of bytes. Whether
-    the read succeeded is indicated by a single byte containing a 1 or
-    0 (success or failure). If successful, the return result is given
-    in a sequence of ranges. _len_, the length of each range, is
-    indicated by a 32-bit unsigned integer transmitted with big-endian
-    byte ordering (i.e., most significant byte first).  _isMapped_
-    indicates whether the range is mapped or unmapped in the target
-    process's address space, and will contain the value 1 or 0 for
-    mapped or unmapped, respectively. If the range is mapped,
-    _isMapped_ is followed by _data_, containing the raw binary data
-    for the range. The sum of all ranges' lengths is guaranteed to be
-    equivalent to the number of bytes requested.
-
-poke <address addr> <int numBytes> B[<binary char data>]... ::= <bool result>
-
-    NOTE that the binary portion of this message is prefixed by the
-    uppercase US-ASCII letter 'B', allowing easier synchronization by
-    clients. There is no data between the 'B' and the rest of the
-    message.
-
-    Writes the given data to the target process starting at the given
-    address. Returns 1 on success, 0 on failure (i.e., one or more of
-    target addresses were unmapped).
-
-mapped <address addr> <int numBytes> ::= <bool result>
-
-    Returns 1 if entire address range [address...address + int arg) is
-    mapped in target process's address space, 0 if not
-
-lookup <symbol objName> <symbol sym> ::= <address addr>
-
-    First symbol is object name; second is symbol to be looked up.
-    Looks up symbol in target process's symbol table and returns
-    address. Returns NULL (0x0) if symbol is not found.
-
-thr_gregs <int tid>                  ::= <int numAddresses> <address...>
-
-    Fetch the "general" (integer) register set for the given thread.
-    Returned as a series of hexidecimal values. NOTE: the meaning of
-    the return value is architecture-dependent. In general it is the
-    contents of the prgregset_t.
-
-exit                                 ::=
-
-    Exits the serviceability agent dbx module, returning control to
-    the dbx prompt.
-
-// Data formats and example values:
-<address>      ::=   0x12345678[9ABCDEF0] /* up to 64-bit hex value */
-<unsigned int> ::=   5                    /* up to 32-bit integer number; no leading sign */
-<bool>         ::=   1                    /* ASCII '0' or '1' */
--- a/hotspot/agent/src/os/solaris/dbx/helloWorld.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +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.
- *
- */
-
-#include <stdio.h>
-#include <inttypes.h>
-
-extern "C" {
-  const char* helloWorldString = "Hello, world!";
-  // Do not change these values without changing TestDebugger.java as well
-  // FIXME: should make these jbyte, jshort, etc...
-  volatile int8_t  testByte     = 132;
-  volatile int16_t testShort    = 27890;
-  volatile int32_t testInt      = 1020304050;
-  volatile int64_t testLong     = 102030405060708090LL;
-  volatile float   testFloat    = 35.4F;
-  volatile double  testDouble   = 1.23456789;
-
-  volatile int helloWorldTrigger = 0;
-}
-
-int
-main(int, char**) {
-  while (1) {
-    while (helloWorldTrigger == 0) {
-    }
-
-    fprintf(stderr, "%s\n", helloWorldString);
-    fprintf(stderr, "testByte=%d\n", testByte);
-    fprintf(stderr, "testShort=%d\n", testShort);
-    fprintf(stderr, "testInt=%d\n", testInt);
-    fprintf(stderr, "testLong=%d\n", testLong);
-    fprintf(stderr, "testFloat=%d\n", testFloat);
-    fprintf(stderr, "testDouble=%d\n", testDouble);
-
-    while (helloWorldTrigger != 0) {
-    }
-  }
-}
--- a/hotspot/agent/src/os/solaris/dbx/proc_service_2.h	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef _PROC_SERVICE_2_H
-#define _PROC_SERVICE_2_H
-
-/*
- * Types, function definitions for the provider of services beyond
- * proc_service.  This interface will be used by import modules like
- * BAT/prex, NEO debugger etc.
- */
-
-/*
- CCR info
-
- Version history:
-
-        1.0       - Initial CCR release
-
-        1.1       - Changes for GLUE/neo.
-                    New entry points ps_svnt_generic() and ps_svc_generic()
-                  - New entry point ps_getpid()
-
- Release information for automatic CCR updates:
- BEGIN RELEASE NOTES: (signifies what gets put into CCR release notes)
-        1.2       - Changes to support Solaris 2.7
-
- END RELEASE NOTES: (signifies what gets put into CCR release notes)
-
- Following is used for CCR version number:
-
-#define CCR_PROC_SERVICE_2_VERSION 1.2
-
-*/
-
-
-#include <proc_service.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct ps_loadobj {
-        int     objfd;          /* fd of the load object or executable
-                                 * -1 implies its not available.
-                                 * This file decriptor is live only during the
-                                 * particular call to ps_iter_f().  If you
-                                 * need it beyond that you need to dup() it.
-                                 */
-        psaddr_t
-                text_base;      /* address where text of loadobj was mapped */
-        psaddr_t
-                data_base;      /* address where data of loadobj was mapped */
-        const char *objname;    /* loadobj name */
-};
-
-typedef int ps_iter_f(const struct ps_prochandle *, const struct ps_loadobj *,
-                        void *cd);
-
-/*
- * Returns the ps_prochandle for the current process under focus.  Returns
- * NULL if there is none.
- */
-
-const struct ps_prochandle *
-ps_get_prochandle(void);
-
-/*
- * Returns the ps_prochandle for the current process(allows core files to
- * be specified) under focus.  Returns NULL if there is none.
- */
-const struct ps_prochandle *
-ps_get_prochandle2(int cores_too);
-
-/*
- * Returns the pid of the process referred to by the ps_prochandle.
- *
- * 0 is returned in case the ps_prochandle is not valid or refers to dead
- * process.
- *
- */
-pid_t
-ps_getpid(const struct ps_prochandle *);
-
-/*
- * Iteration function that iterates over all load objects *and the
- *      executable*
- *
- *      If the callback routine returns:
- *      0 - continue processing link objects
- *      non zero - stop calling the callback function
- *
- */
-
-ps_err_e
-ps_loadobj_iter(const struct ps_prochandle *, ps_iter_f *, void *clnt_data);
-
-/*
- * Address => function name mapping
- *
- * Given an address, returns a pointer to the function's
- * linker name (null terminated).
- */
-
-ps_err_e
-ps_find_fun_name(const struct ps_prochandle *, psaddr_t addr,
-                        const char **name);
-
-/*
- * Interface to LD_PRELOAD.  LD_PRELOAD given library across the
- * program 'exec'.
- *
- */
-
-/*
- * Append/Prepend the 'lib' (has to be library name as understood by LD_PRELOAD)
- * to the LD_PRELOAD variable setting to be used by the debugee
- * Returns a cookie (in id).
- */
-ps_err_e
-ps_ld_preload_append(const char *lib, int *id);
-ps_err_e
-ps_ld_preload_prepend(const char *lib, int *id);
-
-/*
- * Remove the library associated with 'id' from the LD_PRELOAD setting.
- *
- */
-ps_err_e
-ps_ld_preload_remove(int id);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*
- * The following are C++ only interfaces
- */
-#ifdef __cplusplus
-
-/*
- * classes ServiceDbx and ServantDbx and defined in "gp_dbx_svc.h" which is
- * accessed via CCR
- */
-extern class ServantDbx *ps_svnt_generic();
-extern class ServiceDbx *ps_svc_generic();
-
-#endif
-
-#endif /* _PROC_SERVICE_2_H */
--- a/hotspot/agent/src/os/solaris/dbx/shell_imp.h	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 SHELL_IMP_H
-#define SHELL_IMP_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-
-/*
- CCR info
-
- Vesrion history:
-
-        1.0       - Initial CCR release
-
- Release information for automatic CCR updates:
-
- BEGIN RELEASE NOTES: (signifies what gets put into CCR release notes)
-        1.1
-                  - Entry points for va_list style msgs; new shell_imp_vmsg()
-                    and shell_imp_verrmsg()
-                  - shell_imp_env_checker() is now shell_imp_var_checker().
-                    Also the var_checker callback gets passed interp.
-        1.2       - interposition framework (used by jdbx)
-                  - access to input FILE pointer.
-
- END RELEASE NOTES: (signifies what gets put into CCR release notes)
-
-Following is used as a CCR version number:
-#define CCR_SHELL_IMP_VERSION 1.1
-*/
-
-#include <stdarg.h>
-
-#define SHELL_IMP_MAJOR 1
-#define SHELL_IMP_MINOR 2
-#define SHELL_IMP_FLAG_GLOB 0x1
-#define SHELL_IMP_FLAG_ARGQ 0x2
-
-typedef void *shell_imp_interp_t;
-typedef void *shell_imp_command_t;
-typedef int shell_imp_fun_t(shell_imp_interp_t, int, char **, void *);
-
-int
-shell_imp_init(
-    int,                /* major version number */
-    int,                /* minor version number */
-    shell_imp_interp_t, /* interpreter */
-    int,                /* argc */
-    char *[]            /* argv */
-);
-
-int
-shell_imp_fini(shell_imp_interp_t);
-
-shell_imp_command_t
-shell_imp_define_command(char *,        /* command name e.g. "tnf" */
-                    shell_imp_fun_t *,  /* callback function */
-                    int,                /* SHELL_IMP_FLAG_* bit vector */
-                    void *,             /* client_data Passed as last arg to
-                                        /* callback function */
-                    char *              /* help message, e.g. */
-                                        /* "enable the specified tnf probes" */
-            );
-
-int
-shell_imp_undefine_command(shell_imp_command_t);
-
-int
-shell_imp_var_checker(shell_imp_interp_t,
-                      const char *,         /* var name */
-                      int (*)(shell_imp_interp_t, const char*) /* env checker */
-                     );
-
-int
-shell_imp_execute(shell_imp_interp_t, const char *);
-
-const char *
-shell_imp_get_var(shell_imp_interp_t, const char *);
-
-void
-shell_imp_msg(shell_imp_interp_t, const char *, ...);
-
-void
-shell_imp_errmsg(shell_imp_interp_t, const char *, ...);
-
-void
-shell_imp_vmsg(shell_imp_interp_t, const char *, va_list);
-
-void
-shell_imp_verrmsg(shell_imp_interp_t, const char *, va_list);
-
-
-
-/*
- * Stuff added for 1.2
- */
-
-struct shell_imp_interposition_info_t {
-    shell_imp_fun_t *
-                new_func;
-    void *      new_client_data;
-    shell_imp_fun_t *
-                original_func;
-    void *      original_client_data;
-    int         original_flags;
-};
-
-typedef int shell_imp_dispatcher_t(shell_imp_interp_t, int, char **,
-                                   shell_imp_interposition_info_t *);
-
-shell_imp_command_t
-shell_imp_interpose(char *name,
-                    shell_imp_fun_t *new_func,
-                    int    flags,
-                    void *client_data,
-                    char * description,
-                    shell_imp_dispatcher_t *);
-
-int shell_imp_uninterpose(shell_imp_command_t);
-
-int
-shell_imp_dispatch_interposition(shell_imp_interp_t,
-                                 shell_imp_interposition_info_t *,
-                                 int argc, char *argv[]);
-
-int
-shell_imp_dispatch_original(shell_imp_interp_t,
-                                 shell_imp_interposition_info_t *,
-                                 int argc, char *argv[]);
-
-FILE *
-shell_imp_cur_input(shell_imp_interp_t);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
--- a/hotspot/agent/src/os/solaris/dbx/svc_agent_dbx.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1068 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-// This is the implementation of a very simple dbx import module which
-// handles requests from the VM which come in over a socket. The
-// higher-level Java wrapper for dbx starts the debugger, attaches to
-// the process, imports this command, and runs it. After that, the SA
-// writes commands to this agent via its own private communications
-// channel. The intent is to move away from the text-based front-end
-// completely in the near future (no more calling "debug" by printing
-// text to dbx's stdin).
-
-#include <stdio.h>
-#include <errno.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <string.h>
-#include <stropts.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <proc_service.h>
-#include <sys/procfs_isa.h>
-#include <rtld_db.h>
-#include "proc_service_2.h"
-#include "svc_agent_dbx.hpp"
-
-static ServiceabilityAgentDbxModule* module = NULL;
-#define NEEDS_CLEANUP
-
-// Useful for debugging
-#define VERBOSE_DEBUGGING
-
-#ifdef VERBOSE_DEBUGGING
-# define debug_only(x) x
-#else
-# define debug_only(x)
-#endif
-
-// For profiling
-//#define PROFILING
-
-#ifdef PROFILING
-#define PROFILE_COUNT 200
-static Timer scanTimer;
-static Timer workTimer;
-static Timer writeTimer;
-static int numRequests = 0;
-#endif /* PROFILING */
-
-const char* ServiceabilityAgentDbxModule::CMD_ADDRESS_SIZE   = "address_size";
-const char* ServiceabilityAgentDbxModule::CMD_PEEK_FAIL_FAST = "peek_fail_fast";
-const char* ServiceabilityAgentDbxModule::CMD_PEEK           = "peek";
-const char* ServiceabilityAgentDbxModule::CMD_POKE           = "poke";
-const char* ServiceabilityAgentDbxModule::CMD_MAPPED         = "mapped";
-const char* ServiceabilityAgentDbxModule::CMD_LOOKUP         = "lookup";
-const char* ServiceabilityAgentDbxModule::CMD_THR_GREGS      = "thr_gregs";
-const char* ServiceabilityAgentDbxModule::CMD_EXIT           = "exit";
-
-// The initialization routines must not have C++ name mangling
-extern "C" {
-
-/** This is the initialization routine called by dbx upon importing of
-    this module. Returns 0 upon successful initialization, -1 upon
-    failure. */
-int shell_imp_init(int major, int minor,
-                   shell_imp_interp_t interp, int argc, char *argv[])
-{
-  // Ensure shell interpreter data structure is laid out the way we
-  // expect
-  if (major != SHELL_IMP_MAJOR) {
-    debug_only(fprintf(stderr, "Serviceability agent: unexpected value for SHELL_IMP_MAJOR (got %d, expected %d)\n", major, SHELL_IMP_MAJOR);)
-    return -1;
-  }
-  if (minor < SHELL_IMP_MINOR) {
-    debug_only(fprintf(stderr, "Serviceability agent: unexpected value for SHELL_IMP_MINOR (got %d, expected >= %d)\n", minor, SHELL_IMP_MINOR);)
-    return -1;
-  }
-
-  if (module != NULL) {
-    debug_only(fprintf(stderr, "Serviceability agent: module appears to already be initialized (should not happen)\n");)
-    // Already initialized. Should not happen.
-    return -1;
-  }
-
-  module = new ServiceabilityAgentDbxModule(major, minor, interp, argc, argv);
-  if (!module->install()) {
-    debug_only(fprintf(stderr, "Serviceability agent: error installing import module\n");)
-    delete module;
-    module = NULL;
-    return -1;
-  }
-
-  // Installation was successful. Next step will be for the user to
-  // enter the appropriate command on the command line, which will
-  // make the SA's dbx module wait for commands to come in over the
-  // socket.
-  return 0;
-}
-
-/** This is the routine called by dbx upon unloading of this module.
-    Returns 0 upon success, -1 upon failure. */
-int
-shell_imp_fini(shell_imp_interp_t)
-{
-  if (module == NULL) {
-    return -1;
-  }
-
-  bool res = module->uninstall();
-  delete module;
-  module = NULL;
-  if (!res) {
-    return -1;
-  }
-  return 0;
-}
-
-} // extern "C"
-
-/** This is the routine which is called by the dbx shell when the user
-    requests the serviceability agent module to run. This delegates to
-    ServiceabilityAgentDbxModule::run. This routine's signature must
-    match that of shell_imp_fun_t. */
-extern "C" {
-static int
-svc_agent_run(shell_imp_interp_t, int, char **, void *) {
-  if (module == NULL) {
-    return -1;
-  }
-
-  module->run();
-  return 0;
-}
-}
-
-/*
- * Implementation of ServiceabilityAgentDbxModule class
- */
-
-// NOTE: we need to forward declare the special "ps_get_prochandle2"
-// function which allows examination of core files as well. It isn't
-// currently in proc_service_2.h. Note also that it has name mangling
-// because it isn't declared extern "C".
-//const struct ps_prochandle *ps_get_prochandle2(int cores_too);
-
-ServiceabilityAgentDbxModule::ServiceabilityAgentDbxModule(int, int, shell_imp_interp_t interp,
-                                                           int argc, char *argv[])
-  :myComm(32768, 131072)
-{
-  _interp = interp;
-  _argc = argc;
-  _argv = argv;
-  _tdb_agent = NULL;
-  peek_fail_fast = false;
-  libThreadName = NULL;
-}
-
-ServiceabilityAgentDbxModule::~ServiceabilityAgentDbxModule() {
-  if (_command != NULL) {
-    uninstall();
-  }
-}
-
-char*
-readCStringFromProcess(psaddr_t addr) {
-  char c;
-  int num = 0;
-  ps_prochandle* cur_proc = (ps_prochandle*) ps_get_prochandle2(1);
-
-  // Search for null terminator
-  do {
-    if (ps_pread(cur_proc, addr + num, &c, 1) != PS_OK) {
-      return NULL;
-    }
-    ++num;
-  } while (c != 0);
-
-  // Allocate string
-  char* res = new char[num];
-  if (ps_pread(cur_proc, addr, res, num) != PS_OK) {
-    delete[] res;
-    return NULL;
-  }
-  return res;
-}
-
-int
-findLibThreadCB(const rd_loadobj_t* lo, void* data) {
-  ServiceabilityAgentDbxModule* module = (ServiceabilityAgentDbxModule*) data;
-  char* name = readCStringFromProcess(lo->rl_nameaddr);
-  if (strstr(name, "libthread.so") != NULL) {
-    module->libThreadName = name;
-    return 0;
-  } else {
-    delete[] name;
-    return 1;
-  }
-}
-
-bool
-ServiceabilityAgentDbxModule::install() {
-  // NOTE interdependency between here and Java side wrapper
-  // FIXME: casts of string literal to char * to match prototype
-  _command = shell_imp_define_command((char *) "svc_agent_run",
-                                      &svc_agent_run,
-                                      0,
-                                      NULL,
-                                      (char *) "Run the serviceability agent's dbx module.\n"
-                                      "This routine causes the module to listen on a socket for requests.\n"
-                                      "It does not return until the Java-side code tells it to exit, at\n"
-                                      "which point control is returned to the dbx shell.");
-  if (_command == NULL) {
-    debug_only(fprintf(stderr, "Serviceability agent: Failed to install svc_agent_run command\n"));
-    return false;
-  }
-
-  // This is fairly painful. Since dbx doesn't currently load
-  // libthread_db with RTLD_GLOBAL, we can't just use RTLD_DEFAULT for
-  // the argument to dlsym. Instead, we have to use rtld_db to search
-  // through the loaded objects in the target process for libthread.so and
-
-  // Try rtld_db
-  if (rd_init(RD_VERSION) != RD_OK) {
-    debug_only(fprintf(stderr, "Serviceability agent: Unable to init rtld_db\n"));
-    return false;
-  }
-
-  rd_agent_t* rda = rd_new((struct ps_prochandle*) ps_get_prochandle2(1));
-  if (rda == NULL) {
-    debug_only(fprintf(stderr, "Serviceability agent: Unable to allocate rtld_db agent\n"));
-    return false;
-  }
-
-  if (rd_loadobj_iter(rda, (rl_iter_f*) findLibThreadCB, this) != RD_OK) {
-    debug_only(fprintf(stderr, "Serviceability agent: Loadobject iteration failed\n"));
-    return false;
-  }
-
-  if (libThreadName == NULL) {
-    debug_only(fprintf(stderr, "Serviceability agent: Failed to find pathname to libthread.so in target process\n"));
-    return false;
-  }
-
-  // Find and open libthread_db.so
-  char* slash = strrchr(libThreadName, '/');
-  if (slash == NULL) {
-    debug_only(fprintf(stderr, "Serviceability agent: can't parse path to libthread.so \"%s\"\n"));
-    return false;
-  }
-
-  int slashPos = slash - libThreadName;
-  char* buf = new char[slashPos + strlen("libthread_db.so") + 20]; // slop
-  if (buf == NULL) {
-    debug_only(fprintf(stderr, "Serviceability agent: error allocating libthread_db.so pathname\n"));
-    return false;
-  }
-  strncpy(buf, libThreadName, slashPos + 1);
-
-  // Check dbx's data model; use sparcv9/ subdirectory if 64-bit and
-  // if target process is 32-bit
-  if ((sizeof(void*) == 8) &&
-      (strstr(libThreadName, "sparcv9") == NULL)) {
-    strcpy(buf + slashPos + 1, "sparcv9/");
-    slashPos += strlen("sparcv9/");
-  }
-
-  strcpy(buf + slashPos + 1, "libthread_db.so");
-
-  libThreadDB = dlopen(buf, RTLD_LAZY);
-  void* tmpDB = libThreadDB;
-  if (libThreadDB == NULL) {
-    debug_only(fprintf(stderr, "Serviceability agent: Warning: unable to find libthread_db.so at \"%s\"\n", buf));
-    // Would like to handle this case as well. Maybe dbx has a better
-    // idea of where libthread_db.so lies. If the problem with dbx
-    // loading libthread_db without RTLD_GLOBAL specified ever gets
-    // fixed, we could run this code all the time.
-    tmpDB = RTLD_DEFAULT;
-  }
-
-  delete[] buf;
-
-  // Initialize access to libthread_db
-  td_init_fn          = (td_init_fn_t*)          dlsym(tmpDB, "td_init");
-  td_ta_new_fn        = (td_ta_new_fn_t*)        dlsym(tmpDB, "td_ta_new");
-  td_ta_delete_fn     = (td_ta_delete_fn_t*)     dlsym(tmpDB, "td_ta_delete");
-  td_ta_map_id2thr_fn = (td_ta_map_id2thr_fn_t*) dlsym(tmpDB, "td_ta_map_id2thr");
-  td_thr_getgregs_fn  = (td_thr_getgregs_fn_t*)  dlsym(tmpDB, "td_thr_getgregs");
-
-  if (td_init_fn == NULL ||
-      td_ta_new_fn == NULL ||
-      td_ta_delete_fn == NULL ||
-      td_ta_map_id2thr_fn == NULL ||
-      td_thr_getgregs_fn == NULL) {
-    debug_only(fprintf(stderr, "Serviceability agent: Failed to find one or more libthread_db symbols:\n"));
-    debug_only(if (td_init_fn == NULL)          fprintf(stderr, "  td_init\n"));
-    debug_only(if (td_ta_new_fn == NULL)        fprintf(stderr, "  td_ta_new\n"));
-    debug_only(if (td_ta_delete_fn == NULL)     fprintf(stderr, "  td_ta_delete\n"));
-    debug_only(if (td_ta_map_id2thr_fn == NULL) fprintf(stderr, "  td_ta_map_id2thr\n"));
-    debug_only(if (td_thr_getgregs_fn == NULL)  fprintf(stderr, "  td_thr_getgregs\n"));
-    return false;
-  }
-
-  if ((*td_init_fn)() != TD_OK) {
-    debug_only(fprintf(stderr, "Serviceability agent: Failed to initialize libthread_db\n"));
-    return false;
-  }
-
-  return true;
-}
-
-bool
-ServiceabilityAgentDbxModule::uninstall() {
-  if (_command == NULL) {
-    return false;
-  }
-
-  if (libThreadDB != NULL) {
-    dlclose(libThreadDB);
-    libThreadDB = NULL;
-  }
-
-  int res = shell_imp_undefine_command(_command);
-
-  if (res != 0) {
-    return false;
-  }
-
-  return true;
-}
-
-bool
-ServiceabilityAgentDbxModule::run() {
-  // This is where most of the work gets done.
-  // The command processor loop looks like the following:
-  //  - create listening socket
-  //  - accept a connection (only one for now)
-  //  - while that connection is open and the "exit" command has not
-  //    been received:
-  //    - read command
-  //    - if it's the exit command, cleanup and return
-  //    - otherwise, process command and write result
-
-  int listening_socket = socket(AF_INET, SOCK_STREAM, 0);
-  if (listening_socket < 0) {
-    return false;
-  }
-
-  // Set the SO_REUSEADDR property on the listening socket. This
-  // prevents problems with calls to bind() to the same port failing
-  // after this process exits. This seems to work on all platforms.
-  int reuse_address = 1;
-  if (setsockopt(listening_socket, SOL_SOCKET, SO_REUSEADDR,
-                 (char *)&reuse_address, sizeof(reuse_address)) < 0) {
-    close(listening_socket);
-    return false;
-  }
-
-  sockaddr_in server_address;
-  // Build the server address. We can bind the listening socket to the
-  // INADDR_ANY internet address.
-  memset((char*)&server_address, 0, sizeof(server_address));
-  server_address.sin_family = AF_INET;
-  server_address.sin_addr.s_addr = (unsigned long)htonl(INADDR_ANY);
-  server_address.sin_port = htons((short)PORT);
-
-  // Bind socket to port
-  if (bind(listening_socket, (sockaddr*) &server_address,
-           sizeof(server_address)) < 0) {
-    close(listening_socket);
-    return false;
-  }
-
-  // Arbitrarily chosen backlog of 5 (shouldn't matter since we expect
-  // at most one connection)
-  if (listen(listening_socket, 5) < 0) {
-    close(listening_socket);
-    return false;
-  }
-
-  // OK, now ready to wait for a data connection. This call to
-  // accept() will block.
-  struct sockaddr_in client_address;
-  int address_len   = sizeof(client_address);
-  int client_socket = accept(listening_socket, (sockaddr*) &client_address,
-                         &address_len);
-  // Close listening socket regardless of whether accept() succeeded.
-  // (FIXME: this may be annoying, especially during debugging, but I
-  // really feel that robustness and multiple connections should be
-  // handled higher up, e.g., at the Java level -- multiple clients
-  // could conceivably connect to the SA via RMI, and that would be a
-  // more robust solution than implementing multiple connections at
-  // this level)
-  NEEDS_CLEANUP;
-
-  // NOTE: the call to shutdown() usually fails, so don't panic if this happens
-  shutdown(listening_socket, 2);
-
-  if (close(listening_socket) < 0) {
-    debug_only(fprintf(stderr, "Serviceability agent: Error closing listening socket\n"));
-    return false;
-  }
-
-  if (client_socket < 0) {
-    debug_only(fprintf(stderr, "Serviceability agent: Failed to open client socket\n"));
-    // No more cleanup necessary
-    return false;
-  }
-
-  // Attempt to disable TCP buffering on this socket. We send small
-  // amounts of data back and forth and don't want buffering.
-  int buffer_val = 1;
-  if (setsockopt(client_socket, IPPROTO_IP, TCP_NODELAY, (char *) &buffer_val, sizeof(buffer_val)) < 0) {
-    debug_only(fprintf(stderr, "Serviceability agent: Failed to set TCP_NODELAY option on client socket\n"));
-    cleanup(client_socket);
-    return false;
-  }
-
-  // OK, we have the data socket through which we will communicate
-  // with the Java side. Wait for commands or until reading or writing
-  // caused an error.
-
-  bool should_continue = true;
-
-  myComm.setSocket(client_socket);
-
-#ifdef PROFILING
-  scanTimer.reset();
-  workTimer.reset();
-  writeTimer.reset();
-#endif
-
-  // Allocate a new thread agent for libthread_db
-  if ((*td_ta_new_fn)((ps_prochandle*) ps_get_prochandle2(1), &_tdb_agent) !=
-      TD_OK) {
-    debug_only(fprintf(stderr, "Serviceability agent: Failed to allocate thread agent\n"));
-    cleanup(client_socket);
-    return false;
-  }
-
-  do {
-    // Decided to use text to communicate between these processes.
-    // Probably will make debugging easier -- could telnet in if
-    // necessary. Will make scanning harder, but probably doesn't
-    // matter.
-
-    // Why not just do what workshop does and parse dbx's console?
-    // Probably could do that, but at least this way we are in control
-    // of the text format on both ends.
-
-    // FIXME: should have some way of synchronizing these commands
-    // between the C and Java sources.
-
-    NEEDS_CLEANUP;
-
-    // Do a blocking read of a line from the socket.
-    char *input_buffer = myComm.readLine();
-    if (input_buffer == NULL) {
-      debug_only(fprintf(stderr, "Serviceability agent: error during read: errno = %d\n", errno));
-      debug_only(perror("Serviceability agent"));
-      // Error occurred during read.
-      // FIXME: should guard against SIGPIPE
-      cleanup(client_socket);
-      return false;
-    }
-
-    // OK, now ready to scan. See README-commands.txt for syntax
-    // descriptions.
-
-    bool res = false;
-    if (!strncmp(input_buffer, CMD_ADDRESS_SIZE, strlen(CMD_ADDRESS_SIZE))) {
-      res = handleAddressSize(input_buffer + strlen(CMD_ADDRESS_SIZE));
-    } else if (!strncmp(input_buffer, CMD_PEEK_FAIL_FAST, strlen(CMD_PEEK_FAIL_FAST))) {
-      res = handlePeekFailFast(input_buffer + strlen(CMD_PEEK_FAIL_FAST));
-    } else if (!strncmp(input_buffer, CMD_PEEK, strlen(CMD_PEEK))) {
-      res = handlePeek(input_buffer + strlen(CMD_PEEK));
-    } else if (!strncmp(input_buffer, CMD_POKE, strlen(CMD_POKE))) {
-      res = handlePoke(input_buffer + strlen(CMD_POKE));
-    } else if (!strncmp(input_buffer, CMD_MAPPED, strlen(CMD_MAPPED))) {
-      res = handleMapped(input_buffer + strlen(CMD_MAPPED));
-    } else if (!strncmp(input_buffer, CMD_LOOKUP, strlen(CMD_LOOKUP))) {
-      res = handleLookup(input_buffer + strlen(CMD_LOOKUP));
-    } else if (!strncmp(input_buffer, CMD_THR_GREGS, strlen(CMD_THR_GREGS))) {
-      res = handleThrGRegs(input_buffer + strlen(CMD_THR_GREGS));
-    } else if (!strncmp(input_buffer, CMD_EXIT, strlen(CMD_EXIT))) {
-      should_continue = false;
-    }
-
-    if (should_continue) {
-      if (!res) {
-        cleanup(client_socket);
-        return false;
-      }
-    }
-
-#ifdef PROFILING
-    if (++numRequests == PROFILE_COUNT) {
-      fprintf(stderr, "%d requests: %d ms scanning, %d ms work, %d ms writing\n",
-              PROFILE_COUNT, scanTimer.total(), workTimer.total(), writeTimer.total());
-      fflush(stderr);
-      scanTimer.reset();
-      workTimer.reset();
-      writeTimer.reset();
-      numRequests = 0;
-    }
-#endif
-
-  } while (should_continue);
-
-  // Successful exit
-  cleanup(client_socket);
-  return true;
-}
-
-void
-ServiceabilityAgentDbxModule::cleanup(int client_socket) {
-  shutdown(client_socket, 2);
-  close(client_socket);
-  if (_tdb_agent != NULL) {
-    (*td_ta_delete_fn)(_tdb_agent);
-  }
-}
-
-bool
-ServiceabilityAgentDbxModule::handleAddressSize(char* data) {
-  int data_model;
-  ps_err_e result = ps_pdmodel((ps_prochandle*) ps_get_prochandle2(1),
-                               &data_model);
-  if (result != PS_OK) {
-    myComm.writeString("0");
-    myComm.flush();
-    return false;
-  }
-
-  int val;
-  switch (data_model) {
-  case PR_MODEL_ILP32:
-    val = 32;
-    break;
-  case PR_MODEL_LP64:
-    val = 64;
-    break;
-  default:
-    val = 0;
-    break;
-  }
-
-  if (!myComm.writeInt(val)) {
-    return false;
-  }
-  if (!myComm.writeEOL()) {
-    return false;
-  }
-  return myComm.flush();
-}
-
-bool
-ServiceabilityAgentDbxModule::handlePeekFailFast(char* data) {
-  unsigned int val;
-  if (!scanUnsignedInt(&data, &val)) {
-    return false;
-  }
-  peek_fail_fast = (val ? true : false);
-  return true;
-}
-
-bool
-ServiceabilityAgentDbxModule::handlePeek(char* data) {
-  // Scan hex address, return false if failed
-  psaddr_t addr;
-#ifdef PROFILING
-  scanTimer.start();
-#endif /* PROFILING */
-  if (!scanAddress(&data, &addr)) {
-    return false;
-  }
-  unsigned int num;
-  if (!scanUnsignedInt(&data, &num)) {
-    return false;
-  }
-  if (num == 0) {
-#ifdef PROFILING
-    writeTimer.start();
-#endif /* PROFILING */
-    myComm.writeBinChar('B');
-    myComm.writeBinChar(1);
-    myComm.writeBinUnsignedInt(0);
-    myComm.writeBinChar(0);
-#ifdef PROFILING
-    writeTimer.stop();
-#endif /* PROFILING */
-    return true;
-  }
-#ifdef PROFILING
-  scanTimer.stop();
-  workTimer.start();
-#endif /* PROFILING */
-  char* buf = new char[num];
-  ps_prochandle* cur_proc = (ps_prochandle*) ps_get_prochandle2(1);
-  ps_err_e result = ps_pread(cur_proc, addr, buf, num);
-  if (result == PS_OK) {
-    // Fast case; entire read succeeded.
-#ifdef PROFILING
-    workTimer.stop();
-    writeTimer.start();
-#endif /* PROFILING */
-    myComm.writeBinChar('B');
-    myComm.writeBinChar(1);
-    myComm.writeBinUnsignedInt(num);
-    myComm.writeBinChar(1);
-    myComm.writeBinBuf(buf, num);
-#ifdef PROFILING
-    writeTimer.stop();
-#endif /* PROFILING */
-  } else {
-#ifdef PROFILING
-    workTimer.stop();
-#endif /* PROFILING */
-
-    if (peek_fail_fast) {
-#ifdef PROFILING
-    writeTimer.start();
-#endif /* PROFILING */
-      // Fail fast
-      myComm.writeBinChar('B');
-      myComm.writeBinChar(1);
-      myComm.writeBinUnsignedInt(num);
-      myComm.writeBinChar(0);
-#ifdef PROFILING
-    writeTimer.stop();
-#endif /* PROFILING */
-    } else {
-      // Slow case: try to read one byte at a time
-      // FIXME: need better way of handling this, a la VirtualQuery
-
-      unsigned int  strideLen      = 0;
-      int           bufIdx         = 0;
-      bool          lastByteMapped = (ps_pread(cur_proc, addr, buf, 1) == PS_OK ? true : false);
-
-#ifdef PROFILING
-      writeTimer.start();
-#endif /* PROFILING */
-      myComm.writeBinChar('B');
-      myComm.writeBinChar(1);
-#ifdef PROFILING
-      writeTimer.stop();
-#endif /* PROFILING */
-
-      for (int i = 0; i < num; ++i, ++addr) {
-#ifdef PROFILING
-        workTimer.start();
-#endif /* PROFILING */
-        result = ps_pread(cur_proc, addr, &buf[bufIdx], 1);
-#ifdef PROFILING
-        workTimer.stop();
-#endif /* PROFILING */
-        bool tmpMapped = (result == PS_OK ? true : false);
-#ifdef PROFILING
-        writeTimer.start();
-#endif /* PROFILING */
-        if (tmpMapped != lastByteMapped) {
-          // State change. Write the length of the last stride.
-          myComm.writeBinUnsignedInt(strideLen);
-          if (lastByteMapped) {
-            // Stop gathering data. Write the data of the last stride.
-            myComm.writeBinChar(1);
-            myComm.writeBinBuf(buf, strideLen);
-            bufIdx = 0;
-          } else {
-            // Start gathering data to write.
-            myComm.writeBinChar(0);
-          }
-          strideLen = 0;
-          lastByteMapped = tmpMapped;
-        }
-#ifdef PROFILING
-        writeTimer.stop();
-#endif /* PROFILING */
-        if (lastByteMapped) {
-          ++bufIdx;
-        }
-        ++strideLen;
-      }
-
-      // Write last stride (must be at least one byte long by definition)
-#ifdef PROFILING
-      writeTimer.start();
-#endif /* PROFILING */
-      myComm.writeBinUnsignedInt(strideLen);
-      if (lastByteMapped) {
-        myComm.writeBinChar(1);
-        myComm.writeBinBuf(buf, strideLen);
-      } else {
-        myComm.writeBinChar(0);
-      }
-#ifdef PROFILING
-      writeTimer.stop();
-#endif /* PROFILING */
-    }
-  }
-  delete[] buf;
-  myComm.flush();
-  return true;
-}
-
-bool
-ServiceabilityAgentDbxModule::handlePoke(char* data) {
-  // FIXME: not yet implemented
-  NEEDS_CLEANUP;
-  bool res = myComm.writeBoolAsInt(false);
-  myComm.flush();
-  return res;
-}
-
-bool
-ServiceabilityAgentDbxModule::handleMapped(char* data) {
-  // Scan address
-  psaddr_t addr;
-  if (!scanAddress(&data, &addr)) {
-    return false;
-  }
-  unsigned int num;
-  if (!scanUnsignedInt(&data, &num)) {
-    return false;
-  }
-  unsigned char val;
-  ps_prochandle* cur_proc = (ps_prochandle*) ps_get_prochandle2(1);
-  char* buf = new char[num];
-  if (ps_pread(cur_proc, addr, buf, num) == PS_OK) {
-    myComm.writeBoolAsInt(true);
-  } else {
-    myComm.writeBoolAsInt(false);
-  }
-  delete[] buf;
-  myComm.writeEOL();
-  myComm.flush();
-  return true;
-}
-
-extern "C"
-int loadobj_iterator(const rd_loadobj_t* loadobj, void *) {
-  if (loadobj != NULL) {
-    fprintf(stderr, "loadobj_iterator: visited loadobj \"%p\"\n", (void*) loadobj->rl_nameaddr);
-    return 1;
-  }
-
-  fprintf(stderr, "loadobj_iterator: NULL loadobj\n");
-  return 0;
-}
-
-bool
-ServiceabilityAgentDbxModule::handleLookup(char* data) {
-  // Debugging: iterate over loadobjs
-  /*
-  rd_agent_t* rld_agent = rd_new((ps_prochandle*) ps_get_prochandle2(1));
-  rd_loadobj_iter(rld_agent, &loadobj_iterator, NULL);
-  rd_delete(rld_agent);
-  */
-
-#ifdef PROFILING
-  scanTimer.start();
-#endif /* PROFILING */
-
-  char* object_name = scanSymbol(&data);
-  if (object_name == NULL) {
-    return false;
-  }
-  char* symbol_name = scanSymbol(&data);
-  if (symbol_name == NULL) {
-    delete[] object_name;
-    return false;
-  }
-
-#ifdef PROFILING
-  scanTimer.stop();
-  workTimer.start();
-#endif /* PROFILING */
-
-  ps_sym_t sym;
-  // FIXME: check return values from write routines
-  ps_prochandle* process = (ps_prochandle*) ps_get_prochandle2(1);
-  ps_err_e lookup_res = ps_pglobal_sym(process,
-                                       object_name, symbol_name, &sym);
-#ifdef PROFILING
-  workTimer.stop();
-  writeTimer.start();
-#endif /* PROFILING */
-
-  delete[] object_name;
-  delete[] symbol_name;
-  if (lookup_res != PS_OK) {
-    // This is too noisy
-    //    debug_only(fprintf(stderr, "ServiceabilityAgentDbxModule::handleLookup: error %d\n", lookup_res));
-    myComm.writeString("0x0");
-  } else {
-    myComm.writeAddress((void *)sym.st_value);
-  }
-  myComm.writeEOL();
-  myComm.flush();
-
-#ifdef PROFILING
-  writeTimer.stop();
-#endif /* PROFILING */
-
-  return true;
-}
-
-bool
-ServiceabilityAgentDbxModule::handleThrGRegs(char* data) {
-#ifdef PROFILING
-  scanTimer.start();
-#endif /* PROFILING */
-
-  unsigned int num;
-  // Get the thread ID
-  if (!scanUnsignedInt(&data, &num)) {
-    return false;
-  }
-
-#ifdef PROFILING
-  scanTimer.stop();
-  workTimer.start();
-#endif /* PROFILING */
-
-  // Map tid to thread handle
-  td_thrhandle_t thread_handle;
-  if ((*td_ta_map_id2thr_fn)(_tdb_agent, num, &thread_handle) != TD_OK) {
-    //    fprintf(stderr, "Error mapping thread ID %d to thread handle\n", num);
-    return false;
-  }
-
-  // Fetch register set
-  prgregset_t reg_set;
-  memset(reg_set, 0, sizeof(reg_set));
-  td_err_e result = (*td_thr_getgregs_fn)(&thread_handle, reg_set);
-  if ((result != TD_OK) && (result != TD_PARTIALREG)) {
-    //    fprintf(stderr, "Error fetching registers for thread handle %d: error = %d\n", num, result);
-    return false;
-  }
-
-#ifdef PROFILING
-  workTimer.stop();
-  writeTimer.start();
-#endif /* PROFILING */
-
-#if (defined(__sparc) || defined(__i386))
-  myComm.writeInt(NPRGREG);
-  myComm.writeSpace();
-  for (int i = 0; i < NPRGREG; i++) {
-    myComm.writeAddress((void *)reg_set[i]);
-    if (i == NPRGREG - 1) {
-      myComm.writeEOL();
-    } else {
-      myComm.writeSpace();
-    }
-  }
-#else
-#error  Please port ServiceabilityAgentDbxModule::handleThrGRegs to your current platform
-#endif
-
-  myComm.flush();
-
-#ifdef PROFILING
-  writeTimer.stop();
-#endif /* PROFILING */
-
-  return true;
-}
-
-//
-// Input routines
-//
-
-bool
-ServiceabilityAgentDbxModule::scanAddress(char** data, psaddr_t* addr) {
-  *addr = 0;
-
-  // Skip whitespace
-  while ((**data != 0) && (isspace(**data))) {
-    ++*data;
-  }
-
-  if (**data == 0) {
-    return false;
-  }
-
-  if (strncmp(*data, "0x", 2) != 0) {
-    return false;
-  }
-
-  *data += 2;
-
-  while ((**data != 0) && (!isspace(**data))) {
-    int val;
-    bool res = charToNibble(**data, &val);
-    if (!res) {
-      return false;
-    }
-    *addr <<= 4;
-    *addr |= val;
-    ++*data;
-  }
-
-  return true;
-}
-
-bool
-ServiceabilityAgentDbxModule::scanUnsignedInt(char** data, unsigned int* num) {
-  *num = 0;
-
-  // Skip whitespace
-  while ((**data != 0) && (isspace(**data))) {
-    ++*data;
-  }
-
-  if (**data == 0) {
-    return false;
-  }
-
-  while ((**data != 0) && (!isspace(**data))) {
-    char cur = **data;
-    if ((cur < '0') || (cur > '9')) {
-      return false;
-    }
-    *num *= 10;
-    *num += cur - '0';
-    ++*data;
-  }
-
-  return true;
-}
-
-char*
-ServiceabilityAgentDbxModule::scanSymbol(char** data) {
-  // Skip whitespace
-  while ((**data != 0) && (isspace(**data))) {
-    ++*data;
-  }
-
-  if (**data == 0) {
-    return NULL;
-  }
-
-  // First count length
-  int len = 1; // Null terminator
-  char* tmpData = *data;
-  while ((*tmpData != 0) && (!isspace(*tmpData))) {
-    ++tmpData;
-    ++len;
-  }
-  char* buf = new char[len];
-  strncpy(buf, *data, len - 1);
-  buf[len - 1] = 0;
-  *data += len - 1;
-  return buf;
-}
-
-bool
-ServiceabilityAgentDbxModule::charToNibble(char ascii, int* value) {
-  if (ascii >= '0' && ascii <= '9') {
-    *value = ascii - '0';
-    return true;
-  } else if (ascii >= 'A' && ascii <= 'F') {
-    *value = 10 + ascii - 'A';
-    return true;
-  } else if (ascii >= 'a' && ascii <= 'f') {
-    *value = 10 + ascii - 'a';
-    return true;
-  }
-
-  return false;
-}
-
-
-char*
-ServiceabilityAgentDbxModule::readCStringFromProcess(psaddr_t addr) {
-  char c;
-  int num = 0;
-  ps_prochandle* cur_proc = (ps_prochandle*) ps_get_prochandle2(1);
-
-  // Search for null terminator
-  do {
-    if (ps_pread(cur_proc, addr + num, &c, 1) != PS_OK) {
-      return NULL;
-    }
-    ++num;
-  } while (c != 0);
-
-  // Allocate string
-  char* res = new char[num];
-  if (ps_pread(cur_proc, addr, res, num) != PS_OK) {
-    delete[] res;
-    return NULL;
-  }
-  return res;
-}
-
-
-//--------------------------------------------------------------------------------
-// Class Timer
-//
-
-Timer::Timer() {
-  reset();
-}
-
-Timer::~Timer() {
-}
-
-void
-Timer::start() {
-  gettimeofday(&startTime, NULL);
-}
-
-void
-Timer::stop() {
-  struct timeval endTime;
-  gettimeofday(&endTime, NULL);
-  totalMicroseconds += timevalDiff(&startTime, &endTime);
-  ++counter;
-}
-
-long
-Timer::total() {
-  return (totalMicroseconds / 1000);
-}
-
-long
-Timer::average() {
-  return (long) ((double) total() / (double) counter);
-}
-
-void
-Timer::reset() {
-  totalMicroseconds = 0;
-  counter = 0;
-}
-
-long long
-Timer::timevalDiff(struct timeval* start, struct timeval* end) {
-  long long secs = end->tv_sec - start->tv_sec;
-  secs *= 1000000;
-  long long usecs = end->tv_usec - start->tv_usec;
-  return (secs + usecs);
-}
--- a/hotspot/agent/src/os/solaris/dbx/svc_agent_dbx.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 "shell_imp.h"
-#include "IOBuf.hpp"
-#include <sys/time.h>
-#include <thread_db.h>
-
-typedef td_err_e td_init_fn_t();
-typedef td_err_e td_ta_new_fn_t(struct ps_prochandle *, td_thragent_t **);
-typedef td_err_e td_ta_delete_fn_t(td_thragent_t *);
-typedef td_err_e td_ta_map_id2thr_fn_t(const td_thragent_t *, thread_t,  td_thrhandle_t *);
-typedef td_err_e td_thr_getgregs_fn_t(const td_thrhandle_t *, prgregset_t);
-
-class ServiceabilityAgentDbxModule {
-public:
-  ServiceabilityAgentDbxModule(int major, int minor,
-                               shell_imp_interp_t interp, int argc, char *argv[]);
-  ~ServiceabilityAgentDbxModule();
-
-  bool install();
-  bool uninstall();
-
-  /* This is invoked through the dbx command interpreter. It listens
-     on a socket for commands and does not return until it receives an
-     "exit" command. At that point control is returned to dbx's main
-     loop, at which point if the user sends an exit command to dbx's
-     shell the dbx process will exit. Returns true if completed
-     successfully, false if an error occurred while running (for
-     example, unable to bind listening socket). */
-  bool run();
-
-private:
-
-  // This must be shared between the Java and C layers
-  static const int PORT = 21928;
-
-  // Command handlers
-  bool handleAddressSize(char* data);
-  bool handlePeekFailFast(char* data);
-  bool handlePeek(char* data);
-  bool handlePoke(char* data);
-  bool handleMapped(char* data);
-  bool handleLookup(char* data);
-  bool handleThrGRegs(char* data);
-
-  // Input routines
-
-  // May mutate addr argument even if result is false
-  bool scanAddress(char** data, psaddr_t* addr);
-  // May mutate num argument even if result is false
-  bool scanUnsignedInt(char** data, unsigned int* num);
-  // Returns NULL if error occurred while scanning. Otherwise, returns
-  // newly-allocated character array which must be freed with delete[].
-  char* scanSymbol(char** data);
-  // Helper routine: converts ASCII to 4-bit integer. Returns true if
-  // character is in range, false otherwise.
-  bool charToNibble(char ascii, int* value);
-
-  // Output routines
-
-  // Writes an int with no leading or trailing spaces
-  bool writeInt(int val, int fd);
-  // Writes an address in hex format with no leading or trailing
-  // spaces
-  bool writeAddress(psaddr_t addr, int fd);
-  // Writes a register in hex format with no leading or trailing
-  // spaces (addresses and registers might be of different size)
-  bool writeRegister(prgreg_t reg, int fd);
-  // Writes a space to given file descriptor
-  bool writeSpace(int fd);
-  // Writes carriage return to given file descriptor
-  bool writeCR(int fd);
-  // Writes a bool as [0|1]
-  bool writeBoolAsInt(bool val, int fd);
-  // Helper routine: converts low 4 bits to ASCII [0..9][A..F]
-  char nibbleToChar(unsigned char nibble);
-
-  // Base routine called by most of the above
-  bool writeString(const char* str, int fd);
-
-  // Writes a binary character
-  bool writeBinChar(char val, int fd);
-  // Writes a binary unsigned int in network (big-endian) byte order
-  bool writeBinUnsignedInt(unsigned int val, int fd);
-  // Writes a binary buffer
-  bool writeBinBuf(char* buf, int size, int fd);
-
-  // Routine to flush the socket
-  bool flush(int client_socket);
-
-  void cleanup(int client_socket);
-
-  // The shell interpreter on which we can invoke commands (?)
-  shell_imp_interp_t _interp;
-
-  // The "command line" arguments passed to us by dbx (?)
-  int _argc;
-  char **_argv;
-
-  // The installed command in the dbx shell
-  shell_imp_command_t _command;
-
-  // Access to libthread_db (dlsym'ed to be able to pick up the
-  // version loaded by dbx)
-  td_init_fn_t*          td_init_fn;
-  td_ta_new_fn_t*        td_ta_new_fn;
-  td_ta_delete_fn_t*     td_ta_delete_fn;
-  td_ta_map_id2thr_fn_t* td_ta_map_id2thr_fn;
-  td_thr_getgregs_fn_t*  td_thr_getgregs_fn;
-
-  // Our "thread agent" -- access to libthread_db
-  td_thragent_t* _tdb_agent;
-
-  // Path to libthread.so in target process; free with delete[]
-  char* libThreadName;
-
-  // Handle to dlopen'ed libthread_db.so
-  void* libThreadDB;
-
-  // Helper callback for finding libthread_db.so
-  friend int findLibThreadCB(const rd_loadobj_t* lo, void* data);
-
-  // Support for reading C strings out of the target process (so we
-  // can find the correct libthread_db). Returns newly-allocated char*
-  // which must be freed with delete[], or null if the read failed.
-  char* readCStringFromProcess(psaddr_t addr);
-
-  IOBuf myComm;
-
-  // Output buffer support (used by writeString, writeChar, flush)
-  char* output_buffer;
-  int output_buffer_size;
-  int output_buffer_pos;
-
-  // "Fail fast" flag
-  bool peek_fail_fast;
-
-  // Commands
-  static const char* CMD_ADDRESS_SIZE;
-  static const char* CMD_PEEK_FAIL_FAST;
-  static const char* CMD_PEEK;
-  static const char* CMD_POKE;
-  static const char* CMD_MAPPED;
-  static const char* CMD_LOOKUP;
-  static const char* CMD_THR_GREGS;
-  static const char* CMD_EXIT;
-};
-
-// For profiling. Times reported are in milliseconds.
-class Timer {
-public:
-  Timer();
-  ~Timer();
-
-  void start();
-  void stop();
-  long total();
-  long average();
-  void reset();
-
-private:
-  struct timeval startTime;
-  long long totalMicroseconds; // stored internally in microseconds
-  int counter;
-  long long timevalDiff(struct timeval* startTime, struct timeval* endTime);
-};
--- a/hotspot/agent/src/os/win32/BasicList.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +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.
- *
- */
-
-#ifndef _BASIC_LIST_
-#define _BASIC_LIST_
-
-#include <vector>
-
-template<class T>
-class BasicList {
-protected:
-  typedef std::vector<T> InternalListType;
-  InternalListType internalList;
-
-public:
-  BasicList() {
-  }
-  virtual ~BasicList() {
-  }
-
-  void add(T arg) {
-    internalList.push_back(arg);
-  }
-
-  bool remove(T arg) {
-    for (InternalListType::iterator iter = internalList.begin();
-         iter != internalList.end(); iter++) {
-      if (*iter == arg) {
-        internalList.erase(iter);
-        return true;
-      }
-    }
-    return false;
-  }
-
-  int size() {
-    return internalList.size();
-  }
-
-  T get(int index) {
-    return internalList[index];
-  }
-};
-
-#endif  // #defined _BASIC_LIST_
--- a/hotspot/agent/src/os/win32/Buffer.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 "Buffer.hpp"
-
-#include <string.h>
-
-Buffer::Buffer(int bufSize) {
-  buf = new char[bufSize];
-  sz = bufSize;
-  fill = 0;
-  drain = 0;
-}
-
-Buffer::~Buffer() {
-  delete[] buf;
-}
-
-char*
-Buffer::fillPos() {
-  return buf + fill;
-}
-
-int
-Buffer::remaining() {
-  return sz - fill;
-}
-
-int
-Buffer::size() {
-  return sz;
-}
-
-bool
-Buffer::incrFillPos(int amt) {
-  if (fill + amt >= sz) {
-    return false;
-  }
-  fill += amt;
-  return true;
-}
-
-int
-Buffer::readByte() {
-  if (drain < fill) {
-    return buf[drain++] & 0xFF;
-  } else {
-    return -1;
-  }
-}
-
-int
-Buffer::readBytes(char* data, int len) {
-  int numRead = 0;
-  while (numRead < len) {
-    int c = readByte();
-    if (c < 0) break;
-    data[numRead++] = (char) c;
-  }
-  return numRead;
-}
-
-char*
-Buffer::drainPos() {
-  return buf + drain;
-}
-
-int
-Buffer::drainRemaining() {
-  return fill - drain;
-}
-
-bool
-Buffer::incrDrainPos(int amt) {
-  if (drainRemaining() < amt) {
-    return false;
-  }
-  drain += amt;
-  return true;
-}
-
-void
-Buffer::compact() {
-  // Copy down data
-  memmove(buf, buf + drain, fill - drain);
-  // Adjust positions
-  fill -= drain;
-  drain = 0;
-}
--- a/hotspot/agent/src/os/win32/Buffer.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _BUFFER_
-#define _BUFFER_
-
-// A Buffer is the backing store for the IOBuf abstraction and
-// supports producer-consumer filling and draining.
-
-class Buffer {
-public:
-  Buffer(int bufSize);
-  ~Buffer();
-
-  char* fillPos();   // Position of the place where buffer should be filled
-  int   remaining(); // Number of bytes that can be placed starting at fillPos
-  int   size();      // Size of the buffer
-  // Move up fill position by amount (decreases remaining()); returns
-  // false if not enough space
-  bool  incrFillPos(int amt);
-
-  // Read single byte (0..255); returns -1 if no data available.
-  int   readByte();
-  // Read multiple bytes, non-blocking (this buffer does not define a
-  // fill mechanism), into provided buffer. Returns number of bytes read.
-  int   readBytes(char* buf, int len);
-
-  // Access to drain position. Be very careful using this.
-  char* drainPos();
-  int   drainRemaining();
-  bool  incrDrainPos(int amt);
-
-  // Compact buffer, removing already-consumed input. This must be
-  // called periodically to yield the illusion of an infinite buffer.
-  void  compact();
-
-private:
-  Buffer(const Buffer&);
-  Buffer& operator=(const Buffer&);
-
-  char* buf;
-  int   sz;
-  int   fill;
-  int   drain;
-};
-
-#endif // #defined _BUFFER_
--- a/hotspot/agent/src/os/win32/Dispatcher.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "dispatcher.hpp"
-
-const char* CMD_ASCII         = "ascii";
-const char* CMD_UNICODE       = "unicode";
-const char* CMD_PROCLIST      = "proclist";
-const char* CMD_ATTACH        = "attach";
-const char* CMD_DETACH        = "detach";
-const char* CMD_LIBINFO       = "libinfo";
-const char* CMD_PEEK          = "peek";
-const char* CMD_POKE          = "poke";
-const char* CMD_THREADLIST    = "threadlist";
-const char* CMD_DUPHANDLE     = "duphandle";
-const char* CMD_CLOSEHANDLE   = "closehandle";
-const char* CMD_GETCONTEXT    = "getcontext";
-const char* CMD_SETCONTEXT    = "setcontext";
-const char* CMD_SELECTORENTRY = "selectorentry";
-const char* CMD_SUSPEND       = "suspend";
-const char* CMD_RESUME        = "resume";
-const char* CMD_POLLEVENT     = "pollevent";
-const char* CMD_CONTINUEEVENT = "continueevent";
-const char* CMD_EXIT          = "exit";
-
-// Uncomment the #define below to get messages on stderr
-// #define DEBUGGING
-
-void
-Dispatcher::dispatch(char* cmd, Handler* handler) {
-  if (!strncmp(cmd, CMD_ASCII, strlen(CMD_ASCII))) {
-    handler->ascii(cmd + strlen(CMD_ASCII));
-
-  } else if (!strncmp(cmd, CMD_UNICODE, strlen(CMD_UNICODE))) {
-    handler->unicode(cmd + strlen(CMD_UNICODE));
-
-  } else if (!strncmp(cmd, CMD_PROCLIST, strlen(CMD_PROCLIST))) {
-    handler->procList(cmd + strlen(CMD_PROCLIST));
-
-  } else if (!strncmp(cmd, CMD_ATTACH, strlen(CMD_ATTACH))) {
-    handler->attach(cmd + strlen(CMD_ATTACH));
-
-  } else if (!strncmp(cmd, CMD_DETACH, strlen(CMD_DETACH))) {
-    handler->detach(cmd + strlen(CMD_DETACH));
-
-  } else if (!strncmp(cmd, CMD_LIBINFO, strlen(CMD_LIBINFO))) {
-    handler->libInfo(cmd + strlen(CMD_LIBINFO));
-
-  } else if (!strncmp(cmd, CMD_PEEK, strlen(CMD_PEEK))) {
-    handler->peek(cmd + strlen(CMD_PEEK));
-
-  } else if (!strncmp(cmd, CMD_POKE, strlen(CMD_POKE))) {
-    handler->poke(cmd + strlen(CMD_POKE));
-
-  } else if (!strncmp(cmd, CMD_THREADLIST, strlen(CMD_THREADLIST))) {
-    handler->threadList(cmd + strlen(CMD_THREADLIST));
-
-  } else if (!strncmp(cmd, CMD_DUPHANDLE, strlen(CMD_DUPHANDLE))) {
-    handler->dupHandle(cmd + strlen(CMD_DUPHANDLE));
-
-  } else if (!strncmp(cmd, CMD_CLOSEHANDLE, strlen(CMD_CLOSEHANDLE))) {
-    handler->closeHandle(cmd + strlen(CMD_CLOSEHANDLE));
-
-  } else if (!strncmp(cmd, CMD_GETCONTEXT, strlen(CMD_GETCONTEXT))) {
-    handler->getContext(cmd + strlen(CMD_GETCONTEXT));
-
-  } else if (!strncmp(cmd, CMD_SETCONTEXT, strlen(CMD_SETCONTEXT))) {
-    handler->setContext(cmd + strlen(CMD_SETCONTEXT));
-
-  } else if (!strncmp(cmd, CMD_SELECTORENTRY, strlen(CMD_SELECTORENTRY))) {
-    handler->selectorEntry(cmd + strlen(CMD_SELECTORENTRY));
-
-  } else if (!strncmp(cmd, CMD_SUSPEND, strlen(CMD_SUSPEND))) {
-    handler->suspend(cmd + strlen(CMD_SUSPEND));
-
-  } else if (!strncmp(cmd, CMD_RESUME, strlen(CMD_RESUME))) {
-    handler->resume(cmd + strlen(CMD_RESUME));
-
-  } else if (!strncmp(cmd, CMD_POLLEVENT, strlen(CMD_POLLEVENT))) {
-    handler->pollEvent(cmd + strlen(CMD_POLLEVENT));
-
-  } else if (!strncmp(cmd, CMD_CONTINUEEVENT, strlen(CMD_CONTINUEEVENT))) {
-    handler->continueEvent(cmd + strlen(CMD_CONTINUEEVENT));
-
-  } else if (!strcmp(cmd, CMD_EXIT)) {
-    handler->exit(cmd + strlen(CMD_EXIT));
-  }
-
-#ifdef DEBUGGING
-  else fprintf(stderr, "Ignoring illegal command \"%s\"\n", cmd);
-#endif
-}
--- a/hotspot/agent/src/os/win32/Dispatcher.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +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.
- *
- */
-
-#ifndef _DISPATCHER_
-#define _DISPATCHER_
-
-#include "Handler.hpp"
-
-/** This class understands the commands supported by the system and
-    calls the appropriate handler routines. */
-
-class Dispatcher {
-public:
-  static void dispatch(char* cmd, Handler* handler);
-};
-
-#endif  // #defined _DISPATCHER_
--- a/hotspot/agent/src/os/win32/Handler.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _HANDLER_
-#define _HANDLER_
-
-/** An abstract base class encapsulating the handlers for all commands
-    understood by the system. */
-class Handler {
-public:
-  virtual void ascii(char* arg)         = 0;
-  virtual void unicode(char* arg)       = 0;
-  virtual void procList(char* arg)      = 0;
-  virtual void attach(char* arg)        = 0;
-  virtual void detach(char* arg)        = 0;
-  virtual void libInfo(char* arg)       = 0;
-  virtual void peek(char* arg)          = 0;
-  virtual void poke(char* arg)          = 0;
-  virtual void threadList(char* arg)    = 0;
-  virtual void dupHandle(char* arg)     = 0;
-  virtual void closeHandle(char* arg)   = 0;
-  virtual void getContext(char* arg)    = 0;
-  virtual void setContext(char* arg)    = 0;
-  virtual void selectorEntry(char* arg) = 0;
-  virtual void suspend(char* arg)       = 0;
-  virtual void resume(char* arg)        = 0;
-  virtual void pollEvent(char* arg)     = 0;
-  virtual void continueEvent(char* arg) = 0;
-  virtual void exit(char* arg)          = 0;
-};
-
-#endif  // #defined _HANDLER_
--- a/hotspot/agent/src/os/win32/IOBuf.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,490 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include <stdio.h>
-
-// This file is currently used for os/solaris/agent too.  At some point in time
-// the source will be reorganized to avoid these ifdefs.
-
-#ifdef __sun
-  #include <string.h>
-  #include <inttypes.h>
-  #include <sys/byteorder.h>
-#endif
-
-#include "IOBuf.hpp"
-
-// Formats for printing pointers
-#ifdef _LP64
-#  define INTPTR_FORMAT "0x%016lx"
-#else /* ! _LP64 */
-#  define INTPTR_FORMAT "0x%08lx"
-#endif /* _LP64 */
-
-// Uncomment the #define below to get messages on stderr
-// #define DEBUGGING
-
-IOBuf::IOBuf(int inLen, int outLen) {
-  inBuf = new Buffer(inLen);
-  outBuf = new Buffer(outLen);
-  fd = INVALID_SOCKET;
-  outHandle = NULL;
-  usingSocket = true;
-  reset();
-}
-
-IOBuf::~IOBuf() {
-  delete inBuf;
-  delete outBuf;
-}
-
-void
-IOBuf::setSocket(SOCKET sock) {
-  fd = sock;
-  usingSocket = true;
-}
-
-// Reading/writing files is only needed and used on windows.
-#ifdef WIN32
-void
-IOBuf::setOutputFileHandle(HANDLE handle) {
-  outHandle = handle;
-  usingSocket = false;
-}
-#endif
-
-void
-IOBuf::reset() {
-  gotDataLastTime = false;
-  state          = TEXT_STATE;
-  binPos         = 0;
-  binLength      = 0;
-}
-
-IOBuf::ReadLineResult
-IOBuf::tryReadLine() {
-  return doReadLine(false);
-}
-
-char*
-IOBuf::readLine() {
-  ReadLineResult rr = doReadLine(true);
-  if (rr != RL_GOT_DATA) {
-    return NULL;
-  }
-  return getLine();
-}
-
-IOBuf::ReadLineResult
-IOBuf::doReadLine(bool shouldWait) {
-
-  if (!usingSocket) {
-    return IOBuf::RL_ERROR;
-  }
-
-  if (gotDataLastTime) {
-    curLine.clear();
-  }
-
-  int c;
-  do {
-    c = readChar(shouldWait);
-    if (c >= 0) {
-      Action act = processChar((char) c);
-      if (act == GOT_LINE) {
-        curLine.push_back('\0');
-        gotDataLastTime = true;
-        return IOBuf::RL_GOT_DATA;
-      } else if (act == SKIP_EOL_CHAR) {
-        // Do nothing
-      } else {
-        curLine.push_back((char) c);
-      }
-    }
-  } while (shouldWait || c >= 0);
-
-  gotDataLastTime = false;
-  return IOBuf::RL_NO_DATA;
-}
-
-bool
-IOBuf::flushImpl(bool moreDataToCome) {
-  int numWritten = 0;
-
-#ifdef WIN32
-  // When running on Windows and using IOBufs for inter-process
-  // communication, we need to write metadata into the stream
-  // indicating how many bytes are coming down. Five bytes are written
-  // per flush() call, four containing the integer number of bytes
-  // coming (not including the five-byte header) and one (a 0 or 1)
-  // indicating whether there is more data coming.
-  if (!usingSocket) {
-    int numToWrite = outBuf->drainRemaining();
-    char moreToCome = (moreDataToCome ? 1 : 0);
-    DWORD numBytesWritten;
-    if (!WriteFile(outHandle, &numToWrite, sizeof(int), &numBytesWritten, NULL)) {
-      return false;
-    }
-    if (numBytesWritten != sizeof(int)) {
-      return false;
-    }
-    if (!WriteFile(outHandle, &moreToCome, 1, &numBytesWritten, NULL)) {
-      return false;
-    }
-    if (numBytesWritten != 1) {
-      return false;
-    }
-  }
-#endif
-
-  while (outBuf->drainRemaining() != 0) {
-#ifdef DEBUGGING
-      fprintf(stderr, "Flushing %d bytes\n", outBuf->drainRemaining());
-#endif
-    if (usingSocket) {
-      numWritten = send(fd, outBuf->drainPos(), outBuf->drainRemaining(), 0);
-    } else {
-#ifdef WIN32
-      DWORD numBytesWritten;
-      if (!WriteFile(outHandle, outBuf->drainPos(), outBuf->drainRemaining(), &numBytesWritten, NULL)) {
-        numWritten = -1;
-      } else {
-        numWritten = numBytesWritten;
-      }
-#endif
-    }
-    if (numWritten != -1) {
-#ifdef DEBUGGING
-      fprintf(stderr, "Flushed %d bytes\n", numWritten);
-#endif
-      outBuf->incrDrainPos(numWritten);
-    } else {
-      return false;
-    }
-  }
-
-  outBuf->compact();
-
-  return true;
-}
-
-int
-IOBuf::readChar(bool block) {
-  do {
-    int c = inBuf->readByte();
-    if (c >= 0) {
-      return c;
-    }
-    // See whether we need to compact the input buffer
-    if (inBuf->remaining() < inBuf->size() / 2) {
-      inBuf->compact();
-    }
-    // See whether socket is ready
-    fd_set fds;
-    FD_ZERO(&fds);
-    FD_SET(fd, &fds);
-    struct timeval timeout;
-    timeout.tv_sec = 0;
-    timeout.tv_usec = 0;
-    if (block || select(1 + fd, &fds, NULL, NULL, &timeout) > 0) {
-      if (block || FD_ISSET(fd, &fds)) {
-#ifdef DEBUGGING
-        int b = (block ? 1 : 0);
-        fprintf(stderr, "calling recv: block = %d\n", b);
-#endif
-        // Read data from socket
-        int numRead = recv(fd, inBuf->fillPos(), inBuf->remaining(), 0);
-        if (numRead < 0) {
-#ifdef DEBUGGING
-          fprintf(stderr, "recv failed\n");
-#endif
-          return -1;
-        }
-        inBuf->incrFillPos(numRead);
-      }
-    }
-  } while (block);
-
-  return inBuf->readByte();
-}
-
-char*
-IOBuf::getLine() {
-#ifdef DEBUGGING
-  fprintf(stderr, "Returning (first 10 chars) \"%.10s\"\n", curLine.begin());
-#endif
-  return curLine.begin();
-}
-
-bool
-IOBuf::flush() {
-  return flushImpl(false);
-}
-
-bool
-IOBuf::writeString(const char* str) {
-  int len = strlen(str);
-
-  if (len > outBuf->size()) {
-    return false;
-  }
-
-  if (len > outBuf->remaining()) {
-    if (!flushImpl(true)) {
-      return false;
-    }
-  }
-
-  // NOTE we do not copy the null terminator of the string.
-
-  strncpy(outBuf->fillPos(), str, len);
-  outBuf->incrFillPos(len);
-  return true;
-}
-
-bool
-IOBuf::writeInt(int val) {
-  char buf[128];
-  sprintf(buf, "%d", val);
-  return writeString(buf);
-}
-
-bool
-IOBuf::writeUnsignedInt(unsigned int val) {
-  char buf[128];
-  sprintf(buf, "%u", val);
-  return writeString(buf);
-}
-
-bool
-IOBuf::writeBoolAsInt(bool val) {
-  if (val) {
-    return writeString("1");
-  } else {
-    return writeString("0");
-  }
-}
-
-bool
-IOBuf::writeAddress(void* val) {
-  char buf[128];
-  sprintf(buf, INTPTR_FORMAT, val);
-  return writeString(buf);
-}
-
-bool
-IOBuf::writeSpace() {
-  return writeString(" ");
-}
-
-bool
-IOBuf::writeEOL() {
-  return writeString("\n\r");
-}
-
-bool
-IOBuf::writeBinChar(char c) {
-  return writeBinBuf((char*) &c, sizeof(c));
-}
-
-bool
-IOBuf::writeBinUnsignedShort(unsigned short i) {
-  i = htons(i);
-  return writeBinBuf((char*) &i, sizeof(i));
-}
-
-bool
-IOBuf::writeBinUnsignedInt(unsigned int i) {
-  i = htonl(i);
-  return writeBinBuf((char*) &i, sizeof(i));
-}
-
-bool
-IOBuf::writeBinBuf(char* buf, int size) {
-  while (size > 0) {
-    int spaceRemaining = outBuf->remaining();
-    if (spaceRemaining == 0) {
-      if (!flushImpl(true)) {
-        return false;
-      }
-      spaceRemaining = outBuf->remaining();
-    }
-    int toCopy = (size > spaceRemaining) ? spaceRemaining : size;
-    memcpy(outBuf->fillPos(), buf, toCopy);
-    outBuf->incrFillPos(toCopy);
-    buf += toCopy;
-    size -= toCopy;
-    if (size > 0) {
-      if (!flushImpl(true)) {
-        return false;
-      }
-    }
-  }
-  return true;
-}
-
-#ifdef WIN32
-IOBuf::FillState
-IOBuf::fillFromFileHandle(HANDLE fh, DWORD* numBytesRead) {
-  int totalToRead;
-  char moreToCome;
-
-  outBuf->compact();
-
-  DWORD numRead;
-  if (!ReadFile(fh, &totalToRead, sizeof(int), &numRead, NULL)) {
-    return FAILED;
-  }
-  if (numRead != sizeof(int)) {
-    return FAILED;
-  }
-  if (!ReadFile(fh, &moreToCome, 1, &numRead, NULL)) {
-    return FAILED;
-  }
-  if (numRead != 1) {
-    return FAILED;
-  }
-  if (outBuf->remaining() < totalToRead) {
-    return FAILED;
-  }
-
-  int tmp = totalToRead;
-
-  while (totalToRead > 0) {
-    if (!ReadFile(fh, outBuf->fillPos(), totalToRead, &numRead, NULL)) {
-      return FAILED;
-    }
-    outBuf->incrFillPos((int) numRead);
-    totalToRead -= numRead;
-  }
-
-  *numBytesRead = tmp;
-  return ((moreToCome == 0) ? DONE : MORE_DATA_PENDING);
-}
-#endif
-
-bool
-IOBuf::isBinEscapeChar(char c) {
-  return (c == '|');
-}
-
-IOBuf::Action
-IOBuf::processChar(char c) {
-  Action action = NO_ACTION;
-  switch (state) {
-  case TEXT_STATE: {
-    // Looking for text char, bin escape char, or EOL
-    if (isBinEscapeChar(c)) {
-#ifdef DEBUGGING
-      fprintf(stderr, "[a: '%c'] ", inBuf[0]);
-#endif
-      binPos = 0;
-#ifdef DEBUGGING
-      fprintf(stderr, "[b: '%c'] ", inBuf[0]);
-#endif
-      binLength = 0;
-#ifdef DEBUGGING
-      fprintf(stderr, "[c: '%c'] ", inBuf[0]);
-#endif
-      state = BIN_STATE;
-#ifdef DEBUGGING
-      fprintf(stderr, "[d: '%c'] ", inBuf[0]);
-#endif
-#ifdef DEBUGGING
-      fprintf(stderr, "\nSwitching to BIN_STATE\n");
-#endif
-    } else if (isEOL(c)) {
-      state = EOL_STATE;
-      action = GOT_LINE;
-#ifdef DEBUGGING
-      fprintf(stderr, "\nSwitching to EOL_STATE (GOT_LINE)\n");
-#endif
-    }
-#ifdef DEBUGGING
-    else {
-      fprintf(stderr, "'%c' ", c);
-      fflush(stderr);
-    }
-#endif
-    break;
-  }
-
-  case BIN_STATE: {
-    // Seeking to finish read of input
-    if (binPos < 4) {
-      int cur = c & 0xFF;
-      binLength <<= 8;
-      binLength |= cur;
-      ++binPos;
-    } else {
-#ifdef DEBUGGING
-      fprintf(stderr, "Reading binary byte %d of %d\n",
-              binPos - 4, binLength);
-#endif
-      ++binPos;
-      if (binPos == 4 + binLength) {
-        state = TEXT_STATE;
-#ifdef DEBUGGING
-        fprintf(stderr, "Switching to TEXT_STATE\n");
-#endif
-      }
-    }
-    break;
-  }
-
-  case EOL_STATE: {
-    // More EOL characters just cause us to re-enter this state
-    if (isEOL(c)) {
-      action = SKIP_EOL_CHAR;
-    } else if (isBinEscapeChar(c)) {
-      binPos = 0;
-      binLength = 0;
-      state = BIN_STATE;
-    } else {
-      state = TEXT_STATE;
-#ifdef DEBUGGING
-      fprintf(stderr, "'%c' ", c);
-      fflush(stderr);
-#endif
-    }
-    break;
-  }
-
-  } // switch
-
-  return action;
-}
-
-
-bool
-IOBuf::isEOL(char c) {
-#ifdef WIN32
-  return ((c == '\n') || (c == '\r'));
-#elif defined(__sun)
-  return c == '\n';
-#else
-  #error Please port isEOL() to your platform
-  return false;
-#endif
-}
--- a/hotspot/agent/src/os/win32/IOBuf.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * 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 _IO_BUF_
-#define _IO_BUF_
-
-// This file is currently used for os/solaris/agent/ too.  At some point in time
-// the source will be reorganized to avoid these ifdefs.
-// Note that this class can read/write from a file as well as a socket.  This
-// file capability is only implemented on win32.
-
-#ifdef WIN32
-  #include <winsock2.h>
-#else
-  #include <sys/types.h>
-  #include <sys/socket.h>
-  // These are from win32 winsock2.h
-  typedef unsigned int SOCKET;
-  typedef void * HANDLE;
-  typedef unsigned long DWORD;
-  #define INVALID_SOCKET (SOCKET)(~0)
-#endif
-
-#include <vector>
-#include "Buffer.hpp"
-
-/** Manages an input/output buffer pair for a socket or file handle. */
-class IOBuf {
-public:
-  IOBuf(int inBufLen, int outBufLen);
-  ~IOBuf();
-
-  enum ReadLineResult {
-    RL_GOT_DATA,
-    RL_NO_DATA,
-    RL_ERROR
-  };
-
-  /** Change the socket with which this buffer is associated */
-  void setSocket(SOCKET sock);
-
-  // Reading/writing files is only supported on windows.
-#ifdef WIN32
-  /** Change the output file handle with which this buffer is
-      associated. Currently IOBufs can not be used to read from a file
-      handle. */
-  void setOutputFileHandle(HANDLE handle);
-#endif
-
-  /** Reset the input and output buffers, without flushing the output
-      data to the socket */
-  void reset();
-
-  /** Try to read a line of data from the given socket without
-      blocking. If was able to read a complete line of data, returns a
-      character pointer to the beginning of the (null-terminated)
-      string. If not, returns NULL, but maintains enough state that
-      subsequent calls to tryReadLine() will not ignore the data
-      already read. NOTE: this skips end-of-line characters (typically
-      CR/LF) as defined by "isEOL()". When switching back and forth
-      between binary and text modes, to be sure no data is lost, pad
-      the beginning and end of the binary transmission with bytes
-      which can not be confused with these characters. */
-  ReadLineResult tryReadLine();
-
-  /** Read a line of data from the given socket, blocking until a
-      line, including EOL, appears.  Return the line, or NULL if
-      something goes wrong. */
-  char *readLine();
-
-  /** Get the pointer to the beginning of the (null-terminated) line.
-      This should only be called if tryReadLine() has returned
-      RL_GOT_DATA. This sets the "parsing cursor" to the beginning of
-      the line. */
-  char* getLine();
-
-  // NOTE: any further data-acquisition routines must ALWAYS call
-  // fixupData() at the beginning!
-
-  //----------------------------------------------------------------------
-  // Output routines
-  //
-
-  /** Flush the output buffer to the socket. Returns true if
-      succeeded, false if write error occurred. */
-  bool flush();
-
-  /** Write the given string to the output buffer. May flush if output
-      buffer becomes too full to store the data. Not guaranteed to
-      work if string is longer than the size of the output buffer.
-      Does not include the null terminator of the string. Returns true
-      if succeeded, false if write error occurred. */
-  bool writeString(const char* str);
-
-  /** Write the given int to the output buffer. May flush if output
-      buffer becomes too full to store the data. Returns true if
-      succeeded, false if write error occurred. */
-  bool writeInt(int val);
-
-  /** Write the given unsigned int to the output buffer. May flush if
-      output buffer becomes too full to store the data. Returns true
-      if succeeded, false if write error occurred. */
-  bool writeUnsignedInt(unsigned int val);
-
-  /** Write the given boolean to the output buffer. May flush if
-      output buffer becomes too full to store the data. Returns true
-      if succeeded, false if write error occurred. */
-  bool writeBoolAsInt(bool val);
-
-  /** Write the given address to the output buffer. May flush if
-      output buffer becomes too full to store the data. Returns true
-      if succeeded, false if write error occurred. */
-  bool writeAddress(void* val);
-
-  /** Writes a space to the output buffer. May flush if output buffer
-      becomes too full to store the data. Returns true if succeeded,
-      false if write error occurred. */
-  bool writeSpace();
-
-  /** Writes an end-of-line sequence to the output buffer. May flush
-      if output buffer becomes too full to store the data. Returns
-      true if succeeded, false if write error occurred. */
-  bool writeEOL();
-
-  /** Writes a binary character to the output buffer. */
-  bool writeBinChar(char c);
-
-  /** Writes a binary unsigned short in network (big-endian) byte
-      order to the output buffer. */
-  bool writeBinUnsignedShort(unsigned short i);
-
-  /** Writes a binary unsigned int in network (big-endian) byte order
-      to the output buffer. */
-  bool writeBinUnsignedInt(unsigned int i);
-
-  /** Writes a binary buffer to the output buffer. */
-  bool writeBinBuf(char* buf, int size);
-
-#ifdef WIN32
-  enum FillState {
-    DONE = 1,
-    MORE_DATA_PENDING = 2,
-    FAILED = 3
-  };
-
-  /** Very specialized routine; fill the output buffer from the given
-      file handle. Caller is responsible for ensuring that there is
-      data to be read on the file handle. */
-  FillState fillFromFileHandle(HANDLE fh, DWORD* numRead);
-#endif
-
-  /** Binary utility routine (for poke) */
-  static bool isBinEscapeChar(char c);
-
-private:
-  IOBuf(const IOBuf&);
-  IOBuf& operator=(const IOBuf&);
-
-  // Returns -1 if non-blocking and no data available
-  int readChar(bool block);
-  // Line-oriented reading
-  std::vector<char> curLine;
-  bool gotDataLastTime;
-
-  ReadLineResult doReadLine(bool);
-
-  bool flushImpl(bool moreDataToCome);
-
-  SOCKET fd;
-  HANDLE outHandle;
-  bool usingSocket;
-
-  // Buffers
-  Buffer* inBuf;
-  Buffer* outBuf;
-
-  // Simple finite-state machine to handle binary data
-  enum State {
-    TEXT_STATE,
-    BIN_STATE,
-    EOL_STATE
-  };
-  enum Action {
-    NO_ACTION,
-    GOT_LINE,     // TEXT_STATE -> EOL_STATE transition
-    SKIP_EOL_CHAR // EOL_STATE -> EOL_STATE transition
-  };
-
-  State state;
-  Action processChar(char c);
-
-  // Handling incoming binary buffers (poke command)
-  int   binPos;    // Number of binary characters read so far;
-                   // total number to read is binLength + 4
-  int   binLength; // Number of binary characters in message;
-                   // not valid until binPos >= 4
-
-  bool isEOL(char c);
-};
-
-#endif  // #defined _IO_BUF_
--- a/hotspot/agent/src/os/win32/LockableList.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +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.
- *
- */
-
-#ifndef _LOCKABLE_LIST_
-#define _LOCKABLE_LIST_
-
-#include <windows.h>
-#include "BasicList.hpp"
-
-template<class T>
-class LockableList : public BasicList<T> {
-private:
-  CRITICAL_SECTION crit;
-
-public:
-  LockableList() {
-    InitializeCriticalSection(&crit);
-  }
-
-  ~LockableList() {
-    DeleteCriticalSection(&crit);
-  }
-
-  void lock() {
-    EnterCriticalSection(&crit);
-  }
-
-  void unlock() {
-    LeaveCriticalSection(&crit);
-  }
-};
-
-#endif  // #defined _LOCKABLE_LIST_
--- a/hotspot/agent/src/os/win32/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-#
-# Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#  
-#
-
-SERVER=SwDbgSrv.exe
-SUBPROCESS=SwDbgSub.exe
-
-SERVER_SOURCES =   \
-  Buffer.cpp       \
-  Dispatcher.cpp   \
-  initWinsock.cpp  \
-  IOBuf.cpp        \
-  ioUtils.cpp      \
-  isNT4.cpp        \
-  nt4internals.cpp \
-  procList.cpp     \
-  Reaper.cpp       \
-  SwDbgSrv.cpp     \
-  serverLists.cpp  \
-  toolHelp.cpp
-
-SUBPROCESS_SOURCES = \
-  SwDbgSub.cpp       \
-  Buffer.cpp         \
-  IOBuf.cpp          \
-  isNT4.cpp          \
-  libInfo.cpp        \
-  Monitor.cpp        \
-  nt4internals.cpp   \
-  toolHelp.cpp
-
-SERVER_OBJS     = $(SERVER_SOURCES:.cpp=.obj)
-SUBPROCESS_OBJS = $(SUBPROCESS_SOURCES:.cpp=.obj)
-
-CPP=cl.exe
-LINK32=link.exe
-
-# These do not need to be optimized (don't run a lot of code) and it
-# will be useful to have the assertion checks in place
-
-CFLAGS=/nologo /MD /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-
-LIBS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib          \
-     ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib     \
-     winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib \
-     odbccp32.lib ws2_32.lib  /nologo /subsystem:console /debug /machine:I386
-
-default: $(SERVER) $(SUBPROCESS)
-
-$(SERVER): $(SERVER_OBJS)
-	$(LINK32) /out:$@ $(SERVER_OBJS) $(LIBS)
-
-$(SUBPROCESS): $(SUBPROCESS_OBJS)
-	$(LINK32) /out:$@ $(SUBPROCESS_OBJS) $(LIBS)
-
-clean:
-	rm -f *.obj *.idb *.pch *.pdb *.ncb *.opt *.plg *.exe *.ilk
-
-.cpp.obj:
-	@ $(CPP) $(CFLAGS) /o $@ $<
--- a/hotspot/agent/src/os/win32/Message.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _MESSAGE_
-#define _MESSAGE_
-
-// These are the commands sent from the server to the child processes
-// over the child processes' stdin pipes. A subset of the commands
-// understood by the overall system, these require responses from the
-// child process. Having a data structure rather than sending text
-// simplifies parsing on the child side. The child replies by sending
-// back fully-formatted replies which are copied by the server process
-// to the clients' sockets.
-
-struct PeekArg {
-  DWORD address;
-  DWORD numBytes;
-};
-
-// NOTE: when sending a PokeArg to the child process, we handle the
-// buffer specially
-struct PokeArg {
-  DWORD address;
-  DWORD numBytes;
-  void* data;
-};
-
-// Used for continueevent
-struct BoolArg {
-  bool val;
-};
-
-// Used for duphandle, closehandle, and getcontext
-struct HandleArg {
-  HANDLE handle;
-};
-
-// Used for setcontext
-const int NUM_REGS_IN_CONTEXT = 22;
-struct SetContextArg {
-  HANDLE handle;
-  DWORD  Eax;
-  DWORD  Ebx;
-  DWORD  Ecx;
-  DWORD  Edx;
-  DWORD  Esi;
-  DWORD  Edi;
-  DWORD  Ebp;
-  DWORD  Esp;
-  DWORD  Eip;
-  DWORD  Ds;
-  DWORD  Es;
-  DWORD  Fs;
-  DWORD  Gs;
-  DWORD  Cs;
-  DWORD  Ss;
-  DWORD  EFlags;
-  DWORD  Dr0;
-  DWORD  Dr1;
-  DWORD  Dr2;
-  DWORD  Dr3;
-  DWORD  Dr6;
-  DWORD  Dr7;
-};
-
-// Used for selectorentry
-struct SelectorEntryArg {
-  HANDLE handle;
-  DWORD  selector;
-};
-
-struct Message {
-  typedef enum {
-    ATTACH,
-    DETACH,
-    LIBINFO,
-    PEEK,
-    POKE,
-    THREADLIST,
-    DUPHANDLE,
-    CLOSEHANDLE,
-    GETCONTEXT,
-    SETCONTEXT,
-    SELECTORENTRY,
-    SUSPEND,
-    RESUME,
-    POLLEVENT,
-    CONTINUEEVENT
-  } Type;
-
-  Type type;
-  union {
-    PeekArg          peekArg;
-    PokeArg          pokeArg;
-    BoolArg          boolArg;
-    HandleArg        handleArg;
-    SetContextArg    setContextArg;
-    SelectorEntryArg selectorArg;
-  };
-};
-
-#endif  // #defined _MESSAGE_
--- a/hotspot/agent/src/os/win32/Monitor.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include <stdio.h>
-#include <assert.h>
-#include "Monitor.hpp"
-
-Monitor::Monitor() {
-  _lock_count = -1;       // No threads have entered the critical section
-  _owner = NULL;
-  _lock_event = CreateEvent(NULL, false, false, NULL);
-  _wait_event = CreateEvent(NULL, true, false, NULL);
-  _counter = 0;
-  _tickets = 0;
-  _waiters = 0;
-}
-
-Monitor::~Monitor() {
-  assert(_owner == NULL);    // Otherwise, owned monitor being deleted
-  assert(_lock_count == -1); // Otherwise, monitor being deleted with non -1 lock count
-  CloseHandle(_lock_event);
-  CloseHandle(_wait_event);
-}
-
-void
-Monitor::lock() {
-  if (InterlockedIncrement(&_lock_count) == 0) {
-    // Success, we now own the lock
-  } else {
-    DWORD dwRet = WaitForSingleObject((HANDLE)_lock_event,  INFINITE);
-    assert(dwRet == WAIT_OBJECT_0); // Unexpected return value from WaitForSingleObject
-  }
-  assert(owner() == NULL); // Otherwise, lock count and owner are inconsistent
-  setOwner(GetCurrentThread());
-}
-
-void
-Monitor::unlock() {
-  setOwner(NULL);
-  if (InterlockedDecrement(&_lock_count) >= 0) {
-    // Wake a waiting thread up
-    DWORD dwRet = SetEvent(_lock_event);
-    assert(dwRet != 0); // Unexpected return value from SetEvent
-  }
-}
-
-bool
-Monitor::wait(long timeout) {
-  assert(owner() != NULL);
-  assert(owner() == GetCurrentThread());
-
-  // 0 means forever. Convert to Windows specific code.
-  DWORD timeout_value = (timeout == 0) ? INFINITE : timeout;
-  DWORD which;
-
-  long c = _counter;
-  bool retry = false;
-
-  _waiters++;
-  // Loop until condition variable is signaled.  The event object is
-  // set whenever the condition variable is signaled, and tickets will
-  // reflect the number of threads which have been notified. The counter
-  // field is used to make sure we don't respond to notifications that
-  // have occurred *before* we started waiting, and is incremented each
-  // time the condition variable is signaled.
-
-  while (true) {
-
-    // Leave critical region
-    unlock();
-
-    // If this is a retry, let other low-priority threads have a chance
-    // to run.  Make sure that we sleep outside of the critical section.
-    if (retry) {
-      Sleep(1);
-    } else {
-      retry = true;
-    }
-
-    which = WaitForSingleObject(_wait_event, timeout_value);
-    // Enter critical section
-    lock();
-
-    if (_tickets != 0 && _counter != c) break;
-
-    if (which == WAIT_TIMEOUT) {
-      --_waiters;
-      return true;
-    }
-  }
-  _waiters--;
-
-  // If this was the last thread to be notified, then we need to reset
-  // the event object.
-  if (--_tickets == 0) {
-    ResetEvent(_wait_event);
-  }
-
-  return false;
-}
-
-// Notify a single thread waiting on this monitor
-bool
-Monitor::notify() {
-  assert(ownedBySelf()); // Otherwise, notify on unknown thread
-
-  if (_waiters > _tickets) {
-    if (!SetEvent(_wait_event)) {
-      return false;
-    }
-    _tickets++;
-    _counter++;
-  }
-
-  return true;
-}
-
-// Notify all threads waiting on this monitor
-bool
-Monitor::notifyAll() {
-  assert(ownedBySelf()); // Otherwise, notifyAll on unknown thread
-
-  if (_waiters > 0) {
-    if (!SetEvent(_wait_event)) {
-      return false;
-    }
-    _tickets = _waiters;
-    _counter++;
-  }
-
-  return true;
-}
-
-HANDLE
-Monitor::owner() {
-  return _owner;
-}
-
-void
-Monitor::setOwner(HANDLE owner) {
-  if (owner != NULL) {
-    assert(_owner == NULL);                 // Setting owner thread of already owned monitor
-    assert(owner == GetCurrentThread());    // Else should not be doing this
-  } else {
-    HANDLE oldOwner = _owner;
-    assert(oldOwner != NULL);               // Removing the owner thread of an unowned mutex
-    assert(oldOwner == GetCurrentThread());
-  }
-  _owner = owner;
-}
-
-bool
-Monitor::ownedBySelf() {
-  return (_owner == GetCurrentThread());
-}
--- a/hotspot/agent/src/os/win32/Monitor.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _MONITOR_
-#define _MONITOR_
-
-#include <windows.h>
-
-class Monitor {
-public:
-  Monitor();
-  ~Monitor();
-
-  void lock();
-  void unlock();
-  // Default time is forever (i.e, zero). Returns true if it times-out, otherwise
-  // false.
-  bool wait(long timeout = 0);
-  bool notify();
-  bool notifyAll();
-
-private:
-  HANDLE owner();
-  void setOwner(HANDLE owner);
-  bool ownedBySelf();
-
-  HANDLE _owner;
-  long   _lock_count;
-  HANDLE _lock_event;   // Auto-reset event for blocking in lock()
-  HANDLE _wait_event;   // Manual-reset event for notifications
-  long _counter;        // Current number of notifications
-  long _waiters;        // Number of threads waiting for notification
-  long _tickets;        // Number of waiters to be notified
-};
-
-
-#endif  // #defined _MONITOR_
--- a/hotspot/agent/src/os/win32/README-commands.txt	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +0,0 @@
-This debug server uses a largely text-based protocol, except for
-certain bulk data transfer operations. All text is in single-byte
-US-ASCII except for the strings returned in "proclist".
-
-NOTE that the character '|' (vertical bar) is used as an escape
-character to switch the incoming data stream to the debug server into
-binary mode, so no text command may contain that character.
-
-Commands understood:
-
-ascii <EOL>                 ::=
-
-    Changes to ASCII mode. This affects all outgoing strings. At
-    startup the system is in unicode mode.
-
-unicode <EOL>               ::=
-
-    Changes to UNICODE mode. This affects all outgoing strings. This
-    is the default mode upon startup.
-
-proclist <EOL>              ::=
-      <int num> [<unsigned int pid> <int charSize> <int numChars> [<binary char_t name>]...]... <EOL>
-
-    Returns integer indicating number of processes to follow, followed
-    by (pid, name) pairs. Names are given by (charSize, numChars,
-    [char_t]...) tuples; charSize indicates the size of each character
-    in bytes, numChars the number of characters in the string, and
-    name the raw data for the string. Each individual character of the
-    string, if multi-byte, is transmitted in network byte order.
-    numChars and name are guaranteed to be separated by precisely one
-    US-ASCII space. If process list is not available because of
-    limitations of the underlying operating system, number of
-    processes returned is 0.
-
-attach <int pid> <EOL>      ::= <bool result> <EOL>
-
-    Attempts to attach to the specified process. Returns 1 if
-    successful, 0 if not. Will fail if already attached or if the
-    process ID does not exist. Attaching to a process causes the
-    process to be suspended.
-
-detach <EOL>                ::= <bool result> <EOL>
-
-    Detaches from the given process. Attaching and detaching multiple
-    times during a debugging session is allowed. Detaching causes the
-    process to resume execution.
-
-libinfo <EOL>               ::=
-      <int numLibs> [<int charSize> <int numChars> [<binary char_t name>]... <address baseAddr>]... <EOL>
-
-    May only be called once attached and the target process must be
-    suspended; otherwise, returns 0. Returns list of the full path
-    names of all of the loaded modules (including the executable
-    image) in the target process, as well as the base address at which
-    each module was relocated. See proclist for format of strings, but
-    NOTE that charSize is ALWAYS 1 for this particular routine,
-    regardless of the setting of ASCII/UNICODE.
-
-peek <address addr> <unsigned int numBytes> <EOL> ::=
-     B<binary char success>
-      [<binary unsigned int len> <binary char isMapped> [<binary char data>]...]...
-
-    NOTE that the binary portion of this message is prefixed by the
-    uppercase US-ASCII letter 'B', allowing easier synchronization by
-    clients. There is no data between the 'B' and the rest of the
-    message.
-
-    May only be called once attached. Reads the address space of the
-    target process starting at the given address (see below for format
-    specifications) and extending the given number of bytes. Whether
-    the read succeeded is indicated by a single byte containing a 1 or
-    0 (success or failure). If successful, the return result is given
-    in a sequence of ranges. _len_, the length of each range, is
-    indicated by a 32-bit unsigned integer transmitted with big-endian
-    byte ordering (i.e., most significant byte first).  _isMapped_
-    indicates whether the range is mapped or unmapped in the target
-    process's address space, and will contain the value 1 or 0 for
-    mapped or unmapped, respectively. If the range is mapped,
-    _isMapped_ is followed by _data_, containing the raw binary data
-    for the range. The sum of all ranges' lengths is guaranteed to be
-    equivalent to the number of bytes requested.
-
-poke <address addr> |[<binary unsigned int len> [<binary char data>]] <EOL> ::=
-     <bool result> <EOL>
-
-    NOTE that the binary portion of this message is prefixed by the
-    uppercase US-ASCII character '|' (vertical bar), allowing easier
-    synchronization by the server. There is no data between the '|'
-    and the rest of the message. ('B' is not used here because
-    addresses can contain that letter; no alphanumeric characters are
-    used because some of the parsing routines are used by the Solaris
-    SA port, and in that port any alphanumeric character can show up
-    as a part of a symbol being looked up.)
-
-    May only be called once attached. Writes the address space of the
-    target process starting at the given address (see below for format
-    specifications), extending the given number of bytes, and
-    containing the given data. The number of bytes is a 32-bit
-    unsigned integer transmitted with big-endian byte ordering (i.e.,
-    most significant byte first). This is followed by the raw binary
-    data to be placed at that address. The number of bytes of data
-    must match the number of bytes specified in the message.
-
-    Returns true if the write succeeded; false if it failed, for
-    example because a portion of the region was not mapped in the
-    target address space.
-
-threadlist <EOL>            ::= <int numThreads> [<address threadHandle>...] <EOL>
-
-    May only be called once attached and the target process must be
-    suspended; otherwise, returns 0. If available, returns handles for
-    all of the threads in the target process. These handles may be
-    used as arguments to the getcontext and selectorentry
-    commands. They do not need to be (and should not be) duplicated
-    via the duphandle command and must not be closed via the
-    closehandle command.
-
-duphandle <address handle> <EOL> ::=
-    <bool success> [<address duplicate>] <EOL>
-
-    Duplicates a HANDLE read from the target process's address space.
-    HANDLE is a Windows construct (typically typedef'd to void *).
-    The returned handle should ultimately be closed via the
-    closehandle command; failing to do so can cause resource leaks.
-
-    The purpose of this command is to allow the debugger to read the
-    value of a thread handle from the target process and query its
-    register set and thread selector entries via the getcontext and
-    selectorentry commands, below; such use implies that the target
-    program has its own notion of the thread list, and further, that
-    the debugger has a way of locating that thread list.
-
-closehandle <address handle> <EOL> ::=
-
-    Closes a handle retrieved via the duphandle command, above.
-
-getcontext <address threadHandle> <EOL> ::= <bool success> [<context>] <EOL>
-    
-    Returns the context for the given thread. The handle must either
-    be one of the handles returned from the threadlist command or the
-    result of duplicating a thread handle out of the target process
-    via the duphandle command. The target process must be suspended.
-
-    The context is returned as a series of hex values which represent
-    the following x86 registers in the following order:
-      EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIP, DS, ES, FS, GS,
-      CS, SS, EFLAGS, DR0, DR1, DR2, DR3, DR6, DR7
-
-    FIXME: needs to be generalized and/or specified for other
-    architectures.
-
-setcontext <address threadHandle> <context> ::= <bool success> <EOL>
-
-    Sets the context of the given thread. The target process must be
-    suspended. See the getcontext command for the ordering of the
-    registers in the context.
-
-    Even if the setcontext command succeeds, some of the bits in some
-    of the registers (like the global enable bits in the debug
-    registers) may be overridden by the operating system. To ensure
-    the debugger's notion of the register set is up to date, it is
-    recommended to follow up a setcontext with a getcontext.
-
-selectorentry <address threadHandle> <int selector> <EOL> ::=
-    <bool success>
-    [<address limitLow> <address baseLow>
-     <address baseMid>  <address flags1>
-     <address flags2>   <address baseHi>] <EOL>
-
-    Retrieves a descriptor table entry for the given thread and
-    selector. This data structure allows conversion of a
-    segment-relative address to a linear virtual address. It is most
-    useful for locating the Thread Information Block for a given
-    thread handle to be able to find that thread's ID, to be able to
-    understand whether two different thread handles in fact refer to
-    the same underlying thread.
-
-    This command will only work on the X86 architecture and will
-    return false for the success flag (with no additional information
-    sent) on other architectures.
-
-suspend                     ::=
-
-    Suspends the target process. Must be attached to a target process.
-    A process is suspended when attached to via the attach command. If
-    the target process is already suspended then this command has no
-    effect.
-
-resume                      ::=
-
-    Resumes the target process without detaching from it. Must be
-    attached to a target process. After resuming a target process, the
-    debugger client must be prepared to poll for events from the
-    target process fairly frequently in order for execution in the
-    target process to proceed normally. If the target process is
-    already resumed then this command has no effect.
-
-pollevent                   ::=
-    <bool eventPresent> [<address threadHandle> <unsigned int eventCode>]
-
-  Additional entries in result for given eventCode:
-
-    LOAD/UNLOAD_DLL_DEBUG_EVENT: <address baseOfDLL>
-    EXCEPTION_DEBUG_EVENT:       <unsigned int exceptionCode> <address faultingPC>
-
-      Additional entries for given exceptionCode:
-
-         EXCEPTION_ACCESS_VIOLATION: <bool wasWrite> <address faultingAddress>
-
-    <EOL>
-
-    Polls once to see whether a debug event has been generated by the
-    target process. If none is present, returns 0 immediately.
-    Otherwise, returns 1 along with a series of textual information
-    about the event. The event is not cleared, and the thread resumed,
-    until the continueevent command is sent, or the debugger client
-    detaches from the target process.
-
-    Typically a debugger client will suspend the target process upon
-    reception of a debug event. Otherwise, it is not guaranteed that
-    all threads will be suspended upon reception of a debug event, and
-    any operations requiring that threads be suspended (including
-    fetching the context for the thread which generated the event)
-    will fail.
-
-continueevent <bool passEventToClient> ::= <bool success> <EOL>
-
-    Indicates that the current debug event has been used by the
-    debugger client and that the target process should be resumed. The
-    passEventToClient flag indicates whether the event should be
-    propagated to the target process. Breakpoint and single-step
-    events should not be propagated to the target. Returns false if
-    there was no pending event, true otherwise.
-
-exit <EOL>
-
-    Exits this debugger session.
-
-Format specifications:
-
-// Data formats and example values:
-<EOL>          ::=   end of line (typically \n on Unix platforms, or \n\r on Windows)
-<address>      ::=   0x12345678[9ABCDEF0] /* up to 64-bit hex value */
-<unsigned int> ::=   5                    /* up to 32-bit integer number; no leading sign */
-<bool>         ::=   1                    /* ASCII '0' or '1' */
-<context>      ::=   <address> ...
--- a/hotspot/agent/src/os/win32/README.txt	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-This is a "Simple Windows Debug Server" written for the purpose of
-enabling the Serviceability Agent on Win32. It has backends both for
-Windows NT 4.0 (using internal Windows APIs for a few routines) as
-well as for 95/98/ME/2000 via the Tool Help APIs.
-
-The reason this debug server is necessary is that the Win32 debug APIs
-by design tear down the target process when the debugger exits (see
-knowledge base article Q164205 on msdn.microsoft.com). On Solaris, one
-can attach to and detach from a process with no effect; this is key to
-allowing dbx and gcore to work.
-
-The Simple Windows Debug Server effectively implements attach/detach
-functionality for arbitrary debug clients. This allows the SA to
-attach non-destructively to a process, and will enable gcore for Win32
-to be written shortly. While the debugger (the "client" in all of the
-source code) is attached, the target process is suspended. (Note that
-the debug server could be extended to support resumption of the target
-process and transmission of debug events over to the debugger, but
-this has been left for the future.)
-
-The makefile (type "nmake") builds two executables: SwDbgSrv.exe,
-which is the server process, and SwDbgSub.exe, which is forked by the
-server and should not be directly invoked by the user.
-
-The intent is that these two executables can be installed into
-C:\WINNT\SYSTEM32 and SwDbgSrv installed to run as a service (on NT),
-for example using ServiceInstaller (http://www.kcmultimedia.com/smaster/). 
-However, SwDbgSrv can also be run from the command line. It generates
-no text output unless the source code is changed to enable debugging
-printouts. As long as any processes which have been attached to by the
-SA are alive, the SwDbgSrv and any forked SwDbgSub processes must be
-left running. Terminating them will cause termination of the target
-processes.
-
-The debug server opens port 27000 and accepts incoming connections
-from localhost only. The security model assumes that if one can run a
-process on the given machine then one basically has access to most or
-all of the machine's facilities; this seems to be in line with the
-standard Windows security model. The protocol used is text-based, so
-one can debug the debug server using telnet. See README-commands.txt
-for documentation on the supported commands.
-
-Testing indicates that the performance impact of attaching to a
-process (and therefore permanently attaching a debugger) is minimal.
-Some serious performance problems had been seen which ultimately
-appeared to be a lack of physical memory on the machine running the
-system.
-
-Bugs:
-
-This debug server is fundamentally incompatible with the Visual C++
-debugger. Once the debug server is used to attach to a process, the
-Visual C++ IDE will not be able to attach to the same process (even if
-the debug server is "detached" from that process). Note that this
-system is designed to work with the same primitives that C and C++
-debuggers use (like "symbol lookup" and "read from process memory")
-and exposes these primitives to Java, so in the long term we could
-solve this problem by implementing platform-specific debug symbol
-parsing and a platform-independent C++ debugger in Java.
-
-Note:
-
-The files IOBuf.cpp and IOBuf.hpp are also used in 
-building src/os/solaris/agent.
--- a/hotspot/agent/src/os/win32/Reaper.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +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.
- *
- */
-
-#include <iostream>
-#include "Reaper.hpp"
-
-using namespace std;
-
-Reaper::Reaper(ReaperCB* cb) {
-  InitializeCriticalSection(&crit);
-  event = CreateEvent(NULL, TRUE, FALSE, NULL);
-  this->cb = cb;
-
-  active = false;
-  shouldShutDown = false;
-}
-
-bool
-Reaper::start() {
-  bool result = false;
-
-  EnterCriticalSection(&crit);
-
-  if (!active) {
-    DWORD id;
-    HANDLE reaper = CreateThread(NULL, 0, &Reaper::reaperThreadEntry,
-                                 this, 0, &id);
-    if (reaper != NULL) {
-      result = true;
-    }
-  }
-
-  LeaveCriticalSection(&crit);
-
-  return result;
-}
-
-bool
-Reaper::stop() {
-  bool result = false;
-
-  EnterCriticalSection(&crit);
-
-  if (active) {
-    shouldShutDown = true;
-    SetEvent(event);
-    while (active) {
-      Sleep(1);
-    }
-    shouldShutDown = false;
-    result = true;
-  }
-
-  LeaveCriticalSection(&crit);
-
-  return result;
-}
-
-void
-Reaper::registerProcess(HANDLE processHandle, void* userData) {
-  ProcessInfo info;
-
-  info.handle = processHandle;
-  info.userData = userData;
-
-  EnterCriticalSection(&crit);
-
-  procInfo.push_back(info);
-  SetEvent(event);
-
-  LeaveCriticalSection(&crit);
-}
-
-void
-Reaper::reaperThread() {
-  while (!shouldShutDown) {
-    // Take atomic snapshot of the current process list and user data
-    EnterCriticalSection(&crit);
-
-    int num = procInfo.size();
-    HANDLE* handleList = new HANDLE[1 + num];
-    void**  dataList   = new void*[num];
-    for (int i = 0; i < num; i++) {
-      handleList[i] = procInfo[i].handle;
-      dataList[i]   = procInfo[i].userData;
-    }
-
-    LeaveCriticalSection(&crit);
-
-    // Topmost handle becomes the event object, so other threads can
-    // signal this one to notice differences in the above list (or
-    // shut down)
-    handleList[num] = event;
-
-    // Wait for these objects
-    DWORD idx = WaitForMultipleObjects(1 + num, handleList,
-                                       FALSE, INFINITE);
-    if ((idx >= WAIT_OBJECT_0) && (idx <= WAIT_OBJECT_0 + num)) {
-      idx -= WAIT_OBJECT_0;
-      if (idx < num) {
-        // A process exited (i.e., it wasn't that we were woken up
-        // just because the event went off)
-        (*cb)(dataList[idx]);
-        // Remove this process from the list (NOTE: requires that
-        // ordering does not change, i.e., that all additions are to
-        // the back of the process list)
-        EnterCriticalSection(&crit);
-
-        std::vector<ProcessInfo>::iterator iter = procInfo.begin();
-        iter += idx;
-        procInfo.erase(iter);
-
-        LeaveCriticalSection(&crit);
-      } else {
-        // Notification from other thread
-        ResetEvent(event);
-      }
-    } else {
-      // Unexpected return value. For now, warn.
-      cerr << "Reaper::reaperThread(): unexpected return value "
-           << idx << " from WaitForMultipleObjects" << endl;
-    }
-
-    // Clean up these lists
-    delete[] handleList;
-    delete[] dataList;
-  }
-
-  // Time to shut down
-  active = false;
-}
-
-DWORD WINAPI
-Reaper::reaperThreadEntry(LPVOID data) {
-  Reaper* reaper = (Reaper*) data;
-  reaper->reaperThread();
-  return 0;
-}
--- a/hotspot/agent/src/os/win32/Reaper.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +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.
- *
- */
-
-#ifndef _REAPER_
-#define _REAPER_
-
-#include <vector>
-#include <windows.h>
-
-typedef void ReaperCB(void* userData);
-
-/** A Reaper maintains a thread which waits for child processes to
-    terminate; upon termination it calls a user-specified ReaperCB to
-    clean up resources associated with those child processes. */
-
-class Reaper {
-private:
-  Reaper& operator=(const Reaper&);
-  Reaper(const Reaper&);
-
-public:
-  Reaper(ReaperCB*);
-  ~Reaper();
-
-  // Start the reaper thread.
-  bool start();
-
-  // Stop the reaper thread. This is called automatically in the
-  // reaper's destructor. It is not thread safe and should be called
-  // by at most one thread at a time.
-  bool stop();
-
-  // Register a given child process with the reaper. This should be
-  // called by the application's main thread. When that process
-  // terminates, the cleanup callback will be called with the
-  // specified userData in the context of the reaper thread. Callbacks
-  // are guaranteed to be called serially, so they can safely refer to
-  // static data as well as the given user data.
-  void registerProcess(HANDLE processHandle, void* userData);
-
-private:
-  // For thread safety of register()
-  CRITICAL_SECTION crit;
-
-  ReaperCB* cb;
-
-  // State variables
-  volatile bool active;
-  volatile bool shouldShutDown;
-
-  struct ProcessInfo {
-    HANDLE handle;
-    void* userData;
-  };
-
-  // Bookkeeping
-  std::vector<ProcessInfo> procInfo;
-
-  // Synchronization between application thread and reaper thread
-  HANDLE event;
-
-  // Entry point for reaper thread
-  void reaperThread();
-
-  // Static function which is actual thread entry point
-  static DWORD WINAPI reaperThreadEntry(LPVOID data);
-};
-
-#endif  // #defined _REAPER_
--- a/hotspot/agent/src/os/win32/SwDbgSrv.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1266 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * 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.
- *
- */
-
-// A Simple Windows Debug Server.
-//
-// This software provides a socket-based debug server which uses
-// mostly ASCII protocols to communicate with its clients. Since the
-// Windows security model is largely based around being able to run
-// programs on the machine, this server only accepts connections
-// coming from localhost.
-//
-// When run as a service (under Windows NT), this software provides
-// clients the ability to attach to and detach from processes without
-// killing those processes. Ordinarily this is forbidden by the
-// Windows debugging APIs (although more recent debugging environments
-// from Microsoft seem to have circumvented this restriction, perhaps
-// in a different way). This is achieved by forking a persistent
-// subprocess for each debugging session which remains alive as long
-// as the target process is.
-//
-// At this point the client can read information out of the target
-// process's address space. Future work includes exposing more
-// functionality like writing to the remote address space and
-// suspending and resuming threads.
-
-#include <iostream>
-#include <vector>
-#include <stdlib.h>
-// Must come before everything else
-#include <winsock2.h>
-#include <assert.h>
-#include "Dispatcher.hpp"
-#include "Handler.hpp"
-#include "initWinsock.hpp"
-#include "ioUtils.hpp"
-#include "isNT4.hpp"
-#include "Message.hpp"
-#include "nt4internals.hpp"
-#include "ports.h"
-#include "procList.hpp"
-#include "serverLists.hpp"
-#include "Reaper.hpp"
-
-// Uncomment the #define below to get messages on stderr
-// #define DEBUGGING
-
-using namespace std;
-
-static ChildList childList;
-static ClientList clientList;
-static Reaper* reaper = NULL;
-
-// Needed prototypes
-void shutdownChild(ChildInfo* childInfo);
-void detachClient(ClientInfo* clientInfo);
-void shutdownClient(ClientInfo* clientInfo);
-
-char *
-longToDotFormat(long addr)
-{
-  char *temp_s = new char[20];
-
-  sprintf(temp_s, "%d.%d.%d.%d", ((addr & 0xff000000) >> 24),
-          ((addr & 0x00ff0000) >> 16), ((addr & 0x0000ff00) >> 8),
-          (addr & 0x000000ff));
-
-  return temp_s;
-}
-
-// NOTE that we do this query every time. It is a bad idea to cache IP
-// addresses. For example, we might be hosted on a machine using DHCP
-// and the connection addresses might change over time. (Yes, this
-// actually happened.)
-bool
-isConnectionOkay(ULONG connAddr) {
-  if (connAddr == INADDR_LOOPBACK) {
-    return true;
-  }
-
-  const int MAXNAME = 1024;
-  char myname[MAXNAME];
-  gethostname(myname, MAXNAME);
-  struct hostent* myInfo = gethostbyname(myname);
-  if (myInfo == NULL) {
-#ifdef DEBUGGING
-    cerr << "My host information was null" << endl;
-#endif
-  } else {
-    // Run down the list of IP addresses for myself
-    assert(myInfo->h_length == sizeof(ULONG));
-#ifdef DEBUGGING
-    cerr << "My known IP addresses: " << endl;
-#endif
-    for (char** pp = myInfo->h_addr_list; *pp != NULL; pp++) {
-      char* p = *pp;
-      ULONG altAddr = ntohl(*((ULONG*) p));
-#ifdef DEBUGGING
-      char* name = longToDotFormat(altAddr);
-      cerr << name << endl;
-      delete[] name;
-#endif
-      if (altAddr == connAddr) {
-#ifdef DEBUGGING
-        cerr << "FOUND" << endl;
-#endif
-        return true;
-      }
-    }
-#ifdef DEBUGGING
-    cerr << "Done." << endl;
-#endif
-  }
-
-  return false;
-}
-
-SOCKET
-setupListeningSocket(short port) {
-  SOCKET listening = socket(AF_INET, SOCK_STREAM, 0);
-  if (listening == INVALID_SOCKET) {
-    cerr << "Error creating listening socket" << endl;
-    exit(1);
-  }
-
-  int reuseAddress = 1;
-  if (setsockopt(listening, SOL_SOCKET, SO_REUSEADDR,
-                 (char *)&reuseAddress, sizeof(reuseAddress)) == -1) {
-    cerr << "Error reusing address" << endl;
-    exit(1);
-  }
-
-  struct sockaddr_in serverInfo;
-
-  memset((char *)&serverInfo, 0, sizeof(serverInfo));
-  serverInfo.sin_addr.s_addr = INADDR_ANY;
-  serverInfo.sin_family = AF_INET;
-  serverInfo.sin_port = htons(port);
-
-  if (bind(listening, (struct sockaddr *) &serverInfo, sizeof(serverInfo)) < 0) {
-    cerr << "Error binding socket" << endl;
-    exit(1);
-  }
-
-  if (listen(listening, 5) < 0) {
-    cerr << "Error listening" << endl;
-    exit(1);
-  }
-
-  return listening;
-}
-
-/** Accepts a connection from the given listening socket, but only if
-    the connection came from localhost. Returns INVALID_SOCKET if the
-    connection came from any other IP address or if an error occurred
-    during the call to accept(). */
-SOCKET
-acceptFromLocalhost(SOCKET listening) {
-  struct sockaddr_in peerAddr;
-  int peerAddrLen = sizeof(peerAddr);
-  SOCKET fd = accept(listening, (sockaddr*) &peerAddr, &peerAddrLen);
-  if (fd == INVALID_SOCKET) {
-    return fd;
-  }
-
-  if (!isConnectionOkay(ntohl(peerAddr.sin_addr.s_addr))) {
-    // Reject connections from other machines for security purposes.
-    // The Windows security model seems to assume one user per
-    // machine, and that security is compromised if another user is
-    // able to run executables on the given host. (If these
-    // assumptions are not strict enough, we will have to change
-    // this.)
-    shutdown(fd, SD_BOTH);
-    closesocket(fd);
-    return INVALID_SOCKET;
-  }
-
-  // Disable TCP buffering on all sockets. We send small amounts of
-  // data back and forth and don't want buffering.
-  int buffer_val = 1;
-  if (setsockopt(fd, IPPROTO_IP, TCP_NODELAY,
-                 (char *) &buffer_val, sizeof(buffer_val)) < 0) {
-    shutdown(fd, SD_BOTH);
-    closesocket(fd);
-  }
-
-  return fd;
-}
-
-void
-reapCB(void* arg) {
-  ChildInfo* info = (ChildInfo*) arg;
-  ListsLocker ll;
-  DWORD pid = info->getPid();
-  shutdownChild(info);
-#ifdef DEBUGGING
-  cerr << "Reaped child for process " << pid << endl;
-#endif
-}
-
-/** Starts a child process with stdin and stdout redirected to pipes,
-    handles to which are returned. auxHandle1 and auxHandle2 should be
-    closed as well when the child process exits. Returns false if
-    process creation failed. */
-bool
-startChildProcess(DWORD pidToDebug,
-                  DWORD childStdinBufSize,
-                  DWORD childStdoutBufSize,
-                  LPHANDLE childProcessHandle,
-                  LPHANDLE writeToStdinHandle,
-                  LPHANDLE readFromStdoutHandle,
-                  LPHANDLE auxHandle1,
-                  LPHANDLE auxHandle2) {
-  // Code adapted from Microsoft example
-  // "Creating a Child Process with Redirected Input and Output"
-
-  SECURITY_ATTRIBUTES saAttr;
-  BOOL fSuccess;
-
-  HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup,
-    hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup,
-    hSaveStdin, hSaveStdout;
-
-  // Set the bInheritHandle flag so pipe handles are inherited.
-  saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
-  saAttr.bInheritHandle = TRUE;
-  saAttr.lpSecurityDescriptor = NULL;
-
-  // The steps for redirecting child process's STDOUT:
-  //   1. Save current STDOUT, to be restored later.
-  //   2. Create anonymous pipe to be STDOUT for child process.
-  //   3. Set STDOUT of the parent process to be write handle to
-  //      the pipe, so it is inherited by the child process.
-  //   4. Create a noninheritable duplicate of the read handle and
-  //      close the inheritable read handle.
-
-  // Save the handle to the current STDOUT.
-  hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE);
-  // Create a pipe for the child process's STDOUT.
-  if (! CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, childStdoutBufSize)) {
-    return false;
-  }
-  // Set a write handle to the pipe to be STDOUT.
-  if (! SetStdHandle(STD_OUTPUT_HANDLE, hChildStdoutWr)) {
-    return false;
-  }
-  // Create noninheritable read handle and close the inheritable read
-  // handle.
-  fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd,
-                             GetCurrentProcess(), &hChildStdoutRdDup,
-                             0, FALSE,
-                             DUPLICATE_SAME_ACCESS);
-  if( !fSuccess ) {
-    return false;
-  }
-  CloseHandle(hChildStdoutRd);
-
-  // The steps for redirecting child process's STDIN:
-  //   1.  Save current STDIN, to be restored later.
-  //   2.  Create anonymous pipe to be STDIN for child process.
-  //   3.  Set STDIN of the parent to be the read handle to the
-  //       pipe, so it is inherited by the child process.
-  //   4.  Create a noninheritable duplicate of the write handle,
-  //       and close the inheritable write handle.
-  // Save the handle to the current STDIN.
-  hSaveStdin = GetStdHandle(STD_INPUT_HANDLE);
-  // Create a pipe for the child process's STDIN.
-  if (! CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, childStdinBufSize)) {
-    return false;
-  }
-  // Set a read handle to the pipe to be STDIN.
-  if (! SetStdHandle(STD_INPUT_HANDLE, hChildStdinRd)) {
-    return false;
-  }
-  // Duplicate the write handle to the pipe so it is not inherited.
-  fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdinWr,
-                             GetCurrentProcess(), &hChildStdinWrDup, 0,
-                             FALSE,                  // not inherited
-                             DUPLICATE_SAME_ACCESS);
-  if (! fSuccess) {
-    return false;
-  }
-  CloseHandle(hChildStdinWr);
-
-  // Create the child process
-  char cmdLine[256];
-  sprintf(cmdLine, "SwDbgSub.exe %u", pidToDebug);
-  PROCESS_INFORMATION procInfo;
-  STARTUPINFO startInfo;
-  memset((char*) &startInfo, 0, sizeof(startInfo));
-  startInfo.cb = sizeof(startInfo);
-  BOOL res = CreateProcess(NULL,
-                           cmdLine,
-                           NULL,
-                           NULL,
-                           TRUE, // inherit handles: important
-                           0,
-                           NULL,
-                           NULL,
-                           &startInfo,
-                           &procInfo);
-  if (!res) {
-    return false;
-  }
-  // After process creation, restore the saved STDIN and STDOUT.
-  if (! SetStdHandle(STD_INPUT_HANDLE, hSaveStdin)) {
-    return false;
-  }
-  if (! SetStdHandle(STD_OUTPUT_HANDLE, hSaveStdout)) {
-    return false;
-  }
-
-  // hChildStdinWrDup can be used to write to the child's stdin
-  // hChildStdoutRdDup can be used to read from the child's stdout
-
-  // NOTE: example code closes hChildStdoutWr before reading from
-  // hChildStdoutRdDup. "Close the write end of the pipe before
-  // reading from the read end of the pipe"??? Looks like this is
-  // example-specific.
-
-  // Set up return arguments
-  // hChildStdoutRd and hChildStdinWr are already closed at this point
-  *childProcessHandle = procInfo.hProcess;
-  *writeToStdinHandle = hChildStdinWrDup;
-  *readFromStdoutHandle = hChildStdoutRdDup;
-  *auxHandle1 = hChildStdinRd;
-  *auxHandle2 = hChildStdoutWr;
-  return true;
-}
-
-/** Clears the event and writes the message to the child process */
-bool
-sendMessage(ChildInfo* child, Message* message) {
-  DWORD numBytesWritten;
-  if (!WriteFile(child->getWriteToStdinHandle(),
-                 message, sizeof(Message), &numBytesWritten, NULL)) {
-    return false;
-  }
-  if (numBytesWritten != sizeof(Message)) {
-    return false;
-  }
-  // Follow up "poke" messages with the raw data
-  if (message->type == Message::POKE) {
-    if (!WriteFile(child->getWriteToStdinHandle(),
-                   message->pokeArg.data, message->pokeArg.numBytes, &numBytesWritten, NULL)) {
-      return false;
-    }
-    if (numBytesWritten != message->pokeArg.numBytes) {
-      return false;
-    }
-  }
-  return true;
-}
-
-/** Copies data from child's stdout to the client's IOBuf and sends it
-    along */
-bool
-forwardReplyToClient(ChildInfo* child, ClientInfo* client) {
-  DWORD total = 0;
-  IOBuf::FillState ret;
-
-  do {
-    DWORD temp;
-    ret = client->getIOBuf()->fillFromFileHandle(child->getReadFromStdoutHandle(),
-                                                 &temp);
-    if (ret == IOBuf::DONE || ret == IOBuf::MORE_DATA_PENDING) {
-      if (!client->getIOBuf()->flush()) {
-#ifdef DEBUGGING
-        cerr << "Forward failed because flush failed" << endl;
-#endif
-        return false;
-      }
-      total += temp;
-    }
-  } while (ret == IOBuf::MORE_DATA_PENDING);
-
-  return (ret == IOBuf::FAILED) ? false : true;
-}
-
-//----------------------------------------------------------------------
-// Server Handler
-//
-
-class ServerHandler : public Handler {
-public:
-  ServerHandler();
-
-  // Starts up in Unicode mode by default
-  bool getASCII();
-
-  void setIOBuf(IOBuf* ioBuf);
-
-  void procList(char* arg);
-
-  // Must be called before calling one of the routines below
-  void setClientInfo(ClientInfo* info);
-
-  // Indicates to outer loop that exit was called or that an error
-  // occurred and that the client exited.
-  bool exited();
-  // Clears this state
-  void clearExited();
-
-  void ascii(char* arg);
-  void unicode(char* arg);
-  void attach(char* arg);
-  void detach(char* arg);
-  void libInfo(char* arg);
-  void peek(char* arg);
-  void poke(char* arg);
-  void threadList(char* arg);
-  void dupHandle(char* arg);
-  void closeHandle(char* arg);
-  void getContext(char* arg);
-  void setContext(char* arg);
-  void selectorEntry(char* arg);
-  void suspend(char* arg);
-  void resume(char* arg);
-  void pollEvent(char* arg);
-  void continueEvent(char* arg);
-  void exit(char* arg);
-
-  // This is pretty gross. Needed to make the target process know
-  // about clients that have disconnected unexpectedly while attached.
-  friend void shutdownClient(ClientInfo*);
-private:
-  // Writes: charSize <space> numChars <space> <binary string>
-  // Handles both ASCII and UNICODE modes
-  void writeString(USHORT len, WCHAR* str);
-
-  // Handles only ASCII mode
-  void writeString(USHORT len, char* str);
-
-  ClientInfo* clientInfo;
-  IOBuf* ioBuf;
-  bool _exited;
-  bool _ascii;
-};
-
-static ServerHandler* handler;
-
-ServerHandler::ServerHandler() {
-  _exited = false;
-  _ascii = false;
-  ioBuf = NULL;
-}
-
-bool
-ServerHandler::getASCII() {
-  return _ascii;
-}
-
-void
-ServerHandler::setIOBuf(IOBuf* buf) {
-  ioBuf = buf;
-}
-
-void
-ServerHandler::setClientInfo(ClientInfo* info) {
-  clientInfo = info;
-}
-
-bool
-ServerHandler::exited() {
-  return _exited;
-}
-
-void
-ServerHandler::clearExited() {
-  _exited = false;
-}
-
-void
-ServerHandler::ascii(char* arg) {
-  _ascii = true;
-}
-
-void
-ServerHandler::unicode(char* arg) {
-  _ascii = false;
-}
-
-void
-ServerHandler::procList(char* arg) {
-#ifdef DEBUGGING
-  cerr << "proclist" << endl;
-#endif
-
-  ProcEntryList processes;
-  ::procList(processes);
-
-  ioBuf->writeInt(processes.size());
-
-  for (ProcEntryList::iterator iter = processes.begin();
-       iter != processes.end(); iter++) {
-    ProcEntry& entry = *iter;
-    ioBuf->writeSpace();
-    ioBuf->writeUnsignedInt(entry.getPid());
-    ioBuf->writeSpace();
-    writeString(entry.getNameLength(), entry.getName());
-  }
-
-  ioBuf->writeEOL();
-  ioBuf->flush();
-}
-
-void
-ServerHandler::attach(char* arg) {
-  // If the client is already attached to a process, fail.
-  if (clientInfo->getTarget() != NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->writeEOL();
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get pid
-  DWORD pid;
-  if (!scanUnsignedLong(&arg, &pid)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->writeEOL();
-    ioBuf->flush();
-    return;
-  }
-
-  // See whether this pid is already forked
-  ListsLocker ll;
-  ChildInfo* childInfo = childList.getChildByPid(pid);
-  if (childInfo != NULL) {
-    // If this child already has a client, return false
-    if (childInfo->getClient() != NULL) {
-      ioBuf->writeBoolAsInt(false);
-      ioBuf->writeEOL();
-      ioBuf->flush();
-      return;
-    }
-
-    // Otherwise, can associate this client with this child process
-    childInfo->setClient(clientInfo);
-    clientInfo->setTarget(childInfo);
-
-    // Tell the child we are attaching so it can suspend the target
-    // process
-    Message msg;
-    msg.type = Message::ATTACH;
-    sendMessage(childInfo, &msg);
-
-    ioBuf->writeBoolAsInt(true);
-    ioBuf->writeEOL();
-    ioBuf->flush();
-    return;
-  } else {
-    // Have to fork a new child subprocess
-    HANDLE childProcessHandle;
-    HANDLE writeToStdinHandle;
-    HANDLE readFromStdoutHandle;
-    HANDLE auxHandle1;
-    HANDLE auxHandle2;
-    if (!startChildProcess(pid,
-                           32768,
-                           131072,
-                           &childProcessHandle,
-                           &writeToStdinHandle,
-                           &readFromStdoutHandle,
-                           &auxHandle1,
-                           &auxHandle2)) {
-      ioBuf->writeBoolAsInt(false);
-      ioBuf->writeEOL();
-      ioBuf->flush();
-      return;
-    }
-
-    // See whether the child succeeded in attaching to the process
-    char res;
-    DWORD numRead;
-    if (!ReadFile(readFromStdoutHandle,
-                  &res,
-                  sizeof(char),
-                  &numRead,
-                  NULL)) {
-      ioBuf->writeBoolAsInt(false);
-      ioBuf->writeEOL();
-      ioBuf->flush();
-      return;
-    }
-
-    if (!res) {
-      ioBuf->writeBoolAsInt(false);
-      ioBuf->writeEOL();
-      ioBuf->flush();
-      return;
-    }
-
-    // OK, success.
-    childInfo = new ChildInfo(pid, childProcessHandle,
-                              writeToStdinHandle, readFromStdoutHandle,
-                              auxHandle1, auxHandle2);
-    childList.addChild(childInfo);
-    reaper->registerProcess(childProcessHandle, childInfo);
-    // Associate this client with this child process
-    childInfo->setClient(clientInfo);
-    clientInfo->setTarget(childInfo);
-
-    // Tell the child process to actually suspend the target process
-    Message msg;
-    msg.type = Message::ATTACH;
-    sendMessage(childInfo, &msg);
-
-    // Write result to client
-    ioBuf->writeBoolAsInt(true);
-    ioBuf->writeEOL();
-    ioBuf->flush();
-    return;
-  }
-}
-
-void
-ServerHandler::detach(char* arg) {
-  // If the client is not attached, fail.
-  if (clientInfo->getTarget() == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->writeEOL();
-    ioBuf->flush();
-    return;
-  }
-
-  detachClient(clientInfo);
-
-  ioBuf->writeBoolAsInt(true);
-  ioBuf->writeEOL();
-  ioBuf->flush();
-}
-
-void
-ServerHandler::libInfo(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeInt(0);
-    ioBuf->writeEOL();
-    ioBuf->flush();
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::LIBINFO;
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::peek(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeString("B");
-    ioBuf->writeBinChar(0);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get address
-  DWORD address;
-  if (!scanAddress(&arg, &address)) {
-    ioBuf->writeString("B");
-    ioBuf->writeBinChar(0);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get number of bytes
-  DWORD numBytes;
-  if (!scanUnsignedLong(&arg, &numBytes)) {
-    ioBuf->writeString("B");
-    ioBuf->writeBinChar(0);
-    ioBuf->flush();
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::PEEK;
-  msg.peekArg.address = address;
-  msg.peekArg.numBytes = numBytes;
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::poke(char* arg) {
-#ifdef DEBUGGING
-  cerr << "ServerHandler::poke" << endl;
-#endif
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get address
-  DWORD address;
-  if (!scanAddress(&arg, &address)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get number of bytes
-  if (!scanAndSkipBinEscapeChar(&arg)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-  DWORD numBytes;
-  if (!scanBinUnsignedLong(&arg, &numBytes)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Raw data is now in "arg"
-  // Send message to child
-  Message msg;
-  msg.type = Message::POKE;
-  msg.pokeArg.address = address;
-  msg.pokeArg.numBytes = numBytes;
-  msg.pokeArg.data = arg;
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::threadList(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::THREADLIST;
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::dupHandle(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get handle
-  DWORD address;
-  if (!scanAddress(&arg, &address)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::DUPHANDLE;
-  msg.handleArg.handle = (HANDLE) address;
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::closeHandle(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    return;
-  }
-
-  // Try to get handle
-  DWORD address;
-  if (!scanAddress(&arg, &address)) {
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::CLOSEHANDLE;
-  msg.handleArg.handle = (HANDLE) address;
-  sendMessage(child, &msg);
-
-  // No reply
-}
-
-void
-ServerHandler::getContext(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get handle
-  DWORD address;
-  if (!scanAddress(&arg, &address)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::GETCONTEXT;
-  msg.handleArg.handle = (HANDLE) address;
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::setContext(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get handle
-  DWORD address;
-  if (!scanAddress(&arg, &address)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get context
-  DWORD regs[NUM_REGS_IN_CONTEXT];
-  for (int i = 0; i < NUM_REGS_IN_CONTEXT; i++) {
-    if (!scanAddress(&arg, &regs[i])) {
-      ioBuf->writeBoolAsInt(false);
-      ioBuf->flush();
-      return;
-    }
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::SETCONTEXT;
-  msg.setContextArg.handle = (HANDLE) address;
-  msg.setContextArg.Eax    = regs[0];
-  msg.setContextArg.Ebx    = regs[1];
-  msg.setContextArg.Ecx    = regs[2];
-  msg.setContextArg.Edx    = regs[3];
-  msg.setContextArg.Esi    = regs[4];
-  msg.setContextArg.Edi    = regs[5];
-  msg.setContextArg.Ebp    = regs[6];
-  msg.setContextArg.Esp    = regs[7];
-  msg.setContextArg.Eip    = regs[8];
-  msg.setContextArg.Ds     = regs[9];
-  msg.setContextArg.Es     = regs[10];
-  msg.setContextArg.Fs     = regs[11];
-  msg.setContextArg.Gs     = regs[12];
-  msg.setContextArg.Cs     = regs[13];
-  msg.setContextArg.Ss     = regs[14];
-  msg.setContextArg.EFlags = regs[15];
-  msg.setContextArg.Dr0    = regs[16];
-  msg.setContextArg.Dr1    = regs[17];
-  msg.setContextArg.Dr2    = regs[18];
-  msg.setContextArg.Dr3    = regs[19];
-  msg.setContextArg.Dr6    = regs[20];
-  msg.setContextArg.Dr7    = regs[21];
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::selectorEntry(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get thread handle
-  DWORD address;
-  if (!scanAddress(&arg, &address)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get selector
-  DWORD selector;
-  if (!scanUnsignedLong(&arg, &selector)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::SELECTORENTRY;
-  msg.selectorArg.handle   = (HANDLE) address;
-  msg.selectorArg.selector = selector;
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::suspend(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::SUSPEND;
-  sendMessage(child, &msg);
-
-  // No reply
-}
-
-void
-ServerHandler::resume(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::RESUME;
-  sendMessage(child, &msg);
-
-  // No reply
-}
-
-void
-ServerHandler::pollEvent(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::POLLEVENT;
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::continueEvent(char* arg) {
-  ListsLocker ll;
-  ChildInfo* child = clientInfo->getTarget();
-  if (child == NULL) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Try to get bool arg
-  int passEventToClient;
-  if (!scanInt(&arg, &passEventToClient)) {
-    ioBuf->writeBoolAsInt(false);
-    ioBuf->flush();
-    return;
-  }
-
-  // Send message to child
-  Message msg;
-  msg.type = Message::CONTINUEEVENT;
-  msg.boolArg.val = ((passEventToClient != 0) ? true : false);
-  sendMessage(child, &msg);
-
-  // Forward reply to client
-  forwardReplyToClient(child, clientInfo);
-}
-
-void
-ServerHandler::exit(char* arg) {
-  shutdownClient(clientInfo);
-  _exited = true;
-}
-
-void
-ServerHandler::writeString(USHORT len, WCHAR* str) {
-  if (_ascii) {
-    char* cStr = new char[len + 1];
-    sprintf(cStr, "%.*ls", len, str);
-    writeString(len, cStr);
-    delete[] cStr;
-  } else {
-    ioBuf->writeInt(sizeof(unsigned short));
-    ioBuf->writeSpace();
-    ioBuf->writeInt(len);
-    ioBuf->writeSpace();
-    for (int i = 0; i < len; i++) {
-      ioBuf->writeBinUnsignedShort(str[i]);
-    }
-  }
-}
-
-void
-ServerHandler::writeString(USHORT len, char* str) {
-  ioBuf->writeInt(1);
-  ioBuf->writeSpace();
-  ioBuf->writeInt(len);
-  ioBuf->writeSpace();
-  ioBuf->writeString(str);
-}
-
-//
-//----------------------------------------------------------------------
-
-//----------------------------------------------------------------------
-// Shutdown routines
-//
-
-void
-shutdownChild(ChildInfo* childInfo) {
-  childList.removeChild(childInfo);
-  childInfo->closeAll();
-  if (childInfo->getClient() != NULL) {
-    shutdownClient(childInfo->getClient());
-  }
-  delete childInfo;
-}
-
-void
-detachClient(ClientInfo* info) {
-  ListsLocker ll;
-  // May have been dissociated while not under cover of lock
-  if (info->getTarget() == NULL) {
-    return;
-  }
-
-  // Tell the child that we have detached to let the target process
-  // continue running
-  Message msg;
-  msg.type = Message::DETACH;
-  sendMessage(info->getTarget(), &msg);
-
-  // Dissociate the client and the target
-  info->getTarget()->setClient(NULL);
-  info->setTarget(NULL);
-}
-
-void
-shutdownClient(ClientInfo* clientInfo) {
-#ifdef DEBUGGING
-  cerr << "Shutting down client" << endl;
-#endif
-
-  // If we're connected, inform the target process that we're
-  // disconnecting
-  detachClient(clientInfo);
-
-  // Remove this client from the list and delete it
-  clientList.removeClient(clientInfo);
-  if (clientInfo->getTarget() != NULL) {
-    clientInfo->getTarget()->setClient(NULL);
-  }
-  clientInfo->closeAll();
-  delete clientInfo;
-}
-
-//
-//----------------------------------------------------------------------
-
-
-/** Main dispatcher for client commands. NOTE: do not refer to this
-    clientInfo data structure after calling this routine, as it may be
-    deleted internally. */
-void
-readAndDispatch(ClientInfo* clientInfo) {
-  IOBuf::ReadLineResult res;
-  IOBuf* ioBuf = clientInfo->getIOBuf();
-  unsigned long howMany;
-  ioctlsocket(clientInfo->getDataSocket(), FIONREAD, &howMany);
-  if (howMany == 0) {
-    // Client closed down.
-    shutdownClient(clientInfo);
-    return;
-  }
-  // Read and process as much data as possible
-  do {
-    res = ioBuf->tryReadLine();
-    if (res == IOBuf::RL_ERROR) {
-#ifdef DEBUGGING
-      cerr << "Error while reading line" << endl;
-#endif
-      shutdownClient(clientInfo);
-      return;
-    } else if (res == IOBuf::RL_GOT_DATA) {
-#ifdef DEBUGGING
-      cerr << "Got data: \"" << ioBuf->getLine() << "\"" << endl;
-#endif
-      handler->setIOBuf(ioBuf);
-      handler->setClientInfo(clientInfo);
-      handler->clearExited();
-      Dispatcher::dispatch(ioBuf->getLine(), handler);
-    }
-  } while (res == IOBuf::RL_GOT_DATA && (!handler->exited()));
-#ifdef DEBUGGING
-  cerr << "Exiting readAndDispatch" << endl;
-#endif
-}
-
-int
-main(int argc, char **argv)
-{
-  initWinsock();
-
-  if (isNT4()) {
-    loadPSAPIDLL(); // Will exit if not present
-  }
-
-  SOCKET clientListeningSock = setupListeningSocket(CLIENT_PORT);
-
-  handler = new ServerHandler();
-  Lists::init();
-
-  reaper = new Reaper(&reapCB);
-  if (!reaper->start()) {
-    exit(1);
-  }
-
-  while (true) {
-    // Select on all sockets:
-    //  - client listening socket
-    //  - sockets for all client connections
-
-    // When one of the client connections closes, close its socket
-    // handles.
-
-    fd_set set;
-    SOCKET maxSock = 0;
-
-    // Set up fd_set
-    {
-      int i;
-      FD_ZERO(&set);
-      FD_SET(clientListeningSock, &set);
-      if (clientListeningSock > maxSock) {
-        maxSock = clientListeningSock;
-      }
-      for (i = 0; i < clientList.size(); i++) {
-        ClientInfo* info = clientList.get(i);
-        if (info->getDataSocket() > maxSock) {
-          maxSock = info->getDataSocket();
-        }
-        FD_SET(info->getDataSocket(), &set);
-      }
-    }
-    struct timeval timeout;
-    timeout.tv_sec = 300; // 5 minutes
-    timeout.tv_usec = 0;
-    int res = select(maxSock, &set, NULL, NULL, &timeout);
-    if (res > 0) {
-
-      ////////////////
-      // New client //
-      ////////////////
-      if (FD_ISSET(clientListeningSock, &set)) {
-        SOCKET fd = acceptFromLocalhost(clientListeningSock);
-        if (fd != INVALID_SOCKET) {
-          // Create new client information object
-          ClientInfo* info = new ClientInfo(fd);
-          // Add to list of clients
-          clientList.addClient(info);
-#ifdef DEBUGGING
-          cerr << "New client" << endl;
-#endif
-        }
-      }
-
-      ///////////////////////////
-      // Commands from clients //
-      ///////////////////////////
-      ClientInfo* clientInfo;
-      if (clientList.isAnyDataSocketSet(&set, &clientInfo)) {
-        readAndDispatch(clientInfo);
-      }
-    } else if (res < 0) {
-      // Looks like one of the clients was killed. Try to figure out which one.
-      bool found = false;
-      fd_set set;
-      struct timeval timeout;
-      timeout.tv_sec = 0;
-      timeout.tv_usec = 0;
-      for (int i = 0; i < clientList.size(); i++) {
-        ClientInfo* info = clientList.get(i);
-        FD_ZERO(&set);
-        FD_SET(info->getDataSocket(), &set);
-        if (select(1 + info->getDataSocket(), &set, NULL, NULL, &timeout) < 0) {
-          found = true;
-          clientList.removeClient(info);
-          info->closeAll();
-          delete info;
-          break;
-        }
-      }
-      if (!found) {
-        // This indicates trouble -- one of our listening sockets died.
-        exit(1);
-      }
-    }
-  }
-
-  return 0;
-}
--- a/hotspot/agent/src/os/win32/SwDbgSrv.dsp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-# Microsoft Developer Studio Project File - Name="SwDbgSrv" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=SwDbgSrv - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "SwDbgSrv.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "SwDbgSrv.mak" CFG="SwDbgSrv - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "SwDbgSrv - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "SwDbgSrv - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "SwDbgSrv - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "SwDbgSrv - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "SwDbgSrv___Win32_Debug"
-# PROP BASE Intermediate_Dir "SwDbgSrv___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF 
-
-# Begin Target
-
-# Name "SwDbgSrv - Win32 Release"
-# Name "SwDbgSrv - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\Buffer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Dispatcher.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\initWinsock.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\IOBuf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ioUtils.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\isNT4.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\nt4internals.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\procList.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Reaper.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\serverLists.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\SwDbgSrv.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\toolHelp.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
--- a/hotspot/agent/src/os/win32/SwDbgSrv.dsw	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "SwDbgSrv"=.\SwDbgSrv.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "SwDbgSub"=.\SwDbgSub.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
--- a/hotspot/agent/src/os/win32/SwDbgSub.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,883 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-// This is the source code for the subprocess forked by the Simple
-// Windows Debug Server. It assumes most of the responsibility for the
-// debug session, and processes all of the commands sent by clients.
-
-// Disable too-long symbol warnings
-#pragma warning ( disable : 4786 )
-
-#include <iostream>
-#include <vector>
-#include <stdlib.h>
-#include <assert.h>
-// Must come before windows.h
-#include <winsock2.h>
-#include <windows.h>
-#include "IOBuf.hpp"
-#include "libInfo.hpp"
-#include "LockableList.hpp"
-#include "Message.hpp"
-#include "Monitor.hpp"
-#include "nt4internals.hpp"
-
-// Uncomment the #define below to get messages on stderr
-// #define DEBUGGING
-
-using namespace std;
-
-DWORD pid;
-HANDLE procHandle;
-IOBuf* ioBuf;
-
-// State flags indicating whether the attach to the remote process
-// definitively succeeded or failed
-volatile bool attachFailed    = false;
-volatile bool attachSucceeded = false;
-
-// State flag indicating whether the target process is suspended.
-// Modified by suspend()/resume(), viewed by debug thread, but only
-// under cover of the threads lock.
-volatile bool suspended       = false;
-
-// State flags indicating whether we are considered to be attached to
-// the target process and are therefore queuing up events to be sent
-// back to the debug server. These flags are only accessed and
-// modified under the cover of the eventLock.
-Monitor* eventLock;
-// The following is set to true when a client is attached to this process
-volatile bool generateDebugEvents = false;
-// Pointer to current debug event; non-NULL indicates a debug event is
-// waiting to be sent to the client. Main thread sets this to NULL to
-// indicate that the event has been consumed; also sets
-// passEventToClient, below.
-volatile DEBUG_EVENT* curDebugEvent = NULL;
-// Set by main thread to indicate whether the most recently posted
-// debug event should be passed on to the target process.
-volatile bool passEventToClient = true;
-
-void conditionalPostDebugEvent(DEBUG_EVENT* ev, DWORD* continueOrNotHandledFlag) {
-  // FIXME: make it possible for the client to enable and disable
-  // certain types of events (have to do so in a platform-independent
-  // manner)
-  switch (ev->dwDebugEventCode) {
-  case EXCEPTION_DEBUG_EVENT:
-    switch (ev->u.Exception.ExceptionRecord.ExceptionCode) {
-    case EXCEPTION_BREAKPOINT:  break;
-    case EXCEPTION_SINGLE_STEP: break;
-    case EXCEPTION_ACCESS_VIOLATION: break;
-    default: return;
-    }
-  }
-  eventLock->lock();
-  if (generateDebugEvents) {
-    curDebugEvent = ev;
-    while (curDebugEvent != NULL) {
-      eventLock->wait();
-    }
-    if (passEventToClient) {
-      *continueOrNotHandledFlag = DBG_EXCEPTION_NOT_HANDLED;
-    } else {
-      *continueOrNotHandledFlag = DBG_CONTINUE;
-    }
-  }
-  eventLock->unlock();
-}
-
-
-//----------------------------------------------------------------------
-// Module list
-//
-
-vector<LibInfo> libs;
-
-//----------------------------------------------------------------------
-// Thread list
-//
-
-struct ThreadInfo {
-  DWORD tid;
-  HANDLE thread;
-
-  ThreadInfo(DWORD tid, HANDLE thread) {
-    this->tid = tid;
-    this->thread = thread;
-  }
-};
-
-class ThreadList : public LockableList<ThreadInfo> {
-public:
-  bool removeByThreadID(DWORD tid) {
-    for (InternalListType::iterator iter = internalList.begin();
-         iter != internalList.end(); iter++) {
-      if ((*iter).tid == tid) {
-        internalList.erase(iter);
-        return true;
-      }
-    }
-    return false;
-  }
-  HANDLE threadIDToHandle(DWORD tid) {
-    for (InternalListType::iterator iter = internalList.begin();
-         iter != internalList.end(); iter++) {
-      if ((*iter).tid == tid) {
-        return (*iter).thread;
-      }
-    }
-    return NULL;
-  }
-};
-
-ThreadList threads;
-
-//----------------------------------------------------------------------
-// INITIALIZATION AND TERMINATION
-//
-
-void
-printError(const char* prefix) {
-  DWORD detail = GetLastError();
-  LPTSTR message;
-  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                FORMAT_MESSAGE_FROM_SYSTEM,
-                0,
-                detail,
-                0,
-                (LPTSTR) &message,
-                1,
-                NULL);
-  // FIXME: This is signaling an error: "The handle is invalid." ?
-  // Do I have to do all of my WaitForDebugEvent calls from the same thread?
-  cerr << prefix << ": " << message << endl;
-  LocalFree(message);
-}
-
-void
-endProcess(bool waitForProcess = true) {
-  NT4::unloadNTDLL();
-  if (waitForProcess) {
-    // Though we're exiting because of an error, do not tear down the
-    // target process.
-    WaitForSingleObject(procHandle, INFINITE);
-  }
-  CloseHandle(procHandle);
-  exit(0);
-}
-
-DWORD WINAPI
-debugThreadEntry(void*) {
-#ifdef DEBUGGING
-  DWORD lastMsgId = 0;
-  int count = 0;
-#endif
-
-  if (!DebugActiveProcess(pid)) {
-    attachFailed = true;
-    return 0;
-  }
-
-  // Wait for debug events. We keep the information from some of these
-  // on the side in anticipation of later queries by the client. NOTE
-  // that we leave the process running. The main thread is responsible
-  // for suspending and resuming all currently-active threads upon
-  // client attach and detach.
-
-  while (true) {
-    DEBUG_EVENT ev;
-    if (!WaitForDebugEvent(&ev, INFINITE)) {
-#ifdef DEBUGGING
-      if (++count < 10) {
-        // FIXME: This is signaling an error: "The handle is invalid." ?
-        // Do I have to do all of my WaitForDebugEvent calls from the same thread?
-        printError("WaitForDebugEvent failed");
-      }
-#endif
-    } else {
-
-#ifdef DEBUGGING
-      if (ev.dwDebugEventCode != lastMsgId) {
-        lastMsgId = ev.dwDebugEventCode;
-        count = 0;
-        cerr << "Debug thread received event " << ev.dwDebugEventCode << endl;
-      } else {
-        if (++count < 10) {
-          cerr << "Debug thread received event " << ev.dwDebugEventCode << endl;
-        }
-      }
-#endif
-
-      DWORD dbgContinueMode = DBG_CONTINUE;
-
-      switch (ev.dwDebugEventCode) {
-      case LOAD_DLL_DEBUG_EVENT:
-        conditionalPostDebugEvent(&ev, &dbgContinueMode);
-        break;
-
-      case UNLOAD_DLL_DEBUG_EVENT:
-        conditionalPostDebugEvent(&ev, &dbgContinueMode);
-        break;
-
-      case CREATE_PROCESS_DEBUG_EVENT:
-        threads.lock();
-        // FIXME: will this deal properly with child processes? If
-        // not, is it possible to make it do so?
-#ifdef DEBUGGING
-        cerr << "CREATE_PROCESS_DEBUG_EVENT " << ev.dwThreadId
-             << " " << ev.u.CreateProcessInfo.hThread << endl;
-#endif
-        if (ev.u.CreateProcessInfo.hThread != NULL) {
-          threads.add(ThreadInfo(ev.dwThreadId, ev.u.CreateProcessInfo.hThread));
-        }
-        threads.unlock();
-        break;
-
-      case CREATE_THREAD_DEBUG_EVENT:
-        threads.lock();
-#ifdef DEBUGGING
-        cerr << "CREATE_THREAD_DEBUG_EVENT " << ev.dwThreadId
-             << " " << ev.u.CreateThread.hThread << endl;
-#endif
-        if (suspended) {
-          // Suspend this thread before adding it to the thread list
-          SuspendThread(ev.u.CreateThread.hThread);
-        }
-        threads.add(ThreadInfo(ev.dwThreadId, ev.u.CreateThread.hThread));
-        threads.unlock();
-        break;
-
-      case EXIT_THREAD_DEBUG_EVENT:
-        threads.lock();
-#ifdef DEBUGGING
-        cerr << "EXIT_THREAD_DEBUG_EVENT " << ev.dwThreadId << endl;
-#endif
-        threads.removeByThreadID(ev.dwThreadId);
-        threads.unlock();
-        break;
-
-      case EXCEPTION_DEBUG_EVENT:
-        //      cerr << "EXCEPTION_DEBUG_EVENT" << endl;
-        switch (ev.u.Exception.ExceptionRecord.ExceptionCode) {
-        case EXCEPTION_BREAKPOINT:
-          //        cerr << "EXCEPTION_BREAKPOINT" << endl;
-          if (!attachSucceeded && !attachFailed) {
-            attachSucceeded = true;
-          }
-          break;
-
-        default:
-          dbgContinueMode = DBG_EXCEPTION_NOT_HANDLED;
-          break;
-        }
-        conditionalPostDebugEvent(&ev, &dbgContinueMode);
-        break;
-
-      case EXIT_PROCESS_DEBUG_EVENT:
-        endProcess(false);
-        // NOT REACHED
-        break;
-
-      default:
-#ifdef DEBUGGING
-        cerr << "Received debug event " << ev.dwDebugEventCode << endl;
-#endif
-        break;
-      }
-
-      ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, dbgContinueMode);
-    }
-  }
-}
-
-bool
-attachToProcess() {
-  // Create event lock
-  eventLock = new Monitor();
-
-  // Get a process handle for later
-  procHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
-  if (procHandle == NULL) {
-    return false;
-  }
-
-  // Start up the debug thread
-  DWORD debugThreadId;
-  if (CreateThread(NULL, 0, &debugThreadEntry, NULL, 0, &debugThreadId) == NULL) {
-    // Failed to make background debug thread. Fail.
-    return false;
-  }
-
-  while ((!attachSucceeded) && (!attachFailed)) {
-    Sleep(1);
-  }
-
-  if (attachFailed) {
-    return false;
-  }
-
-  assert(attachSucceeded);
-
-  return true;
-}
-
-bool
-readMessage(Message* msg) {
-  DWORD numRead;
-  if (!ReadFile(GetStdHandle(STD_INPUT_HANDLE),
-                msg,
-                sizeof(Message),
-                &numRead,
-                NULL)) {
-    return false;
-  }
-  if (numRead != sizeof(Message)) {
-    return false;
-  }
-  // For "poke" messages, must follow up by reading raw data
-  if (msg->type == Message::POKE) {
-    char* dataBuf = new char[msg->pokeArg.numBytes];
-    if (dataBuf == NULL) {
-      return false;
-    }
-    if (!ReadFile(GetStdHandle(STD_INPUT_HANDLE),
-                  dataBuf,
-                  msg->pokeArg.numBytes,
-                  &numRead,
-                  NULL)) {
-      delete[] dataBuf;
-      return false;
-    }
-    if (numRead != msg->pokeArg.numBytes) {
-      delete[] dataBuf;
-      return false;
-    }
-    msg->pokeArg.data = (void *) dataBuf;
-  }
-  return true;
-}
-
-void
-handlePeek(Message* msg) {
-#ifdef DEBUGGING
-  cerr << "Entering handlePeek()" << endl;
-#endif
-
-  char* memBuf = new char[msg->peekArg.numBytes];
-  if (memBuf == NULL) {
-    ioBuf->writeString("B");
-    ioBuf->writeBinChar(0);
-    ioBuf->flush();
-    delete[] memBuf;
-    return;
-  }
-
-  // Try fast case first
-  DWORD numRead;
-  BOOL res = ReadProcessMemory(procHandle,
-                               (LPCVOID) msg->peekArg.address,
-                               memBuf,
-                               msg->peekArg.numBytes,
-                               &numRead);
-  if (res && (numRead == msg->peekArg.numBytes)) {
-
-    // OK, complete success. Phew.
-#ifdef DEBUGGING
-    cerr << "Peek success case" << endl;
-#endif
-    ioBuf->writeString("B");
-    ioBuf->writeBinChar(1);
-    ioBuf->writeBinUnsignedInt(numRead);
-    ioBuf->writeBinChar(1);
-    ioBuf->writeBinBuf(memBuf, numRead);
-  } else {
-#ifdef DEBUGGING
-    cerr << "*** Peek slow case ***" << endl;
-#endif
-
-    ioBuf->writeString("B");
-    ioBuf->writeBinChar(1);
-
-    // Use VirtualQuery to speed things up a bit
-    DWORD numLeft = msg->peekArg.numBytes;
-    char* curAddr = (char*) msg->peekArg.address;
-    while (numLeft > 0) {
-      MEMORY_BASIC_INFORMATION memInfo;
-      VirtualQueryEx(procHandle, curAddr, &memInfo, sizeof(memInfo));
-      DWORD numToRead = memInfo.RegionSize;
-      if (numToRead > numLeft) {
-        numToRead = numLeft;
-      }
-      DWORD numRead;
-      if (memInfo.State == MEM_COMMIT) {
-        // Read the process memory at this address for this length
-        // FIXME: should check the result of this read
-        ReadProcessMemory(procHandle, curAddr, memBuf,
-                          numToRead, &numRead);
-        // Write this out
-#ifdef DEBUGGING
-        cerr << "*** Writing " << numToRead << " bytes as mapped ***" << endl;
-#endif
-        ioBuf->writeBinUnsignedInt(numToRead);
-        ioBuf->writeBinChar(1);
-        ioBuf->writeBinBuf(memBuf, numToRead);
-      } else {
-        // Indicate region is free
-#ifdef DEBUGGING
-        cerr << "*** Writing " << numToRead << " bytes as unmapped ***" << endl;
-#endif
-        ioBuf->writeBinUnsignedInt(numToRead);
-        ioBuf->writeBinChar(0);
-      }
-      curAddr += numToRead;
-      numLeft -= numToRead;
-    }
-  }
-
-  ioBuf->flush();
-  delete[] memBuf;
-#ifdef DEBUGGING
-  cerr << "Exiting handlePeek()" << endl;
-#endif
-}
-
-void
-handlePoke(Message* msg) {
-#ifdef DEBUGGING
-  cerr << "Entering handlePoke()" << endl;
-#endif
-  DWORD numWritten;
-  BOOL res = WriteProcessMemory(procHandle,
-                                (LPVOID) msg->pokeArg.address,
-                                msg->pokeArg.data,
-                                msg->pokeArg.numBytes,
-                                &numWritten);
-  if (res && (numWritten == msg->pokeArg.numBytes)) {
-    // Success
-    ioBuf->writeBoolAsInt(true);
-#ifdef DEBUGGING
-    cerr << " (Succeeded)" << endl;
-#endif
-  } else {
-    // Failure
-    ioBuf->writeBoolAsInt(false);
-#ifdef DEBUGGING
-    cerr << " (Failed)" << endl;
-#endif
-  }
-  ioBuf->writeEOL();
-  ioBuf->flush();
-  // We clean up the data
-  char* dataBuf = (char*) msg->pokeArg.data;
-  delete[] dataBuf;
-#ifdef DEBUGGING
-  cerr << "Exiting handlePoke()" << endl;
-#endif
-}
-
-bool
-suspend() {
-  if (suspended) {
-    return false;
-  }
-  // Before we suspend, we must take a snapshot of the loaded module
-  // names and base addresses, since acquiring this snapshot requires
-  // starting and exiting a thread in the remote process (at least on
-  // NT 4).
-  libs.clear();
-#ifdef DEBUGGING
-  cerr << "Starting suspension" << endl;
-#endif
-  libInfo(pid, libs);
-#ifdef DEBUGGING
-  cerr << "  Got lib info" << endl;
-#endif
-  threads.lock();
-#ifdef DEBUGGING
-  cerr << "  Got thread lock" << endl;
-#endif
-  suspended = true;
-  int j = 0;
-  for (int i = 0; i < threads.size(); i++) {
-    j++;
-    SuspendThread(threads.get(i).thread);
-  }
-#ifdef DEBUGGING
-  cerr << "Suspended " << j << " threads" << endl;
-#endif
-  threads.unlock();
-  return true;
-}
-
-bool
-resume() {
-  if (!suspended) {
-    return false;
-  }
-  threads.lock();
-  suspended = false;
-  for (int i = 0; i < threads.size(); i++) {
-    ResumeThread(threads.get(i).thread);
-  }
-  threads.unlock();
-#ifdef DEBUGGING
-  cerr << "Resumed process" << endl;
-#endif
-  return true;
-}
-
-int
-main(int argc, char **argv)
-{
-  if (argc != 2) {
-    // Should only be used by performing CreateProcess within SwDbgSrv
-    exit(1);
-  }
-
-  if (sscanf(argv[1], "%u", &pid) != 1) {
-    exit(1);
-  }
-
-  // Try to attach to process
-  if (!attachToProcess()) {
-    // Attach failed. Notify parent by writing result to stdout file
-    // handle.
-    char res = 0;
-    DWORD numBytes;
-    WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &res, sizeof(res),
-              &numBytes, NULL);
-    exit(1);
-  }
-
-  // Server is expecting success result back.
-  char res = 1;
-  DWORD numBytes;
-  WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &res, sizeof(res),
-            &numBytes, NULL);
-
-  // Initialize our I/O buffer
-  ioBuf = new IOBuf(32768, 131072);
-  ioBuf->setOutputFileHandle(GetStdHandle(STD_OUTPUT_HANDLE));
-
-  // At this point we are attached. Enter our main loop which services
-  // requests from the server. Note that in order to handle attach/
-  // detach properly (i.e., resumption of process upon "detach") we
-  // will need another thread which handles debug events.
-  while (true) {
-    // Read a message from the server
-    Message msg;
-    if (!readMessage(&msg)) {
-      endProcess();
-    }
-
-#ifdef DEBUGGING
-    cerr << "Main thread read message: " << msg.type << endl;
-#endif
-
-    switch (msg.type) {
-    // ATTACH and DETACH messages MUST come in pairs
-    case Message::ATTACH:
-      suspend();
-      eventLock->lock();
-      generateDebugEvents = true;
-      eventLock->unlock();
-      break;
-
-    case Message::DETACH:
-      eventLock->lock();
-      generateDebugEvents = false;
-      // Flush remaining event if any
-      if (curDebugEvent != NULL) {
-        curDebugEvent = NULL;
-        eventLock->notifyAll();
-      }
-      eventLock->unlock();
-      resume();
-      break;
-
-    case Message::LIBINFO:
-      {
-        if (!suspended) {
-          ioBuf->writeInt(0);
-        } else {
-          // Send back formatted text
-          ioBuf->writeInt(libs.size());
-          for (int i = 0; i < libs.size(); i++) {
-            ioBuf->writeSpace();
-            ioBuf->writeInt(1);
-            ioBuf->writeSpace();
-            ioBuf->writeInt(libs[i].name.size());
-            ioBuf->writeSpace();
-            ioBuf->writeString(libs[i].name.c_str());
-            ioBuf->writeSpace();
-            ioBuf->writeAddress(libs[i].base);
-          }
-        }
-        ioBuf->writeEOL();
-        ioBuf->flush();
-        break;
-      }
-
-    case Message::PEEK:
-      handlePeek(&msg);
-      break;
-
-    case Message::POKE:
-      handlePoke(&msg);
-      break;
-
-    case Message::THREADLIST:
-      {
-        if (!suspended) {
-          ioBuf->writeInt(0);
-        } else {
-          threads.lock();
-          ioBuf->writeInt(threads.size());
-          for (int i = 0; i < threads.size(); i++) {
-            ioBuf->writeSpace();
-            ioBuf->writeAddress((void*) threads.get(i).thread);
-          }
-          threads.unlock();
-        }
-        ioBuf->writeEOL();
-        ioBuf->flush();
-        break;
-      }
-
-    case Message::DUPHANDLE:
-      {
-        HANDLE dup;
-        if (DuplicateHandle(procHandle,
-                            msg.handleArg.handle,
-                            GetCurrentProcess(),
-                            &dup,
-                            0,
-                            FALSE,
-                            DUPLICATE_SAME_ACCESS)) {
-          ioBuf->writeBoolAsInt(true);
-          ioBuf->writeSpace();
-          ioBuf->writeAddress((void*) dup);
-        } else {
-          ioBuf->writeBoolAsInt(false);
-        }
-        ioBuf->writeEOL();
-        ioBuf->flush();
-        break;
-      }
-
-    case Message::CLOSEHANDLE:
-      {
-        CloseHandle(msg.handleArg.handle);
-        break;
-      }
-
-    case Message::GETCONTEXT:
-      {
-        if (!suspended) {
-          ioBuf->writeBoolAsInt(false);
-        } else {
-          CONTEXT context;
-          context.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS;
-          if (GetThreadContext(msg.handleArg.handle, &context)) {
-            ioBuf->writeBoolAsInt(true);
-            // EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP, EIP, DS, ES, FS, GS,
-            // CS, SS, EFLAGS, DR0, DR1, DR2, DR3, DR6, DR7
-            // See README-commands.txt
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Eax);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Ebx);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Ecx);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Edx);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Esi);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Edi);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Ebp);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Esp);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Eip);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.SegDs);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.SegEs);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.SegFs);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.SegGs);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.SegCs);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.SegSs);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.EFlags);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Dr0);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Dr1);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Dr2);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Dr3);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Dr6);
-            ioBuf->writeSpace(); ioBuf->writeAddress((void*) context.Dr7);
-          } else {
-            ioBuf->writeBoolAsInt(false);
-          }
-        }
-        ioBuf->writeEOL();
-        ioBuf->flush();
-        break;
-      }
-
-    case Message::SETCONTEXT:
-      {
-        if (!suspended) {
-          ioBuf->writeBoolAsInt(false);
-        } else {
-          CONTEXT context;
-          context.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS;
-          context.Eax    = msg.setContextArg.Eax;
-          context.Ebx    = msg.setContextArg.Ebx;
-          context.Ecx    = msg.setContextArg.Ecx;
-          context.Edx    = msg.setContextArg.Edx;
-          context.Esi    = msg.setContextArg.Esi;
-          context.Edi    = msg.setContextArg.Edi;
-          context.Ebp    = msg.setContextArg.Ebp;
-          context.Esp    = msg.setContextArg.Esp;
-          context.Eip    = msg.setContextArg.Eip;
-          context.SegDs  = msg.setContextArg.Ds;
-          context.SegEs  = msg.setContextArg.Es;
-          context.SegFs  = msg.setContextArg.Fs;
-          context.SegGs  = msg.setContextArg.Gs;
-          context.SegCs  = msg.setContextArg.Cs;
-          context.SegSs  = msg.setContextArg.Ss;
-          context.EFlags = msg.setContextArg.EFlags;
-          context.Dr0    = msg.setContextArg.Dr0;
-          context.Dr1    = msg.setContextArg.Dr1;
-          context.Dr2    = msg.setContextArg.Dr2;
-          context.Dr3    = msg.setContextArg.Dr3;
-          context.Dr6    = msg.setContextArg.Dr6;
-          context.Dr7    = msg.setContextArg.Dr7;
-          if (SetThreadContext(msg.setContextArg.handle, &context)) {
-            ioBuf->writeBoolAsInt(true);
-          } else {
-            ioBuf->writeBoolAsInt(false);
-          }
-        }
-        ioBuf->writeEOL();
-        ioBuf->flush();
-        break;
-      }
-
-    case Message::SELECTORENTRY:
-      {
-        LDT_ENTRY entry;
-
-        if (GetThreadSelectorEntry(msg.selectorArg.handle,
-                                   msg.selectorArg.selector,
-                                   &entry)) {
-          ioBuf->writeBoolAsInt(true);
-          ioBuf->writeSpace(); ioBuf->writeAddress((void*) entry.LimitLow);
-          ioBuf->writeSpace(); ioBuf->writeAddress((void*) entry.BaseLow);
-          ioBuf->writeSpace(); ioBuf->writeAddress((void*) entry.HighWord.Bytes.BaseMid);
-          ioBuf->writeSpace(); ioBuf->writeAddress((void*) entry.HighWord.Bytes.Flags1);
-          ioBuf->writeSpace(); ioBuf->writeAddress((void*) entry.HighWord.Bytes.Flags2);
-          ioBuf->writeSpace(); ioBuf->writeAddress((void*) entry.HighWord.Bytes.BaseHi);
-        } else {
-          ioBuf->writeBoolAsInt(false);
-        }
-
-        ioBuf->writeEOL();
-        ioBuf->flush();
-        break;
-      }
-
-    case Message::SUSPEND:
-      suspend();
-      break;
-
-    case Message::RESUME:
-      resume();
-      break;
-
-    case Message::POLLEVENT:
-      eventLock->lock();
-      if (curDebugEvent == NULL) {
-        ioBuf->writeBoolAsInt(false);
-      } else {
-        ioBuf->writeBoolAsInt(true);
-        ioBuf->writeSpace();
-        threads.lock();
-        ioBuf->writeAddress((void*) threads.threadIDToHandle(curDebugEvent->dwThreadId));
-        threads.unlock();
-        ioBuf->writeSpace();
-        ioBuf->writeUnsignedInt(curDebugEvent->dwDebugEventCode);
-        // Figure out what else to write
-        switch (curDebugEvent->dwDebugEventCode) {
-        case LOAD_DLL_DEBUG_EVENT:
-          ioBuf->writeSpace();
-          ioBuf->writeAddress(curDebugEvent->u.LoadDll.lpBaseOfDll);
-          break;
-
-        case UNLOAD_DLL_DEBUG_EVENT:
-          ioBuf->writeSpace();
-          ioBuf->writeAddress(curDebugEvent->u.UnloadDll.lpBaseOfDll);
-          break;
-
-        case EXCEPTION_DEBUG_EVENT:
-          {
-            DWORD code = curDebugEvent->u.Exception.ExceptionRecord.ExceptionCode;
-            ioBuf->writeSpace();
-            ioBuf->writeUnsignedInt(code);
-            ioBuf->writeSpace();
-            ioBuf->writeAddress(curDebugEvent->u.Exception.ExceptionRecord.ExceptionAddress);
-            switch (curDebugEvent->u.Exception.ExceptionRecord.ExceptionCode) {
-            case EXCEPTION_ACCESS_VIOLATION:
-              ioBuf->writeSpace();
-              ioBuf->writeBoolAsInt(curDebugEvent->u.Exception.ExceptionRecord.ExceptionInformation[0] != 0);
-              ioBuf->writeSpace();
-              ioBuf->writeAddress((void*) curDebugEvent->u.Exception.ExceptionRecord.ExceptionInformation[1]);
-              break;
-
-            default:
-              break;
-            }
-            break;
-          }
-
-        default:
-          break;
-        }
-      }
-      eventLock->unlock();
-      ioBuf->writeEOL();
-      ioBuf->flush();
-      break;
-
-    case Message::CONTINUEEVENT:
-      eventLock->lock();
-      if (curDebugEvent == NULL) {
-        ioBuf->writeBoolAsInt(false);
-      } else {
-        curDebugEvent = NULL;
-        passEventToClient = msg.boolArg.val;
-        ioBuf->writeBoolAsInt(true);
-        eventLock->notify();
-      }
-      eventLock->unlock();
-      ioBuf->writeEOL();
-      ioBuf->flush();
-      break;
-    }
-  }
-
-  endProcess();
-
-  // NOT REACHED
-  return 0;
-}
--- a/hotspot/agent/src/os/win32/SwDbgSub.dsp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-# Microsoft Developer Studio Project File - Name="SwDbgSub" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=SwDbgSub - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "SwDbgSub.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "SwDbgSub.mak" CFG="SwDbgSub - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "SwDbgSub - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "SwDbgSub - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "SwDbgSub - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "SwDbgSub - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "SwDbgSub___Win32_Debug"
-# PROP BASE Intermediate_Dir "SwDbgSub___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF 
-
-# Begin Target
-
-# Name "SwDbgSub - Win32 Release"
-# Name "SwDbgSub - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\Buffer.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\IOBuf.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\isNT4.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\libInfo.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\Monitor.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\nt4internals.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\SwDbgSub.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\toolHelp.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
--- a/hotspot/agent/src/os/win32/initWinsock.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +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.
- *
- */
-
-#include <iostream>
-#include <winsock2.h>
-
-using namespace std;
-
-void
-initWinsock()
-{
-  static int initted = 0;
-  WORD wVersionRequested;
-  WSADATA wsaData;
-  int err;
-
-  if (!initted) {
-    wVersionRequested = MAKEWORD( 2, 0 );
-
-    err = WSAStartup( wVersionRequested, &wsaData );
-    if ( err != 0 ) {
-      {
-        /* Tell the user that we couldn't find a usable */
-        /* WinSock DLL.                                 */
-        cerr << "SocketBase::SocketBase: unable to find usable "
-             << "WinSock DLL" << endl;
-        exit(1);
-      }
-    }
-
-    /* Confirm that the WinSock DLL supports 2.0.*/
-    /* Note that if the DLL supports versions greater    */
-    /* than 2.0 in addition to 2.0, it will still return */
-    /* 2.0 in wVersion since that is the version we      */
-    /* requested.                                        */
-
-    if ( LOBYTE( wsaData.wVersion ) != 2 ||
-         HIBYTE( wsaData.wVersion ) != 0 ) {
-      /* Tell the user that we couldn't find a usable */
-      /* WinSock DLL.                                  */
-      {
-        cerr << "Unable to find suitable version of WinSock DLL" << endl;
-        WSACleanup( );
-        exit(1);
-      }
-    }
-
-    initted = 1;
-  }
-}
--- a/hotspot/agent/src/os/win32/initWinsock.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +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.
- *
- */
-
-#ifndef _INIT_WINSOCK_
-#define _INIT_WINSOCK_
-
-void initWinsock();
-
-#endif // #defined _INIT_WINSOCK_
--- a/hotspot/agent/src/os/win32/ioUtils.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 <ctype.h>
-#include <string.h>
-#include "ioUtils.hpp"
-#include "IOBuf.hpp"
-
-bool
-scanInt(char** data, int* num) {
-  *num = 0;
-
-  // Skip whitespace
-  while ((**data != 0) && (isspace(**data))) {
-    ++*data;
-  }
-
-  if (**data == 0) {
-    return false;
-  }
-
-  while ((**data != 0) && (!isspace(**data))) {
-    char cur = **data;
-    if ((cur < '0') || (cur > '9')) {
-      return false;
-    }
-    *num *= 10;
-    *num += cur - '0';
-    ++*data;
-  }
-
-  return true;
-}
-
-bool
-scanUnsignedLong(char** data, unsigned long* num) {
-  *num = 0;
-
-  // Skip whitespace
-  while ((**data != 0) && (isspace(**data))) {
-    ++*data;
-  }
-
-  if (**data == 0) {
-    return false;
-  }
-
-  while ((**data != 0) && (!isspace(**data))) {
-    char cur = **data;
-    if ((cur < '0') || (cur > '9')) {
-      return false;
-    }
-    *num *= 10;
-    *num += cur - '0';
-    ++*data;
-  }
-
-  return true;
-}
-
-bool
-charToNibble(char ascii, int* value) {
-  if (ascii >= '0' && ascii <= '9') {
-    *value = ascii - '0';
-    return true;
-  } else if (ascii >= 'A' && ascii <= 'F') {
-    *value = 10 + ascii - 'A';
-    return true;
-  } else if (ascii >= 'a' && ascii <= 'f') {
-    *value = 10 + ascii - 'a';
-    return true;
-  }
-
-  return false;
-}
-
-bool
-scanAddress(char** data, unsigned long* addr) {
-  *addr = 0;
-
-  // Skip whitespace
-  while ((**data != 0) && (isspace(**data))) {
-    ++*data;
-  }
-
-  if (**data == 0) {
-    return false;
-  }
-
-  if (strncmp(*data, "0x", 2) != 0) {
-    return false;
-  }
-
-  *data += 2;
-
-  while ((**data != 0) && (!isspace(**data))) {
-    int val;
-    bool res = charToNibble(**data, &val);
-    if (!res) {
-      return false;
-    }
-    *addr <<= 4;
-    *addr |= val;
-    ++*data;
-  }
-
-  return true;
-}
-
-bool
-scanAndSkipBinEscapeChar(char** data) {
-  // Skip whitespace
-  while ((**data != 0) && (isspace(**data))) {
-    ++*data;
-  }
-
-  if (!IOBuf::isBinEscapeChar(**data)) {
-    return false;
-  }
-
-  ++*data;
-
-  return true;
-}
-
-bool
-scanBinUnsignedLong(char** data, unsigned long* num) {
-  *num = 0;
-  for (int i = 0; i < 4; i++) {
-    unsigned char val = (unsigned char) **data;
-    *num = (*num << 8) | val;
-    ++*data;
-  }
-  return true;
-}
--- a/hotspot/agent/src/os/win32/ioUtils.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _IO_UTILS_
-#define _IO_UTILS_
-
-bool scanInt(char** data, int* num);
-bool scanUnsignedLong(char** data, unsigned long* num);
-bool scanAddress(char** data, unsigned long* addr);
-
-// Binary utils (for poke)
-bool scanAndSkipBinEscapeChar(char** data);
-bool scanBinUnsignedLong(char** data, unsigned long* num);
-
-#endif  // #defined _IO_UTILS_
--- a/hotspot/agent/src/os/win32/isNT4.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +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.
- *
- */
-
-#include "isNT4.hpp"
-#include <windows.h>
-
-bool
-isNT4() {
-  OSVERSIONINFO info;
-  info.dwOSVersionInfoSize = sizeof(info);
-
-  if (!GetVersionEx(&info)) {
-    return false;
-  }
-
-  return ((info.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
-          (info.dwMajorVersion == 4));
-}
--- a/hotspot/agent/src/os/win32/isNT4.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +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.
- *
- */
-
-#ifndef _ISNT4_H_
-#define _ISNT4_H_
-
-// We need to special-case the Windows NT 4.0 implementations of some
-// of the debugging routines because the Tool Help API is not
-// available on this platform.
-
-bool isNT4();
-
-#endif  // #defined _ISNT4_H_
--- a/hotspot/agent/src/os/win32/libInfo.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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.
- *
- */
-
-// Disable too-long symbol warnings
-#pragma warning ( disable : 4786 )
-
-#include "libInfo.hpp"
-#include "nt4internals.hpp"
-#include "isNT4.hpp"
-#include "toolHelp.hpp"
-#include <assert.h>
-
-using namespace std;
-
-typedef void LibInfoImplFunc(DWORD pid, vector<LibInfo>& info);
-
-static void libInfoImplNT4(DWORD pid, vector<LibInfo>& info);
-static void libInfoImplToolHelp(DWORD pid, vector<LibInfo>& info);
-
-void
-libInfo(DWORD pid, vector<LibInfo>& info) {
-  static LibInfoImplFunc* impl = NULL;
-
-  if (impl == NULL) {
-    // See which operating system we're on
-    impl = (isNT4() ? &libInfoImplNT4 : &libInfoImplToolHelp);
-  }
-
-  assert(impl != NULL);
-
-  (*impl)(pid, info);
-}
-
-static ULONG
-ModuleCount(NT4::PDEBUG_BUFFER db) {
-  return db->ModuleInformation ? *PULONG(db->ModuleInformation) : 0;
-}
-
-#define MAX2(a, b) (((a) < (b)) ? (b) : (a))
-
-static void
-libInfoImplNT4(DWORD pid, vector<LibInfo>& info) {
-  static EnumProcessModulesFunc*   enumFunc = NULL;
-  static GetModuleFileNameExFunc*  fnFunc   = NULL;
-  static GetModuleInformationFunc* infoFunc = NULL;
-
-  if (enumFunc == NULL) {
-    HMODULE dll = loadPSAPIDLL();
-
-    enumFunc = (EnumProcessModulesFunc*)   GetProcAddress(dll, "EnumProcessModules");
-    fnFunc   = (GetModuleFileNameExFunc*)  GetProcAddress(dll, "GetModuleFileNameExA");
-    infoFunc = (GetModuleInformationFunc*) GetProcAddress(dll, "GetModuleInformation");
-
-    assert(enumFunc != NULL);
-    assert(fnFunc   != NULL);
-    assert(infoFunc != NULL);
-  }
-
-  static HMODULE* mods = new HMODULE[256];
-  static int      numMods = 256;
-
-  if (mods == NULL) {
-    mods = new HMODULE[numMods];
-    if (mods == NULL) {
-      return;
-    }
-  }
-
-  bool done = false;
-
-  HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
-  if (proc == NULL) {
-    return;
-  }
-
-  do {
-    DWORD bufSize = numMods * sizeof(HMODULE);
-    DWORD neededSize;
-
-    if (!(*enumFunc)(proc, mods, bufSize, &neededSize)) {
-      // Enum failed
-      CloseHandle(proc);
-      return;
-    }
-
-    int numFetched = neededSize / sizeof(HMODULE);
-
-    if (numMods < numFetched) {
-      // Grow buffer
-      numMods = MAX2(numFetched, 2 * numMods);
-      delete[] mods;
-      mods = new HMODULE[numMods];
-      if (mods == NULL) {
-        CloseHandle(proc);
-        return;
-      }
-    } else {
-      char filename[MAX_PATH];
-      MODULEINFO modInfo;
-
-      // Iterate through and fetch each one's info
-      for (int i = 0; i < numFetched; i++) {
-        if (!(*fnFunc)(proc, mods[i], filename, MAX_PATH)) {
-          CloseHandle(proc);
-          return;
-        }
-
-        if (!(*infoFunc)(proc, mods[i], &modInfo, sizeof(MODULEINFO))) {
-          CloseHandle(proc);
-          return;
-        }
-
-        info.push_back(LibInfo(string(filename), (void*) modInfo.lpBaseOfDll));
-      }
-
-      done = true;
-    }
-  } while (!done);
-
-  CloseHandle(proc);
-  return;
-}
-
-void
-libInfoImplToolHelp(DWORD pid, vector<LibInfo>& info) {
-  using namespace ToolHelp;
-
-  static CreateToolhelp32SnapshotFunc* snapshotFunc = NULL;
-  static Module32FirstFunc*            firstFunc    = NULL;
-  static Module32NextFunc*             nextFunc     = NULL;
-
-  if (snapshotFunc == NULL) {
-    HMODULE dll = loadDLL();
-
-    snapshotFunc =
-      (CreateToolhelp32SnapshotFunc*) GetProcAddress(dll,
-                                                     "CreateToolhelp32Snapshot");
-
-    firstFunc = (Module32FirstFunc*) GetProcAddress(dll,
-                                                    "Module32First");
-
-    nextFunc = (Module32NextFunc*) GetProcAddress(dll,
-                                                  "Module32Next");
-
-    assert(snapshotFunc != NULL);
-    assert(firstFunc    != NULL);
-    assert(nextFunc     != NULL);
-  }
-
-  HANDLE snapshot = (*snapshotFunc)(TH32CS_SNAPMODULE, pid);
-  if (snapshot == (HANDLE) -1) {
-    // Error occurred during snapshot
-    return;
-  }
-
-  // Iterate
-  MODULEENTRY32 module;
-  if ((*firstFunc)(snapshot, &module)) {
-    do {
-      info.push_back(LibInfo(string(module.szExePath), (void*) module.modBaseAddr));
-    } while ((*nextFunc)(snapshot, &module));
-  }
-
-  CloseHandle(snapshot);
-}
--- a/hotspot/agent/src/os/win32/libInfo.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _LIBINFO_
-#define _LIBINFO_
-
-#include <vector>
-#include <string>
-#include <windows.h>
-
-struct LibInfo {
-  std::string name;
-  void*  base;
-
-  LibInfo(const std::string& name, void* base) {
-    this->name = name;
-    this->base = base;
-  }
-};
-
-void libInfo(DWORD pid, std::vector<LibInfo>& info);
-
-#endif  // #defined _LIBINFO_
--- a/hotspot/agent/src/os/win32/nt4internals.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 "nt4internals.hpp"
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-namespace NT4 {
-
-static HMODULE ntDLL = NULL;
-
-HMODULE loadNTDLL() {
-  if (ntDLL == NULL) {
-    ntDLL = LoadLibrary("NTDLL.DLL");
-  }
-
-  assert(ntDLL != NULL);
-  return ntDLL;
-}
-
-void unloadNTDLL() {
-  if (ntDLL != NULL) {
-    FreeLibrary(ntDLL);
-    ntDLL = NULL;
-  }
-}
-
-} // namespace NT4
-
-static HMODULE psapiDLL = NULL;
-
-HMODULE
-loadPSAPIDLL() {
-  if (psapiDLL == NULL) {
-    psapiDLL = LoadLibrary("PSAPI.DLL");
-  }
-
-  if (psapiDLL == NULL) {
-    fprintf(stderr, "Simple Windows Debug Server requires PSAPI.DLL on Windows NT 4.0.\n");
-    fprintf(stderr, "Please install this DLL from the SDK and restart the server.\n");
-    exit(1);
-  }
-
-  return psapiDLL;
-}
-
-void
-unloadPSAPIDLL() {
-  if (psapiDLL != NULL) {
-    FreeLibrary(psapiDLL);
-    psapiDLL = NULL;
-  }
-}
--- a/hotspot/agent/src/os/win32/nt4internals.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,273 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _NT4INTERNALS_H_
-#define _NT4INTERNALS_H_
-
-#include <windows.h>
-
-namespace NT4 {
-extern "C" {
-
-// Data structures and constants required to be able to get necessary
-// debugging-related information on Windows NT 4.0 through internal
-// (i.e., non-public) APIs. These are adapted from those in the
-// _Windows NT/2000 Native API Reference_ by Gary Nebbett, Macmillan
-// Technical Publishing, 201 West 103rd Street, Indianapolis, IN
-// 46290, 2000.
-
-typedef LONG NTSTATUS;
-typedef LONG KPRIORITY;
-
-#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
-#define NTAPI __stdcall
-#else
-#define _cdecl
-#define NTAPI
-#endif
-
-#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L)
-
-typedef enum _SYSTEM_INFORMATION_CLASS {
-  SystemProcessesAndThreadsInformation = 5
-} SYSTEM_INFORMATION_CLASS;
-
-typedef struct _UNICODE_STRING {
-  USHORT Length;
-  USHORT MaximumLength;
-  PWSTR  Buffer;
-} UNICODE_STRING;
-
-typedef struct _VM_COUNTERS {
-  ULONG PeakVirtualSize;
-  ULONG VirtualSize;
-  ULONG PageFaultCount;
-  ULONG PeakWorkingSetSize;
-  ULONG WorkingSetSize;
-  ULONG QuotaPeakPagedPoolUsage;
-  ULONG QuotaPagedPoolUsage;
-  ULONG QuotaPeakNonPagedPoolUsage;
-  ULONG QuotaNonPagedPoolUsage;
-  ULONG PagefileUsage;
-  ULONG PeakPagefileUsage;
-} VM_COUNTERS, *PVM_COUNTERS;
-
-typedef struct _IO_COUNTERS {
-  LARGE_INTEGER ReadOperationCount;
-  LARGE_INTEGER WriteOperationCount;
-  LARGE_INTEGER OtherOperationCount;
-  LARGE_INTEGER ReadTransferCount;
-  LARGE_INTEGER WriteTransferCount;
-  LARGE_INTEGER OtherTransferCount;
-} IO_COUNTERS, *PIO_COUNTERS;
-
-typedef struct _CLIENT_ID {
-  HANDLE UniqueProcess;
-  HANDLE UniqueThread;
-} CLIENT_ID, *PCLIENT_ID;
-
-typedef enum {
-  StateInitialized,
-  StateReady,
-  StateRunning,
-  StateStandby,
-  StateTerminated,
-  StateWait,
-  StateTransition,
-  StateUnknown
-} THREAD_STATE;
-
-typedef enum {
-  Executive,
-  FreePage,
-  PageIn,
-  PoolAllocation,
-  DelayExecution,
-  Suspended,
-  UserRequest,
-  WrExecutive,
-  WrFreePage,
-  WrPageIn,
-  WrPoolAllocation,
-  WrDelayExecution,
-  WrSuspended,
-  WrUserRequest,
-  WrEventPair,
-  WrQueue,
-  WrLpcReceive,
-  WrLpcReply,
-  WrVirtualMemory,
-  WrPageOut,
-  WrRendezvous,
-  Spare2,
-  Spare3,
-  Spare4,
-  Spare5,
-  Spare6,
-  WrKernel
-} KWAIT_REASON;
-
-typedef struct _SYSTEM_THREADS {
-  LARGE_INTEGER KernelTime;
-  LARGE_INTEGER UserTime;
-  LARGE_INTEGER CreateTime;
-  ULONG WaitTime;
-  PVOID StartAddress;
-  CLIENT_ID ClientId;
-  KPRIORITY Priority;
-  KPRIORITY BasePriority;
-  ULONG ContextSwitchCount;
-  THREAD_STATE State;
-  KWAIT_REASON WaitReason;
-} SYSTEM_THREADS, *PSYSTEM_THREADS;
-
-typedef struct _SYSTEM_PROCESSES { // Information class 5
-  ULONG NextEntryDelta;
-  ULONG ThreadCount;
-  ULONG Reserved1[6];
-  LARGE_INTEGER CreateTime;
-  LARGE_INTEGER UserTime;
-  LARGE_INTEGER KernelTime;
-  UNICODE_STRING ProcessName;
-  KPRIORITY BasePriority;
-  ULONG ProcessId;
-  ULONG InheritedFromProcessId;
-  ULONG HandleCount;
-  ULONG Reserved2[2];
-  ULONG PrivatePageCount;
-  VM_COUNTERS VmCounters;
-  IO_COUNTERS IoCounters; // Windows 2000 only
-  SYSTEM_THREADS Threads[1];
-} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES;
-
-typedef NTSTATUS NTAPI
-ZwQuerySystemInformationFunc(IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
-                             IN OUT PVOID SystemInformation,
-                             IN ULONG SystemInformationLength,
-                             OUT PULONG ReturnLength OPTIONAL
-                             );
-
-typedef struct _DEBUG_BUFFER {
-  HANDLE SectionHandle;
-  PVOID  SectionBase;
-  PVOID  RemoteSectionBase;
-  ULONG  SectionBaseDelta;
-  HANDLE EventPairHandle;
-  ULONG  Unknown[2];
-  HANDLE RemoteThreadHandle;
-  ULONG  InfoClassMask;
-  ULONG  SizeOfInfo;
-  ULONG  AllocatedSize;
-  ULONG  SectionSize;
-  PVOID  ModuleInformation;
-  PVOID  BackTraceInformation;
-  PVOID  HeapInformation;
-  PVOID  LockInformation;
-  PVOID  Reserved[8];
-} DEBUG_BUFFER, *PDEBUG_BUFFER;
-
-typedef PDEBUG_BUFFER NTAPI
-RtlCreateQueryDebugBufferFunc(IN ULONG Size,
-                              IN BOOLEAN EventPair);
-
-#define PDI_MODULES     0x01 // The loaded modules of the process
-#define PDI_BACKTRACE   0x02 // The heap stack back traces
-#define PDI_HEAPS       0x04 // The heaps of the process
-#define PDI_HEAP_TAGS   0x08 // The heap tags
-#define PDI_HEAP_BLOCKS 0x10 // The heap blocks
-#define PDI_LOCKS       0x20 // The locks created by the process
-
-typedef struct _DEBUG_MODULE_INFORMATION { // c.f. SYSTEM_MODULE_INFORMATION
-  ULONG  Reserved[2];
-  ULONG  Base;
-  ULONG  Size;
-  ULONG  Flags;
-  USHORT Index;
-  USHORT Unknown;
-  USHORT LoadCount;
-  USHORT ModuleNameOffset;
-  CHAR   ImageName[256];
-} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
-
-// Flags
-#define LDRP_STATIC_LINK             0x00000002
-#define LDRP_IMAGE_DLL               0x00000004
-#define LDRP_LOAD_IN_PROGRESS        0x00001000
-#define LDRP_UNLOAD_IN_PROGRESS      0x00002000
-#define LDRP_ENTRY_PROCESSED         0x00004000
-#define LDRP_ENTRY_INSERTED          0x00008000
-#define LDRP_CURRENT_LOAD            0x00010000
-#define LDRP_FAILED_BUILTIN_LOAD     0x00020000
-#define LDRP_DONT_CALL_FOR_THREADS   0x00040000
-#define LDRP_PROCESS_ATTACH_CALLED   0x00080000
-#define LDRP_DEBUG_SYMBOLS_LOADED    0x00100000
-#define LDRP_IMAGE_NOT_AT_BASE       0x00200000
-#define LDRP_WX86_IGNORE_MACHINETYPE 0x00400000
-
-// NOTE that this will require creating a thread in the target
-// process, implying that we can not call this while the process is
-// suspended. May have to run this command in the child processes
-// rather than the server.
-
-typedef NTSTATUS NTAPI
-RtlQueryProcessDebugInformationFunc(IN ULONG ProcessId,
-                                    IN ULONG DebugInfoClassMask,
-                                    IN OUT PDEBUG_BUFFER DebugBuffer);
-
-typedef NTSTATUS NTAPI
-RtlDestroyQueryDebugBufferFunc(IN PDEBUG_BUFFER DebugBuffer);
-
-// Routines to load and unload NTDLL.DLL.
-HMODULE loadNTDLL();
-// Safe to call even if has not been loaded
-void    unloadNTDLL();
-
-} // extern "C"
-} // namespace NT4
-
-//----------------------------------------------------------------------
-
-// On NT 4 only, we now use PSAPI to enumerate the loaded modules in
-// the target processes. RtlQueryProcessDebugInformation creates a
-// thread in the target process, which causes problems when we are
-// handling events like breakpoints in the debugger. The dependence on
-// an external DLL which might not be present is unfortunate, but we
-// can either redistribute this DLL (if allowed) or refuse to start on
-// NT 4 if it is not present.
-
-typedef struct _MODULEINFO {
-    LPVOID lpBaseOfDll;
-    DWORD SizeOfImage;
-    LPVOID EntryPoint;
-} MODULEINFO, *LPMODULEINFO;
-
-typedef BOOL (WINAPI EnumProcessModulesFunc)(HANDLE, HMODULE *, DWORD, LPDWORD);
-typedef DWORD (WINAPI GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
-typedef BOOL (WINAPI GetModuleInformationFunc)(HANDLE, HMODULE, LPMODULEINFO, DWORD);
-// Routines to load and unload PSAPI.DLL.
-HMODULE loadPSAPIDLL();
-// Safe to call even if has not been loaded
-void    unloadPSAPIDLL();
-
-#endif // #defined _NT4INTERNALS_H_
--- a/hotspot/agent/src/os/win32/ports.h	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +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.
- *
- */
-
-#ifndef _PORTS_H_
-#define _PORTS_H_
-
-// This is the "public" port which end-user clients can connect to
-// with an arbitrary application, including telnet.
-const short CLIENT_PORT = 27000;
-
-#endif  // #defined _PORTS_H_
--- a/hotspot/agent/src/os/win32/procList.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 "procList.hpp"
-#include "nt4internals.hpp"
-#include "isNT4.hpp"
-#include "toolHelp.hpp"
-#include <assert.h>
-
-using namespace std;
-using namespace NT4;
-
-typedef void ProcListImplFunc(ProcEntryList& processes);
-
-void procListImplNT4(ProcEntryList& processes);
-void procListImplToolHelp(ProcEntryList& processes);
-
-ProcEntry::ProcEntry(ULONG pid, USHORT nameLength, WCHAR* name) {
-  this->pid = pid;
-  this->nameLength = nameLength;
-  this->name = new WCHAR[nameLength];
-  memcpy(this->name, name, nameLength * sizeof(WCHAR));
-}
-
-ProcEntry::ProcEntry(ULONG pid, USHORT nameLength, char* name) {
-  this->pid = pid;
-  this->nameLength = nameLength;
-  this->name = new WCHAR[nameLength];
-  int j = 0;
-  for (int i = 0; i < nameLength; i++) {
-    // FIXME: what is the proper promotion from ASCII to UNICODE?
-    this->name[i] = name[i] & 0xFF;
-  }
-}
-
-ProcEntry::ProcEntry(const ProcEntry& arg) {
-  name = NULL;
-  copyFrom(arg);
-}
-
-ProcEntry&
-ProcEntry::operator=(const ProcEntry& arg) {
-  copyFrom(arg);
-  return *this;
-}
-
-ProcEntry::~ProcEntry() {
-  delete[] name;
-}
-
-void
-ProcEntry::copyFrom(const ProcEntry& arg) {
-  if (name != NULL) {
-    delete[] name;
-  }
-  pid = arg.pid;
-  nameLength = arg.nameLength;
-  name = new WCHAR[nameLength];
-  memcpy(name, arg.name, nameLength * sizeof(WCHAR));
-}
-
-ULONG
-ProcEntry::getPid() {
-  return pid;
-}
-
-USHORT
-ProcEntry::getNameLength() {
-  return nameLength;
-}
-
-WCHAR*
-ProcEntry::getName() {
-  return name;
-}
-
-void
-procList(ProcEntryList& processes) {
-  static ProcListImplFunc* impl = NULL;
-
-  if (impl == NULL) {
-    // See which operating system we're on
-    impl = (isNT4() ? &procListImplNT4 : &procListImplToolHelp);
-  }
-
-  assert(impl != NULL);
-
-  (*impl)(processes);
-}
-
-void
-procListImplNT4(ProcEntryList& processes) {
-  using namespace NT4;
-
-  static ZwQuerySystemInformationFunc* query = NULL;
-
-  if (query == NULL) {
-    HMODULE ntDLL = loadNTDLL();
-    query =
-      (ZwQuerySystemInformationFunc*) GetProcAddress(ntDLL,
-                                                     "ZwQuerySystemInformation");
-    assert(query != NULL);
-  }
-
-  ULONG n = 0x100;
-  PSYSTEM_PROCESSES sp = new SYSTEM_PROCESSES[n];
-  while ((*query)(SystemProcessesAndThreadsInformation,
-                  sp, n * sizeof(SYSTEM_PROCESSES), 0) == STATUS_INFO_LENGTH_MISMATCH) {
-    delete[] sp;
-    n *= 2;
-    sp = new SYSTEM_PROCESSES[n];
-  }
-
-  bool done = false;
-  for (PSYSTEM_PROCESSES p = sp; !done;
-       p = PSYSTEM_PROCESSES(PCHAR(p) + p->NextEntryDelta)) {
-    processes.push_back(ProcEntry(p->ProcessId,
-                                  p->ProcessName.Length / 2,
-                                  p->ProcessName.Buffer));
-    done = p->NextEntryDelta == 0;
-  }
-}
-
-void
-procListImplToolHelp(ProcEntryList& processes) {
-  using namespace ToolHelp;
-
-  static CreateToolhelp32SnapshotFunc* snapshotFunc = NULL;
-  static Process32FirstFunc*           firstFunc    = NULL;
-  static Process32NextFunc*            nextFunc     = NULL;
-
-  if (snapshotFunc == NULL) {
-    HMODULE dll = loadDLL();
-
-    snapshotFunc =
-      (CreateToolhelp32SnapshotFunc*) GetProcAddress(dll,
-                                                     "CreateToolhelp32Snapshot");
-
-    firstFunc = (Process32FirstFunc*) GetProcAddress(dll,
-                                                     "Process32First");
-
-    nextFunc = (Process32NextFunc*) GetProcAddress(dll,
-                                                   "Process32Next");
-
-    assert(snapshotFunc != NULL);
-    assert(firstFunc    != NULL);
-    assert(nextFunc     != NULL);
-  }
-
-  HANDLE snapshot = (*snapshotFunc)(TH32CS_SNAPPROCESS, 0 /* ignored */);
-  if (snapshot == (HANDLE) -1) {
-    // Error occurred during snapshot
-    return;
-  }
-
-  // Iterate
-  PROCESSENTRY32 proc;
-  if ((*firstFunc)(snapshot, &proc)) {
-    do {
-      // FIXME: could make this uniform to the NT version by cutting
-      // off the path name just before the executable name
-      processes.push_back(ProcEntry(proc.th32ProcessID,
-                                    strlen(proc.szExeFile),
-                                    proc.szExeFile));
-    } while ((*nextFunc)(snapshot, &proc));
-  }
-
-  CloseHandle(snapshot);
-}
--- a/hotspot/agent/src/os/win32/procList.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _PROCLIST_
-#define _PROCLIST_
-
-#include <windows.h>
-#include <vector>
-
-class ProcEntry {
-public:
-  /** name may not be NULL */
-  ProcEntry(ULONG pid, USHORT nameLength, wchar_t* name);
-  ProcEntry(ULONG pid, USHORT nameLength, char* name);
-  ~ProcEntry();
-  ProcEntry(const ProcEntry& arg);
-  ProcEntry& operator=(const ProcEntry& arg);
-
-  ULONG getPid();
-  /** Returns number of WCHAR characters in getName() */
-  USHORT getNameLength();
-  WCHAR* getName();
-
-private:
-  ULONG pid;
-  USHORT nameLength;
-  WCHAR* name;
-  void copyFrom(const ProcEntry& arg);
-};
-
-typedef std::vector<ProcEntry> ProcEntryList;
-void procList(ProcEntryList& processes);
-
-#endif  // #defined _PROCLIST_
--- a/hotspot/agent/src/os/win32/serverLists.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,270 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * 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 <assert.h>
-#include "serverLists.hpp"
-
-//----------------------------------------------------------------------
-// Lists
-//
-
-CRITICAL_SECTION Lists::crit;
-
-void
-Lists::init() {
-  InitializeCriticalSection(&crit);
-}
-
-void
-Lists::lock() {
-  EnterCriticalSection(&crit);
-}
-
-void
-Lists::unlock() {
-  LeaveCriticalSection(&crit);
-}
-
-//----------------------------------------------------------------------
-// ListsLocker
-//
-
-ListsLocker::ListsLocker() {
-  Lists::lock();
-}
-
-ListsLocker::~ListsLocker() {
-  Lists::unlock();
-}
-
-//----------------------------------------------------------------------
-// ChildInfo
-//
-
-ChildInfo::ChildInfo(DWORD pid, HANDLE childProcessHandle,
-                     HANDLE writeToStdinHandle, HANDLE readFromStdoutHandle,
-                     HANDLE auxHandle1, HANDLE auxHandle2) {
-  this->pid = pid;
-  this->childProcessHandle = childProcessHandle;
-  this->writeToStdinHandle = writeToStdinHandle;
-  this->readFromStdoutHandle = readFromStdoutHandle;
-  this->auxHandle1 = auxHandle1;
-  this->auxHandle2 = auxHandle2;
-  client = NULL;
-}
-
-DWORD
-ChildInfo::getPid() {
-  return pid;
-}
-
-HANDLE
-ChildInfo::getChildProcessHandle() {
-  return childProcessHandle;
-}
-
-HANDLE
-ChildInfo::getWriteToStdinHandle() {
-  return writeToStdinHandle;
-}
-
-HANDLE
-ChildInfo::getReadFromStdoutHandle() {
-  return readFromStdoutHandle;
-}
-
-void
-ChildInfo::setClient(ClientInfo* clientInfo) {
-  client = clientInfo;
-}
-
-ClientInfo*
-ChildInfo::getClient() {
-  return client;
-}
-
-void
-ChildInfo::closeAll() {
-  CloseHandle(childProcessHandle);
-  CloseHandle(writeToStdinHandle);
-  CloseHandle(readFromStdoutHandle);
-  CloseHandle(auxHandle1);
-  CloseHandle(auxHandle2);
-}
-
-//----------------------------------------------------------------------
-// ChildList
-//
-
-ChildList::ChildList() {
-}
-
-ChildList::~ChildList() {
-}
-
-void
-ChildList::addChild(ChildInfo* info) {
-  // Could store these in binary sorted order by pid for efficiency
-  childList.push_back(info);
-}
-
-ChildInfo*
-ChildList::removeChild(HANDLE childProcessHandle) {
-  for (ChildInfoList::iterator iter = childList.begin(); iter != childList.end();
-       iter++) {
-    ChildInfo* info = *iter;
-    if (info->getChildProcessHandle() == childProcessHandle) {
-      childList.erase(iter);
-      return info;
-    }
-  }
-  assert(false);
-  return NULL;
-}
-
-void
-ChildList::removeChild(ChildInfo* info) {
-  for (ChildInfoList::iterator iter = childList.begin(); iter != childList.end();
-       iter++) {
-    if (*iter == info) {
-      childList.erase(iter);
-      return;
-    }
-  }
-  assert(false);
-}
-
-ChildInfo*
-ChildList::getChildByPid(DWORD pid) {
-  for (ChildInfoList::iterator iter = childList.begin(); iter != childList.end();
-       iter++) {
-    ChildInfo* info = *iter;
-    if (info->getPid() == pid) {
-      return info;
-    }
-  }
-  return NULL;
-}
-
-int
-ChildList::size() {
-  return childList.size();
-}
-
-ChildInfo*
-ChildList::getChildByIndex(int index) {
-  return childList[index];
-}
-
-//----------------------------------------------------------------------
-// ClientInfo
-//
-
-ClientInfo::ClientInfo(SOCKET dataSocket) {
-  this->dataSocket = dataSocket;
-  buf = new IOBuf(32768, 131072);
-  buf->setSocket(dataSocket);
-  target = NULL;
-}
-
-ClientInfo::~ClientInfo() {
-  delete buf;
-}
-
-SOCKET
-ClientInfo::getDataSocket() {
-  return dataSocket;
-}
-
-IOBuf*
-ClientInfo::getIOBuf() {
-  return buf;
-}
-
-void
-ClientInfo::setTarget(ChildInfo* childInfo) {
-  target = childInfo;
-}
-
-ChildInfo*
-ClientInfo::getTarget() {
-  return target;
-}
-
-void
-ClientInfo::closeAll() {
-  shutdown(dataSocket, SD_BOTH);
-  closesocket(dataSocket);
-  dataSocket = INVALID_SOCKET;
-}
-
-//----------------------------------------------------------------------
-// ClientList
-//
-
-ClientList::ClientList() {
-}
-
-ClientList::~ClientList() {
-}
-
-void
-ClientList::addClient(ClientInfo* info) {
-  clientList.push_back(info);
-}
-
-bool
-ClientList::isAnyDataSocketSet(fd_set* fds, ClientInfo** out) {
-  for (ClientInfoList::iterator iter = clientList.begin(); iter != clientList.end();
-       iter++) {
-    ClientInfo* info = *iter;
-    if (FD_ISSET(info->getDataSocket(), fds)) {
-      *out = info;
-      return true;
-    }
-  }
-  return false;
-}
-
-void
-ClientList::removeClient(ClientInfo* client) {
-  for (ClientInfoList::iterator iter = clientList.begin(); iter != clientList.end();
-       iter++) {
-    if (*iter == client) {
-      clientList.erase(iter);
-      return;
-    }
-  }
-  assert(false);
-}
-
-int
-ClientList::size() {
-  return clientList.size();
-}
-
-ClientInfo*
-ClientList::get(int num) {
-  return clientList[num];
-}
--- a/hotspot/agent/src/os/win32/serverLists.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * 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 _SERVER_LISTS_
-#define _SERVER_LISTS_
-
-#include <vector>
-#include <winsock2.h>
-#include "IOBuf.hpp"
-
-//
-// NOTE:
-//
-// All of these lists are guarded by the global lock managed by the
-// Lists class. Lists::init() must be called at the start of the
-// program.
-//
-
-class Lists {
-  friend class ListsLocker;
-public:
-  static void init();
-private:
-  static void lock();
-  static void unlock();
-  static CRITICAL_SECTION crit;
-};
-
-// Should be allocated on stack. Ensures proper locking/unlocking
-// pairing.
-class ListsLocker {
-public:
-  ListsLocker();
-  ~ListsLocker();
-};
-
-// We must keep track of all of the child processes we have forked to
-// handle attaching to a target process. This is necessary because we
-// allow clients to detach from processes, but the child processes we
-// fork must necessarily stay alive for the duration of the target
-// application. A subsequent attach operation to the target process
-// results in the same child process being reused. For this reason,
-// child processes are known to be in one of two states: attached and
-// detached.
-
-class ClientInfo;
-
-class ChildInfo {
-public:
-  /** The pid of the ChildInfo indicates the process ID of the target
-      process which the subprocess was created to debug, not the pid
-      of the subprocess itself. */
-  ChildInfo(DWORD pid, HANDLE childProcessHandle,
-            HANDLE writeToStdinHandle, HANDLE readFromStdoutHandle,
-            HANDLE auxHandle1, HANDLE auxHandle2);
-
-  DWORD getPid();
-  HANDLE getChildProcessHandle();
-  HANDLE getWriteToStdinHandle();
-  HANDLE getReadFromStdoutHandle();
-
-  /** Set the client which is currently attached to the target process
-      via this child process. Set this to NULL to indicate that the
-      child process is ready to accept another attachment. */
-  void setClient(ClientInfo* clientInfo);
-
-  ClientInfo* getClient();
-
-  /** This is NOT automatically called in the destructor */
-  void closeAll();
-
-private:
-  DWORD pid;
-  HANDLE childProcessHandle;
-  HANDLE writeToStdinHandle;
-  HANDLE readFromStdoutHandle;
-  HANDLE auxHandle1;
-  HANDLE auxHandle2;
-  ClientInfo* client;
-};
-
-// We keep track of a list of child debugger processes, each of which
-// is responsible for debugging a certain target process. These
-// debugger processes can serve multiple clients during their
-// lifetime. When a client detaches from a given process or tells the
-// debugger to "exit", the debug server is notified that the child
-// process is once again available to accept connections from clients.
-
-class ChildList {
-private:
-  typedef std::vector<ChildInfo*> ChildInfoList;
-
-public:
-  ChildList();
-  ~ChildList();
-
-  void addChild(ChildInfo*);
-
-  /** Removes and returns the ChildInfo* associated with the given
-      child process handle. */
-  ChildInfo* removeChild(HANDLE childProcessHandle);
-
-  /** Removes the given ChildInfo. */
-  void removeChild(ChildInfo* info);
-
-  /** Return the ChildInfo* associated with a given process ID without
-      removing it from the list. */
-  ChildInfo* getChildByPid(DWORD pid);
-
-  /** Iteration support */
-  int size();
-
-  /** Iteration support */
-  ChildInfo* getChildByIndex(int index);
-
-private:
-  ChildInfoList childList;
-};
-
-// We also keep a list of clients whose requests we are responsible
-// for serving. Clients can attach and detach from child processes.
-
-class ClientInfo {
-public:
-  ClientInfo(SOCKET dataSocket);
-  ~ClientInfo();
-
-  SOCKET getDataSocket();
-  /** Gets an IOBuf configured for the data socket, which should be
-      used for all communication with the client. */
-  IOBuf* getIOBuf();
-
-  /** Set the information for the process to which this client is
-      attached. Set this to NULL to indicate that the client is not
-      currently attached to any target process. */
-  void setTarget(ChildInfo* childInfo);
-
-  /** Get the information for the process to which this client is
-      currently attached, or NULL if none. */
-  ChildInfo* getTarget();
-
-  /** Close down the socket connection to this client. This is NOT
-      automatically called by the destructor. */
-  void closeAll();
-
-private:
-  SOCKET dataSocket;
-  IOBuf* buf;
-  ChildInfo* target;
-};
-
-class ClientList {
-private:
-  typedef std::vector<ClientInfo*> ClientInfoList;
-
-public:
-  ClientList();
-  ~ClientList();
-
-  /** Adds a client to the list. */
-  void addClient(ClientInfo* info);
-
-  /** Check to see whether the parent socket of any of the ClientInfo
-      objects is readable in the given fd_set. If so, returns TRUE and
-      sets the given ClientInfo* (a non-NULL pointer to which must be
-      given) appropriately. */
-  bool isAnyDataSocketSet(fd_set* fds, ClientInfo** info);
-
-  /** Removes a client from the list. User is responsible for deleting
-      the ClientInfo* using operator delete. */
-  void removeClient(ClientInfo* client);
-
-  /** Iteration support. */
-  int size();
-
-  /** Iteration support. */
-  ClientInfo* get(int num);
-
-private:
-  ClientInfoList clientList;
-};
-
-#endif  // #defined _SERVER_LISTS_
--- a/hotspot/agent/src/os/win32/toolHelp.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 "toolHelp.hpp"
-#include <assert.h>
-
-namespace ToolHelp {
-
-static HMODULE kernelDLL = NULL;
-
-HMODULE loadDLL() {
-  if (kernelDLL == NULL) {
-    kernelDLL = LoadLibrary("KERNEL32.DLL");
-  }
-
-  assert(kernelDLL != NULL);
-  return kernelDLL;
-}
-
-void unloadDLL() {
-  if (kernelDLL != NULL) {
-    FreeLibrary(kernelDLL);
-    kernelDLL = NULL;
-  }
-}
-
-} // namespace ToolHelp
--- a/hotspot/agent/src/os/win32/toolHelp.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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 _TOOLHELP_H_
-#define _TOOLHELP_H_
-
-#include <windows.h>
-#include <tlhelp32.h>
-
-namespace ToolHelp {
-extern "C" {
-
-  ///////////////
-  // Snapshots //
-  ///////////////
-  typedef HANDLE WINAPI
-  CreateToolhelp32SnapshotFunc(DWORD dwFlags, DWORD th32ProcessID);
-
-  //////////////////
-  // Process List //
-  //////////////////
-  typedef BOOL WINAPI Process32FirstFunc(HANDLE hSnapshot,
-                                         LPPROCESSENTRY32 lppe);
-
-  typedef BOOL WINAPI Process32NextFunc(HANDLE hSnapshot,
-                                        LPPROCESSENTRY32 lppe);
-
-  // NOTE: although these routines are defined in TLHELP32.H, they
-  // seem to always return false (maybe only under US locales)
-  typedef BOOL WINAPI Process32FirstWFunc(HANDLE hSnapshot,
-                                          LPPROCESSENTRY32W lppe);
-
-  typedef BOOL WINAPI Process32NextWFunc(HANDLE hSnapshot,
-                                         LPPROCESSENTRY32W lppe);
-
-  /////////////////
-  // Module List //
-  /////////////////
-  typedef BOOL WINAPI
-  Module32FirstFunc(HANDLE hSnapshot, LPMODULEENTRY32 lpme);
-
-  typedef BOOL WINAPI
-  Module32NextFunc (HANDLE hSnapshot, LPMODULEENTRY32 lpme);
-
-
-  // Routines to load and unload KERNEL32.DLL.
-  HMODULE loadDLL();
-  // Safe to call even if has not been loaded
-  void    unloadDLL();
-
-} // extern "C"
-} // namespace "ToolHelp"
-
-#endif // #defined _TOOLHELP_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/BsdVtblAccess.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.types.basic.*;
+
+public class BsdVtblAccess extends BasicVtblAccess {
+  private String vt;
+
+  public BsdVtblAccess(SymbolLookup symbolLookup,
+                         String[] dllNames) {
+    super(symbolLookup, dllNames);
+
+    if (symbolLookup.lookup("libjvm.so", "__vt_10JavaThread") != null ||
+        symbolLookup.lookup("libjvm_g.so", "__vt_10JavaThread") != null) {
+       // old C++ ABI
+       vt = "__vt_";
+    } else {
+       // new C++ ABI
+       vt = "_ZTV";
+    }
+  }
+
+  protected String vtblSymbolForType(Type type) {
+    return vt + type.getName().length() + type;
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -170,6 +170,7 @@
             final String errMsg = formatMessage(e.getMessage(), 80);
             System.err.println("Unable to connect to process ID " + pid + ":\n\n" + errMsg);
             agent.detach();
+            e.printStackTrace();
             return;
         }
     }
@@ -191,6 +192,7 @@
             final String errMsg = formatMessage(e.getMessage(), 80);
             System.err.println("Unable to open core file\n" + corePath + ":\n\n" + errMsg);
             agent.detach();
+            e.printStackTrace();
             return;
         }
     }
@@ -209,6 +211,7 @@
             final String errMsg = formatMessage(e.getMessage(), 80);
             System.err.println("Unable to connect to machine \"" + remoteMachineName + "\":\n\n" + errMsg);
             agent.detach();
+            e.printStackTrace();
             return;
         }
     }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java	Wed Oct 26 17:59:13 2011 -0700
@@ -40,6 +40,8 @@
 import sun.jvm.hotspot.interpreter.*;
 import sun.jvm.hotspot.memory.*;
 import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.opto.*;
+import sun.jvm.hotspot.ci.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.utilities.*;
 import sun.jvm.hotspot.utilities.soql.*;
@@ -48,6 +50,8 @@
 import sun.jvm.hotspot.tools.*;
 import sun.jvm.hotspot.tools.ObjectHistogram;
 import sun.jvm.hotspot.tools.StackTrace;
+import sun.jvm.hotspot.tools.jcore.ClassDump;
+import sun.jvm.hotspot.tools.jcore.ClassFilter;
 
 public class CommandProcessor {
     public abstract static class DebuggerInterface {
@@ -59,6 +63,27 @@
         public abstract void reattach();
     }
 
+    public static class BootFilter implements ClassFilter {
+        public boolean canInclude(InstanceKlass kls) {
+            return kls.getClassLoader() == null;
+        }
+    }
+
+    public static class NonBootFilter implements ClassFilter {
+        private HashMap emitted = new HashMap();
+        public boolean canInclude(InstanceKlass kls) {
+            if (kls.getClassLoader() == null) return false;
+            if (emitted.get(kls.getName()) != null) {
+                // Since multiple class loaders are being shoved
+                // together duplicate classes are a possibilty.  For
+                // now just ignore them.
+                return false;
+            }
+            emitted.put(kls.getName(), kls);
+            return true;
+        }
+    }
+
     static class Tokens {
         final String input;
         int i;
@@ -258,9 +283,14 @@
     }
 
     void dumpFields(Type type) {
+        dumpFields(type, true);
+    }
+
+    void dumpFields(Type type, boolean allowStatic) {
         Iterator i = type.getFields();
         while (i.hasNext()) {
             Field f = (Field) i.next();
+            if (!allowStatic && f.isStatic()) continue;
             out.print("field ");
             quote(type.getName());
             out.print(" ");
@@ -458,13 +488,18 @@
                     });
             }
         },
-        new Command("flags", "flags [ flag ]", false) {
+        new Command("flags", "flags [ flag | -nd ]", false) {
             public void doit(Tokens t) {
                 int tokens = t.countTokens();
                 if (tokens != 0 && tokens != 1) {
                     usage();
                 } else {
                     String name = tokens > 0 ? t.nextToken() : null;
+                    boolean nonDefault = false;
+                    if (name != null && name.equals("-nd")) {
+                        name = null;
+                        nonDefault = true;
+                    }
 
                     VM.Flag[] flags = VM.getVM().getCommandLineFlags();
                     if (flags == null) {
@@ -474,7 +509,12 @@
                         for (int f = 0; f < flags.length; f++) {
                             VM.Flag flag = flags[f];
                             if (name == null || flag.getName().equals(name)) {
-                                out.println(flag.getName() + " = " + flag.getValue());
+
+                                if (nonDefault && flag.getOrigin() == 0) {
+                                    // only print flags which aren't their defaults
+                                    continue;
+                                }
+                                out.println(flag.getName() + " = " + flag.getValue() + " " + flag.getOrigin());
                                 printed = true;
                             }
                         }
@@ -586,6 +626,158 @@
                 }
             }
         },
+        new Command("printmdo", "printmdo [ -a | expression ]", false) {
+            // Print every MDO in the heap or the one referenced by expression.
+            public void doit(Tokens t) {
+                if (t.countTokens() != 1) {
+                    usage();
+                } else {
+                    String s = t.nextToken();
+                    if (s.equals("-a")) {
+                        HeapVisitor iterator = new DefaultHeapVisitor() {
+                                public boolean doObj(Oop obj) {
+                                    if (obj instanceof MethodData) {
+                                        Method m = ((MethodData)obj).getMethod();
+                                        out.println("MethodData " + obj.getHandle() + " for " +
+                                                    "method " + m.getMethodHolder().getName().asString() + "." +
+                                                    m.getName().asString() +
+                                                    m.getSignature().asString() + "@" + m.getHandle());
+                                        ((MethodData)obj).printDataOn(out);
+                                    }
+                                    return false;
+                                }
+                            };
+                        VM.getVM().getObjectHeap().iteratePerm(iterator);
+                    } else {
+                        Address a = VM.getVM().getDebugger().parseAddress(s);
+                        OopHandle handle = a.addOffsetToAsOopHandle(0);
+                        MethodData mdo = (MethodData)VM.getVM().getObjectHeap().newOop(handle);
+                        mdo.printDataOn(out);
+                    }
+                }
+            }
+        },
+        new Command("dumpideal", "dumpideal { -a | id }", false) {
+            // Do a full dump of the nodes reachabile from root in each compiler thread.
+            public void doit(Tokens t) {
+                if (t.countTokens() != 1) {
+                    usage();
+                } else {
+                    String name = t.nextToken();
+                    boolean all = name.equals("-a");
+                    Threads threads = VM.getVM().getThreads();
+                    for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
+                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                        thread.printThreadIDOn(new PrintStream(bos));
+                        if (all || bos.toString().equals(name)) {
+                          if (thread instanceof CompilerThread) {
+                            CompilerThread ct = (CompilerThread)thread;
+                            out.println(ct);
+                            ciEnv env = ct.env();
+                            if (env != null) {
+                              Compile c = env.compilerData();
+                              c.root().dump(9999, out);
+                            } else {
+                              out.println("  not compiling");
+                            }
+                          }
+                        }
+                    }
+                }
+            }
+        },
+        new Command("dumpcfg", "dumpcfg { -a | id }", false) {
+            // Dump the PhaseCFG for every compiler thread that has one live.
+            public void doit(Tokens t) {
+                if (t.countTokens() != 1) {
+                    usage();
+                } else {
+                    String name = t.nextToken();
+                    boolean all = name.equals("-a");
+                    Threads threads = VM.getVM().getThreads();
+                    for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
+                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                        thread.printThreadIDOn(new PrintStream(bos));
+                        if (all || bos.toString().equals(name)) {
+                          if (thread instanceof CompilerThread) {
+                            CompilerThread ct = (CompilerThread)thread;
+                            out.println(ct);
+                            ciEnv env = ct.env();
+                            if (env != null) {
+                              Compile c = env.compilerData();
+                              c.cfg().dump(out);
+                            }
+                          }
+                        }
+                    }
+                }
+            }
+        },
+        new Command("dumpilt", "dumpilt { -a | id }", false) {
+            // dumps the InlineTree of a C2 compile
+            public void doit(Tokens t) {
+                if (t.countTokens() != 1) {
+                    usage();
+                } else {
+                    String name = t.nextToken();
+                    boolean all = name.equals("-a");
+                    Threads threads = VM.getVM().getThreads();
+                    for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
+                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                        thread.printThreadIDOn(new PrintStream(bos));
+                        if (all || bos.toString().equals(name)) {
+                            if (thread instanceof CompilerThread) {
+                                CompilerThread ct = (CompilerThread)thread;
+                                ciEnv env = ct.env();
+                                if (env != null) {
+                                    Compile c = env.compilerData();
+                                    InlineTree ilt = c.ilt();
+                                    if (ilt != null) {
+                                        ilt.print(out);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        },
+        new Command("vmstructsdump", "vmstructsdump", false) {
+            public void doit(Tokens t) {
+                if (t.countTokens() != 0) {
+                    usage();
+                    return;
+                }
+
+                // Dump a copy of the type database in a form that can
+                // be read back.
+                Iterator i = agent.getTypeDataBase().getTypes();
+                // Make sure the types are emitted in an order than can be read back in
+                HashSet emitted = new HashSet();
+                Stack pending = new Stack();
+                while (i.hasNext()) {
+                    Type n = (Type)i.next();
+                    if (emitted.contains(n.getName())) {
+                        continue;
+                    }
+
+                    while (n != null && !emitted.contains(n.getName())) {
+                        pending.push(n);
+                        n = n.getSuperclass();
+                    }
+                    while (!pending.empty()) {
+                        n = (Type)pending.pop();
+                        dumpType(n);
+                        emitted.add(n.getName());
+                    }
+                }
+                i = agent.getTypeDataBase().getTypes();
+                while (i.hasNext()) {
+                    dumpFields((Type)i.next(), false);
+                }
+            }
+        },
+
         new Command("inspect", "inspect expression", false) {
             public void doit(Tokens t) {
                 if (t.countTokens() != 1) {
@@ -760,6 +952,50 @@
                 }
             }
         },
+        new Command("intConstant", "intConstant [ name [ value ] ]", true) {
+            public void doit(Tokens t) {
+                if (t.countTokens() != 1 && t.countTokens() != 0 && t.countTokens() != 2) {
+                    usage();
+                    return;
+                }
+                HotSpotTypeDataBase db = (HotSpotTypeDataBase)agent.getTypeDataBase();
+                if (t.countTokens() == 1) {
+                    out.println("intConstant " + name + " " + db.lookupIntConstant(name));
+                } else if (t.countTokens() == 0) {
+                    Iterator i = db.getIntConstants();
+                    while (i.hasNext()) {
+                        String name = (String)i.next();
+                        out.println("intConstant " + name + " " + db.lookupIntConstant(name));
+                    }
+                } else if (t.countTokens() == 2) {
+                    String name = t.nextToken();
+                    Integer value = Integer.valueOf(t.nextToken());
+                    db.addIntConstant(name, value);
+                }
+            }
+        },
+        new Command("longConstant", "longConstant [ name [ value ] ]", true) {
+            public void doit(Tokens t) {
+                if (t.countTokens() != 1 && t.countTokens() != 0 && t.countTokens() != 2) {
+                    usage();
+                    return;
+                }
+                HotSpotTypeDataBase db = (HotSpotTypeDataBase)agent.getTypeDataBase();
+                if (t.countTokens() == 1) {
+                    out.println("longConstant " + name + " " + db.lookupLongConstant(name));
+                } else if (t.countTokens() == 0) {
+                    Iterator i = db.getLongConstants();
+                    while (i.hasNext()) {
+                        String name = (String)i.next();
+                        out.println("longConstant " + name + " " + db.lookupLongConstant(name));
+                    }
+                } else if (t.countTokens() == 2) {
+                    String name = t.nextToken();
+                    Long value = Long.valueOf(t.nextToken());
+                    db.addLongConstant(name, value);
+                }
+            }
+        },
         new Command("field", "field [ type [ name fieldtype isStatic offset address ] ]", true) {
             public void doit(Tokens t) {
                 if (t.countTokens() != 1 && t.countTokens() != 0 && t.countTokens() != 6) {
@@ -1311,13 +1547,13 @@
                 return;
             }
 
-            executeCommand(ln);
+            executeCommand(ln, prompt);
         }
     }
 
     static Pattern historyPattern = Pattern.compile("((!\\*)|(!\\$)|(!!-?)|(!-?[0-9][0-9]*)|(![a-zA-Z][^ ]*))");
 
-    public void executeCommand(String ln) {
+    public void executeCommand(String ln, boolean putInHistory) {
         if (ln.indexOf('!') != -1) {
             int size = history.size();
             if (size == 0) {
@@ -1406,7 +1642,7 @@
         Tokens t = new Tokens(ln);
         if (t.hasMoreTokens()) {
             boolean error = false;
-            history.add(ln);
+            if (putInHistory) history.add(ln);
             int len = t.countTokens();
             if (len > 2) {
                 String r = t.at(len - 2);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/DebugServer.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/DebugServer.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 package sun.jvm.hotspot;
 
 import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.dbx.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.oops.*;
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1740,7 +1740,7 @@
       else if (f.isCompiledFrame())    { tty.print("compiled"); }
       else if (f.isEntryFrame())       { tty.print("entry"); }
       else if (f.isNativeFrame())      { tty.print("native"); }
-      else if (f.isGlueFrame())        { tty.print("glue"); }
+      else if (f.isRuntimeFrame())     { tty.print("runtime"); }
       else { tty.print("external"); }
       tty.print(" frame with PC = " + f.getPC() + ", SP = " + f.getSP() + ", FP = " + f.getFP());
       if (f.isSignalHandlerFrameDbg()) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotAgent.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,10 +28,9 @@
 import java.net.*;
 import java.rmi.*;
 import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.dbx.*;
+import sun.jvm.hotspot.debugger.bsd.*;
 import sun.jvm.hotspot.debugger.proc.*;
 import sun.jvm.hotspot.debugger.remote.*;
-import sun.jvm.hotspot.debugger.win32.*;
 import sun.jvm.hotspot.debugger.windbg.*;
 import sun.jvm.hotspot.debugger.linux.*;
 import sun.jvm.hotspot.memory.*;
@@ -337,6 +336,8 @@
                 setupDebuggerWin32();
             } else if (os.equals("linux")) {
                 setupDebuggerLinux();
+            } else if (os.equals("bsd")) {
+                setupDebuggerBsd();
             } else {
                 // Add support for more operating systems here
                 throw new DebuggerException("Operating system " + os + " not yet supported");
@@ -392,6 +393,10 @@
                 db = new HotSpotTypeDataBase(machDesc,
                 new LinuxVtblAccess(debugger, jvmLibNames),
                 debugger, jvmLibNames);
+            } else if (os.equals("bsd")) {
+                db = new HotSpotTypeDataBase(machDesc,
+                new BsdVtblAccess(debugger, jvmLibNames),
+                debugger, jvmLibNames);
             } else {
                 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess yet)");
             }
@@ -436,113 +441,35 @@
 
     private void setupDebuggerSolaris() {
         setupJVMLibNamesSolaris();
-        if(System.getProperty("sun.jvm.hotspot.debugger.useProcDebugger") != null) {
-            ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true);
-            debugger = dbg;
-            attachDebugger();
-
-            // Set up CPU-dependent stuff
-            if (cpu.equals("x86")) {
-                machDesc = new MachineDescriptionIntelX86();
-            } else if (cpu.equals("sparc")) {
-                int addressSize = dbg.getRemoteProcessAddressSize();
-                if (addressSize == -1) {
-                    throw new DebuggerException("Error occurred while trying to determine the remote process's " +
-                    "address size");
-                }
+        ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true);
+        debugger = dbg;
+        attachDebugger();
 
-                if (addressSize == 32) {
-                    machDesc = new MachineDescriptionSPARC32Bit();
-                } else if (addressSize == 64) {
-                    machDesc = new MachineDescriptionSPARC64Bit();
-                } else {
-                    throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
-                }
-            } else if (cpu.equals("amd64")) {
-                machDesc = new MachineDescriptionAMD64();
-            } else {
-                throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
-            }
-
-            dbg.setMachineDescription(machDesc);
-            return;
-
-        } else {
-            String dbxPathName;
-            String dbxPathPrefix;
-            String dbxSvcAgentDSOPathName;
-            String dbxSvcAgentDSOPathPrefix;
-            String[] dbxSvcAgentDSOPathNames = null;
-
-            // use path names/prefixes specified on command
-            dbxPathName = System.getProperty("dbxPathName");
-            if (dbxPathName == null) {
-                dbxPathPrefix = System.getProperty("dbxPathPrefix");
-                if (dbxPathPrefix == null) {
-                    dbxPathPrefix = defaultDbxPathPrefix;
-                }
-                dbxPathName = dbxPathPrefix + fileSep + os + fileSep + cpu + fileSep + "bin" + fileSep + "dbx";
+        // Set up CPU-dependent stuff
+        if (cpu.equals("x86")) {
+            machDesc = new MachineDescriptionIntelX86();
+        } else if (cpu.equals("sparc")) {
+            int addressSize = dbg.getRemoteProcessAddressSize();
+            if (addressSize == -1) {
+                throw new DebuggerException("Error occurred while trying to determine the remote process's " +
+                                            "address size");
             }
 
-            dbxSvcAgentDSOPathName = System.getProperty("dbxSvcAgentDSOPathName");
-            if (dbxSvcAgentDSOPathName != null) {
-                dbxSvcAgentDSOPathNames = new String[] { dbxSvcAgentDSOPathName } ;
+            if (addressSize == 32) {
+                machDesc = new MachineDescriptionSPARC32Bit();
+            } else if (addressSize == 64) {
+                machDesc = new MachineDescriptionSPARC64Bit();
             } else {
-                dbxSvcAgentDSOPathPrefix = System.getProperty("dbxSvcAgentDSOPathPrefix");
-                if (dbxSvcAgentDSOPathPrefix == null) {
-                    dbxSvcAgentDSOPathPrefix = defaultDbxSvcAgentDSOPathPrefix;
-                }
-                if (cpu.equals("sparc")) {
-                    dbxSvcAgentDSOPathNames = new String[] {
-                        // FIXME: bad hack for SPARC v9. This is necessary because
-                        // there are two dbx executables on SPARC, one for v8 and one
-                        // for v9, and it isn't obvious how to tell the two apart
-                        // using the dbx command line. See
-                        // DbxDebuggerLocal.importDbxModule().
-                        dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + "v9" + fileSep + "lib" +
-                        fileSep + "libsvc_agent_dbx.so",
-                        dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + fileSep + "lib" +
-                        fileSep + "libsvc_agent_dbx.so",
-                    };
-                } else {
-                    dbxSvcAgentDSOPathNames = new String[] {
-                        dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + fileSep + "lib" +
-                        fileSep + "libsvc_agent_dbx.so"
-                    };
-                }
+                throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
             }
+        } else if (cpu.equals("amd64")) {
+            machDesc = new MachineDescriptionAMD64();
+        } else {
+            throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
+        }
 
-            // Note we do not use a cache for the local debugger in server
-            // mode; it's taken care of on the client side
-            DbxDebuggerLocal dbg = new DbxDebuggerLocal(null, dbxPathName, dbxSvcAgentDSOPathNames, !isServer);
-            debugger = dbg;
-
-            attachDebugger();
-
-            // Set up CPU-dependent stuff
-            if (cpu.equals("x86")) {
-                machDesc = new MachineDescriptionIntelX86();
-            } else if (cpu.equals("sparc")) {
-                int addressSize = dbg.getRemoteProcessAddressSize();
-                if (addressSize == -1) {
-                    throw new DebuggerException("Error occurred while trying to determine the remote process's " +
-                    "address size. It's possible that the Serviceability Agent's dbx module failed to " +
-                    "initialize. Examine the standard output and standard error streams from the dbx " +
-                    "process for more information.");
-                }
-
-                if (addressSize == 32) {
-                    machDesc = new MachineDescriptionSPARC32Bit();
-                } else if (addressSize == 64) {
-                    machDesc = new MachineDescriptionSPARC64Bit();
-                } else {
-                    throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
-                }
-            }
-
-            dbg.setMachineDescription(machDesc);
-
-        }
+        dbg.setMachineDescription(machDesc);
+        return;
     }
 
     private void connectRemoteDebugger() throws DebuggerException {
@@ -557,6 +484,8 @@
             setupJVMLibNamesWin32();
         } else if (os.equals("linux")) {
             setupJVMLibNamesLinux();
+        } else if (os.equals("bsd")) {
+            setupJVMLibNamesBsd();
         } else {
             throw new RuntimeException("Unknown OS type");
         }
@@ -589,11 +518,7 @@
         // mode; it will be taken care of on the client side (once remote
         // debugging is implemented).
 
-        if (System.getProperty("sun.jvm.hotspot.debugger.useWindbgDebugger") != null) {
-            debugger = new WindbgDebuggerLocal(machDesc, !isServer);
-        } else {
-            debugger = new Win32DebuggerLocal(machDesc, !isServer);
-        }
+        debugger = new WindbgDebuggerLocal(machDesc, !isServer);
 
         attachDebugger();
 
@@ -638,6 +563,31 @@
         jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
     }
 
+    //
+    // BSD
+    //
+
+    private void setupDebuggerBsd() {
+        setupJVMLibNamesBsd();
+
+        if (cpu.equals("x86")) {
+            machDesc = new MachineDescriptionIntelX86();
+        } else if (cpu.equals("amd64")) {
+            machDesc = new MachineDescriptionAMD64();
+        } else {
+            throw new DebuggerException("BSD only supported on x86/amd64");
+        }
+
+        BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);
+        debugger = dbg;
+
+        attachDebugger();
+    }
+
+    private void setupJVMLibNamesBsd() {
+        jvmLibNames = new String[] { "libjvm.so", "libjvm_g.so" };
+    }
+
     /** Convenience routine which should be called by per-platform
       debugger setup. Should not be called when startupMode is
       REMOTE_MODE. */
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java	Wed Oct 26 17:59:13 2011 -0700
@@ -87,6 +87,7 @@
     readVMStructs();
     readVMIntConstants();
     readVMLongConstants();
+    readExternalDefinitions();
   }
 
   public Type lookupType(String cTypeName, boolean throwException) {
@@ -98,9 +99,9 @@
         fieldType = (BasicType)lookupType(cTypeName.substring(0, cTypeName.length() - 6), false);
     }
     if (fieldType == null) {
-      if (cTypeName.startsWith("GrowableArray<") && cTypeName.endsWith(">*")) {
+      if (cTypeName.startsWith("GrowableArray<") && cTypeName.endsWith(">")) {
         String ttype = cTypeName.substring("GrowableArray<".length(),
-                                            cTypeName.length() - 2);
+                                            cTypeName.length() - 1);
         Type templateType = lookupType(ttype, false);
         if (templateType == null && typeNameIsPointerType(ttype)) {
           templateType = recursiveCreateBasicPointerType(ttype);
@@ -108,7 +109,21 @@
         if (templateType == null) {
           lookupOrFail(ttype);
         }
-        fieldType = recursiveCreateBasicPointerType(cTypeName);
+
+        BasicType basicTargetType = createBasicType(cTypeName, false, false, false);
+
+        // transfer fields from GenericGrowableArray to template instance
+        BasicType generic = lookupOrFail("GenericGrowableArray");
+        BasicType specific = lookupOrFail("GrowableArray<int>");
+        basicTargetType.setSize(specific.getSize());
+        Iterator fields = generic.getFields();
+        while (fields.hasNext()) {
+          Field f = (Field)fields.next();
+          basicTargetType.addField(internalCreateField(basicTargetType, f.getName(),
+                                                       f.getType(), f.isStatic(),
+                                                       f.getOffset(), null));
+        }
+        fieldType = basicTargetType;
       }
     }
     if (fieldType == null && typeNameIsPointerType(cTypeName)) {
@@ -208,6 +223,156 @@
     return type;
   }
 
+  private void readExternalDefinitions() {
+    String file = System.getProperty("sun.jvm.hotspot.typedb");
+    if (file != null) {
+      System.out.println("Reading " + file);
+      BufferedReader in = null;
+      try {
+        StreamTokenizer t = new StreamTokenizer(in = new BufferedReader(new InputStreamReader(new FileInputStream(file))));
+        t.resetSyntax();
+        t.wordChars('\u0000','\uFFFF');
+        t.whitespaceChars(' ', ' ');
+        t.whitespaceChars('\n', '\n');
+        t.whitespaceChars('\r', '\r');
+        t.quoteChar('\"');
+        t.eolIsSignificant(true);
+        while (t.nextToken() != StreamTokenizer.TT_EOF) {
+          if (t.ttype == StreamTokenizer.TT_EOL) {
+            continue;
+          }
+
+          if (t.sval.equals("field")) {
+            t.nextToken();
+            BasicType containingType = (BasicType)lookupType(t.sval);
+            t.nextToken();
+            String fieldName = t.sval;
+
+            // The field's Type must already be in the database -- no exceptions
+            t.nextToken();
+            Type fieldType = lookupType(t.sval);
+            t.nextToken();
+            boolean isStatic = Boolean.valueOf(t.sval).booleanValue();
+            t.nextToken();
+            long offset = Long.parseLong(t.sval);
+            t.nextToken();
+            Address staticAddress = null;
+            if (isStatic) {
+              throw new InternalError("static fields not supported");
+            }
+
+            // check to see if the field already exists
+            Iterator i = containingType.getFields();
+            boolean defined = false;
+            while (i.hasNext()) {
+              Field f = (Field) i.next();
+              if (f.getName().equals(fieldName)) {
+                if (f.isStatic() != isStatic) {
+                  throw new RuntimeException("static/nonstatic mismatch: " + fieldName);
+                }
+                if (!isStatic) {
+                  if (f.getOffset() != offset) {
+                    throw new RuntimeException("bad redefinition of field offset: " + fieldName);
+                  }
+                } else {
+                  if (!f.getStaticFieldAddress().equals(staticAddress)) {
+                    throw new RuntimeException("bad redefinition of field location: " + fieldName);
+                  }
+                }
+                if (f.getType() != fieldType) {
+                  System.out.println(fieldType);
+                  System.out.println(f.getType());
+                  throw new RuntimeException("bad redefinition of field type: " + fieldName);
+                }
+                defined = true;
+                break;
+              }
+            }
+
+            if (!defined) {
+              // Create field by type
+              createField(containingType,
+                          fieldName, fieldType,
+                          isStatic,
+                          offset,
+                          staticAddress);
+            }
+          } else if (t.sval.equals("type")) {
+            t.nextToken();
+            String typeName = t.sval;
+            t.nextToken();
+            String superclassName = t.sval;
+            if (superclassName.equals("null")) {
+              superclassName = null;
+            }
+            t.nextToken();
+            boolean isOop = Boolean.valueOf(t.sval).booleanValue();
+            t.nextToken();
+            boolean isInteger = Boolean.valueOf(t.sval).booleanValue();
+            t.nextToken();
+            boolean isUnsigned = Boolean.valueOf(t.sval).booleanValue();
+            t.nextToken();
+            long size = Long.parseLong(t.sval);
+
+            BasicType type = null;
+            try {
+              type = (BasicType)lookupType(typeName);
+            } catch (RuntimeException e) {
+            }
+            if (type != null) {
+              if (type.isOopType() != isOop) {
+                throw new RuntimeException("oop mismatch in type definition: " + typeName);
+              }
+              if (type.isCIntegerType() != isInteger) {
+                throw new RuntimeException("integer type mismatch in type definition: " + typeName);
+              }
+              if (type.isCIntegerType() && (((CIntegerType)type).isUnsigned()) != isUnsigned) {
+                throw new RuntimeException("unsigned mismatch in type definition: " + typeName);
+              }
+              if (type.getSuperclass() == null) {
+                if (superclassName != null) {
+                  if (type.getSize() == -1) {
+                    type.setSuperclass(lookupType(superclassName));
+                  } else {
+                    throw new RuntimeException("unexpected superclass in type definition: " + typeName);
+                  }
+                }
+              } else {
+                if (superclassName == null) {
+                  throw new RuntimeException("missing superclass in type definition: " + typeName);
+                }
+                if (!type.getSuperclass().getName().equals(superclassName)) {
+                  throw new RuntimeException("incorrect superclass in type definition: " + typeName);
+                }
+              }
+              if (type.getSize() != size) {
+                if (type.getSize() == -1 || type.getSize() == 0) {
+                  type.setSize(size);
+                } else {
+                  throw new RuntimeException("size mismatch in type definition: " + typeName + ": " + type.getSize() + " != " + size);
+                }
+              }
+            }
+
+            if (lookupType(typeName, false) == null) {
+              // Create type
+              createType(typeName, superclassName, isOop, isInteger, isUnsigned, size);
+            }
+          } else {
+            throw new InternalError("\"" + t.sval + "\"");
+          }
+        }
+      } catch (IOException ioe) {
+        ioe.printStackTrace();
+      } finally {
+        try {
+          in.close();
+        } catch (Exception e) {
+        }
+      }
+    }
+  }
+
   private void readVMStructs() {
     // Get the variables we need in order to traverse the VMStructEntry[]
     long structEntryTypeNameOffset;
@@ -504,20 +669,6 @@
           BasicType basicTargetType = createBasicType(targetTypeName, false, true, true);
           basicTargetType.setSize(1);
           targetType = basicTargetType;
-        } else if (targetTypeName.startsWith("GrowableArray<")) {
-          BasicType basicTargetType = createBasicType(targetTypeName, false, false, false);
-
-          // transfer fields from GenericGrowableArray to template instance
-          BasicType generic = lookupOrFail("GenericGrowableArray");
-          basicTargetType.setSize(generic.getSize());
-          Iterator fields = generic.getFields();
-          while (fields.hasNext()) {
-              Field f = (Field)fields.next();
-              basicTargetType.addField(internalCreateField(basicTargetType, f.getName(),
-                                                           f.getType(), f.isStatic(),
-                                                           f.getOffset(), null));
-          }
-          targetType = basicTargetType;
         } else {
           if (DEBUG) {
             System.err.println("WARNING: missing target type \"" + targetTypeName + "\" for pointer type \"" + typeName + "\"");
@@ -572,7 +723,7 @@
 
         // Classes are created with a size of UNINITIALIZED_SIZE.
         // Set size if necessary.
-        if (curType.getSize() == UNINITIALIZED_SIZE) {
+        if (curType.getSize() == UNINITIALIZED_SIZE || curType.getSize() == 0) {
             curType.setSize(size);
         } else {
             if (curType.getSize() != size) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/TestDebugger.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/TestDebugger.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,12 @@
 package sun.jvm.hotspot;
 
 import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.dbx.*;
+import sun.jvm.hotspot.debugger.proc.*;
 
 // A test of the debugger backend. This should be used to connect to
 // the helloWorld.cpp program.
 
 public class TestDebugger {
-  // FIXME: make these configurable, i.e., via a dotfile
-  private static final String dbxPathName               = "/export/home/kbr/ws/dbx_61/dev/Derived-sparcv9-S2./src/dbx/dbx";
-  private static final String[] dbxSvcAgentDSOPathNames =
-    new String[] {
-      "/export/home/kbr/main/sa_baseline/src/os/solaris/agent/libsvc_agent_dbx.so"
-    };
 
   private static void usage() {
     System.out.println("usage: java TestDebugger [pid]");
@@ -58,8 +52,7 @@
         usage();
       }
 
-      JVMDebugger debugger = new DbxDebuggerLocal(new MachineDescriptionSPARC64Bit(),
-                                                  dbxPathName, dbxSvcAgentDSOPathNames, true);
+      JVMDebugger debugger = new ProcDebuggerLocal(null, true);
 
       try {
         debugger.attach(pid);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpot.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpot.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.debugger.cdbg.*;
 import sun.jvm.hotspot.debugger.posix.*;
-import sun.jvm.hotspot.debugger.win32.*;
+import sun.jvm.hotspot.debugger.windbg.*;
 import sun.jvm.hotspot.livejvm.*;
 import sun.jvm.hotspot.memory.*;
 import sun.jvm.hotspot.oops.*;
@@ -604,7 +604,7 @@
           throw new DebuggerException("Unsupported CPU \"" + cpu + "\" for Windows");
         }
 
-        localDebugger = new Win32DebuggerLocal(new MachineDescriptionIntelX86(), true);
+        localDebugger = new WindbgDebuggerLocal(new MachineDescriptionIntelX86(), true);
       } else if (os.equals("linux")) {
         if (!cpu.equals("x86")) {
           throw new DebuggerException("Unsupported CPU \"" + cpu + "\" for Linux");
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/bugspot/BugSpotAgent.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,10 +29,9 @@
 import java.rmi.*;
 import sun.jvm.hotspot.*;
 import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.dbx.*;
+import sun.jvm.hotspot.debugger.bsd.*;
 import sun.jvm.hotspot.debugger.proc.*;
 import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.debugger.win32.*;
 import sun.jvm.hotspot.debugger.windbg.*;
 import sun.jvm.hotspot.debugger.linux.*;
 import sun.jvm.hotspot.debugger.sparc.*;
@@ -516,6 +515,8 @@
                 setupDebuggerWin32();
             } else if (os.equals("linux")) {
                 setupDebuggerLinux();
+            } else if (os.equals("bsd")) {
+                setupDebuggerBsd();
             } else {
                 // Add support for more operating systems here
                 throw new DebuggerException("Operating system " + os + " not yet supported");
@@ -567,6 +568,9 @@
             } else if (os.equals("linux")) {
                 db = new HotSpotTypeDataBase(machDesc, new LinuxVtblAccess(debugger, jvmLibNames),
                 debugger, jvmLibNames);
+            } else if (os.equals("bsd")) {
+                db = new HotSpotTypeDataBase(machDesc, new BsdVtblAccess(debugger, jvmLibNames),
+                debugger, jvmLibNames);
             } else {
                 throw new DebuggerException("OS \"" + os + "\" not yet supported (no VtblAccess implemented yet)");
             }
@@ -627,104 +631,33 @@
 
     private void setupDebuggerSolaris() {
         setupJVMLibNamesSolaris();
-        String prop = System.getProperty("sun.jvm.hotspot.debugger.useProcDebugger");
-        if (prop != null && !prop.equals("false")) {
-            ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true);
-            debugger = dbg;
-            attachDebugger();
-
-            // Set up CPU-dependent stuff
-            if (cpu.equals("x86")) {
-                machDesc = new MachineDescriptionIntelX86();
-            } else if (cpu.equals("sparc")) {
-                int addressSize = dbg.getRemoteProcessAddressSize();
-                if (addressSize == -1) {
-                    throw new DebuggerException("Error occurred while trying to determine the remote process's address size");
-                }
+        ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true);
+        debugger = dbg;
+        attachDebugger();
 
-                if (addressSize == 32) {
-                    machDesc = new MachineDescriptionSPARC32Bit();
-                } else if (addressSize == 64) {
-                    machDesc = new MachineDescriptionSPARC64Bit();
-                } else {
-                    throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
-                }
-            } else if (cpu.equals("amd64")) {
-                machDesc = new MachineDescriptionAMD64();
-            } else {
-                throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
-            }
-
-            dbg.setMachineDescription(machDesc);
-            return;
-        } else {
-            String dbxPathName;
-            String dbxPathPrefix;
-            String dbxSvcAgentDSOPathName;
-            String dbxSvcAgentDSOPathPrefix;
-            String[] dbxSvcAgentDSOPathNames = null;
-
-            // use path names/prefixes specified on command
-            dbxPathName = System.getProperty("dbxPathName");
-            if (dbxPathName == null) {
-                dbxPathPrefix = System.getProperty("dbxPathPrefix");
-                if (dbxPathPrefix == null) {
-                    dbxPathPrefix = defaultDbxPathPrefix;
-                }
-                dbxPathName = dbxPathPrefix + fileSep + os + fileSep + cpu + fileSep + "bin" + fileSep + "dbx";
+        // Set up CPU-dependent stuff
+        if (cpu.equals("x86")) {
+            machDesc = new MachineDescriptionIntelX86();
+        } else if (cpu.equals("sparc")) {
+            int addressSize = dbg.getRemoteProcessAddressSize();
+            if (addressSize == -1) {
+                throw new DebuggerException("Error occurred while trying to determine the remote process's address size");
             }
 
-            dbxSvcAgentDSOPathName = System.getProperty("dbxSvcAgentDSOPathName");
-            if (dbxSvcAgentDSOPathName != null) {
-                dbxSvcAgentDSOPathNames = new String[] { dbxSvcAgentDSOPathName } ;
+            if (addressSize == 32) {
+                machDesc = new MachineDescriptionSPARC32Bit();
+            } else if (addressSize == 64) {
+                machDesc = new MachineDescriptionSPARC64Bit();
             } else {
-                dbxSvcAgentDSOPathPrefix = System.getProperty("dbxSvcAgentDSOPathPrefix");
-                if (dbxSvcAgentDSOPathPrefix == null) {
-                    dbxSvcAgentDSOPathPrefix = defaultDbxSvcAgentDSOPathPrefix;
-                }
-                if (cpu.equals("sparc")) {
-                    dbxSvcAgentDSOPathNames = new String[] {
-                        // FIXME: bad hack for SPARC v9. This is necessary because
-                        // there are two dbx executables on SPARC, one for v8 and one
-                        // for v9, and it isn't obvious how to tell the two apart
-                        // using the dbx command line. See
-                        // DbxDebuggerLocal.importDbxModule().
-                        dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + "v9" + fileSep + "lib" + fileSep + "libsvc_agent_dbx.so",
-                        dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + fileSep + "lib" + fileSep + "libsvc_agent_dbx.so",
-                    };
-                } else {
-                    dbxSvcAgentDSOPathNames = new String[] {
-                        dbxSvcAgentDSOPathPrefix + fileSep + os + fileSep + cpu + fileSep + "lib" + fileSep + "libsvc_agent_dbx.so"
-                    };
-                }
+                throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
             }
-            // Note we do not use a cache for the local debugger in server
-            // mode; it's taken care of on the client side
-            DbxDebuggerLocal dbg = new DbxDebuggerLocal(null, dbxPathName, dbxSvcAgentDSOPathNames, !isServer);
-            debugger = dbg;
-
-            attachDebugger();
+        } else if (cpu.equals("amd64")) {
+            machDesc = new MachineDescriptionAMD64();
+        } else {
+            throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64");
+        }
 
-            // Set up CPU-dependent stuff
-            if (cpu.equals("x86")) {
-                machDesc = new MachineDescriptionIntelX86();
-            } else if (cpu.equals("sparc")) {
-                int addressSize = dbg.getRemoteProcessAddressSize();
-                if (addressSize == -1) {
-                    throw new DebuggerException("Error occurred while trying to determine the remote process's address size. It's possible that the Serviceability Agent's dbx module failed to initialize. Examine the standard output and standard error streams from the dbx process for more information.");
-                }
-
-                if (addressSize == 32) {
-                    machDesc = new MachineDescriptionSPARC32Bit();
-                } else if (addressSize == 64) {
-                    machDesc = new MachineDescriptionSPARC64Bit();
-                } else {
-                    throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC");
-                }
-            }
-
-            dbg.setMachineDescription(machDesc);
-        }
+        dbg.setMachineDescription(machDesc);
     }
 
     private void connectRemoteDebugger() throws DebuggerException {
@@ -739,6 +672,8 @@
             setupJVMLibNamesWin32();
         } else if (os.equals("linux")) {
             setupJVMLibNamesLinux();
+        } else if (os.equals("bsd")) {
+            setupJVMLibNamesBsd();
         } else {
             throw new RuntimeException("Unknown OS type");
         }
@@ -772,11 +707,7 @@
         // mode; it will be taken care of on the client side (once remote
         // debugging is implemented).
 
-        if (System.getProperty("sun.jvm.hotspot.debugger.useWindbgDebugger") != null) {
-            debugger = new WindbgDebuggerLocal(machDesc, !isServer);
-        } else {
-            debugger = new Win32DebuggerLocal(machDesc, !isServer);
-        }
+        debugger = new WindbgDebuggerLocal(machDesc, !isServer);
 
         attachDebugger();
     }
@@ -822,6 +753,34 @@
         setupJVMLibNamesSolaris();
     }
 
+    //
+    // BSD
+    //
+
+    private void setupDebuggerBsd() {
+        setupJVMLibNamesBsd();
+
+        if (cpu.equals("x86")) {
+            machDesc = new MachineDescriptionIntelX86();
+        } else if (cpu.equals("amd64")) {
+            machDesc = new MachineDescriptionAMD64();
+        } else {
+            throw new DebuggerException("Bsd only supported on x86/amd64");
+        }
+
+        // Note we do not use a cache for the local debugger in server
+        // mode; it will be taken care of on the client side (once remote
+        // debugging is implemented).
+
+        debugger = new BsdDebuggerLocal(machDesc, !isServer);
+        attachDebugger();
+    }
+
+    private void setupJVMLibNamesBsd() {
+        // same as solaris
+        setupJVMLibNamesSolaris();
+    }
+
     /** Convenience routine which should be called by per-platform
       debugger setup. Should not be called when startupMode is
       REMOTE_MODE. */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciArrayKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciArrayKlass extends ciKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciArrayKlass");
+    dimensionField = new IntField(type.getJIntField("_dimension"), 0);
+  }
+
+  private static IntField dimensionField;
+
+  public ciArrayKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciArrayKlassKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciArrayKlassKlass extends ciKlassKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciArrayKlassKlass");
+  }
+
+
+  public ciArrayKlassKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciConstant.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciConstant extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciConstant");
+    valueObjectField = type.getAddressField("_value._object");
+    valueDoubleField = type.getJDoubleField("_value._double");
+    valueFloatField = type.getJFloatField("_value._float");
+    valueLongField = type.getJLongField("_value._long");
+    valueIntField = type.getJIntField("_value._int");
+    typeField = new CIntField(type.getCIntegerField("_type"), 0);
+  }
+
+  private static AddressField valueObjectField;
+  private static JDoubleField valueDoubleField;
+  private static JFloatField valueFloatField;
+  private static JLongField valueLongField;
+  private static JIntField valueIntField;
+  private static CIntField typeField;
+
+  public ciConstant(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.opto.*;
+import sun.jvm.hotspot.compiler.CompileTask;
+import sun.jvm.hotspot.prims.JvmtiExport;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.GrowableArray;
+
+public class ciEnv extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciEnv");
+    dependenciesField = type.getAddressField("_dependencies");
+    factoryField = type.getAddressField("_factory");
+    compilerDataField = type.getAddressField("_compiler_data");
+    taskField = type.getAddressField("_task");
+    systemDictionaryModificationCounterField = new CIntField(type.getCIntegerField("_system_dictionary_modification_counter"), 0);
+  }
+
+  private static AddressField dependenciesField;
+  private static AddressField factoryField;
+  private static AddressField compilerDataField;
+  private static AddressField taskField;
+  private static CIntField systemDictionaryModificationCounterField;
+
+  public ciEnv(Address addr) {
+    super(addr);
+  }
+
+  public Compile compilerData() {
+    return new Compile(compilerDataField.getValue(this.getAddress()));
+  }
+
+  public ciObjectFactory factory() {
+    return new ciObjectFactory(factoryField.getValue(this.getAddress()));
+  }
+
+  public CompileTask task() {
+    return new CompileTask(taskField.getValue(this.getAddress()));
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciField.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciField extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciField");
+    constantValueField = type.getAddressField("_constant_value");
+    isConstantField = type.getAddressField("_is_constant");
+    offsetField = new CIntField(type.getCIntegerField("_offset"), 0);
+    signatureField = type.getAddressField("_signature");
+    nameField = type.getAddressField("_name");
+    holderField = type.getAddressField("_holder");
+  }
+
+  private static AddressField constantValueField;
+  private static AddressField isConstantField;
+  private static CIntField offsetField;
+  private static AddressField signatureField;
+  private static AddressField nameField;
+  private static AddressField holderField;
+
+  public ciField(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstance.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciInstance extends ciObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciInstance");
+  }
+
+
+  public ciInstance(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.memory.SystemDictionary;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+import sun.jvm.hotspot.types.WrongTypeException;
+
+public class ciInstanceKlass extends ciKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciInstanceKlass");
+    initStateField = new CIntField(type.getCIntegerField("_init_state"), 0);
+    isSharedField = new CIntField(type.getCIntegerField("_is_shared"), 0);
+    CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
+    CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
+  }
+
+  private static CIntField initStateField;
+  private static CIntField isSharedField;
+  private static int CLASS_STATE_LINKED;
+  private static int CLASS_STATE_FULLY_INITIALIZED;
+
+  public ciInstanceKlass(Address addr) {
+    super(addr);
+  }
+
+  public int initState() {
+    int initState = (int)initStateField.getValue(getAddress());
+    if (isShared() && initState < CLASS_STATE_LINKED) {
+      InstanceKlass ik = (InstanceKlass)getOop();
+      initState = ik.getInitStateAsInt();
+    }
+    return initState;
+  }
+
+  public boolean isShared() {
+    return isSharedField.getValue(getAddress()) != 0;
+  }
+
+  public boolean isLinked() {
+    return initState() >= CLASS_STATE_LINKED;
+  }
+
+  public boolean isInitialized() {
+    return initState() == CLASS_STATE_FULLY_INITIALIZED;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciInstanceKlassKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciInstanceKlassKlass extends ciKlassKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciInstanceKlassKlass");
+  }
+
+
+  public ciInstanceKlassKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciKlass extends ciType {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciKlass");
+    nameField = type.getAddressField("_name");
+  }
+
+  private static AddressField nameField;
+
+  public String name() {
+    ciSymbol sym = new ciSymbol(nameField.getValue(getAddress()));
+    return sym.asUtf88();
+  }
+
+  public ciKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciKlassKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciKlassKlass extends ciKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciKlassKlass");
+  }
+
+
+  public ciKlassKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.code.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciMethod extends ciObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciMethod");
+    interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0);
+    interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0);
+    try {
+        // XXX
+        instructionsSizeField = new CIntField(type.getCIntegerField("_instructions_size"), 0);
+    } catch (Exception e) {
+    }
+  }
+
+  private static CIntField interpreterThrowoutCountField;
+  private static CIntField interpreterInvocationCountField;
+  private static CIntField instructionsSizeField;
+
+  public ciMethod(Address addr) {
+    super(addr);
+  }
+
+  public Method method() {
+    return (Method)getOop();
+  }
+
+  public int interpreterThrowoutCount() {
+    return (int) interpreterThrowoutCountField.getValue(getAddress());
+  }
+
+  public int interpreterInvocationCount() {
+    return (int) interpreterInvocationCountField.getValue(getAddress());
+  }
+
+  public int instructionsSize() {
+    if (instructionsSizeField == null) {
+      // XXX
+      Method method = (Method)getOop();
+      NMethod nm = method.getNativeMethod();
+      if (nm != null) return (int)nm.codeEnd().minus(nm.getVerifiedEntryPoint());
+      return 0;
+    }
+    return (int) instructionsSizeField.getValue(getAddress());
+  }
+
+  public void printShortName(PrintStream st) {
+    Method method = (Method)getOop();
+    st.printf(" %s::%s", method.getMethodHolder().getName().asString().replace('/', '.'),
+              method.getName().asString());
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciMethodData extends ciObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciMethodData");
+    origField = type.getAddressField("_orig");
+    currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0);
+    argReturnedField = new CIntField(type.getCIntegerField("_arg_returned"), 0);
+    argStackField = new CIntField(type.getCIntegerField("_arg_stack"), 0);
+    argLocalField = new CIntField(type.getCIntegerField("_arg_local"), 0);
+    eflagsField = new CIntField(type.getCIntegerField("_eflags"), 0);
+    hintDiField = new CIntField(type.getCIntegerField("_hint_di"), 0);
+    currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0);
+    dataField = type.getAddressField("_data");
+    extraDataSizeField = new CIntField(type.getCIntegerField("_extra_data_size"), 0);
+    dataSizeField = new CIntField(type.getCIntegerField("_data_size"), 0);
+    stateField = new CIntField(type.getCIntegerField("_state"), 0);
+    sizeofMethodDataOopDesc = (int)db.lookupType("methodDataOopDesc").getSize();;
+  }
+
+  private static AddressField origField;
+  private static CIntField currentMileageField;
+  private static CIntField argReturnedField;
+  private static CIntField argStackField;
+  private static CIntField argLocalField;
+  private static CIntField eflagsField;
+  private static CIntField hintDiField;
+  private static AddressField dataField;
+  private static CIntField extraDataSizeField;
+  private static CIntField dataSizeField;
+  private static CIntField stateField;
+  private static int sizeofMethodDataOopDesc;
+
+  public ciMethodData(Address addr) {
+    super(addr);
+  }
+
+  private byte[] fetchDataAt(Address base, long size) {
+    byte[] result = new byte[(int)size];
+    for (int i = 0; i < size; i++) {
+      result[i] = base.getJByteAt(i);
+    }
+    return result;
+  }
+
+  public byte[] orig() {
+    // fetch the orig methodDataOopDesc data between header and dataSize
+    Address base = getAddress().addOffsetTo(origField.getOffset());
+    byte[] result = new byte[MethodData.sizeofMethodDataOopDesc];
+    for (int i = 0; i < MethodData.sizeofMethodDataOopDesc; i++) {
+      result[i] = base.getJByteAt(i);
+    }
+    return result;
+  }
+
+  public  long[] data() {
+    // Read the data as an array of intptr_t elements
+    Address base = dataField.getValue(getAddress());
+    int elements = dataSize() / MethodData.cellSize;
+    long[] result = new long[elements];
+    for (int i = 0; i < elements; i++) {
+      Address value = base.getAddressAt(i * MethodData.cellSize);
+      if (value != null) {
+        result[i] = value.minus(null);
+      }
+    }
+    return result;
+  }
+
+  int dataSize() {
+    return (int)dataSizeField.getValue(getAddress());
+  }
+
+  int state() {
+    return (int)stateField.getValue(getAddress());
+  }
+
+  int currentMileage() {
+    return (int)currentMileageField.getValue(getAddress());
+  }
+
+  boolean outOfBounds(int dataIndex) {
+    return dataIndex >= dataSize();
+  }
+
+  ProfileData dataAt(int dataIndex) {
+    if (outOfBounds(dataIndex)) {
+      return null;
+    }
+    DataLayout dataLayout = new DataLayout(dataField.getValue(getAddress()), dataIndex);
+
+    switch (dataLayout.tag()) {
+    case DataLayout.noTag:
+    default:
+      throw new InternalError();
+    case DataLayout.bitDataTag:
+      return new BitData(dataLayout);
+    case DataLayout.counterDataTag:
+      return new CounterData(dataLayout);
+    case DataLayout.jumpDataTag:
+      return new JumpData(dataLayout);
+    case DataLayout.receiverTypeDataTag:
+      return new ciReceiverTypeData(dataLayout);
+    case DataLayout.virtualCallDataTag:
+      return new ciVirtualCallData(dataLayout);
+    case DataLayout.retDataTag:
+      return new RetData(dataLayout);
+    case DataLayout.branchDataTag:
+      return new BranchData(dataLayout);
+    case DataLayout.multiBranchDataTag:
+      return new MultiBranchData(dataLayout);
+    }
+  }
+
+  int dpToDi(int dp) {
+    return dp;
+  }
+
+  int firstDi() { return 0; }
+  ProfileData firstData() { return dataAt(firstDi()); }
+  ProfileData nextData(ProfileData current) {
+    int currentIndex = dpToDi(current.dp());
+    int nextIndex = currentIndex + current.sizeInBytes();
+    return dataAt(nextIndex);
+  }
+  boolean isValid(ProfileData current) { return current != null; }
+
+  public void printDataOn(PrintStream st) {
+    ProfileData data = firstData();
+    for ( ; isValid(data); data = nextData(data)) {
+      st.print(dpToDi(data.dp()));
+      st.print(" ");
+      // st->fillTo(6);
+      data.printDataOn(st);
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethodKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciMethodKlass extends ciKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciMethodKlass");
+  }
+
+
+  public ciMethodKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObjArrayKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciObjArrayKlass extends ciArrayKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciObjArrayKlass");
+    elementKlassField = type.getAddressField("_element_klass");
+    baseElementKlassField = type.getAddressField("_base_element_klass");
+  }
+
+  private static AddressField elementKlassField;
+  private static AddressField baseElementKlassField;
+
+  public ciObjArrayKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObjArrayKlassKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciObjArrayKlassKlass extends ciArrayKlassKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciObjArrayKlassKlass");
+  }
+
+
+  public ciObjArrayKlassKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciObject extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciObject");
+    identField = new CIntField(type.getCIntegerField("_ident"), 0);
+    klassField = type.getAddressField("_klass");
+    handleField = type.getAddressField("_handle");
+  }
+
+  private static CIntField identField;
+  private static AddressField klassField;
+  private static AddressField handleField;
+
+  public Oop getOop() {
+    OopHandle oh =  handleField.getValue(getAddress()).getOopHandleAt(0);
+    return VM.getVM().getObjectHeap().newOop(oh);
+  }
+
+  public ciObject(Address addr) {
+    super(addr);
+  }
+
+  public void printOn(PrintStream out) {
+    getOop().printValueOn(out);
+    out.println();
+  }
+
+  public String toString() {
+    return getOop().toString();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciObjectFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.lang.reflect.Constructor;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.utilities.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciObjectFactory extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciObjectFactory");
+    unloadedMethodsField = type.getAddressField("_unloaded_methods");
+    ciObjectsField = type.getAddressField("_ci_objects");
+    symbolsField = type.getAddressField("_symbols");
+
+    ciObjectConstructor = new VirtualBaseConstructor<ciObject>(db, db.lookupType("ciObject"), "sun.jvm.hotspot.ci", ciObject.class);
+    ciSymbolConstructor = new VirtualBaseConstructor<ciSymbol>(db, db.lookupType("ciSymbol"), "sun.jvm.hotspot.ci", ciSymbol.class);
+  }
+
+  private static AddressField unloadedMethodsField;
+  private static AddressField ciObjectsField;
+  private static AddressField symbolsField;
+
+  private static VirtualBaseConstructor<ciObject> ciObjectConstructor;
+  private static VirtualBaseConstructor<ciSymbol> ciSymbolConstructor;
+
+  public static ciObject get(Address addr) {
+    if (addr == null) return null;
+
+    return (ciObject)ciObjectConstructor.instantiateWrapperFor(addr);
+  }
+
+  public GrowableArray<ciObject> objects() {
+    return GrowableArray.create(ciObjectsField.getValue(getAddress()), ciObjectConstructor);
+  }
+
+  public GrowableArray<ciSymbol> symbols() {
+    return GrowableArray.create(symbolsField.getValue(getAddress()), ciSymbolConstructor);
+  }
+
+  public ciObjectFactory(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciReceiverTypeData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciReceiverTypeData extends ReceiverTypeData {
+  public ciReceiverTypeData(DataLayout data) {
+    super(data);
+  }
+
+  public Klass receiver(int row) {
+      throw new InternalError("should not call");
+  }
+
+  public ciKlass receiverAt(int row) {
+    //assert((uint)row < rowLimit(), "oob");
+    ciObject recv = ciObjectFactory.get(addressAt(receiverCellIndex(row)));
+    if (recv != null && !(recv instanceof ciKlass)) {
+      System.err.println(recv);
+    }
+    //assert(recv == NULL || recv->isKlass(), "wrong type");
+    return (ciKlass)recv;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciSymbol.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciSymbol extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type = db.lookupType("ciSymbol");
+    identField = type.getCIntegerField("_ident");
+    symbolField = type.getAddressField("_symbol");
+  }
+
+  private static AddressField symbolField;
+  private static CIntegerField identField;
+
+  public String asUtf88() {
+    Symbol sym = Symbol.create(symbolField.getValue(getAddress()));
+    return sym.asString();
+  }
+
+  public ciSymbol(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciType.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciType extends ciObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciType");
+    basicTypeField = new CIntField(type.getCIntegerField("_basic_type"), 0);
+  }
+
+  private static CIntField basicTypeField;
+
+  public ciType(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciTypeArrayKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciTypeArrayKlass extends ciArrayKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciTypeArrayKlass");
+  }
+
+  public ciTypeArrayKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciTypeArrayKlassKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciTypeArrayKlassKlass extends ciArrayKlassKlass {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ciTypeArrayKlassKlass");
+  }
+
+
+  public ciTypeArrayKlassKlass(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciVirtualCallData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.ci;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ciVirtualCallData extends VirtualCallData {
+  public ciVirtualCallData(DataLayout data) {
+    super(data);
+  }
+
+  public Klass receiver(int row) {
+      throw new InternalError("should not call");
+  }
+
+  public ciKlass receiverAt(int row) {
+    //assert((uint)row < rowLimit(), "oob");
+    ciObject recv = ciObjectFactory.get(addressAt(receiverCellIndex(row)));
+    if (recv != null && !(recv instanceof ciKlass)) {
+      System.err.println(recv);
+    }
+    //assert(recv == NULL || recv->isKlass(), "wrong type");
+    return (ciKlass)recv;
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java	Wed Oct 26 17:59:13 2011 -0700
@@ -102,6 +102,11 @@
   /** On-Stack Replacement method */
   public boolean isOSRMethod()          { return false; }
 
+  public NMethod asNMethodOrNull() {
+    if (isNMethod()) return (NMethod)this;
+    return null;
+  }
+
   // Boundaries
   public Address headerBegin() {
     return addr;
@@ -195,7 +200,7 @@
   }
 
   // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
-  public boolean callerMustGCArguments(JavaThread thread) { return false; }
+  public boolean callerMustGCArguments() { return false; }
 
   public String getName() {
     return CStringUtilities.getString(nameField.getValue(addr));
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java	Wed Oct 26 17:59:13 2011 -0700
@@ -59,6 +59,7 @@
     virtualConstructor.addMapping("RuntimeStub", RuntimeStub.class);
     virtualConstructor.addMapping("RicochetBlob", RicochetBlob.class);
     virtualConstructor.addMapping("AdapterBlob", AdapterBlob.class);
+    virtualConstructor.addMapping("MethodHandlesAdapterBlob", MethodHandlesAdapterBlob.class);
     virtualConstructor.addMapping("SafepointBlob", SafepointBlob.class);
     virtualConstructor.addMapping("DeoptimizationBlob", DeoptimizationBlob.class);
     if (VM.getVM().isServerCompiler()) {
@@ -126,6 +127,10 @@
       Assert.that(result.blobContains(start) || result.blobContains(start.addOffsetTo(8)),
                                                                     "found wrong CodeBlob");
     }
+    if (result.isRicochetBlob()) {
+      // This should probably be done for other SingletonBlobs
+      return VM.getVM().ricochetBlob();
+    }
     return result;
   }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/MethodHandlesAdapterBlob.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.code;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+
+public class MethodHandlesAdapterBlob extends AdapterBlob {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static void initialize(TypeDataBase db) {
+    Type type = db.lookupType("MethodHandlesAdapterBlob");
+
+    // FIXME: add any needed fields
+  }
+
+  public MethodHandlesAdapterBlob(Address addr) {
+    super(addr);
+  }
+
+  public boolean isMethodHandlesAdapterBlob() {
+    return true;
+  }
+
+  public String getName() {
+    return "MethodHandlesAdapterBlob: " + super.getName();
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,7 @@
   /** Offsets for different nmethod parts */
   private static CIntegerField exceptionOffsetField;
   private static CIntegerField deoptOffsetField;
+  private static CIntegerField deoptMhOffsetField;
   private static CIntegerField origPCOffsetField;
   private static CIntegerField stubOffsetField;
   private static CIntegerField oopsOffsetField;
@@ -95,6 +96,7 @@
 
     exceptionOffsetField        = type.getCIntegerField("_exception_offset");
     deoptOffsetField            = type.getCIntegerField("_deoptimize_offset");
+    deoptMhOffsetField          = type.getCIntegerField("_deoptimize_mh_offset");
     origPCOffsetField           = type.getCIntegerField("_orig_pc_offset");
     stubOffsetField             = type.getCIntegerField("_stub_offset");
     oopsOffsetField             = type.getCIntegerField("_oops_offset");
@@ -136,10 +138,11 @@
   /** Boundaries for different parts */
   public Address constantsBegin()       { return contentBegin();                                     }
   public Address constantsEnd()         { return getEntryPoint();                                    }
-  public Address instsBegin()           { return codeBegin();                                       }
+  public Address instsBegin()           { return codeBegin();                                        }
   public Address instsEnd()             { return headerBegin().addOffsetTo(getStubOffset());         }
   public Address exceptionBegin()       { return headerBegin().addOffsetTo(getExceptionOffset());    }
-  public Address deoptBegin()           { return headerBegin().addOffsetTo(getDeoptOffset());        }
+  public Address deoptHandlerBegin()    { return headerBegin().addOffsetTo(getDeoptOffset());        }
+  public Address deoptMhHandlerBegin()  { return headerBegin().addOffsetTo(getDeoptMhOffset());      }
   public Address stubBegin()            { return headerBegin().addOffsetTo(getStubOffset());         }
   public Address stubEnd()              { return headerBegin().addOffsetTo(getOopsOffset());         }
   public Address oopsBegin()            { return headerBegin().addOffsetTo(getOopsOffset());         }
@@ -187,6 +190,8 @@
   public boolean handlerTableContains(Address addr) { return handlerTableBegin().lessThanOrEqual(addr) && handlerTableEnd().greaterThan(addr); }
   public boolean nulChkTableContains (Address addr) { return nulChkTableBegin() .lessThanOrEqual(addr) && nulChkTableEnd() .greaterThan(addr); }
 
+  public int getOopsLength() { return (int) (oopsSize() / VM.getVM().getOopSize()); }
+
   /** Entry points */
   public Address getEntryPoint()         { return entryPointField.getValue(addr);         }
   public Address getVerifiedEntryPoint() { return verifiedEntryPointField.getValue(addr); }
@@ -195,7 +200,7 @@
   public OopHandle getOopAt(int index) {
     if (index == 0) return null;
     if (Assert.ASSERTS_ENABLED) {
-      Assert.that(index > 0 && index <= oopsSize(), "must be a valid non-zero index");
+      Assert.that(index > 0 && index <= getOopsLength(), "must be a valid non-zero index");
     }
     return oopsBegin().getOopHandleAt((index - 1) * VM.getVM().getOopSize());
   }
@@ -250,6 +255,22 @@
     return (int) scavengeRootStateField.getValue(addr);
   }
 
+  // MethodHandle
+  public boolean isMethodHandleReturn(Address returnPc) {
+    // Hard to read a bit fields from Java and it's only there for performance
+    // so just go directly to the PCDesc
+    // if (!hasMethodHandleInvokes())  return false;
+    PCDesc pd = getPCDescAt(returnPc);
+    if (pd == null)
+      return false;
+    return pd.isMethodHandleInvoke();
+  }
+
+  // Deopt
+  // Return true is the PC is one would expect if the frame is being deopted.
+  public boolean isDeoptPc      (Address pc) { return isDeoptEntry(pc) || isDeoptMhEntry(pc); }
+  public boolean isDeoptEntry   (Address pc) { return pc == deoptHandlerBegin(); }
+  public boolean isDeoptMhEntry (Address pc) { return pc == deoptMhHandlerBegin(); }
 
   /** Tells whether frames described by this nmethod can be
       deoptimized. Note: native wrappers cannot be deoptimized. */
@@ -388,6 +409,7 @@
   private int getEntryBCI()           { return (int) entryBCIField          .getValue(addr); }
   private int getExceptionOffset()    { return (int) exceptionOffsetField   .getValue(addr); }
   private int getDeoptOffset()        { return (int) deoptOffsetField       .getValue(addr); }
+  private int getDeoptMhOffset()      { return (int) deoptMhOffsetField     .getValue(addr); }
   private int getStubOffset()         { return (int) stubOffsetField        .getValue(addr); }
   private int getOopsOffset()         { return (int) oopsOffsetField        .getValue(addr); }
   private int getScopesDataOffset()   { return (int) scopesDataOffsetField  .getValue(addr); }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java	Wed Oct 26 17:59:13 2011 -0700
@@ -38,6 +38,9 @@
   private static CIntegerField scopeDecodeOffsetField;
   private static CIntegerField objDecodeOffsetField;
   private static CIntegerField pcFlagsField;
+  private static int reexecuteMask;
+  private static int isMethodHandleInvokeMask;
+  private static int returnOopMask;
 
   static {
     VM.registerVMInitializedObserver(new Observer() {
@@ -54,6 +57,10 @@
     scopeDecodeOffsetField = type.getCIntegerField("_scope_decode_offset");
     objDecodeOffsetField   = type.getCIntegerField("_obj_decode_offset");
     pcFlagsField           = type.getCIntegerField("_flags");
+
+    reexecuteMask            = db.lookupIntConstant("PcDesc::PCDESC_reexecute");
+    isMethodHandleInvokeMask = db.lookupIntConstant("PcDesc::PCDESC_is_method_handle_invoke");
+    returnOopMask            = db.lookupIntConstant("PcDesc::PCDESC_return_oop");
   }
 
   public PCDesc(Address addr) {
@@ -81,7 +88,12 @@
 
   public boolean getReexecute() {
     int flags = (int)pcFlagsField.getValue(addr);
-    return ((flags & 0x1)== 1); //first is the reexecute bit
+    return (flags & reexecuteMask) != 0;
+  }
+
+  public boolean isMethodHandleInvoke() {
+    int flags = (int)pcFlagsField.getValue(addr);
+    return (flags & isMethodHandleInvokeMask) != 0;
   }
 
   public void print(NMethod code) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/RicochetBlob.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/RicochetBlob.java	Wed Oct 26 17:59:13 2011 -0700
@@ -41,11 +41,15 @@
   }
 
   private static void initialize(TypeDataBase db) {
-    // Type type = db.lookupType("RicochetBlob");
+    Type type = db.lookupType("RicochetBlob");
 
-    // FIXME: add any needed fields
+    bounceOffsetField                = type.getCIntegerField("_bounce_offset");
+    exceptionOffsetField             = type.getCIntegerField("_exception_offset");
   }
 
+  private static CIntegerField bounceOffsetField;
+  private static CIntegerField exceptionOffsetField;
+
   public RicochetBlob(Address addr) {
     super(addr);
   }
@@ -53,4 +57,14 @@
   public boolean isRicochetBlob() {
     return true;
   }
+
+  public Address bounceAddr() {
+    return codeBegin().addOffsetTo(bounceOffsetField.getValue(addr));
+  }
+
+  public boolean returnsToBounceAddr(Address pc) {
+    Address bouncePc = bounceAddr();
+    return (pc.equals(bouncePc) || pc.addOffsetTo(Frame.pcReturnOffset()).equals(bouncePc));
+  }
+
 }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/RuntimeStub.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/RuntimeStub.java	Wed Oct 26 17:59:13 2011 -0700
@@ -30,6 +30,8 @@
 import sun.jvm.hotspot.types.*;
 
 public class RuntimeStub extends CodeBlob {
+  private static CIntegerField callerMustGCArgumentsField;
+
   static {
     VM.registerVMInitializedObserver(new Observer() {
         public void update(Observable o, Object data) {
@@ -40,6 +42,7 @@
 
   private static void initialize(TypeDataBase db) {
     Type type = db.lookupType("RuntimeStub");
+    callerMustGCArgumentsField                = type.getCIntegerField("_caller_must_gc_arguments");
 
     // FIXME: add any needed fields
   }
@@ -52,6 +55,11 @@
     return true;
   }
 
+  public boolean callerMustGCArguments() {
+    return callerMustGCArgumentsField.getValue(addr) != 0;
+  }
+
+
   public String getName() {
     return "RuntimeStub: " + super.getName();
   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.compiler;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.opto.*;
+import sun.jvm.hotspot.prims.JvmtiExport;
+import sun.jvm.hotspot.types.*;
+
+public class CompileTask extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("CompileTask");
+    methodField = type.getAddressField("_method");
+    osrBciField = new CIntField(type.getCIntegerField("_osr_bci"), 0);
+  }
+
+  private static AddressField methodField;
+  private static CIntField osrBciField;
+
+  public CompileTask(Address addr) {
+    super(addr);
+  }
+
+  public Method method() {
+    OopHandle oh =  methodField.getValue(getAddress()).getOopHandleAt(0);
+    return (Method)VM.getVM().getObjectHeap().newOop(oh);
+  }
+
+  public int osrBci() {
+    return (int)osrBciField.getValue(getAddress());
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapSet.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapSet.java	Wed Oct 26 17:59:13 2011 -0700
@@ -246,7 +246,7 @@
     }
 
     // Check if caller must update oop argument
-    regMap.setIncludeArgumentOops(cb.callerMustGCArguments(regMap.getThread()));
+    regMap.setIncludeArgumentOops(cb.callerMustGCArguments());
 
     int nofCallee = 0;
     Address[] locs = new Address[2 * REG_COUNT + 1];
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/AddressException.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/AddressException.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,4 +39,8 @@
   public long getAddress() {
     return addr;
   }
+
+  public String getMessage() {
+    return Long.toHexString(addr);
+  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdAddress.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd;
+
+import sun.jvm.hotspot.debugger.*;
+
+class BsdAddress implements Address {
+    protected BsdDebugger debugger;
+    protected long addr;
+
+    BsdAddress(BsdDebugger debugger, long addr) {
+        this.debugger = debugger;
+        this.addr = addr;
+    }
+
+    //
+    // Basic Java routines
+    //
+
+    public boolean equals(Object arg) {
+        if (arg == null) {
+            return false;
+        }
+
+        if (!(arg instanceof BsdAddress)) {
+            return false;
+        }
+
+        return (addr == ((BsdAddress) arg).addr);
+    }
+
+    public int hashCode() {
+        // FIXME: suggestions on a better hash code?
+        return (int) addr;
+    }
+
+    public String toString() {
+        return debugger.addressValueToString(addr);
+    }
+
+    //
+    // C/C++-related routines
+    //
+
+    public long getCIntegerAt(long offset, long numBytes, boolean isUnsigned)
+            throws UnalignedAddressException, UnmappedAddressException {
+        return debugger.readCInteger(addr + offset, numBytes, isUnsigned);
+    }
+
+    public Address getAddressAt(long offset)
+            throws UnalignedAddressException, UnmappedAddressException {
+        return debugger.readAddress(addr + offset);
+    }
+
+    public Address getCompOopAddressAt(long offset)
+            throws UnalignedAddressException, UnmappedAddressException {
+        return debugger.readCompOopAddress(addr + offset);
+    }
+
+    //
+    // Java-related routines
+    //
+
+  public boolean getJBooleanAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
+    return debugger.readJBoolean(addr + offset);
+  }
+
+  public byte getJByteAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
+    return debugger.readJByte(addr + offset);
+  }
+
+  public char getJCharAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
+    return debugger.readJChar(addr + offset);
+  }
+
+  public double getJDoubleAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
+    return debugger.readJDouble(addr + offset);
+  }
+
+  public float getJFloatAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
+    return debugger.readJFloat(addr + offset);
+  }
+
+  public int getJIntAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
+    return debugger.readJInt(addr + offset);
+  }
+
+  public long getJLongAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
+    return debugger.readJLong(addr + offset);
+  }
+
+  public short getJShortAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
+    return debugger.readJShort(addr + offset);
+  }
+
+  public OopHandle getOopHandleAt(long offset)
+    throws UnalignedAddressException, UnmappedAddressException, NotInHeapException {
+    return debugger.readOopHandle(addr + offset);
+  }
+
+  public OopHandle getCompOopHandleAt(long offset)
+    throws UnalignedAddressException, UnmappedAddressException, NotInHeapException {
+    return debugger.readCompOopHandle(addr + offset);
+  }
+
+  // Mutators -- not implemented for now (FIXME)
+  public void setCIntegerAt(long offset, long numBytes, long value) {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void setAddressAt(long offset, Address value) {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setJBooleanAt      (long offset, boolean value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setJByteAt         (long offset, byte value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setJCharAt         (long offset, char value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setJDoubleAt       (long offset, double value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setJFloatAt        (long offset, float value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setJIntAt          (long offset, int value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setJLongAt         (long offset, long value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setJShortAt        (long offset, short value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+  public void       setOopHandleAt     (long offset, OopHandle value)
+    throws UnmappedAddressException, UnalignedAddressException {
+    throw new DebuggerException("Unimplemented");
+  }
+
+  //
+  // Arithmetic operations -- necessary evil.
+  //
+
+  public Address    addOffsetTo       (long offset) throws UnsupportedOperationException {
+    long value = addr + offset;
+    if (value == 0) {
+      return null;
+    }
+    return new BsdAddress(debugger, value);
+  }
+
+  public OopHandle  addOffsetToAsOopHandle(long offset) throws UnsupportedOperationException {
+    long value = addr + offset;
+    if (value == 0) {
+      return null;
+    }
+    return new BsdOopHandle(debugger, value);
+  }
+
+  /** (FIXME: any signed/unsigned issues? Should this work for
+      OopHandles?) */
+  public long       minus(Address arg) {
+    if (arg == null) {
+      return addr;
+    }
+    return addr - ((BsdAddress) arg).addr;
+  }
+
+  // Two's complement representation.
+  // All negative numbers are larger than positive numbers.
+  // Numbers with the same sign can be compared normally.
+  // Test harness is below in main().
+
+  public boolean    lessThan          (Address a) {
+    if (a == null) {
+      return false;
+    }
+    BsdAddress arg = (BsdAddress) a;
+    if ((addr >= 0) && (arg.addr < 0)) {
+      return true;
+    }
+    if ((addr < 0) && (arg.addr >= 0)) {
+      return false;
+    }
+    return (addr < arg.addr);
+  }
+
+  public boolean    lessThanOrEqual   (Address a) {
+    if (a == null) {
+      return false;
+    }
+    BsdAddress arg = (BsdAddress) a;
+    if ((addr >= 0) && (arg.addr < 0)) {
+      return true;
+    }
+    if ((addr < 0) && (arg.addr >= 0)) {
+      return false;
+    }
+    return (addr <= arg.addr);
+  }
+
+  public boolean    greaterThan       (Address a) {
+    if (a == null) {
+      return true;
+    }
+    BsdAddress arg = (BsdAddress) a;
+    if ((addr >= 0) && (arg.addr < 0)) {
+      return false;
+    }
+    if ((addr < 0) && (arg.addr >= 0)) {
+      return true;
+    }
+    return (addr > arg.addr);
+  }
+
+  public boolean    greaterThanOrEqual(Address a) {
+    if (a == null) {
+      return true;
+    }
+    BsdAddress arg = (BsdAddress) a;
+    if ((addr >= 0) && (arg.addr < 0)) {
+      return false;
+    }
+    if ((addr < 0) && (arg.addr >= 0)) {
+      return true;
+    }
+    return (addr >= arg.addr);
+  }
+
+  public Address    andWithMask(long mask) throws UnsupportedOperationException {
+    long value = addr & mask;
+    if (value == 0) {
+      return null;
+    }
+    return new BsdAddress(debugger, value);
+  }
+
+  public Address    orWithMask(long mask) throws UnsupportedOperationException {
+    long value = addr | mask;
+    if (value == 0) {
+      return null;
+    }
+    return new BsdAddress(debugger, value);
+  }
+
+  public Address    xorWithMask(long mask) throws UnsupportedOperationException {
+    long value = addr ^ mask;
+    if (value == 0) {
+      return null;
+    }
+    return new BsdAddress(debugger, value);
+  }
+
+
+  //--------------------------------------------------------------------------------
+  // Internals only below this point
+  //
+
+  long getValue() {
+    return addr;
+  }
+
+
+  private static void check(boolean arg, String failMessage) {
+    if (!arg) {
+      System.err.println(failMessage + ": FAILED");
+      System.exit(1);
+    }
+  }
+
+  // Test harness
+  public static void main(String[] args) {
+    // p/n indicates whether the interior address is really positive
+    // or negative. In unsigned terms, p1 < p2 < n1 < n2.
+
+    BsdAddress p1 = new BsdAddress(null, 0x7FFFFFFFFFFFFFF0L);
+    BsdAddress p2 = (BsdAddress) p1.addOffsetTo(10);
+    BsdAddress n1 = (BsdAddress) p2.addOffsetTo(10);
+    BsdAddress n2 = (BsdAddress) n1.addOffsetTo(10);
+
+    // lessThan positive tests
+    check(p1.lessThan(p2), "lessThan 1");
+    check(p1.lessThan(n1), "lessThan 2");
+    check(p1.lessThan(n2), "lessThan 3");
+    check(p2.lessThan(n1), "lessThan 4");
+    check(p2.lessThan(n2), "lessThan 5");
+    check(n1.lessThan(n2), "lessThan 6");
+
+    // lessThan negative tests
+    check(!p1.lessThan(p1), "lessThan 7");
+    check(!p2.lessThan(p2), "lessThan 8");
+    check(!n1.lessThan(n1), "lessThan 9");
+    check(!n2.lessThan(n2), "lessThan 10");
+
+    check(!p2.lessThan(p1), "lessThan 11");
+    check(!n1.lessThan(p1), "lessThan 12");
+    check(!n2.lessThan(p1), "lessThan 13");
+    check(!n1.lessThan(p2), "lessThan 14");
+    check(!n2.lessThan(p2), "lessThan 15");
+    check(!n2.lessThan(n1), "lessThan 16");
+
+    // lessThanOrEqual positive tests
+    check(p1.lessThanOrEqual(p1), "lessThanOrEqual 1");
+    check(p2.lessThanOrEqual(p2), "lessThanOrEqual 2");
+    check(n1.lessThanOrEqual(n1), "lessThanOrEqual 3");
+    check(n2.lessThanOrEqual(n2), "lessThanOrEqual 4");
+
+    check(p1.lessThanOrEqual(p2), "lessThanOrEqual 5");
+    check(p1.lessThanOrEqual(n1), "lessThanOrEqual 6");
+    check(p1.lessThanOrEqual(n2), "lessThanOrEqual 7");
+    check(p2.lessThanOrEqual(n1), "lessThanOrEqual 8");
+    check(p2.lessThanOrEqual(n2), "lessThanOrEqual 9");
+    check(n1.lessThanOrEqual(n2), "lessThanOrEqual 10");
+
+    // lessThanOrEqual negative tests
+    check(!p2.lessThanOrEqual(p1), "lessThanOrEqual 11");
+    check(!n1.lessThanOrEqual(p1), "lessThanOrEqual 12");
+    check(!n2.lessThanOrEqual(p1), "lessThanOrEqual 13");
+    check(!n1.lessThanOrEqual(p2), "lessThanOrEqual 14");
+    check(!n2.lessThanOrEqual(p2), "lessThanOrEqual 15");
+    check(!n2.lessThanOrEqual(n1), "lessThanOrEqual 16");
+
+    // greaterThan positive tests
+    check(n2.greaterThan(p1), "greaterThan 1");
+    check(n2.greaterThan(p2), "greaterThan 2");
+    check(n2.greaterThan(n1), "greaterThan 3");
+    check(n1.greaterThan(p1), "greaterThan 4");
+    check(n1.greaterThan(p2), "greaterThan 5");
+    check(p2.greaterThan(p1), "greaterThan 6");
+
+    // greaterThan negative tests
+    check(!p1.greaterThan(p1), "greaterThan 7");
+    check(!p2.greaterThan(p2), "greaterThan 8");
+    check(!n1.greaterThan(n1), "greaterThan 9");
+    check(!n2.greaterThan(n2), "greaterThan 10");
+
+    check(!p1.greaterThan(n2), "greaterThan 11");
+    check(!p2.greaterThan(n2), "greaterThan 12");
+    check(!n1.greaterThan(n2), "greaterThan 13");
+    check(!p1.greaterThan(n1), "greaterThan 14");
+    check(!p2.greaterThan(n1), "greaterThan 15");
+    check(!p1.greaterThan(p2), "greaterThan 16");
+
+    // greaterThanOrEqual positive tests
+    check(p1.greaterThanOrEqual(p1), "greaterThanOrEqual 1");
+    check(p2.greaterThanOrEqual(p2), "greaterThanOrEqual 2");
+    check(n1.greaterThanOrEqual(n1), "greaterThanOrEqual 3");
+    check(n2.greaterThanOrEqual(n2), "greaterThanOrEqual 4");
+
+    check(n2.greaterThanOrEqual(p1), "greaterThanOrEqual 5");
+    check(n2.greaterThanOrEqual(p2), "greaterThanOrEqual 6");
+    check(n2.greaterThanOrEqual(n1), "greaterThanOrEqual 7");
+    check(n1.greaterThanOrEqual(p1), "greaterThanOrEqual 8");
+    check(n1.greaterThanOrEqual(p2), "greaterThanOrEqual 9");
+    check(p2.greaterThanOrEqual(p1), "greaterThanOrEqual 10");
+
+    // greaterThanOrEqual negative tests
+    check(!p1.greaterThanOrEqual(n2), "greaterThanOrEqual 11");
+    check(!p2.greaterThanOrEqual(n2), "greaterThanOrEqual 12");
+    check(!n1.greaterThanOrEqual(n2), "greaterThanOrEqual 13");
+    check(!p1.greaterThanOrEqual(n1), "greaterThanOrEqual 14");
+    check(!p2.greaterThanOrEqual(n1), "greaterThanOrEqual 15");
+    check(!p1.greaterThanOrEqual(p2), "greaterThanOrEqual 16");
+
+    System.err.println("BsdAddress: all tests passed successfully.");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdCDebugger.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.cdbg.*;
+import sun.jvm.hotspot.debugger.x86.*;
+import sun.jvm.hotspot.debugger.amd64.*;
+import sun.jvm.hotspot.debugger.bsd.x86.*;
+import sun.jvm.hotspot.debugger.bsd.amd64.*;
+import sun.jvm.hotspot.utilities.*;
+
+class BsdCDebugger implements CDebugger {
+  private BsdDebugger dbg;
+
+  BsdCDebugger(BsdDebugger dbg) {
+    this.dbg = dbg;
+  }
+
+  public List getThreadList() throws DebuggerException {
+    return dbg.getThreadList();
+  }
+
+  public List/*<LoadObject>*/ getLoadObjectList() throws DebuggerException {
+    return dbg.getLoadObjectList();
+  }
+
+  public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {
+    if (pc == null) {
+      return null;
+    }
+    List objs = getLoadObjectList();
+    Object[] arr = objs.toArray();
+    // load objects are sorted by base address, do binary search
+    int mid  = -1;
+    int low  = 0;
+    int high = arr.length - 1;
+
+    while (low <= high) {
+       mid = (low + high) >> 1;
+       LoadObject midVal = (LoadObject) arr[mid];
+       long cmp = pc.minus(midVal.getBase());
+       if (cmp < 0) {
+          high = mid - 1;
+       } else if (cmp > 0) {
+          long size = midVal.getSize();
+          if (cmp >= size) {
+             low = mid + 1;
+          } else {
+             return (LoadObject) arr[mid];
+          }
+       } else { // match found
+          return (LoadObject) arr[mid];
+       }
+    }
+    // no match found.
+    return null;
+  }
+
+  public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
+    String cpu = dbg.getCPU();
+    if (cpu.equals("x86")) {
+       X86ThreadContext context = (X86ThreadContext) thread.getContext();
+       Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
+       if (ebp == null) return null;
+       Address pc  = context.getRegisterAsAddress(X86ThreadContext.EIP);
+       if (pc == null) return null;
+       return new BsdX86CFrame(dbg, ebp, pc);
+    } else if (cpu.equals("amd64")) {
+       AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
+       Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP);
+       if (rbp == null) return null;
+       Address pc  = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
+       if (pc == null) return null;
+       return new BsdAMD64CFrame(dbg, rbp, pc);
+    } else {
+       throw new DebuggerException(cpu + " is not yet supported");
+    }
+  }
+
+  public String getNameOfFile(String fileName) {
+    return new File(fileName).getName();
+  }
+
+  public ProcessControl getProcessControl() throws DebuggerException {
+    // FIXME: after stabs parser
+    return null;
+  }
+
+  public boolean canDemangle() {
+    return false;
+  }
+
+  public String demangle(String sym) {
+    throw new UnsupportedOperationException();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd;
+
+import java.util.List;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.cdbg.*;
+
+/** An extension of the JVMDebugger interface with a few additions to
+    support 32-bit vs. 64-bit debugging as well as features required
+    by the architecture-specific subpackages. */
+
+public interface BsdDebugger extends JVMDebugger {
+  public String       addressValueToString(long address) throws DebuggerException;
+  public boolean      readJBoolean(long address) throws DebuggerException;
+  public byte         readJByte(long address) throws DebuggerException;
+  public char         readJChar(long address) throws DebuggerException;
+  public double       readJDouble(long address) throws DebuggerException;
+  public float        readJFloat(long address) throws DebuggerException;
+  public int          readJInt(long address) throws DebuggerException;
+  public long         readJLong(long address) throws DebuggerException;
+  public short        readJShort(long address) throws DebuggerException;
+  public long         readCInteger(long address, long numBytes, boolean isUnsigned)
+    throws DebuggerException;
+  public BsdAddress readAddress(long address) throws DebuggerException;
+  public BsdAddress readCompOopAddress(long address) throws DebuggerException;
+  public BsdOopHandle readOopHandle(long address) throws DebuggerException;
+  public BsdOopHandle readCompOopHandle(long address) throws DebuggerException;
+  public long[]       getThreadIntegerRegisterSet(int lwp_id) throws DebuggerException;
+  public long         getAddressValue(Address addr) throws DebuggerException;
+  public Address      newAddress(long value) throws DebuggerException;
+
+  // For BsdCDebugger
+  public List         getThreadList();
+  public List         getLoadObjectList();
+  public ClosestSymbol lookup(long address);
+
+  // NOTE: this interface implicitly contains the following methods:
+  // From the Debugger interface via JVMDebugger
+  //   public void attach(int processID) throws DebuggerException;
+  //   public void attach(String executableName, String coreFileName) throws DebuggerException;
+  //   public boolean detach();
+  //   public Address parseAddress(String addressString) throws NumberFormatException;
+  //   public String getOS();
+  //   public String getCPU();
+  // From the SymbolLookup interface via Debugger and JVMDebugger
+  //   public Address lookup(String objectName, String symbol);
+  //   public OopHandle lookupOop(String objectName, String symbol);
+  // From the JVMDebugger interface
+  //   public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
+  //                                               long jbyteSize,
+  //                                               long jcharSize,
+  //                                               long jdoubleSize,
+  //                                               long jfloatSize,
+  //                                               long jintSize,
+  //                                               long jlongSize,
+  //                                               long jshortSize);
+  // From the ThreadAccess interface via Debugger and JVMDebugger
+  //   public ThreadProxy getThreadForIdentifierAddress(Address addr);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebuggerLocal.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,597 @@
+/*
+ * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.x86.*;
+import sun.jvm.hotspot.debugger.cdbg.*;
+import sun.jvm.hotspot.utilities.*;
+import java.lang.reflect.*;
+
+/** <P> An implementation of the JVMDebugger interface. The basic debug
+    facilities are implemented through ptrace interface in the JNI code
+    (libsaproc.so). Library maps and symbol table management are done in
+    JNI. </P>
+
+    <P> <B>NOTE</B> that since we have the notion of fetching "Java
+    primitive types" from the remote process (which might have
+    different sizes than we expect) we have a bootstrapping
+    problem. We need to know the sizes of these types before we can
+    fetch them. The current implementation solves this problem by
+    requiring that it be configured with these type sizes before they
+    can be fetched. The readJ(Type) routines here will throw a
+    RuntimeException if they are called before the debugger is
+    configured with the Java primitive type sizes. </P> */
+
+public class BsdDebuggerLocal extends DebuggerBase implements BsdDebugger {
+    private boolean useGCC32ABI;
+    private boolean attached;
+    private long    p_ps_prochandle; // native debugger handle
+    private long    symbolicator; // macosx symbolicator handle
+    private long    task; // macosx task handle
+    private boolean isCore;
+
+    // CDebugger support
+    private BsdCDebugger cdbg;
+
+    // threadList and loadObjectList are filled by attach0 method
+    private List threadList;
+    private List loadObjectList;
+
+    // called by native method lookupByAddress0
+    private ClosestSymbol createClosestSymbol(String name, long offset) {
+       return new ClosestSymbol(name, offset);
+    }
+
+    // called by native method attach0
+    private LoadObject createLoadObject(String fileName, long textsize,
+                                        long base) {
+       File f = new File(fileName);
+       Address baseAddr = newAddress(base);
+       return new SharedObject(this, fileName, f.length(), baseAddr);
+    }
+
+    // native methods
+
+    private native static void init0()
+                                throws DebuggerException;
+    private native void attach0(int pid)
+                                throws DebuggerException;
+    private native void attach0(String execName, String coreName)
+                                throws DebuggerException;
+    private native void detach0()
+                                throws DebuggerException;
+    private native long lookupByName0(String objectName, String symbol)
+                                throws DebuggerException;
+    private native ClosestSymbol lookupByAddress0(long address)
+                                throws DebuggerException;
+    private native long[] getThreadIntegerRegisterSet0(int lwp_id)
+                                throws DebuggerException;
+    private native byte[] readBytesFromProcess0(long address, long numBytes)
+                                throws DebuggerException;
+    public native static int  getAddressSize() ;
+
+    // Note on Bsd threads are really processes. When target process is
+    // attached by a serviceability agent thread, only that thread can do
+    // ptrace operations on the target. This is because from kernel's point
+    // view, other threads are just separate processes and they are not
+    // attached to the target. When they attempt to make ptrace calls,
+    // an ESRCH error will be returned as kernel believes target is not
+    // being traced by the caller.
+    // To work around the problem, we use a worker thread here to handle
+    // all JNI functions that are making ptrace calls.
+
+    interface WorkerThreadTask {
+       public void doit(BsdDebuggerLocal debugger) throws DebuggerException;
+    }
+
+    class BsdDebuggerLocalWorkerThread extends Thread {
+       BsdDebuggerLocal debugger;
+       WorkerThreadTask task;
+       DebuggerException lastException;
+
+       public BsdDebuggerLocalWorkerThread(BsdDebuggerLocal debugger) {
+         this.debugger = debugger;
+         setDaemon(true);
+       }
+
+       public void run() {
+          synchronized (workerThread) {
+             for (;;) {
+                if (task != null) {
+                   lastException = null;
+                   try {
+                      task.doit(debugger);
+                   } catch (DebuggerException exp) {
+                      lastException = exp;
+                   }
+                   task = null;
+                   workerThread.notifyAll();
+                }
+
+                try {
+                   workerThread.wait();
+                } catch (InterruptedException x) {}
+             }
+          }
+       }
+
+       public WorkerThreadTask execute(WorkerThreadTask task) throws DebuggerException {
+          synchronized (workerThread) {
+             this.task = task;
+             workerThread.notifyAll();
+             while (this.task != null) {
+                try {
+                   workerThread.wait();
+                } catch (InterruptedException x) {}
+             }
+             if (lastException != null) {
+                throw new DebuggerException(lastException);
+             } else {
+                return task;
+             }
+          }
+       }
+    }
+
+    private BsdDebuggerLocalWorkerThread workerThread = null;
+
+    //----------------------------------------------------------------------
+    // Implementation of Debugger interface
+    //
+
+    /** <P> machDesc may not be null. </P>
+
+    <P> useCache should be set to true if debugging is being done
+    locally, and to false if the debugger is being created for the
+    purpose of supporting remote debugging. </P> */
+    public BsdDebuggerLocal(MachineDescription machDesc,
+                              boolean useCache) throws DebuggerException {
+        this.machDesc = machDesc;
+        utils = new DebuggerUtilities(machDesc.getAddressSize(),
+                                      machDesc.isBigEndian()) {
+           public void checkAlignment(long address, long alignment) {
+             // Need to override default checkAlignment because we need to
+             // relax alignment constraints on Bsd/x86
+             if ( (address % alignment != 0)
+                &&(alignment != 8 || address % 4 != 0)) {
+                throw new UnalignedAddressException(
+                        "Trying to read at address: "
+                      + addressValueToString(address)
+                      + " with alignment: " + alignment,
+                        address);
+             }
+           }
+        };
+
+        if (useCache) {
+            // FIXME: re-test necessity of cache on Bsd, where data
+            // fetching is faster
+            // Cache portion of the remote process's address space.
+            // Fetching data over the socket connection to dbx is slow.
+            // Might be faster if we were using a binary protocol to talk to
+            // dbx, but would have to test. For now, this cache works best
+            // if it covers the entire heap of the remote process. FIXME: at
+            // least should make this tunable from the outside, i.e., via
+            // the UI. This is a cache of 4096 4K pages, or 16 MB. The page
+            // size must be adjusted to be the hardware's page size.
+            // (FIXME: should pick this up from the debugger.)
+            if (getCPU().equals("ia64")) {
+              initCache(16384, parseCacheNumPagesProperty(1024));
+            } else {
+              initCache(4096, parseCacheNumPagesProperty(4096));
+            }
+        }
+
+        workerThread = new BsdDebuggerLocalWorkerThread(this);
+        workerThread.start();
+    }
+
+    /** From the Debugger interface via JVMDebugger */
+    public boolean hasProcessList() throws DebuggerException {
+        return false;
+    }
+
+    /** From the Debugger interface via JVMDebugger */
+    public List getProcessList() throws DebuggerException {
+        throw new DebuggerException("getProcessList not implemented yet");
+    }
+
+    private void checkAttached() throws DebuggerException {
+        if (attached) {
+            if (isCore) {
+                throw new DebuggerException("attached to a core dump already");
+            } else {
+                throw new DebuggerException("attached to a process already");
+            }
+        }
+    }
+
+    private void requireAttach() {
+        if (! attached) {
+            throw new RuntimeException("not attached to a process or a core!");
+        }
+    }
+
+    /* called from attach methods */
+    private void findABIVersion() throws DebuggerException {
+        if (lookupByName0("libjvm.so", "__vt_10JavaThread") != 0 ||
+            lookupByName0("libjvm_g.so", "__vt_10JavaThread") != 0) {
+            // old C++ ABI
+            useGCC32ABI = false;
+        } else {
+            // new C++ ABI
+            useGCC32ABI = true;
+        }
+    }
+
+    /** From the Debugger interface via JVMDebugger */
+    public synchronized void attach(int processID) throws DebuggerException {
+        checkAttached();
+        threadList = new ArrayList();
+        loadObjectList = new ArrayList();
+        class AttachTask implements WorkerThreadTask {
+           int pid;
+           public void doit(BsdDebuggerLocal debugger) {
+              debugger.attach0(pid);
+              debugger.attached = true;
+              debugger.isCore = false;
+              findABIVersion();
+           }
+        }
+
+        AttachTask task = new AttachTask();
+        task.pid = processID;
+        workerThread.execute(task);
+    }
+
+    /** From the Debugger interface via JVMDebugger */
+    public synchronized void attach(String execName, String coreName) {
+        checkAttached();
+        threadList = new ArrayList();
+        loadObjectList = new ArrayList();
+        attach0(execName, coreName);
+        attached = true;
+        isCore = true;
+        findABIVersion();
+    }
+
+    /** From the Debugger interface via JVMDebugger */
+    public synchronized boolean detach() {
+        if (!attached) {
+            return false;
+        }
+
+        threadList = null;
+        loadObjectList = null;
+
+        if (isCore) {
+            detach0();
+            attached = false;
+            return true;
+        } else {
+            class DetachTask implements WorkerThreadTask {
+                boolean result = false;
+
+                public void doit(BsdDebuggerLocal debugger) {
+                    debugger.detach0();
+                    debugger.attached = false;
+                    result = true;
+                }
+            }
+
+            DetachTask task = new DetachTask();
+            workerThread.execute(task);
+            return task.result;
+        }
+    }
+
+    /** From the Debugger interface via JVMDebugger */
+    public Address parseAddress(String addressString)
+            throws NumberFormatException {
+        long addr = utils.scanAddress(addressString);
+        if (addr == 0) {
+            return null;
+        }
+        return new BsdAddress(this, addr);
+    }
+
+    /** From the Debugger interface via JVMDebugger */
+    public String getOS() {
+        return PlatformInfo.getOS();
+    }
+
+    /** From the Debugger interface via JVMDebugger */
+    public String getCPU() {
+        return PlatformInfo.getCPU();
+    }
+
+    public boolean hasConsole() throws DebuggerException {
+        return false;
+    }
+
+    public String consoleExecuteCommand(String cmd) throws DebuggerException {
+        throw new DebuggerException("No debugger console available on Bsd");
+    }
+
+    public String getConsolePrompt() throws DebuggerException {
+        return null;
+    }
+
+    /* called from lookup */
+    private long handleGCC32ABI(long addr, String symbol) throws DebuggerException {
+        if (useGCC32ABI && symbol.startsWith("_ZTV")) {
+            return addr + (2 * machDesc.getAddressSize());
+        } else {
+            return addr;
+        }
+    }
+
+    /** From the SymbolLookup interface via Debugger and JVMDebugger */
+    public synchronized Address lookup(String objectName, String symbol) {
+        requireAttach();
+        if (!attached) {
+            return null;
+        }
+
+        if (isCore) {
+            long addr = lookupByName0(objectName, symbol);
+            return (addr == 0)? null : new BsdAddress(this, handleGCC32ABI(addr, symbol));
+        } else {
+            class LookupByNameTask implements WorkerThreadTask {
+                String objectName, symbol;
+                Address result;
+
+                public void doit(BsdDebuggerLocal debugger) {
+                    long addr = debugger.lookupByName0(objectName, symbol);
+                    result = (addr == 0 ? null : new BsdAddress(debugger, handleGCC32ABI(addr, symbol)));
+                }
+            }
+
+            LookupByNameTask task = new LookupByNameTask();
+            task.objectName = objectName;
+            task.symbol = symbol;
+            workerThread.execute(task);
+            return task.result;
+        }
+    }
+
+    /** From the SymbolLookup interface via Debugger and JVMDebugger */
+    public synchronized OopHandle lookupOop(String objectName, String symbol) {
+        Address addr = lookup(objectName, symbol);
+        if (addr == null) {
+            return null;
+        }
+        return addr.addOffsetToAsOopHandle(0);
+    }
+
+    /** From the Debugger interface */
+    public MachineDescription getMachineDescription() {
+        return machDesc;
+    }
+
+    //----------------------------------------------------------------------
+    // Implementation of ThreadAccess interface
+    //
+
+    /** From the ThreadAccess interface via Debugger and JVMDebugger */
+    public ThreadProxy getThreadForIdentifierAddress(Address addr) {
+        return new BsdThread(this, addr);
+    }
+
+    /** From the ThreadAccess interface via Debugger and JVMDebugger */
+    public ThreadProxy getThreadForThreadId(long id) {
+        return new BsdThread(this, id);
+    }
+
+    //----------------------------------------------------------------------
+    // Internal routines (for implementation of BsdAddress).
+    // These must not be called until the MachineDescription has been set up.
+    //
+
+    /** From the BsdDebugger interface */
+    public String addressValueToString(long address) {
+        return utils.addressValueToString(address);
+    }
+
+    /** From the BsdDebugger interface */
+    public BsdAddress readAddress(long address)
+            throws UnmappedAddressException, UnalignedAddressException {
+        long value = readAddressValue(address);
+        return (value == 0 ? null : new BsdAddress(this, value));
+    }
+    public BsdAddress readCompOopAddress(long address)
+            throws UnmappedAddressException, UnalignedAddressException {
+        long value = readCompOopAddressValue(address);
+        return (value == 0 ? null : new BsdAddress(this, value));
+    }
+
+    /** From the BsdDebugger interface */
+    public BsdOopHandle readOopHandle(long address)
+            throws UnmappedAddressException, UnalignedAddressException,
+                NotInHeapException {
+        long value = readAddressValue(address);
+        return (value == 0 ? null : new BsdOopHandle(this, value));
+    }
+    public BsdOopHandle readCompOopHandle(long address)
+            throws UnmappedAddressException, UnalignedAddressException,
+                NotInHeapException {
+        long value = readCompOopAddressValue(address);
+        return (value == 0 ? null : new BsdOopHandle(this, value));
+    }
+
+    //----------------------------------------------------------------------
+    // Thread context access
+    //
+
+    public synchronized long[] getThreadIntegerRegisterSet(int lwp_id)
+                                            throws DebuggerException {
+        requireAttach();
+        if (isCore) {
+            return getThreadIntegerRegisterSet0(lwp_id);
+        } else {
+            class GetThreadIntegerRegisterSetTask implements WorkerThreadTask {
+                int lwp_id;
+                long[] result;
+                public void doit(BsdDebuggerLocal debugger) {
+                    result = debugger.getThreadIntegerRegisterSet0(lwp_id);
+                }
+            }
+
+            GetThreadIntegerRegisterSetTask task = new GetThreadIntegerRegisterSetTask();
+            task.lwp_id = lwp_id;
+            workerThread.execute(task);
+            return task.result;
+        }
+    }
+
+    /** Need to override this to relax alignment checks on x86. */
+    public long readCInteger(long address, long numBytes, boolean isUnsigned)
+        throws UnmappedAddressException, UnalignedAddressException {
+        // Only slightly relaxed semantics -- this is a hack, but is
+        // necessary on x86 where it seems the compiler is
+        // putting some global 64-bit data on 32-bit boundaries
+        if (numBytes == 8) {
+            utils.checkAlignment(address, 4);
+        } else {
+            utils.checkAlignment(address, numBytes);
+        }
+        byte[] data = readBytes(address, numBytes);
+        return utils.dataToCInteger(data, isUnsigned);
+    }
+
+    // Overridden from DebuggerBase because we need to relax alignment
+    // constraints on x86
+    public long readJLong(long address)
+        throws UnmappedAddressException, UnalignedAddressException {
+        utils.checkAlignment(address, jintSize);
+        byte[] data = readBytes(address, jlongSize);
+        return utils.dataToJLong(data, jlongSize);
+    }
+
+    //----------------------------------------------------------------------
+    // Address access. Can not be package private, but should only be
+    // accessed by the architecture-specific subpackages.
+
+    /** From the BsdDebugger interface */
+    public long getAddressValue(Address addr) {
+      if (addr == null) return 0;
+      return ((BsdAddress) addr).getValue();
+    }
+
+    /** From the BsdDebugger interface */
+    public Address newAddress(long value) {
+      if (value == 0) return null;
+      return new BsdAddress(this, value);
+    }
+
+    /** From the BsdCDebugger interface */
+    public List/*<ThreadProxy>*/ getThreadList() {
+      requireAttach();
+      return threadList;
+    }
+
+    /** From the BsdCDebugger interface */
+    public List/*<LoadObject>*/ getLoadObjectList() {
+      requireAttach();
+      return loadObjectList;
+    }
+
+    /** From the BsdCDebugger interface */
+    public synchronized ClosestSymbol lookup(long addr) {
+       requireAttach();
+       if (isCore) {
+          return lookupByAddress0(addr);
+       } else {
+          class LookupByAddressTask implements WorkerThreadTask {
+             long addr;
+             ClosestSymbol result;
+
+             public void doit(BsdDebuggerLocal debugger) {
+                 result = debugger.lookupByAddress0(addr);
+             }
+          }
+
+          LookupByAddressTask task = new LookupByAddressTask();
+          task.addr = addr;
+          workerThread.execute(task);
+          return task.result;
+       }
+    }
+
+    public CDebugger getCDebugger() {
+      if (cdbg == null) {
+         String cpu = getCPU();
+         if (cpu.equals("ia64") ) {
+            // IA-64 is not supported because of stack-walking issues
+            return null;
+         }
+         cdbg = new BsdCDebugger(this);
+      }
+      return cdbg;
+    }
+
+    /** This reads bytes from the remote process. */
+    public synchronized ReadResult readBytesFromProcess(long address,
+            long numBytes) throws UnmappedAddressException, DebuggerException {
+        requireAttach();
+        if (isCore) {
+            byte[] res = readBytesFromProcess0(address, numBytes);
+            return (res != null)? new ReadResult(res) : new ReadResult(address);
+        } else {
+            class ReadBytesFromProcessTask implements WorkerThreadTask {
+                long address, numBytes;
+                ReadResult result;
+                public void doit(BsdDebuggerLocal debugger) {
+                    byte[] res = debugger.readBytesFromProcess0(address, numBytes);
+                    if (res != null)
+                        result = new ReadResult(res);
+                    else
+                        result = new ReadResult(address);
+                }
+            }
+
+            ReadBytesFromProcessTask task = new ReadBytesFromProcessTask();
+            task.address = address;
+            task.numBytes = numBytes;
+            workerThread.execute(task);
+            return task.result;
+        }
+    }
+
+    public void writeBytesToProcess(long address, long numBytes, byte[] data)
+        throws UnmappedAddressException, DebuggerException {
+        // FIXME
+        throw new DebuggerException("Unimplemented");
+    }
+
+    static {
+        System.loadLibrary("saproc");
+        init0();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdOopHandle.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.debugger.bsd;
+
+import sun.jvm.hotspot.debugger.*;
+
+class BsdOopHandle extends BsdAddress implements OopHandle {
+  BsdOopHandle(BsdDebugger debugger, long addr) {
+    super(debugger, addr);
+  }
+
+  public boolean equals(Object arg) {
+    if (arg == null) {
+      return false;
+    }
+
+    if (!(arg instanceof BsdOopHandle)) {
+      return false;
+    }
+
+    return (addr == ((BsdAddress) arg).addr);
+  }
+
+  public Address    addOffsetTo       (long offset) throws UnsupportedOperationException {
+    throw new UnsupportedOperationException("addOffsetTo not applicable to OopHandles (interior object pointers not allowed)");
+  }
+
+  public Address    andWithMask(long mask) throws UnsupportedOperationException {
+    throw new UnsupportedOperationException("andWithMask not applicable to OopHandles (i.e., anything but C addresses)");
+  }
+
+  public Address    orWithMask(long mask) throws UnsupportedOperationException {
+    throw new UnsupportedOperationException("orWithMask not applicable to OopHandles (i.e., anything but C addresses)");
+  }
+
+  public Address    xorWithMask(long mask) throws UnsupportedOperationException {
+    throw new UnsupportedOperationException("xorWithMask not applicable to OopHandles (i.e., anything but C addresses)");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThread.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd;
+
+import sun.jvm.hotspot.debugger.*;
+
+class BsdThread implements ThreadProxy {
+    private BsdDebugger debugger;
+    private int           lwp_id;
+
+    /** The address argument must be the address of the _thread_id in the
+        OSThread. It's value is result ::gettid() call. */
+    BsdThread(BsdDebugger debugger, Address addr) {
+        this.debugger = debugger;
+        // FIXME: size of data fetched here should be configurable.
+        // However, making it so would produce a dependency on the "types"
+        // package from the debugger package, which is not desired.
+        this.lwp_id = (int) addr.getCIntegerAt(0, 4, true);
+    }
+
+    BsdThread(BsdDebugger debugger, long id) {
+        this.debugger = debugger;
+        this.lwp_id = (int) id;
+    }
+
+    public boolean equals(Object obj) {
+        if ((obj == null) || !(obj instanceof BsdThread)) {
+            return false;
+        }
+
+        return (((BsdThread) obj).lwp_id == lwp_id);
+    }
+
+    public int hashCode() {
+        return lwp_id;
+    }
+
+    public String toString() {
+        return Integer.toString(lwp_id);
+    }
+
+    public ThreadContext getContext() throws IllegalThreadStateException {
+        long[] data = debugger.getThreadIntegerRegisterSet(lwp_id);
+        ThreadContext context = BsdThreadContextFactory.createThreadContext(debugger);
+        for (int i = 0; i < data.length; i++) {
+            context.setRegister(i, data[i]);
+        }
+        return context;
+    }
+
+    public boolean canSetContext() throws DebuggerException {
+        return false;
+    }
+
+    public void setContext(ThreadContext context)
+      throws IllegalThreadStateException, DebuggerException {
+        throw new DebuggerException("Unimplemented");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdThreadContextFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.bsd.amd64.*;
+import sun.jvm.hotspot.debugger.bsd.x86.*;
+
+class BsdThreadContextFactory {
+   static ThreadContext createThreadContext(BsdDebugger dbg) {
+      String cpu = dbg.getCPU();
+      if (cpu.equals("x86")) {
+         return new BsdX86ThreadContext(dbg);
+      } else if (cpu.equals("amd64")) {
+         return new BsdAMD64ThreadContext(dbg);
+      } else {
+         throw new RuntimeException("cpu " + cpu + " is not yet supported");
+      }
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/SharedObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.cdbg.*;
+import sun.jvm.hotspot.debugger.posix.*;
+
+/** A Object can represent either a .so or an a.out file. */
+
+class SharedObject extends DSO {
+  SharedObject(BsdDebugger dbg, String filename, long size, Address relocation) {
+    super(filename, size, relocation);
+    this.dbg     = dbg;
+  }
+
+  protected Address newAddress(long address) {
+    return dbg.newAddress(address);
+  }
+
+  protected long getAddressValue(Address addr) {
+    return dbg.getAddressValue(addr);
+  }
+
+  private BsdDebugger   dbg;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/amd64/BsdAMD64CFrame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd.amd64;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.bsd.*;
+import sun.jvm.hotspot.debugger.cdbg.*;
+import sun.jvm.hotspot.debugger.cdbg.basic.*;
+
+final public class BsdAMD64CFrame extends BasicCFrame {
+   public BsdAMD64CFrame(BsdDebugger dbg, Address rbp, Address rip) {
+      super(dbg.getCDebugger());
+      this.rbp = rbp;
+      this.rip = rip;
+      this.dbg = dbg;
+   }
+
+   // override base class impl to avoid ELF parsing
+   public ClosestSymbol closestSymbolToPC() {
+      // try native lookup in debugger.
+      return dbg.lookup(dbg.getAddressValue(pc()));
+   }
+
+   public Address pc() {
+      return rip;
+   }
+
+   public Address localVariableBase() {
+      return rbp;
+   }
+
+   public CFrame sender() {
+      if (rbp == null) {
+        return null;
+      }
+
+      Address nextRBP = rbp.getAddressAt( 0 * ADDRESS_SIZE);
+      if (nextRBP == null) {
+        return null;
+      }
+      Address nextPC  = rbp.getAddressAt( 1 * ADDRESS_SIZE);
+      if (nextPC == null) {
+        return null;
+      }
+      return new BsdAMD64CFrame(dbg, nextRBP, nextPC);
+   }
+
+   // package/class internals only
+   private static final int ADDRESS_SIZE = 8;
+   private Address rip;
+   private Address rbp;
+   private BsdDebugger dbg;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/amd64/BsdAMD64ThreadContext.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd.amd64;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.amd64.*;
+import sun.jvm.hotspot.debugger.bsd.*;
+
+public class BsdAMD64ThreadContext extends AMD64ThreadContext {
+  private BsdDebugger debugger;
+
+  public BsdAMD64ThreadContext(BsdDebugger debugger) {
+    super();
+    this.debugger = debugger;
+  }
+
+  public void setRegisterAsAddress(int index, Address value) {
+    setRegister(index, debugger.getAddressValue(value));
+  }
+
+  public Address getRegisterAsAddress(int index) {
+    return debugger.newAddress(getRegister(index));
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/x86/BsdX86CFrame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd.x86;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.bsd.*;
+import sun.jvm.hotspot.debugger.cdbg.*;
+import sun.jvm.hotspot.debugger.cdbg.basic.*;
+
+final public class BsdX86CFrame extends BasicCFrame {
+   // package/class internals only
+   public BsdX86CFrame(BsdDebugger dbg, Address ebp, Address pc) {
+      super(dbg.getCDebugger());
+      this.ebp = ebp;
+      this.pc = pc;
+      this.dbg = dbg;
+   }
+
+   // override base class impl to avoid ELF parsing
+   public ClosestSymbol closestSymbolToPC() {
+      // try native lookup in debugger.
+      return dbg.lookup(dbg.getAddressValue(pc()));
+   }
+
+   public Address pc() {
+      return pc;
+   }
+
+   public Address localVariableBase() {
+      return ebp;
+   }
+
+   public CFrame sender() {
+      if (ebp == null) {
+        return null;
+      }
+
+      Address nextEBP = ebp.getAddressAt( 0 * ADDRESS_SIZE);
+      if (nextEBP == null) {
+        return null;
+      }
+      Address nextPC  = ebp.getAddressAt( 1 * ADDRESS_SIZE);
+      if (nextPC == null) {
+        return null;
+      }
+      return new BsdX86CFrame(dbg, nextEBP, nextPC);
+   }
+
+   private static final int ADDRESS_SIZE = 4;
+   private Address pc;
+   private Address ebp;
+   private BsdDebugger dbg;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/x86/BsdX86ThreadContext.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.debugger.bsd.x86;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.x86.*;
+import sun.jvm.hotspot.debugger.bsd.*;
+
+public class BsdX86ThreadContext extends X86ThreadContext {
+  private BsdDebugger debugger;
+
+  public BsdX86ThreadContext(BsdDebugger debugger) {
+    super();
+    this.debugger = debugger;
+  }
+
+  public void setRegisterAsAddress(int index, Address value) {
+    setRegister(index, debugger.getAddressValue(value));
+  }
+
+  public Address getRegisterAsAddress(int index) {
+    return debugger.newAddress(getRegister(index));
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxAddress.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.dbx;
-
-import sun.jvm.hotspot.debugger.*;
-
-class DbxAddress implements Address {
-  protected DbxDebugger debugger;
-  protected long addr;
-
-  DbxAddress(DbxDebugger debugger, long addr) {
-    this.debugger = debugger;
-    this.addr = addr;
-  }
-
-  //
-  // Basic Java routines
-  //
-
-  public boolean equals(Object arg) {
-    if (arg == null) {
-      return false;
-    }
-
-    if (!(arg instanceof DbxAddress)) {
-      return false;
-    }
-
-    return (addr == ((DbxAddress) arg).addr);
-  }
-
-  public int hashCode() {
-    // FIXME: suggestions on a better hash code?
-    return (int) addr;
-  }
-
-  public String toString() {
-    return debugger.addressValueToString(addr);
-  }
-
-  //
-  // C/C++-related routines
-  //
-
-  public long getCIntegerAt(long offset, long numBytes, boolean isUnsigned) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readCInteger(addr + offset, numBytes, isUnsigned);
-  }
-
-  public Address getAddressAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readAddress(addr + offset);
-  }
-  public Address getCompOopAddressAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readCompOopAddress(addr + offset);
-  }
-
-  //
-  // Java-related routines
-  //
-
-  public boolean getJBooleanAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJBoolean(addr + offset);
-  }
-
-  public byte getJByteAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJByte(addr + offset);
-  }
-
-  public char getJCharAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJChar(addr + offset);
-  }
-
-  public double getJDoubleAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJDouble(addr + offset);
-  }
-
-  public float getJFloatAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJFloat(addr + offset);
-  }
-
-  public int getJIntAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJInt(addr + offset);
-  }
-
-  public long getJLongAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJLong(addr + offset);
-  }
-
-  public short getJShortAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJShort(addr + offset);
-  }
-
-  public OopHandle getOopHandleAt(long offset)
-    throws UnalignedAddressException, UnmappedAddressException, NotInHeapException {
-    return debugger.readOopHandle(addr + offset);
-  }
-
-  public OopHandle getCompOopHandleAt(long offset)
-    throws UnalignedAddressException, UnmappedAddressException, NotInHeapException {
-    return debugger.readCompOopHandle(addr + offset);
-  }
-
-  // Mutators -- not implemented for now (FIXME)
-  public void setCIntegerAt(long offset, long numBytes, long value) {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void setAddressAt(long offset, Address value) {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setJBooleanAt      (long offset, boolean value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setJByteAt         (long offset, byte value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setJCharAt         (long offset, char value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setJDoubleAt       (long offset, double value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setJFloatAt        (long offset, float value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setJIntAt          (long offset, int value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setJLongAt         (long offset, long value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setJShortAt        (long offset, short value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-  public void       setOopHandleAt     (long offset, OopHandle value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    throw new DebuggerException("Unimplemented");
-  }
-
-  //
-  // Arithmetic operations -- necessary evil.
-  //
-
-  public Address    addOffsetTo       (long offset) throws UnsupportedOperationException {
-    long value = addr + offset;
-    if (value == 0) {
-      return null;
-    }
-    return new DbxAddress(debugger, value);
-  }
-
-  public OopHandle  addOffsetToAsOopHandle(long offset) throws UnsupportedOperationException {
-    long value = addr + offset;
-    if (value == 0) {
-      return null;
-    }
-    return new DbxOopHandle(debugger, value);
-  }
-
-  /** (FIXME: any signed/unsigned issues? Should this work for
-      OopHandles?) */
-  public long       minus(Address arg) {
-    if (arg == null) {
-      return addr;
-    }
-    return addr - ((DbxAddress) arg).addr;
-  }
-
-  // Two's complement representation.
-  // All negative numbers are larger than positive numbers.
-  // Numbers with the same sign can be compared normally.
-  // Test harness is below in main().
-
-  public boolean    lessThan          (Address arg) {
-    if (arg == null) {
-      return false;
-    }
-    DbxAddress dbxArg = (DbxAddress) arg;
-    if ((addr >= 0) && (dbxArg.addr < 0)) {
-      return true;
-    }
-    if ((addr < 0) && (dbxArg.addr >= 0)) {
-      return false;
-    }
-    return (addr < dbxArg.addr);
-  }
-
-  public boolean    lessThanOrEqual   (Address arg) {
-    if (arg == null) {
-      return false;
-    }
-    DbxAddress dbxArg = (DbxAddress) arg;
-    if ((addr >= 0) && (dbxArg.addr < 0)) {
-      return true;
-    }
-    if ((addr < 0) && (dbxArg.addr >= 0)) {
-      return false;
-    }
-    return (addr <= dbxArg.addr);
-  }
-
-  public boolean    greaterThan       (Address arg) {
-    if (arg == null) {
-      return true;
-    }
-    DbxAddress dbxArg = (DbxAddress) arg;
-    if ((addr >= 0) && (dbxArg.addr < 0)) {
-      return false;
-    }
-    if ((addr < 0) && (dbxArg.addr >= 0)) {
-      return true;
-    }
-    return (addr > dbxArg.addr);
-  }
-
-  public boolean    greaterThanOrEqual(Address arg) {
-    if (arg == null) {
-      return true;
-    }
-    DbxAddress dbxArg = (DbxAddress) arg;
-    if ((addr >= 0) && (dbxArg.addr < 0)) {
-      return false;
-    }
-    if ((addr < 0) && (dbxArg.addr >= 0)) {
-      return true;
-    }
-    return (addr >= dbxArg.addr);
-  }
-
-  public Address    andWithMask(long mask) throws UnsupportedOperationException {
-    long value = addr & mask;
-    if (value == 0) {
-      return null;
-    }
-    return new DbxAddress(debugger, value);
-  }
-
-  public Address    orWithMask(long mask) throws UnsupportedOperationException {
-    long value = addr | mask;
-    if (value == 0) {
-      return null;
-    }
-    return new DbxAddress(debugger, value);
-  }
-
-  public Address    xorWithMask(long mask) throws UnsupportedOperationException {
-    long value = addr ^ mask;
-    if (value == 0) {
-      return null;
-    }
-    return new DbxAddress(debugger, value);
-  }
-
-
-  //--------------------------------------------------------------------------------
-  // Internals only below this point
-  //
-
-  long getValue() {
-    return addr;
-  }
-
-
-  private static void check(boolean arg, String failMessage) {
-    if (!arg) {
-      System.err.println(failMessage + ": FAILED");
-      System.exit(1);
-    }
-  }
-
-  // Test harness
-  public static void main(String[] args) {
-    // p/n indicates whether the interior address is really positive
-    // or negative. In unsigned terms, p1 < p2 < n1 < n2.
-
-    DbxAddress p1 = new DbxAddress(null, 0x7FFFFFFFFFFFFFF0L);
-    DbxAddress p2 = (DbxAddress) p1.addOffsetTo(10);
-    DbxAddress n1 = (DbxAddress) p2.addOffsetTo(10);
-    DbxAddress n2 = (DbxAddress) n1.addOffsetTo(10);
-
-    // lessThan positive tests
-    check(p1.lessThan(p2), "lessThan 1");
-    check(p1.lessThan(n1), "lessThan 2");
-    check(p1.lessThan(n2), "lessThan 3");
-    check(p2.lessThan(n1), "lessThan 4");
-    check(p2.lessThan(n2), "lessThan 5");
-    check(n1.lessThan(n2), "lessThan 6");
-
-    // lessThan negative tests
-    check(!p1.lessThan(p1), "lessThan 7");
-    check(!p2.lessThan(p2), "lessThan 8");
-    check(!n1.lessThan(n1), "lessThan 9");
-    check(!n2.lessThan(n2), "lessThan 10");
-
-    check(!p2.lessThan(p1), "lessThan 11");
-    check(!n1.lessThan(p1), "lessThan 12");
-    check(!n2.lessThan(p1), "lessThan 13");
-    check(!n1.lessThan(p2), "lessThan 14");
-    check(!n2.lessThan(p2), "lessThan 15");
-    check(!n2.lessThan(n1), "lessThan 16");
-
-    // lessThanOrEqual positive tests
-    check(p1.lessThanOrEqual(p1), "lessThanOrEqual 1");
-    check(p2.lessThanOrEqual(p2), "lessThanOrEqual 2");
-    check(n1.lessThanOrEqual(n1), "lessThanOrEqual 3");
-    check(n2.lessThanOrEqual(n2), "lessThanOrEqual 4");
-
-    check(p1.lessThanOrEqual(p2), "lessThanOrEqual 5");
-    check(p1.lessThanOrEqual(n1), "lessThanOrEqual 6");
-    check(p1.lessThanOrEqual(n2), "lessThanOrEqual 7");
-    check(p2.lessThanOrEqual(n1), "lessThanOrEqual 8");
-    check(p2.lessThanOrEqual(n2), "lessThanOrEqual 9");
-    check(n1.lessThanOrEqual(n2), "lessThanOrEqual 10");
-
-    // lessThanOrEqual negative tests
-    check(!p2.lessThanOrEqual(p1), "lessThanOrEqual 11");
-    check(!n1.lessThanOrEqual(p1), "lessThanOrEqual 12");
-    check(!n2.lessThanOrEqual(p1), "lessThanOrEqual 13");
-    check(!n1.lessThanOrEqual(p2), "lessThanOrEqual 14");
-    check(!n2.lessThanOrEqual(p2), "lessThanOrEqual 15");
-    check(!n2.lessThanOrEqual(n1), "lessThanOrEqual 16");
-
-    // greaterThan positive tests
-    check(n2.greaterThan(p1), "greaterThan 1");
-    check(n2.greaterThan(p2), "greaterThan 2");
-    check(n2.greaterThan(n1), "greaterThan 3");
-    check(n1.greaterThan(p1), "greaterThan 4");
-    check(n1.greaterThan(p2), "greaterThan 5");
-    check(p2.greaterThan(p1), "greaterThan 6");
-
-    // greaterThan negative tests
-    check(!p1.greaterThan(p1), "greaterThan 7");
-    check(!p2.greaterThan(p2), "greaterThan 8");
-    check(!n1.greaterThan(n1), "greaterThan 9");
-    check(!n2.greaterThan(n2), "greaterThan 10");
-
-    check(!p1.greaterThan(n2), "greaterThan 11");
-    check(!p2.greaterThan(n2), "greaterThan 12");
-    check(!n1.greaterThan(n2), "greaterThan 13");
-    check(!p1.greaterThan(n1), "greaterThan 14");
-    check(!p2.greaterThan(n1), "greaterThan 15");
-    check(!p1.greaterThan(p2), "greaterThan 16");
-
-    // greaterThanOrEqual positive tests
-    check(p1.greaterThanOrEqual(p1), "greaterThanOrEqual 1");
-    check(p2.greaterThanOrEqual(p2), "greaterThanOrEqual 2");
-    check(n1.greaterThanOrEqual(n1), "greaterThanOrEqual 3");
-    check(n2.greaterThanOrEqual(n2), "greaterThanOrEqual 4");
-
-    check(n2.greaterThanOrEqual(p1), "greaterThanOrEqual 5");
-    check(n2.greaterThanOrEqual(p2), "greaterThanOrEqual 6");
-    check(n2.greaterThanOrEqual(n1), "greaterThanOrEqual 7");
-    check(n1.greaterThanOrEqual(p1), "greaterThanOrEqual 8");
-    check(n1.greaterThanOrEqual(p2), "greaterThanOrEqual 9");
-    check(p2.greaterThanOrEqual(p1), "greaterThanOrEqual 10");
-
-    // greaterThanOrEqual negative tests
-    check(!p1.greaterThanOrEqual(n2), "greaterThanOrEqual 11");
-    check(!p2.greaterThanOrEqual(n2), "greaterThanOrEqual 12");
-    check(!n1.greaterThanOrEqual(n2), "greaterThanOrEqual 13");
-    check(!p1.greaterThanOrEqual(n1), "greaterThanOrEqual 14");
-    check(!p2.greaterThanOrEqual(n1), "greaterThanOrEqual 15");
-    check(!p1.greaterThanOrEqual(p2), "greaterThanOrEqual 16");
-
-    System.err.println("DbxAddress: all tests passed successfully.");
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxDebugger.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.dbx;
-
-import sun.jvm.hotspot.debugger.*;
-
-/** An extension of the JVMDebugger interface with a few additions to
-    support 32-bit vs. 64-bit debugging as well as features required
-    by the architecture-specific subpackages. */
-
-public interface DbxDebugger extends JVMDebugger {
-  public String       addressValueToString(long address) throws DebuggerException;
-  public boolean      readJBoolean(long address) throws DebuggerException;
-  public byte         readJByte(long address) throws DebuggerException;
-  public char         readJChar(long address) throws DebuggerException;
-  public double       readJDouble(long address) throws DebuggerException;
-  public float        readJFloat(long address) throws DebuggerException;
-  public int          readJInt(long address) throws DebuggerException;
-  public long         readJLong(long address) throws DebuggerException;
-  public short        readJShort(long address) throws DebuggerException;
-  public long         readCInteger(long address, long numBytes, boolean isUnsigned)
-    throws DebuggerException;
-  public DbxAddress   readAddress(long address) throws DebuggerException;
-  public DbxAddress   readCompOopAddress(long address) throws DebuggerException;
-  public DbxOopHandle readOopHandle(long address) throws DebuggerException;
-  public DbxOopHandle readCompOopHandle(long address) throws DebuggerException;
-  public long[]       getThreadIntegerRegisterSet(int tid) throws DebuggerException;
-  public Address      newAddress(long value) throws DebuggerException;
-
-  // NOTE: this interface implicitly contains the following methods:
-  // From the Debugger interface via JVMDebugger
-  //   public void attach(int processID) throws DebuggerException;
-  //   public void attach(String executableName, String coreFileName) throws DebuggerException;
-  //   public boolean detach();
-  //   public Address parseAddress(String addressString) throws NumberFormatException;
-  //   public long getAddressValue(Address addr) throws DebuggerException;
-  //   public String getOS();
-  //   public String getCPU();
-  // From the SymbolLookup interface via Debugger and JVMDebugger
-  //   public Address lookup(String objectName, String symbol);
-  //   public OopHandle lookupOop(String objectName, String symbol);
-  // From the JVMDebugger interface
-  //   public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
-  //                                               long jbyteSize,
-  //                                               long jcharSize,
-  //                                               long jdoubleSize,
-  //                                               long jfloatSize,
-  //                                               long jintSize,
-  //                                               long jlongSize,
-  //                                               long jshortSize);
-  // From the ThreadAccess interface via Debugger and JVMDebugger
-  //   public ThreadProxy getThreadForIdentifierAddress(Address addr);
-  //   public ThreadProxy getThreadForThreadId(long id);
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxDebuggerLocal.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,744 +0,0 @@
-/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.dbx;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.dbx.sparc.*;
-import sun.jvm.hotspot.debugger.dbx.x86.*;
-import sun.jvm.hotspot.debugger.cdbg.CDebugger;
-import sun.jvm.hotspot.utilities.*;
-
-/** <P> An implementation of the JVMDebugger interface which sits on
-    top of dbx and relies on the SA's dbx import module for
-    communication with the debugger. </P>
-
-    <P> <B>NOTE</B> that since we have the notion of fetching "Java
-    primitive types" from the remote process (which might have
-    different sizes than we expect) we have a bootstrapping
-    problem. We need to know the sizes of these types before we can
-    fetch them. The current implementation solves this problem by
-    requiring that it be configured with these type sizes before they
-    can be fetched. The readJ(Type) routines here will throw a
-    RuntimeException if they are called before the debugger is
-    configured with the Java primitive type sizes. </P>
-*/
-
-public class DbxDebuggerLocal extends DebuggerBase implements DbxDebugger {
-  // These may be set by DbxDebuggerRemote
-  protected boolean unalignedAccessesOkay;
-  protected DbxThreadFactory threadFactory;
-
-  private String dbxPathName;
-  private String[] dbxSvcAgentDSOPathNames;
-  private Process dbxProcess;
-  private StreamMonitor dbxOutStreamMonitor;
-  private StreamMonitor dbxErrStreamMonitor;
-  private PrintWriter dbxOstr;
-  private PrintWriter out;
-  private InputLexer in;
-  private Socket importModuleSocket;
-  private static final int PORT = 21928;
-  private static final int  LONG_TIMEOUT = 60000;
-  private static final int  DBX_MODULE_NOT_FOUND      = 101;
-  private static final int  DBX_MODULE_LOADED         = 102;
-
-  //--------------------------------------------------------------------------------
-  // Implementation of Debugger interface
-  //
-
-  /** <P> machDesc may be null if it couldn't be determined yet; i.e.,
-      if we're on SPARC, we need to ask the remote process whether
-      we're in 32- or 64-bit mode. </P>
-
-      <P> useCache should be set to true if debugging is being done
-      locally, and to false if the debugger is being created for the
-      purpose of supporting remote debugging. </P> */
-  public DbxDebuggerLocal(MachineDescription machDesc,
-                          String dbxPathName,
-                          String[] dbxSvcAgentDSOPathNames,
-                          boolean useCache) {
-    this.machDesc = machDesc;
-    this.dbxPathName = dbxPathName;
-    this.dbxSvcAgentDSOPathNames = dbxSvcAgentDSOPathNames;
-    int cacheNumPages;
-    int cachePageSize;
-    if (PlatformInfo.getCPU().equals("sparc")) {
-      cacheNumPages = parseCacheNumPagesProperty(2048);
-      cachePageSize = 8192;
-      threadFactory = new DbxSPARCThreadFactory(this);
-    } else if (PlatformInfo.getCPU().equals("x86")) {
-      cacheNumPages = 4096;
-      cachePageSize = 4096;
-      threadFactory = new DbxX86ThreadFactory(this);
-      unalignedAccessesOkay = true;
-    } else {
-      throw new RuntimeException("Thread access for CPU architecture " + PlatformInfo.getCPU() + " not yet supported");
-    }
-    if (useCache) {
-      // Cache portion of the remote process's address space.
-      // Fetching data over the socket connection to dbx is relatively
-      // slow. For now, this cache works best if it covers the entire
-      // heap of the remote process. FIXME: at least should make this
-      // tunable from the outside, i.e., via the UI. This is a 16 MB
-      // cache divided on SPARC into 2048 8K pages and on x86 into
-      // 4096 4K pages; the page size must be adjusted to be the OS's
-      // page size. (FIXME: should pick this up from the debugger.)
-      initCache(cachePageSize, cacheNumPages);
-    }
-  }
-
-  /** Only called by DbxDebuggerRemote */
-  protected DbxDebuggerLocal() {
-  }
-
-  /** FIXME: implement this with a Runtime.exec() of ps followed by
-      parsing of its output */
-  public boolean hasProcessList() throws DebuggerException {
-    return false;
-  }
-
-  public List getProcessList() throws DebuggerException {
-    throw new DebuggerException("Not yet supported");
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public synchronized void attach(int processID) throws DebuggerException {
-    try {
-      launchProcess();
-      dbxErrStreamMonitor.addTrigger("dbx: no process", 1);
-      dbxErrStreamMonitor.addTrigger("dbx: Cannot open", 1);
-      dbxErrStreamMonitor.addTrigger("dbx: Cannot find", DBX_MODULE_NOT_FOUND);
-      dbxOstr = new PrintWriter(dbxProcess.getOutputStream(), true);
-      dbxOstr.println("debug - " + processID);
-      dbxOstr.println("kprint -u2 \\(ready\\)");
-      boolean seen = dbxErrStreamMonitor.waitFor("(ready)", LONG_TIMEOUT);
-      if (!seen) {
-        detach();
-        throw new DebuggerException("Timed out while connecting to process " + processID);
-      }
-      List retVals = dbxErrStreamMonitor.getTriggersSeen();
-      if (retVals.contains(new Integer(1))) {
-        detach();
-        throw new DebuggerException("No such process " + processID);
-      }
-
-      // Throws DebuggerException upon failure
-      importDbxModule();
-
-      dbxOstr.println("svc_agent_run");
-
-      connectToImportModule();
-
-      // Set "fail fast" mode on process memory reads
-      printlnToOutput("peek_fail_fast 1");
-    }
-    catch (IOException e) {
-      detach();
-      throw new DebuggerException("Error while connecting to dbx process", e);
-    }
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public synchronized void attach(String executableName, String coreFileName) throws DebuggerException {
-    try {
-      launchProcess();
-      // Missing executable
-      dbxErrStreamMonitor.addTrigger("dbx: Cannot open", 1);
-      // Missing core file
-      dbxErrStreamMonitor.addTrigger("dbx: can't read", 2);
-      // Corrupt executable
-      dbxErrStreamMonitor.addTrigger("dbx: File", 3);
-      // Corrupt core file
-      dbxErrStreamMonitor.addTrigger("dbx: Unable to read", 4);
-      // Mismatched core and executable
-      dbxErrStreamMonitor.addTrigger("dbx: core object name", 5);
-      // Missing loadobject
-      dbxErrStreamMonitor.addTrigger("dbx: can't stat", 6);
-      // Successful load of svc module
-      dbxOstr = new PrintWriter(dbxProcess.getOutputStream(), true);
-      dbxOstr.println("debug " + executableName + " " + coreFileName);
-      dbxOstr.println("kprint -u2 \\(ready\\)");
-      boolean seen = dbxErrStreamMonitor.waitFor("(ready)", LONG_TIMEOUT);
-      if (!seen) {
-        detach();
-        throw new DebuggerException("Timed out while attaching to core file");
-      }
-      List retVals = dbxErrStreamMonitor.getTriggersSeen();
-      if (retVals.size() > 0) {
-        detach();
-
-        if (retVals.contains(new Integer(1))) {
-          throw new DebuggerException("Can not find executable \"" + executableName + "\"");
-        } else if (retVals.contains(new Integer(2))) {
-          throw new DebuggerException("Can not find core file \"" + coreFileName + "\"");
-        } else if (retVals.contains(new Integer(3))) {
-          throw new DebuggerException("Corrupt executable \"" + executableName + "\"");
-        } else if (retVals.contains(new Integer(4))) {
-          throw new DebuggerException("Corrupt core file \"" + coreFileName + "\"");
-        } else if (retVals.contains(new Integer(5))) {
-          throw new DebuggerException("Mismatched core file/executable \"" + coreFileName + "\"/\"" + executableName + "\"");
-        } else {
-          throw new DebuggerException("Couldn't find all loaded libraries for executable \"" + executableName + "\"");
-        }
-      }
-
-      // Throws DebuggerException upon failure
-      importDbxModule();
-
-      dbxOstr.println("svc_agent_run");
-
-      connectToImportModule();
-
-      // Set "fail fast" mode on process memory reads
-      printlnToOutput("peek_fail_fast 1");
-    }
-    catch (IOException e) {
-      detach();
-      throw new DebuggerException("Error while connecting to dbx process", e);
-    }
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public synchronized boolean detach() {
-    try {
-      if (dbxProcess == null) {
-        return false;
-      }
-
-      if (out != null && dbxOstr != null) {
-        printlnToOutput("exit");
-        dbxOstr.println("exit");
-
-        // Wait briefly for the process to exit (FIXME: should make this
-        // nicer)
-        try {
-          Thread.sleep(500);
-        }
-        catch (InterruptedException e) {
-        }
-      }
-
-      shutdown();
-
-      return true;
-    } catch (IOException e) {
-      e.printStackTrace();
-      return false;
-    }
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public Address parseAddress(String addressString) throws NumberFormatException {
-    long addr = utils.scanAddress(addressString);
-    if (addr == 0) {
-      return null;
-    }
-    return new DbxAddress(this, addr);
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public String getOS() {
-    return PlatformInfo.getOS();
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public String getCPU() {
-    return PlatformInfo.getCPU();
-  }
-
-  public boolean hasConsole() throws DebuggerException {
-    return true;
-  }
-
-  public synchronized String consoleExecuteCommand(String cmd) throws DebuggerException {
-    try {
-      // A little tricky. We need to cause the dbx import module to
-      // exit, then print our command on dbx's stdin along with a
-      // command which will allow our StreamMonitors to
-      // resynchronize. We need save the output from the StreamMonitors
-      // along the way.
-      printlnToOutput("exit");
-      importModuleSocket.close();
-      importModuleSocket = null;
-      out = null;
-      in = null;
-      dbxOstr.println("kprint \\(ready\\)");
-      dbxOstr.flush();
-      dbxOutStreamMonitor.waitFor("(ready)", LONG_TIMEOUT);
-
-      dbxOutStreamMonitor.startCapture();
-      dbxErrStreamMonitor.startCapture();
-      dbxOstr.println(cmd);
-      dbxOstr.println("kprint \\(ready\\)");
-      dbxOutStreamMonitor.waitFor("(ready)", LONG_TIMEOUT);
-      String result = dbxOutStreamMonitor.stopCapture();
-      String result2 = dbxErrStreamMonitor.stopCapture();
-      result = result + result2;
-      // Cut out the "(ready)" string
-      StringBuffer outBuf = new StringBuffer(result.length());
-      BufferedReader reader = new BufferedReader(new StringReader(result));
-      // FIXME: bug in BufferedReader? readLine returns null when
-      // ready() returns true.
-      String line = null;
-      do {
-        line = reader.readLine();
-        if ((line != null) && (!line.equals("(ready)"))) {
-          outBuf.append(line);
-          outBuf.append("\n");
-        }
-      } while (line != null);
-      dbxOstr.println("svc_agent_run");
-      dbxOstr.flush();
-
-      connectToImportModule();
-
-      return outBuf.toString();
-    }
-    catch (IOException e) {
-      detach();
-      throw new DebuggerException("Error while executing command on dbx console", e);
-    }
-  }
-
-  public String getConsolePrompt() throws DebuggerException {
-    return "(dbx) ";
-  }
-
-  public CDebugger getCDebugger() throws DebuggerException {
-    return null;
-  }
-
-  /** From the SymbolLookup interface via Debugger and JVMDebugger */
-  public synchronized Address lookup(String objectName, String symbol) {
-    long addr = lookupInProcess(objectName, symbol);
-    if (addr == 0) {
-      return null;
-    }
-    return new DbxAddress(this, addr);
-  }
-
-  /** From the SymbolLookup interface via Debugger and JVMDebugger */
-  public synchronized OopHandle lookupOop(String objectName, String symbol) {
-    long addr = lookupInProcess(objectName, symbol);
-    if (addr == 0) {
-      return null;
-    }
-    return new DbxOopHandle(this, addr);
-  }
-
-  /** From the Debugger interface */
-  public MachineDescription getMachineDescription() {
-    return machDesc;
-  }
-
-  /** Internal routine supporting lazy setting of MachineDescription,
-      since on SPARC we will need to query the remote process to ask
-      it what its data model is (32- or 64-bit). NOTE that this is NOT
-      present in the DbxDebugger interface because it should not be
-      called across the wire (until we support attaching to multiple
-      remote processes via RMI -- see the documentation for
-      DbxDebuggerRemoteIntf.) */
-  public void setMachineDescription(MachineDescription machDesc) {
-    this.machDesc = machDesc;
-    setBigEndian(machDesc.isBigEndian());
-    utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian());
-  }
-
-  /** Internal routine which queries the remote process about its data
-      model -- i.e., size of addresses. Returns -1 upon error.
-      Currently supported return values are 32 and 64. NOTE that this
-      is NOT present in the DbxDebugger interface because it should
-      not be called across the wire (until we support attaching to
-      multiple remote processes via RMI -- see the documentation for
-      DbxDebuggerRemoteIntf.) */
-  public int getRemoteProcessAddressSize() {
-    if (dbxProcess == null) {
-      throw new RuntimeException("Not attached to remote process");
-    }
-
-    try {
-      printlnToOutput("address_size");
-      int i = in.parseInt();
-      return i;
-    }
-    catch (IOException e) {
-      return -1;
-    }
-  }
-
-  //--------------------------------------------------------------------------------
-  // Implementation of ThreadAccess interface
-  //
-
-  /** From the ThreadAccess interface via Debugger and JVMDebugger */
-  public ThreadProxy getThreadForIdentifierAddress(Address addr) {
-    return threadFactory.createThreadWrapper(addr);
-  }
-
-  public ThreadProxy getThreadForThreadId(long id) {
-    return threadFactory.createThreadWrapper(id);
-  }
-
-  //----------------------------------------------------------------------
-  // Overridden from DebuggerBase because we need to relax alignment
-  // constraints on x86
-
-  public long readJLong(long address)
-    throws UnmappedAddressException, UnalignedAddressException {
-    checkJavaConfigured();
-    // FIXME: allow this to be configurable. Undesirable to add a
-    // dependency on the runtime package here, though, since this
-    // package should be strictly underneath it.
-    if (unalignedAccessesOkay) {
-      utils.checkAlignment(address, jintSize);
-    } else {
-      utils.checkAlignment(address, jlongSize);
-    }
-    byte[] data = readBytes(address, jlongSize);
-    return utils.dataToJLong(data, jlongSize);
-  }
-
-  //--------------------------------------------------------------------------------
-  // Internal routines (for implementation of DbxAddress).
-  // These must not be called until the MachineDescription has been set up.
-  //
-
-  /** From the DbxDebugger interface */
-  public String addressValueToString(long address) {
-    return utils.addressValueToString(address);
-  }
-
-  /** Need to override this to relax alignment checks on Solaris/x86. */
-  public long readCInteger(long address, long numBytes, boolean isUnsigned)
-    throws UnmappedAddressException, UnalignedAddressException {
-    checkConfigured();
-    if (!unalignedAccessesOkay) {
-      utils.checkAlignment(address, numBytes);
-    } else {
-      // Only slightly relaxed semantics -- this is a hack, but is
-      // necessary on Solaris/x86 where it seems the compiler is
-      // putting some global 64-bit data on 32-bit boundaries
-      if (numBytes == 8) {
-        utils.checkAlignment(address, 4);
-      } else {
-        utils.checkAlignment(address, numBytes);
-      }
-    }
-    byte[] data = readBytes(address, numBytes);
-    return utils.dataToCInteger(data, isUnsigned);
-  }
-
-  /** From the DbxDebugger interface */
-  public DbxAddress readAddress(long address)
-    throws UnmappedAddressException, UnalignedAddressException {
-    long value = readAddressValue(address);
-    return (value == 0 ? null : new DbxAddress(this, value));
-  }
-
-  public DbxAddress readCompOopAddress(long address)
-    throws UnmappedAddressException, UnalignedAddressException {
-    long value = readCompOopAddressValue(address);
-    return (value == 0 ? null : new DbxAddress(this, value));
-  }
-
-  /** From the DbxDebugger interface */
-  public DbxOopHandle readOopHandle(long address)
-    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
-    long value = readAddressValue(address);
-    return (value == 0 ? null : new DbxOopHandle(this, value));
-  }
-  public DbxOopHandle readCompOopHandle(long address)
-    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
-    long value = readCompOopAddressValue(address);
-    return (value == 0 ? null : new DbxOopHandle(this, value));
-  }
-
-  //--------------------------------------------------------------------------------
-  // Thread context access. Can not be package private, but should
-  // only be accessed by the architecture-specific subpackages.
-
-  /** From the DbxDebugger interface. May have to redefine this later. */
-  public synchronized long[] getThreadIntegerRegisterSet(int tid) {
-    try {
-      printlnToOutput("thr_gregs " + tid);
-      int num = in.parseInt();
-      long[] res = new long[num];
-      for (int i = 0; i < num; i++) {
-        res[i] = in.parseAddress();
-      }
-      return res;
-    }
-    catch (Exception e) {
-      e.printStackTrace();
-      return null;
-    }
-  }
-
-  //--------------------------------------------------------------------------------
-  // Address access. Can not be package private, but should only be
-  // accessed by the architecture-specific subpackages.
-
-  /** From the Debugger interface */
-  public long getAddressValue(Address addr) {
-    if (addr == null) return 0;
-    return ((DbxAddress) addr).getValue();
-  }
-
-  /** From the DbxDebugger interface */
-  public Address newAddress(long value) {
-    if (value == 0) return null;
-    return new DbxAddress(this, value);
-  }
-
-  //--------------------------------------------------------------------------------
-  // Internals only below this point
-  //
-
-  private void launchProcess() throws IOException {
-    dbxProcess = Runtime.getRuntime().exec(dbxPathName);
-    //      dbxOutStreamMonitor = new StreamMonitor(dbxProcess.getInputStream());
-    //      dbxErrStreamMonitor = new StreamMonitor(dbxProcess.getErrorStream());
-    dbxOutStreamMonitor = new StreamMonitor(dbxProcess.getInputStream(), "dbx stdout", true);
-    dbxErrStreamMonitor = new StreamMonitor(dbxProcess.getErrorStream(), "dbx stderr", true);
-  }
-
-  /** Requires that dbxErrStreamMonitor has a trigger on "dbx: Cannot
-      find" with number DBX_MODULE_NOT_FOUND as well as one on "dbx:
-      warning:" (plus the serviceability agent's dbx module path name,
-      to avoid conflation with inability to load individual object
-      files) with number DBX_MODULE_FAILED_TO_LOAD. The former
-      indicates an absence of libsvc_agent_dbx.so, while the latter
-      indicates that the module failed to load, specifically because
-      the architecture was mismatched. (I don't see a way to detect
-      from the dbx command prompt whether it's running the v8 or v9
-      executbale, so we try to import both flavors of the import
-      module; the "v8" file name convention doesn't actually include
-      the v8 prefix, so this code should work for Intel as well.) */
-  private void importDbxModule() throws DebuggerException {
-    // Trigger for a successful load
-    dbxOutStreamMonitor.addTrigger("Defining svc_agent_run", DBX_MODULE_LOADED);
-    for (int i = 0; i < dbxSvcAgentDSOPathNames.length; i++) {
-      dbxOstr.println("import " + dbxSvcAgentDSOPathNames[i]);
-      dbxOstr.println("kprint -u2 \\(Ready\\)");
-      boolean seen = dbxErrStreamMonitor.waitFor("(Ready)", LONG_TIMEOUT);
-      if (!seen) {
-        detach();
-        throw new DebuggerException("Timed out while importing dbx module from file\n" + dbxSvcAgentDSOPathNames[i]);
-      }
-      List retVals = dbxErrStreamMonitor.getTriggersSeen();
-      if (retVals.contains(new Integer(DBX_MODULE_NOT_FOUND))) {
-        detach();
-        throw new DebuggerException("Unable to find the Serviceability Agent's dbx import module at pathname \"" +
-                                    dbxSvcAgentDSOPathNames[i] + "\"");
-      } else {
-        retVals = dbxOutStreamMonitor.getTriggersSeen();
-        if (retVals.contains(new Integer(DBX_MODULE_LOADED))) {
-          System.out.println("importDbxModule: imported " +  dbxSvcAgentDSOPathNames[i]);
-          return;
-        }
-      }
-    }
-
-    // Failed to load all flavors
-    detach();
-    String errMsg = ("Unable to find a version of the Serviceability Agent's dbx import module\n" +
-                     "matching the architecture of dbx at any of the following locations:");
-    for (int i = 0; i < dbxSvcAgentDSOPathNames.length; i++) {
-      errMsg = errMsg + "\n" + dbxSvcAgentDSOPathNames[i];
-    }
-    throw new DebuggerException(errMsg);
-  }
-
-  /** Terminate the debugger forcibly */
-  private void shutdown() {
-
-    if (dbxProcess != null) {
-      // See whether the process has exited and, if not, terminate it
-      // forcibly
-      try {
-        dbxProcess.exitValue();
-      }
-      catch (IllegalThreadStateException e) {
-        dbxProcess.destroy();
-      }
-    }
-
-    try {
-      if (importModuleSocket != null) {
-        importModuleSocket.close();
-      }
-    }
-    catch (IOException e) {
-    }
-
-    // Release references to all objects
-    clear();
-    clearCache();
-  }
-
-  /** Looks up an address in the remote process's address space.
-      Returns 0 if symbol not found or upon error. Package private to
-      allow DbxDebuggerRemoteIntfImpl access. */
-  synchronized long lookupInProcess(String objectName, String symbol) {
-    try {
-      printlnToOutput("lookup " + objectName + " " + symbol);
-      return in.parseAddress();
-    }
-    catch (Exception e) {
-      return 0;
-    }
-  }
-
-  /** This reads bytes from the remote process. */
-  public synchronized ReadResult readBytesFromProcess(long address, long numBytes)
-    throws DebuggerException {
-    if (numBytes < 0) {
-      throw new DebuggerException("Can not read negative number (" + numBytes + ") of bytes from process");
-    }
-    try {
-      String cmd = "peek " + utils.addressValueToString(address) + " " + numBytes;
-      printlnToOutput(cmd);
-      while (in.readByte() != 'B') {
-      }
-      byte res = in.readByte();
-      if (res == 0) {
-        System.err.println("Failing command: " + cmd);
-        throw new DebuggerException("Read of remote process address space failed");
-      }
-      // NOTE: must read ALL of the data regardless of whether we need
-      // to throw an UnmappedAddressException. Otherwise will corrupt
-      // the input stream each time we have a failure. Not good. Do
-      // not want to risk "flushing" the input stream in case a huge
-      // read has a hangup in the middle and we leave data on the
-      // stream.
-      byte[] buf = new byte[(int) numBytes];
-      boolean bailOut = false;
-      long failureAddress = 0;
-      int numReads = 0;
-      while (numBytes > 0) {
-        long len = in.readUnsignedInt();
-        boolean isMapped = ((in.readByte() == 0) ? false : true);
-        if (!isMapped) {
-          if (!bailOut) {
-            bailOut = true;
-            failureAddress = address;
-          }
-        } else {
-          // This won't work if we have unmapped regions, but if we do
-          // then we're going to throw an exception anyway
-
-          // NOTE: there is a factor of 20 speed difference between
-          // these two ways of doing this read.
-          in.readBytes(buf, 0, (int) len);
-        }
-
-        // Do NOT do this:
-        //        for (int i = 0; i < (int) len; i++) {
-        //          buf[i] = in.readByte();
-        //        }
-
-        numBytes -= len;
-        address += len;
-        ++numReads;
-      }
-      if (Assert.ASSERTS_ENABLED) {
-        Assert.that(numBytes == 0, "Bug in debug server's implementation of peek: numBytesLeft == " +
-                    numBytes + ", should be 0 (did " + numReads + " reads)");
-      }
-      if (bailOut) {
-        return new ReadResult(failureAddress);
-      }
-      return new ReadResult(buf);
-    }
-    catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  public void writeBytesToProcess(long address, long numBytes, byte[] data)
-    throws UnmappedAddressException, DebuggerException {
-    // FIXME
-    throw new DebuggerException("Unimplemented");
-  }
-
-  /** This provides DbxDebuggerRemoteIntfImpl access to readBytesFromProcess */
-  ReadResult readBytesFromProcessInternal(long address, long numBytes)
-    throws DebuggerException {
-    return readBytesFromProcess(address, numBytes);
-  }
-
-  /** Convenience routine */
-  private void printlnToOutput(String s) throws IOException {
-    out.println(s);
-    if (out.checkError()) {
-      throw new IOException("Error occurred while writing to debug server");
-    }
-  }
-
-  private void clear() {
-    dbxProcess = null;
-    dbxOstr = null;
-    out = null;
-    in = null;
-    importModuleSocket = null;
-  }
-
-  /** Connects to the dbx import module, setting up out and in
-      streams. Factored out to allow access to the dbx console. */
-  private void connectToImportModule() throws IOException {
-    // Try for 20 seconds to connect to dbx import module; time out
-    // with failure if didn't succeed
-    importModuleSocket = null;
-    long endTime = System.currentTimeMillis() + LONG_TIMEOUT;
-
-    while ((importModuleSocket == null) && (System.currentTimeMillis() < endTime)) {
-      try {
-        importModuleSocket = new Socket(InetAddress.getLocalHost(), PORT);
-        importModuleSocket.setTcpNoDelay(true);
-      }
-      catch (IOException e) {
-        // Swallow IO exceptions while attempting connection
-        try {
-          // Don't swamp the CPU
-          Thread.sleep(1000);
-        }
-        catch (InterruptedException ex) {
-        }
-      }
-    }
-
-    if (importModuleSocket == null) {
-      // Failed to connect because of timeout
-      detach();
-      throw new DebuggerException("Timed out while attempting to connect to remote dbx process");
-    }
-
-    out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(importModuleSocket.getOutputStream(), "US-ASCII")), true);
-    in = new InputLexer(new BufferedInputStream(importModuleSocket.getInputStream()));
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxOopHandle.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.debugger.dbx;
-
-import sun.jvm.hotspot.debugger.*;
-
-class DbxOopHandle extends DbxAddress implements OopHandle {
-  DbxOopHandle(DbxDebugger debugger, long addr) {
-    super(debugger, addr);
-  }
-
-  public Address    addOffsetTo       (long offset) throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("addOffsetTo not applicable to OopHandles (interior object pointers not allowed)");
-  }
-
-  public Address    andWithMask(long mask) throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("andWithMask not applicable to OopHandles (i.e., anything but C addresses)");
-  }
-
-  public Address    orWithMask(long mask) throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("orWithMask not applicable to OopHandles (i.e., anything but C addresses)");
-  }
-
-  public Address    xorWithMask(long mask) throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("xorWithMask not applicable to OopHandles (i.e., anything but C addresses)");
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/DbxThreadFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.debugger.dbx;
-
-import sun.jvm.hotspot.debugger.*;
-
-/** An interface used only internally by the DbxDebugger to be able to
-    create platform-specific Thread objects */
-
-public interface DbxThreadFactory {
-  public ThreadProxy createThreadWrapper(Address threadIdentifierAddr);
-  public ThreadProxy createThreadWrapper(long id);
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/sparc/DbxSPARCThread.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.debugger.dbx.sparc;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.sparc.*;
-import sun.jvm.hotspot.debugger.dbx.*;
-import sun.jvm.hotspot.utilities.*;
-
-public class DbxSPARCThread implements ThreadProxy {
-  private DbxDebugger debugger;
-  private int         id;
-
-  public DbxSPARCThread(DbxDebugger debugger, Address addr) {
-    this.debugger = debugger;
-
-    // FIXME: the size here should be configurable. However, making it
-    // so would produce a dependency on the "types" package from the
-    // debugger package, which is not desired.
-    this.id       = (int) addr.getCIntegerAt(0, 4, true);
-  }
-
-  public DbxSPARCThread(DbxDebugger debugger, long id) {
-    this.debugger = debugger;
-    this.id = (int) id;
-  }
-
-  public boolean equals(Object obj) {
-    if ((obj == null) || !(obj instanceof DbxSPARCThread)) {
-      return false;
-    }
-
-    return (((DbxSPARCThread) obj).id == id);
-  }
-
-  public int hashCode() {
-    return id;
-  }
-
-  public ThreadContext getContext() throws IllegalThreadStateException {
-    DbxSPARCThreadContext context = new DbxSPARCThreadContext(debugger);
-    long[] regs = debugger.getThreadIntegerRegisterSet(id);
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(regs.length == SPARCThreadContext.NPRGREG, "size of register set must match");
-    }
-    for (int i = 0; i < regs.length; i++) {
-      context.setRegister(i, regs[i]);
-    }
-    return context;
-  }
-
-  public boolean canSetContext() throws DebuggerException {
-    return false;
-  }
-
-  public void setContext(ThreadContext context)
-    throws IllegalThreadStateException, DebuggerException {
-    throw new DebuggerException("Unimplemented");
-  }
-
-  public String toString() {
-    return "t@" + id;
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/sparc/DbxSPARCThreadContext.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.dbx.sparc;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.sparc.*;
-import sun.jvm.hotspot.debugger.dbx.*;
-
-public class DbxSPARCThreadContext extends SPARCThreadContext {
-  private DbxDebugger debugger;
-
-  public DbxSPARCThreadContext(DbxDebugger debugger) {
-    super();
-    this.debugger = debugger;
-  }
-
-  public void setRegisterAsAddress(int index, Address value) {
-    setRegister(index, debugger.getAddressValue(value));
-  }
-
-  public Address getRegisterAsAddress(int index) {
-    return debugger.newAddress(getRegister(index));
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/sparc/DbxSPARCThreadFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.debugger.dbx.sparc;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.dbx.*;
-
-public class DbxSPARCThreadFactory implements DbxThreadFactory {
-  private DbxDebugger debugger;
-
-  public DbxSPARCThreadFactory(DbxDebugger debugger) {
-    this.debugger = debugger;
-  }
-
-  public ThreadProxy createThreadWrapper(Address threadIdentifierAddr) {
-    return new DbxSPARCThread(debugger, threadIdentifierAddr);
-  }
-
-  public ThreadProxy createThreadWrapper(long id) {
-    return new DbxSPARCThread(debugger, id);
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/x86/DbxX86Thread.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.debugger.dbx.x86;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.x86.*;
-import sun.jvm.hotspot.debugger.dbx.*;
-import sun.jvm.hotspot.utilities.*;
-
-public class DbxX86Thread implements ThreadProxy {
-  private DbxDebugger debugger;
-  private int         id;
-
-  public DbxX86Thread(DbxDebugger debugger, Address addr) {
-    this.debugger = debugger;
-
-    // FIXME: the size here should be configurable. However, making it
-    // so would produce a dependency on the "types" package from the
-    // debugger package, which is not desired.
-    this.id       = (int) addr.getCIntegerAt(0, 4, true);
-  }
-
-  public DbxX86Thread(DbxDebugger debugger, long id) {
-    this.debugger = debugger;
-    this.id  = (int) id;
-  }
-
-  public boolean equals(Object obj) {
-    if ((obj == null) || !(obj instanceof DbxX86Thread)) {
-      return false;
-    }
-
-    return (((DbxX86Thread) obj).id == id);
-  }
-
-  public int hashCode() {
-    return id;
-  }
-
-  public ThreadContext getContext() throws IllegalThreadStateException {
-    DbxX86ThreadContext context = new DbxX86ThreadContext(debugger);
-    long[] regs = debugger.getThreadIntegerRegisterSet(id);
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(regs.length == 19, "unknown size of register set -- adjust this code");
-    }
-    for (int i = 0; i < regs.length; i++) {
-      context.setRegister(i, regs[i]);
-    }
-    return context;
-  }
-
-  public boolean canSetContext() throws DebuggerException {
-    return false;
-  }
-
-  public void setContext(ThreadContext context)
-    throws IllegalThreadStateException, DebuggerException {
-    throw new DebuggerException("Unimplemented");
-  }
-
-  public String toString() {
-    return "t@" + id;
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/x86/DbxX86ThreadContext.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.dbx.x86;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.x86.*;
-import sun.jvm.hotspot.debugger.dbx.*;
-
-public class DbxX86ThreadContext extends X86ThreadContext {
-  private DbxDebugger debugger;
-
-  public DbxX86ThreadContext(DbxDebugger debugger) {
-    super();
-    this.debugger = debugger;
-  }
-
-  public void setRegisterAsAddress(int index, Address value) {
-    setRegister(index, debugger.getAddressValue(value));
-  }
-
-  public Address getRegisterAsAddress(int index) {
-    return debugger.newAddress(getRegister(index));
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/dbx/x86/DbxX86ThreadFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-package sun.jvm.hotspot.debugger.dbx.x86;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.dbx.*;
-
-public class DbxX86ThreadFactory implements DbxThreadFactory {
-  private DbxDebugger debugger;
-
-  public DbxX86ThreadFactory(DbxDebugger debugger) {
-    this.debugger = debugger;
-  }
-
-  public ThreadProxy createThreadWrapper(Address threadIdentifierAddr) {
-    return new DbxX86Thread(debugger, threadIdentifierAddr);
-  }
-
-  public ThreadProxy createThreadWrapper(long id) {
-    return new DbxX86Thread(debugger, id);
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/AddressDataSource.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import java.io.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.win32.coff.*;
-
-class AddressDataSource implements DataSource {
-  AddressDataSource(Address addr) {
-    this.addr = addr;
-    offset = 0;
-  }
-
-  public byte readByte() throws IOException {
-    try {
-      byte res = (byte) addr.getCIntegerAt(offset, 1, false);
-      ++offset;
-      return res;
-    } catch (UnmappedAddressException e) {
-      throw (IOException) new IOException("Unmapped address at 0x" + Long.toHexString(e.getAddress())).initCause(e);
-    } catch (DebuggerException e) {
-      throw (IOException) new IOException(e.toString()).initCause(e);
-    }
-  }
-
-  public short readShort() throws IOException {
-    // NOTE: byte swapping is taken care of at the COFFFileImpl level
-    int b1 = readByte() & 0xFF;
-    int b2 = readByte() & 0xFF;
-    return (short) ((b1 << 8) | b2);
-  }
-
-  public int readInt() throws IOException {
-    // NOTE: byte swapping is taken care of at the COFFFileImpl level
-    int b1 = ((int) readByte()) & 0xFF;
-    int b2 = ((int) readByte()) & 0xFF;
-    int b3 = ((int) readByte()) & 0xFF;
-    int b4 = ((int) readByte()) & 0xFF;
-    return ((b1 << 24) | (b2 << 16) | (b3 << 8) | b4);
-  }
-
-  public long readLong() throws IOException {
-    // NOTE: byte swapping is taken care of at the COFFFileImpl level
-    long b1 = ((long) readByte()) & 0xFFL;
-    long b2 = ((long) readByte()) & 0xFFL;
-    long b3 = ((long) readByte()) & 0xFFL;
-    long b4 = ((long) readByte()) & 0xFFL;
-    long b5 = ((long) readByte()) & 0xFFL;
-    long b6 = ((long) readByte()) & 0xFFL;
-    long b7 = ((long) readByte()) & 0xFFL;
-    long b8 = ((long) readByte()) & 0xFFL;
-    return (((((b1 << 24) | (b2 << 16) | (b3 << 8) | b4)) << 32) |
-            ((((b5 << 24) | (b6 << 16) | (b7 << 8) | b8))));
-  }
-
-  public int read(byte[] b) throws IOException {
-    for (int i = 0; i < b.length; i++) {
-      b[i] = readByte();
-    }
-    return b.length;
-  }
-
-  public void seek(long pos) throws IOException {
-    offset = pos;
-  }
-
-  public long getFilePointer() throws IOException {
-    return offset;
-  }
-
-  public void close() throws IOException {
-  }
-
-  private Address addr;
-  private long offset;
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/DLL.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.win32.coff.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.utilities.Assert;
-import sun.jvm.hotspot.utilities.memo.*;
-
-/** Provides a simple wrapper around the COFF library which handles
-    relocation. A DLL can represent either a DLL or an EXE file. */
-
-class DLL implements LoadObject {
-
-  DLL(Win32Debugger dbg, String filename, long size, Address relocation) throws COFFException {
-    this.dbg     = dbg;
-    fullPathName = filename;
-    this.size    = size;
-    file = new MemoizedObject() {
-        public Object computeValue() {
-          return COFFFileParser.getParser().parse(fullPathName);
-        }
-      };
-    addr = relocation;
-  }
-
-  /** This constructor was originally used to fetch the DLL's name out
-      of the target process to match it up with the known DLL names,
-      before the fetching of the DLL names and bases was folded into
-      one command. It is no longer used. If it is used, getName() will
-      return null and getSize() will return 0. */
-  DLL(Address base) throws COFFException {
-    this.addr = base;
-    file = new MemoizedObject() {
-        public Object computeValue() {
-          return COFFFileParser.getParser().parse(new AddressDataSource(addr));
-        }
-      };
-  }
-
-  /** Indicates whether this is really a DLL or actually a .EXE
-      file. */
-  boolean isDLL() {
-    return getFile().getHeader().hasCharacteristic(Characteristics.IMAGE_FILE_DLL);
-  }
-
-  /** Look up a symbol; returns absolute address or null if symbol was
-      not found. */
-  Address lookupSymbol(String symbol) throws COFFException {
-    if (!isDLL()) {
-      return null;
-    }
-    ExportDirectoryTable exports = getExportDirectoryTable();
-    return lookupSymbol(symbol, exports,
-                        0, exports.getNumberOfNamePointers() - 1);
-  }
-
-  public Address getBase() {
-    return addr;
-  }
-
-  /** Returns the full path name of this DLL/EXE, or null if this DLL
-      object was created by parsing the target process's address
-      space. */
-  public String getName() {
-    return fullPathName;
-  }
-
-  public long getSize() {
-    return size;
-  }
-
-  public CDebugInfoDataBase getDebugInfoDataBase() throws DebuggerException {
-    if (db != null) {
-      return db;
-    }
-
-    // Try to parse
-    if (dbg == null) {
-      return null; // Need Win32Debugger
-    }
-
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(fullPathName != null, "Need full path name to build debug info database");
-    }
-
-    db = new Win32CDebugInfoBuilder(dbg).buildDataBase(fullPathName, addr);
-    return db;
-  }
-
-  public BlockSym debugInfoForPC(Address pc) throws DebuggerException {
-    CDebugInfoDataBase db = getDebugInfoDataBase();
-    if (db == null) {
-      return null;
-    }
-    return db.debugInfoForPC(pc);
-  }
-
-  public ClosestSymbol closestSymbolToPC(Address pcAsAddr) throws DebuggerException {
-    ExportDirectoryTable exports = getExportDirectoryTable();
-    if (exports == null) {
-      return null;
-    }
-    String name = null;
-    long   pc   = dbg.getAddressValue(pcAsAddr);
-    long   diff = Long.MAX_VALUE;
-    long   base = dbg.getAddressValue(addr);
-    for (int i = 0; i < exports.getNumberOfNamePointers(); i++) {
-      if (!exports.isExportAddressForwarder(exports.getExportOrdinal(i))) {
-        long tmp = base + (exports.getExportAddress(exports.getExportOrdinal(i)) & 0xFFFFFFFF);
-        if ((tmp <= pc) && ((pc - tmp) < diff)) {
-          diff = pc - tmp;
-          name = exports.getExportName(i);
-        }
-      }
-    }
-    if (name == null) {
-      return null;
-    }
-    return new ClosestSymbol(name, diff);
-  }
-
-  public LineNumberInfo lineNumberForPC(Address pc) throws DebuggerException {
-    CDebugInfoDataBase db = getDebugInfoDataBase();
-    if (db == null) {
-      return null;
-    }
-    return db.lineNumberForPC(pc);
-  }
-
-  void close() {
-    getFile().close();
-    file = null;
-  }
-
-  //----------------------------------------------------------------------
-  // Internals only below this point
-  //
-
-  private COFFFile getFile() {
-    return (COFFFile) file.getValue();
-  }
-
-  private Address lookupSymbol(String symbol, ExportDirectoryTable exports,
-                               int loIdx, int hiIdx) {
-    do {
-      int curIdx = ((loIdx + hiIdx) >> 1);
-      String cur = exports.getExportName(curIdx);
-      if (symbol.equals(cur)) {
-        return addr.addOffsetTo(
-          ((long) exports.getExportAddress(exports.getExportOrdinal(curIdx))) & 0xFFFFFFFFL
-        );
-      }
-      if (symbol.compareTo(cur) < 0) {
-        if (hiIdx == curIdx) {
-          hiIdx = curIdx - 1;
-        } else {
-          hiIdx = curIdx;
-        }
-      } else {
-        if (loIdx == curIdx) {
-          loIdx = curIdx + 1;
-        } else {
-          loIdx = curIdx;
-        }
-      }
-    } while (loIdx <= hiIdx);
-
-    return null;
-  }
-
-  private ExportDirectoryTable getExportDirectoryTable() {
-    return
-      getFile().getHeader().getOptionalHeader().getDataDirectories().getExportDirectoryTable();
-  }
-
-  private Win32Debugger  dbg;
-  private String         fullPathName;
-  private long           size;
-  // MemoizedObject contains a COFFFile
-  private MemoizedObject file;
-  // Base address of module in target process
-  private Address        addr;
-  // Debug info database for this DLL
-  private CDebugInfoDataBase db;
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/TestDebugger.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +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.debugger.win32;
-
-import java.util.*;
-import sun.jvm.hotspot.debugger.*;
-
-public class TestDebugger {
-  private static void usage() {
-    System.out.println("usage: java TestDebugger [pid]");
-    System.exit(1);
-  }
-
-  public static void main(String[] args) {
-    try {
-      if (args.length != 1) {
-        usage();
-      }
-
-      int pid = 0;
-      try {
-        pid = Integer.parseInt(args[0]);
-      }
-      catch (NumberFormatException e) {
-        usage();
-      }
-
-      JVMDebugger debugger = new Win32DebuggerLocal(new MachineDescriptionIntelX86(), true);
-      System.err.println("Process list: ");
-      List processes = debugger.getProcessList();
-      for (Iterator iter = processes.iterator(); iter.hasNext(); ) {
-        ProcessInfo info = (ProcessInfo) iter.next();
-        System.err.println(info.getPid() + " " + info.getName());
-      }
-      System.err.println("Trying to attach...");
-      debugger.attach(pid);
-      System.err.println("Attach succeeded.");
-      System.err.println("Trying to detach...");
-      if (!debugger.detach()) {
-        System.err.println("ERROR: detach failed.");
-        System.exit(0);
-      }
-      System.err.println("Detach succeeded.");
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/TestHelloWorld.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +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.debugger.win32;
-
-import java.util.*;
-import sun.jvm.hotspot.debugger.*;
-
-/** Tests to see whether we can find the "Hello, World" string in a
-    target process */
-
-public class TestHelloWorld {
-  private static void usage() {
-    System.out.println("usage: java TestHelloWorld [pid]");
-    System.out.println("pid must be the process ID of the HelloWorldDLL programs");
-    System.exit(1);
-  }
-
-  public static void main(String[] args) {
-    try {
-      if (args.length != 1) {
-        usage();
-      }
-
-      int pid = 0;
-      try {
-        pid = Integer.parseInt(args[0]);
-      }
-      catch (NumberFormatException e) {
-        usage();
-      }
-
-      JVMDebugger debugger = new Win32DebuggerLocal(new MachineDescriptionIntelX86(), true);
-      System.err.println("Trying to attach...");
-      debugger.attach(pid);
-      System.err.println("Attach succeeded.");
-      Address addr = debugger.lookup("helloworld.dll", "helloWorldString");
-      System.err.println("helloWorldString address = " + addr);
-      System.err.println("Trying to detach...");
-      if (!debugger.detach()) {
-        System.err.println("ERROR: detach failed.");
-        System.exit(0);
-      }
-      System.err.println("Detach succeeded.");
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32Address.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,403 +0,0 @@
-/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import sun.jvm.hotspot.debugger.*;
-
-class Win32Address implements Address {
-  protected Win32Debugger debugger;
-  protected long addr;
-
-  Win32Address(Win32Debugger debugger, long addr) {
-    this.debugger = debugger;
-    this.addr = addr;
-  }
-
-  //
-  // Basic Java routines
-  //
-
-  public boolean equals(Object arg) {
-    if (arg == null) {
-      return false;
-    }
-
-    if (!(arg instanceof Win32Address)) {
-      return false;
-    }
-
-    return (addr == ((Win32Address) arg).addr);
-  }
-
-  public int hashCode() {
-    // FIXME: suggestions on a better hash code?
-    return (int) addr;
-  }
-
-  public String toString() {
-    return debugger.addressValueToString(addr);
-  }
-
-  //
-  // C/C++-related routines
-  //
-
-  public long getCIntegerAt(long offset, long numBytes, boolean isUnsigned) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readCInteger(addr + offset, numBytes, isUnsigned);
-  }
-
-  public Address getAddressAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readAddress(addr + offset);
-  }
-
-  public Address getCompOopAddressAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readCompOopAddress(addr + offset);
-  }
-
-  //
-  // Java-related routines
-  //
-
-  public boolean getJBooleanAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJBoolean(addr + offset);
-  }
-
-  public byte getJByteAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJByte(addr + offset);
-  }
-
-  public char getJCharAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJChar(addr + offset);
-  }
-
-  public double getJDoubleAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJDouble(addr + offset);
-  }
-
-  public float getJFloatAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJFloat(addr + offset);
-  }
-
-  public int getJIntAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJInt(addr + offset);
-  }
-
-  public long getJLongAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJLong(addr + offset);
-  }
-
-  public short getJShortAt(long offset) throws UnalignedAddressException, UnmappedAddressException {
-    return debugger.readJShort(addr + offset);
-  }
-
-  public OopHandle getOopHandleAt(long offset)
-    throws UnalignedAddressException, UnmappedAddressException, NotInHeapException {
-    return debugger.readOopHandle(addr + offset);
-  }
-  public OopHandle getCompOopHandleAt(long offset)
-    throws UnalignedAddressException, UnmappedAddressException, NotInHeapException {
-    return debugger.readCompOopHandle(addr + offset);
-  }
-
-  //
-  // C/C++-related mutators
-  //
-
-  public void setCIntegerAt(long offset, long numBytes, long value) {
-    debugger.writeCInteger(addr + offset, numBytes, value);
-  }
-  public void setAddressAt(long offset, Address value) {
-    debugger.writeAddress(addr + offset, (Win32Address) value);
-  }
-
-  //
-  // Java-related mutators
-  //
-
-  public void       setJBooleanAt      (long offset, boolean value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeJBoolean(addr + offset, value);
-  }
-  public void       setJByteAt         (long offset, byte value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeJByte(addr + offset, value);
-  }
-  public void       setJCharAt         (long offset, char value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeJChar(addr + offset, value);
-  }
-  public void       setJDoubleAt       (long offset, double value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeJDouble(addr + offset, value);
-  }
-  public void       setJFloatAt        (long offset, float value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeJFloat(addr + offset, value);
-  }
-  public void       setJIntAt          (long offset, int value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeJInt(addr + offset, value);
-  }
-  public void       setJLongAt         (long offset, long value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeJLong(addr + offset, value);
-  }
-  public void       setJShortAt        (long offset, short value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeJShort(addr + offset, value);
-  }
-  public void       setOopHandleAt     (long offset, OopHandle value)
-    throws UnmappedAddressException, UnalignedAddressException {
-    debugger.writeOopHandle(addr + offset, (Win32OopHandle) value);
-  }
-
-  //
-  // Arithmetic operations -- necessary evil.
-  //
-
-  public Address    addOffsetTo       (long offset) throws UnsupportedOperationException {
-    long value = addr + offset;
-    if (value == 0) {
-      return null;
-    }
-    return new Win32Address(debugger, value);
-  }
-
-  public OopHandle  addOffsetToAsOopHandle(long offset) throws UnsupportedOperationException {
-    long value = addr + offset;
-    if (value == 0) {
-      return null;
-    }
-    return new Win32OopHandle(debugger, value);
-  }
-
-  /** (FIXME: any signed/unsigned issues? Should this work for
-      OopHandles?) */
-  public long       minus(Address arg) {
-    if (arg == null) {
-      return addr;
-    }
-    return addr - ((Win32Address) arg).addr;
-  }
-
-  // Two's complement representation.
-  // All negative numbers are larger than positive numbers.
-  // Numbers with the same sign can be compared normally.
-  // Test harness is below in main().
-
-  public boolean    lessThan          (Address a) {
-    if (a == null) {
-      return false;
-    }
-    Win32Address arg = (Win32Address) a;
-    if ((addr >= 0) && (arg.addr < 0)) {
-      return true;
-    }
-    if ((addr < 0) && (arg.addr >= 0)) {
-      return false;
-    }
-    return (addr < arg.addr);
-  }
-
-  public boolean    lessThanOrEqual   (Address a) {
-    if (a == null) {
-      return false;
-    }
-    Win32Address arg = (Win32Address) a;
-    if ((addr >= 0) && (arg.addr < 0)) {
-      return true;
-    }
-    if ((addr < 0) && (arg.addr >= 0)) {
-      return false;
-    }
-    return (addr <= arg.addr);
-  }
-
-  public boolean    greaterThan       (Address a) {
-    if (a == null) {
-      return true;
-    }
-    Win32Address arg = (Win32Address) a;
-    if ((addr >= 0) && (arg.addr < 0)) {
-      return false;
-    }
-    if ((addr < 0) && (arg.addr >= 0)) {
-      return true;
-    }
-    return (addr > arg.addr);
-  }
-
-  public boolean    greaterThanOrEqual(Address a) {
-    if (a == null) {
-      return true;
-    }
-    Win32Address arg = (Win32Address) a;
-    if ((addr >= 0) && (arg.addr < 0)) {
-      return false;
-    }
-    if ((addr < 0) && (arg.addr >= 0)) {
-      return true;
-    }
-    return (addr >= arg.addr);
-  }
-
-  public Address    andWithMask(long mask) throws UnsupportedOperationException {
-    long value = addr & mask;
-    if (value == 0) {
-      return null;
-    }
-    return new Win32Address(debugger, value);
-  }
-
-  public Address    orWithMask(long mask) throws UnsupportedOperationException {
-    long value = addr | mask;
-    if (value == 0) {
-      return null;
-    }
-    return new Win32Address(debugger, value);
-  }
-
-  public Address    xorWithMask(long mask) throws UnsupportedOperationException {
-    long value = addr ^ mask;
-    if (value == 0) {
-      return null;
-    }
-    return new Win32Address(debugger, value);
-  }
-
-
-  //--------------------------------------------------------------------------------
-  // Internals only below this point
-  //
-
-  long getValue() {
-    return addr;
-  }
-
-
-  private static void check(boolean arg, String failMessage) {
-    if (!arg) {
-      System.err.println(failMessage + ": FAILED");
-      System.exit(1);
-    }
-  }
-
-  // Test harness
-  public static void main(String[] args) {
-    // p/n indicates whether the interior address is really positive
-    // or negative. In unsigned terms, p1 < p2 < n1 < n2.
-
-    Win32Address p1 = new Win32Address(null, 0x7FFFFFFFFFFFFFF0L);
-    Win32Address p2 = (Win32Address) p1.addOffsetTo(10);
-    Win32Address n1 = (Win32Address) p2.addOffsetTo(10);
-    Win32Address n2 = (Win32Address) n1.addOffsetTo(10);
-
-    // lessThan positive tests
-    check(p1.lessThan(p2), "lessThan 1");
-    check(p1.lessThan(n1), "lessThan 2");
-    check(p1.lessThan(n2), "lessThan 3");
-    check(p2.lessThan(n1), "lessThan 4");
-    check(p2.lessThan(n2), "lessThan 5");
-    check(n1.lessThan(n2), "lessThan 6");
-
-    // lessThan negative tests
-    check(!p1.lessThan(p1), "lessThan 7");
-    check(!p2.lessThan(p2), "lessThan 8");
-    check(!n1.lessThan(n1), "lessThan 9");
-    check(!n2.lessThan(n2), "lessThan 10");
-
-    check(!p2.lessThan(p1), "lessThan 11");
-    check(!n1.lessThan(p1), "lessThan 12");
-    check(!n2.lessThan(p1), "lessThan 13");
-    check(!n1.lessThan(p2), "lessThan 14");
-    check(!n2.lessThan(p2), "lessThan 15");
-    check(!n2.lessThan(n1), "lessThan 16");
-
-    // lessThanOrEqual positive tests
-    check(p1.lessThanOrEqual(p1), "lessThanOrEqual 1");
-    check(p2.lessThanOrEqual(p2), "lessThanOrEqual 2");
-    check(n1.lessThanOrEqual(n1), "lessThanOrEqual 3");
-    check(n2.lessThanOrEqual(n2), "lessThanOrEqual 4");
-
-    check(p1.lessThanOrEqual(p2), "lessThanOrEqual 5");
-    check(p1.lessThanOrEqual(n1), "lessThanOrEqual 6");
-    check(p1.lessThanOrEqual(n2), "lessThanOrEqual 7");
-    check(p2.lessThanOrEqual(n1), "lessThanOrEqual 8");
-    check(p2.lessThanOrEqual(n2), "lessThanOrEqual 9");
-    check(n1.lessThanOrEqual(n2), "lessThanOrEqual 10");
-
-    // lessThanOrEqual negative tests
-    check(!p2.lessThanOrEqual(p1), "lessThanOrEqual 11");
-    check(!n1.lessThanOrEqual(p1), "lessThanOrEqual 12");
-    check(!n2.lessThanOrEqual(p1), "lessThanOrEqual 13");
-    check(!n1.lessThanOrEqual(p2), "lessThanOrEqual 14");
-    check(!n2.lessThanOrEqual(p2), "lessThanOrEqual 15");
-    check(!n2.lessThanOrEqual(n1), "lessThanOrEqual 16");
-
-    // greaterThan positive tests
-    check(n2.greaterThan(p1), "greaterThan 1");
-    check(n2.greaterThan(p2), "greaterThan 2");
-    check(n2.greaterThan(n1), "greaterThan 3");
-    check(n1.greaterThan(p1), "greaterThan 4");
-    check(n1.greaterThan(p2), "greaterThan 5");
-    check(p2.greaterThan(p1), "greaterThan 6");
-
-    // greaterThan negative tests
-    check(!p1.greaterThan(p1), "greaterThan 7");
-    check(!p2.greaterThan(p2), "greaterThan 8");
-    check(!n1.greaterThan(n1), "greaterThan 9");
-    check(!n2.greaterThan(n2), "greaterThan 10");
-
-    check(!p1.greaterThan(n2), "greaterThan 11");
-    check(!p2.greaterThan(n2), "greaterThan 12");
-    check(!n1.greaterThan(n2), "greaterThan 13");
-    check(!p1.greaterThan(n1), "greaterThan 14");
-    check(!p2.greaterThan(n1), "greaterThan 15");
-    check(!p1.greaterThan(p2), "greaterThan 16");
-
-    // greaterThanOrEqual positive tests
-    check(p1.greaterThanOrEqual(p1), "greaterThanOrEqual 1");
-    check(p2.greaterThanOrEqual(p2), "greaterThanOrEqual 2");
-    check(n1.greaterThanOrEqual(n1), "greaterThanOrEqual 3");
-    check(n2.greaterThanOrEqual(n2), "greaterThanOrEqual 4");
-
-    check(n2.greaterThanOrEqual(p1), "greaterThanOrEqual 5");
-    check(n2.greaterThanOrEqual(p2), "greaterThanOrEqual 6");
-    check(n2.greaterThanOrEqual(n1), "greaterThanOrEqual 7");
-    check(n1.greaterThanOrEqual(p1), "greaterThanOrEqual 8");
-    check(n1.greaterThanOrEqual(p2), "greaterThanOrEqual 9");
-    check(p2.greaterThanOrEqual(p1), "greaterThanOrEqual 10");
-
-    // greaterThanOrEqual negative tests
-    check(!p1.greaterThanOrEqual(n2), "greaterThanOrEqual 11");
-    check(!p2.greaterThanOrEqual(n2), "greaterThanOrEqual 12");
-    check(!n1.greaterThanOrEqual(n2), "greaterThanOrEqual 13");
-    check(!p1.greaterThanOrEqual(n1), "greaterThanOrEqual 14");
-    check(!p2.greaterThanOrEqual(n1), "greaterThanOrEqual 15");
-    check(!p1.greaterThanOrEqual(p2), "greaterThanOrEqual 16");
-
-    System.err.println("Win32Address: all tests passed successfully.");
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32CDebugInfoBuilder.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,824 +0,0 @@
-/*
- * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import java.util.*;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.win32.coff.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.debugger.cdbg.basic.*;
-import sun.jvm.hotspot.utilities.Assert;
-
-class Win32CDebugInfoBuilder
-  implements DebugVC50SubsectionTypes, DebugVC50TypeLeafIndices, DebugVC50TypeEnums, DebugVC50SymbolTypes, DebugVC50MemberAttributes, CVAttributes, AccessControl {
-  private Win32Debugger dbg;
-  private Address       base;
-
-  private DebugVC50 vc50;
-  private BasicCDebugInfoDataBase db;
-  private DebugVC50TypeIterator iter;
-
-  private DebugVC50SymbolIterator symIter;
-
-  // Logical->physical segment mapping
-  private COFFFile file;
-  private DebugVC50SSSegMap segMap;
-
-  // Canonicalization of primitive types
-  private Map primIndexToTypeMap;
-
-  // Global unnamed enumeration
-  // (FIXME: must figure out how to handle nested type descriptions)
-  private BasicEnumType unnamedEnum;
-
-  private Stack blockStack;
-  private int   endsToSkip;
-
-  private static final int POINTER_SIZE = 4;
-
-  Win32CDebugInfoBuilder(Win32Debugger dbg) {
-    this.dbg = dbg;
-  }
-
-  CDebugInfoDataBase buildDataBase(String dllName, Address base) {
-    this.base = base;
-    file = COFFFileParser.getParser().parse(dllName);
-    vc50 = getDebugVC50(file);
-
-    if (vc50 == null) return null;
-
-    segMap = getSegMap();
-
-    primIndexToTypeMap = new HashMap();
-    blockStack = new Stack();
-    endsToSkip = 0;
-
-    db = new BasicCDebugInfoDataBase();
-    db.beginConstruction();
-
-    // Get global types and add them to the database
-    DebugVC50SSGlobalTypes types = getGlobalTypes();
-    for (iter = types.getTypeIterator(); !iter.done(); iter.next()) {
-      while (!iter.typeStringDone()) {
-        switch (iter.typeStringLeaf()) {
-        case LF_MODIFIER: {
-          int idx = iter.getModifierIndex();
-          BasicType target = getTypeByIndex(idx);
-          short windowsMods = iter.getModifierAttribute();
-          short mods = 0;
-          if ((windowsMods & MODIFIER_CONST_MASK)    != 0) mods |= CONST;
-          if ((windowsMods & MODIFIER_VOLATILE_MASK) != 0) mods |= VOLATILE;
-          putType(target.getCVVariant(mods));
-          break;
-        }
-        case LF_POINTER: {
-          int idx = iter.getPointerType();
-          BasicType target = getTypeByIndex(idx);
-          short windowsMods = iter.getModifierAttribute();
-          short mods = 0;
-          if ((windowsMods & POINTER_CONST_MASK)    != 0) mods |= CONST;
-          if ((windowsMods & POINTER_VOLATILE_MASK) != 0) mods |= VOLATILE;
-          BasicPointerType ptrType = new BasicPointerType(POINTER_SIZE, target);
-          if (mods != 0) {
-            ptrType = (BasicPointerType) ptrType.getCVVariant(mods);
-          }
-
-          putType(ptrType);
-          break;
-        }
-        case LF_ARRAY: {
-          BasicType elemType = getTypeByIndex(iter.getArrayElementType());
-          putType(new BasicArrayType(iter.getArrayName(), elemType, iter.getArrayLength()));
-          break;
-        }
-        case LF_CLASS:
-        case LF_STRUCTURE: {
-          CompoundTypeKind kind = ((iter.typeStringLeaf() == LF_CLASS) ? CompoundTypeKind.CLASS
-                                                                       : CompoundTypeKind.STRUCT);
-          BasicCompoundType type = new BasicCompoundType(iter.getClassName(),
-                                                         iter.getClassSize(),
-                                                         kind);
-          // Skip parsing of forward references to types
-          // FIXME: do we have to resolve these later?
-          if ((iter.getClassProperty() & PROPERTY_FWDREF) == 0) {
-            DebugVC50TypeIterator fieldIter = iter.getClassFieldListIterator();
-            if (Assert.ASSERTS_ENABLED) {
-              Assert.that(fieldIter.typeStringLeaf() == LF_FIELDLIST, "Expected field list");
-            }
-            boolean advance = false;
-            while (!fieldIter.typeStringDone()) {
-              advance = true;
-              switch (fieldIter.typeStringLeaf()) {
-              case LF_FIELDLIST: break;
-              case LF_BCLASS: {
-                int accessControl = memberAttributeToAccessControl(fieldIter.getBClassAttribute());
-                Type baseType = getTypeByIndex(fieldIter.getBClassType());
-                // FIXME: take offset into account
-                type.addBaseClass(new BasicBaseClass(accessControl, false, baseType));
-                break;
-              }
-              case LF_VBCLASS: {
-                int accessControl = memberAttributeToAccessControl(fieldIter.getVBClassAttribute());
-                Type baseType = getTypeByIndex(fieldIter.getVBClassBaseClassType());
-                // FIXME: take offset and virtual base offset into account
-                type.addBaseClass(new BasicBaseClass(accessControl, true, baseType));
-                break;
-              }
-              // I don't think we need to handle indirect virtual base
-              // classes since they should be handled indirectly through
-              // the modeling of the type hierarchy
-              case LF_IVBCLASS: break;
-              case LF_INDEX: {
-                fieldIter = fieldIter.getIndexIterator();
-                advance = false;
-                break;
-              }
-              case LF_MEMBER: {
-                BasicField field = new BasicField(fieldIter.getMemberName(),
-                                                  getTypeByIndex(fieldIter.getMemberType()),
-                                                  memberAttributeToAccessControl(fieldIter.getMemberAttribute()),
-                                                  false);
-                field.setOffset(fieldIter.getMemberOffset());
-                type.addField(field);
-                break;
-              }
-              case LF_STMEMBER: {
-                BasicField field = new BasicField(fieldIter.getStaticName(),
-                                                  getTypeByIndex(fieldIter.getStaticType()),
-                                                  memberAttributeToAccessControl(fieldIter.getStaticAttribute()),
-                                                  true);
-                // The field's address will be found during resolution
-                // of the debug info database
-                type.addField(field);
-                break;
-              }
-              // FIXME: handle methods
-              case LF_METHOD: break;
-              case LF_ONEMETHOD: break;
-                // FIXME: handle nested types
-              case LF_NESTTYPE: break;
-              case LF_NESTTYPEEX: break;
-                // NOTE: virtual functions not needed/handled yet for
-                // this debugging system (because we are not planning to
-                // handle calling methods in the target process at
-                // runtime)
-              case LF_VFUNCTAB: break;
-              case LF_FRIENDCLS: break;
-              case LF_VFUNCOFF: break;
-              case LF_MEMBERMODIFY: break;
-              case LF_PAD0:  case LF_PAD1:  case LF_PAD2:  case LF_PAD3:
-              case LF_PAD4:  case LF_PAD5:  case LF_PAD6:  case LF_PAD7:
-              case LF_PAD8:  case LF_PAD9:  case LF_PAD10: case LF_PAD11:
-              case LF_PAD12: case LF_PAD13: case LF_PAD14: case LF_PAD15: break;
-              default: System.err.println("WARNING: unexpected leaf index " +
-                                          fieldIter.typeStringLeaf() +
-                                          " in field list for type " + iter.getTypeIndex());
-              }
-              if (advance) {
-                fieldIter.typeStringNext();
-              }
-            }
-          }
-          putType(type);
-          break;
-        }
-        case LF_UNION: {
-          BasicCompoundType type = new BasicCompoundType(iter.getUnionName(),
-                                                         iter.getUnionSize(),
-                                                         CompoundTypeKind.UNION);
-          // Skip parsing of forward references to types
-          // FIXME: do we have to resolve these later?
-          if ((iter.getClassProperty() & PROPERTY_FWDREF) == 0) {
-            DebugVC50TypeIterator fieldIter = iter.getUnionFieldListIterator();
-            if (Assert.ASSERTS_ENABLED) {
-              Assert.that(fieldIter.typeStringLeaf() == LF_FIELDLIST, "Expected field list");
-            }
-            boolean advance = false;
-            while (!fieldIter.typeStringDone()) {
-              advance = true;
-              switch (fieldIter.typeStringLeaf()) {
-              case LF_FIELDLIST: break;
-              case LF_BCLASS:    break;
-              case LF_VBCLASS:   break;
-              case LF_IVBCLASS:  break;
-              case LF_INDEX: {
-                fieldIter = fieldIter.getIndexIterator();
-                advance = false;
-                break;
-              }
-              case LF_MEMBER: {
-                BasicField field = new BasicField(fieldIter.getMemberName(),
-                                                  getTypeByIndex(fieldIter.getMemberType()),
-                                                  memberAttributeToAccessControl(fieldIter.getMemberAttribute()),
-                                                  false);
-                field.setOffset(fieldIter.getMemberOffset());
-                type.addField(field);
-                break;
-              }
-              case LF_STMEMBER: {
-                System.err.println("WARNING: I didn't think unions could contain static fields...");
-                BasicField field = new BasicField(fieldIter.getStaticName(),
-                                                  getTypeByIndex(fieldIter.getStaticType()),
-                                                  memberAttributeToAccessControl(fieldIter.getStaticAttribute()),
-                                                  true);
-                // The field's address will be found during resolution
-                // of the debug info database
-                type.addField(field);
-                break;
-              }
-              case LF_METHOD: break;
-              case LF_ONEMETHOD: break;
-                // FIXME: handle nested types
-              case LF_NESTTYPE: break;
-              case LF_NESTTYPEEX: break;
-              case LF_VFUNCTAB: break;
-              case LF_FRIENDCLS: break;
-              case LF_VFUNCOFF: break;
-              case LF_MEMBERMODIFY: break;
-              case LF_PAD0:  case LF_PAD1:  case LF_PAD2:  case LF_PAD3:
-              case LF_PAD4:  case LF_PAD5:  case LF_PAD6:  case LF_PAD7:
-              case LF_PAD8:  case LF_PAD9:  case LF_PAD10: case LF_PAD11:
-              case LF_PAD12: case LF_PAD13: case LF_PAD14: case LF_PAD15: break;
-
-              default: System.err.println("WARNING: unexpected leaf index " +
-                                          fieldIter.typeStringLeaf() +
-                                          " in field list for union of type " + iter.getTypeIndex());
-              }
-              if (advance) {
-                fieldIter.typeStringNext();
-              }
-            }
-          }
-          putType(type);
-          break;
-        }
-        case LF_ENUM: {
-          String name = iter.getEnumName();
-          BasicEnumType enumType = null;
-          if ((name == null) || (name.equals(""))) {
-            if (unnamedEnum == null) {
-              unnamedEnum = new BasicEnumType(null, getTypeByIndex(iter.getEnumType()));
-            }
-            enumType = unnamedEnum;
-          } else {
-            enumType = new BasicEnumType(name, getTypeByIndex(iter.getEnumType()));
-          }
-          DebugVC50TypeIterator fieldIter = iter.getEnumFieldListIterator();
-          if (Assert.ASSERTS_ENABLED) {
-            Assert.that(fieldIter.typeStringLeaf() == LF_FIELDLIST, "Expected field list");
-          }
-          boolean advance = false;
-          while (!fieldIter.typeStringDone()) {
-            advance = true;
-            switch (fieldIter.typeStringLeaf()) {
-            case LF_FIELDLIST: break;
-            case LF_ENUMERATE: {
-              String enumName = fieldIter.getEnumerateName();
-              long   enumVal  = fieldIter.getEnumerateValue();
-              enumType.addEnum(enumName, enumVal);
-              break;
-            }
-            case LF_INDEX: {
-              fieldIter = fieldIter.getIndexIterator();
-              advance = false;
-              break;
-            }
-
-            case LF_PAD0:  case LF_PAD1:  case LF_PAD2:  case LF_PAD3:
-            case LF_PAD4:  case LF_PAD5:  case LF_PAD6:  case LF_PAD7:
-            case LF_PAD8:  case LF_PAD9:  case LF_PAD10: case LF_PAD11:
-            case LF_PAD12: case LF_PAD13: case LF_PAD14: case LF_PAD15: break;
-
-            default: System.err.println("WARNING: unexpected leaf index " +
-                                        fieldIter.typeStringLeaf() +
-                                        " in field list for enum of type " + iter.getTypeIndex());
-            }
-
-            if (advance) {
-              fieldIter.typeStringNext();
-            }
-          }
-
-          putType(enumType);
-          break;
-        }
-        case LF_PROCEDURE: {
-          Type retType = getTypeByIndex(iter.getProcedureReturnType());
-          BasicFunctionType func = new BasicFunctionType(null, POINTER_SIZE, retType);
-          DebugVC50TypeIterator argIter = iter.getProcedureArgumentListIterator();
-          if (Assert.ASSERTS_ENABLED) {
-            Assert.that(argIter.typeStringLeaf() == LF_ARGLIST, "Expected argument list");
-          }
-          for (int i = 0; i < argIter.getArgListCount(); i++) {
-            func.addArgumentType(getTypeByIndex(argIter.getArgListType(i)));
-          }
-          putType(func);
-          break;
-        }
-        case LF_MFUNCTION: {
-          Type retType   = getTypeByIndex(iter.getMFunctionReturnType());
-          Type container = getTypeByIndex(iter.getMFunctionContainingClass());
-          Type thisType  = getTypeByIndex(iter.getMFunctionThis());
-          long thisAdjust = iter.getMFunctionThisAdjust();
-          BasicMemberFunctionType func = new BasicMemberFunctionType(null,
-                                                                     POINTER_SIZE,
-                                                                     retType,
-                                                                     container,
-                                                                     thisType,
-                                                                     thisAdjust);
-          DebugVC50TypeIterator argIter = iter.getMFunctionArgumentListIterator();
-          for (int i = 0; i < argIter.getArgListCount(); i++) {
-            func.addArgumentType(getTypeByIndex(argIter.getArgListType(i)));
-          }
-          putType(func);
-          break;
-        }
-        // FIXME: handle virtual function table shape description
-        case LF_VTSHAPE: break;
-        case LF_BARRAY: System.err.println("FIXME: don't know what to do with LF_BARRAY leaves (convert to pointers?"); break;
-        case LF_LABEL: break;
-        case LF_NULL: break; // FIXME: do we need to handle this? With what?
-        case LF_DIMARRAY: System.err.println("FIXME: don't know what to do with LF_DIMARRAY leaves yet"); break;
-        case LF_VFTPATH: break;
-        case LF_PRECOMP: break;
-        case LF_ENDPRECOMP: break;
-        case LF_OEM: break;
-        case LF_TYPESERVER: break;
-
-        // Type records referenced from other type records
-
-        case LF_SKIP: break;
-        case LF_ARGLIST: skipTypeRecord(); break;
-        case LF_DEFARG: System.err.println("FIXME: handle default arguments (dereference the type)"); break;
-        case LF_FIELDLIST: skipTypeRecord(); break;
-        case LF_DERIVED: break;
-        case LF_BITFIELD: {
-          Type underlyingType = getTypeByIndex(iter.getBitfieldFieldType());
-          BasicBitType bit = new BasicBitType(underlyingType,
-                                              (iter.getBitfieldLength() & 0xFF),
-                                              (iter.getBitfieldPosition() & 0xFF));
-          putType(bit);
-          break;
-        }
-        case LF_METHODLIST: break;
-        case LF_DIMCONU:
-        case LF_DIMCONLU:
-        case LF_DIMVARU:
-        case LF_DIMVARLU: break;
-        case LF_REFSYM: break;
-
-        case LF_PAD0:  case LF_PAD1:  case LF_PAD2:  case LF_PAD3:
-        case LF_PAD4:  case LF_PAD5:  case LF_PAD6:  case LF_PAD7:
-        case LF_PAD8:  case LF_PAD9:  case LF_PAD10: case LF_PAD11:
-        case LF_PAD12: case LF_PAD13: case LF_PAD14: case LF_PAD15: break;
-
-        default: {
-          System.err.println("Unexpected leaf index " +
-                             iter.typeStringLeaf() + " at offset 0x" +
-                             Integer.toHexString(iter.typeStringOffset()));
-          break;
-        }
-        }
-
-
-        if (!iter.typeStringDone()) {
-          iter.typeStringNext();
-        }
-      }
-    }
-
-    // Add all symbol directories to debug info
-    // (FIXME: must figure out how to handle module-by-module
-    // arrangement of at least the static symbols to have proper
-    // lookup -- should probably also take advantage of the PROCREF
-    // and UDT references to understand how to build the global
-    // database vs. the module-by-module one)
-    DebugVC50SubsectionDirectory dir = vc50.getSubsectionDirectory();
-    int moduleNumber = 0; // Debugging
-    for (int i = 0; i < dir.getNumEntries(); i++) {
-      DebugVC50Subsection ss = dir.getSubsection(i);
-      int ssType = ss.getSubsectionType();
-      boolean process = false;
-
-      if ((ssType == SST_GLOBAL_SYM) ||
-          (ssType == SST_GLOBAL_PUB) ||
-          (ssType == SST_STATIC_SYM)) {
-        DebugVC50SSSymbolBase syms = (DebugVC50SSSymbolBase) ss;
-        symIter = syms.getSymbolIterator();
-        process = true;
-      }
-
-      if (ssType == SST_ALIGN_SYM) {
-        DebugVC50SSAlignSym syms = (DebugVC50SSAlignSym) ss;
-        symIter = syms.getSymbolIterator();
-        process = true;
-      }
-
-      if (process) {
-        for (; !symIter.done(); symIter.next()) {
-          switch (symIter.getType()) {
-          case S_COMPILE: break;
-          case S_SSEARCH: break; // FIXME: may need this later
-          case S_END: {
-            try {
-              // FIXME: workaround for warnings until we figure out
-              // what to do with THUNK32 symbols
-              if (endsToSkip == 0) {
-                blockStack.pop();
-              } else {
-                --endsToSkip;
-              }
-            } catch (EmptyStackException e) {
-              System.err.println("WARNING: mismatched block begins/ends in debug information");
-            }
-            break;
-          }
-          case S_SKIP: break;
-          case S_CVRESERVE: break;
-          case S_OBJNAME: break; // FIXME: may need this later
-          case S_ENDARG: break;
-          case S_COBOLUDT: break;
-          case S_MANYREG: break; // FIXME: may need to add support for this
-          case S_RETURN: break;  // NOTE: would need this if adding support for calling functions
-          case S_ENTRYTHIS: break; // FIXME: may need to add support for this
-          case S_REGISTER: break; // FIXME: may need to add support for this
-          case S_CONSTANT: break; // FIXME: will need to add support for this
-          case S_UDT: break; // FIXME: need to see how these are used; are
-            // they redundant, or are they used to describe
-            // global variables as opposed to types?
-          case S_COBOLUDT2: break;
-          case S_MANYREG2: break;
-          case S_BPREL32: {
-            LocalSym sym = new BasicLocalSym(symIter.getBPRelName(),
-                                             getTypeByIndex(symIter.getBPRelType()),
-                                             symIter.getBPRelOffset());
-            addLocalToCurBlock(sym);
-            break;
-          }
-          case S_LDATA32:
-          case S_GDATA32: {
-            // FIXME: must handle these separately from global data (have
-            // module scoping and only add these at the module level)
-            boolean isModuleLocal = (symIter.getType() == S_LDATA32);
-
-            GlobalSym sym = new BasicGlobalSym(symIter.getLGDataName(),
-                                               getTypeByIndex(symIter.getLGDataType()),
-                                               newAddress(symIter.getLGDataOffset(), symIter.getLGDataSegment()),
-                                               isModuleLocal);
-            // FIXME: must handle module-local symbols differently
-            addGlobalSym(sym);
-            break;
-          }
-          case S_PUB32: break; // FIXME: figure out how these differ from
-            // above and how they are used
-          case S_LPROC32:
-          case S_GPROC32: {
-            BasicFunctionSym sym = new BasicFunctionSym(newLazyBlockSym(symIter.getLGProcParentOffset()),
-                                                        symIter.getLGProcLength(),
-                                                        newAddress(symIter.getLGProcOffset(), symIter.getLGProcSegment()),
-                                                        symIter.getLGProcName(),
-                                                        getTypeByIndex(symIter.getLGProcType()),
-                                                        (symIter.getType() == S_LPROC32));
-
-            // FIXME: have to handle local procedures differently (have
-            // notion of modules and only add those procedures to the
-            // module they are defined in)
-            addBlock(sym);
-            break;
-          }
-          case S_THUNK32: {
-            // FIXME: see whether we need to handle these
-            skipEnd();
-            break;
-          }
-          case S_BLOCK32: {
-            BasicBlockSym sym = new BasicBlockSym(newLazyBlockSym(symIter.getBlockParentOffset()),
-                                                  symIter.getBlockLength(),
-                                                  newAddress(symIter.getBlockOffset(), symIter.getBlockSegment()),
-                                                  symIter.getBlockName());
-            addBlock(sym);
-            break;
-          }
-          case S_WITH32: break;
-          case S_LABEL32: break;
-          case S_CEXMODEL32: break;
-          case S_VFTTABLE32: break; // FIXME: may need to handle this
-                                // (most likely for run-time type determination)
-          case S_REGREL32: break;   // FIXME: may need to add support for this
-          case S_LTHREAD32: break;
-          case S_GTHREAD32: break;  // FIXME: may need to add support for these
-          case S_PROCREF: break;
-          case S_DATAREF: break;
-          case S_ALIGN: break;
-          default:
-            // These two unknown symbol types show up very frequently.
-            // Symbol type 0 appears to always be a no-op symbol of
-            // length 2 (i.e., length just covers the symbol type.)
-            // Symbol type 4115 appears to be a copyright notice for
-            // the Microsoft linker.
-            if ((symIter.getType() != 0) && (symIter.getType() != 4115)) {
-              System.err.println("  NOTE: Unexpected symbol of type " +
-                                 symIter.getType() + " at offset 0x" +
-                                 Integer.toHexString(symIter.getOffset()));
-            }
-            break;
-          }
-        }
-      }
-    }
-
-    // Add line number information for all modules
-    for (int i = 0; i < dir.getNumEntries(); i++) {
-      DebugVC50Subsection ss = dir.getSubsection(i);
-      if (ss.getSubsectionType() == SST_SRC_MODULE) {
-        DebugVC50SSSrcModule srcMod = (DebugVC50SSSrcModule) ss;
-        for (int sf = 0; sf < srcMod.getNumSourceFiles(); sf++) {
-          DebugVC50SrcModFileDesc desc = srcMod.getSourceFileDesc(sf);
-          // Uniquify these to save space
-          String name = desc.getSourceFileName().intern();
-          for (int cs = 0; cs < desc.getNumCodeSegments(); cs++) {
-            DebugVC50SrcModLineNumberMap map = desc.getLineNumberMap(cs);
-            SectionHeader seg = file.getHeader().getSectionHeader(map.getSegment());
-            for (int lp = 0; lp < map.getNumSourceLinePairs(); lp++) {
-              Address startPC = base.addOffsetTo(seg.getVirtualAddress() + map.getCodeOffset(lp));
-              // Fake address for endPC -- will be filled in by BasicLineNumberMapping
-              Address endPC = base.addOffsetTo(seg.getSize());
-              db.addLineNumberInfo(new BasicLineNumberInfo(name, map.getLineNumber(lp), startPC, endPC));
-            }
-          }
-        }
-      }
-    }
-
-    // Finish assembly of database
-    db.resolve(new ResolveListener() {
-        public void resolveFailed(Type containingType, LazyType failedResolve, String detail) {
-          System.err.println("WARNING: failed to resolve type of index " +
-                             ((Integer) failedResolve.getKey()).intValue() +
-                             " in type " + containingType.getName() + " (class " +
-                             containingType.getClass().getName() + ") while " + detail);
-        }
-
-        public void resolveFailed(Type containingType, String staticFieldName) {
-          System.err.println("WARNING: failed to resolve address of static field \"" +
-                             staticFieldName + "\" in type " + containingType.getName());
-        }
-
-        public void resolveFailed(Sym containingSymbol, LazyType failedResolve, String detail) {
-          System.err.println("WARNING: failed to resolve type of index " +
-                             ((Integer) failedResolve.getKey()).intValue() +
-                             " in symbol of type " + containingSymbol.getClass().getName() +
-                             " while " + detail);
-        }
-
-        public void resolveFailed(Sym containingSymbol, LazyBlockSym failedResolve, String detail) {
-          System.err.println("WARNING: failed to resolve block at offset 0x" +
-                             Integer.toHexString(((Integer) failedResolve.getKey()).intValue()) +
-                             " in symbol of type " + containingSymbol.getClass().getName() +
-                             " while " + detail);
-        }
-      });
-
-    db.endConstruction();
-
-    return db;
-  }
-
-
-  //----------------------------------------------------------------------
-  // Internals only below this point
-  //
-
-  private static DebugVC50 getDebugVC50(COFFFile file) {
-    COFFHeader header = file.getHeader();
-    OptionalHeader opt = header.getOptionalHeader();
-    if (opt == null) {
-      // Optional header not found
-      return null;
-    }
-    OptionalHeaderDataDirectories dd = opt.getDataDirectories();
-    if (dd == null) {
-      // Optional header data directories not found
-      return null;
-    }
-    DebugDirectory debug = dd.getDebugDirectory();
-    if (debug == null) {
-      // Debug directory not found
-      return null;
-    }
-    for (int i = 0; i < debug.getNumEntries(); i++) {
-      DebugDirectoryEntry entry = debug.getEntry(i);
-      if (entry.getType() == DebugTypes.IMAGE_DEBUG_TYPE_CODEVIEW) {
-        return entry.getDebugVC50();
-      }
-    }
-
-    // CodeView information not found in debug directory
-    return null;
-  }
-
-  private DebugVC50SSSegMap getSegMap() {
-    return (DebugVC50SSSegMap) findSubsection(SST_SEG_MAP);
-  }
-
-  private DebugVC50SSGlobalTypes getGlobalTypes() {
-    return (DebugVC50SSGlobalTypes) findSubsection(SST_GLOBAL_TYPES);
-  }
-
-  private DebugVC50SSGlobalSym getGlobalSymbols() {
-    return (DebugVC50SSGlobalSym) findSubsection(SST_GLOBAL_SYM);
-  }
-
-  private DebugVC50Subsection findSubsection(short ssType) {
-    DebugVC50SubsectionDirectory dir = vc50.getSubsectionDirectory();
-    for (int i = 0; i < dir.getNumEntries(); i++) {
-      DebugVC50Subsection ss = dir.getSubsection(i);
-      if (ss.getSubsectionType() == ssType) {
-        return ss;
-      }
-    }
-    throw new DebuggerException("Unable to find subsection of type " + ssType);
-  }
-
-  private void putType(Type t) {
-    db.addType(new Integer(iter.getTypeIndex()), t);
-  }
-
-  private Address newAddress(int offset, short segment) {
-    int seg = segment & 0xFFFF;
-    // NOTE: it isn't clear how to use the segMap to map from logical
-    // to physical segments. It seems it would make more sense if the
-    // SegDescs contained a physical segment number in addition to the
-    // offset within the physical segment of the logical one.
-
-    // Get the section header corresponding to this segment
-    SectionHeader section = file.getHeader().getSectionHeader(seg);
-
-    // Result is relative to image base
-    return base.addOffsetTo(section.getVirtualAddress() + offset);
-  }
-
-  private BasicType getTypeByIndex(int intIndex) {
-    Integer index = new Integer(intIndex);
-
-    // Handle primitive types here.
-    if (intIndex <= 0x0FFF) {
-      BasicType type = (BasicType) primIndexToTypeMap.get(index);
-      if (type != null) {
-        return type;
-      }
-      // Construct appropriate new primitive type
-      int primMode = intIndex & RESERVED_MODE_MASK;
-      if (primMode == RESERVED_MODE_DIRECT) {
-        int primType = intIndex & RESERVED_TYPE_MASK;
-        switch (primType) {
-        case RESERVED_TYPE_SIGNED_INT:
-        case RESERVED_TYPE_UNSIGNED_INT: {
-          boolean unsigned = (primType == RESERVED_TYPE_UNSIGNED_INT);
-          int size = 0;
-          String name = null;
-          switch (intIndex & RESERVED_SIZE_MASK) {
-          case RESERVED_SIZE_INT_1_BYTE: size = 1; name = "char";    break;
-          case RESERVED_SIZE_INT_2_BYTE: size = 2; name = "short";   break;
-          case RESERVED_SIZE_INT_4_BYTE: size = 4; name = "int";     break;
-          case RESERVED_SIZE_INT_8_BYTE: size = 8; name = "__int64"; break;
-          default: throw new DebuggerException("Illegal size of integer type " + intIndex);
-          }
-          type = new BasicIntType(name, size, unsigned);
-          break;
-        }
-        case RESERVED_TYPE_BOOLEAN: {
-          int size = 0;
-          switch (intIndex & RESERVED_SIZE_MASK) {
-          case RESERVED_SIZE_INT_1_BYTE: size = 1; break;
-          case RESERVED_SIZE_INT_2_BYTE: size = 2; break;
-          case RESERVED_SIZE_INT_4_BYTE: size = 4; break;
-          case RESERVED_SIZE_INT_8_BYTE: size = 8; break;
-          default: throw new DebuggerException("Illegal size of boolean type " + intIndex);
-          }
-          type = new BasicIntType("bool", size, false);
-          break;
-        }
-        case RESERVED_TYPE_REAL: {
-          switch (intIndex & RESERVED_SIZE_MASK) {
-          case RESERVED_SIZE_REAL_32_BIT:
-            type = new BasicFloatType("float", 4);
-            break;
-          case RESERVED_SIZE_REAL_64_BIT:
-            type = new BasicDoubleType("double", 8);
-            break;
-          default:
-            throw new DebuggerException("Unsupported floating-point size in type " + intIndex);
-          }
-          break;
-        }
-        case RESERVED_TYPE_REALLY_INT: {
-          switch (intIndex & RESERVED_SIZE_MASK) {
-          case RESERVED_SIZE_REALLY_INT_CHAR:     type = new BasicIntType("char",    1, false); break;
-          case RESERVED_SIZE_REALLY_INT_WCHAR:    type = new BasicIntType("wchar",   2, false); break;
-          case RESERVED_SIZE_REALLY_INT_2_BYTE:   type = new BasicIntType("short",   2, false); break;
-          case RESERVED_SIZE_REALLY_INT_2_BYTE_U: type = new BasicIntType("short",   2, true);  break;
-          case RESERVED_SIZE_REALLY_INT_4_BYTE:   type = new BasicIntType("int",     4, false); break;
-          case RESERVED_SIZE_REALLY_INT_4_BYTE_U: type = new BasicIntType("int",     4, true);  break;
-          case RESERVED_SIZE_REALLY_INT_8_BYTE:   type = new BasicIntType("__int64", 8, false); break;
-          case RESERVED_SIZE_REALLY_INT_8_BYTE_U: type = new BasicIntType("__int64", 8, true);  break;
-          default: throw new DebuggerException("Illegal REALLY_INT size in type " + intIndex);
-          }
-          break;
-        }
-        case RESERVED_TYPE_SPECIAL: {
-          switch (intIndex & RESERVED_SIZE_MASK) {
-          case RESERVED_SIZE_SPECIAL_NO_TYPE:
-          case RESERVED_SIZE_SPECIAL_VOID: type = new BasicVoidType(); break;
-          default: throw new DebuggerException("Don't know how to handle reserved special type " + intIndex);
-          }
-          break;
-        }
-
-        default:
-          throw new DebuggerException("Don't know how to handle reserved type " + intIndex);
-        }
-      } else {
-        // Fold all pointer types together since we only support
-        // flat-mode addressing anyway
-        Type targetType = getTypeByIndex(intIndex & (~RESERVED_MODE_MASK));
-
-        type = new BasicPointerType(POINTER_SIZE, targetType);
-      }
-      if (Assert.ASSERTS_ENABLED) {
-        Assert.that(type != null, "Got null Type for primitive type " + intIndex);
-      }
-      primIndexToTypeMap.put(index, type);
-      return type;
-    }
-
-    // Not primitive type. Construct lazy reference to target type.
-    // (Is it worth canonicalizing these as well to save space?)
-    return new LazyType(index);
-  }
-
-  private void addBlock(BlockSym block) {
-    db.addBlock(new Integer(symIter.getOffset()), block);
-    blockStack.push(block);
-  }
-
-  private void skipEnd() {
-    ++endsToSkip;
-  }
-
-  private BlockSym newLazyBlockSym(int offset) {
-    if (offset == 0) {
-      return null;
-    }
-
-    return new LazyBlockSym(new Integer(offset));
-  }
-
-  private int memberAttributeToAccessControl(short memberAttribute) {
-    int acc = memberAttribute & MEMATTR_ACCESS_MASK;
-    switch (acc) {
-    case MEMATTR_ACCESS_NO_PROTECTION: return NO_PROTECTION;
-    case MEMATTR_ACCESS_PRIVATE:       return PRIVATE;
-    case MEMATTR_ACCESS_PROTECTED:     return PROTECTED;
-    case MEMATTR_ACCESS_PUBLIC:        return PUBLIC;
-    default: throw new RuntimeException("Should not reach here");
-    }
-  }
-
-  private void addLocalToCurBlock(LocalSym local) {
-    ((BasicBlockSym) blockStack.peek()).addLocal(local);
-  }
-
-  private void addGlobalSym(GlobalSym sym) {
-    db.addGlobalSym(sym);
-  }
-
-  private void skipTypeRecord() {
-    while (!iter.typeStringDone()) {
-      iter.typeStringNext();
-    }
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32CDebugger.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import java.io.*;
-import java.util.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.debugger.cdbg.basic.x86.*;
-import sun.jvm.hotspot.debugger.x86.*;
-import sun.jvm.hotspot.utilities.AddressOps;
-
-class Win32CDebugger implements CDebugger, ProcessControl {
-  // FIXME: think about how to make this work in a remote debugging
-  // scenario; who should keep open DLLs? Need local copies of these
-  // DLLs on the debugging machine?
-  private Win32Debugger dbg;
-
-  Win32CDebugger(Win32Debugger dbg) {
-    this.dbg = dbg;
-  }
-
-  public List getThreadList() throws DebuggerException {
-    return dbg.getThreadList();
-  }
-
-  public List/*<LoadObject>*/ getLoadObjectList() throws DebuggerException{
-    return dbg.getLoadObjectList();
-  }
-
-  public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {
-    // FIXME: could keep sorted list of these to be able to do binary
-    // searches, for better scalability
-    if (pc == null) {
-      return null;
-    }
-    List objs = getLoadObjectList();
-    for (Iterator iter = objs.iterator(); iter.hasNext(); ) {
-      LoadObject obj = (LoadObject) iter.next();
-      if (AddressOps.lte(obj.getBase(), pc) && (pc.minus(obj.getBase()) < obj.getSize())) {
-        return obj;
-      }
-    }
-    return null;
-  }
-
-  public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
-    X86ThreadContext context = (X86ThreadContext) thread.getContext();
-    Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
-    if (ebp == null) return null;
-    Address pc  = context.getRegisterAsAddress(X86ThreadContext.EIP);
-    if (pc == null) return null;
-    return new X86CFrame(this, ebp, pc);
-  }
-
-  public String getNameOfFile(String fileName) {
-    return new File(fileName).getName();
-  }
-
-  public ProcessControl getProcessControl() throws DebuggerException {
-    return this;
-  }
-
-  // C++ name demangling
-  public boolean canDemangle() {
-    return false;
-  }
-
-  public String demangle(String sym) {
-    throw new UnsupportedOperationException();
-  }
-
-  //
-  // Support for ProcessControl interface
-  //
-
-  public void suspend() throws DebuggerException {
-    dbg.suspend();
-  }
-  public void resume() throws DebuggerException {
-    dbg.resume();
-  }
-  public boolean isSuspended() throws DebuggerException {
-    return dbg.isSuspended();
-  }
-  public void setBreakpoint(Address addr) throws DebuggerException {
-    dbg.setBreakpoint(addr);
-  }
-  public void clearBreakpoint(Address addr) throws DebuggerException {
-    dbg.clearBreakpoint(addr);
-  }
-  public boolean isBreakpointSet(Address addr) throws DebuggerException {
-    return dbg.isBreakpointSet(addr);
-  }
-  public DebugEvent debugEventPoll() throws DebuggerException {
-    return dbg.debugEventPoll();
-  }
-  public void debugEventContinue() throws DebuggerException {
-    dbg.debugEventContinue();
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32Debugger.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import java.util.List;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
-
-/** An extension of the JVMDebugger interface with a few additions to
-    support 32-bit vs. 64-bit debugging as well as features required
-    by the architecture-specific subpackages. */
-
-public interface Win32Debugger extends JVMDebugger {
-  public String       addressValueToString(long address) throws DebuggerException;
-  public boolean      readJBoolean(long address) throws DebuggerException;
-  public byte         readJByte(long address) throws DebuggerException;
-  public char         readJChar(long address) throws DebuggerException;
-  public double       readJDouble(long address) throws DebuggerException;
-  public float        readJFloat(long address) throws DebuggerException;
-  public int          readJInt(long address) throws DebuggerException;
-  public long         readJLong(long address) throws DebuggerException;
-  public short        readJShort(long address) throws DebuggerException;
-  public long         readCInteger(long address, long numBytes, boolean isUnsigned)
-    throws DebuggerException;
-  public Win32Address readAddress(long address) throws DebuggerException;
-  public Win32Address readCompOopAddress(long address) throws DebuggerException;
-  public Win32OopHandle readOopHandle(long address) throws DebuggerException;
-  public Win32OopHandle readCompOopHandle(long address) throws DebuggerException;
-  public void         writeJBoolean(long address, boolean value) throws DebuggerException;
-  public void         writeJByte(long address, byte value) throws DebuggerException;
-  public void         writeJChar(long address, char value) throws DebuggerException;
-  public void         writeJDouble(long address, double value) throws DebuggerException;
-  public void         writeJFloat(long address, float value) throws DebuggerException;
-  public void         writeJInt(long address, int value) throws DebuggerException;
-  public void         writeJLong(long address, long value) throws DebuggerException;
-  public void         writeJShort(long address, short value) throws DebuggerException;
-  public void         writeCInteger(long address, long numBytes, long value) throws DebuggerException;
-  public void         writeAddress(long address, Win32Address value) throws DebuggerException;
-  public void         writeOopHandle(long address, Win32OopHandle value) throws DebuggerException;
-
-  // On Windows the int is actually the value of a HANDLE which
-  // currently must be read from the target process; that is, the
-  // target process must maintain its own thread list, each element of
-  // which holds a HANDLE to its underlying OS thread. FIXME: should
-  // add access to the OS-level thread list, but there are too many
-  // limitations imposed by Windows to usefully do so; see
-  // src/os/win32/agent/README-commands.txt, command "duphandle".
-  //
-  // The returned array of register contents is guaranteed to be in
-  // the same order as in the DbxDebugger for Solaris/x86; that is,
-  // the indices match those in debugger/x86/X86ThreadContext.java.
-  public long[]       getThreadIntegerRegisterSet(int threadHandleValue,
-                                                  boolean mustDuplicateHandle) throws DebuggerException;
-  // Implmentation of setContext
-  public void         setThreadIntegerRegisterSet(int threadHandleValue,
-                                                  boolean mustDuplicateHandle,
-                                                  long[] contents) throws DebuggerException;
-
-  public Address      newAddress(long value) throws DebuggerException;
-
-  // Routine supporting the ThreadProxy implementation, in particular
-  // the ability to get a thread ID from a thread handle via
-  // examination of the Thread Information Block. Fetch the LDT entry
-  // for a given selector.
-  public Win32LDTEntry getThreadSelectorEntry(int threadHandleValue,
-                                              boolean mustDuplicateHandle,
-                                              int selector) throws DebuggerException;
-
-  // Support for the CDebugger interface. Retrieves the thread list of
-  // the target process as a List of ThreadProxy objects.
-  public List/*<ThreadProxy>*/ getThreadList() throws DebuggerException;
-
-  // Support for the CDebugger interface. Retrieves a List of the
-  // loadobjects in the target process.
-  public List/*<LoadObject>*/ getLoadObjectList() throws DebuggerException;
-
-  // Support for the ProcessControl interface
-  public void writeBytesToProcess(long startAddress, long numBytes, byte[] data) throws UnmappedAddressException, DebuggerException;
-  public void suspend() throws DebuggerException;
-  public void resume() throws DebuggerException;
-  public boolean isSuspended() throws DebuggerException;
-  public void setBreakpoint(Address addr) throws DebuggerException;
-  public void clearBreakpoint(Address addr) throws DebuggerException;
-  public boolean isBreakpointSet(Address addr) throws DebuggerException;
-  // FIXME: do not want to expose complicated data structures (like
-  // the DebugEvent) in this interface due to serialization issues
-  public DebugEvent debugEventPoll() throws DebuggerException;
-  public void debugEventContinue() throws DebuggerException;
-
-  // NOTE: this interface implicitly contains the following methods:
-  // From the Debugger interface via JVMDebugger
-  //   public void attach(int processID) throws DebuggerException;
-  //   public void attach(String executableName, String coreFileName) throws DebuggerException;
-  //   public boolean detach();
-  //   public Address parseAddress(String addressString) throws NumberFormatException;
-  //   public long getAddressValue(Address addr) throws DebuggerException;
-  //   public String getOS();
-  //   public String getCPU();
-  // From the SymbolLookup interface via Debugger and JVMDebugger
-  //   public Address lookup(String objectName, String symbol);
-  //   public OopHandle lookupOop(String objectName, String symbol);
-  // From the JVMDebugger interface
-  //   public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
-  //                                               long jbyteSize,
-  //                                               long jcharSize,
-  //                                               long jdoubleSize,
-  //                                               long jfloatSize,
-  //                                               long jintSize,
-  //                                               long jlongSize,
-  //                                               long jshortSize);
-  // From the ThreadAccess interface via Debugger and JVMDebugger
-  //   public ThreadProxy getThreadForIdentifierAddress(Address addr);
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32DebuggerLocal.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1083 +0,0 @@
-/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.x86.*;
-import sun.jvm.hotspot.debugger.win32.coff.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
-import sun.jvm.hotspot.debugger.cdbg.basic.BasicDebugEvent;
-import sun.jvm.hotspot.utilities.*;
-import sun.jvm.hotspot.utilities.memo.*;
-
-/** <P> An implementation of the JVMDebugger interface which talks to
-    the Free Windows Debug Server (FwDbgSrv) over a socket to
-    implement attach/detach and read from process memory. All DLL and
-    symbol table management is done in Java. </P>
-
-    <P> <B>NOTE</B> that since we have the notion of fetching "Java
-    primitive types" from the remote process (which might have
-    different sizes than we expect) we have a bootstrapping
-    problem. We need to know the sizes of these types before we can
-    fetch them. The current implementation solves this problem by
-    requiring that it be configured with these type sizes before they
-    can be fetched. The readJ(Type) routines here will throw a
-    RuntimeException if they are called before the debugger is
-    configured with the Java primitive type sizes. </P> */
-
-public class Win32DebuggerLocal extends DebuggerBase implements Win32Debugger {
-  private Socket debuggerSocket;
-  private boolean attached;
-  // FIXME: update when core files supported
-  private long pid;
-  // Communication with debug server
-  private PrintWriter out;
-  private DataOutputStream rawOut;
-  private InputLexer in;
-  private static final int PORT = 27000;
-  private PageCache cache;
-  private static final long SHORT_TIMEOUT = 2000;
-  private static final long LONG_TIMEOUT = 20000;
-
-  // Symbol lookup support
-  // This is a map of library names to DLLs
-  private Map nameToDllMap;
-
-  // C/C++ debugging support
-  private List/*<LoadObject>*/ loadObjects;
-  private CDebugger cdbg;
-
-  // ProcessControl support
-  private boolean suspended;
-  // Maps Long objects (addresses) to Byte objects (original instructions)
-  // (Longs used instead of Addresses to properly represent breakpoints at 0x0 if needed)
-  private Map     breakpoints;
-  // Current debug event, if any
-  private DebugEvent curDebugEvent;
-
-  //--------------------------------------------------------------------------------
-  // Implementation of Debugger interface
-  //
-
-  /** <P> machDesc may not be null. </P>
-
-      <P> useCache should be set to true if debugging is being done
-      locally, and to false if the debugger is being created for the
-      purpose of supporting remote debugging. </P> */
-  public Win32DebuggerLocal(MachineDescription machDesc,
-                            boolean useCache) throws DebuggerException {
-    this.machDesc = machDesc;
-    utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian());
-    if (useCache) {
-      // Cache portion of the remote process's address space.
-      // Fetching data over the socket connection to dbx is slow.
-      // Might be faster if we were using a binary protocol to talk to
-      // dbx, but would have to test. For now, this cache works best
-      // if it covers the entire heap of the remote process. FIXME: at
-      // least should make this tunable from the outside, i.e., via
-      // the UI. This is a cache of 4096 4K pages, or 16 MB. The page
-      // size must be adjusted to be the hardware's page size.
-      // (FIXME: should pick this up from the debugger.)
-      initCache(4096, parseCacheNumPagesProperty(4096));
-    }
-    // FIXME: add instantiation of thread factory
-
-    try {
-      connectToDebugServer();
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public boolean hasProcessList() throws DebuggerException {
-    return true;
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public List getProcessList() throws DebuggerException {
-    List processes = new ArrayList();
-
-    try {
-      printlnToOutput("proclist");
-      int num = in.parseInt();
-      for (int i = 0; i < num; i++) {
-        int pid = in.parseInt();
-        String name = parseString();
-        // NOTE: Win32 hack
-        if (name.equals("")) {
-          name = "System Idle Process";
-        }
-        processes.add(new ProcessInfo(name, pid));
-      }
-      return processes;
-    }
-    catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public synchronized void attach(int processID) throws DebuggerException {
-    if (attached) {
-      // FIXME: update when core files supported
-      throw new DebuggerException("Already attached to process " + pid);
-    }
-
-    try {
-      printlnToOutput("attach " + processID);
-      if (!in.parseBoolean()) {
-        throw new DebuggerException("Error attaching to process, or no such process");
-      }
-
-      attached = true;
-      pid = processID;
-      suspended = true;
-      breakpoints = new HashMap();
-      curDebugEvent = null;
-      nameToDllMap = null;
-      loadObjects = null;
-    }
-    catch (IOException e) {
-        throw new DebuggerException(e);
-    }
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public synchronized void attach(String executableName, String coreFileName) throws DebuggerException {
-    throw new DebuggerException("Core files not yet supported on Win32");
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public synchronized boolean detach() {
-    if (!attached) {
-      return false;
-    }
-
-    attached = false;
-    suspended = false;
-    breakpoints = null;
-
-    // Close all open DLLs
-    if (nameToDllMap != null) {
-      for (Iterator iter = nameToDllMap.values().iterator(); iter.hasNext(); ) {
-        DLL dll = (DLL) iter.next();
-        dll.close();
-      }
-      nameToDllMap = null;
-      loadObjects = null;
-    }
-
-    cdbg = null;
-    clearCache();
-
-    try {
-      printlnToOutput("detach");
-      return in.parseBoolean();
-    }
-    catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public Address parseAddress(String addressString) throws NumberFormatException {
-    return newAddress(utils.scanAddress(addressString));
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public String getOS() {
-    return PlatformInfo.getOS();
-  }
-
-  /** From the Debugger interface via JVMDebugger */
-  public String getCPU() {
-    return PlatformInfo.getCPU();
-  }
-
-  public boolean hasConsole() throws DebuggerException {
-    return false;
-  }
-
-  public String consoleExecuteCommand(String cmd) throws DebuggerException {
-    throw new DebuggerException("No debugger console available on Win32");
-  }
-
-  public String getConsolePrompt() throws DebuggerException {
-    return null;
-  }
-
-  public CDebugger getCDebugger() throws DebuggerException {
-    if (cdbg == null) {
-      cdbg = new Win32CDebugger(this);
-    }
-    return cdbg;
-  }
-
-  /** From the SymbolLookup interface via Debugger and JVMDebugger */
-  public synchronized Address lookup(String objectName, String symbol) {
-    if (!attached) {
-      return null;
-    }
-    return newAddress(lookupInProcess(objectName, symbol));
-  }
-
-  /** From the SymbolLookup interface via Debugger and JVMDebugger */
-  public synchronized OopHandle lookupOop(String objectName, String symbol) {
-    Address addr = lookup(objectName, symbol);
-    if (addr == null) {
-      return null;
-    }
-    return addr.addOffsetToAsOopHandle(0);
-  }
-
-  /** From the Debugger interface */
-  public MachineDescription getMachineDescription() {
-    return machDesc;
-  }
-
-  //--------------------------------------------------------------------------------
-  // Implementation of ThreadAccess interface
-  //
-
-  /** From the ThreadAccess interface via Debugger and JVMDebugger */
-  public ThreadProxy getThreadForIdentifierAddress(Address addr) {
-    return new Win32Thread(this, addr);
-  }
-
-  public ThreadProxy getThreadForThreadId(long handle) {
-    return new Win32Thread(this, handle);
-  }
-
-  //----------------------------------------------------------------------
-  // Overridden from DebuggerBase because we need to relax alignment
-  // constraints on x86
-
-  public long readJLong(long address)
-    throws UnmappedAddressException, UnalignedAddressException {
-    checkJavaConfigured();
-    // FIXME: allow this to be configurable. Undesirable to add a
-    // dependency on the runtime package here, though, since this
-    // package should be strictly underneath it.
-    //    utils.checkAlignment(address, jlongSize);
-    utils.checkAlignment(address, jintSize);
-    byte[] data = readBytes(address, jlongSize);
-    return utils.dataToJLong(data, jlongSize);
-  }
-
-  //--------------------------------------------------------------------------------
-  // Internal routines (for implementation of Win32Address).
-  // These must not be called until the MachineDescription has been set up.
-  //
-
-  /** From the Win32Debugger interface */
-  public String addressValueToString(long address) {
-    return utils.addressValueToString(address);
-  }
-
-  /** From the Win32Debugger interface */
-  public Win32Address readAddress(long address)
-    throws UnmappedAddressException, UnalignedAddressException {
-    return (Win32Address) newAddress(readAddressValue(address));
-  }
-
-  public Win32Address readCompOopAddress(long address)
-    throws UnmappedAddressException, UnalignedAddressException {
-    return (Win32Address) newAddress(readCompOopAddressValue(address));
-  }
-
-  /** From the Win32Debugger interface */
-  public Win32OopHandle readOopHandle(long address)
-    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
-    long value = readAddressValue(address);
-    return (value == 0 ? null : new Win32OopHandle(this, value));
-  }
-  public Win32OopHandle readCompOopHandle(long address)
-    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
-    long value = readCompOopAddressValue(address);
-    return (value == 0 ? null : new Win32OopHandle(this, value));
-  }
-
-  /** From the Win32Debugger interface */
-  public void writeAddress(long address, Win32Address value) {
-    writeAddressValue(address, getAddressValue(value));
-  }
-
-  /** From the Win32Debugger interface */
-  public void writeOopHandle(long address, Win32OopHandle value) {
-    writeAddressValue(address, getAddressValue(value));
-  }
-
-  //--------------------------------------------------------------------------------
-  // Thread context access
-  //
-
-  public synchronized long[] getThreadIntegerRegisterSet(int threadHandleValue,
-                                                         boolean mustDuplicateHandle)
-    throws DebuggerException {
-    if (!suspended) {
-      throw new DebuggerException("Process not suspended");
-    }
-
-    try {
-      int handle = threadHandleValue;
-      if (mustDuplicateHandle) {
-        printlnToOutput("duphandle 0x" + Integer.toHexString(threadHandleValue));
-        if (!in.parseBoolean()) {
-          throw new DebuggerException("Error duplicating thread handle 0x" + threadHandleValue);
-        }
-        handle = (int) in.parseAddress(); // Must close to avoid leaks
-      }
-      printlnToOutput("getcontext 0x" + Integer.toHexString(handle));
-      if (!in.parseBoolean()) {
-        if (mustDuplicateHandle) {
-          printlnToOutput("closehandle 0x" + Integer.toHexString(handle));
-        }
-        String failMessage = "GetThreadContext failed for thread handle 0x" +
-                             Integer.toHexString(handle);
-        if (mustDuplicateHandle) {
-          failMessage = failMessage + ", duplicated from thread handle " +
-                        Integer.toHexString(threadHandleValue);
-        }
-        throw new DebuggerException(failMessage);
-      }
-      // Otherwise, parse all registers. See
-      // src/os/win32/agent/README-commands.txt for the format.
-      // Note the array we have to return has to match that specified by
-      // X86ThreadContext.java.
-      int numRegs = 22;
-      long[] winRegs = new long[numRegs];
-      for (int i = 0; i < numRegs; i++) {
-        winRegs[i] = in.parseAddress();
-      }
-      if (mustDuplicateHandle) {
-        // Clean up after ourselves
-        printlnToOutput("closehandle 0x" + Integer.toHexString(handle));
-      }
-      // Now create the real return value
-      long[] retval = new long[X86ThreadContext.NPRGREG];
-      retval[X86ThreadContext.EAX] = winRegs[0];
-      retval[X86ThreadContext.EBX] = winRegs[1];
-      retval[X86ThreadContext.ECX] = winRegs[2];
-      retval[X86ThreadContext.EDX] = winRegs[3];
-      retval[X86ThreadContext.ESI] = winRegs[4];
-      retval[X86ThreadContext.EDI] = winRegs[5];
-      retval[X86ThreadContext.EBP] = winRegs[6];
-      retval[X86ThreadContext.ESP] = winRegs[7];
-      retval[X86ThreadContext.EIP] = winRegs[8];
-      retval[X86ThreadContext.DS]  = winRegs[9];
-      retval[X86ThreadContext.ES]  = winRegs[10];
-      retval[X86ThreadContext.FS]  = winRegs[11];
-      retval[X86ThreadContext.GS]  = winRegs[12];
-      retval[X86ThreadContext.CS]  = winRegs[13];
-      retval[X86ThreadContext.SS]  = winRegs[14];
-      retval[X86ThreadContext.EFL] = winRegs[15];
-      retval[X86ThreadContext.DR0] = winRegs[16];
-      retval[X86ThreadContext.DR1] = winRegs[17];
-      retval[X86ThreadContext.DR2] = winRegs[18];
-      retval[X86ThreadContext.DR3] = winRegs[19];
-      retval[X86ThreadContext.DR6] = winRegs[20];
-      retval[X86ThreadContext.DR7] = winRegs[21];
-      return retval;
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  public synchronized void setThreadIntegerRegisterSet(int threadHandleValue,
-                                                       boolean mustDuplicateHandle,
-                                                       long[] context)
-    throws DebuggerException {
-    if (!suspended) {
-      throw new DebuggerException("Process not suspended");
-    }
-
-    try {
-      int handle = threadHandleValue;
-      if (mustDuplicateHandle) {
-        printlnToOutput("duphandle 0x" + Integer.toHexString(threadHandleValue));
-        if (!in.parseBoolean()) {
-          throw new DebuggerException("Error duplicating thread handle 0x" + threadHandleValue);
-        }
-        handle = (int) in.parseAddress(); // Must close to avoid leaks
-      }
-      // Change order of registers to match that of debug server
-      long[] winRegs = new long[context.length];
-      winRegs[0] = context[X86ThreadContext.EAX];
-      winRegs[1] = context[X86ThreadContext.EBX];
-      winRegs[2] = context[X86ThreadContext.ECX];
-      winRegs[3] = context[X86ThreadContext.EDX];
-      winRegs[4] = context[X86ThreadContext.ESI];
-      winRegs[5] = context[X86ThreadContext.EDI];
-      winRegs[6] = context[X86ThreadContext.EBP];
-      winRegs[7] = context[X86ThreadContext.ESP];
-      winRegs[8] = context[X86ThreadContext.EIP];
-      winRegs[9] = context[X86ThreadContext.DS];
-      winRegs[10] = context[X86ThreadContext.ES];
-      winRegs[11] = context[X86ThreadContext.FS];
-      winRegs[12] = context[X86ThreadContext.GS];
-      winRegs[13] = context[X86ThreadContext.CS];
-      winRegs[14] = context[X86ThreadContext.SS];
-      winRegs[15] = context[X86ThreadContext.EFL];
-      winRegs[16] = context[X86ThreadContext.DR0];
-      winRegs[17] = context[X86ThreadContext.DR1];
-      winRegs[18] = context[X86ThreadContext.DR2];
-      winRegs[19] = context[X86ThreadContext.DR3];
-      winRegs[20] = context[X86ThreadContext.DR6];
-      winRegs[21] = context[X86ThreadContext.DR7];
-      StringBuffer cmd = new StringBuffer();
-      cmd.append("setcontext 0x");
-      cmd.append(Integer.toHexString(threadHandleValue));
-      for (int i = 0; i < context.length; i++) {
-        cmd.append(" 0x");
-        cmd.append(Long.toHexString(winRegs[i]));
-      }
-      printlnToOutput(cmd.toString());
-      boolean res = in.parseBoolean();
-      if (mustDuplicateHandle) {
-        printlnToOutput("closehandle 0x" + Integer.toHexString(handle));
-      }
-      if (!res) {
-        String failMessage = "SetThreadContext failed for thread handle 0x" +
-          Integer.toHexString(handle);
-        if (mustDuplicateHandle) {
-          failMessage = failMessage + ", duplicated from thread handle " +
-            Integer.toHexString(threadHandleValue);
-        }
-        throw new DebuggerException(failMessage);
-      }
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  /** Fetches the Win32 LDT_ENTRY for the given thread and selector.
-      This data structure allows the conversion of a segment-relative
-      address to a linear virtual address. For example, it allows the
-      expression of operations like "mov eax, fs:[18h]", which fetches
-      the thread information block, allowing access to the thread
-      ID. */
-  public synchronized Win32LDTEntry getThreadSelectorEntry(int threadHandleValue,
-                                                           boolean mustDuplicateHandle,
-                                                           int selector)
-    throws DebuggerException {
-    try {
-      int handle = threadHandleValue;
-      if (mustDuplicateHandle) {
-        printlnToOutput("duphandle 0x" + Integer.toHexString(threadHandleValue));
-        if (!in.parseBoolean()) {
-          throw new DebuggerException("Error duplicating thread handle 0x" + threadHandleValue);
-        }
-        handle = (int) in.parseAddress(); // Must close to avoid leaks
-      }
-      printlnToOutput("selectorentry 0x" + Integer.toHexString(handle) + " " + selector);
-      if (!in.parseBoolean()) {
-        if (mustDuplicateHandle) {
-          printlnToOutput("closehandle 0x" + Integer.toHexString(handle));
-        }
-        throw new DebuggerException("GetThreadContext failed for thread handle 0x" + handle +
-                                    ", duplicated from thread handle " + threadHandleValue);
-      }
-      // Parse result. See
-      // src/os/win32/agent/README-commands.txt for the format.
-      short limitLow = (short) in.parseAddress();
-      short baseLow  = (short) in.parseAddress();
-      byte  baseMid  = (byte)  in.parseAddress();
-      byte  flags1   = (byte)  in.parseAddress();
-      byte  flags2   = (byte)  in.parseAddress();
-      byte  baseHi   = (byte)  in.parseAddress();
-      return new Win32LDTEntry(limitLow, baseLow, baseMid, flags1, flags2, baseHi);
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  public synchronized List getThreadList() throws DebuggerException {
-    if (!suspended) {
-      throw new DebuggerException("Process not suspended");
-    }
-
-    try {
-      printlnToOutput("threadlist");
-      List ret = new ArrayList();
-      int numThreads = in.parseInt();
-      for (int i = 0; i < numThreads; i++) {
-        int handle = (int) in.parseAddress();
-        ret.add(new Win32Thread(this, handle));
-      }
-      return ret;
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  public synchronized List getLoadObjectList() throws DebuggerException {
-    if (!suspended) {
-      throw new DebuggerException("Process not suspended");
-    }
-
-    try {
-      if (loadObjects == null) {
-        loadObjects  = new ArrayList();
-        nameToDllMap = new HashMap();
-        // Get list of library names and base addresses
-        printlnToOutput("libinfo");
-        int numInfo = in.parseInt();
-
-        for (int i = 0; i < numInfo; i++) {
-          // NOTE: because Win32 is case insensitive, we standardize on
-          // lowercase file names.
-          String  fullPathName = parseString().toLowerCase();
-          Address base         = newAddress(in.parseAddress());
-
-          File   file = new File(fullPathName);
-          long   size = file.length();
-          DLL    dll  = new DLL(this, fullPathName, size, base);
-          String name = file.getName();
-          nameToDllMap.put(name, dll);
-          loadObjects.add(dll);
-        }
-      }
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-
-    return loadObjects;
-  }
-
-  //----------------------------------------------------------------------
-  // Process control access
-  //
-
-  public synchronized void writeBytesToProcess(long startAddress, long numBytes, byte[] data)
-    throws UnmappedAddressException, DebuggerException {
-    try {
-      printToOutput("poke 0x" + Long.toHexString(startAddress) +
-                    " |");
-      writeIntToOutput((int) numBytes);
-      writeToOutput(data, 0, (int) numBytes);
-      printlnToOutput("");
-      if (!in.parseBoolean()) {
-        throw new UnmappedAddressException(startAddress);
-      }
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  public synchronized void suspend() throws DebuggerException {
-    try {
-      if (suspended) {
-        throw new DebuggerException("Process already suspended");
-      }
-      printlnToOutput("suspend");
-      suspended = true;
-      enableCache();
-      reresolveLoadObjects();
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  public synchronized void resume() throws DebuggerException {
-    try {
-      if (!suspended) {
-        throw new DebuggerException("Process not suspended");
-      }
-      disableCache();
-      printlnToOutput("resume");
-      suspended = false;
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  public synchronized boolean isSuspended() throws DebuggerException {
-    return suspended;
-  }
-
-  public synchronized void setBreakpoint(Address addr) throws DebuggerException {
-    if (!suspended) {
-      throw new DebuggerException("Process not suspended");
-    }
-
-    long addrVal = getAddressValue(addr);
-    Long where = new Long(addrVal);
-    if (breakpoints.get(where) != null) {
-      throw new DebuggerException("Breakpoint already set at " + addr);
-    }
-    Byte what = new Byte(readBytes(addrVal, 1)[0]);
-    // Now put 0xCC (int 3) at the target address, fail if can not
-    writeBytesToProcess(addrVal, 1, new byte[] { (byte) 0xCC });
-    // OK, the breakpoint is set.
-    breakpoints.put(where, what);
-  }
-
-  public synchronized void clearBreakpoint(Address addr) throws DebuggerException {
-    if (!suspended) {
-      throw new DebuggerException("Process not suspended");
-    }
-
-    long addrVal = getAddressValue(addr);
-    Long where = new Long(addrVal);
-    Byte what = (Byte) breakpoints.get(where);
-    if (what == null) {
-      throw new DebuggerException("Breakpoint not set at " + addr);
-    }
-    // Put original data back at address
-    writeBytesToProcess(addrVal, 1, new byte[] { what.byteValue() });
-    // OK, breakpoint is cleared
-    breakpoints.remove(where);
-  }
-
-  public synchronized boolean isBreakpointSet(Address addr) throws DebuggerException {
-    return (breakpoints.get(new Long(getAddressValue(addr))) != null);
-  }
-
-  // Following constants taken from winnt.h
-  private static final int EXCEPTION_DEBUG_EVENT  = 1;
-  private static final int LOAD_DLL_DEBUG_EVENT   = 6;
-  private static final int UNLOAD_DLL_DEBUG_EVENT = 7;
-  private static final int EXCEPTION_ACCESS_VIOLATION = 0xC0000005;
-  private static final int EXCEPTION_BREAKPOINT       = 0x80000003;
-  private static final int EXCEPTION_SINGLE_STEP      = 0x80000004;
-
-  public synchronized DebugEvent debugEventPoll() throws DebuggerException {
-    if (curDebugEvent != null) {
-      return curDebugEvent;
-    }
-
-    try {
-      printlnToOutput("pollevent");
-      if (!in.parseBoolean()) {
-        return null;
-      }
-      // Otherwise, got a debug event. Need to figure out what kind it is.
-      int handle = (int) in.parseAddress();
-      ThreadProxy thread = new Win32Thread(this, handle);
-      int code = in.parseInt();
-      DebugEvent ev = null;
-      switch (code) {
-      case LOAD_DLL_DEBUG_EVENT: {
-        Address addr = newAddress(in.parseAddress());
-        ev = BasicDebugEvent.newLoadObjectLoadEvent(thread, addr);
-        break;
-      }
-
-      case UNLOAD_DLL_DEBUG_EVENT: {
-        Address addr = newAddress(in.parseAddress());
-        ev = BasicDebugEvent.newLoadObjectUnloadEvent(thread, addr);
-        break;
-      }
-
-      case EXCEPTION_DEBUG_EVENT: {
-        int exceptionCode = in.parseInt();
-        Address pc = newAddress(in.parseAddress());
-        switch (exceptionCode) {
-        case EXCEPTION_ACCESS_VIOLATION:
-          boolean wasWrite = in.parseBoolean();
-          Address addr = newAddress(in.parseAddress());
-          ev = BasicDebugEvent.newAccessViolationEvent(thread, pc, wasWrite, addr);
-          break;
-
-        case EXCEPTION_BREAKPOINT:
-          ev = BasicDebugEvent.newBreakpointEvent(thread, pc);
-          break;
-
-        case EXCEPTION_SINGLE_STEP:
-          ev = BasicDebugEvent.newSingleStepEvent(thread, pc);
-          break;
-
-        default:
-          ev = BasicDebugEvent.newUnknownEvent(thread,
-                                               "Exception 0x" + Integer.toHexString(exceptionCode) +
-                                               " at PC " + pc);
-          break;
-        }
-        break;
-      }
-
-      default:
-        ev = BasicDebugEvent.newUnknownEvent(thread,
-                                             "Debug event " + code + " occurred");
-        break;
-      }
-      if (Assert.ASSERTS_ENABLED) {
-        Assert.that(ev != null, "Must have created event");
-      }
-      curDebugEvent = ev;
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-
-    return curDebugEvent;
-  }
-
-  public synchronized void debugEventContinue() throws DebuggerException {
-    if (curDebugEvent == null) {
-      throw new DebuggerException("No debug event pending");
-    }
-
-    try {
-      ///////////////////////////////////////////////////////////////////
-      //                                                               //
-      // FIXME: this **must** be modified to handle breakpoint events
-      // properly. Must temporarily remove the breakpoint and enable
-      // single-stepping mode (hiding those single-step events from
-      // the user unless they have been requested; currently there is
-      // no way to request single-step events; and it isn't clear how
-      // to enable them or how the hardware and/or OS typically
-      // supports them, i.e., are they on a per-process or per-thread
-      // level?) until the process steps past the breakpoint, then put
-      // the breakpoint back.
-      //                                                               //
-      ///////////////////////////////////////////////////////////////////
-
-      DebugEvent.Type t = curDebugEvent.getType();
-      boolean shouldPassOn = true;
-      if (t == DebugEvent.Type.BREAKPOINT) {
-        // FIXME: correct algorithm appears to be as follows:
-        //
-        // 1. Check to see whether we know about this breakpoint. If
-        // not, it's requested by the user's program and we should
-        // ignore it (not pass it on to the program).
-        //
-        // 2. Replace the original opcode.
-        //
-        // 3. Set single-stepping mode in the debug registers.
-        //
-        // 4. Back up the PC.
-        //
-        // 5. In debugEventPoll(), watch for a single-step event on
-        // this thread. When we get it, put the breakpoint back. Only
-        // deliver that single-step event if the user has requested
-        // single-step events (FIXME: must figure out whether they are
-        // per-thread or per-process, and also expose a way to turn
-        // them on.)
-
-        // To make breakpoints work for now, we will just back up the
-        // PC, which we have to do in order to not disrupt the program
-        // execution in case the user decides to disable the breakpoint.
-
-        if (breakpoints.get(new Long(getAddressValue(curDebugEvent.getPC()))) != null) {
-          System.err.println("Backing up PC due to breakpoint");
-          X86ThreadContext ctx = (X86ThreadContext) curDebugEvent.getThread().getContext();
-          ctx.setRegister(X86ThreadContext.EIP, ctx.getRegister(X86ThreadContext.EIP) - 1);
-          curDebugEvent.getThread().setContext(ctx);
-        } else {
-          System.err.println("Skipping back up of PC since I didn't know about this breakpoint");
-          System.err.println("Known breakpoints:");
-          for (Iterator iter = breakpoints.keySet().iterator(); iter.hasNext(); ) {
-            System.err.println("  0x" + Long.toHexString(((Long) iter.next()).longValue()));
-          }
-        }
-        shouldPassOn = false;
-      } else if (t == DebugEvent.Type.SINGLE_STEP) {
-        shouldPassOn = false;
-      }
-      // Other kinds of debug events are either ignored if passed on
-      // or probably should be passed on so the program exits
-      // FIXME: generate process exiting events (should be easy)
-
-      int val = (shouldPassOn ? 1 : 0);
-      printlnToOutput("continueevent " + val);
-      if (!in.parseBoolean()) {
-        throw new DebuggerException("Unknown error while attempting to continue past debug event");
-      }
-      curDebugEvent = null;
-    } catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  //--------------------------------------------------------------------------------
-  // Address access
-  //
-
-  /** From the Debugger interface */
-  public long getAddressValue(Address addr) {
-    if (addr == null) return 0;
-    return ((Win32Address) addr).getValue();
-  }
-
-  /** From the Win32Debugger interface */
-  public Address newAddress(long value) {
-    if (value == 0) return null;
-    return new Win32Address(this, value);
-  }
-
-  //--------------------------------------------------------------------------------
-  // Internals only below this point
-  //
-
-  private String parseString() throws IOException {
-    int charSize = in.parseInt();
-    int numChars = in.parseInt();
-    in.skipByte();
-    String str;
-    if (charSize == 1) {
-      str = in.readByteString(numChars);
-    } else {
-      str = in.readCharString(numChars);
-    }
-    return str;
-  }
-
-  /** Looks up an address in the remote process's address space.
-      Returns 0 if symbol not found or upon error. Package private to
-      allow Win32DebuggerRemoteIntfImpl access. NOTE that this returns
-      a long instead of an Address because we do not want to serialize
-      Addresses. */
-  synchronized long lookupInProcess(String objectName, String symbol) {
-    // NOTE: this assumes that process is suspended (which is probably
-    // necessary assumption given that DLLs can be loaded/unloaded as
-    // process runs). Should update documentation.
-    if (nameToDllMap == null) {
-      getLoadObjectList();
-    }
-    DLL dll = (DLL) nameToDllMap.get(objectName);
-    // The DLL can be null because we use this to search through known
-    // DLLs in HotSpotTypeDataBase (for example)
-    if (dll != null) {
-      Win32Address addr = (Win32Address) dll.lookupSymbol(symbol);
-      if (addr != null) {
-        return addr.getValue();
-      }
-    }
-    return 0;
-  }
-
-  /** This reads bytes from the remote process. */
-  public synchronized ReadResult readBytesFromProcess(long address, long numBytes)
-    throws UnmappedAddressException, DebuggerException {
-    try {
-      String cmd = "peek " + utils.addressValueToString(address) + " " + numBytes;
-      printlnToOutput(cmd);
-      while (in.readByte() != 'B') {
-      }
-      byte res = in.readByte();
-      if (res == 0) {
-        System.err.println("Failing command: " + cmd);
-        throw new DebuggerException("Read of remote process address space failed");
-      }
-      // NOTE: must read ALL of the data regardless of whether we need
-      // to throw an UnmappedAddressException. Otherwise will corrupt
-      // the input stream each time we have a failure. Not good. Do
-      // not want to risk "flushing" the input stream in case a huge
-      // read has a hangup in the middle and we leave data on the
-      // stream.
-      byte[] buf = new byte[(int) numBytes];
-      boolean bailOut = false;
-      long failureAddress = 0;
-      while (numBytes > 0) {
-        long len = in.readUnsignedInt();
-        boolean isMapped = ((in.readByte() == 0) ? false : true);
-        if (!isMapped) {
-          if (!bailOut) {
-            bailOut = true;
-            failureAddress = address;
-          }
-        } else {
-          // This won't work if we have unmapped regions, but if we do
-          // then we're going to throw an exception anyway
-
-          // NOTE: there is a factor of 20 speed difference between
-          // these two ways of doing this read.
-          in.readBytes(buf, 0, (int) len);
-        }
-
-        // Do NOT do this:
-        //        for (int i = 0; i < (int) len; i++) {
-        //          buf[i] = in.readByte();
-        //        }
-
-        numBytes -= len;
-        address += len;
-      }
-      if (Assert.ASSERTS_ENABLED) {
-        Assert.that(numBytes == 0, "Bug in debug server's implementation of peek");
-      }
-      if (bailOut) {
-        return new ReadResult(failureAddress);
-      }
-      return new ReadResult(buf);
-    }
-    catch (IOException e) {
-      throw new DebuggerException(e);
-    }
-  }
-
-  /** Convenience routines */
-  private void printlnToOutput(String s) throws IOException {
-    out.println(s);
-    if (out.checkError()) {
-      throw new IOException("Error occurred while writing to debug server");
-    }
-  }
-
-  private void printToOutput(String s) throws IOException {
-    out.print(s);
-    if (out.checkError()) {
-      throw new IOException("Error occurred while writing to debug server");
-    }
-  }
-
-  private void writeIntToOutput(int val) throws IOException {
-    rawOut.writeInt(val);
-    rawOut.flush();
-  }
-
-  private void writeToOutput(byte[] buf, int off, int len) throws IOException {
-    rawOut.write(buf, off, len);
-    rawOut.flush();
-  }
-
-  /** Connects to the debug server, setting up out and in streams. */
-  private void connectToDebugServer() throws IOException {
-    // Try for a short period of time to connect to debug server; time out
-    // with failure if didn't succeed
-    debuggerSocket = null;
-    long endTime = System.currentTimeMillis() + SHORT_TIMEOUT;
-
-    while ((debuggerSocket == null) && (System.currentTimeMillis() < endTime)) {
-      try {
-        // FIXME: this does not work if we are on a DHCP machine which
-        // did not get an IP address this session. It appears to use
-        // an old cached address and the connection does not actually
-        // succeed. Must file a bug.
-        // debuggerSocket = new Socket(InetAddress.getLocalHost(), PORT);
-        debuggerSocket = new Socket(InetAddress.getByName("127.0.0.1"), PORT);
-        debuggerSocket.setTcpNoDelay(true);
-      }
-      catch (IOException e) {
-        // Swallow IO exceptions while attempting connection
-        debuggerSocket = null;
-        try {
-          // Don't swamp the CPU
-          Thread.sleep(750);
-        }
-        catch (InterruptedException ex) {
-        }
-      }
-    }
-
-    if (debuggerSocket == null) {
-      // Failed to connect because of timeout
-      throw new DebuggerException("Timed out while attempting to connect to debug server (please start SwDbgSrv.exe)");
-    }
-
-    out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(debuggerSocket.getOutputStream(), "US-ASCII")), true);
-    rawOut = new DataOutputStream(new BufferedOutputStream(debuggerSocket.getOutputStream()));
-    in = new InputLexer(new BufferedInputStream(debuggerSocket.getInputStream()));
-  }
-
-  private DLL findDLLByName(String fullPathName) {
-    for (Iterator iter = loadObjects.iterator(); iter.hasNext(); ) {
-      DLL dll = (DLL) iter.next();
-      if (dll.getName().equals(fullPathName)) {
-        return dll;
-      }
-    }
-    return null;
-  }
-
-  private void reresolveLoadObjects() throws DebuggerException {
-    try {
-      // It is too expensive to throw away the loadobject list every
-      // time the process is suspended, largely because of debug
-      // information re-parsing. When we suspend the target process we
-      // instead fetch the list of loaded libraries in the target and
-      // see whether any loadobject needs to be thrown away (because it
-      // was unloaded) or invalidated (because it was unloaded and
-      // reloaded at a different target address). Note that we don't
-      // properly handle the case of a loaded DLL being unloaded,
-      // recompiled, and reloaded. We could handle this by keeping a
-      // time stamp.
-
-      if (loadObjects == null) {
-        return;
-      }
-
-      // Need to create new list since have to figure out which ones
-      // were unloaded
-      List newLoadObjects = new ArrayList();
-
-    // Get list of library names and base addresses
-      printlnToOutput("libinfo");
-      int numInfo = in.parseInt();
-
-      for (int i = 0; i < numInfo; i++) {
-        // NOTE: because Win32 is case insensitive, we standardize on
-        // lowercase file names.
-        String  fullPathName = parseString().toLowerCase();
-        Address base         = newAddress(in.parseAddress());
-
-        // Look for full path name in DLL list
-        DLL dll = findDLLByName(fullPathName);
-        boolean mustLoad = true;
-        if (dll != null) {
-          loadObjects.remove(dll);
-
-          // See whether base addresses match; otherwise, need to reload
-          if (AddressOps.equal(base, dll.getBase())) {
-            mustLoad = false;
-          }
-        }
-
-        if (mustLoad) {
-          // Create new DLL
-          File   file = new File(fullPathName);
-          long   size = file.length();
-          String name = file.getName();
-          dll  = new DLL(this, fullPathName, size, base);
-          nameToDllMap.put(name, dll);
-        }
-        newLoadObjects.add(dll);
-      }
-
-      // All remaining entries in loadObjects have to be removed from
-      // the nameToDllMap
-      for (Iterator dllIter = loadObjects.iterator(); dllIter.hasNext(); ) {
-        DLL dll = (DLL) dllIter.next();
-        for (Iterator iter = nameToDllMap.keySet().iterator(); iter.hasNext(); ) {
-          String name = (String) iter.next();
-          if (nameToDllMap.get(name) == dll) {
-            nameToDllMap.remove(name);
-            break;
-          }
-        }
-      }
-
-      loadObjects = newLoadObjects;
-    } catch (IOException e) {
-      loadObjects = null;
-      nameToDllMap = null;
-      throw new DebuggerException(e);
-    }
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32LDTEntry.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import java.io.Serializable;
-
-/** Describes an LDT entry. (Some of the descriptions are taken
-    directly from Microsoft's documentation and are copyrighted by
-    Microsoft.) */
-
-class Win32LDTEntry implements Serializable {
-  private short limitLow;
-  private short baseLow;
-  private byte  baseMid;
-  private byte  flags1;
-  private byte  flags2;
-  private byte  baseHi;
-
-  private Win32LDTEntry() {}
-
-  public Win32LDTEntry(short limitLow,
-                       short baseLow,
-                       byte  baseMid,
-                       byte  flags1,
-                       byte  flags2,
-                       byte  baseHi) {
-    this.limitLow = limitLow;
-    this.baseLow  = baseLow;
-    this.baseMid  = baseMid;
-    this.flags1   = flags1;
-    this.flags2   = flags2;
-    this.baseHi   = baseHi;
-  }
-
-  /** Returns base address of segment */
-  public long  getBase()     { return ( (baseLow & 0xFFFF)       |
-                                       ((baseMid & 0xFF) << 16)  |
-                                       ((baseHi  & 0xFF) << 24)) & 0xFFFFFFFF; }
-
-  public short getLimitLow() { return limitLow; }
-  public short getBaseLow()  { return baseLow; }
-  public byte  getBaseMid()  { return baseMid; }
-  public byte  getBaseHi()   { return baseHi; }
-
-  // FIXME: must verify mask and shift are correct
-  /** Describes type of segment. See TYPE_ portion of {@link
-      sun.jvm.hotspot.debugger.win32.Win32LDTEntryConstants}. */
-  public int   getType()     { return (flags1 & 0x1F); }
-
-  // FIXME: verify mask and shift are correct
-  /** Privilege level of descriptor: 0 = most privileged, 3 = least privileged */
-  public int   getPrivilegeLevel() { return ((flags1 & 0x60) >> 5); }
-
-  // FIXME: verify mask is correct
-  /** Is segment present in physical memory? */
-  public boolean isSegmentPhysical() { return ((flags1 & 0x70) != 0); }
-
-  // FIXME: verify mask and shift are correct
-  /** High bits (16-19) of the address of the last byte of the segment */
-  public int getLimitHi() { return (flags2 & 0x0F); }
-
-  // FIXME: verify mask is correct
-  /** <P> Size of segment. If the segment is a data segment, this
-      member contains 1 if the segment is larger than 64 kilobytes (K)
-      or 0 if the segment is smaller than or equal to 64K. </P>
-
-      <P> If the segment is a code segment, this member contains 1 if
-      the segment is a code segment and runs with the default (native
-      mode) instruction set. This member contains 0 if the code
-      segment is an 80286 code segment and runs with 16-bit offsets
-      and the 80286-compatible instruction set. </P> */
-  public boolean isDefaultBig() { return ((flags2 & 0x40) != 0); }
-
-  // FIXME: verify mask is correct
-  /** Returns true if segment is page granular, false if byte
-      granular. */
-  public boolean isPageGranular() { return ((flags2 & 0x80) != 0); }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32LDTEntryConstants.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-/** Enumerates flags in Win32LDTEntry */
-
-interface Win32LDTEntryConstants {
-  // Types of segments
-  public static final int TYPE_READ_ONLY_DATA                      = 0;
-  public static final int TYPE_READ_WRITE_DATA                     = 1;
-  public static final int TYPE_UNUSED                              = 2;
-  public static final int TYPE_READ_WRITE_EXPAND_DOWN_DATA         = 3;
-  public static final int TYPE_EXECUTE_ONLY_CODE                   = 4;
-  public static final int TYPE_EXECUTABLE_READABLE_CODE            = 5;
-  public static final int TYPE_EXECUTE_ONLY_CONFORMING_CODE        = 6;
-  public static final int TYPE_EXECUTABLE_READABLE_CONFORMING_CODE = 7;
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32OopHandle.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +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.debugger.win32;
-
-import sun.jvm.hotspot.debugger.*;
-
-class Win32OopHandle extends Win32Address implements OopHandle {
-  Win32OopHandle(Win32Debugger debugger, long addr) {
-    super(debugger, addr);
-  }
-
-  public boolean equals(Object arg) {
-    if (arg == null) {
-      return false;
-    }
-
-    if (!(arg instanceof Win32OopHandle)) {
-      return false;
-    }
-
-    return (addr == ((Win32Address) arg).addr);
-  }
-
-  public Address    addOffsetTo       (long offset) throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("addOffsetTo not applicable to OopHandles (interior object pointers not allowed)");
-  }
-
-  public Address    andWithMask(long mask) throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("andWithMask not applicable to OopHandles (i.e., anything but C addresses)");
-  }
-
-  public Address    orWithMask(long mask) throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("orWithMask not applicable to OopHandles (i.e., anything but C addresses)");
-  }
-
-  public Address    xorWithMask(long mask) throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("xorWithMask not applicable to OopHandles (i.e., anything but C addresses)");
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32Thread.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.x86.*;
-
-class Win32Thread implements ThreadProxy {
-  private Win32Debugger debugger;
-  private int           handle;
-  private boolean       mustDuplicate;
-  private boolean       gotID;
-  private int           id;
-
-  /** The address argument must be the address of the HANDLE of the
-      desired thread in the target process. */
-  Win32Thread(Win32Debugger debugger, Address addr) {
-    this.debugger = debugger;
-    // FIXME: size of data fetched here should be configurable.
-    // However, making it so would produce a dependency on the "types"
-    // package from the debugger package, which is not desired.
-    this.handle   = (int) addr.getCIntegerAt(0, 4, true);
-    // Thread handles in the target process must be duplicated before
-    // fetching their contexts
-    mustDuplicate = true;
-    gotID = false;
-  }
-
-  /** The integer argument must be the value of a HANDLE received from
-      the "threadlist" operation. */
-  Win32Thread(Win32Debugger debugger, long handle) {
-    this.debugger = debugger;
-    this.handle   = (int) handle;
-    mustDuplicate = false;
-    gotID         = false;
-  }
-
-  public ThreadContext getContext() throws IllegalThreadStateException {
-    if (!debugger.isSuspended()) {
-      throw new IllegalThreadStateException("Target process must be suspended");
-    }
-    long[] data = debugger.getThreadIntegerRegisterSet(handle, mustDuplicate);
-    Win32ThreadContext context = new Win32ThreadContext(debugger);
-    for (int i = 0; i < data.length; i++) {
-      context.setRegister(i, data[i]);
-    }
-    return context;
-  }
-
-  public boolean canSetContext() throws DebuggerException {
-    return true;
-  }
-
-  public void setContext(ThreadContext thrCtx)
-    throws IllegalThreadStateException, DebuggerException {
-    if (!debugger.isSuspended()) {
-      throw new IllegalThreadStateException("Target process must be suspended");
-    }
-    X86ThreadContext context = (X86ThreadContext) thrCtx;
-    long[] data = new long[X86ThreadContext.NPRGREG];
-    for (int i = 0; i < data.length; i++) {
-      data[i] = context.getRegister(i);
-    }
-    debugger.setThreadIntegerRegisterSet(handle, mustDuplicate, data);
-  }
-
-  public boolean equals(Object obj) {
-    if ((obj == null) || !(obj instanceof Win32Thread)) {
-      return false;
-    }
-
-    return (((Win32Thread) obj).getThreadID() == getThreadID());
-  }
-
-  public int hashCode() {
-    return getThreadID();
-  }
-
-  public String toString() {
-    return Integer.toString(getThreadID());
-  }
-
-  /** Retrieves the thread ID of this thread by examining the Thread
-      Information Block. */
-  private int getThreadID() {
-    if (!gotID) {
-      try {
-        // Get thread context
-        X86ThreadContext context = (X86ThreadContext) getContext();
-        // Get LDT entry for FS register
-        Win32LDTEntry ldt =
-          debugger.getThreadSelectorEntry(handle,
-                                          mustDuplicate,
-                                          (int) context.getRegister(X86ThreadContext.FS));
-        // Get base address of segment = Thread Environment Block (TEB)
-        Address teb = debugger.newAddress(ldt.getBase());
-        // Thread ID is at offset 0x24
-        id = (int) teb.getCIntegerAt(0x24, 4, true);
-        gotID = true;
-      } catch (AddressException e) {
-        throw new DebuggerException(e);
-      }
-    }
-
-    return id;
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32ThreadContext.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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.debugger.win32;
-
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.x86.*;
-
-class Win32ThreadContext extends X86ThreadContext {
-  private Win32Debugger debugger;
-
-  public Win32ThreadContext(Win32Debugger debugger) {
-    super();
-    this.debugger = debugger;
-  }
-
-  public void setRegisterAsAddress(int index, Address value) {
-    setRegister(index, debugger.getAddressValue(value));
-  }
-
-  public Address getRegisterAsAddress(int index) {
-    return debugger.newAddress(getRegister(index));
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.gc_implementation.g1;
+
+import java.util.Iterator;
+import java.util.Observable;
+import java.util.Observer;
+
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.gc_interface.CollectedHeapName;
+import sun.jvm.hotspot.memory.MemRegion;
+import sun.jvm.hotspot.memory.SharedHeap;
+import sun.jvm.hotspot.memory.SpaceClosure;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.runtime.VMObjectFactory;
+import sun.jvm.hotspot.types.AddressField;
+import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+
+// Mirror class for G1CollectedHeap.
+
+public class G1CollectedHeap extends SharedHeap {
+    // HeapRegionSeq _seq;
+    static private long hrsFieldOffset;
+    // MemRegion _g1_committed;
+    static private long g1CommittedFieldOffset;
+    // size_t _summary_bytes_used;
+    static private CIntegerField summaryBytesUsedField;
+    // G1MonitoringSupport* _g1mm
+    static private AddressField g1mmField;
+
+    static {
+        VM.registerVMInitializedObserver(new Observer() {
+                public void update(Observable o, Object data) {
+                    initialize(VM.getVM().getTypeDataBase());
+                }
+            });
+    }
+
+    static private synchronized void initialize(TypeDataBase db) {
+        Type type = db.lookupType("G1CollectedHeap");
+
+        hrsFieldOffset = type.getField("_hrs").getOffset();
+        g1CommittedFieldOffset = type.getField("_g1_committed").getOffset();
+        summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used");
+        g1mmField = type.getAddressField("_g1mm");
+    }
+
+    public long capacity() {
+        Address g1CommittedAddr = addr.addOffsetTo(g1CommittedFieldOffset);
+        MemRegion g1_committed = new MemRegion(g1CommittedAddr);
+        return g1_committed.byteSize();
+    }
+
+    public long used() {
+        return summaryBytesUsedField.getValue(addr);
+    }
+
+    public long n_regions() {
+        return hrs().length();
+    }
+
+    private HeapRegionSeq hrs() {
+        Address hrsAddr = addr.addOffsetTo(hrsFieldOffset);
+        return (HeapRegionSeq) VMObjectFactory.newObject(HeapRegionSeq.class,
+                                                         hrsAddr);
+    }
+
+    public G1MonitoringSupport g1mm() {
+        Address g1mmAddr = g1mmField.getValue(addr);
+        return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr);
+    }
+
+    private Iterator<HeapRegion> heapRegionIterator() {
+        return hrs().heapRegionIterator();
+    }
+
+    public void heapRegionIterate(SpaceClosure scl) {
+        Iterator<HeapRegion> iter = heapRegionIterator();
+        while (iter.hasNext()) {
+            HeapRegion hr = iter.next();
+            scl.doSpace(hr);
+        }
+    }
+
+    public CollectedHeapName kind() {
+        return CollectedHeapName.G1_COLLECTED_HEAP;
+    }
+
+    public G1CollectedHeap(Address addr) {
+        super(addr);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1MonitoringSupport.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.gc_implementation.g1;
+
+import java.util.Observable;
+import java.util.Observer;
+
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.runtime.VMObject;
+import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+
+// Mirror class for G1MonitoringSupport.
+
+public class G1MonitoringSupport extends VMObject {
+    // size_t _eden_committed;
+    static private CIntegerField edenCommittedField;
+    // size_t _eden_used;
+    static private CIntegerField edenUsedField;
+    // size_t _survivor_committed;
+    static private CIntegerField survivorCommittedField;
+    // size_t _survivor_used;
+    static private CIntegerField survivorUsedField;
+    // size_t _old_committed;
+    static private CIntegerField oldCommittedField;
+    // size_t _old_used;
+    static private CIntegerField oldUsedField;
+
+    static {
+        VM.registerVMInitializedObserver(new Observer() {
+                public void update(Observable o, Object data) {
+                    initialize(VM.getVM().getTypeDataBase());
+                }
+            });
+    }
+
+    static private synchronized void initialize(TypeDataBase db) {
+        Type type = db.lookupType("G1MonitoringSupport");
+
+        edenCommittedField = type.getCIntegerField("_eden_committed");
+        edenUsedField = type.getCIntegerField("_eden_used");
+        survivorCommittedField = type.getCIntegerField("_survivor_committed");
+        survivorUsedField = type.getCIntegerField("_survivor_used");
+        oldCommittedField = type.getCIntegerField("_old_committed");
+        oldUsedField = type.getCIntegerField("_old_used");
+    }
+
+    public long edenCommitted() {
+        return edenCommittedField.getValue(addr);
+    }
+
+    public long edenUsed() {
+        return edenUsedField.getValue(addr);
+    }
+
+    public long survivorCommitted() {
+        return survivorCommittedField.getValue(addr);
+    }
+
+    public long survivorUsed() {
+        return survivorUsedField.getValue(addr);
+    }
+
+    public long oldCommitted() {
+        return oldCommittedField.getValue(addr);
+    }
+
+    public long oldUsed() {
+        return oldUsedField.getValue(addr);
+    }
+
+    public G1MonitoringSupport(Address addr) {
+        super(addr);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegion.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.gc_implementation.g1;
+
+import java.util.Observable;
+import java.util.Observer;
+
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.memory.ContiguousSpace;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+
+// Mirror class for HeapRegion. Currently we don't actually include
+// any of its fields but only iterate over it (which we get "for free"
+// as HeapRegion ultimately inherits from ContiguousSpace).
+
+public class HeapRegion extends ContiguousSpace {
+    // static int GrainBytes;
+    static private CIntegerField grainBytesField;
+
+    static {
+        VM.registerVMInitializedObserver(new Observer() {
+                public void update(Observable o, Object data) {
+                    initialize(VM.getVM().getTypeDataBase());
+                }
+            });
+    }
+
+    static private synchronized void initialize(TypeDataBase db) {
+        Type type = db.lookupType("HeapRegion");
+
+        grainBytesField = type.getCIntegerField("GrainBytes");
+    }
+
+    static public long grainBytes() {
+        return grainBytesField.getValue();
+    }
+
+    public HeapRegion(Address addr) {
+        super(addr);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.gc_implementation.g1;
+
+import java.util.Iterator;
+import java.util.Observable;
+import java.util.Observer;
+
+import sun.jvm.hotspot.debugger.Address;
+import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.runtime.VMObject;
+import sun.jvm.hotspot.runtime.VMObjectFactory;
+import sun.jvm.hotspot.types.AddressField;
+import sun.jvm.hotspot.types.CIntegerField;
+import sun.jvm.hotspot.types.Type;
+import sun.jvm.hotspot.types.TypeDataBase;
+
+// Mirror class for HeapRegionSeq. It's essentially an index -> HeapRegion map.
+
+public class HeapRegionSeq extends VMObject {
+    // HeapRegion** _regions;
+    static private AddressField regionsField;
+    // size_t _length;
+    static private CIntegerField lengthField;
+
+    static {
+        VM.registerVMInitializedObserver(new Observer() {
+                public void update(Observable o, Object data) {
+                    initialize(VM.getVM().getTypeDataBase());
+                }
+            });
+    }
+
+    static private synchronized void initialize(TypeDataBase db) {
+        Type type = db.lookupType("HeapRegionSeq");
+
+        regionsField = type.getAddressField("_regions");
+        lengthField = type.getCIntegerField("_length");
+    }
+
+    private HeapRegion at(long index) {
+        Address arrayAddr = regionsField.getValue(addr);
+        // Offset of &_region[index]
+        long offset = index * VM.getVM().getAddressSize();
+        Address regionAddr = arrayAddr.getAddressAt(offset);
+        return (HeapRegion) VMObjectFactory.newObject(HeapRegion.class,
+                                                      regionAddr);
+    }
+
+    public long length() {
+        return lengthField.getValue(addr);
+    }
+
+    private class HeapRegionIterator implements Iterator<HeapRegion> {
+        private long index;
+        private long length;
+
+        @Override
+        public boolean hasNext() { return index < length; }
+
+        @Override
+        public HeapRegion next() { return at(index++);    }
+
+        @Override
+        public void remove()     { /* not supported */    }
+
+        HeapRegionIterator(Address addr) {
+            index = 0;
+            length = length();
+        }
+    }
+
+    public Iterator<HeapRegion> heapRegionIterator() {
+        return new HeapRegionIterator(addr);
+    }
+
+    public HeapRegionSeq(Address addr) {
+        super(addr);
+    }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/CollectedHeapName.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/CollectedHeapName.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
   public static final CollectedHeapName ABSTRACT = new CollectedHeapName("abstract");
   public static final CollectedHeapName SHARED_HEAP = new CollectedHeapName("SharedHeap");
   public static final CollectedHeapName GEN_COLLECTED_HEAP = new CollectedHeapName("GenCollectedHeap");
+  public static final CollectedHeapName G1_COLLECTED_HEAP = new CollectedHeapName("G1CollectedHeap");
   public static final CollectedHeapName PARALLEL_SCAVENGE_HEAP = new CollectedHeapName("ParallelScavengeHeap");
 
   public String toString() {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java	Wed Oct 26 17:59:13 2011 -0700
@@ -90,7 +90,7 @@
            jcode == Bytecodes._ldc2_w;
     if (! codeOk) return false;
 
-    ConstantTag ctag = method().getConstants().getTagAt(rawIndex());
+    ConstantTag ctag = method().getConstants().getTagAt(poolIndex());
     if (jcode == Bytecodes._ldc2_w) {
        // has to be double or long
        return (ctag.isDouble() || ctag.isLong()) ? true: false;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -28,11 +28,13 @@
 
 import com.sun.jdi.*;
 
+import sun.jvm.hotspot.memory.SystemDictionary;
 import sun.jvm.hotspot.oops.Instance;
 import sun.jvm.hotspot.oops.InstanceKlass;
 import sun.jvm.hotspot.oops.ArrayKlass;
 import sun.jvm.hotspot.oops.JVMDIClassStatus;
 import sun.jvm.hotspot.oops.Klass;
+import sun.jvm.hotspot.oops.ObjArray;
 import sun.jvm.hotspot.oops.Oop;
 import sun.jvm.hotspot.oops.Symbol;
 import sun.jvm.hotspot.oops.DefaultHeapVisitor;
@@ -53,6 +55,7 @@
     private SoftReference methodsCache;
     private SoftReference allMethodsCache;
     private SoftReference nestedTypesCache;
+    private SoftReference methodInvokesCache;
 
     /* to mark when no info available */
     static final SDE NO_SDE_INFO_MARK = new SDE();
@@ -82,6 +85,27 @@
                 return method;
             }
         }
+        if (ref.getMethodHolder().equals(SystemDictionary.getMethodHandleKlass())) {
+          // invoke methods are generated as needed, so make mirrors as needed
+          List mis = null;
+          if (methodInvokesCache == null) {
+            mis = new ArrayList();
+            methodInvokesCache = new SoftReference(mis);
+          } else {
+            mis = (List)methodInvokesCache.get();
+          }
+          it = mis.iterator();
+          while (it.hasNext()) {
+            MethodImpl method = (MethodImpl)it.next();
+            if (ref.equals(method.ref())) {
+              return method;
+            }
+          }
+
+          MethodImpl method = MethodImpl.createMethodImpl(vm, this, ref);
+          mis.add(method);
+          return method;
+        }
         throw new IllegalArgumentException("Invalid method id: " + ref);
     }
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/SADebugServer.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/SADebugServer.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,14 +51,6 @@
          usage();
       }
 
-      // By default, SA agent classes prefer dbx debugger to proc debugger
-      // and Windows process debugger to windbg debugger. SA expects
-      // special properties to be set to choose other debuggers. For SA/JDI,
-      // we choose proc, windbg debuggers instead of the defaults.
-
-      System.setProperty("sun.jvm.hotspot.debugger.useProcDebugger", "true");
-      System.setProperty("sun.jvm.hotspot.debugger.useWindbgDebugger", "true");
-
       // delegate to the actual SA debug server.
       sun.jvm.hotspot.DebugServer.main(args);
    }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/StackFrameImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/StackFrameImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -123,6 +123,9 @@
                 Assert.that(values.size() > 0, "this is missing");
             }
             // 'this' at index 0.
+            if (values.get(0).getType() == BasicType.getTConflict()) {
+              return null;
+            }
             OopHandle handle = values.oopHandleAt(0);
             ObjectHeap heap = vm.saObjectHeap();
             thisObject = vm.objectMirror(heap.newOop(handle));
@@ -210,6 +213,8 @@
         validateStackFrame();
         StackValueCollection values = saFrame.getLocals();
         MethodImpl mmm = (MethodImpl)location.method();
+        if (mmm.isNative())
+            return null;
         List argSigs = mmm.argumentSignatures();
         int count = argSigs.size();
         List res = new ArrayList(0);
@@ -231,34 +236,67 @@
         ValueImpl valueImpl = null;
         OopHandle handle = null;
         ObjectHeap heap = vm.saObjectHeap();
-        if (variableType == BasicType.T_BOOLEAN) {
+        if (values.get(ss).getType() == BasicType.getTConflict()) {
+          // Dead locals, so just represent them as a zero of the appropriate type
+          if (variableType == BasicType.T_BOOLEAN) {
+            valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
+          } else if (variableType == BasicType.T_CHAR) {
+            valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
+          } else if (variableType == BasicType.T_FLOAT) {
+            valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
+          } else if (variableType == BasicType.T_DOUBLE) {
+            valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
+          } else if (variableType == BasicType.T_BYTE) {
+            valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
+          } else if (variableType == BasicType.T_SHORT) {
+            valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
+          } else if (variableType == BasicType.T_INT) {
+            valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
+          } else if (variableType == BasicType.T_LONG) {
+            valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
+          } else if (variableType == BasicType.T_OBJECT) {
+            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
+            // elements themselves may be arrays because every array is an Object.
+            handle = null;
+            valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
+          } else if (variableType == BasicType.T_ARRAY) {
+            handle = null;
+            valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
+          } else if (variableType == BasicType.T_VOID) {
+            valueImpl = new VoidValueImpl(vm);
+          } else {
+            throw new RuntimeException("Should not read here");
+          }
+        } else {
+          if (variableType == BasicType.T_BOOLEAN) {
             valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
-        } else if (variableType == BasicType.T_CHAR) {
+          } else if (variableType == BasicType.T_CHAR) {
             valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
-        } else if (variableType == BasicType.T_FLOAT) {
+          } else if (variableType == BasicType.T_FLOAT) {
             valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
-        } else if (variableType == BasicType.T_DOUBLE) {
+          } else if (variableType == BasicType.T_DOUBLE) {
             valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
-        } else if (variableType == BasicType.T_BYTE) {
+          } else if (variableType == BasicType.T_BYTE) {
             valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
-        } else if (variableType == BasicType.T_SHORT) {
+          } else if (variableType == BasicType.T_SHORT) {
             valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
-        } else if (variableType == BasicType.T_INT) {
+          } else if (variableType == BasicType.T_INT) {
             valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
-        } else if (variableType == BasicType.T_LONG) {
+          } else if (variableType == BasicType.T_LONG) {
             valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
-        } else if (variableType == BasicType.T_OBJECT) {
+          } else if (variableType == BasicType.T_OBJECT) {
             // we may have an [Ljava/lang/Object; - i.e., Object[] with the
             // elements themselves may be arrays because every array is an Object.
             handle = values.oopHandleAt(ss);
             valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
-        } else if (variableType == BasicType.T_ARRAY) {
+          } else if (variableType == BasicType.T_ARRAY) {
             handle = values.oopHandleAt(ss);
             valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
-        } else if (variableType == BasicType.T_VOID) {
+          } else if (variableType == BasicType.T_VOID) {
             valueImpl = new VoidValueImpl(vm);
-        } else {
+          } else {
             throw new RuntimeException("Should not read here");
+          }
         }
 
         return valueImpl;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/VirtualMachineImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -263,14 +263,6 @@
                                             this.hashCode() + "]");
 
         ((com.sun.tools.jdi.VirtualMachineManagerImpl)mgr).addVirtualMachine(this);
-
-        // By default SA agent classes prefer dbx debugger to proc debugger
-        // and Windows process debugger to windbg debugger. SA expects
-        // special properties to be set to choose other debuggers. We will set
-        // those here before attaching to SA agent.
-
-        System.setProperty("sun.jvm.hotspot.debugger.useProcDebugger", "true");
-        System.setProperty("sun.jvm.hotspot.debugger.useWindbgDebugger", "true");
     }
 
     // we reflectively use newly spec'ed class because our ALT_BOOTDIR
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java	Wed Oct 26 17:59:13 2011 -0700
@@ -44,6 +44,7 @@
   private static sun.jvm.hotspot.types.OopField systemKlassField;
   private static sun.jvm.hotspot.types.OopField threadKlassField;
   private static sun.jvm.hotspot.types.OopField threadGroupKlassField;
+  private static sun.jvm.hotspot.types.OopField methodHandleKlassField;
 
   static {
     VM.registerVMInitializedObserver(new Observer() {
@@ -69,6 +70,7 @@
     systemKlassField = type.getOopField(WK_KLASS("System_klass"));
     threadKlassField = type.getOopField(WK_KLASS("Thread_klass"));
     threadGroupKlassField = type.getOopField(WK_KLASS("ThreadGroup_klass"));
+    methodHandleKlassField = type.getOopField(WK_KLASS("MethodHandle_klass"));
   }
 
   // This WK functions must follow the definitions in systemDictionary.hpp:
@@ -127,6 +129,10 @@
     return (InstanceKlass) newOop(systemKlassField.getValue());
   }
 
+  public static InstanceKlass getMethodHandleKlass() {
+    return (InstanceKlass) newOop(methodHandleKlassField.getValue());
+  }
+
   public InstanceKlass getAbstractOwnableSynchronizerKlass() {
     return (InstanceKlass) find("java/util/concurrent/locks/AbstractOwnableSynchronizer",
                                 null, null);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.gc_interface.*;
+import sun.jvm.hotspot.gc_implementation.g1.G1CollectedHeap;
 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.types.*;
@@ -72,6 +73,7 @@
     heapConstructor = new VirtualConstructor(db);
     heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class);
     heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
+    heapConstructor.addMapping("G1CollectedHeap", G1CollectedHeap.class);
 
     mainThreadGroupField   = type.getOopField("_main_thread_group");
     systemThreadGroupField = type.getOopField("_system_thread_group");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// ArrayData
+//
+// A ArrayData is a base class for accessing profiling data which does
+// not have a statically known size.  It consists of an array length
+// and an array start.
+abstract class ArrayData extends ProfileData {
+
+  static final int arrayLenOffSet = 0;
+  static final int arrayStartOffSet = 1;
+
+  int arrayUintAt(int index) {
+    int aindex = index + arrayStartOffSet;
+    return uintAt(aindex);
+  }
+  int arrayIntAt(int index) {
+    int aindex = index + arrayStartOffSet;
+    return intAt(aindex);
+  }
+  Oop arrayOopAt(int index) {
+    int aindex = index + arrayStartOffSet;
+    return oopAt(aindex);
+  }
+
+  // Code generation support for subclasses.
+  static int arrayElementOffset(int index) {
+    return cellOffset(arrayStartOffSet + index);
+  }
+
+  ArrayData(DataLayout layout) {
+    super(layout);
+  }
+
+  static int staticCellCount() {
+    return -1;
+  }
+
+  int arrayLen() {
+    return intAt(arrayLenOffSet);
+  }
+
+  public int cellCount() {
+    return arrayLen() + 1;
+  }
+
+  // Code generation support
+  static int arrayLenOffset() {
+    return cellOffset(arrayLenOffSet);
+  }
+  static int arrayStartOffset() {
+    return cellOffset(arrayStartOffSet);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/BitData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// BitData
+//
+// A BitData holds a flag or two in its header.
+public class BitData extends ProfileData {
+
+  // nullSeen:
+  //  saw a null operand (cast/aastore/instanceof)
+  static final int nullSeenFlag              = DataLayout.firstFlag + 0;
+  static final int bitCellCount = 0;
+
+  public BitData(DataLayout layout) {
+    super(layout);
+  }
+
+  static int staticCellCount() {
+    return bitCellCount;
+  }
+
+  public int cellCount() {
+    return staticCellCount();
+  }
+
+  // Accessor
+
+  // The nullSeen flag bit is specially known to the interpreter.
+  // Consulting it allows the compiler to avoid setting up nullCheck traps.
+  boolean nullSeen()     { return flagAt(nullSeenFlag); }
+
+  // Code generation support
+  // static int nullSeenByteConstant() {
+  //   return flagNumberToByteConstant(nullSeenFlag);
+  // }
+
+  static int bitDataSize() {
+    return cellOffset(bitCellCount);
+  }
+
+  public void printDataOn(PrintStream st) {
+    printShared(st, "BitData");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/BranchData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// BranchData
+//
+// A BranchData is used to access profiling data for a two-way branch.
+// It consists of taken and notTaken counts as well as a data displacement
+// for the taken case.
+public class BranchData extends JumpData {
+
+  static final int notTakenOffSet = jumpCellCount;
+  static final int branchCellCount = notTakenOffSet + 1;
+
+  public BranchData(DataLayout layout) {
+    super(layout);
+    //assert(layout.tag() == DataLayout.branchDataTag, "wrong type");
+  }
+
+  static int staticCellCount() {
+    return branchCellCount;
+  }
+
+  public int cellCount() {
+    return staticCellCount();
+  }
+
+  // Direct accessor
+  int notTaken() {
+    return uintAt(notTakenOffSet);
+  }
+
+  // Code generation support
+  static int notTakenOffset() {
+    return cellOffset(notTakenOffSet);
+  }
+  static int branchDataSize() {
+    return cellOffset(branchCellCount);
+  }
+
+  public void printDataOn(PrintStream st) {
+    printShared(st, "BranchData");
+    st.println("taken(" + taken() + ") displacement(" + displacement() + ")");
+    tab(st);
+    st.println("not taken(" + notTaken() + ")");
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CIntField.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CIntField.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,9 @@
   public long getValue(Oop obj) {
     return obj.getHandle().getCIntegerAt(getOffset(), size, isUnsigned);
   }
+  public long getValue(Address addr) {
+    return addr.getCIntegerAt(getOffset(), size, isUnsigned);
+  }
   public void setValue(Oop obj, long value) throws MutationException {
     // Fix this: set* missing in Address
   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/CounterData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// CounterData
+//
+// A CounterData corresponds to a simple counter.
+public class CounterData extends BitData {
+
+  static final int countOff = 0;
+  static final int counterCellCount = 1;
+
+  public CounterData(DataLayout layout) {
+    super(layout);
+  }
+
+  static int staticCellCount() {
+    return counterCellCount;
+  }
+
+  public int cellCount() {
+    return staticCellCount();
+  }
+
+  // Direct accessor
+  int count() {
+    return uintAt(countOff);
+  }
+
+  // Code generation support
+  static int countOffset() {
+    return cellOffset(countOff);
+  }
+  static int counterDataSize() {
+    return cellOffset(counterCellCount);
+  }
+
+  public void printDataOn(PrintStream st) {
+    printShared(st, "CounterData");
+    st.println("count(" + count() + ")");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/DataLayout.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+public class DataLayout {
+  public static final int noTag = 0;
+  public static final int bitDataTag = 1;
+  public static final int counterDataTag = 2;
+  public static final int jumpDataTag= 3;
+  public static final int receiverTypeDataTag = 4;
+  public static final int virtualCallDataTag = 5;
+  public static final int retDataTag = 6;
+  public static final int branchDataTag = 7;
+  public static final int multiBranchDataTag = 8;
+
+  // The _struct._flags word is formatted as [trapState:4 | flags:4].
+  // The trap state breaks down further as [recompile:1 | reason:3].
+  // This further breakdown is defined in deoptimization.cpp.
+  // See Deoptimization.trapStateReason for an assert that
+  // trapBits is big enough to hold reasons < reasonRecordedLimit.
+  //
+  // The trapState is collected only if ProfileTraps is true.
+  public static final int trapBits = 1+3;  // 3: enough to distinguish [0..reasonRecordedLimit].
+  public static final int trapShift = 8 - trapBits;
+  public static final int trapMask = Bits.rightNBits(trapBits);
+  public static final int trapMaskInPlace = (trapMask << trapShift);
+  public static final int flagLimit = trapShift;
+  public static final int flagMask = Bits.rightNBits(flagLimit);
+  public static final int firstFlag = 0;
+
+  private Address data;
+
+  private int offset;
+
+  private boolean handlized;
+
+  public DataLayout(MethodData d, int o) {
+    data = d.getHandle();
+    offset = o;
+  }
+
+  public DataLayout(Address d, int o) {
+    data = d;
+    offset = o;
+    handlized = true;
+  }
+
+  public int dp() { return offset; }
+
+  private int getU11(int at) {
+    return data.getJByteAt(offset + at) & 0xff;
+  }
+
+  private int getU22(int at) {
+    return data.getJShortAt(offset + at) & 0xffff;
+  }
+
+  int cellAt(int index) {
+    // Cells are intptr_t sized but only contain ints as raw values
+    return (int)data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false);
+  }
+
+  Oop oopAt(int index) {
+    OopHandle handle;
+    if (handlized) {
+      throw new InternalError("unsupported");
+    }
+    handle = data.getOopHandleAt(offset + cellOffset(index));
+    return VM.getVM().getObjectHeap().newOop(handle);
+  }
+
+  public Address addressAt(int index) {
+    OopHandle handle;
+    if (handlized) {
+      return data.getAddressAt(offset + cellOffset(index));
+    } else {
+      return data.getOopHandleAt(offset + cellOffset(index));
+    }
+  }
+
+  // Every data layout begins with a header.  This header
+  // contains a tag, which is used to indicate the size/layout
+  // of the data, 4 bits of flags, which can be used in any way,
+  // 4 bits of trap history (none/one reason/many reasons),
+  // and a bci, which is used to tie this piece of data to a
+  // specific bci in the bytecodes.
+  // union {
+  //   intptrT _bits;
+  //   struct {
+  //     u1 _tag;
+  //     u1 _flags;
+  //     u2 _bci;
+  //   } _struct;
+  // } _header;
+
+  // Some types of data layouts need a length field.
+  static boolean needsArrayLen(int tag) {
+    return (tag == multiBranchDataTag);
+  }
+
+  public static final int counterIncrement = 1;
+
+  // Size computation
+  static int headerSizeInBytes() {
+    return MethodData.cellSize;
+  }
+  static int headerSizeInCells() {
+    return 1;
+  }
+
+  static int computeSizeInBytes(int cellCount) {
+    return headerSizeInBytes() + cellCount * MethodData.cellSize;
+  }
+
+  // Initialization
+  // void initialize(int tag, int bci, int cellCount);
+
+  // Accessors
+  public int tag() {
+    return getU11(0);
+  }
+
+  // Return a few bits of trap state.  Range is [0..trapMask].
+  // The state tells if traps with zero, one, or many reasons have occurred.
+  // It also tells whether zero or many recompilations have occurred.
+  // The associated trap histogram in the MDO itself tells whether
+  // traps are common or not.  If a BCI shows that a trap X has
+  // occurred, and the MDO shows N occurrences of X, we make the
+  // simplifying assumption that all N occurrences can be blamed
+  // on that BCI.
+  int trapState() {
+    return (flags() >> trapShift) & trapMask;
+  }
+
+  int flags() {
+    return getU11(1);
+  }
+
+  int bci() {
+    return getU22(2);
+  }
+
+  boolean flagAt(int flagNumber) {
+    // assert(flagNumber < flagLimit, "oob");
+    return (flags() & (0x1 << flagNumber)) != 0;
+  }
+
+  // Low-level support for code generation.
+  static int headerOffset() {
+    return 0;
+  }
+  static int tagOffset() {
+    return 0;
+  }
+  static int flagsOffset() {
+    return 1;
+  }
+  static int bciOffset() {
+    return 2;
+  }
+  public static int cellOffset(int index) {
+    return MethodData.cellSize + index * MethodData.cellSize;
+  }
+  // // Return a value which, when or-ed as a byte into _flags, sets the flag.
+  // static int flagNumberToByteConstant(int flagNumber) {
+  //   assert(0 <= flagNumber && flagNumber < flagLimit, "oob");
+  //   DataLayout temp; temp.setHeader(0);
+  //   temp.setFlagAt(flagNumber);
+  //   return temp._header._struct._flags;
+  // }
+  // // Return a value which, when or-ed as a word into _header, sets the flag.
+  // static intptrT flagMaskToHeaderMask(int byteConstant) {
+  //   DataLayout temp; temp.setHeader(0);
+  //   temp._header._struct._flags = byteConstant;
+  //   return temp._header._bits;
+  // }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,28 +39,20 @@
 
   /** Constructor for fields that are named in an InstanceKlass's
       fields array (i.e., named, non-VM fields) */
-  Field(InstanceKlass holder, int fieldArrayIndex) {
+  Field(InstanceKlass holder, int fieldIndex) {
     this.holder = holder;
-    this.fieldArrayIndex = fieldArrayIndex;
+    this.fieldIndex = fieldIndex;
+
+    offset               = holder.getFieldOffset(fieldIndex);
+    genericSignature     = holder.getFieldGenericSignature(fieldIndex);
 
-    ConstantPool cp      = holder.getConstants();
-    TypeArray fields     = holder.getFields();
-    short access         = fields.getShortAt(fieldArrayIndex + InstanceKlass.ACCESS_FLAGS_OFFSET);
-    short nameIndex      = fields.getShortAt(fieldArrayIndex + InstanceKlass.NAME_INDEX_OFFSET);
-    short signatureIndex = fields.getShortAt(fieldArrayIndex + InstanceKlass.SIGNATURE_INDEX_OFFSET);
-    offset               = VM.getVM().buildIntFromShorts(fields.getShortAt(fieldArrayIndex + InstanceKlass.LOW_OFFSET),
-                                                         fields.getShortAt(fieldArrayIndex + InstanceKlass.HIGH_OFFSET));
-    short genericSignatureIndex = fields.getShortAt(fieldArrayIndex + InstanceKlass.GENERIC_SIGNATURE_INDEX_OFFSET);
-    Symbol name = cp.getSymbolAt(nameIndex);
+    Symbol name          = holder.getFieldName(fieldIndex);
     id          = new NamedFieldIdentifier(name.asString());
-    signature   = cp.getSymbolAt(signatureIndex);
-    if (genericSignatureIndex != 0)  {
-       genericSignature = cp.getSymbolAt(genericSignatureIndex);
-    } else {
-       genericSignature = null;
-    }
 
+    signature            = holder.getFieldSignature(fieldIndex);
     fieldType   = new FieldType(signature);
+
+    short access         = holder.getFieldAccessFlags(fieldIndex);
     accessFlags = new AccessFlags(access);
   }
 
@@ -73,7 +65,7 @@
   private Symbol          signature;
   private Symbol          genericSignature;
   private AccessFlags     accessFlags;
-  private int             fieldArrayIndex;
+  private int             fieldIndex;
 
   /** Returns the byte offset of the field within the object or klass */
   public long getOffset() { return offset; }
@@ -101,8 +93,8 @@
   /** (Named, non-VM fields only) Returns the index in the fields
       TypeArray for this field. Equivalent to the "index" in the VM's
       fieldDescriptors. */
-  public int getFieldArrayIndex() {
-    return fieldArrayIndex;
+  public int getFieldIndex() {
+    return fieldIndex;
   }
 
   /** (Named, non-VM fields only) Retrieves the access flags. */
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/FieldType.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/FieldType.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,6 +67,8 @@
   public boolean isObject()  { return first == 'L'; }
   public boolean isArray()   { return first == '['; }
 
+  public Symbol getSignature() { return signature; }
+
   public static class ArrayInfo {
     private int dimension;
     private int elementBasicType; // See BasicType.java
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java	Wed Oct 26 17:59:13 2011 -0700
@@ -44,14 +44,14 @@
   }
 
   // field offset constants
-  public static int ACCESS_FLAGS_OFFSET;
-  public static int NAME_INDEX_OFFSET;
-  public static int SIGNATURE_INDEX_OFFSET;
-  public static int INITVAL_INDEX_OFFSET;
-  public static int LOW_OFFSET;
-  public static int HIGH_OFFSET;
-  public static int GENERIC_SIGNATURE_INDEX_OFFSET;
-  public static int NEXT_OFFSET;
+  private static int ACCESS_FLAGS_OFFSET;
+  private static int NAME_INDEX_OFFSET;
+  private static int SIGNATURE_INDEX_OFFSET;
+  private static int INITVAL_INDEX_OFFSET;
+  private static int LOW_OFFSET;
+  private static int HIGH_OFFSET;
+  private static int GENERIC_SIGNATURE_INDEX_OFFSET;
+  private static int FIELD_SLOTS;
   public static int IMPLEMENTORS_LIMIT;
 
   // ClassState constants
@@ -78,6 +78,7 @@
       implementors[i]    = new OopField(type.getOopField("_implementors[0]"), arrayOffset);
     }
     fields               = new OopField(type.getOopField("_fields"), Oop.getHeaderSize());
+    javaFieldsCount      = new CIntField(type.getCIntegerField("_java_fields_count"), Oop.getHeaderSize());
     constants            = new OopField(type.getOopField("_constants"), Oop.getHeaderSize());
     classLoader          = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize());
     protectionDomain     = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize());
@@ -100,14 +101,14 @@
     headerSize           = alignObjectOffset(Oop.getHeaderSize() + type.getSize());
 
     // read field offset constants
-    ACCESS_FLAGS_OFFSET = db.lookupIntConstant("instanceKlass::access_flags_offset").intValue();
-    NAME_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::name_index_offset").intValue();
-    SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::signature_index_offset").intValue();
-    INITVAL_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::initval_index_offset").intValue();
-    LOW_OFFSET = db.lookupIntConstant("instanceKlass::low_offset").intValue();
-    HIGH_OFFSET = db.lookupIntConstant("instanceKlass::high_offset").intValue();
-    GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::generic_signature_offset").intValue();
-    NEXT_OFFSET = db.lookupIntConstant("instanceKlass::next_offset").intValue();
+    ACCESS_FLAGS_OFFSET            = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue();
+    NAME_INDEX_OFFSET              = db.lookupIntConstant("FieldInfo::name_index_offset").intValue();
+    SIGNATURE_INDEX_OFFSET         = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue();
+    INITVAL_INDEX_OFFSET           = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue();
+    LOW_OFFSET                     = db.lookupIntConstant("FieldInfo::low_offset").intValue();
+    HIGH_OFFSET                    = db.lookupIntConstant("FieldInfo::high_offset").intValue();
+    GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::generic_signature_offset").intValue();
+    FIELD_SLOTS                    = db.lookupIntConstant("FieldInfo::field_slots").intValue();
     // read ClassState constants
     CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
     CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
@@ -121,6 +122,13 @@
 
   InstanceKlass(OopHandle handle, ObjectHeap heap) {
     super(handle, heap);
+    if (getJavaFieldsCount() != getAllFieldsCount()) {
+      // Exercise the injected field logic
+      for (int i = getJavaFieldsCount(); i < getAllFieldsCount(); i++) {
+        getFieldName(i);
+        getFieldSignature(i);
+      }
+    }
   }
 
   private static OopField  arrayKlasses;
@@ -131,6 +139,7 @@
   private static CIntField nofImplementors;
   private static OopField[] implementors;
   private static OopField  fields;
+  private static CIntField javaFieldsCount;
   private static OopField  constants;
   private static OopField  classLoader;
   private static OopField  protectionDomain;
@@ -172,7 +181,7 @@
      private String value;
   }
 
-  private int  getInitStateAsInt() { return (int) initState.getValue(this); }
+  public int  getInitStateAsInt() { return (int) initState.getValue(this); }
   public ClassState getInitState() {
      int state = getInitStateAsInt();
      if (state == CLASS_STATE_UNPARSABLE_BY_GC) {
@@ -247,6 +256,61 @@
 
   public static long getHeaderSize() { return headerSize; }
 
+  public short getFieldAccessFlags(int index) {
+    return getFields().getShortAt(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET);
+  }
+
+  public short getFieldNameIndex(int index) {
+    if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;");
+    return getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
+  }
+
+  public Symbol getFieldName(int index) {
+    int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
+    if (index < getJavaFieldsCount()) {
+      return getConstants().getSymbolAt(nameIndex);
+    } else {
+      return vmSymbols.symbolAt(nameIndex);
+    }
+  }
+
+  public short getFieldSignatureIndex(int index) {
+    if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;");
+    return getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET);
+  }
+
+  public Symbol getFieldSignature(int index) {
+    int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET);
+    if (index < getJavaFieldsCount()) {
+      return getConstants().getSymbolAt(signatureIndex);
+    } else {
+      return vmSymbols.symbolAt(signatureIndex);
+    }
+  }
+
+  public short getFieldGenericSignatureIndex(int index) {
+    return getFields().getShortAt(index * FIELD_SLOTS + GENERIC_SIGNATURE_INDEX_OFFSET);
+  }
+
+  public Symbol getFieldGenericSignature(int index) {
+    short genericSignatureIndex = getFieldGenericSignatureIndex(index);
+    if (genericSignatureIndex != 0)  {
+      return getConstants().getSymbolAt(genericSignatureIndex);
+    }
+    return null;
+  }
+
+  public short getFieldInitialValueIndex(int index) {
+    if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;");
+    return getFields().getShortAt(index * FIELD_SLOTS + INITVAL_INDEX_OFFSET);
+  }
+
+  public int getFieldOffset(int index) {
+    TypeArray fields = getFields();
+    return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET),
+                                         fields.getShortAt(index * FIELD_SLOTS + HIGH_OFFSET));
+  }
+
   // Accessors for declared fields
   public Klass     getArrayKlasses()        { return (Klass)        arrayKlasses.getValue(this); }
   public ObjArray  getMethods()             { return (ObjArray)     methods.getValue(this); }
@@ -257,6 +321,8 @@
   public Klass     getImplementor()         { return (Klass)        implementors[0].getValue(this); }
   public Klass     getImplementor(int i)    { return (Klass)        implementors[i].getValue(this); }
   public TypeArray getFields()              { return (TypeArray)    fields.getValue(this); }
+  public int       getJavaFieldsCount()     { return                (int) javaFieldsCount.getValue(this); }
+  public int       getAllFieldsCount()      { return                (int)getFields().getLength() / FIELD_SLOTS; }
   public ConstantPool getConstants()        { return (ConstantPool) constants.getValue(this); }
   public Oop       getClassLoader()         { return                classLoader.getValue(this); }
   public Oop       getProtectionDomain()    { return                protectionDomain.getValue(this); }
@@ -479,12 +545,10 @@
   }
 
   void iterateStaticFieldsInternal(OopVisitor visitor) {
-    TypeArray fields = getFields();
-    int length = (int) fields.getLength();
-    for (int index = 0; index < length; index += NEXT_OFFSET) {
-      short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
-      short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
-      FieldType   type   = new FieldType(getConstants().getSymbolAt(signatureIndex));
+    int length = getJavaFieldsCount();
+    for (int index = 0; index < length; index++) {
+      short accessFlags    = getFieldAccessFlags(index);
+      FieldType   type   = new FieldType(getFieldSignature(index));
       AccessFlags access = new AccessFlags(accessFlags);
       if (access.isStatic()) {
         visitField(visitor, type, index);
@@ -496,18 +560,24 @@
     return getSuper();
   }
 
+  public static class StaticField {
+    public AccessFlags flags;
+    public Field field;
+
+    StaticField(Field field, AccessFlags flags) {
+      this.field = field;
+      this.flags = flags;
+    }
+  }
+
   public void iterateNonStaticFields(OopVisitor visitor, Oop obj) {
     if (getSuper() != null) {
       ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj);
     }
-    TypeArray fields = getFields();
-
-    int length = (int) fields.getLength();
-    for (int index = 0; index < length; index += NEXT_OFFSET) {
-      short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
-      short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
-
-      FieldType   type   = new FieldType(getConstants().getSymbolAt(signatureIndex));
+    int length = getJavaFieldsCount();
+    for (int index = 0; index < length; index++) {
+      short accessFlags    = getFieldAccessFlags(index);
+      FieldType   type   = new FieldType(getFieldSignature(index));
       AccessFlags access = new AccessFlags(accessFlags);
       if (!access.isStatic()) {
         visitField(visitor, type, index);
@@ -517,14 +587,10 @@
 
   /** Field access by name. */
   public Field findLocalField(Symbol name, Symbol sig) {
-    TypeArray fields = getFields();
-    int n = (int) fields.getLength();
-    ConstantPool cp = getConstants();
-    for (int i = 0; i < n; i += NEXT_OFFSET) {
-      int nameIndex = fields.getShortAt(i + NAME_INDEX_OFFSET);
-      int sigIndex  = fields.getShortAt(i + SIGNATURE_INDEX_OFFSET);
-      Symbol f_name = cp.getSymbolAt(nameIndex);
-      Symbol f_sig  = cp.getSymbolAt(sigIndex);
+    int length = getJavaFieldsCount();
+    for (int i = 0; i < length; i++) {
+      Symbol f_name = getFieldName(i);
+      Symbol f_sig  = getFieldSignature(i);
       if (name.equals(f_name) && sig.equals(f_sig)) {
         return newField(i);
       }
@@ -599,8 +665,8 @@
 
   /** Get field by its index in the fields array. Only designed for
       use in a debugging system. */
-  public Field getFieldByIndex(int fieldArrayIndex) {
-    return newField(fieldArrayIndex);
+  public Field getFieldByIndex(int fieldIndex) {
+    return newField(fieldIndex);
   }
 
 
@@ -611,11 +677,9 @@
     public List getImmediateFields() {
         // A list of Fields for each field declared in this class/interface,
         // not including inherited fields.
-        TypeArray fields = getFields();
-
-        int length = (int) fields.getLength();
-        List immediateFields = new ArrayList(length / NEXT_OFFSET);
-        for (int index = 0; index < length; index += NEXT_OFFSET) {
+        int length = getJavaFieldsCount();
+        List immediateFields = new ArrayList(length);
+        for (int index = 0; index < length; index++) {
             immediateFields.add(getFieldByIndex(index));
         }
 
@@ -802,9 +866,7 @@
 
   // Creates new field from index in fields TypeArray
   private Field newField(int index) {
-    TypeArray fields = getFields();
-    short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
-    FieldType type = new FieldType(getConstants().getSymbolAt(signatureIndex));
+    FieldType type = new FieldType(getFieldSignature(index));
     if (type.isOop()) {
      if (VM.getVM().isCompressedOopsEnabled()) {
         return new NarrowOopField(this, index);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/JumpData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// JumpData
+//
+// A JumpData is used to access profiling information for a direct
+// branch.  It is a counter, used for counting the number of branches,
+// plus a data displacement, used for realigning the data pointer to
+// the corresponding target bci.
+public class JumpData extends ProfileData {
+  static final int   takenOffSet = 0;
+  static final int     displacementOffSet = 1;
+  static final int     jumpCellCount = 2;
+
+  public JumpData(DataLayout layout) {
+    super(layout);
+    //assert(layout.tag() == DataLayout.jumpDataTag ||
+    //       layout.tag() == DataLayout.branchDataTag, "wrong type");
+  }
+
+  static int staticCellCount() {
+    return jumpCellCount;
+  }
+
+  public int cellCount() {
+    return staticCellCount();
+  }
+
+  // Direct accessor
+  int taken() {
+    return uintAt(takenOffSet);
+  }
+
+  int displacement() {
+    return intAt(displacementOffSet);
+  }
+
+  // Code generation support
+  static int takenOffset() {
+    return cellOffset(takenOffSet);
+  }
+
+  static int displacementOffset() {
+    return cellOffset(displacementOffSet);
+  }
+
+  public void printDataOn(PrintStream st) {
+    printShared(st, "JumpData");
+    st.println("taken(" + taken() + ") displacement(" + displacement() + ")");
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java	Wed Oct 26 17:59:13 2011 -0700
@@ -49,6 +49,7 @@
     Type type                  = db.lookupType("methodOopDesc");
     constMethod                = new OopField(type.getOopField("_constMethod"), 0);
     constants                  = new OopField(type.getOopField("_constants"), 0);
+    methodData                 = new OopField(type.getOopField("_method_data"), 0);
     methodSize                 = new CIntField(type.getCIntegerField("_method_size"), 0);
     maxStack                   = new CIntField(type.getCIntegerField("_max_stack"), 0);
     maxLocals                  = new CIntField(type.getCIntegerField("_max_locals"), 0);
@@ -58,9 +59,13 @@
     vtableIndex                = new CIntField(type.getCIntegerField("_vtable_index"), 0);
     if (!VM.getVM().isCore()) {
       invocationCounter        = new CIntField(type.getCIntegerField("_invocation_counter"), 0);
+      backedgeCounter          = new CIntField(type.getCIntegerField("_backedge_counter"), 0);
     }
     bytecodeOffset = type.getSize();
 
+    interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0);
+    interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0);
+
     /*
     interpreterEntry           = type.getAddressField("_interpreter_entry");
     fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point");
@@ -79,6 +84,7 @@
   // Fields
   private static OopField  constMethod;
   private static OopField  constants;
+  private static OopField  methodData;
   private static CIntField methodSize;
   private static CIntField maxStack;
   private static CIntField maxLocals;
@@ -86,10 +92,14 @@
   private static CIntField accessFlags;
   private static CIntField vtableIndex;
   private static CIntField invocationCounter;
+  private static CIntField backedgeCounter;
   private static long      bytecodeOffset;
 
   private static AddressField       code;
 
+  private static CIntField interpreterThrowoutCountField;
+  private static CIntField interpreterInvocationCountField;
+
   // constant method names - <init>, <clinit>
   // Initialized lazily to avoid initialization ordering dependencies between Method and SymbolTable
   private static Symbol objectInitializerName;
@@ -116,6 +126,7 @@
   // Accessors for declared fields
   public ConstMethod  getConstMethod()                { return (ConstMethod)  constMethod.getValue(this);       }
   public ConstantPool getConstants()                  { return (ConstantPool) constants.getValue(this);         }
+  public MethodData   getMethodData()                 { return (MethodData) methodData.getValue(this);          }
   public TypeArray    getExceptionTable()             { return getConstMethod().getExceptionTable();            }
   /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */
   public long         getMethodSize()                 { return                methodSize.getValue(this);        }
@@ -134,6 +145,12 @@
     }
     return invocationCounter.getValue(this);
   }
+  public long         getBackedgeCounter()          {
+    if (Assert.ASSERTS_ENABLED) {
+      Assert.that(!VM.getVM().isCore(), "must not be used in core build");
+    }
+    return backedgeCounter.getValue(this);
+  }
 
   // get associated compiled native method, if available, else return null.
   public NMethod getNativeMethod() {
@@ -333,4 +350,11 @@
     buf.append(")");
     return buf.toString().replace('/', '.');
   }
+  public int interpreterThrowoutCount() {
+    return (int) interpreterThrowoutCountField.getValue(getHandle());
+  }
+
+  public int interpreterInvocationCount() {
+    return (int) interpreterInvocationCountField.getValue(getHandle());
+  }
 }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,92 @@
 // A MethodData provides interpreter profiling information
 
 public class MethodData extends Oop {
+  static int TypeProfileWidth = 2;
+  static int BciProfileWidth = 2;
+  static int CompileThreshold;
+
+  static int Reason_many;                 // indicates presence of several reasons
+  static int Reason_none;                 // indicates absence of a relevant deopt.
+  static int Reason_LIMIT;
+  static int Reason_RECORDED_LIMIT;       // some are not recorded per bc
+
+  private static String[] trapReasonName;
+
+  static String trapReasonName(int reason) {
+    if (reason == Reason_many)  return "many";
+    if (reason < Reason_LIMIT)
+      return trapReasonName[reason];
+    return "reason" + reason;
+  }
+
+
+  static int trapStateReason(int trapState) {
+    // This assert provides the link between the width of DataLayout.trapBits
+    // and the encoding of "recorded" reasons.  It ensures there are enough
+    // bits to store all needed reasons in the per-BCI MDO profile.
+    // assert(dsReasonMask >= reasonRecordedLimit, "enough bits");
+    int recompileBit = (trapState & dsRecompileBit);
+    trapState -= recompileBit;
+    if (trapState == dsReasonMask) {
+      return Reason_many;
+    } else {
+      // assert((int)reasonNone == 0, "state=0 => Reason_none");
+      return trapState;
+    }
+  }
+
+
+  static final int dsReasonMask   = DataLayout.trapMask >> 1;
+  static final int dsRecompileBit = DataLayout.trapMask - dsReasonMask;
+
+  static boolean trapStateIsRecompiled(int trapState) {
+    return (trapState & dsRecompileBit) != 0;
+  }
+
+  static boolean reasonIsRecordedPerBytecode(int reason) {
+    return reason > Reason_none && reason < Reason_RECORDED_LIMIT;
+  }
+  static int trapStateAddReason(int trapState, int reason) {
+    // assert(reasonIsRecordedPerBytecode((DeoptReason)reason) || reason == reasonMany, "valid reason");
+    int recompileBit = (trapState & dsRecompileBit);
+    trapState -= recompileBit;
+    if (trapState == dsReasonMask) {
+      return trapState + recompileBit;     // already at state lattice bottom
+    } else if (trapState == reason) {
+      return trapState + recompileBit;     // the condition is already true
+    } else if (trapState == 0) {
+      return reason + recompileBit;          // no condition has yet been true
+    } else {
+      return dsReasonMask + recompileBit;  // fall to state lattice bottom
+    }
+  }
+  static int trapStateSetRecompiled(int trapState, boolean z) {
+    if (z)  return trapState |  dsRecompileBit;
+    else    return trapState & ~dsRecompileBit;
+  }
+
+  static String formatTrapState(int trapState) {
+    int reason      = trapStateReason(trapState);
+    boolean     recompFlag = trapStateIsRecompiled(trapState);
+    // Re-encode the state from its decoded components.
+    int decodedState = 0;
+    if (reasonIsRecordedPerBytecode(reason) || reason == Reason_many)
+      decodedState = trapStateAddReason(decodedState, reason);
+    if (recompFlag)
+      decodedState = trapStateSetRecompiled(decodedState, recompFlag);
+    // If the state re-encodes properly, format it symbolically.
+    // Because this routine is used for debugging and diagnostics,
+    // be robust even if the state is a strange value.
+    if (decodedState != trapState) {
+      // Random buggy state that doesn't decode??
+      return "#" + trapState;
+    } else {
+      return trapReasonName(reason) + (recompFlag ? " recompiled" : "");
+    }
+  }
+
+
+
   static {
     VM.registerVMInitializedObserver(new Observer() {
         public void update(Observable o, Object data) {
@@ -48,7 +134,58 @@
 
     size           = new CIntField(type.getCIntegerField("_size"), 0);
     method         = new OopField(type.getOopField("_method"), 0);
-    // FIXME: add more fields and accessors
+
+    VM.Flag[] flags = VM.getVM().getCommandLineFlags();
+    for (int f = 0; f < flags.length; f++) {
+      VM.Flag flag = flags[f];
+      if (flag.getName().equals("TypeProfileWidth")) {
+        TypeProfileWidth = (int)flag.getIntx();
+      } else if (flag.getName().equals("BciProfileWidth")) {
+        BciProfileWidth = (int)flag.getIntx();
+      } else if (flag.getName().equals("CompileThreshold")) {
+        CompileThreshold = (int)flag.getIntx();
+      }
+    }
+
+    cellSize = (int)VM.getVM().getAddressSize();
+
+    dataSize     = new CIntField(type.getCIntegerField("_data_size"), 0);
+    data         = type.getAddressField("_data[0]");
+
+    sizeofMethodDataOopDesc = (int)type.getSize();;
+
+    Reason_many            = db.lookupIntConstant("Deoptimization::Reason_many").intValue();
+    Reason_none            = db.lookupIntConstant("Deoptimization::Reason_none").intValue();
+    Reason_LIMIT           = db.lookupIntConstant("Deoptimization::Reason_LIMIT").intValue();
+    Reason_RECORDED_LIMIT  = db.lookupIntConstant("Deoptimization::Reason_RECORDED_LIMIT").intValue();
+
+    trapReasonName = new String[Reason_LIMIT];
+
+    // Find Deopt reasons
+    Iterator i = db.getIntConstants();
+    String prefix = "Deoptimization::Reason_";
+    while (i.hasNext()) {
+      String name = (String)i.next();
+      if (name.startsWith(prefix)) {
+        // Strip prefix
+        if (!name.endsWith("Reason_many") &&
+            !name.endsWith("Reason_LIMIT") &&
+            !name.endsWith("Reason_RECORDED_LIMIT")) {
+          String trimmed = name.substring(prefix.length());
+          int value = db.lookupIntConstant(name).intValue();
+          if (trapReasonName[value] != null) {
+            throw new InternalError("duplicate reasons: " + trapReasonName[value] + " " + trimmed);
+          }
+          trapReasonName[value] = trimmed;
+        }
+      }
+    }
+    for (int index = 0; index < trapReasonName.length; index++) {
+      if (trapReasonName[index] == null) {
+        throw new InternalError("missing reason for " + index);
+      }
+      System.out.println(trapReasonName[index]);
+    }
   }
 
   MethodData(OopHandle handle, ObjectHeap heap) {
@@ -60,6 +197,11 @@
   private static long baseOffset;
   private static CIntField size;
   private static OopField  method;
+  private static CIntField dataSize;
+  private static AddressField data;
+
+  public static int sizeofMethodDataOopDesc;
+  public static int cellSize;
 
   public long getObjectSize() {
     return alignObjectSize(size.getValue(this));
@@ -81,4 +223,119 @@
       visitor.doCInt(size, true);
     }
   }
+
+  int dataSize() {
+    if (dataSize == null) {
+      return 0;
+    } else {
+      return (int)dataSize.getValue(this);
+    }
+  }
+
+  boolean outOfBounds(int dataIndex) {
+    return dataIndex >= dataSize();
+  }
+
+  ProfileData dataAt(int dataIndex) {
+    if (outOfBounds(dataIndex)) {
+      return null;
+    }
+    DataLayout dataLayout = new DataLayout(this, dataIndex + (int)data.getOffset());
+
+    switch (dataLayout.tag()) {
+    case DataLayout.noTag:
+    default:
+      throw new InternalError(dataIndex + " " + dataSize() + " " + dataLayout.tag());
+    case DataLayout.bitDataTag:
+      return new BitData(dataLayout);
+    case DataLayout.counterDataTag:
+      return new CounterData(dataLayout);
+    case DataLayout.jumpDataTag:
+      return new JumpData(dataLayout);
+    case DataLayout.receiverTypeDataTag:
+      return new ReceiverTypeData(dataLayout);
+    case DataLayout.virtualCallDataTag:
+      return new VirtualCallData(dataLayout);
+    case DataLayout.retDataTag:
+      return new RetData(dataLayout);
+    case DataLayout.branchDataTag:
+      return new BranchData(dataLayout);
+    case DataLayout.multiBranchDataTag:
+      return new MultiBranchData(dataLayout);
+    }
+  }
+
+  int dpToDi(int dp) {
+    // this in an offset from the base of the MDO, so convert to offset into _data
+    return dp - (int)data.getOffset();
+  }
+
+  int firstDi() { return 0; }
+  public ProfileData firstData() { return dataAt(firstDi()); }
+  public ProfileData nextData(ProfileData current) {
+    int currentIndex = dpToDi(current.dp());
+    int nextIndex = currentIndex + current.sizeInBytes();
+    return dataAt(nextIndex);
+  }
+  boolean isValid(ProfileData current) { return current != null; }
+
+  public void printDataOn(PrintStream st) {
+    ProfileData data = firstData();
+    for ( ; isValid(data); data = nextData(data)) {
+      st.print(dpToDi(data.dp()));
+      st.print(" ");
+      // st->fillTo(6);
+      data.printDataOn(st);
+    }
+  }
+
+  private byte[] fetchDataAt(Address base, long offset, long size) {
+    byte[] result = new byte[(int)size];
+    for (int i = 0; i < size; i++) {
+      result[i] = base.getJByteAt(offset + i);
+    }
+    return result;
+  }
+
+  public byte[] orig() {
+    // fetch the orig methodDataOopDesc data between header and dataSize
+    return fetchDataAt(this.getHandle(), 0, sizeofMethodDataOopDesc);
+  }
+
+  public long[] data() {
+    // Read the data as an array of intptr_t elements
+    OopHandle base = getHandle();
+    long offset = data.getOffset();
+    int elements = dataSize() / cellSize;
+    long[] result = new long[elements];
+    for (int i = 0; i < elements; i++) {
+      Address value = base.getAddressAt(offset + i * MethodData.cellSize);
+      if (value != null) {
+        result[i] = value.minus(null);
+      }
+    }
+    return result;
+  }
+
+  // Get a measure of how much mileage the method has on it.
+  int mileageOf(Method method) {
+    long mileage = 0;
+    int iic = method.interpreterInvocationCount();
+    if (mileage < iic)  mileage = iic;
+
+    long ic = method.getInvocationCounter();
+    long bc = method.getBackedgeCounter();
+
+    long icval = ic >> 3;
+    if ((ic & 4) != 0) icval += CompileThreshold;
+    if (mileage < icval)  mileage = icval;
+    long bcval = bc >> 3;
+    if ((bc & 4) != 0) bcval += CompileThreshold;
+    if (mileage < bcval)  mileage = bcval;
+    return (int)mileage;
+  }
+
+  public int currentMileage() {
+    return 20000;
+  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MultiBranchData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// MultiBranchData
+//
+// A MultiBranchData is used to access profiling information for
+// a multi-way branch (*switch bytecodes).  It consists of a series
+// of (count, displacement) pairs, which count the number of times each
+// case was taken and specify the data displacment for each branch target.
+public class MultiBranchData extends ArrayData {
+  static final int   defaultCountOffSet = 0;
+  static final int     defaultDisaplacementOffSet = 1;
+  static final int     caseArrayStart = 2;
+  static final int   relativeCountOffSet = 0;
+  static final int     relativeDisplacementOffSet = 1;
+  static final int     perCaseCellCount = 2;
+
+  public MultiBranchData(DataLayout layout) {
+    super(layout);
+    //assert(layout.tag() == DataLayout.multiBranchDataTag, "wrong type");
+  }
+
+  // static int computeCellCount(BytecodeStream stream);
+
+  int numberOfCases() {
+    int alen = arrayLen() - 2; // get rid of default case here.
+    //assert(alen % perCaseCellCount == 0, "must be even");
+    return (alen / perCaseCellCount);
+  }
+
+  int defaultCount() {
+    return arrayUintAt(defaultCountOffSet);
+  }
+  int defaultDisplacement() {
+    return arrayIntAt(defaultDisaplacementOffSet);
+  }
+
+  int countAt(int index) {
+    return arrayUintAt(caseArrayStart +
+                         index * perCaseCellCount +
+                         relativeCountOffSet);
+  }
+  int displacementAt(int index) {
+    return arrayIntAt(caseArrayStart +
+                        index * perCaseCellCount +
+                        relativeDisplacementOffSet);
+  }
+
+  // Code generation support
+  static int defaultCountOffset() {
+    return arrayElementOffset(defaultCountOffSet);
+  }
+  static int defaultDisplacementOffset() {
+    return arrayElementOffset(defaultDisaplacementOffSet);
+  }
+  static int caseCountOffset(int index) {
+    return caseArrayOffset() +
+      (perCaseSize() * index) +
+      relativeCountOffset();
+  }
+  static int caseArrayOffset() {
+    return arrayElementOffset(caseArrayStart);
+  }
+  static int perCaseSize() {
+    return (perCaseCellCount) * MethodData.cellSize;
+  }
+  static int relativeCountOffset() {
+    return (relativeCountOffSet) * MethodData.cellSize;
+  }
+  static int relativeDisplacementOffset() {
+    return (relativeDisplacementOffSet) * MethodData.cellSize;
+  }
+
+  public void printDataOn(PrintStream st) {
+    printShared(st, "MultiBranchData");
+    st.println("default_count(" + defaultCount() + ") displacement(" + defaultDisplacement() + ")");
+    int cases = numberOfCases();
+    for (int i = 0; i < cases; i++) {
+      tab(st);
+      st.println("count(" + countAt(i) + ") displacement(" + displacementAt(i) + ")");
+    }
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Wed Oct 26 17:59:13 2011 -0700
@@ -33,6 +33,7 @@
 
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.gc_interface.*;
+import sun.jvm.hotspot.gc_implementation.g1.*;
 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
 import sun.jvm.hotspot.memory.*;
 import sun.jvm.hotspot.runtime.*;
@@ -514,9 +515,16 @@
 
   private void addPermGenLiveRegions(List output, CollectedHeap heap) {
     LiveRegionsCollector lrc = new LiveRegionsCollector(output);
-    if (heap instanceof GenCollectedHeap) {
-       GenCollectedHeap genHeap = (GenCollectedHeap) heap;
-       Generation gen = genHeap.permGen();
+    if (heap instanceof SharedHeap) {
+       if (Assert.ASSERTS_ENABLED) {
+          Assert.that(heap instanceof GenCollectedHeap ||
+                      heap instanceof G1CollectedHeap,
+                      "Expecting GenCollectedHeap or G1CollectedHeap, " +
+                      "but got " + heap.getClass().getName());
+       }
+       // Handles both GenCollectedHeap and G1CollectedHeap
+       SharedHeap sharedHeap = (SharedHeap) heap;
+       Generation gen = sharedHeap.permGen();
        gen.spaceIterate(lrc, true);
     } else if (heap instanceof ParallelScavengeHeap) {
        ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
@@ -524,8 +532,9 @@
        addLiveRegions(permGen.objectSpace().getLiveRegions(), output);
     } else {
        if (Assert.ASSERTS_ENABLED) {
-          Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " +
-                             heap.getClass().getName());
+          Assert.that(false,
+                      "Expecting SharedHeap or ParallelScavengeHeap, " +
+                      "but got " + heap.getClass().getName());
        }
     }
   }
@@ -588,10 +597,14 @@
        addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions);
        PSOldGen oldGen = psh.oldGen();
        addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions);
+    } else if (heap instanceof G1CollectedHeap) {
+        G1CollectedHeap g1h = (G1CollectedHeap) heap;
+        g1h.heapRegionIterate(lrc);
     } else {
        if (Assert.ASSERTS_ENABLED) {
-          Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " +
-                              heap.getClass().getName());
+          Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +
+                      "or ParallelScavengeHeap, but got " +
+                      heap.getClass().getName());
        }
     }
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java	Wed Oct 26 17:59:13 2011 -0700
@@ -112,6 +112,32 @@
     return buf.toString();
   }
 
+  public static String escapeString(String s) {
+    StringBuilder sb = null;
+    for (int index = 0; index < s.length(); index++) {
+      char value = s.charAt(index);
+      if (value >= 32 && value < 127 || value == '\'' || value == '\\') {
+        if (sb != null) {
+          sb.append(value);
+        }
+      } else {
+        if (sb == null) {
+          sb = new StringBuilder(s.length() * 2);
+          sb.append(s, 0, index);
+        }
+        sb.append("\\u");
+        if (value < 0x10) sb.append("000");
+        else if (value < 0x100) sb.append("00");
+        else if (value < 0x1000) sb.append("0");
+        sb.append(Integer.toHexString(value));
+      }
+    }
+    if (sb != null) {
+      return sb.toString();
+    }
+    return s;
+  }
+
   public static String stringOopToString(Oop stringOop) {
     if (offsetField == null) {
       InstanceKlass k = (InstanceKlass) stringOop.getKlass();
@@ -129,6 +155,10 @@
                              countField.getValue(stringOop));
   }
 
+  public static String stringOopToEscapedString(Oop stringOop) {
+    return escapeString(stringOopToString(stringOop));
+  }
+
   private static void initThreadGroupFields() {
     if (threadGroupParentField == null) {
       SystemDictionary sysDict = VM.getVM().getSystemDictionary();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ProfileData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+public abstract class ProfileData {
+  // This is a pointer to a section of profiling data.
+  private DataLayout _data;
+
+  public DataLayout data() { return _data; }
+
+  // How many cells are in this?
+  public abstract int cellCount();
+
+
+  // Return the size of this data.
+  public int sizeInBytes() {
+    return DataLayout.computeSizeInBytes(cellCount());
+  }
+
+  public int dp() {
+    return data().dp();
+  }
+
+  // Low-level accessors for underlying data
+  int intptrAt(int index) {
+    //assert(0 <= index && index < cellCount(), "oob");
+    return data().cellAt(index);
+  }
+  int intAt(int index) {
+    return (int)intptrAt(index);
+  }
+  int uintAt(int index) {
+    return (int)intptrAt(index);
+  }
+  Oop oopAt(int index) {
+    return data().oopAt(index);
+  }
+
+  public Address addressAt(int index) {
+    return data().addressAt(index);
+  }
+
+  boolean flagAt(int flagNumber) {
+    return data().flagAt(flagNumber);
+  }
+
+  // two convenient imports for use by subclasses:
+  public static int cellOffset(int index) {
+    return DataLayout.cellOffset(index);
+  }
+
+  public ProfileData(DataLayout data) {
+    _data = data;
+  }
+
+  // Constructor for invalid ProfileData.
+  ProfileData() {
+    _data = null;
+  }
+
+  int bci() {
+    return data().bci();
+  }
+
+  int trapState() {
+    return data().trapState();
+  }
+  public abstract void printDataOn(PrintStream st);
+
+  void tab(PrintStream st) {
+    st.print("\t");
+  }
+
+  void printShared(PrintStream st, String name) {
+    st.print("bci: " + bci());
+    // st.fillTo(tabWidthOne);
+    st.print(" " +  name + " ");
+    tab(st);
+    int trap = trapState();
+    if (trap != 0) {
+      st.print("trap(" + MethodData.formatTrapState(trap) + ") ");
+    }
+    int flags = data().flags();
+    if (flags != 0)
+      st.print("flags(" + flags + ") ");
+  }
+
+  public String toString() {
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    PrintStream ps = new PrintStream(baos);
+    try {
+      printDataOn(ps);
+    } finally {
+      ps.close();
+    }
+    return baos.toString();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// ReceiverTypeData
+//
+// A ReceiverTypeData is used to access profiling information about a
+// dynamic type check.  It consists of a counter which counts the total times
+// that the check is reached, and a series of (Klass, count) pairs
+// which are used to store a type profile for the receiver of the check.
+public class ReceiverTypeData extends CounterData {
+  static final int   receiver0Offset = counterCellCount;
+  static final int     count0Offset = receiver0Offset + 1;
+  static final int     receiverTypeRowCellCount = (count0Offset + 1) - receiver0Offset;
+
+  public ReceiverTypeData(DataLayout layout) {
+    super(layout);
+    //assert(layout.tag() == DataLayout.receiverTypeDataTag ||
+    //       layout.tag() == DataLayout.virtualCallDataTag, "wrong type");
+  }
+
+  boolean isReceivertypedata() { return true; }
+
+  static int staticCellCount() {
+    return counterCellCount + MethodData.TypeProfileWidth * receiverTypeRowCellCount;
+  }
+
+  public int cellCount() {
+    return staticCellCount();
+  }
+
+  // Direct accessors
+  public static int rowLimit() {
+    return MethodData.TypeProfileWidth;
+  }
+  public static int receiverCellIndex(int row) {
+    return receiver0Offset + row * receiverTypeRowCellCount;
+  }
+  public static int receiverCountCellIndex(int row) {
+    return count0Offset + row * receiverTypeRowCellCount;
+  }
+
+  // Get the receiver at row.  The 'unchecked' version is needed by parallel old
+  // gc; it does not assert the receiver is a klass.  During compaction of the
+  // perm gen, the klass may already have moved, so the isKlass() predicate
+  // would fail.  The 'normal' version should be used whenever possible.
+  Klass receiverUnchecked(int row) {
+    //assert(row < rowLimit(), "oob");
+    Oop recv = oopAt(receiverCellIndex(row));
+    return (Klass)recv;
+  }
+
+  public Klass receiver(int row) {
+    Klass recv = receiverUnchecked(row);
+    //assert(recv == NULL || ((oop)recv).isKlass(), "wrong type");
+    return recv;
+  }
+
+  public int receiverCount(int row) {
+    //assert(row < rowLimit(), "oob");
+    return uintAt(receiverCountCellIndex(row));
+  }
+
+  // Code generation support
+  static int receiverOffset(int row) {
+    return cellOffset(receiverCellIndex(row));
+  }
+  static int receiverCountOffset(int row) {
+    return cellOffset(receiverCountCellIndex(row));
+  }
+  static int receiverTypeDataSize() {
+    return cellOffset(staticCellCount());
+  }
+
+  void printReceiverDataOn(PrintStream st) {
+    int row;
+    int entries = 0;
+    for (row = 0; row < rowLimit(); row++) {
+      if (receiver(row) != null)  entries++;
+    }
+    st.println("count(" + count() + ") entries(" + entries + ")");
+    for (row = 0; row < rowLimit(); row++) {
+      if (receiver(row) != null) {
+        tab(st);
+        receiver(row).printValueOn(st);
+        st.println("(" + receiverCount(row) + ")");
+      }
+    }
+  }
+  public void printDataOn(PrintStream st) {
+    printShared(st, "ReceiverTypeData");
+    printReceiverDataOn(st);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/RetData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// RetData
+//
+// A RetData is used to access profiling information for a ret bytecode.
+// It is composed of a count of the number of times that the ret has
+// been executed, followed by a series of triples of the form
+// (bci, count, di) which count the number of times that some bci was the
+// target of the ret and cache a corresponding data displacement.
+public class RetData extends CounterData {
+
+  static final int   bci0Offset = counterCellCount;
+  static final int     count0Offset = bci0Offset + 1;
+  static final int     displacement0Offset = count0Offset + 1;
+  static final int     retRowCellCount = (displacement0Offset + 1) - bci0Offset;
+
+  public RetData(DataLayout layout) {
+    super(layout);
+    //assert(layout.tag() == DataLayout.retDataTag, "wrong type");
+  }
+
+  static final int noBci = -1; // value of bci when bci1/2 are not in use.
+
+  static int staticCellCount() {
+    return counterCellCount + MethodData.BciProfileWidth * retRowCellCount;
+  }
+
+  public int cellCount() {
+    return staticCellCount();
+  }
+
+  static int rowLimit() {
+    return MethodData.BciProfileWidth;
+  }
+  static int bciCellIndex(int row) {
+    return bci0Offset + row * retRowCellCount;
+  }
+  static int bciCountCellIndex(int row) {
+    return count0Offset + row * retRowCellCount;
+  }
+  static int bciDisplacementCellIndex(int row) {
+    return displacement0Offset + row * retRowCellCount;
+  }
+
+  // Direct accessors
+  int bci(int row) {
+    return intAt(bciCellIndex(row));
+  }
+  int bciCount(int row) {
+    return uintAt(bciCountCellIndex(row));
+  }
+  int bciDisplacement(int row) {
+    return intAt(bciDisplacementCellIndex(row));
+  }
+
+  // Code generation support
+  static int bciOffset(int row) {
+    return cellOffset(bciCellIndex(row));
+  }
+  static int bciCountOffset(int row) {
+    return cellOffset(bciCountCellIndex(row));
+  }
+  static int bciDisplacementOffset(int row) {
+    return cellOffset(bciDisplacementCellIndex(row));
+  }
+
+  public void printDataOn(PrintStream st) {
+    printShared(st, "RetData");
+    int row;
+    int entries = 0;
+    for (row = 0; row < rowLimit(); row++) {
+      if (bci(row) != noBci)  entries++;
+    }
+    st.println("count(" + count() + ") entries(" + entries + ")");
+    for (row = 0; row < rowLimit(); row++) {
+      if (bci(row) != noBci) {
+        tab(st);
+        st.println(" bci(" + bci(row) + ": count(" + bciCount(row) + ") displacement(" + bciDisplacement(row) + "))");
+      }
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/VirtualCallData.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+package sun.jvm.hotspot.oops;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+// VirtualCallData
+//
+// A VirtualCallData is used to access profiling information about a
+// call.  For now, it has nothing more than a ReceiverTypeData.
+public class VirtualCallData extends ReceiverTypeData {
+  public VirtualCallData(DataLayout layout) {
+    super(layout);
+    //assert(layout.tag() == DataLayout.virtualCallDataTag, "wrong type");
+  }
+
+  static int staticCellCount() {
+    // At this point we could add more profile state, e.g., for arguments.
+    // But for now it's the same size as the base record type.
+    return ReceiverTypeData.staticCellCount();
+  }
+
+  public int cellCount() {
+    return staticCellCount();
+  }
+
+  // Direct accessors
+  static int virtualCallDataSize() {
+    return cellOffset(staticCellCount());
+  }
+
+  public void printDataOn(PrintStream st) {
+    printShared(st, "VirtualCallData");
+    printReceiverDataOn(st);
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/java_lang_Class.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/java_lang_Class.java	Wed Oct 26 17:59:13 2011 -0700
@@ -55,13 +55,13 @@
     // klass and oop_size are HotSpot magic fields and hence we can't
     // find them from InstanceKlass for java.lang.Class.
     Type jlc = db.lookupType("java_lang_Class");
-    int klassOffset = (int) jlc.getCIntegerField("klass_offset").getValue();
+    int klassOffset = (int) jlc.getCIntegerField("_klass_offset").getValue();
     if (VM.getVM().isCompressedOopsEnabled()) {
       klassField = new NarrowOopField(new NamedFieldIdentifier("klass"), klassOffset, true);
     } else {
       klassField = new OopField(new NamedFieldIdentifier("klass"), klassOffset, true);
     }
-    int oopSizeOffset = (int) jlc.getCIntegerField("oop_size_offset").getValue();
+    int oopSizeOffset = (int) jlc.getCIntegerField("_oop_size_offset").getValue();
     oopSizeField = new IntField(new NamedFieldIdentifier("oop_size"), oopSizeOffset, true);
   }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Block.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class Block extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("Block");
+    nodesField = type.getAddressField("_nodes");
+    succsField = type.getAddressField("_succs");
+    numSuccsField = new CIntField(type.getCIntegerField("_num_succs"), 0);
+    preOrderField = new CIntField(type.getCIntegerField("_pre_order"), 0);
+    domDepthField = new CIntField(type.getCIntegerField("_dom_depth"), 0);
+    idomField = type.getAddressField("_idom");
+    freqField = type.getJFloatField("_freq");
+  }
+
+  private static AddressField nodesField;
+  private static AddressField succsField;
+  private static CIntField numSuccsField;
+  private static CIntField preOrderField;
+  private static CIntField domDepthField;
+  private static AddressField idomField;
+  private static JFloatField freqField;
+
+  public Block(Address addr) {
+    super(addr);
+  }
+
+  public int preOrder() {
+    return (int)preOrderField.getValue(getAddress());
+  }
+
+  public float freq() {
+    return (float)freqField.getValue(getAddress());
+  }
+
+  public Node_List nodes() {
+    return new Node_List(getAddress().addOffsetTo(nodesField.getOffset()));
+  }
+
+  public void dump(PrintStream out) {
+    out.print("B" + preOrder());
+    out.print(" Freq: " + freq());
+    out.println();
+    Node_List nl = nodes();
+    int cnt = nl.size();
+    for( int i=0; i<cnt; i++ )
+      nl.at(i).dump(out);
+    out.print("\n");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Block_Array.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class Block_Array extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("Block_Array");
+    sizeField = new CIntField(type.getCIntegerField("_size"), 0);
+    blocksField = type.getAddressField("_blocks");
+    arenaField = type.getAddressField("_arena");
+  }
+
+  private static CIntField sizeField;
+  private static AddressField blocksField;
+  private static AddressField arenaField;
+
+  public Block_Array(Address addr) {
+    super(addr);
+  }
+
+  public int Max() {
+    return (int) sizeField.getValue(getAddress());
+  }
+
+  public Block at(int i) {
+    return new Block(blocksField.getValue(getAddress()).getAddressAt(i * (int)VM.getVM().getAddressSize()));
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Block_List.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class Block_List extends Block_Array {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("Block_List");
+    cntField = new CIntField(type.getCIntegerField("_cnt"), 0);
+  }
+
+  private static CIntField cntField;
+
+  public Block_List(Address addr) {
+    super(addr);
+  }
+
+  public int size() {
+    return (int) cntField.getValue(getAddress());
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CallDynamicJavaNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class CallDynamicJavaNode extends CallJavaNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("CallDynamicJavaNode");
+  }
+
+
+  public CallDynamicJavaNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CallJavaNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.*;
+import sun.jvm.hotspot.code.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.ci.*;
+import sun.jvm.hotspot.types.*;
+
+public class CallJavaNode extends CallNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("CallJavaNode");
+    methodField = type.getAddressField("_method");
+  }
+
+  private static AddressField methodField;
+
+  public CallJavaNode(Address addr) {
+    super(addr);
+  }
+
+  public ciMethod method() {
+    return (ciMethod) ciObjectFactory.get(methodField.getValue(getAddress()));
+  }
+
+  public void dumpSpec(PrintStream out) {
+    if (method() !=  null) {
+      out.print(" " + method().method().externalNameAndSignature());
+    }
+    super.dumpSpec(out);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CallNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class CallNode extends SafePointNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("CallNode");
+    entryPointField = type.getAddressField("_entry_point");
+  }
+
+  private static AddressField entryPointField;
+
+  public Address entryPoint() {
+    return entryPointField.getValue(getAddress());
+  }
+
+  public CallNode(Address addr) {
+    super(addr);
+  }
+
+  public void dumpSpec(PrintStream out) {
+    out.print(" ");
+    // tf()->dumpOn(st);
+    // if (_cnt != countUnknown)  st->print(" C=%f",_cnt);
+    JVMState jvms = jvms();
+    if (jvms != null)  jvms.dumpSpec(out);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CallRuntimeNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.utilities.CStringUtilities;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class CallRuntimeNode extends CallNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("CallRuntimeNode");
+    nameField    = type.getAddressField("_name");
+  }
+
+  static private AddressField nameField;
+
+  public String name() {
+    return CStringUtilities.getString(nameField.getValue(getAddress()));
+  }
+
+  public CallRuntimeNode(Address addr) {
+    super(addr);
+  }
+
+  public void dumpSpec(PrintStream out) {
+    out.print(" #");
+    out.print(name());
+    super.dumpSpec(out);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CallStaticJavaNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.utilities.CStringUtilities;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class CallStaticJavaNode extends CallJavaNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("CallStaticJavaNode");
+    nameField    = type.getAddressField("_name");
+  }
+
+  static private AddressField nameField;
+
+  public String name() {
+    return CStringUtilities.getString(nameField.getValue(getAddress()));
+  }
+
+  public CallStaticJavaNode(Address addr) {
+    super(addr);
+  }
+
+  public void dumpSpec(PrintStream out) {
+    out.print(" Static ");
+    String name = name();
+    if (name != null) {
+      out.print(name);
+      // int trapReq = uncommonTrapRequest();
+      // if (trapReq != 0) {
+      //   char buf[100];
+      //   st->print("(%s)",
+      //             Deoptimization::formatTrapRequest(buf, sizeof(buf),
+      //                                                 trapReq));
+      // }
+      out.print(" ");
+    }
+    super.dumpSpec(out);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Compile.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.ci.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class Compile extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("Compile");
+    rootField = type.getAddressField("_root");
+    uniqueField = new CIntField(type.getCIntegerField("_unique"), 0);
+    entryBciField = new CIntField(type.getCIntegerField("_entry_bci"), 0);
+    topField = type.getAddressField("_top");
+    cfgField = type.getAddressField("_cfg");
+    regallocField = type.getAddressField("_regalloc");
+    methodField = type.getAddressField("_method");
+    iltField = type.getAddressField("_ilt");
+  }
+
+  private static AddressField rootField;
+  private static CIntField uniqueField;
+  private static CIntField entryBciField;
+  private static AddressField topField;
+  private static AddressField cfgField;
+  private static AddressField regallocField;
+  private static AddressField methodField;
+  private static AddressField iltField;
+
+  public Compile(Address addr) {
+    super(addr);
+  }
+
+  public Node root() {
+    return new RootNode(rootField.getValue(this.getAddress()));
+  }
+
+  public int entryBci() {
+    return (int)entryBciField.getValue(getAddress());
+  }
+
+  public ciMethod method() {
+    return (ciMethod) ciObjectFactory.get(methodField.getValue(getAddress()));
+  }
+
+  public PhaseCFG cfg() {
+    Address a = cfgField.getValue(this.getAddress());
+    if (a != null) {
+      return new PhaseCFG(a);
+    }
+    return null;
+  }
+
+  public InlineTree ilt() {
+    Address a = iltField.getValue(this.getAddress());
+    if (a != null) {
+      return new InlineTree(a);
+    }
+    return null;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/HaltNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class HaltNode extends Node {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("HaltNode");
+  }
+
+
+  public HaltNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/InlineTree.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.ci.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.utilities.GrowableArray;
+import sun.jvm.hotspot.types.*;
+
+public class InlineTree extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("InlineTree");
+    callerJvmsField = type.getAddressField("_caller_jvms");
+    methodField = type.getAddressField("_method");
+    callerTreeField = type.getAddressField("_caller_tree");
+    subtreesField = type.getAddressField("_subtrees");
+  }
+
+  private static AddressField callerJvmsField;
+  private static AddressField methodField;
+  private static AddressField callerTreeField;
+  private static AddressField subtreesField;
+
+  private static StaticBaseConstructor inlineTreeConstructor = new StaticBaseConstructor<InlineTree>(InlineTree.class);
+
+  public InlineTree(Address addr) {
+    super(addr);
+  }
+
+  public InlineTree callerTree() {
+    Address addr = callerTreeField.getValue(getAddress());
+    if (addr == null) return null;
+
+    return new InlineTree(addr);
+  }
+
+  public ciMethod method() {
+    return (ciMethod) ciObjectFactory.get(methodField.getValue(getAddress()));
+  }
+
+  public JVMState callerJvms() {
+    return JVMState.create(callerJvmsField.getValue(getAddress()));
+  }
+
+  public int callerBci() {
+    JVMState jvms = callerJvms();
+    return (jvms != null) ? jvms.bci() : -1;
+  }
+
+  public GrowableArray<InlineTree> subtrees() {
+    Address addr = getAddress().addOffsetTo(subtreesField.getOffset());
+
+    return GrowableArray.create(addr, inlineTreeConstructor);
+  }
+
+  public void printImpl(PrintStream st, int indent) {
+    for (int i = 0; i < indent; i++) st.print(" ");
+    st.printf(" @ %d ", callerBci());
+    method().printShortName(st);
+    st.println();
+
+    GrowableArray<InlineTree> subt = subtrees();
+    for (int i = 0 ; i < subt.length(); i++) {
+      subt.at(i).printImpl(st, indent + 2);
+    }
+  }
+  public void print(PrintStream st) {
+    printImpl(st, 2);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/JVMState.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.ci.*;
+import sun.jvm.hotspot.types.*;
+
+public class JVMState extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("JVMState");
+    mapField = type.getAddressField("_map");
+    methodField = type.getAddressField("_method");
+    bciField = new CIntField(type.getCIntegerField("_bci"), 0);
+    spField = new CIntField(type.getCIntegerField("_sp"), 0);
+    endoffField = new CIntField(type.getCIntegerField("_endoff"), 0);
+    try {
+        scloffField = new CIntField(type.getCIntegerField("_scloff"), 0);
+    } catch (Exception e) {
+    }
+    monoffField = new CIntField(type.getCIntegerField("_monoff"), 0);
+    stkoffField = new CIntField(type.getCIntegerField("_stkoff"), 0);
+    locoffField = new CIntField(type.getCIntegerField("_locoff"), 0);
+    depthField = new CIntField(type.getCIntegerField("_depth"), 0);
+    callerField = type.getAddressField("_caller");
+  }
+
+  private static AddressField mapField;
+  private static AddressField methodField;
+  private static CIntField bciField;
+  private static CIntField spField;
+  private static CIntField endoffField;
+  private static CIntField scloffField;
+  private static CIntField monoffField;
+  private static CIntField stkoffField;
+  private static CIntField locoffField;
+  private static CIntField depthField;
+  private static AddressField callerField;
+
+  public static JVMState create(Address addr) {
+    if (addr == null) return null;
+    return new JVMState(addr);
+  }
+
+  public JVMState(Address addr) {
+    super(addr);
+  }
+
+  public ciMethod method() {
+    return (ciMethod) ciObjectFactory.get(methodField.getValue(getAddress()));
+  }
+
+  public int bci() {
+    return (int)bciField.getValue(getAddress());
+  }
+
+  public JVMState caller() {
+    return create(callerField.getValue(getAddress()));
+  }
+
+  public void dumpSpec(PrintStream out) {
+    ciMethod m = method();
+    if (m != null) {
+      Method meth = m.method();
+      out.print(" " + meth.getMethodHolder().getName().asString().replace('/', '.') + "::" +
+                meth.getName().asString() + " @ bci:" + bci());
+    } else {
+      out.print(" runtime stub");
+    }
+    if (caller() != null)  caller().dumpSpec(out);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/LoopNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class LoopNode extends RegionNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("LoopNode");
+  }
+
+
+  public LoopNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MachCallJavaNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.ci.ciMethod;
+import sun.jvm.hotspot.ci.ciObjectFactory;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class MachCallJavaNode extends MachCallNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MachCallJavaNode");
+    methodField = type.getAddressField("_method");
+    bciField = new CIntField(type.getCIntegerField("_bci"), 0);
+  }
+
+  private static AddressField methodField;
+  private static CIntField bciField;
+
+  public ciMethod method() {
+    return (ciMethod) ciObjectFactory.get(methodField.getValue(getAddress()));
+  }
+
+  public MachCallJavaNode(Address addr) {
+    super(addr);
+  }
+
+  public void dumpSpec(PrintStream st) {
+    ciMethod m = method();
+    if (m != null) {
+      m.printShortName(st);
+      st.print(" ");
+    }
+    super.dumpSpec(st);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MachCallNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class MachCallNode extends MachSafePointNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MachCallNode");
+  }
+
+  public MachCallNode(Address addr) {
+    super(addr);
+  }
+
+  public void dumpSpec(PrintStream st) {
+      st.print("# ");
+      // tf()->dump_on(st);
+      // if (_cnt != COUNT_UNKNOWN)  st->print(" C=%f",_cnt);
+      if (jvms() != null)  jvms().dumpSpec(st);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MachCallRuntimeNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.CStringUtilities;
+
+public class MachCallRuntimeNode extends MachCallJavaNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MachCallRuntimeNode");
+    nameField    = type.getAddressField("_name");
+  }
+
+  private static AddressField nameField;
+
+  public String name() {
+    return CStringUtilities.getString(nameField.getValue(getAddress()));
+  }
+
+  public MachCallRuntimeNode(Address addr) {
+    super(addr);
+  }
+
+  public void dumpSpec(PrintStream out) {
+    out.printf("%s ", name());
+    super.dumpSpec(out);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MachCallStaticJavaNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.CStringUtilities;
+
+public class MachCallStaticJavaNode extends MachCallJavaNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MachCallStaticJavaNode");
+    nameField    = type.getAddressField("_name");
+  }
+
+  private static AddressField nameField;
+
+  public String name() {
+    return CStringUtilities.getString(nameField.getValue(getAddress()));
+  }
+
+  public MachCallStaticJavaNode(Address addr) {
+    super(addr);
+  }
+
+  public void dumpSpec(PrintStream st) {
+    st.print("Static ");
+    String n = name();
+    if (n != null) {
+      st.printf("wrapper for: %s", n);
+      // dump_trap_args(st);
+      st.print(" ");
+    }
+    super.dumpSpec(st);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MachIfNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class MachIfNode extends MachNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MachIfNode");
+    probField = type.getJFloatField("_prob");
+    fcntField = type.getJFloatField("_fcnt");
+  }
+
+  private static JFloatField probField;
+  private static JFloatField fcntField;
+
+  float prob() {
+    return probField.getValue(getAddress());
+  }
+
+  float cnt() {
+    return fcntField.getValue(getAddress());
+  }
+
+  public MachIfNode(Address addr) {
+    super(addr);
+  }
+
+  public void dumpSpec(PrintStream out) {
+    out.print("P=" + prob() + ", C=" + cnt());
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MachNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class MachNode extends Node {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MachNode");
+  }
+
+  public MachNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MachReturnNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class MachReturnNode extends MachNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MachReturnNode");
+  }
+
+  public MachReturnNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MachSafePointNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class MachSafePointNode extends MachReturnNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MachSafePointNode");
+    jvmsField = type.getAddressField("_jvms");
+    jvmadjField = new CIntField(type.getCIntegerField("_jvmadj"), 0);
+  }
+
+  private static AddressField jvmsField;
+  private static CIntField jvmadjField;
+
+  public MachSafePointNode(Address addr) {
+    super(addr);
+  }
+
+  public JVMState jvms() {
+    return JVMState.create(jvmsField.getValue(getAddress()));
+  }
+
+  public void dumpSpec(PrintStream out) {
+    try {
+      JVMState jvms = jvms();
+      if (jvms != null) out.print(" !");
+      if (jvms == null) out.print("empty jvms");
+      while (jvms != null) {
+        Method m = jvms.method().method();
+        int bci = jvms.bci();
+        out.print(" " + m.getMethodHolder().getName().asString().replace('/', '.') + "::" + m.getName().asString() + " @ bci:" + bci);
+        jvms = jvms.caller();
+      }
+    } catch (Exception e) {
+      out.print(e);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/MultiNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class MultiNode extends Node {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("MultiNode");
+  }
+
+
+  public MultiNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Node.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.io.*;
+import java.lang.reflect.Constructor;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class Node extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("Node");
+    outmaxField = new CIntField(type.getCIntegerField("_outmax"), 0);
+    outcntField = new CIntField(type.getCIntegerField("_outcnt"), 0);
+    maxField = new CIntField(type.getCIntegerField("_max"), 0);
+    cntField = new CIntField(type.getCIntegerField("_cnt"), 0);
+    idxField = new CIntField(type.getCIntegerField("_idx"), 0);
+    outField = type.getAddressField("_out");
+    inField = type.getAddressField("_in");
+
+    nodeType = db.lookupType("Node");
+
+    virtualConstructor = new VirtualBaseConstructor(db, nodeType, "sun.jvm.hotspot.opto", Node.class);
+  }
+
+  private static CIntField outmaxField;
+  private static CIntField outcntField;
+  private static CIntField maxField;
+  private static CIntField cntField;
+  private static CIntField idxField;
+  private static AddressField outField;
+  private static AddressField inField;
+
+  private static VirtualBaseConstructor virtualConstructor;
+
+  private static Type nodeType;
+
+  static HashMap nodes = new HashMap();
+
+  static HashMap constructors = new HashMap();
+
+  static abstract class Instantiator {
+    abstract Node create(Address addr);
+  }
+
+  static public Node create(Address addr) {
+    if (addr == null) return null;
+    Node result = (Node)nodes.get(addr);
+    if (result == null) {
+      result = (Node)virtualConstructor.instantiateWrapperFor(addr);
+      nodes.put(addr, result);
+    }
+    return result;
+  }
+
+  public Node(Address addr) {
+    super(addr);
+  }
+
+  public int outcnt() {
+    return (int)outcntField.getValue(this.getAddress());
+  }
+
+  public int req() {
+    return (int)cntField.getValue(this.getAddress());
+  }
+
+  public int len() {
+    return (int)maxField.getValue(this.getAddress());
+  }
+
+  public int idx() {
+    return (int)idxField.getValue(this.getAddress());
+  }
+
+  private Node[] _out;
+  private Node[] _in;
+
+  public Node rawOut(int i) {
+    if (_out == null) {
+      int addressSize = (int)VM.getVM().getAddressSize();
+      _out = new Node[outcnt()];
+      Address ptr = outField.getValue(this.getAddress());
+      for (int j = 0; j < outcnt(); j++) {
+        _out[j] = Node.create(ptr.getAddressAt(j * addressSize));
+      }
+    }
+    return _out[i];
+  }
+
+  public Node in(int i) {
+    if (_in == null) {
+      int addressSize = (int)VM.getVM().getAddressSize();
+      _in = new Node[len()];
+      Address ptr = inField.getValue(this.getAddress());
+      for (int j = 0; j < len(); j++) {
+        _in[j] = Node.create(ptr.getAddressAt(j * addressSize));
+      }
+    }
+    return _in[i];
+  }
+
+  public ArrayList collect(int d, boolean onlyCtrl) {
+    int depth = Math.abs(d);
+    ArrayList nstack = new ArrayList();
+    BitSet set = new BitSet();
+
+    nstack.add(this);
+    set.set(idx());
+    int begin = 0;
+    int end = 0;
+    for (int i = 0; i < depth; i++) {
+      end = nstack.size();
+      for(int j = begin; j < end; j++) {
+        Node tp  = (Node)nstack.get(j);
+        int limit = d > 0 ? tp.len() : tp.outcnt();
+        for(int k = 0; k < limit; k++) {
+          Node n = d > 0 ? tp.in(k) : tp.rawOut(k);
+
+          // if (NotANode(n))  continue;
+          if (n == null) continue;
+          // do not recurse through top or the root (would reach unrelated stuff)
+          // if (n.isRoot() || n.isTop())  continue;
+          // if (onlyCtrl && !n.isCfg()) continue;
+
+          if (!set.get(n.idx())) {
+            nstack.add(n);
+            set.set(n.idx());
+          }
+        }
+      }
+      begin = end;
+    }
+    return nstack;
+  }
+
+  protected void dumpNodes(Node s, int d, boolean onlyCtrl, PrintStream out) {
+    if (s == null) return;
+
+    ArrayList nstack = s.collect(d, onlyCtrl);
+    int end = nstack.size();
+    if (d > 0) {
+      for(int j = end-1; j >= 0; j--) {
+        ((Node)nstack.get(j)).dump(out);
+      }
+    } else {
+      for(int j = 0; j < end; j++) {
+        ((Node)nstack.get(j)).dump(out);
+      }
+    }
+  }
+
+  public void dump(int depth, PrintStream out) {
+    dumpNodes(this, depth, false, out);
+  }
+
+  public String Name() {
+    Type t = VM.getVM().getTypeDataBase().findDynamicTypeForAddress(getAddress(), nodeType);
+    String name = null;
+    if (t != null) {
+        name = t.toString();
+    } else {
+        Class c = getClass();
+        if (c == Node.class) {
+            // couldn't identify class type
+            return "UnknownNode<" + getAddress().getAddressAt(0) + ">";
+        }
+        name = getClass().getName();
+        if (name.startsWith("sun.jvm.hotspot.opto.")) {
+            name = name.substring("sun.jvm.hotspot.opto.".length());
+        }
+    }
+    if (name.endsWith("Node")) {
+        return name.substring(0, name.length() - 4);
+    }
+    return name;
+  }
+
+  public void dump(PrintStream out) {
+    out.print(" ");
+    out.print(idx());
+    out.print("\t");
+    out.print(Name());
+    out.print("\t=== ");
+    int i = 0;
+    for (i = 0; i < req(); i++) {
+      Node n = in(i);
+      if (n != null) {
+        out.print(' ');
+        out.print(in(i).idx());
+      } else {
+        out.print("_");
+      }
+      out.print(" ");
+    }
+    if (len() != req()) {
+      int prec = 0;
+      for (; i < len(); i++) {
+        Node n = in(i);
+        if (n != null) {
+          if (prec++ == 0) {
+            out.print("| ");
+          }
+          out.print(in(i).idx());
+        }
+        out.print(" ");
+      }
+    }
+    dumpOut(out);
+    dumpSpec(out);
+    out.println();
+  }
+
+  void dumpOut(PrintStream out) {
+    // Delimit the output edges
+    out.print(" [[");
+    // Dump the output edges
+    for (int i = 0; i < outcnt(); i++) {    // For all outputs
+      Node u = rawOut(i);
+      if (u == null) {
+        out.print("_ ");
+      // } else if (NotANode(u)) {
+      //   out.print("NotANode ");
+      } else {
+        // out.print("%c%d ", Compile::current()->nodeArena()->contains(u) ? ' ' : 'o', u->_idx);
+        out.print(' ');
+        out.print(u.idx());
+        out.print(' ');
+      }
+    }
+    out.print("]] ");
+  }
+
+  public void dumpSpec(PrintStream out) {
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Node_Array.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class Node_Array extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("Node_Array");
+    maxField = new CIntField(type.getCIntegerField("_max"), 0);
+    nodesField = type.getAddressField("_nodes");
+    aField = type.getAddressField("_a");
+  }
+
+  private static CIntField maxField;
+  private static AddressField nodesField;
+  private static AddressField aField;
+
+  public Node_Array(Address addr) {
+    super(addr);
+  }
+
+  public int Size() {
+    return (int) maxField.getValue(getAddress());
+  }
+
+  public Node at(int i) {
+    return Node.create(nodesField.getValue(getAddress()).getAddressAt(i * (int)VM.getVM().getAddressSize()));
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Node_List.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class Node_List extends Node_Array {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("Node_List");
+    cntField = new CIntField(type.getCIntegerField("_cnt"), 0);
+  }
+
+  private static CIntField cntField;
+
+  public Node_List(Address addr) {
+    super(addr);
+  }
+
+  public int size() {
+    return (int) cntField.getValue(getAddress());
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Phase.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class Phase extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("Phase");
+  }
+
+
+  public Phase(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import java.io.PrintStream;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class PhaseCFG extends Phase {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("PhaseCFG");
+    numBlocksField = new CIntField(type.getCIntegerField("_num_blocks"), 0);
+    blocksField = type.getAddressField("_blocks");
+    bbsField = type.getAddressField("_bbs");
+    brootField = type.getAddressField("_broot");
+  }
+
+  private static CIntField numBlocksField;
+  private static AddressField blocksField;
+  private static AddressField bbsField;
+  private static AddressField brootField;
+
+  public PhaseCFG(Address addr) {
+    super(addr);
+  }
+
+  public void dump(PrintStream out) {
+    int addressSize = (int)VM.getVM().getAddressSize();
+    int numBlocks = (int)numBlocksField.getValue(getAddress());
+    Block_List blocks = new Block_List(getAddress().addOffsetTo(blocksField.getOffset()));
+    int offset = 0;
+    for (int i  = 0; i < numBlocks; i++) {
+      blocks.at(i).dump(out);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseRegAlloc.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class PhaseRegAlloc extends Phase {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("PhaseRegAlloc");
+    nodeRegsField = type.getAddressField("_node_regs");
+    nodeRegsMaxIndexField = new CIntField(type.getCIntegerField("_node_regs_max_index"), 0);
+    framesizeField = new CIntField(type.getCIntegerField("_framesize"), 0);
+    maxRegField = new CIntField(type.getCIntegerField("_max_reg"), 0);
+  }
+
+  private static AddressField nodeRegsField;
+  private static CIntField nodeRegsMaxIndexField;
+  private static CIntField framesizeField;
+  private static CIntField maxRegField;
+
+  public PhaseRegAlloc(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/PhiNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class PhiNode extends TypeNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("PhiNode");
+  }
+
+
+  public PhiNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/ProjNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class ProjNode extends Node {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("ProjNode");
+  }
+
+
+  public ProjNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/RegionNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class RegionNode extends Node {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("RegionNode");
+  }
+
+
+  public RegionNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/RootNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class RootNode extends LoopNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("RootNode");
+  }
+
+
+  public RootNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/SafePointNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.io.PrintStream;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class SafePointNode extends MultiNode {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("SafePointNode");
+    jvmsField = type.getAddressField("_jvms");
+  }
+
+  private static AddressField jvmsField;
+
+  public SafePointNode(Address addr) {
+    super(addr);
+  }
+
+  public JVMState jvms() {
+    return JVMState.create(jvmsField.getValue(getAddress()));
+  }
+
+  public void dumpSpec(PrintStream out) {
+    JVMState jvms = jvms();
+    if (jvms != null) out.print(" !");
+    while (jvms != null) {
+      Method m = jvms.method().method();
+      int bci = jvms.bci();
+      out.print(" " + m.getMethodHolder().getName().asString().replace('/', '.') + "::" + m.getName().asString() + " @ bci:" + bci);
+      jvms = jvms.caller();
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/TypeNode.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.opto;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class TypeNode extends Node {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("TypeNode");
+  }
+
+
+  public TypeNode(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/prims/JvmtiExport.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.prims;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class JvmtiExport {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("JvmtiExport");
+    // XXX
+    // canAccessLocalVariables =    type.getCIntegerField("_can_access_local_variables");
+    // canHotswapOrPostBreakpoint = type.getCIntegerField("_can_hotswap_or_post_breakpoint");
+    // canPostOnExceptions =        type.getCIntegerField("_can_post_on_exceptions");
+  }
+
+  private static CIntegerField canAccessLocalVariables;
+  private static CIntegerField canHotswapOrPostBreakpoint;
+  private static CIntegerField canPostOnExceptions;
+
+  public static boolean canAccessLocalVariables() {
+    // return canAccessLocalVariables.getValue() != 0;
+    return false;
+  }
+  public static boolean canHotswapOrPostBreakpoint() {
+    // return canHotswapOrPostBreakpoint.getValue() != 0;
+    return false;
+  }
+  public static boolean canPostOnExceptions() {
+    // return canPostOnExceptions.getValue() != 0;
+    return false;
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -93,6 +93,8 @@
   }
 
   public StackValueCollection getLocals() {
+    if (getScope() == null)
+      return new StackValueCollection();
     List scvList = getScope().getLocals();
     if (scvList == null)
       return new StackValueCollection();
@@ -108,6 +110,8 @@
   }
 
   public StackValueCollection getExpressions() {
+    if (getScope() == null)
+      return new StackValueCollection();
     List scvList = getScope().getExpressions();
     if (scvList == null)
       return new StackValueCollection();
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CompilerThread.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CompilerThread.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,40 @@
 package sun.jvm.hotspot.runtime;
 
 import java.io.*;
+import java.util.*;
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.ci.*;
 
 public class CompilerThread extends JavaThread {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static AddressField _env_field;
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("CompilerThread");
+
+    _env_field = type.getAddressField("_env");
+  }
+
+  private ciEnv _env;
+
+  public synchronized ciEnv env() {
+    if (_env == null) {
+      Address v = _env_field.getValue(this.getAddress());
+      if (v != null) {
+        _env = new ciEnv(v);
+      }
+    }
+    return _env;
+  }
+
   public CompilerThread(Address addr) {
     super(addr);
   }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -33,6 +33,7 @@
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.interpreter.*;
 import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.runtime.sparc.SPARCFrame;
 import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;
 
@@ -74,11 +75,19 @@
   /** Size of constMethodOopDesc for computing BCI from BCP (FIXME: hack) */
   private static long    constMethodOopDescSize;
 
+  private static int pcReturnOffset;
+
+  public static int pcReturnOffset() {
+    return pcReturnOffset;
+  }
+
   private static synchronized void initialize(TypeDataBase db) {
     Type constMethodOopType = db.lookupType("constMethodOopDesc");
     // FIXME: not sure whether alignment here is correct or how to
     // force it (round up to address size?)
     constMethodOopDescSize = constMethodOopType.getSize();
+
+    pcReturnOffset = db.lookupIntConstant("frame::pc_return_offset").intValue();
   }
 
   protected int bcpToBci(Address bcp, ConstMethod cm) {
@@ -106,6 +115,10 @@
   public void    setPC(Address newpc) { pc = newpc; }
   public boolean isDeoptimized()      { return deoptimized; }
 
+  public CodeBlob cb() {
+    return VM.getVM().getCodeCache().findBlob(getPC());
+  }
+
   public abstract Address getSP();
   public abstract Address getID();
   public abstract Address getFP();
@@ -134,6 +147,12 @@
     }
   }
 
+  public boolean isRicochetFrame() {
+    CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
+    RicochetBlob rcb = VM.getVM().ricochetBlob();
+    return (cb == rcb && rcb != null && rcb.returnsToBounceAddr(getPC()));
+  }
+
   public boolean isCompiledFrame() {
     if (Assert.ASSERTS_ENABLED) {
       Assert.that(!VM.getVM().isCore(), "noncore builds only");
@@ -142,7 +161,7 @@
     return (cb != null && cb.isJavaMethod());
   }
 
-  public boolean isGlueFrame() {
+  public boolean isRuntimeFrame() {
     if (Assert.ASSERTS_ENABLED) {
       Assert.that(!VM.getVM().isCore(), "noncore builds only");
     }
@@ -197,7 +216,8 @@
   public Frame realSender(RegisterMap map) {
     if (!VM.getVM().isCore()) {
       Frame result = sender(map);
-      while (result.isGlueFrame()) {
+      while (result.isRuntimeFrame() ||
+             result.isRicochetFrame()) {
         result = result.sender(map);
       }
       return result;
@@ -611,6 +631,9 @@
     if (Assert.ASSERTS_ENABLED) {
       Assert.that(cb != null, "sanity check");
     }
+    if (cb == VM.getVM().ricochetBlob()) {
+      oopsRicochetDo(oopVisitor, regMap);
+    }
     if (cb.getOopMaps() != null) {
       OopMapSet.oopsDo(this, cb, regMap, oopVisitor, VM.getVM().isDebugging());
 
@@ -627,6 +650,10 @@
     //    }
   }
 
+  private void oopsRicochetDo      (AddressVisitor oopVisitor, RegisterMap regMap) {
+    // XXX Empty for now
+  }
+
   // FIXME: implement the above routines, plus add
   // oops_interpreted_arguments_do and oops_compiled_arguments_do
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/InstanceConstructor.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.cdbg.CDebugger;
+import sun.jvm.hotspot.debugger.cdbg.ClosestSymbol;
+import sun.jvm.hotspot.debugger.cdbg.LoadObject;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.HotSpotTypeDataBase;
+
+/** Given a pointer to some memory return an appropriate wrapper.
+ Various subclasses provide different mechanisms for identifying the
+ appropriate wrapper. */
+
+abstract public class InstanceConstructor<T> {
+  /** Instantiate the most-precisely typed wrapper object available
+      for the type of the given Address. If no type in the mapping
+      matched the type of the Address, throws a WrongTypeException.
+      Returns null for a null address (similar behavior to
+      VMObjectFactory). */
+  abstract public T instantiateWrapperFor(Address addr) throws WrongTypeException;
+
+  protected WrongTypeException newWrongTypeException(Address addr) {
+    String message = "No suitable match for type of address " + addr;
+    CDebugger cdbg = VM.getVM().getDebugger().getCDebugger();
+    if (cdbg != null) {
+      // Most common case: V-table pointer is the first field
+      Address vtblPtr = addr.getAddressAt(0);
+      LoadObject lo = cdbg.loadObjectContainingPC(vtblPtr);
+      if (lo != null) {
+        ClosestSymbol symbol = lo.closestSymbolToPC(vtblPtr);
+        if (symbol != null) {
+          message += " (nearest symbol is " + symbol.getName() + ")";
+        }
+      }
+    }
+
+    return new WrongTypeException(message);
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/JavaVFrame.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/JavaVFrame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -128,14 +128,14 @@
       }
 
       // dynamic part - we just compare the frame pointer
-      if (! getFrame().getFP().equals(other.getFrame().getFP())) {
+      if (! getFrame().equals(other.getFrame())) {
           return false;
       }
       return true;
   }
 
   public int hashCode() {
-      return getMethod().hashCode() ^ getBCI() ^ getFrame().getFP().hashCode();
+      return getMethod().hashCode() ^ getBCI() ^ getFrame().hashCode();
   }
 
   /** Structural compare */
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StackValue.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StackValue.java	Wed Oct 26 17:59:13 2011 -0700
@@ -100,7 +100,7 @@
 
   public int hashCode() {
     if (type == BasicType.getTObject()) {
-      return handleValue.hashCode();
+      return handleValue != null ? handleValue.hashCode() : 5;
     } else {
       // Returns 0 for conflict type
       return (int) integerValue;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StaticBaseConstructor.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.cdbg.CDebugger;
+import sun.jvm.hotspot.debugger.cdbg.ClosestSymbol;
+import sun.jvm.hotspot.debugger.cdbg.LoadObject;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.HotSpotTypeDataBase;
+
+/** Instantiate wrappers for statically typed instances. */
+
+public class StaticBaseConstructor<T> extends InstanceConstructor {
+  private Class staticType;
+
+  public StaticBaseConstructor(Class<T> t) {
+    staticType = t;
+  }
+
+  /** Instantiate a wrapper using staticType */
+  public VMObject instantiateWrapperFor(Address addr) throws WrongTypeException {
+    if (addr == null) {
+      return null;
+    }
+
+    return (VMObject) VMObjectFactory.newObject(staticType, addr);
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,8 @@
 import sun.jvm.hotspot.runtime.linux_ia64.LinuxIA64JavaThreadPDAccess;
 import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess;
 import sun.jvm.hotspot.runtime.linux_sparc.LinuxSPARCJavaThreadPDAccess;
+import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
+import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
 import sun.jvm.hotspot.utilities.*;
 
 public class Threads {
@@ -90,7 +92,12 @@
             } else if (cpu.equals("sparc")) {
                 access = new LinuxSPARCJavaThreadPDAccess();
             }
-
+        } else if (os.equals("bsd")) {
+            if (cpu.equals("x86")) {
+                access = new BsdX86JavaThreadPDAccess();
+            } else if (cpu.equals("amd64")) {
+                access = new BsdAMD64JavaThreadPDAccess();
+            }
         }
 
         if (access == null) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VFrame.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VFrame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -77,7 +77,7 @@
           return new CompiledVFrame(f, regMap, thread, scope, mayBeImprecise);
         }
 
-        if (f.isGlueFrame()) {
+        if (f.isRuntimeFrame()) {
           // This is a conversion frame. Skip this frame and try again.
           RegisterMap tempMap = regMap.copy();
           Frame s = f.sender(tempMap);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java	Wed Oct 26 17:59:13 2011 -0700
@@ -30,6 +30,7 @@
 import java.util.regex.*;
 import sun.jvm.hotspot.code.*;
 import sun.jvm.hotspot.c1.*;
+import sun.jvm.hotspot.code.*;
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.interpreter.*;
 import sun.jvm.hotspot.memory.*;
@@ -85,6 +86,9 @@
   private Interpreter  interpreter;
   private StubRoutines stubRoutines;
   private Bytes        bytes;
+
+  private RicochetBlob ricochetBlob;
+
   /** Flags indicating whether we are attached to a core, C1, or C2 build */
   private boolean      usingClientCompiler;
   private boolean      usingServerCompiler;
@@ -131,12 +135,14 @@
      private String name;
      private Address addr;
      private String kind;
+     private int origin;
 
-     private Flag(String type, String name, Address addr, String kind) {
+     private Flag(String type, String name, Address addr, String kind, int origin) {
         this.type = type;
         this.name = name;
         this.addr = addr;
         this.kind = kind;
+        this.origin = origin;
      }
 
      public String getType() {
@@ -155,6 +161,10 @@
         return kind;
      }
 
+     public int getOrigin() {
+        return origin;
+     }
+
      public boolean isBool() {
         return type.equals("bool");
      }
@@ -300,7 +310,7 @@
         usingServerCompiler = false;
       } else {
         // Determine whether C2 is present
-        if (type.getField("_interpreter_invocation_count", false, false) != null) {
+        if (db.lookupType("Matcher", false) != null) {
           usingServerCompiler = true;
         } else {
           usingClientCompiler = true;
@@ -618,6 +628,18 @@
     return stubRoutines;
   }
 
+  public RicochetBlob ricochetBlob() {
+    if (ricochetBlob == null) {
+      Type ricochetType  = db.lookupType("SharedRuntime");
+      AddressField ricochetBlobAddress = ricochetType.getAddressField("_ricochet_blob");
+      Address addr = ricochetBlobAddress.getValue();
+      if (addr != null) {
+        ricochetBlob = new RicochetBlob(addr);
+      }
+    }
+    return ricochetBlob;
+  }
+
   public VMRegImpl getVMRegImplInfo() {
     if (vmregImpl == null) {
       vmregImpl = new VMRegImpl();
@@ -788,42 +810,40 @@
   private void readCommandLineFlags() {
     // get command line flags
     TypeDataBase db = getTypeDataBase();
-    try {
-       Type flagType = db.lookupType("Flag");
-       int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
-       // NOTE: last flag contains null values.
-       commandLineFlags = new Flag[numFlags - 1];
+    Type flagType = db.lookupType("Flag");
+    int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
+    // NOTE: last flag contains null values.
+    commandLineFlags = new Flag[numFlags - 1];
+
+    Address flagAddr = flagType.getAddressField("flags").getValue();
 
-       Address flagAddr = flagType.getAddressField("flags").getValue();
+    AddressField typeFld = flagType.getAddressField("type");
+    AddressField nameFld = flagType.getAddressField("name");
+    AddressField addrFld = flagType.getAddressField("addr");
+    AddressField kindFld = flagType.getAddressField("kind");
+    CIntField originFld = new CIntField(flagType.getCIntegerField("origin"), 0);
 
-       AddressField typeFld = flagType.getAddressField("type");
-       AddressField nameFld = flagType.getAddressField("name");
-       AddressField addrFld = flagType.getAddressField("addr");
-       AddressField kindFld = flagType.getAddressField("kind");
-
-       long flagSize = flagType.getSize(); // sizeof(Flag)
+    long flagSize = flagType.getSize(); // sizeof(Flag)
 
-       // NOTE: last flag contains null values.
-       for (int f = 0; f < numFlags - 1; f++) {
-          String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
-          String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
-          Address addr = addrFld.getValue(flagAddr);
-          String kind = CStringUtilities.getString(kindFld.getValue(flagAddr));
-          commandLineFlags[f] = new Flag(type, name, addr, kind);
-          flagAddr = flagAddr.addOffsetTo(flagSize);
-       }
+    // NOTE: last flag contains null values.
+    for (int f = 0; f < numFlags - 1; f++) {
+      String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
+      String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
+      Address addr = addrFld.getValue(flagAddr);
+      String kind = CStringUtilities.getString(kindFld.getValue(flagAddr));
+      int origin = (int)originFld.getValue(flagAddr);
+      commandLineFlags[f] = new Flag(type, name, addr, kind, origin);
+      flagAddr = flagAddr.addOffsetTo(flagSize);
+    }
 
-       // sort flags by name
-       Arrays.sort(commandLineFlags, new Comparator() {
-                                        public int compare(Object o1, Object o2) {
-                                           Flag f1 = (Flag) o1;
-                                           Flag f2 = (Flag) o2;
-                                           return f1.getName().compareTo(f2.getName());
-                                        }
-                                     });
-    } catch (Exception exp) {
-       // ignore. may be older version. command line flags not available.
-    }
+    // sort flags by name
+    Arrays.sort(commandLineFlags, new Comparator() {
+        public int compare(Object o1, Object o2) {
+          Flag f1 = (Flag) o1;
+          Flag f2 = (Flag) o2;
+          return f1.getName().compareTo(f2.getName());
+        }
+      });
   }
 
   public String getSystemProperty(String key) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VirtualBaseConstructor.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.cdbg.CDebugger;
+import sun.jvm.hotspot.debugger.cdbg.ClosestSymbol;
+import sun.jvm.hotspot.debugger.cdbg.LoadObject;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.HotSpotTypeDataBase;
+
+/** This provides a factory to create instances where the base virtual
+ * type is know and the expected subclasses are within a particular
+ * package. */
+
+public class VirtualBaseConstructor<T> extends InstanceConstructor {
+  private TypeDataBase db;
+  private HashMap      map; // Map<String, Class>
+  private Type         baseType;
+  private Class        unknownTypeHandler;
+
+  public VirtualBaseConstructor(TypeDataBase db, Type baseType, String packageName, Class unknownTypeHandler) {
+    this.db = (HotSpotTypeDataBase)db;
+    map     = new HashMap();
+    this.baseType = baseType;
+    this.unknownTypeHandler = unknownTypeHandler;
+    // Try to find mirror types for each of the types.  If there isn't
+    // a direct mirror then try to find an instantiable superclass and
+    // treat it as that.
+    for (Iterator iter = db.getTypes(); iter.hasNext(); ) {
+      Type t = (Type) iter.next();
+      Type superType = t;
+      while (superType != null && superType != baseType) {
+        superType = superType.getSuperclass();
+      }
+      if (superType == baseType) {
+        superType = t;
+        Class c = null;
+        while (c == null && superType != null) {
+          try {
+            c = Class.forName(packageName + "." + superType.getName());
+          } catch (Exception e) {
+          }
+          if (c == null) superType = superType.getSuperclass();
+        }
+        if (c == null) {
+          c = unknownTypeHandler;
+        }
+        map.put(t.getName(), c);
+      }
+    }
+  }
+
+  /** Instantiate the most-precisely typed wrapper object available
+      for the type of the given Address. If no type in the mapping
+      matched the type of the Address, throws a WrongTypeException.
+      Returns null for a null address (similar behavior to
+      VMObjectFactory). */
+  public VMObject instantiateWrapperFor(Address addr) throws WrongTypeException {
+    if (addr == null) {
+      return null;
+    }
+
+    Type type = db.findDynamicTypeForAddress(addr, baseType);
+    if (type != null) {
+        return (VMObject) VMObjectFactory.newObject((Class) map.get(type.getName()), addr);
+    } else if (unknownTypeHandler != null) {
+        return (VMObject) VMObjectFactory.newObject(unknownTypeHandler, addr);
+    }
+
+    throw newWrongTypeException(addr);
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VirtualConstructor.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VirtualConstructor.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.cdbg.*;
 import sun.jvm.hotspot.types.*;
 
 /** This class provides generalized "virtual constructor"
@@ -39,7 +38,7 @@
     type "DefNewGeneration" to class
     sun.jvm.hotspot.memory.DefNewGeneration has been set up. */
 
-public class VirtualConstructor {
+public class VirtualConstructor extends InstanceConstructor<VMObject> {
   private TypeDataBase db;
   private Map          map; // Map<String, Class>
 
@@ -78,20 +77,6 @@
       }
     }
 
-    String message = "No suitable match for type of address " + addr;
-    CDebugger cdbg = VM.getVM().getDebugger().getCDebugger();
-    if (cdbg != null) {
-      // Most common case: V-table pointer is the first field
-      Address vtblPtr = addr.getAddressAt(0);
-      LoadObject lo = cdbg.loadObjectContainingPC(vtblPtr);
-      if (lo != null) {
-        ClosestSymbol symbol = lo.closestSymbolToPC(vtblPtr);
-        if (symbol != null) {
-          message += " (nearest symbol is " + symbol.getName() + ")";
-        }
-      }
-    }
-
-    throw new WrongTypeException(message);
+    throw newWrongTypeException(addr);
   }
 }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64CurrentFrameGuess.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64CurrentFrameGuess.java	Wed Oct 26 17:59:13 2011 -0700
@@ -29,6 +29,7 @@
 import sun.jvm.hotspot.code.*;
 import sun.jvm.hotspot.interpreter.*;
 import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.runtime.x86.*;
 
 /** <P> Should be able to be used on all amd64 platforms we support
     (Linux/amd64) to implement JavaThread's
@@ -123,7 +124,7 @@
              offset += vm.getAddressSize()) {
           try {
             Address curSP = sp.addOffsetTo(offset);
-            Frame frame = new AMD64Frame(curSP, null, pc);
+            Frame frame = new X86Frame(curSP, null, pc);
             RegisterMap map = thread.newRegisterMap(false);
             while (frame != null) {
               if (frame.isEntryFrame() && frame.entryFrameIsFirst()) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64Frame.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,528 +0,0 @@
-/*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
- * 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.runtime.amd64;
-
-import java.util.*;
-import sun.jvm.hotspot.code.*;
-import sun.jvm.hotspot.compiler.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.oops.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.types.*;
-import sun.jvm.hotspot.utilities.*;
-
-/** Specialization of and implementation of abstract methods of the
-    Frame class for the amd64 CPU. */
-
-public class AMD64Frame extends Frame {
-  private static final boolean DEBUG;
-  static {
-    DEBUG = System.getProperty("sun.jvm.hotspot.runtime.amd64.AMD64Frame.DEBUG") != null;
-  }
-
-  // refer to frame_amd64.hpp
-  private static final int PC_RETURN_OFFSET           =  0;
-  // All frames
-  private static final int LINK_OFFSET                =  0;
-  private static final int RETURN_ADDR_OFFSET         =  1;
-  private static final int SENDER_SP_OFFSET           =  2;
-
-  // Interpreter frames
-  private static final int INTERPRETER_FRAME_MIRROR_OFFSET    =  2; // for native calls only
-  private static final int INTERPRETER_FRAME_SENDER_SP_OFFSET = -1;
-  private static final int INTERPRETER_FRAME_LAST_SP_OFFSET   = INTERPRETER_FRAME_SENDER_SP_OFFSET - 1;
-  private static final int INTERPRETER_FRAME_METHOD_OFFSET    = INTERPRETER_FRAME_LAST_SP_OFFSET - 1;
-  private static       int INTERPRETER_FRAME_MDX_OFFSET;         // Non-core builds only
-  private static       int INTERPRETER_FRAME_CACHE_OFFSET;
-  private static       int INTERPRETER_FRAME_LOCALS_OFFSET;
-  private static       int INTERPRETER_FRAME_BCX_OFFSET;
-  private static       int INTERPRETER_FRAME_INITIAL_SP_OFFSET;
-  private static       int INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET;
-  private static       int INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET;
-
-  // Entry frames
-  private static final int ENTRY_FRAME_CALL_WRAPPER_OFFSET   =  -6;
-
-  // Native frames
-  private static final int NATIVE_FRAME_INITIAL_PARAM_OFFSET =  2;
-
-  static {
-    VM.registerVMInitializedObserver(new Observer() {
-        public void update(Observable o, Object data) {
-          initialize(VM.getVM().getTypeDataBase());
-        }
-      });
-  }
-
-  private static synchronized void initialize(TypeDataBase db) {
-    if (VM.getVM().isCore()) {
-      INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_METHOD_OFFSET - 1;
-    } else {
-      INTERPRETER_FRAME_MDX_OFFSET   = INTERPRETER_FRAME_METHOD_OFFSET - 1;
-      INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_MDX_OFFSET - 1;
-    }
-    INTERPRETER_FRAME_LOCALS_OFFSET               = INTERPRETER_FRAME_CACHE_OFFSET - 1;
-    INTERPRETER_FRAME_BCX_OFFSET                  = INTERPRETER_FRAME_LOCALS_OFFSET - 1;
-    INTERPRETER_FRAME_INITIAL_SP_OFFSET           = INTERPRETER_FRAME_BCX_OFFSET - 1;
-    INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET    = INTERPRETER_FRAME_INITIAL_SP_OFFSET;
-    INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET = INTERPRETER_FRAME_INITIAL_SP_OFFSET;
-  }
-
-  // an additional field beyond sp and pc:
-  Address raw_fp; // frame pointer
-  private Address raw_unextendedSP;
-
-  private AMD64Frame() {
-  }
-
-  private void adjustForDeopt() {
-    if ( pc != null) {
-      // Look for a deopt pc and if it is deopted convert to original pc
-      CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc);
-      if (cb != null && cb.isJavaMethod()) {
-        NMethod nm = (NMethod) cb;
-        if (pc.equals(nm.deoptBegin())) {
-          // adjust pc if frame is deoptimized.
-          if (Assert.ASSERTS_ENABLED) {
-            Assert.that(this.getUnextendedSP() != null, "null SP in Java frame");
-          }
-          pc = this.getUnextendedSP().getAddressAt(nm.origPCOffset());
-          deoptimized = true;
-        }
-      }
-    }
-  }
-
-  public AMD64Frame(Address raw_sp, Address raw_fp, Address pc) {
-    this.raw_sp = raw_sp;
-    this.raw_unextendedSP = raw_sp;
-    this.raw_fp = raw_fp;
-    this.pc = pc;
-
-    // Frame must be fully constructed before this call
-    adjustForDeopt();
-
-    if (DEBUG) {
-      System.out.println("AMD64Frame(sp, fp, pc): " + this);
-      dumpStack();
-    }
-  }
-
-  public AMD64Frame(Address raw_sp, Address raw_fp) {
-    this.raw_sp = raw_sp;
-    this.raw_unextendedSP = raw_sp;
-    this.raw_fp = raw_fp;
-    this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
-
-    // Frame must be fully constructed before this call
-    adjustForDeopt();
-
-    if (DEBUG) {
-      System.out.println("AMD64Frame(sp, fp): " + this);
-      dumpStack();
-    }
-  }
-
-  // This constructor should really take the unextended SP as an arg
-  // but then the constructor is ambiguous with constructor that takes
-  // a PC so take an int and convert it.
-  public AMD64Frame(Address raw_sp, Address raw_fp, long extension) {
-    this.raw_sp = raw_sp;
-    if ( raw_sp == null) {
-      this.raw_unextendedSP = null;
-    } else {
-      this.raw_unextendedSP = raw_sp.addOffsetTo(extension);
-    }
-    this.raw_fp = raw_fp;
-    this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
-
-    // Frame must be fully constructed before this call
-    adjustForDeopt();
-
-    if (DEBUG) {
-      System.out.println("AMD64Frame(sp, fp, extension): " + this);
-      dumpStack();
-    }
-
-  }
-
-  public Object clone() {
-    AMD64Frame frame = new AMD64Frame();
-    frame.raw_sp = raw_sp;
-    frame.raw_unextendedSP = raw_unextendedSP;
-    frame.raw_fp = raw_fp;
-    frame.pc = pc;
-    frame.deoptimized = deoptimized;
-    return frame;
-  }
-
-  public boolean equals(Object arg) {
-    if (arg == null) {
-      return false;
-    }
-
-    if (!(arg instanceof AMD64Frame)) {
-      return false;
-    }
-
-    AMD64Frame other = (AMD64Frame) arg;
-
-    return (AddressOps.equal(getSP(), other.getSP()) &&
-            AddressOps.equal(getFP(), other.getFP()) &&
-            AddressOps.equal(getUnextendedSP(), other.getUnextendedSP()) &&
-            AddressOps.equal(getPC(), other.getPC()));
-  }
-
-  public int hashCode() {
-    if (raw_sp == null) {
-      return 0;
-    }
-
-    return raw_sp.hashCode();
-  }
-
-  public String toString() {
-    return "sp: " + (getSP() == null? "null" : getSP().toString()) +
-         ", unextendedSP: " + (getUnextendedSP() == null? "null" : getUnextendedSP().toString()) +
-         ", fp: " + (getFP() == null? "null" : getFP().toString()) +
-         ", pc: " + (pc == null? "null" : pc.toString());
-  }
-
-  // accessors for the instance variables
-  public Address getFP() { return raw_fp; }
-  public Address getSP() { return raw_sp; }
-  public Address getID() { return raw_sp; }
-
-  // FIXME: not implemented yet (should be done for Solaris/AMD64)
-  public boolean isSignalHandlerFrameDbg() { return false; }
-  public int     getSignalNumberDbg()      { return 0;     }
-  public String  getSignalNameDbg()        { return null;  }
-
-  public boolean isInterpretedFrameValid() {
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(isInterpretedFrame(), "Not an interpreted frame");
-    }
-
-    // These are reasonable sanity checks
-    if (getFP() == null || getFP().andWithMask(0x3) != null) {
-      return false;
-    }
-
-    if (getSP() == null || getSP().andWithMask(0x3) != null) {
-      return false;
-    }
-
-    if (getFP().addOffsetTo(INTERPRETER_FRAME_INITIAL_SP_OFFSET * VM.getVM().getAddressSize()).lessThan(getSP())) {
-      return false;
-    }
-
-    // These are hacks to keep us out of trouble.
-    // The problem with these is that they mask other problems
-    if (getFP().lessThanOrEqual(getSP())) {
-      // this attempts to deal with unsigned comparison above
-      return false;
-    }
-
-    if (getFP().minus(getSP()) > 4096 * VM.getVM().getAddressSize()) {
-      // stack frames shouldn't be large.
-      return false;
-    }
-
-    return true;
-  }
-
-  // FIXME: not applicable in current system
-  //  void    patch_pc(Thread* thread, address pc);
-
-  public Frame sender(RegisterMap regMap, CodeBlob cb) {
-    AMD64RegisterMap map = (AMD64RegisterMap) regMap;
-
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(map != null, "map must be set");
-    }
-
-    // Default is we done have to follow them. The sender_for_xxx will
-    // update it accordingly
-    map.setIncludeArgumentOops(false);
-
-    if (isEntryFrame())       return senderForEntryFrame(map);
-    if (isInterpretedFrame()) return senderForInterpreterFrame(map);
-
-
-    if (!VM.getVM().isCore()) {
-      if(cb == null) {
-        cb = VM.getVM().getCodeCache().findBlob(getPC());
-      } else {
-        if (Assert.ASSERTS_ENABLED) {
-          Assert.that(cb.equals(VM.getVM().getCodeCache().findBlob(getPC())), "Must be the same");
-        }
-      }
-
-      if (cb != null) {
-         return senderForCompiledFrame(map, cb);
-      }
-    }
-
-    // Must be native-compiled frame, i.e. the marshaling code for native
-    // methods that exists in the core system.
-    return new AMD64Frame(getSenderSP(), getLink(), getSenderPC());
-  }
-
-  private Frame senderForEntryFrame(AMD64RegisterMap map) {
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(map != null, "map must be set");
-    }
-    // Java frame called from C; skip all C frames and return top C
-    // frame of that chunk as the sender
-    AMD64JavaCallWrapper jcw = (AMD64JavaCallWrapper) getEntryFrameCallWrapper();
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(!entryFrameIsFirst(), "next Java fp must be non zero");
-      Assert.that(jcw.getLastJavaSP().greaterThan(getSP()), "must be above this frame on stack");
-    }
-    AMD64Frame fr;
-    if (jcw.getLastJavaPC() != null) {
-      fr = new AMD64Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP(), jcw.getLastJavaPC());
-    } else {
-      fr = new AMD64Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP());
-    }
-    map.clear();
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(map.getIncludeArgumentOops(), "should be set by clear");
-    }
-    return fr;
-  }
-
-  private Frame senderForInterpreterFrame(AMD64RegisterMap map) {
-    Address unextendedSP = addressOfStackSlot(INTERPRETER_FRAME_SENDER_SP_OFFSET).getAddressAt(0);
-    Address sp = addressOfStackSlot(SENDER_SP_OFFSET);
-    // We do not need to update the callee-save register mapping because above
-    // us is either another interpreter frame or a converter-frame, but never
-    // directly a compiled frame.
-    // 11/24/04 SFG. This is no longer true after adapter were removed. However at the moment
-    // C2 no longer uses callee save register for java calls so there are no callee register
-    // to find.
-    return new AMD64Frame(sp, getLink(), unextendedSP.minus(sp));
-  }
-
-  private Frame senderForCompiledFrame(AMD64RegisterMap map, CodeBlob cb) {
-    //
-    // NOTE: some of this code is (unfortunately) duplicated in AMD64CurrentFrameGuess
-    //
-
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(map != null, "map must be set");
-    }
-
-    // frame owned by optimizing compiler
-    Address        sender_sp = null;
-
-
-    if (VM.getVM().isClientCompiler()) {
-      sender_sp        = addressOfStackSlot(SENDER_SP_OFFSET);
-    } else {
-      if (Assert.ASSERTS_ENABLED) {
-        Assert.that(cb.getFrameSize() >= 0, "Compiled by Compiler1: do not use");
-      }
-      sender_sp = getUnextendedSP().addOffsetTo(cb.getFrameSize());
-    }
-
-    // On Intel the return_address is always the word on the stack
-    Address sender_pc = sender_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
-
-    if (map.getUpdateMap() && cb.getOopMaps() != null) {
-      OopMapSet.updateRegisterMap(this, cb, map, true);
-    }
-
-    if (VM.getVM().isClientCompiler()) {
-      // Move this here for C1 and collecting oops in arguments (According to Rene)
-      map.setIncludeArgumentOops(cb.callerMustGCArguments(map.getThread()));
-    }
-
-    Address saved_fp = null;
-    if (VM.getVM().isClientCompiler()) {
-      saved_fp = getFP().getAddressAt(0);
-    } else if (VM.getVM().isServerCompiler() &&
-               (VM.getVM().getInterpreter().contains(sender_pc) ||
-               VM.getVM().getStubRoutines().returnsToCallStub(sender_pc))) {
-      // C2 prologue saves EBP in the usual place.
-      // however only use it if the sender had link infomration in it.
-      saved_fp = sender_sp.getAddressAt(-2 * VM.getVM().getAddressSize());
-    }
-
-    return new AMD64Frame(sender_sp, saved_fp, sender_pc);
-  }
-
-  protected boolean hasSenderPD() {
-    // FIXME
-    // Check for null ebp? Need to do some tests.
-    return true;
-  }
-
-  public long frameSize() {
-    return (getSenderSP().minus(getSP()) / VM.getVM().getAddressSize());
-  }
-
-  public Address getLink() {
-    return addressOfStackSlot(LINK_OFFSET).getAddressAt(0);
-  }
-
-  // FIXME: not implementable yet
-  //inline void      frame::set_link(intptr_t* addr)  { *(intptr_t **)addr_at(link_offset) = addr; }
-
-  public Address getUnextendedSP() { return raw_unextendedSP; }
-
-  // Return address:
-  public Address getSenderPCAddr() { return addressOfStackSlot(RETURN_ADDR_OFFSET); }
-  public Address getSenderPC()     { return getSenderPCAddr().getAddressAt(0);      }
-
-  // return address of param, zero origin index.
-  public Address getNativeParamAddr(int idx) {
-    return addressOfStackSlot(NATIVE_FRAME_INITIAL_PARAM_OFFSET + idx);
-  }
-
-  public Address getSenderSP()     { return addressOfStackSlot(SENDER_SP_OFFSET); }
-
-  public Address compiledArgumentToLocationPD(VMReg reg, RegisterMap regMap, int argSize) {
-    if (VM.getVM().isCore() || VM.getVM().isClientCompiler()) {
-      throw new RuntimeException("Should not reach here");
-    }
-
-    return oopMapRegToLocation(reg, regMap);
-  }
-
-  public Address addressOfInterpreterFrameLocals() {
-    return addressOfStackSlot(INTERPRETER_FRAME_LOCALS_OFFSET);
-  }
-
-  private Address addressOfInterpreterFrameBCX() {
-    return addressOfStackSlot(INTERPRETER_FRAME_BCX_OFFSET);
-  }
-
-  public int getInterpreterFrameBCI() {
-    // FIXME: this is not atomic with respect to GC and is unsuitable
-    // for use in a non-debugging, or reflective, system. Need to
-    // figure out how to express this.
-    Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0);
-    OopHandle methodHandle = addressOfInterpreterFrameMethod().getOopHandleAt(0);
-    Method method = (Method) VM.getVM().getObjectHeap().newOop(methodHandle);
-    return (int) bcpToBci(bcp, method);
-  }
-
-  public Address addressOfInterpreterFrameMDX() {
-    return addressOfStackSlot(INTERPRETER_FRAME_MDX_OFFSET);
-  }
-
-  // FIXME
-  //inline int frame::interpreter_frame_monitor_size() {
-  //  return BasicObjectLock::size();
-  //}
-
-  // expression stack
-  // (the max_stack arguments are used by the GC; see class FrameClosure)
-
-  public Address addressOfInterpreterFrameExpressionStack() {
-    Address monitorEnd = interpreterFrameMonitorEnd().address();
-    return monitorEnd.addOffsetTo(-1 * VM.getVM().getAddressSize());
-  }
-
-  public int getInterpreterFrameExpressionStackDirection() { return -1; }
-
-  // top of expression stack
-  public Address addressOfInterpreterFrameTOS() {
-    return getSP();
-  }
-
-  /** Expression stack from top down */
-  public Address addressOfInterpreterFrameTOSAt(int slot) {
-    return addressOfInterpreterFrameTOS().addOffsetTo(slot * VM.getVM().getAddressSize());
-  }
-
-  public Address getInterpreterFrameSenderSP() {
-    if (Assert.ASSERTS_ENABLED) {
-      Assert.that(isInterpretedFrame(), "interpreted frame expected");
-    }
-    return addressOfStackSlot(INTERPRETER_FRAME_SENDER_SP_OFFSET).getAddressAt(0);
-  }
-
-  // Monitors
-  public BasicObjectLock interpreterFrameMonitorBegin() {
-    return new BasicObjectLock(addressOfStackSlot(INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET));
-  }
-
-  public BasicObjectLock interpreterFrameMonitorEnd() {
-    Address result = addressOfStackSlot(INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET).getAddressAt(0);
-    if (Assert.ASSERTS_ENABLED) {
-      // make sure the pointer points inside the frame
-      Assert.that(AddressOps.gt(getFP(), result), "result must <  than frame pointer");
-      Assert.that(AddressOps.lte(getSP(), result), "result must >= than stack pointer");
-    }
-    return new BasicObjectLock(result);
-  }
-
-  public int interpreterFrameMonitorSize() {
-    return BasicObjectLock.size();
-  }
-
-  // Method
-  public Address addressOfInterpreterFrameMethod() {
-    return addressOfStackSlot(INTERPRETER_FRAME_METHOD_OFFSET);
-  }
-
-  // Constant pool cache
-  public Address addressOfInterpreterFrameCPCache() {
-    return addressOfStackSlot(INTERPRETER_FRAME_CACHE_OFFSET);
-  }
-
-  // Entry frames
-  public JavaCallWrapper getEntryFrameCallWrapper() {
-    return new AMD64JavaCallWrapper(addressOfStackSlot(ENTRY_FRAME_CALL_WRAPPER_OFFSET).getAddressAt(0));
-  }
-
-  protected Address addressOfSavedOopResult() {
-    // offset is 2 for compiler2 and 3 for compiler1
-    return getSP().addOffsetTo((VM.getVM().isClientCompiler() ? 2 : 3) *
-                               VM.getVM().getAddressSize());
-  }
-
-  protected Address addressOfSavedReceiver() {
-    return getSP().addOffsetTo(-4 * VM.getVM().getAddressSize());
-  }
-
-  private void dumpStack() {
-    if (getFP() != null) {
-      for (Address addr = getSP().addOffsetTo(-5 * VM.getVM().getAddressSize());
-           AddressOps.lte(addr, getFP().addOffsetTo(5 * VM.getVM().getAddressSize()));
-           addr = addr.addOffsetTo(VM.getVM().getAddressSize())) {
-        System.out.println(addr + ": " + addr.getAddressAt(0));
-      }
-    } else {
-      for (Address addr = getSP().addOffsetTo(-5 * VM.getVM().getAddressSize());
-           AddressOps.lte(addr, getSP().addOffsetTo(20 * VM.getVM().getAddressSize()));
-           addr = addr.addOffsetTo(VM.getVM().getAddressSize())) {
-        System.out.println(addr + ": " + addr.getAddressAt(0));
-      }
-    }
-  }
-}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/amd64/AMD64RegisterMap.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
- * 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.runtime.amd64;
-
-import sun.jvm.hotspot.asm.amd64.*;
-import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.runtime.*;
-
-public class AMD64RegisterMap extends RegisterMap {
-
-  /** This is the only public constructor */
-  public AMD64RegisterMap(JavaThread thread, boolean updateMap) {
-    super(thread, updateMap);
-  }
-
-  protected AMD64RegisterMap(RegisterMap map) {
-    super(map);
-  }
-
-  public Object clone() {
-    AMD64RegisterMap retval = new AMD64RegisterMap(this);
-    return retval;
-  }
-
-  // no PD state to clear or copy:
-  protected void clearPD() {}
-  protected void initializePD() {}
-  protected void initializeFromPD(RegisterMap map) {}
-  protected Address getLocationPD(VMReg reg) { return null; }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd/BsdSignals.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.runtime.bsd;
+
+public class BsdSignals {
+  private static String[] signalNames = {
+    "",           /* No signal 0 */
+    "SIGHUP",     /* hangup */
+    "SIGINT",     /* interrupt */
+    "SIGQUIT",    /* quit */
+    "SIGILL",     /* illegal instr. (not reset when caught) */
+    "SIGTRAP",    /* trace trap (not reset when caught) */
+    "SIGABRT",    /* abort() */
+    "SIGEMT",     /* EMT instruction */
+    "SIGFPE",     /* floating point exception */
+    "SIGKILL",    /* kill (cannot be caught or ignored) */
+    "SIGBUS",     /* bus error */
+    "SIGSEGV",    /* segmentation violation */
+    "SIGSYS",     /* non-existent system call invoked */
+    "SIGPIPE",    /* write on a pipe with no one to read it */
+    "SIGALRM",    /* alarm clock */
+    "SIGTERM",    /* software termination signal from kill */
+    "SIGURG",     /* urgent condition on IO channel */
+    "SIGSTOP",    /* sendable stop signal not from tty */
+    "SIGTSTP",    /* stop signal from tty */
+    "SIGCONT",    /* continue a stopped process */
+    "SIGCHLD",    /* to parent on child stop or exit */
+    "SIGTTIN",    /* to readers pgrp upon background tty read */
+    "SIGTTOU",    /* like TTIN if (tp->t_local&LTOSTOP) */
+    "SIGIO",      /* input/output possible signal */
+    "SIGXCPU",    /* exceeded CPU time limit */
+    "SIGXFSZ",    /* exceeded file size limit */
+    "SIGVTALRM",  /* virtual time alarm */
+    "SIGPROF",    /* profiling time alarm */
+    "SIGWINCH",   /* window size changes */
+    "SIGINFO",    /* information request */
+    "SIGUSR1",    /* user defined signal 1 */
+    "SIGUSR2"     /* user defined signal 2 */
+  };
+
+  public static String getSignalName(int sigNum) {
+    if ((sigNum <= 0) || (sigNum >= signalNames.length)) {
+      // Probably best to fail in a non-destructive way
+      return "<Error: Illegal signal number " + sigNum + ">";
+    }
+    return signalNames[sigNum];
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.runtime.bsd_amd64;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.amd64.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.runtime.amd64.*;
+import sun.jvm.hotspot.runtime.x86.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+public class BsdAMD64JavaThreadPDAccess implements JavaThreadPDAccess {
+  private static AddressField  lastJavaFPField;
+  private static AddressField  osThreadField;
+
+  // Field from OSThread
+  private static CIntegerField osThreadThreadIDField;
+
+  // This is currently unneeded but is being kept in case we change
+  // the currentFrameGuess algorithm
+  private static final long GUESS_SCAN_RANGE = 128 * 1024;
+
+  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("JavaThread");
+    osThreadField           = type.getAddressField("_osthread");
+
+    Type anchorType = db.lookupType("JavaFrameAnchor");
+    lastJavaFPField         = anchorType.getAddressField("_last_Java_fp");
+
+    Type osThreadType = db.lookupType("OSThread");
+    osThreadThreadIDField   = osThreadType.getCIntegerField("_thread_id");
+  }
+
+  public    Address getLastJavaFP(Address addr) {
+    return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset()));
+  }
+
+  public    Address getLastJavaPC(Address addr) {
+    return null;
+  }
+
+  public    Address getBaseOfStackPointer(Address addr) {
+    return null;
+  }
+
+  public    Frame getLastFramePD(JavaThread thread, Address addr) {
+    Address fp = thread.getLastJavaFP();
+    if (fp == null) {
+      return null; // no information
+    }
+    return new X86Frame(thread.getLastJavaSP(), fp);
+  }
+
+  public    RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
+    return new X86RegisterMap(thread, updateMap);
+  }
+
+  public    Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
+    ThreadProxy t = getThreadProxy(addr);
+    AMD64ThreadContext context = (AMD64ThreadContext) t.getContext();
+    AMD64CurrentFrameGuess guesser = new AMD64CurrentFrameGuess(context, thread);
+    if (!guesser.run(GUESS_SCAN_RANGE)) {
+      return null;
+    }
+    if (guesser.getPC() == null) {
+      return new X86Frame(guesser.getSP(), guesser.getFP());
+    } else {
+      return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
+    }
+  }
+
+  public    void printThreadIDOn(Address addr, PrintStream tty) {
+    tty.print(getThreadProxy(addr));
+  }
+
+  public    void printInfoOn(Address threadAddr, PrintStream tty) {
+    tty.print("Thread id: ");
+    printThreadIDOn(threadAddr, tty);
+//    tty.println("\nPostJavaState: " + getPostJavaState(threadAddr));
+  }
+
+  public    Address getLastSP(Address addr) {
+    ThreadProxy t = getThreadProxy(addr);
+    AMD64ThreadContext context = (AMD64ThreadContext) t.getContext();
+    return context.getRegisterAsAddress(AMD64ThreadContext.RSP);
+  }
+
+  public    ThreadProxy getThreadProxy(Address addr) {
+    // Addr is the address of the JavaThread.
+    // Fetch the OSThread (for now and for simplicity, not making a
+    // separate "OSThread" class in this package)
+    Address osThreadAddr = osThreadField.getValue(addr);
+    // Get the address of the _thread_id from the OSThread
+    Address threadIdAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());
+
+    JVMDebugger debugger = VM.getVM().getDebugger();
+    return debugger.getThreadForIdentifierAddress(threadIdAddr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_x86/BsdSignals.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime.bsd_x86;
+
+public class BsdSignals {
+  private static String[] signalNames = {
+    "",           /* No signal 0 */
+    "SIGHUP",     /* hangup */
+    "SIGINT",     /* interrupt */
+    "SIGQUIT",    /* quit */
+    "SIGILL",     /* illegal instr. (not reset when caught) */
+    "SIGTRAP",    /* trace trap (not reset when caught) */
+    "SIGABRT",    /* abort() */
+    "SIGEMT",     /* EMT instruction */
+    "SIGFPE",     /* floating point exception */
+    "SIGKILL",    /* kill (cannot be caught or ignored) */
+    "SIGBUS",     /* bus error */
+    "SIGSEGV",    /* segmentation violation */
+    "SIGSYS",     /* non-existent system call invoked */
+    "SIGPIPE",    /* write on a pipe with no one to read it */
+    "SIGALRM",    /* alarm clock */
+    "SIGTERM",    /* software termination signal from kill */
+    "SIGURG",     /* urgent condition on IO channel */
+    "SIGSTOP",    /* sendable stop signal not from tty */
+    "SIGTSTP",    /* stop signal from tty */
+    "SIGCONT",    /* continue a stopped process */
+    "SIGCHLD",    /* to parent on child stop or exit */
+    "SIGTTIN",    /* to readers pgrp upon background tty read */
+    "SIGTTOU",    /* like TTIN if (tp->t_local&LTOSTOP) */
+    "SIGIO",      /* input/output possible signal */
+    "SIGXCPU",    /* exceeded CPU time limit */
+    "SIGXFSZ",    /* exceeded file size limit */
+    "SIGVTALRM",  /* virtual time alarm */
+    "SIGPROF",    /* profiling time alarm */
+    "SIGWINCH",   /* window size changes */
+    "SIGINFO",    /* information request */
+    "SIGUSR1",    /* user defined signal 1 */
+    "SIGUSR2"     /* user defined signal 2 */
+  };
+
+  public static String getSignalName(int sigNum) {
+    if ((sigNum <= 0) || (sigNum >= signalNames.length)) {
+      // Probably best to fail in a non-destructive way
+      return "<Error: Illegal signal number " + sigNum + ">";
+    }
+    return signalNames[sigNum];
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_x86/BsdX86JavaThreadPDAccess.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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.runtime.bsd_x86;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.debugger.x86.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.runtime.x86.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+public class BsdX86JavaThreadPDAccess implements JavaThreadPDAccess {
+  private static AddressField  lastJavaFPField;
+  private static AddressField  osThreadField;
+
+  // Field from OSThread
+  private static CIntegerField osThreadThreadIDField;
+
+  // This is currently unneeded but is being kept in case we change
+  // the currentFrameGuess algorithm
+  private static final long GUESS_SCAN_RANGE = 128 * 1024;
+
+  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("JavaThread");
+    osThreadField           = type.getAddressField("_osthread");
+
+    Type anchorType = db.lookupType("JavaFrameAnchor");
+    lastJavaFPField         = anchorType.getAddressField("_last_Java_fp");
+
+    Type osThreadType = db.lookupType("OSThread");
+    osThreadThreadIDField   = osThreadType.getCIntegerField("_thread_id");
+  }
+
+  public    Address getLastJavaFP(Address addr) {
+    return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset()));
+  }
+
+  public    Address getLastJavaPC(Address addr) {
+    return null;
+  }
+
+  public    Address getBaseOfStackPointer(Address addr) {
+    return null;
+  }
+
+  public    Frame getLastFramePD(JavaThread thread, Address addr) {
+    Address fp = thread.getLastJavaFP();
+    if (fp == null) {
+      return null; // no information
+    }
+    return new X86Frame(thread.getLastJavaSP(), fp);
+  }
+
+  public    RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
+    return new X86RegisterMap(thread, updateMap);
+  }
+
+  public    Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
+    ThreadProxy t = getThreadProxy(addr);
+    X86ThreadContext context = (X86ThreadContext) t.getContext();
+    X86CurrentFrameGuess guesser = new X86CurrentFrameGuess(context, thread);
+    if (!guesser.run(GUESS_SCAN_RANGE)) {
+      return null;
+    }
+    if (guesser.getPC() == null) {
+      return new X86Frame(guesser.getSP(), guesser.getFP());
+    } else {
+      return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
+    }
+  }
+
+  public    void printThreadIDOn(Address addr, PrintStream tty) {
+    tty.print(getThreadProxy(addr));
+  }
+
+  public    void printInfoOn(Address threadAddr, PrintStream tty) {
+    tty.print("Thread id: ");
+    printThreadIDOn(threadAddr, tty);
+//    tty.println("\nPostJavaState: " + getPostJavaState(threadAddr));
+  }
+
+  public    Address getLastSP(Address addr) {
+    ThreadProxy t = getThreadProxy(addr);
+    X86ThreadContext context = (X86ThreadContext) t.getContext();
+    return context.getRegisterAsAddress(X86ThreadContext.ESP);
+  }
+
+  public    ThreadProxy getThreadProxy(Address addr) {
+    // Addr is the address of the JavaThread.
+    // Fetch the OSThread (for now and for simplicity, not making a
+    // separate "OSThread" class in this package)
+    Address osThreadAddr = osThreadField.getValue(addr);
+    // Get the address of the _thread_id from the OSThread
+    Address threadIdAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());
+
+    JVMDebugger debugger = VM.getVM().getDebugger();
+    return debugger.getThreadForIdentifierAddress(threadIdAddr);
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/linux_amd64/LinuxAMD64JavaThreadPDAccess.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/linux_amd64/LinuxAMD64JavaThreadPDAccess.java	Wed Oct 26 17:59:13 2011 -0700
@@ -30,6 +30,7 @@
 import sun.jvm.hotspot.debugger.amd64.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.runtime.amd64.*;
+import sun.jvm.hotspot.runtime.x86.*;
 import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;
 
@@ -80,11 +81,11 @@
     if (fp == null) {
       return null; // no information
     }
-    return new AMD64Frame(thread.getLastJavaSP(), fp);
+    return new X86Frame(thread.getLastJavaSP(), fp);
   }
 
   public    RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
-    return new AMD64RegisterMap(thread, updateMap);
+    return new X86RegisterMap(thread, updateMap);
   }
 
   public    Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
@@ -95,9 +96,9 @@
       return null;
     }
     if (guesser.getPC() == null) {
-      return new AMD64Frame(guesser.getSP(), guesser.getFP());
+      return new X86Frame(guesser.getSP(), guesser.getFP());
     } else {
-      return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
+      return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
     }
   }
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java	Wed Oct 26 17:59:13 2011 -0700
@@ -30,6 +30,7 @@
 import sun.jvm.hotspot.debugger.amd64.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.runtime.amd64.*;
+import sun.jvm.hotspot.runtime.x86.*;
 import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;
 
@@ -84,14 +85,14 @@
         }
         Address pc =  thread.getLastJavaPC();
         if ( pc != null ) {
-            return new AMD64Frame(thread.getLastJavaSP(), fp, pc);
+            return new X86Frame(thread.getLastJavaSP(), fp, pc);
         } else {
-            return new AMD64Frame(thread.getLastJavaSP(), fp);
+            return new X86Frame(thread.getLastJavaSP(), fp);
         }
     }
 
     public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
-        return new AMD64RegisterMap(thread, updateMap);
+        return new X86RegisterMap(thread, updateMap);
     }
 
     public Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
@@ -102,9 +103,9 @@
             return null;
         }
         if (guesser.getPC() == null) {
-            return new AMD64Frame(guesser.getSP(), guesser.getFP());
+            return new X86Frame(guesser.getSP(), guesser.getFP());
         } else {
-            return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
+            return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
         }
     }
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -236,7 +236,7 @@
       CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc);
       if (cb != null && cb.isJavaMethod()) {
         NMethod nm = (NMethod) cb;
-        if (pc.equals(nm.deoptBegin())) {
+        if (pc.equals(nm.deoptHandlerBegin())) {
           // adjust pc if frame is deoptimized.
           pc = this.getUnextendedSP().getAddressAt(nm.origPCOffset());
           deoptimized = true;
@@ -559,49 +559,46 @@
       }
     }
 
-    if (!VM.getVM().isCore()) {
-      // Note:  The version of this operation on any platform with callee-save
-      //        registers must update the register map (if not null).
-      //        In order to do this correctly, the various subtypes of
-      //        of frame (interpreted, compiled, glue, native),
-      //        must be distinguished.  There is no need on SPARC for
-      //        such distinctions, because all callee-save registers are
-      //        preserved for all frames via SPARC-specific mechanisms.
-      //
-      //        *** HOWEVER, *** if and when we make any floating-point
-      //        registers callee-saved, then we will have to copy over
-      //        the RegisterMap update logic from the Intel code.
+    // Note:  The version of this operation on any platform with callee-save
+    //        registers must update the register map (if not null).
+    //        In order to do this correctly, the various subtypes of
+    //        of frame (interpreted, compiled, glue, native),
+    //        must be distinguished.  There is no need on SPARC for
+    //        such distinctions, because all callee-save registers are
+    //        preserved for all frames via SPARC-specific mechanisms.
+    //
+    //        *** HOWEVER, *** if and when we make any floating-point
+    //        registers callee-saved, then we will have to copy over
+    //        the RegisterMap update logic from the Intel code.
 
+    if (isRicochetFrame()) return senderForRicochetFrame(map);
 
-      // The constructor of the sender must know whether this frame is interpreted so it can set the
-      // sender's _interpreter_sp_adjustment field.
-      if (VM.getVM().getInterpreter().contains(pc)) {
-        isInterpreted = true;
-        map.makeIntegerRegsUnsaved();
+    // The constructor of the sender must know whether this frame is interpreted so it can set the
+    // sender's _interpreter_sp_adjustment field.
+    if (VM.getVM().getInterpreter().contains(pc)) {
+      isInterpreted = true;
+      map.makeIntegerRegsUnsaved();
+      map.shiftWindow(sp, youngerSP);
+    } else {
+      // Find a CodeBlob containing this frame's pc or elide the lookup and use the
+      // supplied blob which is already known to be associated with this frame.
+      cb = VM.getVM().getCodeCache().findBlob(pc);
+      if (cb != null) {
+        // Update the location of all implicitly saved registers
+        // as the address of these registers in the register save
+        // area (for %o registers we use the address of the %i
+        // register in the next younger frame)
         map.shiftWindow(sp, youngerSP);
-      } else {
-        // Find a CodeBlob containing this frame's pc or elide the lookup and use the
-        // supplied blob which is already known to be associated with this frame.
-        cb = VM.getVM().getCodeCache().findBlob(pc);
-        if (cb != null) {
-
-          if (cb.callerMustGCArguments(map.getThread())) {
+        if (map.getUpdateMap()) {
+          if (cb.callerMustGCArguments()) {
             map.setIncludeArgumentOops(true);
           }
-
-          // Update the location of all implicitly saved registers
-          // as the address of these registers in the register save
-          // area (for %o registers we use the address of the %i
-          // register in the next younger frame)
-          map.shiftWindow(sp, youngerSP);
-          if (map.getUpdateMap()) {
-            if (cb.getOopMaps() != null) {
-              OopMapSet.updateRegisterMap(this, cb, map, VM.getVM().isDebugging());
-            }
+          if (cb.getOopMaps() != null) {
+            OopMapSet.updateRegisterMap(this, cb, map, VM.getVM().isDebugging());
           }
         }
       }
-    } // #ifndef CORE
+    }
 
     return new SPARCFrame(biasSP(sp), biasSP(youngerSP), isInterpreted);
   }
@@ -948,6 +945,20 @@
   }
 
 
+  private Frame senderForRicochetFrame(SPARCRegisterMap map) {
+    if (DEBUG) {
+      System.out.println("senderForRicochetFrame");
+    }
+    //RicochetFrame* f = RicochetFrame::from_frame(fr);
+    // Cf. is_interpreted_frame path of frame::sender
+    Address youngerSP = getSP();
+    Address sp        = getSenderSP();
+    map.makeIntegerRegsUnsaved();
+    map.shiftWindow(sp, youngerSP);
+    boolean thisFrameAdjustedStack = true;  // I5_savedSP is live in this RF
+    return new SPARCFrame(biasSP(sp), biasSP(youngerSP), thisFrameAdjustedStack);
+  }
+
   private Frame senderForEntryFrame(RegisterMap regMap) {
     SPARCRegisterMap map = (SPARCRegisterMap) regMap;
 
@@ -965,10 +976,8 @@
     Address lastJavaPC = jcw.getLastJavaPC();
     map.clear();
 
-    if (!VM.getVM().isCore()) {
-      map.makeIntegerRegsUnsaved();
-      map.shiftWindow(lastJavaSP, null);
-    }
+    map.makeIntegerRegsUnsaved();
+    map.shiftWindow(lastJavaSP, null);
 
     if (Assert.ASSERTS_ENABLED) {
       Assert.that(map.getIncludeArgumentOops(), "should be set by clear");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCRicochetFrame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime.sparc;
+
+import java.util.*;
+import sun.jvm.hotspot.asm.sparc.SPARCRegister;
+import sun.jvm.hotspot.asm.sparc.SPARCRegisters;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+
+public class SPARCRicochetFrame {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private SPARCFrame frame;
+
+  private static void initialize(TypeDataBase db) {
+    // Type type = db.lookupType("MethodHandles::RicochetFrame");
+
+  }
+
+  static SPARCRicochetFrame fromFrame(SPARCFrame f) {
+    return new SPARCRicochetFrame(f);
+  }
+
+  private SPARCRicochetFrame(SPARCFrame f) {
+    frame = f;
+  }
+
+  private Address registerValue(SPARCRegister reg) {
+    return frame.getSP().addOffsetTo(reg.spOffsetInSavedWindow()).getAddressAt(0);
+  }
+
+  public Address savedArgsBase() {
+    return registerValue(SPARCRegisters.L4);
+  }
+  public Address exactSenderSP() {
+    return registerValue(SPARCRegisters.I5);
+  }
+  public Address senderLink() {
+    return frame.getSenderSP();
+  }
+  public Address senderPC() {
+    return frame.getSenderPC();
+  }
+  public Address extendedSenderSP() {
+    return savedArgsBase();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/vmSymbols.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime;
+
+import java.io.*;
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.memory.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
+
+
+public class vmSymbols {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static Address symbolsAddress;
+  private static int FIRST_SID;
+  private static int SID_LIMIT;
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type            = db.lookupType("vmSymbols");
+    symbolsAddress       = type.getAddressField("_symbols[0]").getStaticFieldAddress();
+    FIRST_SID            = db.lookupIntConstant("vmSymbols::FIRST_SID");
+    SID_LIMIT            = db.lookupIntConstant("vmSymbols::SID_LIMIT");
+  }
+
+  public static Symbol symbolAt(int id) {
+    if (id < FIRST_SID || id >= SID_LIMIT) throw new IndexOutOfBoundsException("bad SID " + id);
+    return Symbol.create(symbolsAddress.getAddressAt(id * VM.getVM().getAddressSize()));
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/win32_amd64/Win32AMD64JavaThreadPDAccess.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/win32_amd64/Win32AMD64JavaThreadPDAccess.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,10 +27,10 @@
 import java.io.*;
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.win32.*;
 import sun.jvm.hotspot.debugger.amd64.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.runtime.amd64.*;
+import sun.jvm.hotspot.runtime.x86.*;
 import sun.jvm.hotspot.types.*;
 import sun.jvm.hotspot.utilities.*;
 
@@ -86,14 +86,14 @@
     }
     Address pc =  thread.getLastJavaPC();
     if ( pc != null ) {
-      return new AMD64Frame(thread.getLastJavaSP(), fp, pc);
+      return new X86Frame(thread.getLastJavaSP(), fp, pc);
     } else {
-      return new AMD64Frame(thread.getLastJavaSP(), fp);
+      return new X86Frame(thread.getLastJavaSP(), fp);
     }
   }
 
   public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
-    return new AMD64RegisterMap(thread, updateMap);
+    return new X86RegisterMap(thread, updateMap);
   }
 
   public Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
@@ -104,9 +104,9 @@
       return null;
     }
     if (guesser.getPC() == null) {
-      return new AMD64Frame(guesser.getSP(), guesser.getFP());
+      return new X86Frame(guesser.getSP(), guesser.getFP());
     } else {
-      return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
+      return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
     }
   }
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/win32_x86/Win32X86JavaThreadPDAccess.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/win32_x86/Win32X86JavaThreadPDAccess.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 import java.io.*;
 import java.util.*;
 import sun.jvm.hotspot.debugger.*;
-import sun.jvm.hotspot.debugger.win32.*;
 import sun.jvm.hotspot.debugger.x86.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.runtime.x86.*;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -25,7 +25,6 @@
 package sun.jvm.hotspot.runtime.x86;
 
 import java.util.*;
-import sun.jvm.hotspot.asm.x86.*;
 import sun.jvm.hotspot.code.*;
 import sun.jvm.hotspot.compiler.*;
 import sun.jvm.hotspot.debugger.*;
@@ -62,11 +61,13 @@
   private static       int INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET;
 
   // Entry frames
-  private static final int ENTRY_FRAME_CALL_WRAPPER_OFFSET   =  2;
+  private static       int ENTRY_FRAME_CALL_WRAPPER_OFFSET;
 
   // Native frames
   private static final int NATIVE_FRAME_INITIAL_PARAM_OFFSET =  2;
 
+  private static VMReg rbp;
+
   static {
     VM.registerVMInitializedObserver(new Observer() {
         public void update(Observable o, Object data) {
@@ -76,19 +77,23 @@
   }
 
   private static synchronized void initialize(TypeDataBase db) {
-    if (VM.getVM().isCore()) {
-      INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_METHOD_OFFSET - 1;
-    } else {
-      INTERPRETER_FRAME_MDX_OFFSET   = INTERPRETER_FRAME_METHOD_OFFSET - 1;
-      INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_MDX_OFFSET - 1;
-    }
+    INTERPRETER_FRAME_MDX_OFFSET                  = INTERPRETER_FRAME_METHOD_OFFSET - 1;
+    INTERPRETER_FRAME_CACHE_OFFSET                = INTERPRETER_FRAME_MDX_OFFSET - 1;
     INTERPRETER_FRAME_LOCALS_OFFSET               = INTERPRETER_FRAME_CACHE_OFFSET - 1;
     INTERPRETER_FRAME_BCX_OFFSET                  = INTERPRETER_FRAME_LOCALS_OFFSET - 1;
     INTERPRETER_FRAME_INITIAL_SP_OFFSET           = INTERPRETER_FRAME_BCX_OFFSET - 1;
     INTERPRETER_FRAME_MONITOR_BLOCK_TOP_OFFSET    = INTERPRETER_FRAME_INITIAL_SP_OFFSET;
     INTERPRETER_FRAME_MONITOR_BLOCK_BOTTOM_OFFSET = INTERPRETER_FRAME_INITIAL_SP_OFFSET;
+
+    ENTRY_FRAME_CALL_WRAPPER_OFFSET = db.lookupIntConstant("frame::entry_frame_call_wrapper_offset");
+    if (VM.getVM().getAddressSize() == 4) {
+      rbp = new VMReg(5);
+    } else {
+      rbp = new VMReg(5 << 1);
+    }
   }
 
+
   // an additional field beyond sp and pc:
   Address raw_fp; // frame pointer
   private Address raw_unextendedSP;
@@ -102,7 +107,7 @@
       CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc);
       if (cb != null && cb.isJavaMethod()) {
         NMethod nm = (NMethod) cb;
-        if (pc.equals(nm.deoptBegin())) {
+        if (pc.equals(nm.deoptHandlerBegin())) {
           if (Assert.ASSERTS_ENABLED) {
             Assert.that(this.getUnextendedSP() != null, "null SP in Java frame");
           }
@@ -119,6 +124,7 @@
     this.raw_unextendedSP = raw_sp;
     this.raw_fp = raw_fp;
     this.pc = pc;
+    adjustUnextendedSP();
 
     // Frame must be fully constructed before this call
     adjustForDeopt();
@@ -134,6 +140,7 @@
     this.raw_unextendedSP = raw_sp;
     this.raw_fp = raw_fp;
     this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
+    adjustUnextendedSP();
 
     // Frame must be fully constructed before this call
     adjustForDeopt();
@@ -144,24 +151,18 @@
     }
   }
 
-  // This constructor should really take the unextended SP as an arg
-  // but then the constructor is ambiguous with constructor that takes
-  // a PC so take an int and convert it.
-  public X86Frame(Address raw_sp, Address raw_fp, long extension) {
+  public X86Frame(Address raw_sp, Address raw_unextendedSp, Address raw_fp, Address pc) {
     this.raw_sp = raw_sp;
-    if (raw_sp == null) {
-      this.raw_unextendedSP = null;
-    } else {
-      this.raw_unextendedSP = raw_sp.addOffsetTo(extension);
-    }
+    this.raw_unextendedSP = raw_unextendedSp;
     this.raw_fp = raw_fp;
-    this.pc = raw_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
+    this.pc = pc;
+    adjustUnextendedSP();
 
     // Frame must be fully constructed before this call
     adjustForDeopt();
 
     if (DEBUG) {
-      System.out.println("X86Frame(sp, fp): " + this);
+      System.out.println("X86Frame(sp, unextendedSP, fp, pc): " + this);
       dumpStack();
     }
 
@@ -172,7 +173,6 @@
     frame.raw_sp = raw_sp;
     frame.raw_unextendedSP = raw_unextendedSP;
     frame.raw_fp = raw_fp;
-    frame.raw_fp = raw_fp;
     frame.pc = pc;
     frame.deoptimized = deoptimized;
     return frame;
@@ -269,19 +269,18 @@
 
     if (isEntryFrame())       return senderForEntryFrame(map);
     if (isInterpretedFrame()) return senderForInterpreterFrame(map);
+    if (isRicochetFrame())    return senderForRicochetFrame(map);
 
-    if (!VM.getVM().isCore()) {
-      if(cb == null) {
-        cb = VM.getVM().getCodeCache().findBlob(getPC());
-      } else {
-        if (Assert.ASSERTS_ENABLED) {
-          Assert.that(cb.equals(VM.getVM().getCodeCache().findBlob(getPC())), "Must be the same");
-        }
+    if(cb == null) {
+      cb = VM.getVM().getCodeCache().findBlob(getPC());
+    } else {
+      if (Assert.ASSERTS_ENABLED) {
+        Assert.that(cb.equals(VM.getVM().getCodeCache().findBlob(getPC())), "Must be the same");
       }
+    }
 
-      if (cb != null) {
-         return senderForCompiledFrame(map, cb);
-      }
+    if (cb != null) {
+      return senderForCompiledFrame(map, cb);
     }
 
     // Must be native-compiled frame, i.e. the marshaling code for native
@@ -289,7 +288,20 @@
     return new X86Frame(getSenderSP(), getLink(), getSenderPC());
   }
 
+  private Frame senderForRicochetFrame(X86RegisterMap map) {
+    if (DEBUG) {
+      System.out.println("senderForRicochetFrame");
+    }
+    X86RicochetFrame f = X86RicochetFrame.fromFrame(this);
+    if (map.getUpdateMap())
+      updateMapWithSavedLink(map, f.senderLinkAddress());
+    return new X86Frame(f.extendedSenderSP(), f.exactSenderSP(), f.senderLink(), f.senderPC());
+  }
+
   private Frame senderForEntryFrame(X86RegisterMap map) {
+    if (DEBUG) {
+      System.out.println("senderForEntryFrame");
+    }
     if (Assert.ASSERTS_ENABLED) {
       Assert.that(map != null, "map must be set");
     }
@@ -313,7 +325,37 @@
     return fr;
   }
 
+  //------------------------------------------------------------------------------
+  // frame::adjust_unextended_sp
+  private void adjustUnextendedSP() {
+    // If we are returning to a compiled MethodHandle call site, the
+    // saved_fp will in fact be a saved value of the unextended SP.  The
+    // simplest way to tell whether we are returning to such a call site
+    // is as follows:
+
+    CodeBlob cb = cb();
+    NMethod senderNm = (cb == null) ? null : cb.asNMethodOrNull();
+    if (senderNm != null) {
+      // If the sender PC is a deoptimization point, get the original
+      // PC.  For MethodHandle call site the unextended_sp is stored in
+      // saved_fp.
+      if (senderNm.isDeoptMhEntry(getPC())) {
+        // DEBUG_ONLY(verifyDeoptMhOriginalPc(senderNm, getFP()));
+        raw_unextendedSP = getFP();
+      }
+      else if (senderNm.isDeoptEntry(getPC())) {
+        // DEBUG_ONLY(verifyDeoptOriginalPc(senderNm, raw_unextendedSp));
+      }
+      else if (senderNm.isMethodHandleReturn(getPC())) {
+        raw_unextendedSP = getFP();
+      }
+    }
+  }
+
   private Frame senderForInterpreterFrame(X86RegisterMap map) {
+    if (DEBUG) {
+      System.out.println("senderForInterpreterFrame");
+    }
     Address unextendedSP = addressOfStackSlot(INTERPRETER_FRAME_SENDER_SP_OFFSET).getAddressAt(0);
     Address sp = addressOfStackSlot(SENDER_SP_OFFSET);
     // We do not need to update the callee-save register mapping because above
@@ -323,10 +365,21 @@
     // However c2 no longer uses callee save register for java calls so there
     // are no callee register to find.
 
-    return new X86Frame(sp, getLink(), unextendedSP.minus(sp));
+    if (map.getUpdateMap())
+      updateMapWithSavedLink(map, addressOfStackSlot(LINK_OFFSET));
+
+    return new X86Frame(sp, unextendedSP, getLink(), getSenderPC());
+  }
+
+  private void updateMapWithSavedLink(RegisterMap map, Address savedFPAddr) {
+    map.setLocation(rbp, savedFPAddr);
   }
 
   private Frame senderForCompiledFrame(X86RegisterMap map, CodeBlob cb) {
+    if (DEBUG) {
+      System.out.println("senderForCompiledFrame");
+    }
+
     //
     // NOTE: some of this code is (unfortunately) duplicated in X86CurrentFrameGuess
     //
@@ -336,41 +389,35 @@
     }
 
     // frame owned by optimizing compiler
-    Address        sender_sp = null;
-
-    if (VM.getVM().isClientCompiler()) {
-      sender_sp        = addressOfStackSlot(SENDER_SP_OFFSET);
-    } else {
-      if (Assert.ASSERTS_ENABLED) {
-        Assert.that(cb.getFrameSize() >= 0, "Compiled by Compiler1: do not use");
-      }
-      sender_sp = getUnextendedSP().addOffsetTo(cb.getFrameSize());
+    if (Assert.ASSERTS_ENABLED) {
+        Assert.that(cb.getFrameSize() >= 0, "must have non-zero frame size");
     }
+    Address senderSP = getUnextendedSP().addOffsetTo(cb.getFrameSize());
 
     // On Intel the return_address is always the word on the stack
-    Address sender_pc = sender_sp.getAddressAt(-1 * VM.getVM().getAddressSize());
+    Address senderPC = senderSP.getAddressAt(-1 * VM.getVM().getAddressSize());
+
+    // This is the saved value of EBP which may or may not really be an FP.
+    // It is only an FP if the sender is an interpreter frame (or C1?).
+    Address savedFPAddr = senderSP.addOffsetTo(- SENDER_SP_OFFSET * VM.getVM().getAddressSize());
 
-    if (map.getUpdateMap() && cb.getOopMaps() != null) {
-      OopMapSet.updateRegisterMap(this, cb, map, true);
+    if (map.getUpdateMap()) {
+      // Tell GC to use argument oopmaps for some runtime stubs that need it.
+      // For C1, the runtime stub might not have oop maps, so set this flag
+      // outside of update_register_map.
+      map.setIncludeArgumentOops(cb.callerMustGCArguments());
+
+      if (cb.getOopMaps() != null) {
+        OopMapSet.updateRegisterMap(this, cb, map, true);
+      }
+
+      // Since the prolog does the save and restore of EBP there is no oopmap
+      // for it so we must fill in its location as if there was an oopmap entry
+      // since if our caller was compiled code there could be live jvm state in it.
+      updateMapWithSavedLink(map, savedFPAddr);
     }
 
-    if (VM.getVM().isClientCompiler()) {
-      // Move this here for C1 and collecting oops in arguments (According to Rene)
-      map.setIncludeArgumentOops(cb.callerMustGCArguments(map.getThread()));
-    }
-
-    Address saved_fp = null;
-    if (VM.getVM().isClientCompiler()) {
-      saved_fp = getFP().getAddressAt(0);
-    } else if (VM.getVM().isServerCompiler() &&
-               (VM.getVM().getInterpreter().contains(sender_pc) ||
-               VM.getVM().getStubRoutines().returnsToCallStub(sender_pc))) {
-      // C2 prologue saves EBP in the usual place.
-      // however only use it if the sender had link infomration in it.
-      saved_fp = sender_sp.getAddressAt(-2 * VM.getVM().getAddressSize());
-    }
-
-    return new X86Frame(sender_sp, saved_fp, sender_pc);
+    return new X86Frame(senderSP, savedFPAddr.getAddressAt(0), senderPC);
   }
 
   protected boolean hasSenderPD() {
@@ -403,14 +450,6 @@
 
   public Address getSenderSP()     { return addressOfStackSlot(SENDER_SP_OFFSET); }
 
-  public Address compiledArgumentToLocationPD(VMReg reg, RegisterMap regMap, int argSize) {
-    if (VM.getVM().isCore() || VM.getVM().isClientCompiler()) {
-      throw new RuntimeException("Should not reach here");
-    }
-
-    return oopMapRegToLocation(reg, regMap);
-  }
-
   public Address addressOfInterpreterFrameLocals() {
     return addressOfStackSlot(INTERPRETER_FRAME_LOCALS_OFFSET);
   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86RicochetFrame.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime.x86;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+
+public class X86RicochetFrame extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static void initialize(TypeDataBase db) {
+    Type type = db.lookupType("MethodHandles::RicochetFrame");
+
+    senderLinkField    = type.getAddressField("_sender_link");
+    savedArgsBaseField = type.getAddressField("_saved_args_base");
+    exactSenderSPField = type.getAddressField("_exact_sender_sp");
+    senderPCField      = type.getAddressField("_sender_pc");
+  }
+
+  private static AddressField senderLinkField;
+  private static AddressField savedArgsBaseField;
+  private static AddressField exactSenderSPField;
+  private static AddressField senderPCField;
+
+  static X86RicochetFrame fromFrame(X86Frame f) {
+    return new X86RicochetFrame(f.getFP().addOffsetTo(- senderLinkField.getOffset()));
+  }
+
+  private X86RicochetFrame(Address addr) {
+    super(addr);
+  }
+
+  public Address senderLink() {
+    return senderLinkField.getValue(addr);
+  }
+  public Address senderLinkAddress() {
+    return addr.addOffsetTo(senderLinkField.getOffset());
+  }
+  public Address savedArgsBase() {
+    return savedArgsBaseField.getValue(addr);
+  }
+  public Address extendedSenderSP() {
+    return savedArgsBase();
+  }
+  public Address exactSenderSP() {
+    return exactSenderSPField.getValue(addr);
+  }
+  public Address senderPC() {
+    return senderPCField.getValue(addr);
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,11 +26,11 @@
 
 import java.util.*;
 import sun.jvm.hotspot.gc_interface.*;
+import sun.jvm.hotspot.gc_implementation.g1.*;
 import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
 import sun.jvm.hotspot.gc_implementation.shared.*;
 import sun.jvm.hotspot.memory.*;
 import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.tools.*;
 
 public class HeapSummary extends Tool {
 
@@ -70,32 +70,45 @@
       System.out.println();
       System.out.println("Heap Usage:");
 
-      if (heap instanceof GenCollectedHeap) {
-         GenCollectedHeap genHeap = (GenCollectedHeap) heap;
-         for (int n = 0; n < genHeap.nGens(); n++) {
-            Generation gen = genHeap.getGen(n);
-            if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
-               System.out.println("New Generation (Eden + 1 Survivor Space):");
-               printGen(gen);
+      if (heap instanceof SharedHeap) {
+         SharedHeap sharedHeap = (SharedHeap) heap;
+         if (sharedHeap instanceof GenCollectedHeap) {
+            GenCollectedHeap genHeap = (GenCollectedHeap) sharedHeap;
+            for (int n = 0; n < genHeap.nGens(); n++) {
+               Generation gen = genHeap.getGen(n);
+               if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
+                  System.out.println("New Generation (Eden + 1 Survivor Space):");
+                  printGen(gen);
 
-               ContiguousSpace eden = ((DefNewGeneration)gen).eden();
-               System.out.println("Eden Space:");
-               printSpace(eden);
+                  ContiguousSpace eden = ((DefNewGeneration)gen).eden();
+                  System.out.println("Eden Space:");
+                  printSpace(eden);
+
+                  ContiguousSpace from = ((DefNewGeneration)gen).from();
+                  System.out.println("From Space:");
+                  printSpace(from);
 
-               ContiguousSpace from = ((DefNewGeneration)gen).from();
-               System.out.println("From Space:");
-               printSpace(from);
-
-               ContiguousSpace to = ((DefNewGeneration)gen).to();
-               System.out.println("To Space:");
-               printSpace(to);
-            } else {
-               System.out.println(gen.name() + ":");
-               printGen(gen);
+                  ContiguousSpace to = ((DefNewGeneration)gen).to();
+                  System.out.println("To Space:");
+                  printSpace(to);
+               } else {
+                  System.out.println(gen.name() + ":");
+                  printGen(gen);
+               }
             }
+         } else if (sharedHeap instanceof G1CollectedHeap) {
+             G1CollectedHeap g1h = (G1CollectedHeap) sharedHeap;
+             G1MonitoringSupport g1mm = g1h.g1mm();
+             System.out.println("G1 Young Generation");
+             printG1Space("Eden Space:", g1mm.edenUsed(), g1mm.edenCommitted());
+             printG1Space("From Space:", g1mm.survivorUsed(), g1mm.survivorCommitted());
+             printG1Space("To Space:", 0, 0);
+             printG1Space("G1 Old Generation", g1mm.oldUsed(), g1mm.oldCommitted());
+         } else {
+             throw new RuntimeException("unknown SharedHeap type : " + heap.getClass());
          }
-         // Perm generation
-         Generation permGen = genHeap.permGen();
+         // Perm generation shared by the above
+         Generation permGen = sharedHeap.permGen();
          System.out.println("Perm Generation:");
          printGen(permGen);
       } else if (heap instanceof ParallelScavengeHeap) {
@@ -119,7 +132,7 @@
          printValMB("free     = ", permFree);
          System.out.println(alignment + (double)permGen.used() * 100.0 / permGen.capacity() + "% used");
       } else {
-         throw new RuntimeException("unknown heap type : " + heap.getClass());
+         throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
       }
    }
 
@@ -151,6 +164,14 @@
           return;
        }
 
+       l = getFlagValue("UseG1GC", flagMap);
+       if (l == 1L) {
+           System.out.print("Garbage-First (G1) GC ");
+           l = getFlagValue("ParallelGCThreads", flagMap);
+           System.out.println("with " + l + " thread(s)");
+           return;
+       }
+
        System.out.println("Mark Sweep Compact GC");
    }
 
@@ -191,6 +212,16 @@
       System.out.println(alignment +  (double)space.used() * 100.0 / space.capacity() + "% used");
    }
 
+   private void printG1Space(String spaceName, long used, long capacity) {
+      long free = capacity - used;
+      System.out.println(spaceName);
+      printValMB("capacity = ", capacity);
+      printValMB("used     = ", used);
+      printValMB("free     = ", free);
+      double occPerc = (capacity > 0) ? (double) used * 100.0 / capacity : 0.0;
+      System.out.println(alignment + occPerc + "% used");
+   }
+
    private static final double FACTOR = 1024*1024;
    private void printValMB(String title, long value) {
       if (value < 0) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,9 @@
 package sun.jvm.hotspot.tools.jcore;
 
 import java.io.*;
+import java.util.jar.JarOutputStream;
+import java.util.jar.JarEntry;
+import java.util.jar.Manifest;
 import sun.jvm.hotspot.memory.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.debugger.*;
@@ -34,27 +37,33 @@
 public class ClassDump extends Tool {
     private ClassFilter classFilter;
     private String      outputDirectory;
+    private JarOutputStream jarStream;
+
+    public void setClassFilter(ClassFilter cf) {
+        classFilter = cf;
+    }
+
+    public void setOutputDirectory(String od) {
+        outputDirectory = od;
+        if (jarStream != null) {
+            try {
+                jarStream.close();
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+            }
+        }
+        jarStream = null;
+    }
+
+    public void setJarOutput(String jarFileName) throws IOException {
+        jarStream = new JarOutputStream(new FileOutputStream(jarFileName), new Manifest());
+        outputDirectory = null;
+    }
 
     public void run() {
         // Ready to go with the database...
         try {
 
-            // load class filters
-
-            String filterClassName = System.getProperty("sun.jvm.hotspot.tools.jcore.filter");
-            if (filterClassName != null) {
-                try {
-                    Class filterClass = Class.forName(filterClassName);
-                    classFilter = (ClassFilter) filterClass.newInstance();
-                } catch(Exception exp) {
-                    System.err.println("Warning: Can not create class filter!");
-                }
-            }
-
-            outputDirectory = System.getProperty("sun.jvm.hotspot.tools.jcore.outputDir");
-            if (outputDirectory == null)
-                outputDirectory = ".";
-
             // walk through the system dictionary
             SystemDictionary dict = VM.getVM().getSystemDictionary();
             dict.classesDo(new SystemDictionary.ClassVisitor() {
@@ -75,6 +84,14 @@
                                + Long.toHexString(e.getAddress()));
             e.printStackTrace();
         }
+        if (jarStream != null) {
+            try {
+                jarStream.close();
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+            }
+            jarStream = null;
+        }
     }
 
     public String getName() {
@@ -88,26 +105,33 @@
 
         String klassName = kls.getName().asString();
         klassName = klassName.replace('/', File.separatorChar);
-        int index = klassName.lastIndexOf(File.separatorChar);
-        File dir = null;
-        if (index != -1) {
-            String dirName = klassName.substring(0, index);
-            dir =  new File(outputDirectory,  dirName);
-        } else {
-            dir = new File(outputDirectory);
-        }
+        try {
+            OutputStream os = null;
+            if (jarStream != null) {
+                jarStream.putNextEntry(new JarEntry(klassName + ".class"));
+                os = jarStream;
+            } else {
+                int index = klassName.lastIndexOf(File.separatorChar);
+                File dir = null;
+                if (index != -1) {
+                    String dirName = klassName.substring(0, index);
+                    dir = new File(outputDirectory,  dirName);
+                } else {
+                    dir = new File(outputDirectory);
+                }
 
-        dir.mkdirs();
-        File f = new File(dir, klassName.substring(klassName.lastIndexOf(File.separatorChar) + 1)
-                          + ".class");
-        try {
-            f.createNewFile();
-            OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
+                dir.mkdirs();
+                File f = new File(dir, klassName.substring(index + 1) + ".class");
+                f.createNewFile();
+                os = new BufferedOutputStream(new FileOutputStream(f));
+            }
             try {
                 ClassWriter cw = new ClassWriter(kls, os);
                 cw.write();
             } finally {
-                os.close();
+                if (os != jarStream) {
+                    os.close();
+                }
             }
         } catch(IOException exp) {
             exp.printStackTrace();
@@ -115,7 +139,26 @@
     }
 
     public static void main(String[] args) {
+        // load class filters
+        ClassFilter classFilter = null;
+        String filterClassName = System.getProperty("sun.jvm.hotspot.tools.jcore.filter");
+        if (filterClassName != null) {
+            try {
+                Class filterClass = Class.forName(filterClassName);
+                classFilter = (ClassFilter) filterClass.newInstance();
+            } catch(Exception exp) {
+                System.err.println("Warning: Can not create class filter!");
+            }
+        }
+
+        String outputDirectory = System.getProperty("sun.jvm.hotspot.tools.jcore.outputDir");
+        if (outputDirectory == null)
+            outputDirectory = ".";
+
+
         ClassDump cd = new ClassDump();
+        cd.setClassFilter(classFilter);
+        cd.setOutputDirectory(outputDirectory);
         cd.start(args);
         cd.stop();
     }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java	Wed Oct 26 17:59:13 2011 -0700
@@ -379,23 +379,21 @@
     }
 
     protected void writeFields() throws IOException {
-        TypeArray fields = klass.getFields();
-        final int length = (int) fields.getLength();
+        final int length = klass.getJavaFieldsCount();
 
         // write number of fields
-        dos.writeShort((short) (length / InstanceKlass.NEXT_OFFSET) );
+        dos.writeShort((short) length);
 
-        if (DEBUG) debugMessage("number of fields = "
-                                + length/InstanceKlass.NEXT_OFFSET);
+        if (DEBUG) debugMessage("number of fields = " + length);
 
-        for (int index = 0; index < length; index += InstanceKlass.NEXT_OFFSET) {
-            short accessFlags    = fields.getShortAt(index + InstanceKlass.ACCESS_FLAGS_OFFSET);
+        for (int index = 0; index < length; index++) {
+            short accessFlags    = klass.getFieldAccessFlags(index);
             dos.writeShort(accessFlags & (short) JVM_RECOGNIZED_FIELD_MODIFIERS);
 
-            short nameIndex    = fields.getShortAt(index + InstanceKlass.NAME_INDEX_OFFSET);
+            short nameIndex    = klass.getFieldNameIndex(index);
             dos.writeShort(nameIndex);
 
-            short signatureIndex = fields.getShortAt(index + InstanceKlass.SIGNATURE_INDEX_OFFSET);
+            short signatureIndex = klass.getFieldSignatureIndex(index);
             dos.writeShort(signatureIndex);
             if (DEBUG) debugMessage("\tfield name = " + nameIndex + ", signature = " + signatureIndex);
 
@@ -404,11 +402,11 @@
             if (hasSyn)
                 fieldAttributeCount++;
 
-            short initvalIndex = fields.getShortAt(index + InstanceKlass.INITVAL_INDEX_OFFSET);
+            short initvalIndex = klass.getFieldInitialValueIndex(index);
             if (initvalIndex != 0)
                 fieldAttributeCount++;
 
-            short genSigIndex = fields.getShortAt(index + InstanceKlass.GENERIC_SIGNATURE_INDEX_OFFSET);
+            short genSigIndex = klass.getFieldGenericSignatureIndex(index);
             if (genSigIndex != 0)
                 fieldAttributeCount++;
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java	Wed Oct 26 17:59:13 2011 -0700
@@ -150,16 +150,13 @@
             }
 
             // list immediate fields only
-            TypeArray fields = klass.getFields();
-            int numFields = (int) fields.getLength();
+            int numFields = klass.getJavaFieldsCount();
             ConstantPool cp = klass.getConstants();
             out.println("fields");
             if (numFields != 0) {
-               for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET) {
-                 int nameIndex = fields.getShortAt(f + InstanceKlass.NAME_INDEX_OFFSET);
-                 int sigIndex  = fields.getShortAt(f + InstanceKlass.SIGNATURE_INDEX_OFFSET);
-                 Symbol f_name = cp.getSymbolAt(nameIndex);
-                 Symbol f_sig  = cp.getSymbolAt(sigIndex);
+              for (int f = 0; f < numFields; f++){
+                 Symbol f_name = klass.getFieldName(f);
+                 Symbol f_sig  = klass.getFieldSignature(f);
                  StringBuffer sigBuf = new StringBuffer();
                  new SignatureConverter(f_sig, sigBuf).dispatchField();
                  out.print('\t');
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/TypeDataBase.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/TypeDataBase.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -120,6 +120,11 @@
       found. */
   public Type guessTypeForAddress(Address addr);
 
+  /** Helper routine for guessing the most derived type of a
+      polymorphic C++ object. Requires a baseType that must be virtual
+      so that lookup can be performed without false positives */
+  public Type findDynamicTypeForAddress(Address addr, Type baseType);
+
   /** Returns an Iterator over the Types in the database. */
   public Iterator getTypes();
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -150,6 +150,19 @@
     return VM.getVM().getOopSize();
   }
 
+  static HashMap typeToVtbl = new HashMap();
+
+  private Address vtblForType(Type type) {
+    Address vtblAddr = (Address)typeToVtbl.get(type);
+    if (vtblAddr == null) {
+      vtblAddr = vtblAccess.getVtblForType(type);
+      if (vtblAddr != null) {
+        typeToVtbl.put(type, vtblAddr);
+      }
+    }
+    return vtblAddr;
+  }
+
   public boolean addressTypeIsEqualToType(Address addr, Type type) {
     if (addr == null) {
       return false;
@@ -158,7 +171,7 @@
     // This implementation should be suitably platform-independent; we
     // search nearby memory for the vtbl value of the given type.
 
-    Address vtblAddr = vtblAccess.getVtblForType(type);
+    Address vtblAddr = vtblForType(type);
 
     if (vtblAddr == null) {
       // Type was not polymorphic, or an error occurred during lookup
@@ -251,6 +264,78 @@
     return false;
   }
 
+  public Type findDynamicTypeForAddress(Address addr, Type baseType) {
+    // This implementation should be suitably platform-independent; we
+    // search nearby memory for the vtbl value of the given type.
+
+    if (vtblForType(baseType) == null) {
+      // Type was not polymorphic which is an error of some sort
+      throw new InternalError(baseType + " does not appear to be polymorphic");
+    }
+
+    // This is a more restricted version of guessTypeForAddress since
+    // that function has some limitations since it doesn't really know
+    // where in the hierarchy a virtual type starts and just poking
+    // around in memory is likely to trip over some vtable address,
+    // resulting in false positives.  Eventually all uses should
+    // switch to this logic but in the interests of stability it will
+    // be separate for the moment.
+
+    // Assuming that the base type is truly the first polymorphic type
+    // then the vtbl for all subclasss should be at several defined
+    // locations so only those locations will be checked.  It's also
+    // required that the caller knows that the static type is at least
+    // baseType.  See the notes in guessTypeForAddress for the logic of
+    // the locations searched.
+
+    Address loc1 = addr.getAddressAt(0);
+    Address loc2 = null;
+    Address loc3 = null;
+    long offset2 = baseType.getSize();
+    // I don't think this should be misaligned under any
+    // circumstances, but I'm not sure (FIXME: also not sure which
+    // way to go here, up or down -- assuming down)
+    offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize();
+    if (offset2 > 0) {
+      loc2 = addr.getAddressAt(offset2);
+    }
+    long offset3 = offset2 - getAddressSize();
+    if (offset3 > 0) {
+      loc3 = addr.getAddressAt(offset3);
+    }
+
+    Type loc2Match = null;
+    Type loc3Match = null;
+    for (Iterator iter = getTypes(); iter.hasNext(); ) {
+      Type type = (Type) iter.next();
+      Type superClass = type;
+      while (superClass != baseType && superClass != null) {
+        superClass = superClass.getSuperclass();
+      }
+      if (superClass == null) continue;
+      Address vtblAddr = vtblForType(type);
+      if (vtblAddr == null) {
+        // This occurs sometimes for intermediate types that are never
+        // instantiated.
+        if (DEBUG) {
+          System.err.println("null vtbl for " + type);
+        }
+        continue;
+      }
+      // Prefer loc1 match
+      if (vtblAddr.equals(loc1)) return type;
+      if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) {
+          loc2Match = type;
+      }
+      if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) {
+          loc3Match = type;
+      }
+    }
+    if (loc2Match != null) return loc2Match;
+    if (loc3Match != null) return loc3Match;
+    return null;
+  }
+
   public Type guessTypeForAddress(Address addr) {
     for (Iterator iter = getTypes(); iter.hasNext(); ) {
       Type t = (Type) iter.next();
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/CommandProcessorPanel.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/CommandProcessorPanel.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,7 +88,7 @@
                                     public void run() {
                                         beginUpdate();
                                         try {
-                                            commands.executeCommand(ln);
+                                            commands.executeCommand(ln, true);
                                             commands.printPrompt();
                                             Document d = editor.getDocument();
                                             try {
@@ -149,7 +149,7 @@
     public void clear() {
         EditableAtEndDocument d = (EditableAtEndDocument) editor.getDocument();
         d.clear();
-        commands.executeCommand("");
+        commands.executeCommand("", false);
         setMark();
         editor.requestFocus();
     }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1116,20 +1116,15 @@
                 InstanceKlass kls = (InstanceKlass) obj;
                 buf.append(" " + kls.getName().asString() + "={");
                 int flen = ov.fieldsSize();
-
-                TypeArray klfields = kls.getFields();
-                int klen = (int) klfields.getLength();
-
-                ConstantPool cp = kls.getConstants();
+                int klen = kls.getJavaFieldsCount();
                 int findex = 0;
-                for (int index = 0; index < klen; index += kls.NEXT_OFFSET) {
-                    int accsFlags = klfields.getShortAt(index + kls.ACCESS_FLAGS_OFFSET);
-                    int nameIndex = klfields.getShortAt(index + kls.NAME_INDEX_OFFSET);
+                for (int index = 0; index < klen; index++) {
+                    int accsFlags = kls.getFieldAccessFlags(index);
+                    Symbol f_name = kls.getFieldName(index);
                     AccessFlags access = new AccessFlags(accsFlags);
                     if (!access.isStatic()) {
                         ScopeValue svf = ov.getFieldAt(findex++);
                         String    fstr = scopeValueAsString(sd, svf);
-                        Symbol f_name  = cp.getSymbolAt(nameIndex);
                         buf.append(" [" + f_name.asString() + " :"+ index + "]=(#" + fstr + ")");
                     }
                 }
@@ -1819,13 +1814,11 @@
 
    protected String genHTMLListForFields(InstanceKlass klass) {
       Formatter buf = new Formatter(genHTML);
-      TypeArray fields = klass.getFields();
-      int numFields = (int) fields.getLength();
-      ConstantPool cp = klass.getConstants();
+      int numFields = klass.getJavaFieldsCount();
       if (numFields != 0) {
          buf.h3("Fields");
          buf.beginList();
-         for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET) {
+         for (int f = 0; f < numFields; f++) {
            sun.jvm.hotspot.oops.Field field = klass.getFieldByIndex(f);
            String f_name = ((NamedFieldIdentifier)field.getID()).getName();
            Symbol f_sig  = field.getSignature();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/GenericGrowableArray.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.utilities;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class GenericGrowableArray extends VMObject {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("GenericGrowableArray");
+    _arena_field = type.getAddressField("_arena");
+    _max_field = new CIntField(type.getCIntegerField("_max"), 0);
+    _len_field = new CIntField(type.getCIntegerField("_len"), 0);
+  }
+
+  private static AddressField _arena_field;
+  private static CIntField _max_field;
+  private static CIntField _len_field;
+
+  public int max() {
+    return (int)_max_field.getValue(getAddress());
+  }
+
+  public int length() {
+    return (int)_len_field.getValue(getAddress());
+  }
+
+  public GenericGrowableArray(Address addr) {
+    super(addr);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+package sun.jvm.hotspot.utilities;
+
+import java.util.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.oops.*;
+import sun.jvm.hotspot.types.*;
+
+public class GrowableArray<T> extends GenericGrowableArray {
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+    Type type      = db.lookupType("GrowableArray<int>");
+    dataField = type.getAddressField("_data");
+  }
+
+  private static AddressField dataField;
+
+  private InstanceConstructor<T> virtualConstructor;
+
+  public static <S> GrowableArray<S> create(Address addr, InstanceConstructor<S> v) {
+    if (addr == null) return null;
+    return new GrowableArray<S>(addr, v);
+  }
+
+  public T at(int i) {
+    if (i < 0 || i >= length()) throw new ArrayIndexOutOfBoundsException(i);
+    Address data = dataField.getValue(getAddress());
+    Address addr = data.getAddressAt(i * VM.getVM().getAddressSize());
+    if (addr == null) return null;
+    return (T) virtualConstructor.instantiateWrapperFor(addr);
+  }
+
+  private GrowableArray(Address addr, InstanceConstructor<T> v) {
+    super(addr);
+    virtualConstructor = v;
+  }
+}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,14 @@
       return "solaris";
     } else if (os.equals("Linux")) {
       return "linux";
+    } else if (os.equals("FreeBSD")) {
+      return "bsd";
+    } else if (os.equals("NetBSD")) {
+      return "bsd";
+    } else if (os.equals("OpenBSD")) {
+      return "bsd";
+    } else if (os.equals("Darwin") || os.startsWith("Mac OS X")) {
+      return "bsd";
     } else if (os.startsWith("Windows")) {
       return "win32";
     } else {
--- a/hotspot/agent/test/jdi/sasanity.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/agent/test/jdi/sasanity.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -76,5 +76,5 @@
   sleep 2
 done
 
-$jdk/bin/java -showversion ${OPTIONS} -classpath $javacp SASanityChecker $pid
+$jdk/bin/java -showversion ${OPTIONS} -classpath $javacp $* SASanityChecker $pid
 kill -9 $pid
--- a/hotspot/make/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -323,28 +323,42 @@
 ifneq ($(OSNAME),windows)
   ifeq ($(ZERO_BUILD), true)
     ifeq ($(SHARK_BUILD), true)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(SHARK_DIR)/%.so
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_SERVER_DIR)/%.so:       $(SHARK_DIR)/%.so
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
     else
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(ZERO_DIR)/%.so
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_SERVER_DIR)/%.so:       $(ZERO_DIR)/%.so
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
     endif
   else
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(C1_DIR)/%.so
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_DIR)/%.$(LIBRARY_SUFFIX)
+	$(install-file)
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_DIR)/%.$(LIBRARY_SUFFIX)
+	$(install-file)
+$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX):       $(C1_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_JRE_LIB_ARCH_DIR)/%.so: $(C2_DIR)/%.so
+$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C1_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_CLIENT_DIR)/%.so:       $(C1_DIR)/%.so
+$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(C2_DIR)/%.$(LIBRARY_SUFFIX)
+	$(install-file)
+$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C2_DIR)/%.$(LIBRARY_SUFFIX)
 	$(install-file)
-$(EXPORT_CLIENT_DIR)/64/%.so:    $(C1_DIR)/%.so
+
+# Debug info for shared library
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(C1_DIR)/%.debuginfo
+	$(install-file)
+$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(C2_DIR)/%.debuginfo
 	$(install-file)
-$(EXPORT_SERVER_DIR)/%.so:       $(C2_DIR)/%.so
+$(EXPORT_CLIENT_DIR)/%.debuginfo:       $(C1_DIR)/%.debuginfo
+	$(install-file)
+$(EXPORT_CLIENT_DIR)/64/%.debuginfo:    $(C1_DIR)/%.debuginfo
 	$(install-file)
-$(EXPORT_SERVER_DIR)/64/%.so:    $(C2_DIR)/%.so
+$(EXPORT_SERVER_DIR)/%.debuginfo:       $(C2_DIR)/%.debuginfo
+	$(install-file)
+$(EXPORT_SERVER_DIR)/64/%.debuginfo:    $(C2_DIR)/%.debuginfo
 	$(install-file)
   endif
 endif
@@ -457,6 +471,36 @@
 	   ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \
 	fi
 
+# macosx universal builds
+
+ifeq ($(MACOSX_UNIVERSAL), true)
+$(UNIVERSAL_LIPO_LIST):
+	lipo -create -output $@ $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@)
+
+$(UNIVERSAL_COPY_LIST):
+	$(CP) $(EXPORT_JRE_LIB_DIR)/i386/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) $@
+
+universalize: $(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST)
+endif
+
+universal_product:
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_product
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_product
+	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
+	$(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize
+
+universal_fastdebug:
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_fastdebug
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_fastdebug
+	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
+	$(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize
+
+universal_debug:
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_debug
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_debug
+	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
+	$(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize
+
 #
 # Check target
 #
@@ -585,5 +629,6 @@
 	export_product export_fastdebug export_debug export_optimized \
 	export_jdk_product export_jdk_fastdebug export_jdk_debug \
 	create_jdk copy_jdk update_jdk test_jdk \
-	copy_product_jdk copy_fastdebug_jdk copy_debug_jdk
+	copy_product_jdk copy_fastdebug_jdk copy_debug_jdk universalize \
+	universal_product
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,371 @@
+#
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+#
+
+# This makefile creates a build tree and lights off a build.
+# You can go back into the build tree and perform rebuilds or
+# incremental builds as desired. Be sure to reestablish
+# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME.
+
+# The make process now relies on java and javac. These can be
+# specified either implicitly on the PATH, by setting the
+# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a
+# JDK in which bin/java and bin/javac are present and working (e.g.,
+# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited)
+# default BOOTDIR path value. Note that one of ALT_BOOTDIR
+# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc.
+# from the PATH.
+#
+# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on
+# an architecture that differs from the target architecture, as long
+# as the bootstrap jdk runs under the same flavor of OS as the target
+# (i.e., if the target is linux, point to a jdk that runs on a linux
+# box).  In order to use such a bootstrap jdk, set the make variable
+# REMOTE to the desired remote command mechanism, e.g.,
+#
+#    make REMOTE="rsh -l me myotherlinuxbox"
+
+# Along with VM, Serviceability Agent (SA) is built for SA/JDI binding.
+# JDI binding on SA produces two binaries:
+#  1. sa-jdi.jar       - This is build before building libjvm[_g].so
+#                        Please refer to ./makefiles/sa.make
+#  2. libsa[_g].so     - Native library for SA - This is built after
+#                        libjsig[_g].so (signal interposition library)
+#                        Please refer to ./makefiles/vm.make
+# If $(GAMMADIR)/agent dir is not present, SA components are not built.
+
+ifeq ($(GAMMADIR),)
+include ../../make/defs.make
+else
+include $(GAMMADIR)/make/defs.make
+endif
+include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make
+
+ifndef CC_INTERP
+  ifndef FORCE_TIERED
+    FORCE_TIERED=1
+  endif
+endif
+
+ifdef LP64
+  ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
+    _JUNK_ := $(shell echo >&2 \
+       $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!")
+	@exit 1
+  endif
+endif
+
+# we need to set up LP64 correctly to satisfy sanity checks in adlc
+ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","")
+  MFLAGS += " LP64=1 "
+endif
+
+# pass USE_SUNCC further, through MFLAGS
+ifdef USE_SUNCC
+  MFLAGS += " USE_SUNCC=1 "
+endif
+
+# The following renders pathnames in generated Makefiles valid on
+# machines other than the machine containing the build tree.
+#
+# For example, let's say my build tree lives on /files12 on
+# exact.east.sun.com.  This logic will cause GAMMADIR to begin with
+# /net/exact/files12/...
+#
+# We only do this on SunOS variants, for a couple of reasons:
+#  * It is extremely rare that source trees exist on other systems
+#  * It has been claimed that the Linux automounter is flakey, so
+#    changing GAMMADIR in a way that exercises the automounter could
+#    prove to be a source of unreliability in the build process.
+# Obviously, this Makefile is only relevant on SunOS boxes to begin
+# with, but the SunOS conditionalization will make it easier to
+# combine Makefiles in the future (assuming we ever do that).
+
+ifeq ($(OSNAME),solaris)
+
+  #   prepend current directory to relative pathnames.
+  NEW_GAMMADIR :=                                    \
+    $(shell echo $(GAMMADIR) |                       \
+      sed -e "s=^\([^/].*\)=$(shell pwd)/\1="        \
+     )
+  unexport NEW_GAMMADIR
+
+  # If NEW_GAMMADIR doesn't already start with "/net/":
+  ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),)
+    #   prepend /net/$(HOST)
+    #   remove /net/$(HOST) if name already began with /home/
+    #   remove /net/$(HOST) if name already began with /java/
+    #   remove /net/$(HOST) if name already began with /lab/
+    NEW_GAMMADIR :=                                     \
+         $(shell echo $(NEW_GAMMADIR) |                 \
+                 sed -e "s=^\(.*\)=/net/$(HOST)\1="     \
+                     -e "s=^/net/$(HOST)/home/=/home/=" \
+                     -e "s=^/net/$(HOST)/java/=/java/=" \
+                     -e "s=^/net/$(HOST)/lab/=/lab/="   \
+          )
+    # Don't use the new value for GAMMADIR unless a file with the new
+    # name actually exists.
+    ifneq ($(wildcard $(NEW_GAMMADIR)),)
+      GAMMADIR := $(NEW_GAMMADIR)
+    endif
+  endif
+
+endif
+
+# BUILDARCH is set to "zero" for Zero builds.  VARIANTARCH
+# is used to give the build directories meaningful names.
+VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH))
+
+# There is a (semi-) regular correspondence between make targets and actions:
+#
+#       Target          Tree Type       Build Dir
+#
+#       debug           compiler2       <os>_<arch>_compiler2/debug
+#       fastdebug       compiler2       <os>_<arch>_compiler2/fastdebug
+#       jvmg            compiler2       <os>_<arch>_compiler2/jvmg
+#       optimized       compiler2       <os>_<arch>_compiler2/optimized
+#       profiled        compiler2       <os>_<arch>_compiler2/profiled
+#       product         compiler2       <os>_<arch>_compiler2/product
+#
+#       debug1          compiler1       <os>_<arch>_compiler1/debug
+#       fastdebug1      compiler1       <os>_<arch>_compiler1/fastdebug
+#       jvmg1           compiler1       <os>_<arch>_compiler1/jvmg
+#       optimized1      compiler1       <os>_<arch>_compiler1/optimized
+#       profiled1       compiler1       <os>_<arch>_compiler1/profiled
+#       product1        compiler1       <os>_<arch>_compiler1/product
+#
+#       debugcore       core            <os>_<arch>_core/debug
+#       fastdebugcore   core            <os>_<arch>_core/fastdebug
+#       jvmgcore        core            <os>_<arch>_core/jvmg
+#       optimizedcore   core            <os>_<arch>_core/optimized
+#       profiledcore    core            <os>_<arch>_core/profiled
+#       productcore     core            <os>_<arch>_core/product
+#
+#       debugzero       zero            <os>_<arch>_zero/debug
+#       fastdebugzero   zero            <os>_<arch>_zero/fastdebug
+#       jvmgzero        zero            <os>_<arch>_zero/jvmg
+#       optimizedzero   zero            <os>_<arch>_zero/optimized
+#       profiledzero    zero            <os>_<arch>_zero/profiled
+#       productzero     zero            <os>_<arch>_zero/product
+#
+#       debugshark      shark           <os>_<arch>_shark/debug
+#       fastdebugshark  shark           <os>_<arch>_shark/fastdebug
+#       jvmgshark       shark           <os>_<arch>_shark/jvmg
+#       optimizedshark  shark           <os>_<arch>_shark/optimized
+#       profiledshark   shark           <os>_<arch>_shark/profiled
+#       productshark    shark           <os>_<arch>_shark/product
+#
+# What you get with each target:
+#
+# debug*     - "thin" libjvm_g - debug info linked into the gamma_g launcher
+# fastdebug* - optimized compile, but with asserts enabled
+# jvmg*      - "fat" libjvm_g - debug info linked into libjvm_g.so
+# optimized* - optimized compile, no asserts
+# profiled*  - gprof
+# product*   - the shippable thing:  optimized compile, no asserts, -DPRODUCT
+
+# This target list needs to be coordinated with the usage message
+# in the build.sh script:
+TARGETS           = debug jvmg fastdebug optimized profiled product
+
+ifeq ($(ZERO_BUILD), true)
+  SUBDIR_DOCS     = $(OSNAME)_$(VARIANTARCH)_docs
+else
+  SUBDIR_DOCS     = $(OSNAME)_$(BUILDARCH)_docs
+endif
+SUBDIRS_C1        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS))
+SUBDIRS_C2        = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS))
+SUBDIRS_TIERED    = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS))
+SUBDIRS_CORE      = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS))
+SUBDIRS_ZERO      = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS))
+SUBDIRS_SHARK     = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS))
+
+TARGETS_C2        = $(TARGETS)
+TARGETS_C1        = $(addsuffix 1,$(TARGETS))
+TARGETS_TIERED    = $(addsuffix tiered,$(TARGETS))
+TARGETS_CORE      = $(addsuffix core,$(TARGETS))
+TARGETS_ZERO      = $(addsuffix zero,$(TARGETS))
+TARGETS_SHARK     = $(addsuffix shark,$(TARGETS))
+
+BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
+BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH)
+BUILDTREE_VARS   += HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) HOTSPOT_BUILD_VERSION=$(HOTSPOT_BUILD_VERSION) JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
+
+BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)
+
+#-------------------------------------------------------------------------------
+
+# Could make everything by default, but that would take a while.
+all:
+	@echo "Try '$(MAKE) <target> ...'  where <target> is one or more of"
+	@echo "  $(TARGETS_C2)"
+	@echo "  $(TARGETS_C1)"
+	@echo "  $(TARGETS_CORE)"
+	@echo "  $(TARGETS_ZERO)"
+	@echo "  $(TARGETS_SHARK)"
+
+checks: check_os_version check_j2se_version
+
+# We do not want people accidentally building on old systems (e.g. Linux 2.2.x,
+# Solaris 2.5.1, 2.6).
+# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok.
+
+#SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 2.7%
+DISABLE_HOTSPOT_OS_VERSION_CHECK = ok
+OS_VERSION := $(shell uname -r)
+EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
+
+check_os_version:
+ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
+	$(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
+endif
+
+# jvmti.make requires XSLT (J2SE 1.4.x or newer):
+XSLT_CHECK	= $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory
+# If not found then fail fast.
+check_j2se_version:
+	$(QUIETLY) $(XSLT_CHECK) > /dev/null 2>&1; \
+	if [ $$? -ne 0 ]; then \
+	  $(REMOTE) $(RUN.JAVA) -version; \
+	  echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \
+	  "to bootstrap this build" 1>&2; \
+	  exit 1; \
+	fi
+
+$(SUBDIRS_TIERED): $(BUILDTREE_MAKE)
+	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
+	$(BUILDTREE) VARIANT=tiered
+
+$(SUBDIRS_C2): $(BUILDTREE_MAKE)
+ifeq ($(FORCE_TIERED),1)
+	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
+		$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1
+else
+	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
+		$(BUILDTREE) VARIANT=compiler2
+endif
+
+$(SUBDIRS_C1): $(BUILDTREE_MAKE)
+	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
+	$(BUILDTREE) VARIANT=compiler1
+
+$(SUBDIRS_CORE): $(BUILDTREE_MAKE)
+	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
+	$(BUILDTREE) VARIANT=core
+
+$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero
+	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
+	$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH)
+
+$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero
+	$(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks
+	$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH)
+
+platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in
+	$(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@
+
+# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME
+
+$(TARGETS_C2):  $(SUBDIRS_C2)
+	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS)
+	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && ./test_gamma
+ifdef INSTALL
+	cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install
+endif
+
+$(TARGETS_TIERED):  $(SUBDIRS_TIERED)
+	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS)
+	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && ./test_gamma
+ifdef INSTALL
+	cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install
+endif
+
+$(TARGETS_C1):  $(SUBDIRS_C1)
+	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS)
+	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && ./test_gamma
+ifdef INSTALL
+	cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install
+endif
+
+$(TARGETS_CORE):  $(SUBDIRS_CORE)
+	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS)
+	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && ./test_gamma
+ifdef INSTALL
+	cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install
+endif
+
+$(TARGETS_ZERO):  $(SUBDIRS_ZERO)
+	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS)
+	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && ./test_gamma
+ifdef INSTALL
+	cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install
+endif
+
+$(TARGETS_SHARK):  $(SUBDIRS_SHARK)
+	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS)
+	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && ./test_gamma
+ifdef INSTALL
+	cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install
+endif
+
+# Just build the tree, and nothing else:
+tree:      $(SUBDIRS_C2)
+tree1:     $(SUBDIRS_C1)
+treecore:  $(SUBDIRS_CORE)
+treezero:  $(SUBDIRS_ZERO)
+treeshark: $(SUBDIRS_SHARK)
+
+# Doc target.  This is the same for all build options.
+#     Hence create a docs directory beside ...$(ARCH)_[...]
+docs: checks
+	$(QUIETLY) mkdir -p $(SUBDIR_DOCS)
+	$(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) jvmtidocs
+
+# Synonyms for win32-like targets.
+compiler2:  jvmg product
+
+compiler1:  jvmg1 product1
+
+core: jvmgcore productcore
+
+zero: jvmgzero productzero
+
+shark: jvmgshark productshark
+
+clean_docs:
+	rm -rf $(SUBDIR_DOCS)
+
+clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark:
+	rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@)
+
+clean:  clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_docs
+
+include $(GAMMADIR)/make/cscope.make
+
+#-------------------------------------------------------------------------------
+
+.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK)
+.PHONY: tree tree1 treecore treezero treeshark
+.PHONY: all compiler1 compiler2 core zero shark
+.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs
+.PHONY: checks check_os_version check_j2se_version
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/README	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,26 @@
+Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+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.
+
+________________________________________________________________________
+
+Please refer to the comments in the Makefile in this directory
+for instructions how to build the Solaris versions.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/adlc_updater	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,20 @@
+#! /bin/sh
+#
+# This file is used by adlc.make to selectively update generated
+# adlc files. Because source and target diretories are relative
+# paths, this file is copied to the target build directory before
+# use.
+#
+# adlc-updater <file> <source-dir> <target-dir>
+#
+fix_lines() {
+  # repair bare #line directives in $1 to refer to $2
+  awk < $1 > $1+ '
+    /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next}
+    {print}
+  ' F2=$2
+  mv $1+ $1
+}
+fix_lines $2/$1 $3/$1
+[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \
+( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/build.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,95 @@
+#! /bin/sh
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Make sure the variable JAVA_HOME is set before running this script.
+
+set -u
+
+
+if [ $# != 2 ]; then 
+    echo "Usage : $0 Build_Options Location"
+    echo "Build Options : debug or optimized or basicdebug or basic or clean"
+    echo "Location : specify any workspace which has gamma sources"
+    exit 1
+fi
+
+# Just in case:
+case ${JAVA_HOME} in
+/*) true;;
+?*) JAVA_HOME=`( cd $JAVA_HOME; pwd )`;;
+esac
+
+case `uname -m` in
+  i386|i486|i586|i686)
+    mach=i386
+    ;;
+  *)
+    echo "Unsupported machine: " `uname -m`
+    exit 1
+    ;;
+esac
+
+if [ "${JAVA_HOME}" = ""  -o  ! -d "${JAVA_HOME}" -o ! -d ${JAVA_HOME}/jre/lib/${mach} ]; then
+    echo "JAVA_HOME needs to be set to a valid JDK path"
+    echo "ksh : export JAVA_HOME=/net/tetrasparc/export/gobi/JDK1.2_fcs_V/bsd"
+    echo "csh : setenv JAVA_HOME /net/tetrasparc/export/gobi/JDK1.2_fcs_V/bsd"
+    exit 1
+fi
+
+
+LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/`uname -p`:\
+${JAVA_HOME}/jre/lib/`uname -p`/native_threads:${LD_LIBRARY_PATH-.}
+
+# This is necessary as long as we are using the old launcher
+# with the new distribution format:
+CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar:${CLASSPATH-.}
+
+
+for gm in gmake gnumake
+do
+  if [ "${GNUMAKE-}" != "" ]; then break; fi
+  ($gm --version >/dev/null) 2>/dev/null && GNUMAKE=$gm
+done
+: ${GNUMAKE:?'Cannot locate the gnumake program.  Stop.'}
+
+
+echo "### ENVIRONMENT SETTINGS:"
+export JAVA_HOME		; echo "JAVA_HOME=$JAVA_HOME"
+export LD_LIBRARY_PATH		; echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+export CLASSPATH		; echo "CLASSPATH=$CLASSPATH"
+export GNUMAKE			; echo "GNUMAKE=$GNUMAKE"
+echo "###"
+
+Build_Options=$1
+Location=$2
+
+case ${Location} in
+/*) true;;
+?*) Location=`(cd ${Location}; pwd)`;;
+esac
+
+echo \
+${GNUMAKE} -f ${Location}/make/bsd/Makefile $Build_Options GAMMADIR=${Location}
+${GNUMAKE} -f ${Location}/make/bsd/Makefile $Build_Options GAMMADIR=${Location}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/adjust-mflags.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,87 @@
+#! /bin/sh
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# This script is used only from top.make.
+# The macro $(MFLAGS-adjusted) calls this script to
+# adjust the "-j" arguments to take into account
+# the HOTSPOT_BUILD_JOBS variable.  The default
+# handling of the "-j" argument by gnumake does
+# not meet our needs, so we must adjust it ourselves.
+
+# This argument adjustment applies to two recursive
+# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make.
+# One invokes adlc.make, and the other invokes vm.make.
+# The adjustment propagates the desired concurrency
+# level down to the sub-make (of the adlc or vm).
+# The default behavior of gnumake is to run all
+# sub-makes without concurrency ("-j1").
+
+# Also, we use a make variable rather than an explicit
+# "-j<N>" argument to control this setting, so that
+# the concurrency setting (which must be tuned separately
+# for each MP system) can be set via an environment variable.
+# The recommended setting is 1.5x to 2x the number of available
+# CPUs on the MP system, which is large enough to keep the CPUs
+# busy (even though some jobs may be I/O bound) but not too large,
+# we may presume, to overflow the system's swap space.
+
+set -eu
+
+default_build_jobs=4
+
+case $# in
+[12])	true;;
+*)	>&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;;
+esac
+
+MFLAGS=$1
+HOTSPOT_BUILD_JOBS=${2-}
+
+# Normalize any -jN argument to the form " -j${HBJ}"
+MFLAGS=`
+	echo "$MFLAGS" \
+	| sed '
+		s/^-/ -/
+		s/ -\([^ 	][^ 	]*\)j/ -\1 -j/
+		s/ -j[0-9][0-9]*/ -j/
+		s/ -j\([^ 	]\)/ -j -\1/
+		s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/
+	' `
+
+case ${HOTSPOT_BUILD_JOBS} in \
+
+'') case ${MFLAGS} in
+    *\ -j*)
+	>&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." 
+	>&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment."
+    esac;;
+
+?*) case ${MFLAGS} in
+     *\ -j*) true;;
+     *)      MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";;
+    esac;;
+esac
+
+echo "${MFLAGS}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/adlc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,228 @@
+#
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# This makefile (adlc.make) is included from the adlc.make in the
+# build directories.
+# It knows how to compile, link, and run the adlc.
+
+include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make
+
+# #########################################################################
+
+# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make:
+GENERATED = ../generated
+OUTDIR  = $(GENERATED)/adfiles
+
+ARCH = $(Platform_arch)
+OS = $(Platform_os_family)
+
+SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad 
+
+SOURCES.AD = \
+  $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \
+  $(call altsrc-replace,$(HS_COMMON_SRC)/os_cpu/$(OS)_$(ARCH)/vm/$(OS)_$(Platform_arch_model).ad)
+
+EXEC	= $(OUTDIR)/adlc
+
+# set VPATH so make knows where to look for source files
+Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc
+VPATH += $(Src_Dirs_V:%=%:)
+
+# set INCLUDES for C preprocessor
+Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED)
+INCLUDES += $(Src_Dirs_I:%=-I%)
+
+# set flags for adlc compilation
+CPPFLAGS = $(SYSDEFS) $(INCLUDES)
+
+# Force assertions on.
+CPPFLAGS += -DASSERT
+
+# CFLAGS_WARN holds compiler options to suppress/enable warnings.
+# Compiler warnings are treated as errors
+ifneq ($(COMPILER_WARNINGS_FATAL),false)
+  CFLAGS_WARN = -Werror
+endif
+CFLAGS += $(CFLAGS_WARN)
+
+OBJECTNAMES = \
+	adlparse.o \
+	archDesc.o \
+	arena.o \
+	dfa.o \
+	dict2.o \
+	filebuff.o \
+	forms.o \
+	formsopt.o \
+	formssel.o \
+	main.o \
+	adlc-opcodes.o \
+	output_c.o \
+	output_h.o \
+
+OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%)
+
+GENERATEDNAMES = \
+        ad_$(Platform_arch_model).cpp \
+        ad_$(Platform_arch_model).hpp \
+        ad_$(Platform_arch_model)_clone.cpp \
+        ad_$(Platform_arch_model)_expand.cpp \
+        ad_$(Platform_arch_model)_format.cpp \
+        ad_$(Platform_arch_model)_gen.cpp \
+        ad_$(Platform_arch_model)_misc.cpp \
+        ad_$(Platform_arch_model)_peephole.cpp \
+        ad_$(Platform_arch_model)_pipeline.cpp \
+        adGlobals_$(Platform_arch_model).hpp \
+        dfa_$(Platform_arch_model).cpp \
+
+GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%)
+
+# #########################################################################
+
+all: $(EXEC)
+
+$(EXEC) : $(OBJECTS)
+	@echo Making adlc
+	$(QUIETLY) $(HOST.LINK_NOPROF.CC) -o $(EXEC) $(OBJECTS)
+
+# Random dependencies:
+$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
+
+# The source files refer to ostream.h, which sparcworks calls iostream.h
+$(OBJECTS): ostream.h
+
+ostream.h :
+	@echo >$@ '#include <iostream.h>'
+
+dump:
+	: OUTDIR=$(OUTDIR)
+	: OBJECTS=$(OBJECTS)
+	: products = $(GENERATEDFILES)
+
+all: $(GENERATEDFILES)
+
+$(GENERATEDFILES): refresh_adfiles
+
+# Get a unique temporary directory name, so multiple makes can run in parallel.
+# Note that product files are updated via "mv", which is atomic.
+TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$)
+
+# Debuggable by default
+CFLAGS += -g
+
+# Pass -D flags into ADLC.
+ADLCFLAGS += $(SYSDEFS)
+
+# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO.
+ADLCFLAGS += -q -T
+
+# Normally, debugging is done directly on the ad_<arch>*.cpp files.
+# But -g will put #line directives in those files pointing back to <arch>.ad.
+# Some builds of gcc 3.2 have a bug that gets tickled by the extra #line directives
+# so skip it for 3.2 and ealier.
+ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
+ADLCFLAGS += -g
+endif
+
+ifdef LP64
+ADLCFLAGS += -D_LP64
+else
+ADLCFLAGS += -U_LP64
+endif
+
+#
+# adlc_updater is a simple sh script, under sccs control. It is
+# used to selectively update generated adlc files. This should
+# provide a nice compilation speed improvement.
+#
+ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS)
+ADLC_UPDATER = adlc_updater
+$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER)
+	$(QUIETLY) cp $< $@; chmod +x $@
+
+# This action refreshes all generated adlc files simultaneously.
+# The way it works is this:
+# 1) create a scratch directory to work in.
+# 2) if the current working directory does not have $(ADLC_UPDATER), copy it.
+# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory.
+# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files.
+# 5) If we actually updated any files, echo a notice.
+#
+refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER)
+	@rm -rf $(TEMPDIR); mkdir $(TEMPDIR)
+	$(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \
+ -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \
+	    || { rm -rf $(TEMPDIR); exit 1; }
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR)
+	$(QUIETLY) [ -f $(TEMPDIR)/made-change ] \
+		|| echo "Rescanned $(SOURCE.AD) but encountered no changes."
+	$(QUIETLY) rm -rf $(TEMPDIR)
+
+
+# #########################################################################
+
+$(SOURCE.AD): $(SOURCES.AD)
+	$(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD)
+
+#PROCESS_AD_FILES = cat
+# Pass through #line directives, in case user enables -g option above:
+PROCESS_AD_FILES = awk '{ \
+    if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \
+    if (need_lineno && $$0 !~ /\/\//) \
+      { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \
+    print }'
+
+$(OUTDIR)/%.o: %.cpp
+	@echo Compiling $<
+	$(QUIETLY) $(REMOVE_TARGET)
+	$(QUIETLY) $(HOST.COMPILE.CC) -o $@ $< $(COMPILE_DONE)
+
+# Some object files are given a prefix, to disambiguate
+# them from objects of the same name built for the VM.
+$(OUTDIR)/adlc-%.o: %.cpp
+	@echo Compiling $<
+	$(QUIETLY) $(REMOVE_TARGET)
+	$(QUIETLY) $(HOST.COMPILE.CC) -o $@ $< $(COMPILE_DONE)
+
+# #########################################################################
+
+clean	:
+	rm $(OBJECTS)
+
+cleanall :
+	rm $(OBJECTS) $(EXEC)
+
+# #########################################################################
+
+.PHONY: all dump refresh_adfiles clean cleanall
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/amd64.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
+OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
+# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
+OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+# Must also specify if CPU is little endian
+CFLAGS += -DVM_LITTLE_ENDIAN
+
+CFLAGS += -D_LP64=1
+
+# The serviceability agent relies on frame pointer (%rbp) to walk thread stack
+ifndef USE_SUNCC
+  CFLAGS += -fno-omit-frame-pointer
+endif
+
+OPT_CFLAGS/compactingPermGenGen.o = -O1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/arm.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+Obj_Files += bsd_arm.o
+
+LIBS += $(EXT_LIBS_PATH)/sflt_glibc.a 
+
+CFLAGS += -DVM_LITTLE_ENDIAN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/build_vm_def.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# If we're cross compiling use that path for nm
+if [ "$CROSS_COMPILE_ARCH" != "" ]; then 
+NM=$ALT_COMPILER_PATH/nm
+else
+NM=nm
+fi
+
+$NM --defined-only $* | awk '
+   { if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";" }
+   '
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/buildtree.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,430 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# 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.
+#  
+#
+
+# Usage:
+#
+# $(MAKE) -f buildtree.make SRCARCH=srcarch BUILDARCH=buildarch LIBARCH=libarch
+#         GAMMADIR=dir OS_FAMILY=os VARIANT=variant
+#
+# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the
+# environment or on the command-line:
+#
+# ARCH		- sparc, i486, ... HotSpot cpu and os_cpu source directory
+# BUILDARCH     - build directory
+# LIBARCH       - the corresponding directory in JDK/JRE
+# GAMMADIR	- top of workspace
+# OS_FAMILY	- operating system
+# VARIANT	- core, compiler1, compiler2, or tiered
+# HOTSPOT_RELEASE_VERSION - <major>.<minor>-b<nn> (11.0-b07)
+# HOTSPOT_BUILD_VERSION   - internal, internal-$(USER_RELEASE_SUFFIX) or empty
+# JRE_RELEASE_VERSION     - <major>.<minor>.<micro> (1.7.0)
+#
+# Builds the directory trees with makefiles plus some convenience files in
+# each directory:
+#
+# Makefile	- for "make foo"
+# flags.make	- with macro settings
+# vm.make	- to support making "$(MAKE) -v vm.make" in makefiles
+# adlc.make	- 
+# jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
+# sa.make	- generate SA jar file and natives
+# env.[ck]sh	- environment settings
+# test_gamma	- script to run the Queens program
+# 
+# The makefiles are split this way so that "make foo" will run faster by not
+# having to read the dependency files for the vm.
+
+include $(GAMMADIR)/make/scm.make
+include $(GAMMADIR)/make/altsrc.make
+
+
+# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details.
+QUIETLY$(MAKE_VERBOSE)	= @
+
+# For now, until the compiler is less wobbly:
+TESTFLAGS	= -Xbatch -showversion
+
+ifeq ($(ZERO_BUILD), true)
+  PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero
+else
+  ifdef USE_SUNCC
+    PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc
+  else
+    PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH)
+  endif
+endif
+
+# Allow overriding of the arch part of the directory but default
+# to BUILDARCH if nothing is specified
+ifeq ($(VARIANTARCH),)
+  VARIANTARCH=$(BUILDARCH)
+endif
+
+ifdef FORCE_TIERED
+ifeq		($(VARIANT),tiered)
+PLATFORM_DIR	= $(OS_FAMILY)_$(VARIANTARCH)_compiler2
+else
+PLATFORM_DIR	= $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
+endif
+else
+PLATFORM_DIR    = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT)
+endif
+
+#
+# We do two levels of exclusion in the shared directory.
+# TOPLEVEL excludes are pruned, they are not recursively searched,
+# but lower level directories can be named without fear of collision.
+# ALWAYS excludes are excluded at any level in the directory tree.
+#
+
+ALWAYS_EXCLUDE_DIRS     = $(SCM_DIRS)
+
+ifeq		($(VARIANT),tiered)
+TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent
+else
+ifeq		($(VARIANT),compiler2)
+TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent
+else
+# compiler1 and core use the same exclude list
+TOPLEVEL_EXCLUDE_DIRS	= $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent
+endif
+endif
+
+# Get things from the platform file.
+COMPILER	= $(shell sed -n 's/^compiler[ 	]*=[ 	]*//p' $(PLATFORM_FILE))
+
+# dtracefiles is used on BSD versions that implement Dtrace (like MacOS X)
+SIMPLE_DIRS	= \
+	$(PLATFORM_DIR)/generated/dependencies \
+	$(PLATFORM_DIR)/generated/adfiles \
+	$(PLATFORM_DIR)/generated/jvmtifiles \
+	$(PLATFORM_DIR)/generated/dtracefiles
+
+TARGETS      = debug fastdebug jvmg optimized product profiled
+SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS))
+
+# For dependencies and recursive makes.
+BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
+
+# dtrace.make is used on BSD versions that implement Dtrace (like MacOS X)
+BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make \
+	jvmti.make sa.make dtrace.make \
+        env.sh env.csh jdkpath.sh .dbxrc test_gamma
+
+BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
+	SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
+
+# Define variables to be set in flags.make.
+# Default values are set in make/defs.make.
+ifeq ($(HOTSPOT_BUILD_VERSION),)
+  HS_BUILD_VER=$(HOTSPOT_RELEASE_VERSION)
+else
+  HS_BUILD_VER=$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)
+endif
+# Set BUILD_USER from system-dependent hints:  $LOGNAME, $(whoami)
+ifndef HOTSPOT_BUILD_USER
+  HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME)
+endif
+ifndef HOTSPOT_BUILD_USER
+  HOTSPOT_BUILD_USER := $(shell whoami)
+endif
+# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro
+# or make/hotspot_distro.
+ifndef HOTSPOT_VM_DISTRO
+  ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true)
+    include $(GAMMADIR)/make/hotspot_distro
+  else
+    include $(GAMMADIR)/make/openjdk_distro
+  endif
+endif
+
+# MACOSX FIXME: we should be able to run test_gamma (see MACOSX_PORT-214)
+ifdef ALWAYS_PASS_TEST_GAMMA
+  TEST_GAMMA_STATUS= echo 'exit 0';
+else
+  TEST_GAMMA_STATUS=
+endif
+
+BUILDTREE_VARS += HOTSPOT_RELEASE_VERSION=$(HS_BUILD_VER) HOTSPOT_BUILD_VERSION=  JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
+
+BUILDTREE	= \
+	$(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS)
+
+BUILDTREE_COMMENT	= echo "\# Generated by $(BUILDTREE_MAKE)"
+
+all:  $(SUBMAKE_DIRS)
+
+# Run make in each subdirectory recursively.
+$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE
+	$(QUIETLY) [ -d $@ ] || { mkdir -p $@; }
+	$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F)
+	$(QUIETLY) touch $@
+
+$(SIMPLE_DIRS):
+	$(QUIETLY) mkdir -p $@
+
+# Convenience macro which takes a source relative path, applies $(1) to the
+# absolute path, and then replaces $(GAMMADIR) in the result with a 
+# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile.  
+gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2)))
+
+flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo; \
+	echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \
+	sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \
+	echo; \
+	echo "GAMMADIR = $(GAMMADIR)"; \
+	echo "SYSDEFS = \$$(Platform_sysdefs)"; \
+	echo "SRCARCH = $(SRCARCH)"; \
+	echo "BUILDARCH = $(BUILDARCH)"; \
+	echo "LIBARCH = $(LIBARCH)"; \
+	echo "TARGET = $(TARGET)"; \
+	echo "HS_BUILD_VER = $(HS_BUILD_VER)"; \
+	echo "JRE_RELEASE_VER = $(JRE_RELEASE_VERSION)"; \
+	echo "SA_BUILD_VERSION = $(HS_BUILD_VER)"; \
+	echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \
+	echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \
+	echo; \
+	echo "# Used for platform dispatching"; \
+	echo "TARGET_DEFINES  = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \
+	echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \
+	echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \
+	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \
+	echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \
+	echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \
+	echo "CFLAGS += \$$(TARGET_DEFINES)"; \
+	echo; \
+	echo "Src_Dirs_V = \\"; \
+	sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \
+	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
+	echo; \
+	echo "Src_Dirs_I = \\"; \
+	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
+	echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \
+	echo "$(call gamma-path,altsrc,share/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,share/vm) \\"; \
+	echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
+	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
+	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
+	[ -n "$(CFLAGS_BROWSE)" ] && \
+	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
+	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
+	    echo && \
+	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
+	    echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
+	echo; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
+	) > $@
+
+flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo; \
+	[ "$(TARGET)" = profiled ] && \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/optimized.make"; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \
+	) > $@
+
+../shared_dirs.lst:  $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm
+	@echo Creating directory list $@
+	$(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \
+          find $(HS_ALT_SRC)/share/vm/* -prune \
+	  -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
+          \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \
+        fi;
+	$(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \
+	-type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \
+        \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@
+
+Makefile: $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo; \
+	echo include flags.make; \
+	echo; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \
+	) > $@
+
+vm.make: $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo; \
+	echo include flags.make; \
+	echo include flags_vm.make; \
+	echo; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
+	) > $@
+
+adlc.make: $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo; \
+	echo include flags.make; \
+	echo; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
+	) > $@
+
+jvmti.make: $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo; \
+	echo include flags.make; \
+	echo; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
+	) > $@
+
+sa.make: $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo; \
+	echo include flags.make; \
+	echo; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
+	) > $@
+
+dtrace.make: $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo; \
+	echo include flags.make; \
+	echo; \
+	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
+	) > $@
+
+env.sh: $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	[ -n "$$JAVA_HOME" ] && { echo ": \$${JAVA_HOME:=$${JAVA_HOME}}"; }; \
+	{ \
+	echo "LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
+	echo "DYLD_LIBRARY_PATH=.:$${DYLD_LIBRARY_PATH:+$$DYLD_LIBRARY_PATH:}\$${JAVA_HOME}/jre/lib/${LIBARCH}/native_threads:\$${JAVA_HOME}/jre/lib/${LIBARCH}:${GCC_LIB}"; \
+	echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
+	} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
+	echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
+	echo "export JAVA_HOME LD_LIBRARY_PATH DYLD_LIBRARY_PATH CLASSPATH HOTSPOT_BUILD_USER"; \
+	) > $@
+
+env.csh: env.sh
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	[ -n "$$JAVA_HOME" ] && \
+	{ echo "if (! \$$?JAVA_HOME) setenv JAVA_HOME \"$$JAVA_HOME\""; }; \
+	sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
+	) > $@
+
+jdkpath.sh: $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	$(BUILDTREE_COMMENT); \
+	echo "JDK=${JAVA_HOME}"; \
+	) > $@	   
+
+.dbxrc:  $(BUILDTREE_MAKE)
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	echo "echo '# Loading $(PLATFORM_DIR)/$(TARGET)/.dbxrc'"; \
+	echo "if [ -f \"\$${HOTSPOT_DBXWARE}\" ]"; \
+	echo "then"; \
+	echo "	source \"\$${HOTSPOT_DBXWARE}\""; \
+	echo "elif [ -f \"\$$HOME/.dbxrc\" ]"; \
+	echo "then"; \
+	echo "	source \"\$$HOME/.dbxrc\""; \
+	echo "fi"; \
+	) > $@
+
+# Skip the test for product builds (which only work when installed in a JDK), to
+# avoid exiting with an error and causing make to halt.
+NO_TEST_MSG	= \
+	echo "$@:  skipping the test--this build must be tested in a JDK."
+
+NO_JAVA_HOME_MSG	= \
+	echo "JAVA_HOME must be set to run this test."
+
+DATA_MODE = $(DATA_MODE/$(BUILDARCH))
+JAVA_FLAG = $(JAVA_FLAG/$(DATA_MODE))
+
+DATA_MODE/i486    = 32
+DATA_MODE/sparc   = 32
+DATA_MODE/sparcv9 = 64
+DATA_MODE/amd64   = 64
+DATA_MODE/ia64    = 64
+DATA_MODE/zero    = $(ARCH_DATA_MODEL)
+
+JAVA_FLAG/32 = -d32
+JAVA_FLAG/64 = -d64
+
+WRONG_DATA_MODE_MSG = \
+	echo "JAVA_HOME must point to $(DATA_MODE)bit JDK."
+
+CROSS_COMPILING_MSG = \
+	echo "Cross compiling for ARCH $(CROSS_COMPILE_ARCH), skipping gamma run."
+
+test_gamma:  $(BUILDTREE_MAKE) $(GAMMADIR)/make/test/Queens.java
+	@echo Creating $@ ...
+	$(QUIETLY) ( \
+	echo '#!/bin/sh'; \
+	$(BUILDTREE_COMMENT); \
+	echo '. ./env.sh'; \
+	echo "if [ \"$(CROSS_COMPILE_ARCH)\" != \"\" ]; then { $(CROSS_COMPILING_MSG); exit 0; }; fi"; \
+	echo "if [ -z \$$JAVA_HOME ]; then { $(NO_JAVA_HOME_MSG); exit 0; }; fi"; \
+	echo "if ! \$${JAVA_HOME}/bin/java $(JAVA_FLAG) -fullversion 2>&1 > /dev/null"; \
+	echo "then"; \
+	echo "  $(WRONG_DATA_MODE_MSG); exit 0;"; \
+	echo "fi"; \
+	echo "rm -f Queens.class"; \
+	echo "\$${JAVA_HOME}/bin/javac -d . $(GAMMADIR)/make/test/Queens.java"; \
+	echo '[ -f gamma_g ] && { gamma=gamma_g; }'; \
+	echo './$${gamma:-gamma} $(TESTFLAGS) Queens < /dev/null'; \
+	$(TEST_GAMMA_STATUS) \
+	) > $@
+	$(QUIETLY) chmod +x $@
+
+FORCE:
+
+.PHONY:  all FORCE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/compiler1.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making client version of VM
+
+TYPE=COMPILER1
+
+VM_SUBDIR = client
+
+CFLAGS += -DCOMPILER1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/compiler2.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making server version of VM
+
+TYPE=COMPILER2
+
+VM_SUBDIR = server
+
+CFLAGS += -DCOMPILER2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/core.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,33 @@
+#
+# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making core version of VM
+
+# Select which files to use (in top.make)
+TYPE=CORE
+
+# There is no "core" directory in JDK. Install core build in server directory.
+VM_SUBDIR = server
+
+# Note:  macros.hpp defines CORE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/cscope.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,160 @@
+#
+# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+#
+# The cscope.out file is made in the current directory and spans the entire
+# source tree.
+#
+# Things to note:
+#	1. We use relative names for cscope.
+#	2. We *don't* remove the old cscope.out file, because cscope is smart
+#	   enough to only build what has changed.  It can be confused, however,
+#	   if files are renamed or removed, so it may be necessary to manually
+#	   remove cscope.out if a lot of reorganization has occurred.
+#
+
+include $(GAMMADIR)/make/scm.make
+
+NAWK	= awk
+RM	= rm -f
+HG	= hg
+CS_TOP	= ../..
+
+CSDIRS	= $(CS_TOP)/src $(CS_TOP)/build
+CSINCS	= $(CSDIRS:%=-I%)
+
+CSCOPE		= cscope
+CSCOPE_FLAGS	= -b
+
+# Allow .java files to be added from the environment (CSCLASSES=yes).
+ifdef	CSCLASSES
+ADDCLASSES=	-o -name '*.java'
+endif
+
+# Adding CClassHeaders also pushes the file count of a full workspace up about
+# 200 files (these files also don't exist in a new workspace, and thus will
+# cause the recreation of the database as they get created, which might seem
+# a little confusing).  Thus allow these files to be added from the environment
+# (CSHEADERS=yes).
+ifndef	CSHEADERS
+RMCCHEADERS=	-o -name CClassHeaders
+endif
+
+# Use CS_GENERATED=x to include auto-generated files in the build directories.
+ifdef	CS_GENERATED
+CS_ADD_GENERATED	= -o -name '*.incl'
+else
+CS_PRUNE_GENERATED	= -o -name '${OS}_*_core' -o -name '${OS}_*_compiler?'
+endif
+
+# OS-specific files for other systems are excluded by default.  Use CS_OS=yes
+# to include platform-specific files for other platforms.
+ifndef	CS_OS
+CS_OS		= linux macos solaris win32 bsd
+CS_PRUNE_OS	= $(patsubst %,-o -name '*%*',$(filter-out ${OS},${CS_OS}))
+endif
+
+# Processor-specific files for other processors are excluded by default.  Use
+# CS_CPU=x to include platform-specific files for other platforms.
+ifndef	CS_CPU
+CS_CPU		= i486 sparc amd64 ia64
+CS_PRUNE_CPU	= $(patsubst %,-o -name '*%*',$(filter-out ${SRCARCH},${CS_CPU}))
+endif
+
+# What files should we include?  A simple rule might be just those files under
+# SCCS control, however this would miss files we create like the opcodes and
+# CClassHeaders.  The following attempts to find everything that is *useful*.
+# (.del files are created by sccsrm, demo directories contain many .java files
+# that probably aren't useful for development, and the pkgarchive may contain
+# duplicates of files within the source hierarchy).
+
+# Directories to exclude.
+CS_PRUNE_STD	= $(SCM_DIRS) \
+		  -o -name '.del-*' \
+		  -o -name '*demo' \
+		  -o -name pkgarchive
+
+CS_PRUNE	= $(CS_PRUNE_STD) \
+		  $(CS_PRUNE_OS) \
+		  $(CS_PRUNE_CPU) \
+		  $(CS_PRUNE_GENERATED) \
+		  $(RMCCHEADERS)
+
+# File names to include.
+CSFILENAMES	= -name '*.[ch]pp' \
+		  -o -name '*.[Ccshlxy]' \
+		  $(CS_ADD_GENERATED) \
+		  -o -name '*.il' \
+		  -o -name '*.cc' \
+		  -o -name '*[Mm]akefile*' \
+		  -o -name '*.gmk' \
+		  -o -name '*.make' \
+		  -o -name '*.ad' \
+		  $(ADDCLASSES)
+
+.PRECIOUS:	cscope.out
+
+cscope cscope.out: cscope.files FORCE
+	$(CSCOPE) $(CSCOPE_FLAGS)
+
+# The .raw file is reordered here in an attempt to make cscope display the most
+# relevant files first.
+cscope.files: .cscope.files.raw
+	echo "$(CSINCS)" > $@
+	-egrep -v "\.java|\/make\/"	$< >> $@
+	-fgrep ".java"			$< >> $@
+	-fgrep "/make/"		$< >> $@
+
+.cscope.files.raw:  .nametable.files
+	-find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o \
+	    -type f \( $(CSFILENAMES) \) -print > $@
+
+cscope.clean:  nametable.clean
+	-$(RM) cscope.out cscope.files .cscope.files.raw
+
+TAGS:  cscope.files FORCE
+	egrep -v '^-|^$$' $< | etags --members -
+
+TAGS.clean:  nametable.clean
+	-$(RM) TAGS
+
+# .nametable.files and .nametable.files.tmp are used to determine if any files
+# were added to/deleted from/renamed in the workspace.  If not, then there's
+# normally no need to rebuild the cscope database. To force a rebuild of
+# the cscope database: gmake nametable.clean.
+.nametable.files:  .nametable.files.tmp
+	( cmp -s $@ $< ) || ( cp $< $@ )
+	-$(RM) $<
+
+# `hg status' is slightly faster than `hg fstatus'. Both are
+# quite a bit slower on an NFS mounted file system, so this is
+# really geared towards repos on local file systems.
+.nametable.files.tmp:
+	-$(HG) fstatus -acmn > $@
+nametable.clean:
+	-$(RM) .nametable.files .nametable.files.tmp
+
+FORCE:
+
+.PHONY:		cscope cscope.clean TAGS.clean nametable.clean FORCE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/debug.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making debug version of VM
+
+# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
+DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS)
+DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
+CFLAGS += $(DEBUG_CFLAGS/BYFILE)
+
+# Linker mapfile
+MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug
+
+_JUNK_ := $(shell echo -e >&2 ""\
+ "----------------------------------------------------------------------\n" \
+ "WARNING: 'make debug' is deprecated. It will be removed in the future.\n" \
+ "Please use 'make jvmg' to build debug JVM.                            \n" \
+ "----------------------------------------------------------------------\n")
+
+G_SUFFIX = _g
+VERSION = debug
+SYSDEFS += -DASSERT -DDEBUG
+PICFLAGS = DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/defs.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,180 @@
+#
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# The common definitions for hotspot bsd builds.
+# Include the top level defs.make under make directory instead of this one.
+# This file is included into make/defs.make.
+
+SLASH_JAVA ?= /java
+
+# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name
+ARCH:=$(shell uname -m)
+PATH_SEP = :
+ifeq ($(LP64), 1)
+  ARCH_DATA_MODEL ?= 64
+else
+  ARCH_DATA_MODEL ?= 32
+endif
+
+# zero
+ifeq ($(ZERO_BUILD), true)
+  ifeq ($(ARCH_DATA_MODEL), 64)
+    MAKE_ARGS      += LP64=1
+  endif
+  PLATFORM         = bsd-zero
+  VM_PLATFORM      = bsd_$(subst i386,i486,$(ZERO_LIBARCH))
+  HS_ARCH          = zero
+  ARCH             = zero
+endif
+
+# ia64
+ifeq ($(ARCH), ia64)
+  ARCH_DATA_MODEL = 64
+  MAKE_ARGS      += LP64=1
+  PLATFORM        = bsd-ia64
+  VM_PLATFORM     = bsd_ia64
+  HS_ARCH         = ia64
+endif
+
+# sparc
+ifeq ($(ARCH), sparc64)
+  ifeq ($(ARCH_DATA_MODEL), 64)
+    ARCH_DATA_MODEL  = 64
+    MAKE_ARGS        += LP64=1
+    PLATFORM         = bsd-sparcv9
+    VM_PLATFORM      = bsd_sparcv9
+  else
+    ARCH_DATA_MODEL  = 32
+    PLATFORM         = bsd-sparc
+    VM_PLATFORM      = bsd_sparc
+  endif
+  HS_ARCH            = sparc
+endif
+
+# amd64
+ifneq (,$(findstring $(ARCH), amd64 x86_64))
+  ifeq ($(ARCH_DATA_MODEL), 64)
+    ARCH_DATA_MODEL = 64
+    MAKE_ARGS       += LP64=1
+    PLATFORM        = bsd-amd64
+    VM_PLATFORM     = bsd_amd64
+    HS_ARCH         = x86
+  else
+    ARCH_DATA_MODEL = 32
+    PLATFORM        = bsd-i586
+    VM_PLATFORM     = bsd_i486
+    HS_ARCH         = x86
+    # We have to reset ARCH to i386 since SRCARCH relies on it
+    ARCH            = i386   
+  endif
+endif
+
+# i386
+ifeq ($(ARCH), i386)
+  ifeq ($(ARCH_DATA_MODEL), 64)
+    ARCH_DATA_MODEL = 64
+    MAKE_ARGS       += LP64=1
+    PLATFORM        = bsd-amd64
+    VM_PLATFORM     = bsd_amd64
+    HS_ARCH         = x86
+    # We have to reset ARCH to amd64 since SRCARCH relies on it
+    ARCH            = amd64
+  else
+    ARCH_DATA_MODEL  = 32
+    PLATFORM         = bsd-i586
+    VM_PLATFORM      = bsd_i486
+    HS_ARCH          = x86
+  endif
+endif
+
+# ARM
+ifeq ($(ARCH), arm)
+  ARCH_DATA_MODEL  = 32
+  PLATFORM         = bsd-arm
+  VM_PLATFORM      = bsd_arm
+  HS_ARCH          = arm
+endif
+
+# PPC
+ifeq ($(ARCH), ppc)
+  ARCH_DATA_MODEL  = 32
+  PLATFORM         = bsd-ppc
+  VM_PLATFORM      = bsd_ppc
+  HS_ARCH          = ppc
+endif
+
+JDK_INCLUDE_SUBDIR=bsd
+
+# Library suffix
+OS_VENDOR:=$(shell uname -s)
+ifeq ($(OS_VENDOR),Darwin)
+  LIBRARY_SUFFIX=dylib
+else
+  LIBRARY_SUFFIX=so
+endif
+
+# FIXUP: The subdirectory for a debug build is NOT the same on all platforms
+VM_DEBUG=jvmg
+
+EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
+
+# client and server subdirectories have symbolic links to ../libjsig.so
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
+EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server
+
+ifndef BUILD_CLIENT_ONLY
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
+endif
+
+ifneq ($(ZERO_BUILD), true)
+  ifeq ($(ARCH_DATA_MODEL), 32)
+    EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
+  endif
+endif
+
+# Serviceability Binaries
+# No SA Support for PPC, IA64, ARM or zero
+ADD_SA_BINARIES/x86   = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
+                        $(EXPORT_LIB_DIR)/sa-jdi.jar
+ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
+                        $(EXPORT_LIB_DIR)/sa-jdi.jar
+ADD_SA_BINARIES/universal = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
+                            $(EXPORT_LIB_DIR)/sa-jdi.jar
+ADD_SA_BINARIES/ppc   =
+ADD_SA_BINARIES/ia64  =
+ADD_SA_BINARIES/arm   =
+ADD_SA_BINARIES/zero  =
+
+EXPORT_LIST += $(ADD_SA_BINARIES/$(HS_ARCH))
+
+UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX)
+UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libsaproc.$(LIBRARY_SUFFIX)
+UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX)
+
+UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/server/Xusage.txt
+UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/client/Xusage.txt
+UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/dtrace.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,303 @@
+#
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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 jvm_db/dtrace, used by vm.make
+
+# We build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2
+# but not for CORE or KERNEL configurations.
+
+ifneq ("${TYPE}", "CORE")
+ifneq ("${TYPE}", "KERNEL")
+
+ifeq ($(OS_VENDOR), Darwin)
+# we build dtrace for macosx using USDT2 probes
+
+DtraceOutDir = $(GENERATED)/dtracefiles
+
+# Bsd does not build libjvm_db, does not compile on macosx
+# disabled in build: rule in vm.make
+JVM_DB = libjvm_db
+#LIBJVM_DB = libjvm_db.dylib
+LIBJVM_DB = libjvm$(G_SUFFIX)_db.dylib
+
+JVM_DTRACE = jvm_dtrace
+#LIBJVM_DTRACE = libjvm_dtrace.dylib
+LIBJVM_DTRACE = libjvm$(G_SUFFIX)_dtrace.dylib
+
+JVMOFFS = JvmOffsets
+JVMOFFS.o = $(JVMOFFS).o
+GENOFFS = generate$(JVMOFFS)
+
+DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace
+DTRACE = dtrace
+DTRACE.o = $(DTRACE).o
+
+# to remove '-g' option which causes link problems
+# also '-z nodefs' is used as workaround
+GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';)
+
+ifdef LP64
+DTRACE_OPTS = -D_LP64
+endif
+
+# making libjvm_db
+
+# Use mapfile with libjvm_db.so
+LIBJVM_DB_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_db
+#LFLAGS_JVM_DB += $(MAPFLAG:FILENAME=$(LIBJVM_DB_MAPFILE))
+
+# Use mapfile with libjvm_dtrace.so
+LIBJVM_DTRACE_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace
+#LFLAGS_JVM_DTRACE += $(MAPFLAG:FILENAME=$(LIBJVM_DTRACE_MAPFILE))
+
+LFLAGS_JVM_DB += $(PICFLAG) # -D_REENTRANT
+LFLAGS_JVM_DTRACE += $(PICFLAG) # -D_REENTRANT
+
+ISA = $(subst i386,i486,$(BUILDARCH))
+
+# Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so
+ifneq ("${ISA}","${BUILDARCH}")
+
+XLIBJVM_DB = 64/$(LIBJVM_DB)
+XLIBJVM_DB_G = 64/$(LIBJVM_DB_G)
+XLIBJVM_DTRACE = 64/$(LIBJVM_DTRACE)
+XLIBJVM_DTRACE_G = 64/$(LIBJVM_DTRACE_G)
+XARCH = $(subst sparcv9,v9,$(shell echo $(ISA)))
+
+$(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
+	@echo Making $@
+	$(QUIETLY) mkdir -p 64/ ; \
+	$(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. -I$(GENERATED) \
+		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c #-lc
+#	[ -f $(XLIBJVM_DB_G) ] || { ln -s $(LIBJVM_DB) $(XLIBJVM_DB_G); }
+
+$(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
+	@echo Making $@
+	$(QUIETLY) mkdir -p 64/ ; \
+	$(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. \
+		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor
+#	[ -f $(XLIBJVM_DTRACE_G) ] || { ln -s $(LIBJVM_DTRACE) $(XLIBJVM_DTRACE_G); }
+
+endif # ifneq ("${ISA}","${BUILDARCH}")
+
+LFLAGS_GENOFFS += -L.
+
+lib$(GENOFFS).dylib: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
+                  $(LIBJVM.o)
+	$(QUIETLY) $(CCC) $(CPPFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
+		 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -ljvm
+
+$(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).dylib
+	$(QUIETLY) $(LINK.CC) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
+		./lib$(GENOFFS).dylib
+
+# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs.
+$(JVMOFFS).h: $(GENOFFS)
+	$(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -header > $@.tmp; touch $@; \
+	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
+	then rm -f $@; mv $@.tmp $@; \
+	else rm -f $@.tmp; \
+	fi
+
+$(JVMOFFS)Index.h: $(GENOFFS)
+	$(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -index > $@.tmp; touch $@; \
+	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
+	then rm -f $@; mv $@.tmp $@; \
+	else rm -f $@.tmp; \
+	fi
+
+$(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h
+	$(QUIETLY) DYLD_LIBRARY_PATH=. ./$(GENOFFS) -table > $@.tmp; touch $@; \
+	if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \
+	then rm -f $@; mv $@.tmp $@; \
+	else rm -f $@.tmp; \
+	fi
+
+$(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
+	$(QUIETLY) $(CCC) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
+
+$(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
+	@echo Making $@
+	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
+		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -Wall # -lc
+#	[ -f $(LIBJVM_DB_G) ] || { ln -s $@ $(LIBJVM_DB_G); }
+
+$(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
+	@echo Making $@
+	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I.  \
+		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor
+#	[ -f $(LIBJVM_DTRACE_G) ] || { ln -s $@ $(LIBJVM_DTRACE_G); }
+
+#$(DTRACE).d: $(DTRACE_SRCDIR)/hotspot.d $(DTRACE_SRCDIR)/hotspot_jni.d \
+#             $(DTRACE_SRCDIR)/hs_private.d $(DTRACE_SRCDIR)/jhelper.d
+#	$(QUIETLY) cat $^ > $@
+
+$(DtraceOutDir):
+	mkdir $(DtraceOutDir)
+
+$(DtraceOutDir)/hotspot.h: $(DTRACE_SRCDIR)/hotspot.d | $(DtraceOutDir)
+	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot.d
+
+$(DtraceOutDir)/hotspot_jni.h: $(DTRACE_SRCDIR)/hotspot_jni.d | $(DtraceOutDir)
+	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hotspot_jni.d
+
+$(DtraceOutDir)/hs_private.h: $(DTRACE_SRCDIR)/hs_private.d | $(DtraceOutDir)
+	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/hs_private.d
+
+$(DtraceOutDir)/jhelper.h: $(DTRACE_SRCDIR)/jhelper.d $(JVMOFFS).o | $(DtraceOutDir)
+	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_SRCDIR)/jhelper.d
+
+# jhelper currently disabled
+dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h 
+
+DTraced_Files = ciEnv.o \
+                classLoadingService.o \
+                compileBroker.o \
+                hashtable.o \
+                instanceKlass.o \
+                java.o \
+                jni.o \
+                jvm.o \
+                memoryManager.o \
+                nmethod.o \
+                objectMonitor.o \
+                runtimeService.o \
+                sharedRuntime.o \
+                synchronizer.o \
+                thread.o \
+                unsafe.o \
+                vmThread.o \
+                vmCMSOperations.o \
+                vmPSOperations.o \
+                vmGCOperations.o \
+
+# Dtrace is available, so we build $(DTRACE.o)  
+#$(DTRACE.o): $(DTRACE).d $(JVMOFFS).h $(JVMOFFS)Index.h $(DTraced_Files)
+#	@echo Compiling $(DTRACE).d
+
+#	$(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -xlazyload -o $@ -s $(DTRACE).d \
+#     $(DTraced_Files) ||\
+#  STATUS=$$?;\
+#	if [ x"$$STATUS" = x"1" -a \
+#       x`uname -r` = x"5.10" -a \
+#       x`uname -p` = x"sparc" ]; then\
+#    echo "*****************************************************************";\
+#    echo "* If you are building server compiler, and the error message is ";\
+#    echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\
+#    echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\
+#    echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\
+#    echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\
+#    echo "* dtrace probes for this build.";\
+#    echo "*****************************************************************";\
+#  fi;\
+#  exit $$STATUS
+  # Since some DTraced_Files are in LIBJVM.o and they are touched by this
+  # command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will
+  # think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets*
+  # files, but it doesn't, so we touch the necessary files to prevent later
+  # recompilation. Note: we only touch the necessary files if they already
+  # exist in order to close a race where an empty file can be created
+  # before the real build rule is executed.
+  # But, we can't touch the *.h files:  This rule depends
+  # on them, and that would cause an infinite cycle of rebuilding.
+  # Neither the *.h or *.ccp files need to be touched, since they have
+  # rules which do not update them when the generator file has not
+  # changed their contents.
+#	$(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi
+#	$(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi
+#	$(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi
+
+.PHONY: dtraceCheck
+
+#SYSTEM_DTRACE_H = /usr/include/dtrace.h
+SYSTEM_DTRACE_PROG = /usr/sbin/dtrace
+#PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace
+systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG})
+#patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG})
+#systemDtraceHdrFound := $(wildcard $(SYSTEM_DTRACE_H))
+
+#ifneq ("$(systemDtraceHdrFound)", "") 
+#CFLAGS += -DHAVE_DTRACE_H
+#endif
+
+#ifneq ("$(patchDtraceFound)", "")
+#DTRACE_PROG=$(PATCH_DTRACE_PROG)
+#DTRACE_INCL=-I/opt/SUNWdtrd/include
+#else
+ifneq ("$(systemDtraceFound)", "")
+DTRACE_PROG=$(SYSTEM_DTRACE_PROG)
+else
+
+endif # ifneq ("$(systemDtraceFound)", "")
+#endif # ifneq ("$(patchDtraceFound)", "")
+
+ifneq ("${DTRACE_PROG}", "")
+ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
+
+DTRACE_OBJS = $(DTRACE.o) #$(JVMOFFS.o)
+CFLAGS += -DDTRACE_ENABLED #$(DTRACE_INCL)
+#clangCFLAGS += -DDTRACE_ENABLED -fno-optimize-sibling-calls
+#MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE)
+
+
+dtraceCheck:
+
+dtrace_stuff: dtrace_gen_headers
+	$(QUIETLY) echo "dtrace headers generated"
+
+
+else # manually disabled
+
+dtraceCheck:
+	$(QUIETLY) echo "**NOTICE** Dtrace support disabled via environment variable"
+
+dtrace_stuff:
+
+endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "")
+
+else # No dtrace program found
+
+dtraceCheck:
+	$(QUIETLY) echo "**NOTICE** Dtrace support disabled: not supported by system"
+
+dtrace_stuff:
+
+endif # ifneq ("${dtraceFound}", "")
+
+endif # ifeq ($(OS_VENDOR), Darwin)
+
+
+else # KERNEL build
+
+dtraceCheck:
+	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for KERNEL builds"
+
+endif # ifneq ("${TYPE}", "KERNEL")
+
+else # CORE build
+
+dtraceCheck:
+	$(QUIETLY) echo "**NOTICE** Dtrace support disabled for CORE builds"
+
+endif # ifneq ("${TYPE}", "CORE")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/fastdebug.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,64 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making debug version of VM
+
+# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
+OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
+OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
+
+# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
+
+ifeq ($(BUILDARCH), ia64)
+  # Bug in GCC, causes hang.  -O1 will override the -O3 specified earlier
+  OPT_CFLAGS/callGenerator.o += -O1
+  OPT_CFLAGS/ciTypeFlow.o += -O1
+  OPT_CFLAGS/compile.o += -O1
+  OPT_CFLAGS/concurrentMarkSweepGeneration.o += -O1
+  OPT_CFLAGS/doCall.o += -O1
+  OPT_CFLAGS/generateOopMap.o += -O1
+  OPT_CFLAGS/generateOptoStub.o += -O1
+  OPT_CFLAGS/graphKit.o += -O1
+  OPT_CFLAGS/instanceKlass.o += -O1
+  OPT_CFLAGS/interpreterRT_ia64.o += -O1
+  OPT_CFLAGS/output.o += -O1
+  OPT_CFLAGS/parse1.o += -O1
+  OPT_CFLAGS/runtime.o += -O1
+  OPT_CFLAGS/synchronizer.o += -O1
+endif
+
+
+# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
+CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
+
+# Set the environment variable HOTSPARC_GENERIC to "true"
+# to inhibit the effect of the previous line on CFLAGS.
+
+# Linker mapfile
+MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug
+
+G_SUFFIX = _g
+VERSION = optimized
+SYSDEFS += -DASSERT -DFASTDEBUG
+PICFLAGS = DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/gcc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,307 @@
+#
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+OS_VENDOR = $(shell uname -s)
+
+#------------------------------------------------------------------------
+# CC, CPP & AS
+
+# When cross-compiling the ALT_COMPILER_PATH points
+# to the cross-compilation toolset
+ifdef CROSS_COMPILE_ARCH
+ CPP = $(ALT_COMPILER_PATH)/g++
+ CC  = $(ALT_COMPILER_PATH)/gcc
+ HOSTCPP = g++
+ HOSTCC  = gcc
+else ifneq ($(OS_VENDOR), Darwin)
+ CXX = g++
+ CPP = $(CXX)
+ CC  = gcc
+ HOSTCPP = $(CPP)
+ HOSTCC  = $(CC)
+endif
+
+# i486 hotspot requires -mstackrealign on Darwin.
+# llvm-gcc supports this in Xcode 3.2.6 and 4.0.
+# gcc-4.0 supports this on earlier versions.
+# Prefer llvm-gcc where available.
+ifeq ($(OS_VENDOR), Darwin)
+  ifeq ($(origin CXX), default)
+   CXX = llvm-g++
+  endif
+  ifeq ($(origin CC), default)
+   CC  = llvm-gcc
+  endif
+  CPP  = $(CXX)
+
+  ifeq ($(ARCH), i486)
+  LLVM_SUPPORTS_STACKREALIGN := $(shell \
+   [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
+   && echo true || echo false)
+
+  ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
+    CXX32 ?= llvm-g++
+    CC32  ?= llvm-gcc
+  else
+    CXX32 ?= g++-4.0
+    CC32  ?= gcc-4.0
+  endif
+  CPP = $(CXX32)
+  CC  = $(CC32)
+  endif
+
+  HOSTCPP = $(CPP)
+  HOSTCC  = $(CC)
+endif
+
+AS   = $(CC) -c -x assembler-with-cpp
+
+# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
+# prints the numbers (e.g. "2.95", "3.2.1")
+CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
+CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
+
+# check for precompiled headers support
+ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0"
+# Allow the user to turn off precompiled headers from the command line.
+ifneq ($(USE_PRECOMPILED_HEADER),0)
+USE_PRECOMPILED_HEADER=1
+PRECOMPILED_HEADER_DIR=.
+PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp
+PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch
+endif
+endif
+
+
+#------------------------------------------------------------------------
+# Compiler flags
+
+# position-independent code
+PICFLAG = -fPIC
+
+VM_PICFLAG/LIBJVM = $(PICFLAG)
+VM_PICFLAG/AOUT   =
+VM_PICFLAG        = $(VM_PICFLAG/$(LINK_INTO))
+
+ifeq ($(ZERO_BUILD), true)
+CFLAGS += $(LIBFFI_CFLAGS)
+endif
+ifeq ($(SHARK_BUILD), true)
+CFLAGS += $(LLVM_CFLAGS)
+endif
+CFLAGS += $(VM_PICFLAG)
+CFLAGS += -fno-rtti
+CFLAGS += -fno-exceptions
+CFLAGS += -pthread
+CFLAGS += -fcheck-new
+# version 4 and above support fvisibility=hidden (matches jni_x86.h file)
+# except 4.1.2 gives pointless warnings that can't be disabled (afaik)
+ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
+CFLAGS += -fvisibility=hidden
+endif
+
+ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
+ARCHFLAG/i486    = -m32 -march=i586
+ARCHFLAG/amd64   = -m64
+ARCHFLAG/ia64    =
+ARCHFLAG/sparc   = -m32 -mcpu=v9
+ARCHFLAG/sparcv9 = -m64 -mcpu=v9
+ARCHFLAG/zero    = $(ZERO_ARCHFLAG)
+
+# Darwin-specific build flags
+ifeq ($(OS_VENDOR), Darwin)
+  # Ineffecient 16-byte stack re-alignment on Darwin/IA32
+  ARCHFLAG/i486 += -mstackrealign
+endif
+
+CFLAGS     += $(ARCHFLAG)
+AOUT_FLAGS += $(ARCHFLAG)
+LFLAGS     += $(ARCHFLAG)
+ASFLAGS    += $(ARCHFLAG)
+
+ifdef E500V2
+CFLAGS += -DE500V2
+endif
+
+# Use C++ Interpreter
+ifdef CC_INTERP
+  CFLAGS += -DCC_INTERP
+endif
+
+# Build for embedded targets
+ifdef JAVASE_EMBEDDED
+  CFLAGS += -DJAVASE_EMBEDDED
+endif
+
+# Keep temporary files (.ii, .s)
+ifdef NEED_ASM
+  CFLAGS += -save-temps
+else
+  CFLAGS += -pipe
+endif
+
+# Compiler warnings are treated as errors
+ifneq ($(COMPILER_WARNINGS_FATAL),false)
+  WARNINGS_ARE_ERRORS = -Werror
+endif
+
+# Except for a few acceptable ones
+# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
+# conversions which might affect the values. To avoid that, we need to turn
+# it off explicitly. 
+ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
+ACCEPTABLE_WARNINGS = -Wpointer-arith -Wsign-compare
+else
+ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare
+endif
+
+CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS)
+# Special cases
+CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
+# XXXDARWIN: for _dyld_bind_fully_image_containing_address
+ifeq ($(OS_VENDOR), Darwin)
+  CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations
+endif
+
+
+# The flags to use for an Optimized g++ build
+ifeq ($(OS_VENDOR), Darwin)
+  # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
+  # <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
+  OPT_CFLAGS += -Os
+else
+  OPT_CFLAGS += -O3
+endif
+
+# Hotspot uses very unstrict aliasing turn this optimization off
+OPT_CFLAGS += -fno-strict-aliasing
+
+# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp 
+# if we use expensive-optimizations
+ifeq ($(BUILDARCH), ia64)
+OPT_CFLAGS += -fno-expensive-optimizations
+endif
+
+OPT_CFLAGS/NOOPT=-O0
+
+# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. 
+ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0"
+OPT_CFLAGS/mulnode.o += -O0
+endif
+
+# Flags for generating make dependency flags.
+ifneq ("${CC_VER_MAJOR}", "2")
+DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d)
+endif
+
+# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
+ifneq ($(USE_PRECOMPILED_HEADER),1)
+CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
+endif
+
+#------------------------------------------------------------------------
+# Linker flags
+
+# statically link libstdc++.so, work with gcc but ignored by g++
+STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
+
+# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x.
+ifneq ("${CC_VER_MAJOR}", "2")
+STATIC_LIBGCC += -static-libgcc
+endif
+
+ifeq ($(BUILDARCH), ia64)
+LFLAGS += -Wl,-relax
+endif
+
+# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
+MAPFLAG = -Xlinker --version-script=FILENAME
+
+#
+# Shared Library
+#
+ifeq ($(OS_VENDOR), Darwin)
+  # Standard linker flags
+  LFLAGS +=
+
+  # Darwin doesn't use ELF and doesn't support version scripts
+  LDNOMAP = true
+
+  # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
+  SONAMEFLAG =
+
+  # Build shared library
+  SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG)
+
+  # Keep symbols even they are not used
+  #AOUT_FLAGS += -Xlinker -export-dynamic
+else
+  # Enable linker optimization
+  LFLAGS += -Xlinker -O1
+
+  # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
+  SONAMEFLAG = -Xlinker -soname=SONAME
+
+  # Build shared library
+  SHARED_FLAG = -shared $(VM_PICFLAG)
+
+  # Keep symbols even they are not used
+  AOUT_FLAGS += -Xlinker -export-dynamic
+endif
+
+#------------------------------------------------------------------------
+# Debug flags
+
+# 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_g.so is only about 16M.
+# Change this back to "-g" if you want the most expressive format.
+# (warning: that could easily inflate libjvm_g.so to 150M!)
+# Note: The Itanium gcc compiler crashes when using -gstabs.
+DEBUG_CFLAGS/ia64  = -g
+DEBUG_CFLAGS/amd64 = -g
+DEBUG_CFLAGS/arm   = -g
+DEBUG_CFLAGS/ppc   = -g
+DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
+ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
+DEBUG_CFLAGS += -gstabs
+endif
+
+# DEBUG_BINARIES overrides everything, use full -g debug information
+ifeq ($(DEBUG_BINARIES), true)
+  DEBUG_CFLAGS = -g
+  CFLAGS += $(DEBUG_CFLAGS)
+endif
+
+# If we are building HEADLESS, pass on to VM
+# so it can set the java.awt.headless property
+ifdef HEADLESS
+CFLAGS += -DHEADLESS
+endif
+
+# We are building Embedded for a small device
+# favor code space over speed
+ifdef MINIMIZE_RAM_USAGE
+CFLAGS += -DMINIMIZE_RAM_USAGE
+endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/hp.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making premium version of VM
+
+TYPE=HP
+
+CFLAGS += -DCOMPILER2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/hp1.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making premium version of VM
+
+TYPE=HP1
+
+CFLAGS += -DCOMPILER1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/i486.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# TLS helper, assembled from .s file
+
+# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
+OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
+# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
+OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+# Must also specify if CPU is little endian
+CFLAGS += -DVM_LITTLE_ENDIAN
+
+OPT_CFLAGS/compactingPermGenGen.o = -O1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/ia64.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+#
+# IA64 only uses c++ based interpreter
+CFLAGS += -DCC_INTERP -D_LP64=1 -DVM_LITTLE_ENDIAN
+# Hotspot uses very unstrict aliasing turn this optimization off
+OPT_CFLAGS += -fno-strict-aliasing
+ifeq ($(VERSION),debug)
+ASM_FLAGS= -DDEBUG
+else
+ASM_FLAGS=
+endif
+# workaround gcc bug in compiling varargs
+OPT_CFLAGS/jni.o = -O0
+
+# gcc/ia64 has a bug that internal gcc functions linked with libjvm.so
+# are made public. Hiding those symbols will cause undefined symbol error
+# when VM is dropped into older JDK. We probably will need an IA64
+# mapfile to include those symbols as a workaround. Disable linker mapfile 
+# for now.
+LDNOMAP=true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/jsig.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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 signal interposition library, used by vm.make
+
+# libjsig[_g].so: signal interposition library
+JSIG   = jsig
+JSIG_G = $(JSIG)$(G_SUFFIX)
+
+ifeq ($(OS_VENDOR), Darwin)
+  LIBJSIG   = lib$(JSIG).dylib
+  LIBJSIG_G = lib$(JSIG_G).dylib
+else
+  LIBJSIG   = lib$(JSIG).so
+  LIBJSIG_G = lib$(JSIG_G).so
+endif
+
+JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm
+
+DEST_JSIG  = $(JDK_LIBDIR)/$(LIBJSIG)
+
+LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
+
+# On Bsd we really dont want a mapfile, as this library is small 
+# and preloaded using LD_PRELOAD, making functions private will 
+# cause problems with interposing. See CR: 6466665
+# LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE))
+
+LFLAGS_JSIG += -D_GNU_SOURCE -pthread $(LDFLAGS_HASH_STYLE)
+
+# DEBUG_BINARIES overrides everything, use full -g debug information
+ifeq ($(DEBUG_BINARIES), true)
+  JSIG_DEBUG_CFLAGS = -g
+endif
+
+$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE)
+	@echo Making signal interposition lib...
+	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
+                         $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $@ $<
+	$(QUIETLY) [ -f $(LIBJSIG_G) ] || { ln -s $@ $(LIBJSIG_G); }
+
+install_jsig: $(LIBJSIG)
+	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
+	$(QUIETLY) cp -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
+
+.PHONY: install_jsig
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/jvmg.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making debug version of VM
+
+# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make
+DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS)
+DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@))
+CFLAGS += $(DEBUG_CFLAGS/BYFILE)
+
+# Set the environment variable HOTSPARC_GENERIC to "true"
+# to inhibit the effect of the previous line on CFLAGS.
+
+# Linker mapfile
+MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug
+
+G_SUFFIX = _g
+VERSION = debug
+SYSDEFS += -DASSERT -DDEBUG
+PICFLAGS = DEFAULT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/jvmti.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,117 @@
+#
+# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# This makefile (jvmti.make) is included from the jvmti.make in the
+# build directories.
+#
+# It knows how to build and run the tools to generate jvmti.
+
+include $(GAMMADIR)/make/bsd/makefiles/rules.make
+
+# #########################################################################
+
+TOPDIR      = $(shell echo `pwd`)
+GENERATED   = $(TOPDIR)/../generated
+JvmtiOutDir = $(GENERATED)/jvmtifiles
+
+JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims
+InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter
+
+# set VPATH so make knows where to look for source files
+Src_Dirs_V += $(JvmtiSrcDir)
+VPATH += $(Src_Dirs_V:%=%:)
+
+JvmtiGeneratedNames = \
+        jvmtiEnv.hpp \
+        jvmtiEnter.cpp \
+        jvmtiEnterTrace.cpp \
+        jvmtiEnvRecommended.cpp \
+        bytecodeInterpreterWithChecks.cpp \
+        jvmti.h \
+
+JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java
+JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class
+
+JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java
+JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class
+
+JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%)
+
+XSLT = $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen
+
+.PHONY: all jvmtidocs clean cleanall
+
+# #########################################################################
+
+all: $(JvmtiGeneratedFiles)
+
+both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl
+
+$(JvmtiGenClass): $(JvmtiGenSource)
+	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource)
+
+$(JvmtiEnvFillClass): $(JvmtiEnvFillSource)
+	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource)
+
+$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
+	@echo Generating $@
+	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti
+
+$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl
+	@echo Generating $@
+	$(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp 
+
+$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl
+	@echo Generating $@
+	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace
+
+$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass)
+	@echo Generating $@
+	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp
+	$(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp
+
+$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl
+	@echo Generating $@
+	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp
+
+$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl
+	@echo Generating $@
+	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h
+
+jvmtidocs:  $(JvmtiOutDir)/jvmti.html 
+
+$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl
+	@echo Generating $@
+	$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html
+
+# #########################################################################
+
+clean :
+	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
+
+cleanall :
+	rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles)
+
+# #########################################################################
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/launcher.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,93 @@
+#
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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 gamma launcher, used by vm.make
+
+
+LAUNCHER_SCRIPT = hotspot
+LAUNCHER   = gamma
+
+LAUNCHERDIR   := $(GAMMADIR)/src/os/posix/launcher
+LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
+LAUNCHERFLAGS := $(ARCHFLAG) \
+                -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
+                -I$(LAUNCHERDIR_SHARE) \
+                -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
+                -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
+                -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
+                -DARCH=\"$(LIBARCH)\" \
+                -DGAMMA \
+                -DLAUNCHER_TYPE=\"gamma\" \
+                -DLINK_INTO_$(LINK_INTO) \
+                $(TARGET_DEFINES)
+
+ifeq ($(LINK_INTO),AOUT)
+  LAUNCHER.o                 = launcher.o $(JVM_OBJ_FILES)
+  LAUNCHER_MAPFILE           = mapfile_reorder
+  LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
+  LFLAGS_LAUNCHER           += $(SONAMEFLAG:SONAME=$(LIBJVM)) $(STATIC_LIBGCC)
+  LIBS_LAUNCHER             += $(STATIC_STDCXX) $(LIBS)
+else
+  LAUNCHER.o                 = launcher.o
+  LFLAGS_LAUNCHER           += -L`pwd`
+  LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
+endif
+
+LINK_LAUNCHER = $(LINK.c)
+
+LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CC/PRE_HOOK)
+LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CC/POST_HOOK)
+
+LAUNCHER_OUT = launcher
+
+SUFFIXES += .d
+
+SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
+SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
+
+OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
+
+DEPFILES := $(patsubst %.o,%.d,$(OBJS))
+-include $(DEPFILES)
+
+$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
+	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
+	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CPPFLAGS)
+
+$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
+	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
+	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CPPFLAGS)
+
+$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
+	$(QUIETLY) echo Linking launcher...
+	$(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
+	$(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(OBJS) $(LIBS_LAUNCHER)
+	$(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
+
+$(LAUNCHER): $(LAUNCHER_SCRIPT)
+
+$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
+	$(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
+	$(QUIETLY) chmod +x $@
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-debug	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,291 @@
+#
+# @(#)mapfile-vers-debug	1.18 07/10/25 16:47:35
+#
+
+#
+# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# Define public interface.
+
+SUNWprivate_1.1 {
+        global:
+                # JNI
+                JNI_CreateJavaVM;
+                JNI_GetCreatedJavaVMs;
+                JNI_GetDefaultJavaVMInitArgs;
+
+                # JVM
+                JVM_Accept;
+                JVM_ActiveProcessorCount;
+                JVM_AllocateNewArray;
+                JVM_AllocateNewObject;
+                JVM_ArrayCopy;
+                JVM_AssertionStatusDirectives;
+                JVM_Available;
+                JVM_Bind;
+                JVM_ClassDepth;
+                JVM_ClassLoaderDepth;
+                JVM_Clone;
+                JVM_Close;
+                JVM_CX8Field;
+                JVM_CompileClass;
+                JVM_CompileClasses;
+                JVM_CompilerCommand;
+                JVM_Connect;
+                JVM_ConstantPoolGetClassAt;
+                JVM_ConstantPoolGetClassAtIfLoaded;
+                JVM_ConstantPoolGetDoubleAt;
+                JVM_ConstantPoolGetFieldAt;
+                JVM_ConstantPoolGetFieldAtIfLoaded;
+                JVM_ConstantPoolGetFloatAt;
+                JVM_ConstantPoolGetIntAt;
+                JVM_ConstantPoolGetLongAt;
+                JVM_ConstantPoolGetMethodAt;
+                JVM_ConstantPoolGetMethodAtIfLoaded;
+                JVM_ConstantPoolGetMemberRefInfoAt;
+                JVM_ConstantPoolGetSize;
+                JVM_ConstantPoolGetStringAt;
+                JVM_ConstantPoolGetUTF8At;
+                JVM_CountStackFrames;
+                JVM_CurrentClassLoader;
+                JVM_CurrentLoadedClass;
+                JVM_CurrentThread;
+                JVM_CurrentTimeMillis;
+                JVM_DefineClass;
+                JVM_DefineClassWithSource;
+                JVM_DefineClassWithSourceCond;
+                JVM_DesiredAssertionStatus;
+                JVM_DisableCompiler;
+                JVM_DoPrivileged;
+                JVM_DTraceGetVersion;
+                JVM_DTraceActivate;
+                JVM_DTraceIsProbeEnabled;
+                JVM_DTraceIsSupported;
+                JVM_DTraceDispose;
+                JVM_DumpAllStacks;
+                JVM_DumpThreads;
+                JVM_EnableCompiler;
+                JVM_Exit;
+                JVM_FillInStackTrace;
+                JVM_FindClassFromClass;
+                JVM_FindClassFromClassLoader;
+                JVM_FindClassFromBootLoader;
+                JVM_FindLibraryEntry;
+                JVM_FindLoadedClass;
+                JVM_FindPrimitiveClass;
+                JVM_FindSignal;
+                JVM_FreeMemory;
+                JVM_GC;
+                JVM_GetAllThreads;
+                JVM_GetArrayElement;
+                JVM_GetArrayLength;
+                JVM_GetCPClassNameUTF;
+                JVM_GetCPFieldClassNameUTF;
+                JVM_GetCPFieldModifiers;
+                JVM_GetCPFieldNameUTF;
+                JVM_GetCPFieldSignatureUTF;
+                JVM_GetCPMethodClassNameUTF;
+                JVM_GetCPMethodModifiers;
+                JVM_GetCPMethodNameUTF;
+                JVM_GetCPMethodSignatureUTF;
+                JVM_GetCallerClass;
+                JVM_GetClassAccessFlags;
+                JVM_GetClassAnnotations;
+                JVM_GetClassCPEntriesCount;
+                JVM_GetClassCPTypes;
+                JVM_GetClassConstantPool;
+                JVM_GetClassContext;
+                JVM_GetClassDeclaredConstructors;
+                JVM_GetClassDeclaredFields;
+                JVM_GetClassDeclaredMethods;
+                JVM_GetClassFieldsCount;
+                JVM_GetClassInterfaces;
+                JVM_GetClassLoader;
+                JVM_GetClassMethodsCount;
+                JVM_GetClassModifiers;
+                JVM_GetClassName;
+                JVM_GetClassNameUTF;
+		JVM_GetClassSignature;
+                JVM_GetClassSigners;
+                JVM_GetComponentType;
+                JVM_GetDeclaredClasses;
+                JVM_GetDeclaringClass;
+                JVM_GetEnclosingMethodInfo;
+                JVM_GetFieldAnnotations;
+                JVM_GetFieldIxModifiers;
+                JVM_GetHostName;
+                JVM_GetInheritedAccessControlContext;
+                JVM_GetInterfaceVersion;
+                JVM_GetLastErrorString;
+                JVM_GetManagement;
+                JVM_GetMethodAnnotations;
+                JVM_GetMethodDefaultAnnotationValue;
+                JVM_GetMethodIxArgsSize;
+                JVM_GetMethodIxByteCode;
+                JVM_GetMethodIxByteCodeLength;
+                JVM_GetMethodIxExceptionIndexes;
+                JVM_GetMethodIxExceptionTableEntry;
+                JVM_GetMethodIxExceptionTableLength;
+                JVM_GetMethodIxExceptionsCount;
+                JVM_GetMethodIxLocalsCount;
+                JVM_GetMethodIxMaxStack;
+                JVM_GetMethodIxModifiers;
+                JVM_GetMethodIxNameUTF;
+                JVM_GetMethodIxSignatureUTF;
+                JVM_GetMethodParameterAnnotations;
+                JVM_GetPrimitiveArrayElement;
+                JVM_GetProtectionDomain;
+                JVM_GetSockName;
+                JVM_GetSockOpt;
+                JVM_GetStackAccessControlContext;
+                JVM_GetStackTraceDepth;
+                JVM_GetStackTraceElement;
+                JVM_GetSystemPackage;
+                JVM_GetSystemPackages;
+                JVM_GetThreadStateNames;
+                JVM_GetThreadStateValues;
+                JVM_GetVersionInfo;
+                JVM_Halt;
+                JVM_HoldsLock;
+                JVM_IHashCode;
+                JVM_InitAgentProperties;
+                JVM_InitProperties;
+                JVM_InitializeCompiler;
+                JVM_InitializeSocketLibrary;
+                JVM_InternString;
+                JVM_Interrupt;
+                JVM_InvokeMethod;
+                JVM_IsArrayClass;
+                JVM_IsConstructorIx;
+                JVM_IsInterface;
+                JVM_IsInterrupted;
+                JVM_IsNaN;
+                JVM_IsPrimitiveClass;
+                JVM_IsSameClassPackage;
+                JVM_IsSilentCompiler;
+                JVM_IsSupportedJNIVersion;
+                JVM_IsThreadAlive;
+                JVM_LatestUserDefinedLoader;
+                JVM_Listen;
+                JVM_LoadClass0;
+                JVM_LoadLibrary;
+                JVM_Lseek;
+                JVM_MaxObjectInspectionAge;
+                JVM_MaxMemory;
+                JVM_MonitorNotify;
+                JVM_MonitorNotifyAll;
+                JVM_MonitorWait;
+                JVM_NanoTime;
+                JVM_NativePath;
+                JVM_NewArray;
+                JVM_NewInstanceFromConstructor;
+                JVM_NewMultiArray;
+                JVM_OnExit;
+                JVM_Open;
+                JVM_PrintStackTrace;
+                JVM_RaiseSignal;
+                JVM_RawMonitorCreate;
+                JVM_RawMonitorDestroy;
+                JVM_RawMonitorEnter;
+                JVM_RawMonitorExit;
+                JVM_Read;
+                JVM_Recv;
+                JVM_RecvFrom;
+                JVM_RegisterSignal;
+                JVM_ReleaseUTF;
+                JVM_ResolveClass;
+                JVM_ResumeThread;
+                JVM_Send;
+                JVM_SendTo;
+                JVM_SetArrayElement;
+                JVM_SetClassSigners;
+                JVM_SetLength;
+                JVM_SetPrimitiveArrayElement;
+                JVM_SetProtectionDomain;
+                JVM_SetSockOpt;
+                JVM_SetThreadPriority;
+                JVM_Sleep;
+                JVM_Socket;
+                JVM_SocketAvailable;
+                JVM_SocketClose;
+                JVM_SocketShutdown;
+                JVM_StartThread;
+                JVM_StopThread;
+                JVM_SuspendThread;
+                JVM_SupportsCX8;
+                JVM_Sync;
+                JVM_Timeout;
+                JVM_TotalMemory;
+                JVM_TraceInstructions;
+                JVM_TraceMethodCalls;
+                JVM_UnloadLibrary;
+                JVM_Write;
+                JVM_Yield;
+                JVM_handle_bsd_signal;
+
+                # Old reflection routines
+                # These do not need to be present in the product build in JDK 1.4
+                # but their code has not been removed yet because there will not
+                # be a substantial code savings until JVM_InvokeMethod and
+                # JVM_NewInstanceFromConstructor can also be removed; see
+                # reflectionCompat.hpp.
+                JVM_GetClassConstructor;
+                JVM_GetClassConstructors;
+                JVM_GetClassField;
+                JVM_GetClassFields;
+                JVM_GetClassMethod;
+                JVM_GetClassMethods;
+                JVM_GetField;
+                JVM_GetPrimitiveField;
+                JVM_NewInstance;
+                JVM_SetField;
+                JVM_SetPrimitiveField;
+
+                # debug JVM
+                JVM_AccessVMBooleanFlag;
+                JVM_AccessVMIntFlag;
+                JVM_VMBreakPoint;
+
+                # miscellaneous functions
+                jio_fprintf;
+                jio_printf;
+                jio_snprintf;
+                jio_vfprintf;
+                jio_vsnprintf;
+                fork1;
+                numa_warn;
+                numa_error;
+
+                # Needed because there is no JVM interface for this.
+                sysThreadAvailableStackWithSlack;
+
+                # This is for Forte Analyzer profiling support.
+                AsyncGetCallTrace;
+
+		# INSERT VTABLE SYMBOLS HERE
+
+        local:
+                *;
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-jsig	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,40 @@
+#
+
+#
+# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Define library interface.
+
+SUNWprivate_1.1 {
+        global:
+            JVM_begin_signal_setting;
+            JVM_end_signal_setting;
+            JVM_get_libjsig_version;
+            JVM_get_signal_action;
+            sigaction;
+            signal;
+            sigset;
+        local:
+                *;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-product	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,286 @@
+#
+# @(#)mapfile-vers-product	1.19 08/02/12 10:56:37
+#
+
+#
+# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# Define public interface.
+
+SUNWprivate_1.1 {
+        global:
+                # JNI
+                JNI_CreateJavaVM;
+                JNI_GetCreatedJavaVMs;
+                JNI_GetDefaultJavaVMInitArgs;
+
+                # JVM
+                JVM_Accept;
+                JVM_ActiveProcessorCount;
+                JVM_AllocateNewArray;
+                JVM_AllocateNewObject;
+                JVM_ArrayCopy;
+                JVM_AssertionStatusDirectives;
+                JVM_Available;
+                JVM_Bind;
+                JVM_ClassDepth;
+                JVM_ClassLoaderDepth;
+                JVM_Clone;
+                JVM_Close;
+                JVM_CX8Field;
+                JVM_CompileClass;
+                JVM_CompileClasses;
+                JVM_CompilerCommand;
+                JVM_Connect;
+                JVM_ConstantPoolGetClassAt;
+                JVM_ConstantPoolGetClassAtIfLoaded;
+                JVM_ConstantPoolGetDoubleAt;
+                JVM_ConstantPoolGetFieldAt;
+                JVM_ConstantPoolGetFieldAtIfLoaded;
+                JVM_ConstantPoolGetFloatAt;
+                JVM_ConstantPoolGetIntAt;
+                JVM_ConstantPoolGetLongAt;
+                JVM_ConstantPoolGetMethodAt;
+                JVM_ConstantPoolGetMethodAtIfLoaded;
+                JVM_ConstantPoolGetMemberRefInfoAt;
+                JVM_ConstantPoolGetSize;
+                JVM_ConstantPoolGetStringAt;
+                JVM_ConstantPoolGetUTF8At;
+                JVM_CountStackFrames;
+                JVM_CurrentClassLoader;
+                JVM_CurrentLoadedClass;
+                JVM_CurrentThread;
+                JVM_CurrentTimeMillis;
+                JVM_DefineClass;
+                JVM_DefineClassWithSource;
+                JVM_DefineClassWithSourceCond;
+                JVM_DesiredAssertionStatus;
+                JVM_DisableCompiler;
+                JVM_DoPrivileged;
+                JVM_DTraceGetVersion;
+                JVM_DTraceActivate;
+                JVM_DTraceIsProbeEnabled;
+                JVM_DTraceIsSupported;
+                JVM_DTraceDispose;
+                JVM_DumpAllStacks;
+                JVM_DumpThreads;
+                JVM_EnableCompiler;
+                JVM_Exit;
+                JVM_FillInStackTrace;
+                JVM_FindClassFromClass;
+                JVM_FindClassFromClassLoader;
+                JVM_FindClassFromBootLoader;
+                JVM_FindLibraryEntry;
+                JVM_FindLoadedClass;
+                JVM_FindPrimitiveClass;
+                JVM_FindSignal;
+                JVM_FreeMemory;
+                JVM_GC;
+                JVM_GetAllThreads;
+                JVM_GetArrayElement;
+                JVM_GetArrayLength;
+                JVM_GetCPClassNameUTF;
+                JVM_GetCPFieldClassNameUTF;
+                JVM_GetCPFieldModifiers;
+                JVM_GetCPFieldNameUTF;
+                JVM_GetCPFieldSignatureUTF;
+                JVM_GetCPMethodClassNameUTF;
+                JVM_GetCPMethodModifiers;
+                JVM_GetCPMethodNameUTF;
+                JVM_GetCPMethodSignatureUTF;
+                JVM_GetCallerClass;
+                JVM_GetClassAccessFlags;
+                JVM_GetClassAnnotations;
+                JVM_GetClassCPEntriesCount;
+                JVM_GetClassCPTypes;
+                JVM_GetClassConstantPool;
+                JVM_GetClassContext;
+                JVM_GetClassDeclaredConstructors;
+                JVM_GetClassDeclaredFields;
+                JVM_GetClassDeclaredMethods;
+                JVM_GetClassFieldsCount;
+                JVM_GetClassInterfaces;
+                JVM_GetClassLoader;
+                JVM_GetClassMethodsCount;
+                JVM_GetClassModifiers;
+                JVM_GetClassName;
+                JVM_GetClassNameUTF;
+                JVM_GetClassSignature;
+                JVM_GetClassSigners;
+                JVM_GetComponentType;
+                JVM_GetDeclaredClasses;
+                JVM_GetDeclaringClass;
+                JVM_GetEnclosingMethodInfo;
+                JVM_GetFieldAnnotations;
+                JVM_GetFieldIxModifiers;
+                JVM_GetHostName;
+                JVM_GetInheritedAccessControlContext;
+                JVM_GetInterfaceVersion;
+                JVM_GetLastErrorString;
+                JVM_GetManagement;
+                JVM_GetMethodAnnotations;
+                JVM_GetMethodDefaultAnnotationValue;
+                JVM_GetMethodIxArgsSize;
+                JVM_GetMethodIxByteCode;
+                JVM_GetMethodIxByteCodeLength;
+                JVM_GetMethodIxExceptionIndexes;
+                JVM_GetMethodIxExceptionTableEntry;
+                JVM_GetMethodIxExceptionTableLength;
+                JVM_GetMethodIxExceptionsCount;
+                JVM_GetMethodIxLocalsCount;
+                JVM_GetMethodIxMaxStack;
+                JVM_GetMethodIxModifiers;
+                JVM_GetMethodIxNameUTF;
+                JVM_GetMethodIxSignatureUTF;
+                JVM_GetMethodParameterAnnotations;
+                JVM_GetPrimitiveArrayElement;
+                JVM_GetProtectionDomain;
+                JVM_GetSockName;
+                JVM_GetSockOpt;
+                JVM_GetStackAccessControlContext;
+                JVM_GetStackTraceDepth;
+                JVM_GetStackTraceElement;
+                JVM_GetSystemPackage;
+                JVM_GetSystemPackages;
+                JVM_GetThreadStateNames;
+                JVM_GetThreadStateValues;
+                JVM_GetVersionInfo;
+                JVM_Halt;
+                JVM_HoldsLock;
+                JVM_IHashCode;
+                JVM_InitAgentProperties;
+                JVM_InitProperties;
+                JVM_InitializeCompiler;
+                JVM_InitializeSocketLibrary;
+                JVM_InternString;
+                JVM_Interrupt;
+                JVM_InvokeMethod;
+                JVM_IsArrayClass;
+                JVM_IsConstructorIx;
+                JVM_IsInterface;
+                JVM_IsInterrupted;
+                JVM_IsNaN;
+                JVM_IsPrimitiveClass;
+                JVM_IsSameClassPackage;
+                JVM_IsSilentCompiler;
+                JVM_IsSupportedJNIVersion;
+                JVM_IsThreadAlive;
+                JVM_LatestUserDefinedLoader;
+                JVM_Listen;
+                JVM_LoadClass0;
+                JVM_LoadLibrary;
+                JVM_Lseek;
+                JVM_MaxObjectInspectionAge;
+                JVM_MaxMemory;
+                JVM_MonitorNotify;
+                JVM_MonitorNotifyAll;
+                JVM_MonitorWait;
+                JVM_NanoTime;
+                JVM_NativePath;
+                JVM_NewArray;
+                JVM_NewInstanceFromConstructor;
+                JVM_NewMultiArray;
+                JVM_OnExit;
+                JVM_Open;
+                JVM_PrintStackTrace;
+                JVM_RaiseSignal;
+                JVM_RawMonitorCreate;
+                JVM_RawMonitorDestroy;
+                JVM_RawMonitorEnter;
+                JVM_RawMonitorExit;
+                JVM_Read;
+                JVM_Recv;
+                JVM_RecvFrom;
+                JVM_RegisterSignal;
+                JVM_ReleaseUTF;
+                JVM_ResolveClass;
+                JVM_ResumeThread;
+                JVM_Send;
+                JVM_SendTo;
+                JVM_SetArrayElement;
+                JVM_SetClassSigners;
+                JVM_SetLength;
+                JVM_SetPrimitiveArrayElement;
+                JVM_SetProtectionDomain;
+                JVM_SetSockOpt;
+                JVM_SetThreadPriority;
+                JVM_Sleep;
+                JVM_Socket;
+                JVM_SocketAvailable;
+                JVM_SocketClose;
+                JVM_SocketShutdown;
+                JVM_StartThread;
+                JVM_StopThread;
+                JVM_SuspendThread;
+                JVM_SupportsCX8;
+                JVM_Sync;
+                JVM_Timeout;
+                JVM_TotalMemory;
+                JVM_TraceInstructions;
+                JVM_TraceMethodCalls;
+                JVM_UnloadLibrary;
+                JVM_Write;
+                JVM_Yield;
+                JVM_handle_bsd_signal;
+
+                # Old reflection routines
+                # These do not need to be present in the product build in JDK 1.4
+                # but their code has not been removed yet because there will not
+                # be a substantial code savings until JVM_InvokeMethod and
+                # JVM_NewInstanceFromConstructor can also be removed; see
+                # reflectionCompat.hpp.
+                JVM_GetClassConstructor;
+                JVM_GetClassConstructors;
+                JVM_GetClassField;
+                JVM_GetClassFields;
+                JVM_GetClassMethod;
+                JVM_GetClassMethods;
+                JVM_GetField;
+                JVM_GetPrimitiveField;
+                JVM_NewInstance;
+                JVM_SetField;
+                JVM_SetPrimitiveField;
+
+                # miscellaneous functions
+                jio_fprintf;
+                jio_printf;
+                jio_snprintf;
+                jio_vfprintf;
+                jio_vsnprintf;
+                fork1;
+                numa_warn;
+                numa_error;
+
+                # Needed because there is no JVM interface for this.
+                sysThreadAvailableStackWithSlack;
+
+                # This is for Forte Analyzer profiling support.
+                AsyncGetCallTrace;
+
+		# INSERT VTABLE SYMBOLS HERE
+
+        local:
+                *;
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/optimized.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making optimized version of Gamma VM
+# (This is the "product", not the "release" version.)
+
+# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
+OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
+OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
+
+# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
+
+# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
+CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
+
+# Set the environment variable HOTSPARC_GENERIC to "true"
+# to inhibit the effect of the previous line on CFLAGS.
+
+# Linker mapfile
+MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug
+
+G_SUFFIX =
+VERSION = optimized
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/ppc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
+OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
+
+# Must also specify if CPU is big endian
+CFLAGS += -DVM_BIG_ENDIAN
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/product.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,58 @@
+#
+# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making optimized version of Gamma VM
+# (This is the "product", not the "release" version.)
+
+# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make
+OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS)
+OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@))
+
+# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files)
+
+# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings
+CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
+
+# Set the environment variable HOTSPARC_GENERIC to "true"
+# to inhibit the effect of the previous line on CFLAGS.
+
+# Linker mapfile
+MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-product
+
+G_SUFFIX =
+SYSDEFS += -DPRODUCT
+VERSION = optimized
+
+# use -g to strip library as -x will discard its symbol table; -x is fine for
+# executables.
+ifdef CROSS_COMPILE_ARCH
+  STRIP = $(ALT_COMPILER_PATH)/strip
+else
+  STRIP = strip
+endif
+STRIP_LIBJVM = $(STRIP) -g $@ || exit 1;
+STRIP_AOUT   = $(STRIP) -x $@ || exit 1;
+
+# Don't strip in VM build; JDK build will strip libraries later
+# LINK_LIB.CC/POST_HOOK += $(STRIP_$(LINK_INTO))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/profiled.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,30 @@
+#
+# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making profiled version of Gamma VM
+# (It is also optimized.)
+
+CFLAGS += -pg
+AOUT_FLAGS += -pg
+LDNOMAP = true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/rules.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,216 @@
+#
+# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# 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.
+#  
+#
+
+# Common rules/macros for the vm, adlc.
+
+# Tell make that .cpp is important
+.SUFFIXES: .cpp $(SUFFIXES)
+
+# For now.  Other makefiles use CPP as the c++ compiler, but that should really
+# name the preprocessor.
+ifeq    ($(CCC),)
+CCC             = $(CPP)
+endif
+
+DEMANGLER       = c++filt
+DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
+
+# $(CC) is the c compiler (cc/gcc), $(CCC) is the c++ compiler (CC/g++).
+C_COMPILE       = $(CC) $(CPPFLAGS) $(CFLAGS)
+CC_COMPILE      = $(CCC) $(CPPFLAGS) $(CFLAGS)
+
+AS.S            = $(AS) $(ASFLAGS)
+
+COMPILE.c       = $(C_COMPILE) -c
+GENASM.c        = $(C_COMPILE) -S
+LINK.c          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
+LINK_LIB.c      = $(CC) $(LFLAGS) $(SHARED_FLAG)
+PREPROCESS.c    = $(C_COMPILE) -E
+
+COMPILE.CC      = $(CC_COMPILE) -c
+GENASM.CC       = $(CC_COMPILE) -S
+LINK.CC         = $(CCC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
+LINK_NOPROF.CC  = $(CCC) $(LFLAGS) $(AOUT_FLAGS)
+LINK_LIB.CC     = $(CCC) $(LFLAGS) $(SHARED_FLAG)
+PREPROCESS.CC   = $(CC_COMPILE) -E
+
+# cross compiling the jvm with c2 requires host compilers to build
+# adlc tool
+
+HOST.CC_COMPILE      = $(HOSTCPP) $(CPPFLAGS) $(CFLAGS)
+HOST.COMPILE.CC      = $(HOST.CC_COMPILE) -c
+HOST.LINK_NOPROF.CC  = $(HOSTCPP) $(LFLAGS) $(AOUT_FLAGS)
+
+
+# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
+REMOVE_TARGET   = rm -f $@
+
+# Synonyms.
+COMPILE.cpp     = $(COMPILE.CC)
+GENASM.cpp      = $(GENASM.CC)
+LINK.cpp        = $(LINK.CC)
+LINK_LIB.cpp    = $(LINK_LIB.CC)
+PREPROCESS.cpp  = $(PREPROCESS.CC)
+
+# Note use of ALT_BOOTDIR to explicitly specify location of java and
+# javac; this is the same environment variable used in the J2SE build
+# process for overriding the default spec, which is BOOTDIR.
+# Note also that we fall back to using JAVA_HOME if neither of these is
+# specified.
+
+ifdef ALT_BOOTDIR
+
+RUN.JAVA  = $(ALT_BOOTDIR)/bin/java
+RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap
+RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah
+RUN.JAR   = $(ALT_BOOTDIR)/bin/jar
+COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac
+COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic
+BOOT_JAVA_HOME = $(ALT_BOOTDIR)
+
+else
+
+ifdef BOOTDIR
+
+RUN.JAVA  = $(BOOTDIR)/bin/java
+RUN.JAVAP = $(BOOTDIR)/bin/javap
+RUN.JAVAH = $(BOOTDIR)/bin/javah
+RUN.JAR   = $(BOOTDIR)/bin/jar
+COMPILE.JAVAC = $(BOOTDIR)/bin/javac
+COMPILE.RMIC  = $(BOOTDIR)/bin/rmic
+BOOT_JAVA_HOME = $(BOOTDIR)
+
+else
+
+ifdef JAVA_HOME
+
+RUN.JAVA  = $(JAVA_HOME)/bin/java
+RUN.JAVAP = $(JAVA_HOME)/bin/javap
+RUN.JAVAH = $(JAVA_HOME)/bin/javah
+RUN.JAR   = $(JAVA_HOME)/bin/jar
+COMPILE.JAVAC = $(JAVA_HOME)/bin/javac
+COMPILE.RMIC  = $(JAVA_HOME)/bin/rmic
+BOOT_JAVA_HOME = $(JAVA_HOME)
+
+else
+
+# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined
+# note that this is to support hotspot build without SA. To build
+# SA along with hotspot, you need to define ALT_BOOTDIR, BOOTDIR or JAVA_HOME
+
+RUN.JAVA  = java
+RUN.JAVAP = javap
+RUN.JAVAH = javah
+RUN.JAR   = jar
+COMPILE.JAVAC = javac
+COMPILE.RMIC  = rmic
+
+endif
+endif
+endif
+
+COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS)
+
+SUM = /usr/bin/sum
+
+# 'gmake MAKE_VERBOSE=y' gives all the gory details.
+QUIETLY$(MAKE_VERBOSE)  = @
+RUN.JAR$(MAKE_VERBOSE) += >/dev/null
+
+# Settings for javac
+BOOT_SOURCE_LANGUAGE_VERSION = 6
+BOOT_TARGET_CLASS_VERSION = 6
+JAVAC_FLAGS = -g -encoding ascii
+BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) -source $(BOOT_SOURCE_LANGUAGE_VERSION) -target $(BOOT_TARGET_CLASS_VERSION)
+
+# With parallel makes, print a message at the end of compilation.
+ifeq    ($(findstring j,$(MFLAGS)),j)
+COMPILE_DONE    = && { echo Done with $<; }
+endif
+
+# Include $(NONPIC_OBJ_FILES) definition
+ifndef LP64
+include $(GAMMADIR)/make/pic.make
+endif
+
+include $(GAMMADIR)/make/altsrc.make
+
+# The non-PIC object files are only generated for 32 bit platforms.
+ifdef LP64
+%.o: %.cpp
+	@echo Compiling $<
+	$(QUIETLY) $(REMOVE_TARGET)
+	$(QUIETLY) $(COMPILE.CC) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
+else
+%.o: %.cpp
+	@echo Compiling $<
+	$(QUIETLY) $(REMOVE_TARGET)
+	$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
+	   $(subst $(VM_PICFLAG), ,$(COMPILE.CC)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
+	   $(COMPILE.CC) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
+endif
+
+%.o: %.s
+	@echo Assembling $<
+	$(QUIETLY) $(REMOVE_TARGET)
+	$(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
+
+%.s: %.cpp
+	@echo Generating assembly for $<
+	$(QUIETLY) $(GENASM.CC) -o $@ $<
+	$(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
+
+# Intermediate files (for debugging macros)
+%.i: %.cpp
+	@echo Preprocessing $< to $@
+	$(QUIETLY) $(PREPROCESS.CC) $< > $@ $(COMPILE_DONE)
+
+#  Override gnumake built-in rules which do sccs get operations badly.
+#  (They put the checked out code in the current directory, not in the
+#  directory of the original file.)  Since this is a symptom of a teamware
+#  failure, and since not all problems can be detected by gnumake due
+#  to incomplete dependency checking... just complain and stop.
+%:: s.%
+	@echo "========================================================="
+	@echo File $@
+	@echo is out of date with respect to its SCCS file.
+	@echo This file may be from an unresolved Teamware conflict.
+	@echo This is also a symptom of a Teamware bringover/putback failure
+	@echo in which SCCS files are updated but not checked out.
+	@echo Check for other out of date files in your workspace.
+	@echo "========================================================="
+	@exit 666
+
+%:: SCCS/s.%
+	@echo "========================================================="
+	@echo File $@
+	@echo is out of date with respect to its SCCS file.
+	@echo This file may be from an unresolved Teamware conflict.
+	@echo This is also a symptom of a Teamware bringover/putback failure
+	@echo in which SCCS files are updated but not checked out.
+	@echo Check for other out of date files in your workspace.
+	@echo "========================================================="
+	@exit 666
+
+.PHONY: default
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/sa.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,117 @@
+#
+# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# This makefile (sa.make) is included from the sa.make in the
+# build directories.
+
+# This makefile is used to build Serviceability Agent java code
+# and generate JNI header file for native methods.
+
+include $(GAMMADIR)/make/bsd/makefiles/rules.make
+
+AGENT_DIR = $(GAMMADIR)/agent
+
+include $(GAMMADIR)/make/sa.files
+
+TOPDIR    = $(shell echo `pwd`)
+GENERATED = $(TOPDIR)/../generated
+
+# tools.jar is needed by the JDI - SA binding
+ifeq ($(SA_APPLE_BOOT_JAVA),true)
+  SA_CLASSPATH = $(BOOT_JAVA_HOME)/bundle/Classes/classes.jar
+else
+  SA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar
+endif
+
+# TODO: if it's a modules image, check if SA module is installed.
+MODULELIB_PATH= $(BOOT_JAVA_HOME)/lib/modules
+
+AGENT_FILES_LIST := $(GENERATED)/agent.classes.list
+
+SA_CLASSDIR = $(GENERATED)/saclasses
+
+SA_BUILD_VERSION_PROP = "sun.jvm.hotspot.runtime.VM.saBuildVersion=$(SA_BUILD_VERSION)"
+
+SA_PROPERTIES = $(SA_CLASSDIR)/sa.properties
+
+# if $(AGENT_DIR) does not exist, we don't build SA
+# also, we don't build SA on Itanium, PowerPC, ARM or zero.
+
+all: 
+	if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" \
+             -a "$(SRCARCH)" != "arm" \
+             -a "$(SRCARCH)" != "ppc" \
+             -a "$(SRCARCH)" != "zero" ] ; then \
+	   $(MAKE) -f sa.make $(GENERATED)/sa-jdi.jar; \
+	fi
+
+$(GENERATED)/sa-jdi.jar: $(AGENT_FILES)
+	$(QUIETLY) echo "Making $@"
+	$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
+	  echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
+	  exit 1; \
+	fi
+	$(QUIETLY) if [ ! -f $(SA_CLASSPATH) -a ! -d $(MODULELIB_PATH) ] ; then \
+	  echo "Missing $(SA_CLASSPATH) file. Use 1.6.0 or later version of JDK";\
+	  echo ""; \
+	  exit 1; \
+	fi
+	$(QUIETLY) if [ ! -d $(SA_CLASSDIR) ] ; then \
+	  mkdir -p $(SA_CLASSDIR);        \
+	fi
+# Note: When indented, make tries to execute the '$(shell' comment.
+# In some environments, cmd processors have limited line length.
+# To prevent the javac invocation in the next block from using
+# a very long cmd line, we use javac's @file-list option. We
+# generate the file lists using make's built-in 'foreach' control
+# flow which also avoids cmd processor line length issues. Since
+# the 'foreach' is done as part of make's macro expansion phase,
+# the initialization of the lists is also done in the same phase
+# using '$(shell rm ...' instead of using the more traditional
+# 'rm ...' rule.
+	$(shell rm -rf $(AGENT_FILES_LIST))
+# gnumake 3.78.1 does not accept the *'s that
+# 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.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
+	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
+	$(QUIETLY) mkdir -p $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
+	$(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/*
+	$(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
+	$(QUIETLY) cp -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
+	$(QUIETLY) $(REMOTE) $(RUN.JAR) cf $@ -C $(SA_CLASSDIR)/ .
+	$(QUIETLY) $(REMOTE) $(RUN.JAR) uf $@ -C $(AGENT_SRC_DIR) META-INF/services/com.sun.jdi.connect.Connector
+	$(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.x86.X86ThreadContext
+	$(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.ia64.IA64ThreadContext
+	$(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext
+	$(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.sparc.SPARCThreadContext
+
+clean:
+	rm -rf $(SA_CLASSDIR)
+	rm -rf $(GENERATED)/sa-jdi.jar
+	rm -rf $(AGENT_FILES_LIST)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/saproc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,124 @@
+#
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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 serviceability agent library, used by vm.make
+
+# libsaproc[_g].so: serviceability agent
+SAPROC   = saproc
+SAPROC_G = $(SAPROC)$(G_SUFFIX)
+
+ifeq ($(OS_VENDOR), Darwin)
+  LIBSAPROC   = lib$(SAPROC).dylib
+  LIBSAPROC_G = lib$(SAPROC_G).dylib
+else
+  LIBSAPROC   = lib$(SAPROC).so
+  LIBSAPROC_G = lib$(SAPROC_G).so
+endif
+
+AGENT_DIR = $(GAMMADIR)/agent
+
+SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family)
+
+NON_STUB_SASRCFILES = $(SASRCDIR)/salibelf.c          \
+                      $(SASRCDIR)/symtab.c            \
+                      $(SASRCDIR)/libproc_impl.c      \
+                      $(SASRCDIR)/ps_proc.c           \
+                      $(SASRCDIR)/ps_core.c           \
+                      $(SASRCDIR)/BsdDebuggerLocal.c
+
+ifeq ($(OS_VENDOR), FreeBSD)
+  SASRCFILES = $(NON_STUB_SASRCFILES)
+  SALIBS = -lutil -lthread_db
+  SAARCH = $(ARCHFLAG)
+else
+  ifeq ($(OS_VENDOR), Darwin)
+    SASRCFILES = $(SASRCDIR)/MacosxDebuggerLocal.m
+    SALIBS = -g -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation
+    #objc compiler blows up on -march=i586, perhaps it should not be included in the macosx intel 32-bit C++ compiles?
+    SAARCH = $(subst -march=i586,,$(ARCHFLAG))
+  else
+    SASRCFILES = $(SASRCDIR)/StubDebuggerLocal.c
+    SALIBS = 
+    SAARCH = $(ARCHFLAG)
+  endif
+endif
+
+SAMAPFILE = $(SASRCDIR)/mapfile
+
+DEST_SAPROC = $(JDK_LIBDIR)/$(LIBSAPROC)
+
+# DEBUG_BINARIES overrides everything, use full -g debug information
+ifeq ($(DEBUG_BINARIES), true)
+  SA_DEBUG_CFLAGS = -g
+endif
+
+# if $(AGENT_DIR) does not exist, we don't build SA
+# also, we don't build SA on Itanium, PPC, ARM or zero.
+
+ifneq ($(wildcard $(AGENT_DIR)),)
+ifneq ($(filter-out ia64 arm ppc zero,$(SRCARCH)),)
+  BUILDLIBSAPROC = $(LIBSAPROC)
+endif
+endif
+
+
+ifneq ($(OS_VENDOR), Darwin)
+SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE))
+endif
+SA_LFLAGS += $(LDFLAGS_HASH_STYLE)
+
+ifeq ($(OS_VENDOR), Darwin)
+  BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \
+    -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") \
+    -I/System/Library/Frameworks/JavaVM.framework/Headers
+else
+  BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \
+    -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]")
+endif
+
+$(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE)
+	$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
+	  echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
+	  exit 1; \
+	fi
+	@echo Making SA debugger back-end...
+	$(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE                   \
+                   $(SYMFLAG) $(SAARCH) $(SHARED_FLAG) $(PICFLAG)     \
+	           -I$(SASRCDIR)                                        \
+	           -I$(GENERATED)                                       \
+	           $(BOOT_JAVA_INCLUDES)                                \
+	           $(SASRCFILES)                                        \
+	           $(SA_LFLAGS)                                         \
+	           $(SA_DEBUG_CFLAGS)                                   \
+	           -o $@                                                \
+	           $(SALIBS)
+	$(QUIETLY) [ -f $(LIBSAPROC_G) ] || { ln -s $@ $(LIBSAPROC_G); }
+
+install_saproc: $(BUILDLIBSAPROC)
+	$(QUIETLY) if [ -e $(LIBSAPROC) ] ; then             \
+	  echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)";     \
+	  cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";  \
+	fi
+
+.PHONY: install_saproc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/shark.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2008, 2010 Red Hat, Inc.
+# 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.
+#  
+#
+
+# Sets make macros for making Shark version of VM
+
+TYPE = SHARK
+
+VM_SUBDIR = server
+
+CFLAGS += -DSHARK
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/sparc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/sparcWorks.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,104 @@
+#
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+#------------------------------------------------------------------------
+# CC, CPP & AS
+
+CPP = CC
+CC  = cc
+AS  = $(CC) -c
+
+HOSTCPP = $(CPP)
+HOSTCC  = $(CC)
+
+ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
+ARCHFLAG/i486    = -m32
+ARCHFLAG/amd64   = -m64
+
+CFLAGS     += $(ARCHFLAG)
+AOUT_FLAGS += $(ARCHFLAG)
+LFLAGS     += $(ARCHFLAG)
+ASFLAGS    += $(ARCHFLAG)
+
+#------------------------------------------------------------------------
+# Compiler flags
+
+# position-independent code
+PICFLAG = -KPIC
+
+CFLAGS += $(PICFLAG)
+# no more exceptions
+CFLAGS += -features=no%except
+# Reduce code bloat by reverting back to 5.0 behavior for static initializers
+CFLAGS += -features=no%split_init
+# allow zero sized arrays
+CFLAGS += -features=zla
+
+# Use C++ Interpreter
+ifdef CC_INTERP
+  CFLAGS += -DCC_INTERP
+endif
+
+# We don't need libCstd.so and librwtools7.so, only libCrun.so
+CFLAGS += -library=Crun
+LIBS += -lCrun
+
+CFLAGS += -mt
+LFLAGS += -mt
+
+# Compiler warnings are treated as errors
+#WARNINGS_ARE_ERRORS = -errwarn=%all
+CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) 
+# Special cases
+CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) 
+
+# The flags to use for an Optimized build
+OPT_CFLAGS+=-xO4
+OPT_CFLAGS/NOOPT=-xO0
+
+# Flags for creating the dependency files.
+ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
+DEPFLAGS = -xMMD -xMF $(DEP_DIR)/$(@:%=%.d)
+endif
+
+# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
+CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
+
+#------------------------------------------------------------------------
+# Linker flags
+
+# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
+MAPFLAG = -Wl,--version-script=FILENAME
+
+# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj
+SONAMEFLAG = -h SONAME
+
+# Build shared library
+SHARED_FLAG = -G
+
+#------------------------------------------------------------------------
+# Debug flags
+DEBUG_CFLAGS += -g
+FASTDEBUG_CFLAGS = -g0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/sparcv9.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+
+# gcc 4.0 miscompiles this code in -m64
+OPT_CFLAGS/macro.o = -O0
+
+CFLAGS += -D_LP64=1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/tiered.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#  
+#
+
+# Sets make macros for making tiered version of VM
+
+TYPE=TIERED
+
+VM_SUBDIR = server
+
+CFLAGS += -DCOMPILER2 -DCOMPILER1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/top.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,151 @@
+#
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# top.make is included in the Makefile in the build directories.
+# It DOES NOT include the vm dependency info in order to be faster.
+# Its main job is to implement the incremental form of make lists.
+# It also:
+#   -builds and runs adlc via adlc.make
+#   -generates JVMTI source and docs via jvmti.make (JSR-163)
+#   -generate sa-jdi.jar (JDI binding to core files)
+
+# It assumes the following flags are set:
+# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Obj_Files
+
+# -- D. Ungar (5/97) from a file by Bill Bush
+
+# Don't override the built-in $(MAKE).
+# Instead, use "gmake" (or "gnumake") from the command line.  --Rose
+#MAKE = gmake
+
+include $(GAMMADIR)/make/altsrc.make
+
+TOPDIR      = $(shell echo `pwd`)
+GENERATED   = $(TOPDIR)/../generated
+VM          = $(GAMMADIR)/src/share/vm
+Plat_File   = $(Platform_file)
+CDG         = cd $(GENERATED); 
+
+ifdef USE_PRECOMPILED_HEADER
+PrecompiledOption = -DUSE_PRECOMPILED_HEADER
+UpdatePCH         = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS) 
+else
+UpdatePCH         = \# precompiled header is not used
+PrecompiledOption = 
+endif
+
+Cached_plat = $(GENERATED)/platform.current
+
+AD_Dir   = $(GENERATED)/adfiles
+ADLC     = $(AD_Dir)/adlc
+AD_Spec  = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad)
+AD_Src   = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc)
+AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp
+AD_Files = $(AD_Names:%=$(AD_Dir)/%)
+
+# AD_Files_If_Required/COMPILER1 = ad_stuff
+AD_Files_If_Required/COMPILER2 = ad_stuff
+AD_Files_If_Required/TIERED = ad_stuff
+AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE))
+
+# Wierd argument adjustment for "gnumake -j..."
+adjust-mflags   = $(GENERATED)/adjust-mflags
+MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"`
+
+
+# default target: update lists, make vm
+# done in stages to force sequential order with parallel make
+#
+
+default: vm_build_preliminaries the_vm
+	@echo All done.
+
+# This is an explicit dependency for the sake of parallel makes.
+vm_build_preliminaries:  checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stuff sa_stuff dtrace_stuff
+	@# We need a null action here, so implicit rules don't get consulted.
+
+$(Cached_plat): $(Plat_File)
+	$(CDG) cp $(Plat_File) $(Cached_plat)
+
+# make AD files as necessary
+ad_stuff: $(Cached_plat) $(adjust-mflags)
+	@$(MAKE) -f adlc.make $(MFLAGS-adjusted)
+
+# generate JVMTI files from the spec
+jvmti_stuff: $(Cached_plat) $(adjust-mflags)
+	@$(MAKE) -f jvmti.make $(MFLAGS-adjusted)
+
+ifeq ($(OS_VENDOR), Darwin)
+# generate dtrace header files
+dtrace_stuff: $(Cached_plat) $(adjust-mflags)
+	@$(MAKE) -f dtrace.make dtrace_stuff $(MFLAGS-adjusted) GENERATED=$(GENERATED)
+else
+dtrace_stuff:
+	@# We need a null action here, so implicit rules don't get consulted.
+endif
+
+# generate SA jar files and native header
+sa_stuff:
+	@$(MAKE) -f sa.make $(MFLAGS-adjusted)
+
+# and the VM: must use other makefile with dependencies included
+
+# We have to go to great lengths to get control over the -jN argument
+# to the recursive invocation of vm.make.  The problem is that gnumake
+# resets -jN to -j1 for recursive runs.  (How helpful.)
+# Note that the user must specify the desired parallelism level via a
+# command-line or environment variable name HOTSPOT_BUILD_JOBS.
+$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh
+	@+rm -f $@ $@+
+	@+cat $< > $@+
+	@+chmod +x $@+
+	@+mv $@+ $@
+
+the_vm: vm_build_preliminaries $(adjust-mflags)
+	@$(UpdatePCH)
+	@$(MAKE) -f vm.make $(MFLAGS-adjusted)
+
+install: the_vm
+	@$(MAKE) -f vm.make install
+
+# next rules support "make foo.[ois]"
+
+%.o %.i %.s:
+	$(UpdatePCH) 
+	$(MAKE) -f vm.make $(MFLAGS) $@
+	#$(MAKE) -f vm.make $@
+
+# this should force everything to be rebuilt
+clean: 
+	rm -f $(GENERATED)/*.class
+	$(MAKE) -f vm.make $(MFLAGS) clean
+
+# just in case it doesn't, this should do it
+realclean:
+	$(MAKE) -f vm.make $(MFLAGS) clean
+	rm -fr $(GENERATED)
+
+.PHONY: default vm_build_preliminaries
+.PHONY: lists ad_stuff jvmti_stuff sa_stuff the_vm clean realclean
+.PHONY: checks check_os_version install
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/vm.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,339 @@
+#
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# Rules to build JVM and related libraries, included from vm.make in the build
+# directory.
+
+# Common build rules.
+MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles
+include $(MAKEFILES_DIR)/rules.make
+include $(GAMMADIR)/make/altsrc.make
+
+default: build
+
+#----------------------------------------------------------------------
+# Defs
+
+GENERATED     = ../generated
+DEP_DIR       = $(GENERATED)/dependencies
+
+# reads the generated files defining the set of .o's and the .o .h dependencies
+-include $(DEP_DIR)/*.d
+
+# read machine-specific adjustments (%%% should do this via buildtree.make?)
+ifeq ($(ZERO_BUILD), true)
+  include $(MAKEFILES_DIR)/zeroshark.make
+else
+  include $(MAKEFILES_DIR)/$(BUILDARCH).make
+endif
+
+# set VPATH so make knows where to look for source files
+# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm
+# The adfiles directory contains ad_<arch>.[ch]pp.
+# The jvmtifiles directory contains jvmti*.[ch]pp
+Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles
+VPATH += $(Src_Dirs_V:%=%:)
+
+# set INCLUDES for C preprocessor.
+Src_Dirs_I += $(GENERATED)
+# The order is important for the precompiled headers to work.
+INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%)
+
+ifeq (${VERSION}, debug)
+  SYMFLAG = -g
+else
+  SYMFLAG =
+endif
+
+# HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined 
+# in $(GAMMADIR)/make/defs.make
+ifeq ($(HOTSPOT_BUILD_VERSION),)
+  BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)\""
+else
+  BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HOTSPOT_RELEASE_VERSION)-$(HOTSPOT_BUILD_VERSION)\""
+endif
+
+# The following variables are defined in the generated flags.make file.
+BUILD_VERSION = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\""
+JRE_VERSION   = -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\""
+HS_LIB_ARCH   = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
+BUILD_TARGET  = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
+BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
+VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
+
+CPPFLAGS =           \
+  ${SYSDEFS}         \
+  ${INCLUDES}        \
+  ${BUILD_VERSION}   \
+  ${BUILD_TARGET}    \
+  ${BUILD_USER}      \
+  ${HS_LIB_ARCH}     \
+  ${JRE_VERSION}     \
+  ${VM_DISTRO}
+
+ifdef DEFAULT_LIBPATH
+CPPFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
+endif
+
+# CFLAGS_WARN holds compiler options to suppress/enable warnings.
+CFLAGS += $(CFLAGS_WARN/BYFILE)
+
+# Do not use C++ exception handling
+CFLAGS += $(CFLAGS/NOEX)
+
+# Extra flags from gnumake's invocation or environment
+CFLAGS += $(EXTRA_CFLAGS)
+LFLAGS += $(EXTRA_CFLAGS)
+
+# Don't set excutable bit on stack segment
+# the same could be done by separate execstack command
+# Darwin is non-executable-stack by default
+ifneq ($(OS_VENDOR), Darwin)
+LFLAGS += -Xlinker -z -Xlinker noexecstack
+endif
+
+LIBS += -lm -pthread
+
+# By default, link the *.o into the library, not the executable.
+LINK_INTO$(LINK_INTO) = LIBJVM
+
+JDK_LIBDIR = $(JAVA_HOME)/jre/lib/$(LIBARCH)
+
+#----------------------------------------------------------------------
+# jvm_db & dtrace
+include $(MAKEFILES_DIR)/dtrace.make
+
+#----------------------------------------------------------------------
+# JVM
+
+JVM    = jvm
+ifeq ($(OS_VENDOR), Darwin)
+  LIBJVM   = lib$(JVM).dylib
+  LIBJVM_G = lib$(JVM)$(G_SUFFIX).dylib
+  CFLAGS  += -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
+else
+  LIBJVM   = lib$(JVM).so
+  LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
+endif
+
+SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt
+
+SOURCE_PATHS=\
+  $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \
+      \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \))
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
+SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
+
+CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
+CORE_PATHS+=$(GENERATED)/jvmtifiles
+
+COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1)
+COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1
+
+COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto)
+COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt)
+COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto
+COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt
+COMPILER2_PATHS += $(GENERATED)/adfiles
+
+SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark
+
+# Include dirs per type.
+Src_Dirs/CORE      := $(CORE_PATHS)
+Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS)
+Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS)
+Src_Dirs/TIERED    := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS)
+Src_Dirs/ZERO      := $(CORE_PATHS)
+Src_Dirs/SHARK     := $(CORE_PATHS) $(SHARK_PATHS)
+Src_Dirs := $(Src_Dirs/$(TYPE))
+
+COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp chaitin\* c2_\* runtime_\*
+COMPILER1_SPECIFIC_FILES := c1_\*
+SHARK_SPECIFIC_FILES     := shark
+ZERO_SPECIFIC_FILES      := zero
+
+# Always exclude these.
+Src_Files_EXCLUDE := jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
+
+# Exclude per type.
+Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
+Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES)
+Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES)
+
+Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
+
+# Special handling of arch model.
+ifeq ($(Platform_arch_model), x86_32)
+Src_Files_EXCLUDE += \*x86_64\*
+endif
+ifeq ($(Platform_arch_model), x86_64)
+Src_Files_EXCLUDE += \*x86_32\*
+endif
+
+# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE.
+define findsrc
+	$(notdir $(shell find $(1)/. ! -name . -prune \
+		-a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \
+		-a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \)))
+endef
+
+Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e)))
+
+Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))))
+
+JVM_OBJ_FILES = $(Obj_Files)
+
+vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
+
+mapfile : $(MAPFILE) vm.def
+	rm -f $@
+	awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE")	\
+                 { system ("cat vm.def"); }		\
+               else					\
+                 { print $$0 }				\
+             }' > $@ < $(MAPFILE)
+
+mapfile_reorder : mapfile $(REORDERFILE)
+	rm -f $@
+	cat $^ > $@
+
+vm.def: $(Res_Files) $(Obj_Files)
+	sh $(GAMMADIR)/make/bsd/makefiles/build_vm_def.sh *.o > $@
+
+STATIC_CXX = false
+
+ifeq ($(LINK_INTO),AOUT)
+  LIBJVM.o                 =
+  LIBJVM_MAPFILE           =
+  LIBS_VM                  = $(LIBS)
+else
+  LIBJVM.o                 = $(JVM_OBJ_FILES)
+  LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder
+  LFLAGS_VM$(LDNOMAP)      += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE))
+  LFLAGS_VM                += $(SONAMEFLAG:SONAME=$(LIBJVM))
+
+  ifeq ($(OS_VENDOR), Darwin)
+    LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/.
+    LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/..
+    LFLAGS_VM += -Xlinker -install_name -Xlinker @rpath/$(@F)
+  endif
+
+  # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to
+  # get around library dependency and compatibility issues. Must use gcc not
+  # g++ to link.
+  ifeq ($(STATIC_CXX), true)
+    LFLAGS_VM              += $(STATIC_LIBGCC)
+    LIBS_VM                += $(STATIC_STDCXX)
+    LINK_VM                = $(LINK_LIB.c)
+  else
+    LINK_VM                = $(LINK_LIB.CC)
+  endif
+
+  LIBS_VM                  += $(LIBS)
+endif
+ifeq ($(ZERO_BUILD), true)
+  LIBS_VM += $(LIBFFI_LIBS)
+endif
+ifeq ($(SHARK_BUILD), true)
+  LFLAGS_VM += $(LLVM_LDFLAGS)
+  LIBS_VM   += $(LLVM_LIBS)
+endif
+
+
+# rule for building precompiled header
+$(PRECOMPILED_HEADER):
+	$(QUIETLY) echo Generating precompiled header $@
+	$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
+	$(QUIETLY) $(COMPILE.CC) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
+
+# making the library:
+
+ifneq ($(JVM_BASE_ADDR),)
+# By default shared library is linked at base address == 0. Modify the
+# linker script if JVM prefers a different base location. It can also be
+# implemented with 'prelink -r'. But 'prelink' is not (yet) available on
+# our build platform (AS-2.1).
+LD_SCRIPT = libjvm.so.lds
+$(LD_SCRIPT): $(LIBJVM_MAPFILE)
+	$(QUIETLY) {                                                \
+	  rm -rf $@;                                                \
+	  $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1             |  \
+	    sed -e '/^======/,/^======/!d'                          \
+		-e '/^======/d'                                     \
+		-e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/'   \
+		> $@;                                               \
+	}
+LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT)
+endif
+
+$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
+	$(QUIETLY) {                                                    \
+	    echo Linking vm...;                                         \
+	    $(LINK_LIB.CC/PRE_HOOK)                                     \
+	    $(LINK_VM) $(LD_SCRIPT_FLAG)                                \
+		       $(LFLAGS_VM) -o $@ $(LIBJVM.o) $(LIBS_VM);       \
+	    $(LINK_LIB.CC/POST_HOOK)                                    \
+	    rm -f $@.1; ln -s $@ $@.1;                                  \
+	    [ -f $(LIBJVM_G) ] || { ln -s $@ $(LIBJVM_G); ln -s $@.1 $(LIBJVM_G).1; }; \
+	}
+
+DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM)
+
+install_jvm: $(LIBJVM)
+	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
+	$(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
+
+#----------------------------------------------------------------------
+# Other files
+
+# Gamma launcher
+include $(MAKEFILES_DIR)/launcher.make
+
+# Signal interposition library
+include $(MAKEFILES_DIR)/jsig.make
+
+# Serviceability agent
+include $(MAKEFILES_DIR)/saproc.make
+
+#----------------------------------------------------------------------
+
+ifeq ($(OS_VENDOR), Darwin)
+$(LIBJVM).dSYM: $(LIBJVM)
+	dsymutil $(LIBJVM)
+
+# no launcher or libjvm_db for macosx
+build: $(LIBJVM) $(LIBJSIG) $(BUILDLIBSAPROC) dtraceCheck $(LIBJVM).dSYM
+	echo "Doing vm.make build:"
+else
+build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(BUILDLIBSAPROC)
+endif
+
+install: install_jvm install_jsig install_saproc
+
+.PHONY: default build install install_jvm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/zero.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2009 Red Hat, Inc.
+# 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.
+#  
+#
+
+# Setup for Zero (non-Shark) version of VM
+
+# Select which files to use (in top.make)
+TYPE = ZERO
+
+# Install libjvm.so, etc in in server directory.
+VM_SUBDIR = server
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/zeroshark.make	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2007, 2008 Red Hat, Inc.
+# 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.
+#
+#
+
+# Setup common to Zero (non-Shark) and Shark versions of VM
+
+# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
+OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT)
+# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized
+OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT)
+
+# Specify that the CPU is little endian, if necessary
+ifeq ($(ZERO_ENDIANNESS), little)
+  CFLAGS += -DVM_LITTLE_ENDIAN
+endif
+
+# Specify that the CPU is 64 bit, if necessary
+ifeq ($(ARCH_DATA_MODEL), 64)
+  CFLAGS += -D_LP64=1
+endif
+
+# Specify the path to the FFI headers
+ifdef ALT_PACKAGE_PATH
+  PACKAGE_PATH = $(ALT_PACKAGE_PATH)
+else
+  ifeq ($(OS_VENDOR),Apple)
+    PACKAGE_PATH = /opt/local
+  else
+    ifeq ($(OS_VENDOR),NetBSD)
+      PACKAGE_PATH = /usr/pkg
+      LIBS += -Wl,-R${PACKAGE_PATH}/lib
+    else
+      PACKAGE_PATH = /usr/local
+    endif
+  endif
+endif
+
+CFLAGS += -I$(PACKAGE_PATH)/include
+LIBS += -L$(PACKAGE_PATH)/lib -lffi
+
+OPT_CFLAGS/compactingPermGenGen.o = -O1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/platform_amd64	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,15 @@
+os_family = bsd
+
+arch = x86
+
+arch_model = x86_64
+
+os_arch = bsd_x86
+
+os_arch_model = bsd_x86_64
+
+lib_arch = amd64
+
+compiler = gcc
+
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DAMD64
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/platform_amd64.suncc	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,17 @@
+os_family = bsd
+
+arch = x86
+
+arch_model = x86_64
+
+os_arch = bsd_x86
+
+os_arch_model = bsd_x86_64
+
+lib_arch = amd64
+
+compiler = sparcWorks
+
+gnu_dis_arch = amd64
+
+sysdefs = -D_ALLBSD_SOURCE -DSPARC_WORKS -D_GNU_SOURCE -DAMD64
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/platform_i486	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,15 @@
+os_family = bsd
+
+arch = x86
+
+arch_model = x86_32
+
+os_arch = bsd_x86
+
+os_arch_model = bsd_x86_32
+
+lib_arch = i386
+
+compiler = gcc
+
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DIA32
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/platform_i486.suncc	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,17 @@
+os_family = bsd
+
+arch = x86
+
+arch_model = x86_32
+
+os_arch = bsd_x86
+
+os_arch_model = bsd_x86_32
+
+lib_arch = i386
+
+compiler = sparcWorks
+
+gnu_dis_arch = i386
+
+sysdefs = -D_ALLBSD_SOURCE -DSPARC_WORKS -D_GNU_SOURCE -DIA32
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/platform_ia64	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,15 @@
+os_family = bsd
+
+arch = ia64
+
+os_arch = bsd_ia64
+
+lib_arch = ia64
+
+compiler = gcc
+
+gnu_dis_arch = ia64
+
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DIA64 -DCC_INTERP
+
+mark_style = alignment
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/platform_sparc	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,15 @@
+os_family = bsd
+
+arch = sparc
+
+arch_model = sparc
+
+os_arch = bsd_sparc
+
+os_arch_model = bsd_sparc
+
+lib_arch = sparc
+
+compiler = gcc
+
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DSPARC
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/platform_sparcv9	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,15 @@
+os_family = bsd
+
+arch = sparc
+
+arch_model = sparc
+
+os_arch = bsd_sparc
+
+os_arch_model = bsd_sparc
+
+lib_arch = sparcv9
+
+compiler = gcc
+
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DSPARC
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/platform_zero.in	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,17 @@
+os_family = bsd
+
+arch = zero
+
+arch_model = zero
+
+os_arch = bsd_zero
+
+os_arch_model = bsd_zero
+
+lib_arch = zero
+
+compiler = gcc
+
+gnu_dis_arch = zero
+
+sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DCC_INTERP -DZERO -D@ZERO_ARCHDEF@ -DZERO_LIBARCH=\"@ZERO_LIBARCH@\"
--- a/hotspot/make/cscope.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/cscope.make	Wed Oct 26 17:59:13 2011 -0700
@@ -63,7 +63,7 @@
 # space-separated list of identifiers to include only those systems.
 ifdef	CS_OS
 CS_PRUNE_OS	= $(patsubst %,-o -name '*%*',\
-		    $(filter-out ${CS_OS},linux macos solaris windows))
+		    $(filter-out ${CS_OS},bsd linux macos solaris windows))
 endif
 
 # CPU-specific files for all processors are included by default.  Set CS_CPU 
--- a/hotspot/make/defs.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/defs.make	Wed Oct 26 17:59:13 2011 -0700
@@ -118,13 +118,23 @@
 # Windows should have OS predefined
 ifeq ($(OS),)
   OS   := $(shell uname -s)
+  ifneq ($(findstring BSD,$(OS)),)
+    OS=bsd
+  endif
+  ifeq ($(OS), Darwin)
+    OS=bsd
+  endif
   HOST := $(shell uname -n)
 endif
 
-# If not SunOS and not Linux, assume Windows
+# If not SunOS, not Linux and not BSD, assume Windows
 ifneq ($(OS), Linux)
   ifneq ($(OS), SunOS)
-    OSNAME=windows
+    ifneq ($(OS), bsd)
+      OSNAME=windows
+    else
+      OSNAME=bsd
+    endif
   else
     OSNAME=solaris
   endif
@@ -271,6 +281,13 @@
 EXPORT_JRE_LIB_DIR = $(EXPORT_JRE_DIR)/lib
 EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR)/$(LIBARCH)
 
+# non-universal macosx builds need to appear universal
+ifeq ($(OS_VENDOR), Darwin)
+  ifneq ($(MACOSX_UNIVERSAL), true)
+    EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR)
+  endif
+endif
+
 # Common export list of files
 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmti.h
 EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmticmlr.h
--- a/hotspot/make/hotspot_version	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/hotspot_version	Wed Oct 26 17:59:13 2011 -0700
@@ -33,7 +33,7 @@
 # Don't put quotes (fail windows build).
 HOTSPOT_VM_COPYRIGHT=Copyright 2011
 
-HS_MAJOR_VER=22
+HS_MAJOR_VER=23
 HS_MINOR_VER=0
 HS_BUILD_NUMBER=03
 
--- a/hotspot/make/linux/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -210,6 +210,7 @@
 BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
 BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH)
 BUILDTREE_VARS   += HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) HOTSPOT_BUILD_VERSION=$(HOTSPOT_BUILD_VERSION) JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
+BUILDTREE_VARS   += OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY)
 
 BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)
 
--- a/hotspot/make/linux/build.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/build.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,6 +1,6 @@
 #! /bin/sh
 #
-# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,9 @@
   i386|i486|i586|i686)
     mach=i386
     ;;
+  x86_64)
+    mach=amd64
+    ;;
   *)
     echo "Unsupported machine: " `uname -m`
     exit 1
--- a/hotspot/make/linux/makefiles/arm.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/arm.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,6 +1,25 @@
 #
 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
-# ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+# 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.
+#  
 #
 
 Obj_Files += linux_arm.o
--- a/hotspot/make/linux/makefiles/build_vm_def.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/build_vm_def.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -7,6 +7,10 @@
 NM=nm
 fi
 
-$NM --defined-only $* | awk '
-   { if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";" }
-   '
+$NM --defined-only $* \
+    | awk '{
+              if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";"
+              if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";"
+              if ($3 ~ /^_ZN9Arguments17SharedArchivePathE$/) print "\t" $3 ";"
+          }' \
+    | sort -u
--- a/hotspot/make/linux/makefiles/buildtree.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/buildtree.make	Wed Oct 26 17:59:13 2011 -0700
@@ -233,6 +233,10 @@
 	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 	[ -n "$(CFLAGS_BROWSE)" ] && \
 	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
+	[ -n "$(OBJCOPY)" ] && \
+	    echo && echo "OBJCOPY = $(OBJCOPY)"; \
+	[ -n "$(STRIP_POLICY)" ] && \
+	    echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
 	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
 	    echo && \
 	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
--- a/hotspot/make/linux/makefiles/defs.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/defs.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -114,36 +114,113 @@
   HS_ARCH          = ppc
 endif
 
+# determine if HotSpot is being built in JDK6 or earlier version
+JDK6_OR_EARLIER=0
+ifeq "$(shell expr \( '$(JDK_MAJOR_VERSION)' != '' \& '$(JDK_MINOR_VERSION)' != '' \& '$(JDK_MICRO_VERSION)' != '' \))" "1"
+  # if the longer variable names (newer build style) are set, then check those
+  ifeq "$(shell expr \( $(JDK_MAJOR_VERSION) = 1 \& $(JDK_MINOR_VERSION) \< 7 \))" "1"
+    JDK6_OR_EARLIER=1
+  endif
+else
+  # the longer variables aren't set so check the shorter variable names
+  ifeq "$(shell expr \( '$(JDK_MAJOR_VER)' = 1 \& '$(JDK_MINOR_VER)' \< 7 \))" "1"
+    JDK6_OR_EARLIER=1
+  endif
+endif
+
+ifeq ($(JDK6_OR_EARLIER),0)
+  # Full Debug Symbols is supported on JDK7 or newer
+
+  # Default OBJCOPY comes from GNU Binutils on Linux:
+  DEF_OBJCOPY=/usr/bin/objcopy
+  ifdef CROSS_COMPILE_ARCH
+    # don't try to generate .debuginfo files when cross compiling
+    _JUNK_ := $(shell \
+      echo >&2 "INFO: cross compiling for ARCH $(CROSS_COMPILE_ARCH)," \
+        "skipping .debuginfo generation.")
+    OBJCOPY=
+  else
+    OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
+    ifneq ($(ALT_OBJCOPY),)
+      _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
+      # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
+      OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
+    endif
+  endif
+  
+  ifeq ($(OBJCOPY),)
+    _JUNK_ := $(shell \
+      echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
+  else
+    _JUNK_ := $(shell \
+      echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")
+  
+    # Library stripping policies for .debuginfo configs:
+    #   all_strip - strips everything from the library
+    #   min_strip - strips most stuff from the library; leaves minimum symbols
+    #   no_strip  - does not strip the library at all
+    #
+    # Oracle security policy requires "all_strip". A waiver was granted on
+    # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
+    #
+    DEF_STRIP_POLICY="min_strip"
+    ifeq ($(ALT_STRIP_POLICY),)
+      STRIP_POLICY=$(DEF_STRIP_POLICY)
+    else
+      STRIP_POLICY=$(ALT_STRIP_POLICY)
+    endif
+  
+    _JUNK_ := $(shell \
+      echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
+  endif
+endif
+
 JDK_INCLUDE_SUBDIR=linux
 
+# Library suffix
+LIBRARY_SUFFIX=so
+
 # FIXUP: The subdirectory for a debug build is NOT the same on all platforms
 VM_DEBUG=jvmg
 
 EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
 
 # client and server subdirectories have symbolic links to ../libjsig.so
-EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.so
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
+ifneq ($(OBJCOPY),)
+  EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.debuginfo
+endif
 EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server
 EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client
 
 ifndef BUILD_CLIENT_ONLY
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.so
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
+  ifneq ($(OBJCOPY),)
+    EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo
+  endif
 endif
 
 ifneq ($(ZERO_BUILD), true)
   ifeq ($(ARCH_DATA_MODEL), 32)
     EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.so 
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX)
+    ifneq ($(OBJCOPY),)
+      EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
+    endif
   endif
 endif
 
 # Serviceability Binaries
 # No SA Support for PPC, IA64, ARM or zero
-ADD_SA_BINARIES/x86   = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so \
+ADD_SA_BINARIES/x86   = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
+                        $(EXPORT_LIB_DIR)/sa-jdi.jar 
+ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \
                         $(EXPORT_LIB_DIR)/sa-jdi.jar 
-ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so \
-                        $(EXPORT_LIB_DIR)/sa-jdi.jar 
+ifneq ($(OBJCOPY),)
+  ADD_SA_BINARIES/x86   += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo
+  ADD_SA_BINARIES/sparc += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo
+endif
 ADD_SA_BINARIES/ppc   = 
 ADD_SA_BINARIES/ia64  = 
 ADD_SA_BINARIES/arm   = 
--- a/hotspot/make/linux/makefiles/gcc.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/gcc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -225,6 +225,26 @@
 DEBUG_CFLAGS += -gstabs
 endif
 
+ifneq ($(OBJCOPY),)
+  FASTDEBUG_CFLAGS/ia64  = -g
+  FASTDEBUG_CFLAGS/amd64 = -g
+  FASTDEBUG_CFLAGS/arm   = -g
+  FASTDEBUG_CFLAGS/ppc   = -g
+  FASTDEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH))
+  ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),)
+    FASTDEBUG_CFLAGS += -gstabs
+  endif
+
+  OPT_CFLAGS/ia64  = -g
+  OPT_CFLAGS/amd64 = -g
+  OPT_CFLAGS/arm   = -g
+  OPT_CFLAGS/ppc   = -g
+  OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH))
+  ifeq ($(OPT_CFLAGS/$(BUILDARCH)),)
+    OPT_CFLAGS += -gstabs
+  endif
+endif
+
 # DEBUG_BINARIES overrides everything, use full -g debug information
 ifeq ($(DEBUG_BINARIES), true)
   DEBUG_CFLAGS = -g
@@ -242,3 +262,9 @@
 ifdef MINIMIZE_RAM_USAGE
 CFLAGS += -DMINIMIZE_RAM_USAGE
 endif
+
+ifdef CROSS_COMPILE_ARCH
+  STRIP = $(ALT_COMPILER_PATH)/strip
+else
+  STRIP = strip
+endif
--- a/hotspot/make/linux/makefiles/jsig.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/jsig.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,13 @@
 JSIG_G    = $(JSIG)$(G_SUFFIX)
 LIBJSIG_G = lib$(JSIG_G).so
 
+LIBJSIG_DEBUGINFO   = lib$(JSIG).debuginfo
+LIBJSIG_G_DEBUGINFO = lib$(JSIG_G).debuginfo
+
 JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm
 
-DEST_JSIG  = $(JDK_LIBDIR)/$(LIBJSIG)
+DEST_JSIG           = $(JDK_LIBDIR)/$(LIBJSIG)
+DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO)
 
 LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
 
@@ -54,9 +58,24 @@
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
                          $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $@ $< -ldl
 	$(QUIETLY) [ -f $(LIBJSIG_G) ] || { ln -s $@ $(LIBJSIG_G); }
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -g $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	[ -f $(LIBJSIG_G_DEBUGINFO) ] || { ln -s $(LIBJSIG_DEBUGINFO) $(LIBJSIG_G_DEBUGINFO); }
+endif
 
 install_jsig: $(LIBJSIG)
 	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
+	$(QUIETLY) test -f $(LIBJSIG_DEBUGINFO) && \
+	    cp -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
 	$(QUIETLY) cp -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
 
 .PHONY: install_jsig
--- a/hotspot/make/linux/makefiles/mapfile-vers-debug	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/mapfile-vers-debug	Wed Oct 26 17:59:13 2011 -0700
@@ -244,24 +244,6 @@
                 JVM_Yield;
                 JVM_handle_linux_signal;
 
-                # Old reflection routines
-                # These do not need to be present in the product build in JDK 1.4
-                # but their code has not been removed yet because there will not
-                # be a substantial code savings until JVM_InvokeMethod and
-                # JVM_NewInstanceFromConstructor can also be removed; see
-                # reflectionCompat.hpp.
-                JVM_GetClassConstructor;
-                JVM_GetClassConstructors;
-                JVM_GetClassField;
-                JVM_GetClassFields;
-                JVM_GetClassMethod;
-                JVM_GetClassMethods;
-                JVM_GetField;
-                JVM_GetPrimitiveField;
-                JVM_NewInstance;
-                JVM_SetField;
-                JVM_SetPrimitiveField;
-
                 # debug JVM
                 JVM_AccessVMBooleanFlag;
                 JVM_AccessVMIntFlag;
--- a/hotspot/make/linux/makefiles/mapfile-vers-product	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/mapfile-vers-product	Wed Oct 26 17:59:13 2011 -0700
@@ -244,24 +244,6 @@
                 JVM_Yield;
                 JVM_handle_linux_signal;
 
-                # Old reflection routines
-                # These do not need to be present in the product build in JDK 1.4
-                # but their code has not been removed yet because there will not
-                # be a substantial code savings until JVM_InvokeMethod and
-                # JVM_NewInstanceFromConstructor can also be removed; see
-                # reflectionCompat.hpp.
-                JVM_GetClassConstructor;
-                JVM_GetClassConstructors;
-                JVM_GetClassField;
-                JVM_GetClassFields;
-                JVM_GetClassMethod;
-                JVM_GetClassMethods;
-                JVM_GetField;
-                JVM_GetPrimitiveField;
-                JVM_NewInstance;
-                JVM_SetField;
-                JVM_SetPrimitiveField;
-
                 # miscellaneous functions
                 jio_fprintf;
                 jio_printf;
--- a/hotspot/make/linux/makefiles/ppc.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/ppc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,6 +1,25 @@
 #
 # Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
-# ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+# 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.
+#  
 #
 
 # The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized
--- a/hotspot/make/linux/makefiles/product.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/product.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -46,13 +46,10 @@
 
 # use -g to strip library as -x will discard its symbol table; -x is fine for
 # executables.
-ifdef CROSS_COMPILE_ARCH
-  STRIP = $(ALT_COMPILER_PATH)/strip
-else
-  STRIP = strip
-endif
+# Note: these macros are not used in .debuginfo configs
 STRIP_LIBJVM = $(STRIP) -g $@ || exit 1;
 STRIP_AOUT   = $(STRIP) -x $@ || exit 1;
 
-# Don't strip in VM build; JDK build will strip libraries later
+# If we can create .debuginfo files, then the VM is stripped in vm.make
+# and this macro is not used.
 # LINK_LIB.CC/POST_HOOK += $(STRIP_$(LINK_INTO))
--- a/hotspot/make/linux/makefiles/sa.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/sa.make	Wed Oct 26 17:59:13 2011 -0700
@@ -43,13 +43,7 @@
 # TODO: if it's a modules image, check if SA module is installed.
 MODULELIB_PATH= $(BOOT_JAVA_HOME)/lib/modules
 
-# gnumake 3.78.1 does not accept the *s that
-# are in AGENT_FILES1 and AGENT_FILES2, so use the shell to expand them
-AGENT_FILES1 := $(shell /usr/bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES1))
-AGENT_FILES2 := $(shell /usr/bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES2))
-
-AGENT_FILES1_LIST := $(GENERATED)/agent1.classes.list
-AGENT_FILES2_LIST := $(GENERATED)/agent2.classes.list
+AGENT_FILES_LIST := $(GENERATED)/agent.classes.list
 
 SA_CLASSDIR = $(GENERATED)/saclasses
 
@@ -68,7 +62,7 @@
 	   $(MAKE) -f sa.make $(GENERATED)/sa-jdi.jar; \
 	fi
 
-$(GENERATED)/sa-jdi.jar: $(AGENT_FILES1) $(AGENT_FILES2)
+$(GENERATED)/sa-jdi.jar: $(AGENT_FILES)
 	$(QUIETLY) echo "Making $@"
 	$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
 	  echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
@@ -82,7 +76,6 @@
 	$(QUIETLY) if [ ! -d $(SA_CLASSDIR) ] ; then \
 	  mkdir -p $(SA_CLASSDIR);        \
 	fi
-	
 # Note: When indented, make tries to execute the '$(shell' comment.
 # In some environments, cmd processors have limited line length.
 # To prevent the javac invocation in the next block from using
@@ -93,13 +86,12 @@
 # the initialization of the lists is also done in the same phase
 # using '$(shell rm ...' instead of using the more traditional
 # 'rm ...' rule.
-	$(shell rm -rf $(AGENT_FILES1_LIST) $(AGENT_FILES2_LIST))
-	$(foreach file,$(AGENT_FILES1),$(shell echo $(file) >> $(AGENT_FILES1_LIST)))
-	$(foreach file,$(AGENT_FILES2),$(shell echo $(file) >> $(AGENT_FILES2_LIST)))
-	
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) @$(AGENT_FILES1_LIST)
-	$(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) @$(AGENT_FILES2_LIST)
-	
+	$(shell rm -rf $(AGENT_FILES_LIST))
+# gnumake 3.78.1 does not accept the *'s that
+# 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.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
@@ -118,4 +110,4 @@
 clean:
 	rm -rf $(SA_CLASSDIR)
 	rm -rf $(GENERATED)/sa-jdi.jar
-	rm -rf $(AGENT_FILES1_LIST) $(AGENT_FILES2_LIST)
+	rm -rf $(AGENT_FILES_LIST)
--- a/hotspot/make/linux/makefiles/saproc.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/saproc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,9 @@
 SAPROC_G = $(SAPROC)$(G_SUFFIX)
 LIBSAPROC_G = lib$(SAPROC_G).so
 
+LIBSAPROC_DEBUGINFO   = lib$(SAPROC).debuginfo
+LIBSAPROC_G_DEBUGINFO = lib$(SAPROC_G).debuginfo
+
 AGENT_DIR = $(GAMMADIR)/agent
 
 SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family)
@@ -45,7 +48,8 @@
 
 SAMAPFILE = $(SASRCDIR)/mapfile
 
-DEST_SAPROC = $(JDK_LIBDIR)/$(LIBSAPROC)
+DEST_SAPROC           = $(JDK_LIBDIR)/$(LIBSAPROC)
+DEST_SAPROC_DEBUGINFO = $(JDK_LIBDIR)/$(LIBSAPROC_DEBUGINFO)
 
 # DEBUG_BINARIES overrides everything, use full -g debug information
 ifeq ($(DEBUG_BINARIES), true)
@@ -82,10 +86,25 @@
 	           -o $@                                                \
 	           -lthread_db
 	$(QUIETLY) [ -f $(LIBSAPROC_G) ] || { ln -s $@ $(LIBSAPROC_G); }
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBSAPROC_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -g $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	[ -f $(LIBSAPROC_G_DEBUGINFO) ] || { ln -s $(LIBSAPROC_DEBUGINFO) $(LIBSAPROC_G_DEBUGINFO); }
+endif
 
 install_saproc: $(BUILDLIBSAPROC)
 	$(QUIETLY) if [ -e $(LIBSAPROC) ] ; then             \
 	  echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)";     \
+	  test -f $(LIBSAPROC_DEBUGINFO) &&                  \
+	    cp -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
 	  cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";  \
 	fi
 
--- a/hotspot/make/linux/makefiles/vm.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/linux/makefiles/vm.make	Wed Oct 26 17:59:13 2011 -0700
@@ -60,10 +60,16 @@
 # The order is important for the precompiled headers to work.
 INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%)
 
-ifeq (${VERSION}, debug)
+# SYMFLAG is used by {jsig,saproc}.make
+ifneq ($(OBJCOPY),)
+  # always build with debug info when we can create .debuginfo files
   SYMFLAG = -g
 else
-  SYMFLAG =
+  ifeq (${VERSION}, debug)
+    SYMFLAG = -g
+  else
+    SYMFLAG =
+  endif
 endif
 
 # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined 
@@ -124,6 +130,9 @@
 LIBJVM   = lib$(JVM).so
 LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
 
+LIBJVM_DEBUGINFO   = lib$(JVM).debuginfo
+LIBJVM_G_DEBUGINFO = lib$(JVM)$(G_SUFFIX).debuginfo
+
 SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt
 
 SOURCE_PATHS=\
@@ -307,11 +316,30 @@
 	      fi                                                        \
             fi 								\
 	}
+ifeq ($(CROSS_COMPILE_ARCH),)
+  ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
+    ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+    else
+      ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -g $@
+      # implied else here is no stripping at all
+      endif
+    endif
+	$(QUIETLY) [ -f $(LIBJVM_G_DEBUGINFO) ] || ln -s $(LIBJVM_DEBUGINFO) $(LIBJVM_G_DEBUGINFO)
+  endif
+endif
 
-DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM)
+DEST_SUBDIR        = $(JDK_LIBDIR)/$(VM_SUBDIR)
+DEST_JVM           = $(DEST_SUBDIR)/$(LIBJVM)
+DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO)
 
 install_jvm: $(LIBJVM)
 	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
+	$(QUIETLY) test -f $(LIBJVM_DEBUGINFO) && \
+	    cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
 	$(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
 
 #----------------------------------------------------------------------
--- a/hotspot/make/sa.files	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/sa.files	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
 # Splitted the set of files into two sets because on linux plaform
 # listing or compiling all the files results in 'Argument list too long' error.
 
-AGENT_FILES1 = \
+AGENT_FILES = \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/asm/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/asm/amd64/*.java \
@@ -46,17 +46,18 @@
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/bugspot/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/bugspot/tree/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/c1/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/ci/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/code/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/compiler/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/bsd/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/cdbg/basic/amd64/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/dbx/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/dbx/sparc/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/dbx/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/dummy/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/ia64/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/linux/*.java \
@@ -75,13 +76,13 @@
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/remote/sparc/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/remote/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/sparc/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/win32/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/win32/coff/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/amd64/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/ia64/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/x86/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/g1/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/shared/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_interface/*.java \
@@ -89,12 +90,14 @@
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/jdi/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/livejvm/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/memory/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/oops/*.java 
-
-
-AGENT_FILES2 = \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/oops/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/opto/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/prims/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd_amd64/*.java \
+$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/bsd_x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/ia64/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/linux/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/linux_amd64/*.java \
@@ -106,9 +109,6 @@
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/solaris_sparc/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/solaris_x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/sparc/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/win32_amd64/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/win32_ia64/*.java \
-$(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/win32_x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/runtime/x86/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/tools/*.java \
 $(AGENT_SRC_DIR)/sun/jvm/hotspot/tools/jcore/*.java \
--- a/hotspot/make/solaris/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -168,6 +168,7 @@
 BUILDTREE_MAKE    = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make
 BUILDTREE_VARS    = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) ARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH)
 BUILDTREE_VARS   += HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) HOTSPOT_BUILD_VERSION=$(HOTSPOT_BUILD_VERSION) JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION)
+BUILDTREE_VARS   += OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY)
 
 BUILDTREE         = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/solaris/makefiles/build_vm_def.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+/usr/ccs/bin/nm -p $* \
+    | awk '{
+          if ($2 == "U") next
+          if ($3 ~ /^__1c.*__vtbl_$/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";"
+          if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";"
+          if ($3 ~ /^__1cJArgumentsRSharedArchivePath_$/) print "\t" $3 ";"
+          }' \
+    | sort -u
--- a/hotspot/make/solaris/makefiles/buildtree.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/buildtree.make	Wed Oct 26 17:59:13 2011 -0700
@@ -226,6 +226,10 @@
 	echo "$(call gamma-path,commonsrc,os/posix/vm)"; \
 	[ -n "$(CFLAGS_BROWSE)" ] && \
 	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
+	[ -n "$(OBJCOPY)" ] && \
+	    echo && echo "OBJCOPY = $(OBJCOPY)"; \
+	[ -n "$(STRIP_POLICY)" ] && \
+	    echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \
 	[ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \
 	    echo && \
 	    echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
--- a/hotspot/make/solaris/makefiles/debug.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/debug.make	Wed Oct 26 17:59:13 2011 -0700
@@ -41,8 +41,7 @@
 
 # Linker mapfiles
 MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \
-          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug \
-          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-nonproduct
+          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug
 
 # This mapfile is only needed when compiling with dtrace support, 
 # and mustn't be otherwise.
--- a/hotspot/make/solaris/makefiles/defs.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/defs.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -59,37 +59,135 @@
   endif
 endif
 
+# determine if HotSpot is being built in JDK6 or earlier version
+JDK6_OR_EARLIER=0
+ifeq "$(shell expr \( '$(JDK_MAJOR_VERSION)' != '' \& '$(JDK_MINOR_VERSION)' != '' \& '$(JDK_MICRO_VERSION)' != '' \))" "1"
+  # if the longer variable names (newer build style) are set, then check those
+  ifeq "$(shell expr \( $(JDK_MAJOR_VERSION) = 1 \& $(JDK_MINOR_VERSION) \< 7 \))" "1"
+    JDK6_OR_EARLIER=1
+  endif
+else
+  # the longer variables aren't set so check the shorter variable names
+  ifeq "$(shell expr \( '$(JDK_MAJOR_VER)' = 1 \& '$(JDK_MINOR_VER)' \< 7 \))" "1"
+    JDK6_OR_EARLIER=1
+  endif
+endif
+
+ifeq ($(JDK6_OR_EARLIER),0)
+  # Full Debug Symbols is supported on JDK7 or newer
+
+ifdef ENABLE_FULL_DEBUG_SYMBOLS
+  # Only check for Full Debug Symbols support on Solaris if it is
+  # specifically enabled. Hopefully, it can be enabled by default
+  # once the .debuginfo size issues are worked out.
+  
+  # Default OBJCOPY comes from the SUNWbinutils package:
+  DEF_OBJCOPY=/usr/sfw/bin/gobjcopy
+  ifeq ($(VM_PLATFORM),solaris_amd64)
+    # On Solaris AMD64/X64, gobjcopy is not happy and fails:
+    #
+    # usr/sfw/bin/gobjcopy --add-gnu-debuglink=<lib>.debuginfo <lib>.so
+    # BFD: stKPaiop: Not enough room for program headers, try linking with -N
+    # /usr/sfw/bin/gobjcopy: stKPaiop: Bad value
+    # BFD: stKPaiop: Not enough room for program headers, try linking with -N
+    # /usr/sfw/bin/gobjcopy: libsaproc.debuginfo: Bad value
+    # BFD: stKPaiop: Not enough room for program headers, try linking with -N
+    # /usr/sfw/bin/gobjcopy: stKPaiop: Bad value
+    _JUNK_ := $(shell \
+      echo >&2 "INFO: $(DEF_OBJCOPY) is not working on Solaris AMD64/X64")
+    OBJCOPY=
+  else
+    OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
+    ifneq ($(ALT_OBJCOPY),)
+      _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
+      # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
+      OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
+    endif
+  endif
+endif
+  
+  ifeq ($(OBJCOPY),)
+    _JUNK_ := $(shell \
+      echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
+  else
+    _JUNK_ := $(shell \
+      echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")
+  
+    # Library stripping policies for .debuginfo configs:
+    #   all_strip - strips everything from the library
+    #   min_strip - strips most stuff from the library; leaves minimum symbols
+    #   no_strip  - does not strip the library at all
+    #
+    # Oracle security policy requires "all_strip". A waiver was granted on
+    # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
+    #
+    DEF_STRIP_POLICY="min_strip"
+    ifeq ($(ALT_STRIP_POLICY),)
+      STRIP_POLICY=$(DEF_STRIP_POLICY)
+    else
+      STRIP_POLICY=$(ALT_STRIP_POLICY)
+    endif
+    _JUNK_ := $(shell \
+      echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
+  endif
+endif
+
 JDK_INCLUDE_SUBDIR=solaris
 
+# Library suffix
+LIBRARY_SUFFIX=so
+
 # FIXUP: The subdirectory for a debug build is NOT the same on all platforms
 VM_DEBUG=jvmg
 
 EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html
 
-# client and server subdirectories have symbolic links to ../libjsig.so
-EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.so
+# client and server subdirectories have symbolic links to ../libjsig.$(LIBRARY_SUFFIX)
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX)
+ifneq ($(OBJCOPY),)
+  EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libjsig.debuginfo
+endif
 
 EXPORT_SERVER_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/server
 EXPORT_CLIENT_DIR = $(EXPORT_JRE_LIB_ARCH_DIR)/client
 
 ifneq ($(BUILD_CLIENT_ONLY),true)
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.so
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.so
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.so
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX)
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.$(LIBRARY_SUFFIX)
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.$(LIBRARY_SUFFIX)
+  ifneq ($(OBJCOPY),)
+    EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo
+    EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.debuginfo
+    EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.debuginfo
+  endif
 endif
 ifeq ($(ARCH_DATA_MODEL), 32)
   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.so 
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.so 
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.so
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.so
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.so
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX) 
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.$(LIBRARY_SUFFIX) 
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.$(LIBRARY_SUFFIX)
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.$(LIBRARY_SUFFIX)
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.$(LIBRARY_SUFFIX)
+  ifneq ($(OBJCOPY),)
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.debuginfo
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.debuginfo
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.debuginfo
+    EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.debuginfo
+  endif
   ifneq ($(BUILD_CLIENT_ONLY), true)
-    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.so
-    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.so
+    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.$(LIBRARY_SUFFIX)
+    EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.$(LIBRARY_SUFFIX)
+    ifneq ($(OBJCOPY),)
+      EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.debuginfo
+      EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.debuginfo
+    endif
   endif
 endif
 
-EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.so
+EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX)
+ifneq ($(OBJCOPY),)
+  EXPORT_LIST += $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.debuginfo
+endif
 EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar 
--- a/hotspot/make/solaris/makefiles/dtrace.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/dtrace.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -41,10 +41,16 @@
 LIBJVM_DB = libjvm_db.so
 LIBJVM_DB_G = libjvm$(G_SUFFIX)_db.so
 
+LIBJVM_DB_DEBUGINFO = libjvm_db.debuginfo
+LIBJVM_DB_G_DEBUGINFO = libjvm$(G_SUFFIX)_db.debuginfo
+
 JVM_DTRACE = jvm_dtrace
 LIBJVM_DTRACE = libjvm_dtrace.so
 LIBJVM_DTRACE_G = libjvm$(G_SUFFIX)_dtrace.so
 
+LIBJVM_DTRACE_DEBUGINFO = libjvm_dtrace.debuginfo
+LIBJVM_DTRACE_G_DEBUGINFO = libjvm$(G_SUFFIX)_dtrace.debuginfo
+
 JVMOFFS = JvmOffsets
 JVMOFFS.o = $(JVMOFFS).o
 GENOFFS = generate$(JVMOFFS)
@@ -89,12 +95,30 @@
 XLIBJVM_DTRACE = 64/$(LIBJVM_DTRACE)
 XLIBJVM_DTRACE_G = 64/$(LIBJVM_DTRACE_G)
 
+XLIBJVM_DB_DEBUGINFO = 64/$(LIBJVM_DB_DEBUGINFO)
+XLIBJVM_DB_G_DEBUGINFO = 64/$(LIBJVM_DB_G_DEBUGINFO)
+XLIBJVM_DTRACE_DEBUGINFO = 64/$(LIBJVM_DTRACE_DEBUGINFO)
+XLIBJVM_DTRACE_G_DEBUGINFO = 64/$(LIBJVM_DTRACE_G_DEBUGINFO)
+
 $(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE)
 	@echo Making $@
 	$(QUIETLY) mkdir -p 64/ ; \
 	$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. -I$(GENERATED) \
 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
 	[ -f $(XLIBJVM_DB_G) ] || { ln -s $(LIBJVM_DB) $(XLIBJVM_DB_G); }
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DB_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(XLIBJVM_DB_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -x $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	[ -f $(XLIBJVM_DB_G_DEBUGINFO) ] || { ln -s $(LIBJVM_DB_DEBUGINFO) $(XLIBJVM_DB_G_DEBUGINFO); }
+endif
 
 $(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
 	@echo Making $@
@@ -102,6 +126,19 @@
 	$(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. \
 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
 	[ -f $(XLIBJVM_DTRACE_G) ] || { ln -s $(LIBJVM_DTRACE) $(XLIBJVM_DTRACE_G); }
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DTRACE_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(XLIBJVM_DTRACE_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -x $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	[ -f $(XLIBJVM_DTRACE_G_DEBUGINFO) ] || { ln -s $(LIBJVM_DTRACE_DEBUGINFO) $(XLIBJVM_DTRACE_G_DEBUGINFO); }
+endif
 
 endif # ifneq ("${ISA}","${BUILDARCH}")
 
@@ -148,12 +185,38 @@
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \
 		$(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc
 	[ -f $(LIBJVM_DB_G) ] || { ln -s $@ $(LIBJVM_DB_G); }
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DB_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -x $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	[ -f $(LIBJVM_DB_G_DEBUGINFO) ] || { ln -s $(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB_G_DEBUGINFO); }
+endif
 
 $(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE)
 	@echo Making $@
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I.  \
 		$(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c -lc -lthread -ldoor
 	[ -f $(LIBJVM_DTRACE_G) ] || { ln -s $@ $(LIBJVM_DTRACE_G); }
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DTRACE_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -x $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	[ -f $(LIBJVM_DTRACE_G_DEBUGINFO) ] || { ln -s $(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE_G_DEBUGINFO); }
+endif
 
 $(DTRACE).d: $(DTRACE_SRCDIR)/hotspot.d $(DTRACE_SRCDIR)/hotspot_jni.d \
              $(DTRACE_SRCDIR)/hs_private.d $(DTRACE_SRCDIR)/jhelper.d
--- a/hotspot/make/solaris/makefiles/fastdebug.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/fastdebug.make	Wed Oct 26 17:59:13 2011 -0700
@@ -107,8 +107,7 @@
 
 # Linker mapfiles
 MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \
-	  $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug \
-	  $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-nonproduct
+	  $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug
 
 # This mapfile is only needed when compiling with dtrace support, 
 # and mustn't be otherwise.
--- a/hotspot/make/solaris/makefiles/jsig.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/jsig.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,13 @@
 JSIG_G    = $(JSIG)$(G_SUFFIX)
 LIBJSIG_G = lib$(JSIG_G).so
 
+LIBJSIG_DEBUGINFO   = lib$(JSIG).debuginfo
+LIBJSIG_G_DEBUGINFO = lib$(JSIG_G).debuginfo
+
 JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm
 
-DEST_JSIG  = $(JDK_LIBDIR)/$(LIBJSIG)
+DEST_JSIG           = $(JDK_LIBDIR)/$(LIBJSIG)
+DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO)
 
 LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig
 
@@ -50,9 +54,24 @@
 	$(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \
                          $(LFLAGS_JSIG) -o $@ $< -ldl
 	[ -f $(LIBJSIG_G) ] || { ln -s $@ $(LIBJSIG_G); }
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -x $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	[ -f $(LIBJSIG_G_DEBUGINFO) ] || { ln -s $(LIBJSIG_DEBUGINFO) $(LIBJSIG_G_DEBUGINFO); }
+endif
 
 install_jsig: $(LIBJSIG)
 	@echo "Copying $(LIBJSIG) to $(DEST_JSIG)"
+	$(QUIETLY) test -f $(LIBJSIG_DEBUGINFO) && \
+	    cp -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO)
 	$(QUIETLY) cp -f $(LIBJSIG) $(DEST_JSIG) && echo "Done"
 
 .PHONY: install_jsig
--- a/hotspot/make/solaris/makefiles/jvmg.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/jvmg.make	Wed Oct 26 17:59:13 2011 -0700
@@ -44,8 +44,7 @@
 
 # Linker mapfiles
 MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \
-          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug \
-          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-nonproduct
+          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug
 
 # This mapfile is only needed when compiling with dtrace support,
 # and mustn't be otherwise.
--- a/hotspot/make/solaris/makefiles/mapfile-vers	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/mapfile-vers	Wed Oct 26 17:59:13 2011 -0700
@@ -3,7 +3,7 @@
 #
 
 #
-# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -256,6 +256,9 @@
 
 		# This is for Forte Analyzer profiling support.
 		AsyncGetCallTrace;
+
+		# INSERT VTABLE SYMBOLS HERE
+
         local:
                 *;
 };
--- a/hotspot/make/solaris/makefiles/mapfile-vers-nonproduct	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#
-
-#
-# Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#  
-#
-
-# Define public interface.
-
-SUNWprivate_1.1 {
-        global:
-		# Old reflection routines
-		# These do not need to be present in the product build in JDK 1.4
-		# but their code has not been removed yet because there will not
-		# be a substantial code savings until JVM_InvokeMethod and
-		# JVM_NewInstanceFromConstructor can also be removed; see
-		# reflectionCompat.hpp.
-		JVM_GetClassConstructor;
-		JVM_GetClassConstructors;
-		JVM_GetClassField;
-		JVM_GetClassFields;
-		JVM_GetClassMethod;
-		JVM_GetClassMethods;
-		JVM_GetField;
-		JVM_GetPrimitiveField;
-		JVM_NewInstance;
-		JVM_SetField;
-		JVM_SetPrimitiveField;
-};
--- a/hotspot/make/solaris/makefiles/optimized.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/optimized.make	Wed Oct 26 17:59:13 2011 -0700
@@ -48,9 +48,7 @@
 CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE)
 
 # Linker mapfiles
-# NOTE: inclusion of nonproduct mapfile not necessary; read it for details
-MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \
-          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-nonproduct
+MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers
 
 # This mapfile is only needed when compiling with dtrace support, 
 # and mustn't be otherwise.
--- a/hotspot/make/solaris/makefiles/product.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/product.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -58,13 +58,9 @@
 # to inhibit the effect of the previous line on CFLAGS.
 
 # Linker mapfiles
-# NOTE: inclusion of nonproduct mapfile not necessary; read it for details
-ifdef USE_GCC
 MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers
-else
-MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \
-          $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-nonproduct
 
+ifndef USE_GCC
 # This mapfile is only needed when compiling with dtrace support, 
 # and mustn't be otherwise.
 MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE)
@@ -72,7 +68,8 @@
 REORDERFILE = $(GAMMADIR)/make/solaris/makefiles/reorder_$(TYPE)_$(BUILDARCH)
 endif
 
-# Don't strip in VM build; JDK build will strip libraries later
+# If we can create .debuginfo files, then the VM is stripped in vm.make
+# and this macro is not used.
 # LINK_LIB.CC/POST_HOOK += $(STRIP_LIB.CC/POST_HOOK)
 
 G_SUFFIX =
--- a/hotspot/make/solaris/makefiles/sa.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/sa.make	Wed Oct 26 17:59:13 2011 -0700
@@ -39,13 +39,7 @@
 # TODO: if it's a modules image, check if SA module is installed.
 MODULELIB_PATH= $(BOOT_JAVA_HOME)/lib/modules
 
-# gnumake 3.78.1 does not accept the *s that
-# are in AGENT_FILES1 and AGENT_FILES2, so use the shell to expand them
-AGENT_FILES1 := $(shell /usr/bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES1))
-AGENT_FILES2 := $(shell /usr/bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES2))
-
-AGENT_FILES1_LIST := $(GENERATED)/agent1.classes.list
-AGENT_FILES2_LIST := $(GENERATED)/agent2.classes.list
+AGENT_FILES_LIST := $(GENERATED)/agent.classes.list
 
 SA_CLASSDIR = $(GENERATED)/saclasses
 
@@ -59,7 +53,7 @@
 	   $(MAKE) -f sa.make $(GENERATED)/sa-jdi.jar; \
 	fi
 
-$(GENERATED)/sa-jdi.jar: $(AGENT_FILES1) $(AGENT_FILES2)
+$(GENERATED)/sa-jdi.jar: $(AGENT_FILES)
 	$(QUIETLY) echo "Making $@";
 	$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
 	   echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
@@ -73,7 +67,6 @@
 	$(QUIETLY) if [ ! -d $(SA_CLASSDIR) ] ; then \
 	  mkdir -p $(SA_CLASSDIR);        \
 	fi
-	
 # Note: When indented, make tries to execute the '$(shell' comment.
 # In some environments, cmd processors have limited line length.
 # To prevent the javac invocation in the next block from using
@@ -84,13 +77,12 @@
 # the initialization of the lists is also done in the same phase
 # using '$(shell rm ...' instead of using the more traditional
 # 'rm ...' rule.
-	$(shell rm -rf $(AGENT_FILES1_LIST) $(AGENT_FILES2_LIST))
-	$(foreach file,$(AGENT_FILES1),$(shell echo $(file) >> $(AGENT_FILES1_LIST)))
-	$(foreach file,$(AGENT_FILES2),$(shell echo $(file) >> $(AGENT_FILES2_LIST)))
-	
-	$(QUIETLY) $(COMPILE.JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) @$(AGENT_FILES1_LIST)
-	$(QUIETLY) $(COMPILE.JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) @$(AGENT_FILES2_LIST)
-	
+	$(shell rm -rf $(AGENT_FILES_LIST))
+# gnumake 3.78.1 does not accept the *'s that
+# 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) $(COMPILE.JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) @$(AGENT_FILES_LIST)
 	$(QUIETLY) $(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
@@ -106,4 +98,4 @@
 clean:
 	rm -rf $(SA_CLASSDIR)
 	rm -rf $(GENERATED)/sa-jdi.jar
-	rm -rf $(AGENT_FILES1_LIST) $(AGENT_FILES2_LIST)
+	rm -rf $(AGENT_FILES_LIST)
--- a/hotspot/make/solaris/makefiles/saproc.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/saproc.make	Wed Oct 26 17:59:13 2011 -0700
@@ -32,6 +32,9 @@
 SAPROC_G = $(SAPROC)$(G_SUFFIX)
 LIBSAPROC_G = lib$(SAPROC_G).so
 
+LIBSAPROC_DEBUGINFO   = lib$(SAPROC).debuginfo
+LIBSAPROC_G_DEBUGINFO = lib$(SAPROC_G).debuginfo
+
 AGENT_DIR = $(GAMMADIR)/agent
 
 SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family)/proc
@@ -40,7 +43,8 @@
 
 SAMAPFILE = $(SASRCDIR)/mapfile
 
-DEST_SAPROC = $(JDK_LIBDIR)/$(LIBSAPROC)
+DEST_SAPROC           = $(JDK_LIBDIR)/$(LIBSAPROC)
+DEST_SAPROC_DEBUGINFO = $(JDK_LIBDIR)/$(LIBSAPROC_DEBUGINFO)
 
 # if $(AGENT_DIR) does not exist, we don't build SA
 
@@ -101,10 +105,25 @@
 	           -o $@                                                \
 	           -ldl -ldemangle -lthread -lc
 	[ -f $(LIBSAPROC_G) ] || { ln -s $@ $(LIBSAPROC_G); }
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBSAPROC_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -x $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	[ -f $(LIBSAPROC_G_DEBUGINFO) ] || { ln -s $(LIBSAPROC_DEBUGINFO) $(LIBSAPROC_G_DEBUGINFO); }
+endif
 
 install_saproc: $(BULDLIBSAPROC)
 	$(QUIETLY) if [ -f $(LIBSAPROC) ] ; then             \
 	  echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)";     \
+	  test -f $(LIBSAPROC_DEBUGINFO) &&             \
+	    cp -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
 	  cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";  \
 	fi
 
--- a/hotspot/make/solaris/makefiles/sparcWorks.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/sparcWorks.make	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -148,6 +148,9 @@
 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
 
+# Compiler warnings are treated as errors
+CFLAGS_WARN = -xwe
+
 ################################################
 # Begin current (>=5.9) Forte compiler options #
 #################################################
@@ -478,9 +481,18 @@
 endif
 
 # Flags for Debugging
+# The -g0 setting allows the C++ frontend to inline, which is a big win.
+# The -xs setting disables 'lazy debug info' which puts everything in
+# the .so instead of requiring the '.o' files.
+ifneq ($(OBJCOPY),)
+  OPT_CFLAGS += -g0 -xs
+endif
 DEBUG_CFLAGS = -g
 FASTDEBUG_CFLAGS = -g0
-# The -g0 setting allows the C++ frontend to inline, which is a big win.
+ifneq ($(OBJCOPY),)
+  DEBUG_CFLAGS += -xs
+  FASTDEBUG_CFLAGS += -xs
+endif
 
 # Special global options for SS12
 ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
@@ -499,6 +511,9 @@
 # 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.
+# EXTRA_CFLAGS only covers vm_version.cpp for some reason
+#EXTRA_CFLAGS += -Qoption ccfe -xglobalstatic
+#OPT_CFLAGS += -Qoption ccfe -xglobalstatic
 #DEBUG_CFLAGS += -Qoption ccfe -xglobalstatic
 #FASTDEBUG_CFLAGS += -Qoption ccfe -xglobalstatic
 
@@ -559,6 +574,8 @@
 # since the hook must terminate itself as a valid command.)
 
 # Also, strip debug and line number information (worth about 1.7Mb).
+# If we can create .debuginfo files, then the VM is stripped in vm.make
+# and this macro is not used.
 STRIP_LIB.CC/POST_HOOK = $(STRIP) -x $@ || exit 1;
 # STRIP_LIB.CC/POST_HOOK is incorporated into LINK_LIB.CC/POST_HOOK
 # in certain configurations, such as product.make.  Other configurations,
--- a/hotspot/make/solaris/makefiles/vm.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/solaris/makefiles/vm.make	Wed Oct 26 17:59:13 2011 -0700
@@ -55,10 +55,17 @@
 Src_Dirs_I += $(GENERATED)
 INCLUDES += $(Src_Dirs_I:%=-I%)
 
-ifeq (${VERSION}, debug)
-  SYMFLAG = -g
+# SYMFLAG is used by {dtrace,jsig,saproc}.make.
+ifneq ($(OBJCOPY),)
+  # always build with debug info when we can create .debuginfo files
+  # and disable 'lazy debug info' so the .so has everything.
+  SYMFLAG = -g -xs
 else
-  SYMFLAG =
+  ifeq (${VERSION}, debug)
+    SYMFLAG = -g
+  else
+    SYMFLAG =
+  endif
 endif
 
 # The following variables are defined in the generated flags.make file.
@@ -140,6 +147,9 @@
 LIBJVM   = lib$(JVM).so
 LIBJVM_G = lib$(JVM)$(G_SUFFIX).so
 
+LIBJVM_DEBUGINFO   = lib$(JVM).debuginfo
+LIBJVM_G_DEBUGINFO = lib$(JVM)$(G_SUFFIX).debuginfo
+
 SPECIAL_PATHS:=adlc c1 dist gc_implementation opto shark libadt
 
 SOURCE_PATHS=\
@@ -212,14 +222,24 @@
 
 vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES))
 
-mapfile : $(MAPFILE) $(MAPFILE_DTRACE_OPT)
+mapfile : $(MAPFILE) $(MAPFILE_DTRACE_OPT) vm.def
 	rm -f $@
-	cat $^ > $@
+	cat $(MAPFILE) $(MAPFILE_DTRACE_OPT) \
+	    | $(NAWK) '{                                         \
+	              if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") {  \
+	                  system ("cat vm.def");                 \
+	              } else {                                   \
+	                  print $$0;                             \
+	              }                                          \
+	          }' > $@
 
 mapfile_reorder : mapfile $(MAPFILE_DTRACE_OPT) $(REORDERFILE)
 	rm -f $@
 	cat $^ > $@
 
+vm.def: $(Obj_Files)
+	sh $(GAMMADIR)/make/solaris/makefiles/build_vm_def.sh *.o > $@
+
 ifeq ($(LINK_INTO),AOUT)
   LIBJVM.o                 =
   LIBJVM_MAPFILE           =
@@ -255,13 +275,30 @@
 	$(QUIETLY) rm -f $@.1 && ln -s $@ $@.1
 	$(QUIETLY) [ -f $(LIBJVM_G) ] || ln -s $@ $(LIBJVM_G)
 	$(QUIETLY) [ -f $(LIBJVM_G).1 ] || ln -s $@.1 $(LIBJVM_G).1
+ifneq ($(OBJCOPY),)
+	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO)
+	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@
+  ifeq ($(STRIP_POLICY),all_strip)
+	$(QUIETLY) $(STRIP) $@
+  else
+    ifeq ($(STRIP_POLICY),min_strip)
+	$(QUIETLY) $(STRIP) -x $@
+    # implied else here is no stripping at all
+    endif
+  endif
+	$(QUIETLY) [ -f $(LIBJVM_G_DEBUGINFO) ] || ln -s $(LIBJVM_DEBUGINFO) $(LIBJVM_G_DEBUGINFO)
+endif
 endif # filter -sbfast -xsbfast
 
 
-DEST_JVM = $(JDK_LIBDIR)/$(VM_SUBDIR)/$(LIBJVM)
+DEST_SUBDIR        = $(JDK_LIBDIR)/$(VM_SUBDIR)
+DEST_JVM           = $(DEST_SUBDIR)/$(LIBJVM)
+DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO)
 
 install_jvm: $(LIBJVM)
 	@echo "Copying $(LIBJVM) to $(DEST_JVM)"
+	$(QUIETLY) test -f $(LIBJVM_DEBUGINFO) && \
+	    cp -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO)
 	$(QUIETLY) cp -f $(LIBJVM) $(DEST_JVM) && echo "Done"
 
 #----------------------------------------------------------------------
--- a/hotspot/make/templates/bsd-header	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-Copyright (c) %YEARS%, Oracle and/or its affiliates. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-  - Redistributions of source code must retain the above copyright
-    notice, this list of conditions and the following disclaimer.
-
-  - Redistributions in binary form must reproduce the above copyright
-    notice, this list of conditions and the following disclaimer in the
-    documentation and/or other materials provided with the distribution.
-
-  - Neither the name of Oracle nor the names of its
-    contributors may be used to endorse or promote products derived
-    from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- a/hotspot/make/windows/makefiles/defs.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/windows/makefiles/defs.make	Wed Oct 26 17:59:13 2011 -0700
@@ -109,6 +109,9 @@
 
 JDK_INCLUDE_SUBDIR=win32
 
+# Library suffix
+LIBRARY_SUFFIX=dll
+
 # HOTSPOT_RELEASE_VERSION and HOTSPOT_BUILD_VERSION are defined
 # and added to MAKE_ARGS list in $(GAMMADIR)/make/defs.make.
 
@@ -175,24 +178,24 @@
 EXPORT_KERNEL_DIR = $(EXPORT_JRE_BIN_DIR)/kernel
 
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt
-EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.dll
+EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.$(LIBRARY_SUFFIX)
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.pdb
 EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.map
 EXPORT_LIST += $(EXPORT_LIB_DIR)/jvm.lib
 ifeq ($(ARCH_DATA_MODEL), 32)
   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.dll
+  EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.$(LIBRARY_SUFFIX)
   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.pdb
   EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.map
   # kernel vm
   EXPORT_LIST += $(EXPORT_KERNEL_DIR)/Xusage.txt
-  EXPORT_LIST += $(EXPORT_KERNEL_DIR)/jvm.dll
+  EXPORT_LIST += $(EXPORT_KERNEL_DIR)/jvm.$(LIBRARY_SUFFIX)
   EXPORT_LIST += $(EXPORT_KERNEL_DIR)/jvm.pdb
   EXPORT_LIST += $(EXPORT_KERNEL_DIR)/jvm.map
 endif
 
 ifeq ($(BUILD_WIN_SA), 1)
-  EXPORT_LIST += $(EXPORT_JRE_BIN_DIR)/sawindbg.dll
+  EXPORT_LIST += $(EXPORT_JRE_BIN_DIR)/sawindbg.$(LIBRARY_SUFFIX)
   EXPORT_LIST += $(EXPORT_JRE_BIN_DIR)/sawindbg.pdb
   EXPORT_LIST += $(EXPORT_JRE_BIN_DIR)/sawindbg.map
   EXPORT_LIST += $(EXPORT_LIB_DIR)/sa-jdi.jar
--- a/hotspot/make/windows/makefiles/sa.make	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/make/windows/makefiles/sa.make	Wed Oct 26 17:59:13 2011 -0700
@@ -52,12 +52,11 @@
 # Remove the space between $(SA_BUILD_VERSION_PROP) and > below as it adds a white space
 # at the end of SA version string and causes a version mismatch with the target VM version.
 
-$(GENERATED)\sa-jdi.jar: $(AGENT_FILES1:/=\) $(AGENT_FILES2:/=\)
+$(GENERATED)\sa-jdi.jar: $(AGENT_FILES:/=\)
 	@if not exist $(SA_CLASSDIR) mkdir $(SA_CLASSDIR)
 	@echo ...Building sa-jdi.jar
 	@echo ...$(COMPILE_JAVAC) -classpath $(SA_CLASSPATH) -d $(SA_CLASSDIR) ....
-	@$(COMPILE_JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) $(AGENT_FILES1:/=\)
-	@$(COMPILE_JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) $(AGENT_FILES2:/=\)
+	@$(COMPILE_JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) $(AGENT_FILES:/=\)
 	$(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/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1794,7 +1794,8 @@
   mov(reg,O0); // Move arg into O0; arg might be in O7 which is about to be crushed
   stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
 
-  set((intptr_t)real_msg, O1);
+  // Size of set() should stay the same
+  patchable_set((intptr_t)real_msg, O1);
   // Load address to call to into O7
   load_ptr_contents(a, O7);
   // Register call to verify_oop_subroutine
@@ -1831,7 +1832,8 @@
   ld_ptr(addr.base(), addr.disp() + 8*8, O0); // Load arg into O0; arg might be in O7 which is about to be crushed
   stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
 
-  set((intptr_t)real_msg, O1);
+  // Size of set() should stay the same
+  patchable_set((intptr_t)real_msg, O1);
   // Load address to call to into O7
   load_ptr_contents(a, O7);
   // Register call to verify_oop_subroutine
@@ -1976,7 +1978,8 @@
     save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
 
     // stop_subroutine expects message pointer in I1.
-    set((intptr_t)msg, O1);
+    // Size of set() should stay the same
+    patchable_set((intptr_t)msg, O1);
 
     // factor long stop-sequence into subroutine to save space
     assert(StubRoutines::Sparc::stop_subroutine_entry_address(), "hasn't been generated yet");
@@ -1998,7 +2001,8 @@
   save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
   RegistersForDebugging::save_registers(this);
   mov(O0, L0);
-  set((intptr_t)msg, O0);
+  // Size of set() should stay the same
+  patchable_set((intptr_t)msg, O0);
   call( CAST_FROM_FN_PTR(address, warning) );
   delayed()->nop();
 //  ret();
@@ -2161,29 +2165,6 @@
 #endif
 }
 
-void MacroAssembler::br_on_reg_cond( RCondition rc, bool a, Predict p,
-                                     Register s1, address d,
-                                     relocInfo::relocType rt ) {
-  assert_not_delayed();
-  if (VM_Version::v9_instructions_work()) {
-    bpr(rc, a, p, s1, d, rt);
-  } else {
-    tst(s1);
-    br(reg_cond_to_cc_cond(rc), a, p, d, rt);
-  }
-}
-
-void MacroAssembler::br_on_reg_cond( RCondition rc, bool a, Predict p,
-                                     Register s1, Label& L ) {
-  assert_not_delayed();
-  if (VM_Version::v9_instructions_work()) {
-    bpr(rc, a, p, s1, L);
-  } else {
-    tst(s1);
-    br(reg_cond_to_cc_cond(rc), a, p, L);
-  }
-}
-
 // Compare registers and branch with nop in delay slot or cbcond without delay slot.
 
 // Compare integer (32 bit) values (icc only).
@@ -3276,15 +3257,10 @@
                                                 Register temp_reg) {
   assert_different_registers(vmslots_reg, mh_reg, temp_reg);
   // load mh.type.form.vmslots
-  if (java_lang_invoke_MethodHandle::vmslots_offset_in_bytes() != 0) {
-    // hoist vmslots into every mh to avoid dependent load chain
-    ld(           Address(mh_reg,    delayed_value(java_lang_invoke_MethodHandle::vmslots_offset_in_bytes, temp_reg)),   vmslots_reg);
-  } else {
-    Register temp2_reg = vmslots_reg;
-    load_heap_oop(Address(mh_reg,    delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)),      temp2_reg);
-    load_heap_oop(Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)),        temp2_reg);
-    ld(           Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg);
-  }
+  Register temp2_reg = vmslots_reg;
+  load_heap_oop(Address(mh_reg,    delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)),      temp2_reg);
+  load_heap_oop(Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)),        temp2_reg);
+  ld(           Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg);
 }
 
 
@@ -4340,22 +4316,29 @@
   } else {
     pre_val = O0;
   }
+
   int satb_q_index_byte_offset =
     in_bytes(JavaThread::satb_mark_queue_offset() +
              PtrQueue::byte_offset_of_index());
+
   int satb_q_buf_byte_offset =
     in_bytes(JavaThread::satb_mark_queue_offset() +
              PtrQueue::byte_offset_of_buf());
+
   assert(in_bytes(PtrQueue::byte_width_of_index()) == sizeof(intptr_t) &&
          in_bytes(PtrQueue::byte_width_of_buf()) == sizeof(intptr_t),
          "check sizes in assembly below");
 
   __ bind(restart);
+
+  // Load the index into the SATB buffer. PtrQueue::_index is a size_t
+  // so ld_ptr is appropriate.
   __ ld_ptr(G2_thread, satb_q_index_byte_offset, L0);
 
-  __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pn, L0, refill);
-  // If the branch is taken, no harm in executing this in the delay slot.
-  __ delayed()->ld_ptr(G2_thread, satb_q_buf_byte_offset, L1);
+  // index == 0?
+  __ cmp_and_brx_short(L0, G0, Assembler::equal, Assembler::pn, refill);
+
+  __ ld_ptr(G2_thread, satb_q_buf_byte_offset, L1);
   __ sub(L0, oopSize, L0);
 
   __ st_ptr(pre_val, L1, L0);  // [_buf + index] := I0
@@ -4466,9 +4449,8 @@
          tmp);
   }
 
-  // Check on whether to annul.
-  br_on_reg_cond(rc_z, /*annul*/false, Assembler::pt, tmp, filtered);
-  delayed()->nop();
+  // Is marking active?
+  cmp_and_br_short(tmp, G0, Assembler::equal, Assembler::pt, filtered);
 
   // Do we need to load the previous value?
   if (obj != noreg) {
@@ -4490,9 +4472,7 @@
   assert(pre_val != noreg, "must have a real register");
 
   // Is the previous value null?
-  // Check on whether to annul.
-  br_on_reg_cond(rc_z, /*annul*/false, Assembler::pt, pre_val, filtered);
-  delayed()->nop();
+  cmp_and_brx_short(pre_val, G0, Assembler::equal, Assembler::pt, filtered);
 
   // OK, it's not filtered, so we'll need to call enqueue.  In the normal
   // case, pre_val will be a scratch G-reg, but there are some cases in
@@ -4519,39 +4499,6 @@
   bind(filtered);
 }
 
-static jint num_ct_writes = 0;
-static jint num_ct_writes_filtered_in_hr = 0;
-static jint num_ct_writes_filtered_null = 0;
-static G1CollectedHeap* g1 = NULL;
-
-static Thread* count_ct_writes(void* filter_val, void* new_val) {
-  Atomic::inc(&num_ct_writes);
-  if (filter_val == NULL) {
-    Atomic::inc(&num_ct_writes_filtered_in_hr);
-  } else if (new_val == NULL) {
-    Atomic::inc(&num_ct_writes_filtered_null);
-  } else {
-    if (g1 == NULL) {
-      g1 = G1CollectedHeap::heap();
-    }
-  }
-  if ((num_ct_writes % 1000000) == 0) {
-    jint num_ct_writes_filtered =
-      num_ct_writes_filtered_in_hr +
-      num_ct_writes_filtered_null;
-
-    tty->print_cr("%d potential CT writes: %5.2f%% filtered\n"
-                  "   (%5.2f%% intra-HR, %5.2f%% null).",
-                  num_ct_writes,
-                  100.0*(float)num_ct_writes_filtered/(float)num_ct_writes,
-                  100.0*(float)num_ct_writes_filtered_in_hr/
-                  (float)num_ct_writes,
-                  100.0*(float)num_ct_writes_filtered_null/
-                  (float)num_ct_writes);
-  }
-  return Thread::current();
-}
-
 static address dirty_card_log_enqueue = 0;
 static u_char* dirty_card_log_enqueue_end = 0;
 
@@ -4574,11 +4521,8 @@
   __ set(addrlit, O1); // O1 := <card table base>
   __ ldub(O0, O1, O2); // O2 := [O0 + O1]
 
-  __ br_on_reg_cond(Assembler::rc_nz, /*annul*/false, Assembler::pt,
-                      O2, not_already_dirty);
-  // Get O1 + O2 into a reg by itself -- useful in the take-the-branch
-  // case, harmless if not.
-  __ delayed()->add(O0, O1, O3);
+  assert(CardTableModRefBS::dirty_card_val() == 0, "otherwise check this code");
+  __ cmp_and_br_short(O2, G0, Assembler::notEqual, Assembler::pt, not_already_dirty);
 
   // We didn't take the branch, so we're already dirty: return.
   // Use return-from-leaf
@@ -4587,8 +4531,13 @@
 
   // Not dirty.
   __ bind(not_already_dirty);
+
+  // Get O0 + O1 into a reg by itself
+  __ add(O0, O1, O3);
+
   // First, dirty it.
   __ stb(G0, O3, G0);  // [cardPtr] := 0  (i.e., dirty).
+
   int dirty_card_q_index_byte_offset =
     in_bytes(JavaThread::dirty_card_queue_offset() +
              PtrQueue::byte_offset_of_index());
@@ -4596,12 +4545,15 @@
     in_bytes(JavaThread::dirty_card_queue_offset() +
              PtrQueue::byte_offset_of_buf());
   __ bind(restart);
+
+  // Load the index into the update buffer. PtrQueue::_index is
+  // a size_t so ld_ptr is appropriate here.
   __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, L0);
 
-  __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pn,
-                      L0, refill);
-  // If the branch is taken, no harm in executing this in the delay slot.
-  __ delayed()->ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, L1);
+  // index == 0?
+  __ cmp_and_brx_short(L0, G0, Assembler::equal, Assembler::pn, refill);
+
+  __ ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, L1);
   __ sub(L0, oopSize, L0);
 
   __ st_ptr(O3, L1, L0);  // [_buf + index] := I0
@@ -4664,6 +4616,7 @@
   G1SATBCardTableModRefBS* bs = (G1SATBCardTableModRefBS*) Universe::heap()->barrier_set();
   assert(bs->kind() == BarrierSet::G1SATBCT ||
          bs->kind() == BarrierSet::G1SATBCTLogging, "wrong barrier");
+
   if (G1RSBarrierRegionFilter) {
     xor3(store_addr, new_val, tmp);
 #ifdef _LP64
@@ -4672,33 +4625,8 @@
     srl(tmp, HeapRegion::LogOfHRGrainBytes, tmp);
 #endif
 
-    if (G1PrintCTFilterStats) {
-      guarantee(tmp->is_global(), "Or stats won't work...");
-      // This is a sleazy hack: I'm temporarily hijacking G2, which I
-      // promise to restore.
-      mov(new_val, G2);
-      save_frame(0);
-      mov(tmp, O0);
-      mov(G2, O1);
-      // Save G-regs that target may use.
-      mov(G1, L1);
-      mov(G2, L2);
-      mov(G3, L3);
-      mov(G4, L4);
-      mov(G5, L5);
-      call(CAST_FROM_FN_PTR(address, &count_ct_writes));
-      delayed()->nop();
-      mov(O0, G2);
-      // Restore G-regs that target may have used.
-      mov(L1, G1);
-      mov(L3, G3);
-      mov(L4, G4);
-      mov(L5, G5);
-      restore(G0, G0, G0);
-    }
-    // XXX Should I predict this taken or not?  Does it mattern?
-    br_on_reg_cond(rc_z, /*annul*/false, Assembler::pt, tmp, filtered);
-    delayed()->nop();
+    // XXX Should I predict this taken or not?  Does it matter?
+    cmp_and_brx_short(tmp, G0, Assembler::equal, Assembler::pt, filtered);
   }
 
   // If the "store_addr" register is an "in" or "local" register, move it to
@@ -4723,7 +4651,6 @@
   restore();
 
   bind(filtered);
-
 }
 
 #endif  // SERIALGC
@@ -4973,3 +4900,64 @@
   // Caller should set it:
   // add(G0, 1, result); // equals
 }
+
+// Use BIS for zeroing (count is in bytes).
+void MacroAssembler::bis_zeroing(Register to, Register count, Register temp, Label& Ldone) {
+  assert(UseBlockZeroing && VM_Version::has_block_zeroing(), "only works with BIS zeroing");
+  Register end = count;
+  int cache_line_size = VM_Version::prefetch_data_size();
+  // Minimum count when BIS zeroing can be used since
+  // it needs membar which is expensive.
+  int block_zero_size  = MAX2(cache_line_size*3, (int)BlockZeroingLowLimit);
+
+  Label small_loop;
+  // Check if count is negative (dead code) or zero.
+  // Note, count uses 64bit in 64 bit VM.
+  cmp_and_brx_short(count, 0, Assembler::lessEqual, Assembler::pn, Ldone);
+
+  // Use BIS zeroing only for big arrays since it requires membar.
+  if (Assembler::is_simm13(block_zero_size)) { // < 4096
+    cmp(count, block_zero_size);
+  } else {
+    set(block_zero_size, temp);
+    cmp(count, temp);
+  }
+  br(Assembler::lessUnsigned, false, Assembler::pt, small_loop);
+  delayed()->add(to, count, end);
+
+  // Note: size is >= three (32 bytes) cache lines.
+
+  // Clean the beginning of space up to next cache line.
+  for (int offs = 0; offs < cache_line_size; offs += 8) {
+    stx(G0, to, offs);
+  }
+
+  // align to next cache line
+  add(to, cache_line_size, to);
+  and3(to, -cache_line_size, to);
+
+  // Note: size left >= two (32 bytes) cache lines.
+
+  // BIS should not be used to zero tail (64 bytes)
+  // to avoid zeroing a header of the following object.
+  sub(end, (cache_line_size*2)-8, end);
+
+  Label bis_loop;
+  bind(bis_loop);
+  stxa(G0, to, G0, Assembler::ASI_ST_BLKINIT_PRIMARY);
+  add(to, cache_line_size, to);
+  cmp_and_brx_short(to, end, Assembler::lessUnsigned, Assembler::pt, bis_loop);
+
+  // BIS needs membar.
+  membar(Assembler::StoreLoad);
+
+  add(end, (cache_line_size*2)-8, end); // restore end
+  cmp_and_brx_short(to, end, Assembler::greaterEqualUnsigned, Assembler::pn, Ldone);
+
+  // Clean the tail.
+  bind(small_loop);
+  stx(G0, to, 0);
+  add(to, 8, to);
+  cmp_and_brx_short(to, end, Assembler::lessUnsigned, Assembler::pt, small_loop);
+  nop(); // Separate short branches
+}
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -885,8 +885,9 @@
   }
 
   enum ASIs { // page 72, v9
-    ASI_PRIMARY        = 0x80,
-    ASI_PRIMARY_LITTLE = 0x88,
+    ASI_PRIMARY            = 0x80,
+    ASI_PRIMARY_NOFAULT    = 0x82,
+    ASI_PRIMARY_LITTLE     = 0x88,
     // Block initializing store
     ASI_ST_BLKINIT_PRIMARY = 0xE2,
     // Most-Recently-Used (MRU) BIS variant
@@ -1786,9 +1787,12 @@
                                                                            rs1(s) |
                                                                            op3(wrreg_op3) |
                                                                            u_field(2, 29, 25) |
-                                                                           u_field(1, 13, 13) |
+                                                                           immed(true) |
                                                                            simm(simm13a, 13)); }
-  inline void wrasi(  Register d) { v9_only(); emit_long( op(arith_op) | rs1(d) | op3(wrreg_op3) | u_field(3, 29, 25)); }
+  inline void wrasi(Register d) { v9_only(); emit_long( op(arith_op) | rs1(d) | op3(wrreg_op3) | u_field(3, 29, 25)); }
+  // wrasi(d, imm) stores (d xor imm) to asi
+  inline void wrasi(Register d, int simm13a) { v9_only(); emit_long( op(arith_op) | rs1(d) | op3(wrreg_op3) |
+                                               u_field(3, 29, 25) | immed(true) | simm(simm13a, 13)); }
   inline void wrfprs( Register d) { v9_only(); emit_long( op(arith_op) | rs1(d) | op3(wrreg_op3) | u_field(6, 29, 25)); }
 
 
@@ -1940,12 +1944,6 @@
   void br_null   ( Register s1, bool a, Predict p, Label& L );
   void br_notnull( Register s1, bool a, Predict p, Label& L );
 
-  // These versions will do the most efficient thing on v8 and v9.  Perhaps
-  // this is what the routine above was meant to do, but it didn't (and
-  // didn't cover both target address kinds.)
-  void br_on_reg_cond( RCondition c, bool a, Predict p, Register s1, address d, relocInfo::relocType rt = relocInfo::none );
-  void br_on_reg_cond( RCondition c, bool a, Predict p, Register s1, Label& L);
-
   //
   // Compare registers and branch with nop in delay slot or cbcond without delay slot.
   //
@@ -2631,6 +2629,8 @@
   void char_arrays_equals(Register ary1, Register ary2,
                           Register limit, Register result,
                           Register chr1, Register chr2, Label& Ldone);
+  // Use BIS for zeroing
+  void bis_zeroing(Register to, Register count, Register temp, Label& Ldone);
 
 #undef VIRTUAL
 
--- a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -421,8 +421,7 @@
   }
 
   if (__ is_in_wdisp16_range(_continuation)) {
-    __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pt,
-                      pre_val_reg, _continuation);
+    __ br_null(pre_val_reg, /*annul*/false, Assembler::pt, _continuation);
   } else {
     __ cmp(pre_val_reg, G0);
     __ brx(Assembler::equal, false, Assembler::pn, _continuation);
@@ -458,8 +457,7 @@
     // The original src operand was not a constant.
     // Generate src == null?
     if (__ is_in_wdisp16_range(_continuation)) {
-      __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pt,
-                        src_reg, _continuation);
+      __ br_null(src_reg, /*annul*/false, Assembler::pt, _continuation);
     } else {
       __ cmp(src_reg, G0);
       __ brx(Assembler::equal, false, Assembler::pt, _continuation);
@@ -476,13 +474,9 @@
   Address ref_type_adr(tmp_reg, instanceKlass::reference_type_offset_in_bytes() + sizeof(oopDesc));
   __ ld(ref_type_adr, tmp_reg);
 
-  if (__ is_in_wdisp16_range(_continuation)) {
-    __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pt,
-                      tmp_reg, _continuation);
-  } else {
-    __ cmp(tmp_reg, G0);
-    __ brx(Assembler::equal, false, Assembler::pt, _continuation);
-  }
+  // _reference_type field is of type ReferenceType (enum)
+  assert(REF_NONE == 0, "check this code");
+  __ cmp_zero_and_br(Assembler::equal, tmp_reg, _continuation, /*annul*/false, Assembler::pt);
   __ delayed()->nop();
 
   // Is marking active?
@@ -498,13 +492,8 @@
     assert(in_bytes(PtrQueue::byte_width_of_active()) == 1, "Assumption");
     __ ldsb(in_progress, tmp_reg);
   }
-  if (__ is_in_wdisp16_range(_continuation)) {
-    __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pt,
-                      tmp_reg, _continuation);
-  } else {
-    __ cmp(tmp_reg, G0);
-    __ brx(Assembler::equal, false, Assembler::pt, _continuation);
-  }
+
+  __ cmp_zero_and_br(Assembler::equal, tmp_reg, _continuation, /*annul*/false, Assembler::pt);
   __ delayed()->nop();
 
   // val == null?
@@ -512,8 +501,7 @@
   Register val_reg = val()->as_register();
 
   if (__ is_in_wdisp16_range(_continuation)) {
-    __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pt,
-                      val_reg, _continuation);
+    __ br_null(val_reg, /*annul*/false, Assembler::pt, _continuation);
   } else {
     __ cmp(val_reg, G0);
     __ brx(Assembler::equal, false, Assembler::pt, _continuation);
@@ -542,9 +530,9 @@
   assert(new_val()->is_register(), "Precondition.");
   Register addr_reg = addr()->as_pointer_register();
   Register new_val_reg = new_val()->as_register();
+
   if (__ is_in_wdisp16_range(_continuation)) {
-    __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pt,
-                      new_val_reg, _continuation);
+    __ br_null(new_val_reg, /*annul*/false, Assembler::pt, _continuation);
   } else {
     __ cmp(new_val_reg, G0);
     __ brx(Assembler::equal, false, Assembler::pn, _continuation);
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -142,11 +142,6 @@
 }
 
 
-LIR_Opr LIR_Assembler::incomingReceiverOpr() {
-  return FrameMap::I0_oop_opr;
-}
-
-
 LIR_Opr LIR_Assembler::osrBufferPointer() {
   return FrameMap::I0_opr;
 }
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -328,7 +328,8 @@
   bool use_length = x->length() != NULL;
   bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT;
   bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
-                                         !get_jobject_constant(x->value())->is_null_object());
+                                         !get_jobject_constant(x->value())->is_null_object() ||
+                                         x->should_profile());
 
   LIRItem array(x->array(), this);
   LIRItem index(x->index(), this);
@@ -382,7 +383,7 @@
     LIR_Opr tmp3 = FrameMap::G5_opr;
 
     CodeEmitInfo* store_check_info = new CodeEmitInfo(range_check_info);
-    __ store_check(value.result(), array.result(), tmp1, tmp2, tmp3, store_check_info);
+    __ store_check(value.result(), array.result(), tmp1, tmp2, tmp3, store_check_info, x->profiled_method(), x->profiled_bci());
   }
 
   if (obj_store) {
--- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -782,13 +782,6 @@
       }
       break;
 
-    case jvmti_exception_throw_id:
-      { // Oexception : exception
-        __ set_info("jvmti_exception_throw", dont_gc_arguments);
-        oop_maps = generate_stub_call(sasm, noreg, CAST_FROM_FN_PTR(address, Runtime1::post_jvmti_exception_throw), I0);
-      }
-      break;
-
     case dtrace_object_alloc_id:
       { // O0: object
         __ set_info("dtrace_object_alloc", dont_gc_arguments);
@@ -834,14 +827,16 @@
         int satb_q_buf_byte_offset =
           in_bytes(JavaThread::satb_mark_queue_offset() +
                    PtrQueue::byte_offset_of_buf());
+
         __ bind(restart);
+        // Load the index into the SATB buffer. PtrQueue::_index is a
+        // size_t so ld_ptr is appropriate
         __ ld_ptr(G2_thread, satb_q_index_byte_offset, tmp);
 
-        __ br_on_reg_cond(Assembler::rc_z, /*annul*/false,
-                          Assembler::pn, tmp, refill);
+        // index == 0?
+        __ cmp_and_brx_short(tmp, G0, Assembler::equal, Assembler::pn, refill);
 
-        // If the branch is taken, no harm in executing this in the delay slot.
-        __ delayed()->ld_ptr(G2_thread, satb_q_buf_byte_offset, tmp2);
+        __ ld_ptr(G2_thread, satb_q_buf_byte_offset, tmp2);
         __ sub(tmp, oopSize, tmp);
 
         __ st_ptr(pre_val, tmp2, tmp);  // [_buf + index] := <address_of_card>
@@ -901,11 +896,8 @@
         __ set(rs, cardtable);         // cardtable := <card table base>
         __ ldub(addr, cardtable, tmp); // tmp := [addr + cardtable]
 
-        __ br_on_reg_cond(Assembler::rc_nz, /*annul*/false, Assembler::pt,
-                          tmp, not_already_dirty);
-        // Get cardtable + tmp into a reg by itself -- useful in the take-the-branch
-        // case, harmless if not.
-        __ delayed()->add(addr, cardtable, tmp2);
+        assert(CardTableModRefBS::dirty_card_val() == 0, "otherwise check this code");
+        __ cmp_and_br_short(tmp, G0, Assembler::notEqual, Assembler::pt, not_already_dirty);
 
         // We didn't take the branch, so we're already dirty: return.
         // Use return-from-leaf
@@ -914,6 +906,10 @@
 
         // Not dirty.
         __ bind(not_already_dirty);
+
+        // Get cardtable + tmp into a reg by itself
+        __ add(addr, cardtable, tmp2);
+
         // First, dirty it.
         __ stb(G0, tmp2, 0);  // [cardPtr] := 0  (i.e., dirty).
 
@@ -929,13 +925,17 @@
         int dirty_card_q_buf_byte_offset =
           in_bytes(JavaThread::dirty_card_queue_offset() +
                    PtrQueue::byte_offset_of_buf());
+
         __ bind(restart);
+
+        // Get the index into the update buffer. PtrQueue::_index is
+        // a size_t so ld_ptr is appropriate here.
         __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, tmp3);
 
-        __ br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pn,
-                          tmp3, refill);
-        // If the branch is taken, no harm in executing this in the delay slot.
-        __ delayed()->ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, tmp4);
+        // index == 0?
+        __ cmp_and_brx_short(tmp3, G0, Assembler::equal,  Assembler::pn, refill);
+
+        __ ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, tmp4);
         __ sub(tmp3, oopSize, tmp3);
 
         __ st_ptr(tmp2, tmp4, tmp3);  // [_buf + index] := <address_of_card>
--- a/hotspot/src/cpu/sparc/vm/copy_sparc.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/copy_sparc.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,13 +82,35 @@
 }
 
 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
-  // FIXME
-  (void)memmove(to, from, count << LogBytesPerShort);
+  if (from > to) {
+    while (count-- > 0) {
+      // Copy forwards
+      *to++ = *from++;
+    }
+  } else {
+    from += count - 1;
+    to   += count - 1;
+    while (count-- > 0) {
+      // Copy backwards
+      *to-- = *from--;
+    }
+  }
 }
 
 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
-  // FIXME
-  (void)memmove(to, from, count << LogBytesPerInt);
+  if (from > to) {
+    while (count-- > 0) {
+      // Copy forwards
+      *to++ = *from++;
+    }
+  } else {
+    from += count - 1;
+    to   += count - 1;
+    while (count-- > 0) {
+      // Copy backwards
+      *to-- = *from--;
+    }
+  }
 }
 
 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
@@ -156,9 +178,16 @@
 #endif // _LP64
 }
 
+typedef void (*_zero_Fn)(HeapWord* to, size_t count);
+
 static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) {
   assert(MinObjAlignmentInBytes >= BytesPerLong, "need alternate implementation");
 
+  if (value == 0 && UseBlockZeroing &&
+      (count > (BlockZeroingLowLimit >> LogHeapWordSize))) {
+   // Call it only when block zeroing is used
+   ((_zero_Fn)StubRoutines::zero_aligned_words())(tohw, count);
+  } else {
    julong* to = (julong*)tohw;
    julong  v  = ((julong)value << 32) | value;
    // If count is odd, odd will be equal to 1 on 32-bit platform
@@ -176,6 +205,7 @@
      *((juint*)to) = value;
 
    }
+  }
 }
 
 static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {
--- a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -839,3 +839,9 @@
 }
 
 #endif
+
+intptr_t *frame::initial_deoptimization_info() {
+  // unused... but returns fp() to minimize changes introduced by 7087445
+  return fp();
+}
+
--- a/hotspot/src/cpu/sparc/vm/frame_sparc.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/frame_sparc.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -259,13 +259,8 @@
   };
 #endif /* CC_INTERP */
 
-  // the compiler frame has many of the same fields as the interpreter frame
-  // %%%%% factor out declarations of the shared fields
   enum compiler_frame_fixed_locals {
-       compiler_frame_d_scratch_fp_offset          = -2,
-       compiler_frame_vm_locals_fp_offset          = -2, // should be same as above
-
-       compiler_frame_vm_local_words = -compiler_frame_vm_locals_fp_offset
+       compiler_frame_vm_locals_fp_offset          = -2
   };
 
  private:
@@ -283,9 +278,6 @@
 
   inline void interpreter_frame_set_tos_address(intptr_t* x);
 
-
-  // %%%%% Another idea: instead of defining 3 fns per item, just define one returning a ref
-
   // monitors:
 
   // next two fns read and write Lmonitors value,
@@ -298,22 +290,8 @@
     return ((interpreterState)sp_at(interpreter_state_ptr_offset));
   }
 
-
 #endif /* CC_INTERP */
 
-
-
- // Compiled frames
-
  public:
-  // Tells if this register can hold 64 bits on V9 (really, V8+).
-  static bool holds_a_doubleword(Register reg) {
-#ifdef _LP64
-    //    return true;
-    return reg->is_out() || reg->is_global();
-#else
-    return reg->is_out() || reg->is_global();
-#endif
-  }
 
 #endif // CPU_SPARC_VM_FRAME_SPARC_HPP
--- a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1262,6 +1262,15 @@
     }
     break;
 
+  case _adapter_opt_profiling:
+    if (java_lang_invoke_CountingMethodHandle::vmcount_offset_in_bytes() != 0) {
+      Address G3_mh_vmcount(G3_method_handle, java_lang_invoke_CountingMethodHandle::vmcount_offset_in_bytes());
+      __ ld(G3_mh_vmcount, O1_scratch);
+      __ add(O1_scratch, 1, O1_scratch);
+      __ st(O1_scratch, G3_mh_vmcount);
+    }
+    // fall through
+
   case _adapter_retype_only:
   case _adapter_retype_raw:
     // Immediately jump to the next MH layer:
--- a/hotspot/src/cpu/sparc/vm/sparc.ad	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad	Wed Oct 26 17:59:13 2011 -0700
@@ -460,6 +460,8 @@
 // Must be visible to the DFA in dfa_sparc.cpp
 extern bool can_branch_register( Node *bol, Node *cmp );
 
+extern bool use_block_zeroing(Node* count);
+
 // Macros to extract hi & lo halves from a long pair.
 // G0 is not part of any long pair, so assert on that.
 // Prevents accidentally using G1 instead of G0.
@@ -521,6 +523,12 @@
   return false;
 }
 
+bool use_block_zeroing(Node* count) {
+  // Use BIS for zeroing if count is not constant
+  // or it is >= BlockZeroingLowLimit.
+  return UseBlockZeroing && (count->find_intptr_t_con(BlockZeroingLowLimit) >= BlockZeroingLowLimit);
+}
+
 // ****************************************************************************
 
 // REQUIRED FUNCTIONALITY
@@ -832,6 +840,7 @@
           !(n->ideal_Opcode()==Op_ConvI2D   && ld_op==Op_LoadF) &&
           !(n->ideal_Opcode()==Op_PrefetchRead  && ld_op==Op_LoadI) &&
           !(n->ideal_Opcode()==Op_PrefetchWrite && ld_op==Op_LoadI) &&
+          !(n->ideal_Opcode()==Op_PrefetchAllocation && ld_op==Op_LoadI) &&
           !(n->ideal_Opcode()==Op_Load2I    && ld_op==Op_LoadD) &&
           !(n->ideal_Opcode()==Op_Load4C    && ld_op==Op_LoadD) &&
           !(n->ideal_Opcode()==Op_Load4S    && ld_op==Op_LoadD) &&
@@ -2810,25 +2819,6 @@
     __ float_cmp( $primary, -1, Fsrc1, Fsrc2, Rdst);
   %}
 
-  // Compiler ensures base is doubleword aligned and cnt is count of doublewords
-  enc_class enc_Clear_Array(iRegX cnt, iRegP base, iRegX temp) %{
-    MacroAssembler _masm(&cbuf);
-    Register    nof_bytes_arg   = reg_to_register_object($cnt$$reg);
-    Register    nof_bytes_tmp    = reg_to_register_object($temp$$reg);
-    Register    base_pointer_arg = reg_to_register_object($base$$reg);
-  
-    Label loop;
-    __ mov(nof_bytes_arg, nof_bytes_tmp);
-  
-    // Loop and clear, walking backwards through the array.
-    // nof_bytes_tmp (if >0) is always the number of bytes to zero
-    __ bind(loop);
-    __ deccc(nof_bytes_tmp, 8);
-    __ br(Assembler::greaterEqual, true, Assembler::pt, loop);
-    __ delayed()-> stx(G0, base_pointer_arg, nof_bytes_tmp);
-    // %%%% this mini-loop must not cross a cache boundary!
-  %}
-
 
   enc_class enc_String_Compare(o0RegP str1, o1RegP str2, g3RegI cnt1, g4RegI cnt2, notemp_iRegI result) %{
     Label Ldone, Lloop;
@@ -10257,9 +10247,9 @@
   ins_pipe(long_memory_op);
 %}
 
-// Count and Base registers are fixed because the allocator cannot
-// kill unknown registers.  The encodings are generic.
+// The encodings are generic.
 instruct clear_array(iRegX cnt, iRegP base, iRegX temp, Universe dummy, flagsReg ccr) %{
+  predicate(!use_block_zeroing(n->in(2)) );
   match(Set dummy (ClearArray cnt base));
   effect(TEMP temp, KILL ccr);
   ins_cost(300);
@@ -10267,7 +10257,71 @@
     "loop:   SUBcc  $temp,8,$temp\t! Count down a dword of bytes\n"
     "        BRge   loop\t\t! Clearing loop\n"
     "        STX    G0,[$base+$temp]\t! delay slot" %}
-  ins_encode( enc_Clear_Array(cnt, base, temp) );
+
+  ins_encode %{
+    // Compiler ensures base is doubleword aligned and cnt is count of doublewords
+    Register nof_bytes_arg    = $cnt$$Register;
+    Register nof_bytes_tmp    = $temp$$Register;
+    Register base_pointer_arg = $base$$Register;
+
+    Label loop;
+    __ mov(nof_bytes_arg, nof_bytes_tmp);
+
+    // Loop and clear, walking backwards through the array.
+    // nof_bytes_tmp (if >0) is always the number of bytes to zero
+    __ bind(loop);
+    __ deccc(nof_bytes_tmp, 8);
+    __ br(Assembler::greaterEqual, true, Assembler::pt, loop);
+    __ delayed()-> stx(G0, base_pointer_arg, nof_bytes_tmp);
+    // %%%% this mini-loop must not cross a cache boundary!
+  %}
+  ins_pipe(long_memory_op);
+%}
+
+instruct clear_array_bis(g1RegX cnt, o0RegP base, Universe dummy, flagsReg ccr) %{
+  predicate(use_block_zeroing(n->in(2)));
+  match(Set dummy (ClearArray cnt base));
+  effect(USE_KILL cnt, USE_KILL base, KILL ccr);
+  ins_cost(300);
+  format %{ "CLEAR  [$base, $cnt]\t! ClearArray" %}
+
+  ins_encode %{
+
+    assert(MinObjAlignmentInBytes >= BytesPerLong, "need alternate implementation");
+    Register to    = $base$$Register;
+    Register count = $cnt$$Register;
+
+    Label Ldone;
+    __ nop(); // Separate short branches
+    // Use BIS for zeroing (temp is not used).
+    __ bis_zeroing(to, count, G0, Ldone);
+    __ bind(Ldone);
+
+  %}
+  ins_pipe(long_memory_op);
+%}
+
+instruct clear_array_bis_2(g1RegX cnt, o0RegP base, iRegX tmp, Universe dummy, flagsReg ccr) %{
+  predicate(use_block_zeroing(n->in(2)) && !Assembler::is_simm13((int)BlockZeroingLowLimit));
+  match(Set dummy (ClearArray cnt base));
+  effect(TEMP tmp, USE_KILL cnt, USE_KILL base, KILL ccr);
+  ins_cost(300);
+  format %{ "CLEAR  [$base, $cnt]\t! ClearArray" %}
+
+  ins_encode %{
+
+    assert(MinObjAlignmentInBytes >= BytesPerLong, "need alternate implementation");
+    Register to    = $base$$Register;
+    Register count = $cnt$$Register;
+    Register temp  = $tmp$$Register;
+
+    Label Ldone;
+    __ nop(); // Separate short branches
+    // Use BIS for zeroing
+    __ bis_zeroing(to, count, temp, Ldone);
+    __ bind(Ldone);
+
+  %}
   ins_pipe(long_memory_op);
 %}
 
@@ -10422,7 +10476,7 @@
   ins_pipe(ialu_reg);
 %}
 
-instruct countTrailingZerosL(iRegI dst, iRegL src, flagsReg cr) %{
+instruct countTrailingZerosL(iRegIsafe dst, iRegL src, flagsReg cr) %{
   predicate(UsePopCountInstruction);  // See Matcher::match_rule_supported
   match(Set dst (CountTrailingZerosL src));
   effect(TEMP dst, KILL cr);
--- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -436,7 +436,7 @@
 #undef __
 #define __ masm->
 
-  address generate_throw_exception(const char* name, address runtime_entry, bool restore_saved_exception_pc,
+  address generate_throw_exception(const char* name, address runtime_entry,
                                    Register arg1 = noreg, Register arg2 = noreg) {
 #ifdef ASSERT
     int insts_size = VerifyThread ? 1 * K : 600;
@@ -462,11 +462,6 @@
 
     int frame_complete = __ offset();
 
-    if (restore_saved_exception_pc) {
-      __ ld_ptr(G2_thread, JavaThread::saved_exception_pc_offset(), I7);
-      __ sub(I7, frame::pc_return_offset, I7);
-    }
-
     // Note that we always have a runtime stub frame on the top of stack by this point
     Register last_java_sp = SP;
     // 64-bit last_java_sp is biased!
@@ -1124,6 +1119,126 @@
     }
   }
 
+  //
+  // Generate main code for disjoint arraycopy
+  //
+  typedef void (StubGenerator::*CopyLoopFunc)(Register from, Register to, Register count, int count_dec,
+                                              Label& L_loop, bool use_prefetch, bool use_bis);
+
+  void disjoint_copy_core(Register from, Register to, Register count, int log2_elem_size,
+                          int iter_size, CopyLoopFunc copy_loop_func) {
+    Label L_copy;
+
+    assert(log2_elem_size <= 3, "the following code should be changed");
+    int count_dec = 16>>log2_elem_size;
+
+    int prefetch_dist = MAX2(ArraycopySrcPrefetchDistance, ArraycopyDstPrefetchDistance);
+    assert(prefetch_dist < 4096, "invalid value");
+    prefetch_dist = (prefetch_dist + (iter_size-1)) & (-iter_size); // round up to one iteration copy size
+    int prefetch_count = (prefetch_dist >> log2_elem_size); // elements count
+
+    if (UseBlockCopy) {
+      Label L_block_copy, L_block_copy_prefetch, L_skip_block_copy;
+
+      // 64 bytes tail + bytes copied in one loop iteration
+      int tail_size = 64 + iter_size;
+      int block_copy_count = (MAX2(tail_size, (int)BlockCopyLowLimit)) >> log2_elem_size;
+      // Use BIS copy only for big arrays since it requires membar.
+      __ set(block_copy_count, O4);
+      __ cmp_and_br_short(count, O4, Assembler::lessUnsigned, Assembler::pt, L_skip_block_copy);
+      // This code is for disjoint source and destination:
+      //   to <= from || to >= from+count
+      // but BIS will stomp over 'from' if (to > from-tail_size && to <= from)
+      __ sub(from, to, O4);
+      __ srax(O4, 4, O4); // divide by 16 since following short branch have only 5 bits for imm.
+      __ cmp_and_br_short(O4, (tail_size>>4), Assembler::lessEqualUnsigned, Assembler::pn, L_skip_block_copy);
+
+      __ wrasi(G0, Assembler::ASI_ST_BLKINIT_PRIMARY);
+      // BIS should not be used to copy tail (64 bytes+iter_size)
+      // to avoid zeroing of following values.
+      __ sub(count, (tail_size>>log2_elem_size), count); // count is still positive >= 0
+
+      if (prefetch_count > 0) { // rounded up to one iteration count
+        // Do prefetching only if copy size is bigger
+        // than prefetch distance.
+        __ set(prefetch_count, O4);
+        __ cmp_and_brx_short(count, O4, Assembler::less, Assembler::pt, L_block_copy);
+        __ sub(count, prefetch_count, count);
+
+        (this->*copy_loop_func)(from, to, count, count_dec, L_block_copy_prefetch, true, true);
+        __ add(count, prefetch_count, count); // restore count
+
+      } // prefetch_count > 0
+
+      (this->*copy_loop_func)(from, to, count, count_dec, L_block_copy, false, true);
+      __ add(count, (tail_size>>log2_elem_size), count); // restore count
+
+      __ wrasi(G0, Assembler::ASI_PRIMARY_NOFAULT);
+      // BIS needs membar.
+      __ membar(Assembler::StoreLoad);
+      // Copy tail
+      __ ba_short(L_copy);
+
+      __ BIND(L_skip_block_copy);
+    } // UseBlockCopy
+
+    if (prefetch_count > 0) { // rounded up to one iteration count
+      // Do prefetching only if copy size is bigger
+      // than prefetch distance.
+      __ set(prefetch_count, O4);
+      __ cmp_and_brx_short(count, O4, Assembler::lessUnsigned, Assembler::pt, L_copy);
+      __ sub(count, prefetch_count, count);
+
+      Label L_copy_prefetch;
+      (this->*copy_loop_func)(from, to, count, count_dec, L_copy_prefetch, true, false);
+      __ add(count, prefetch_count, count); // restore count
+
+    } // prefetch_count > 0
+
+    (this->*copy_loop_func)(from, to, count, count_dec, L_copy, false, false);
+  }
+
+
+
+  //
+  // Helper methods for copy_16_bytes_forward_with_shift()
+  //
+  void copy_16_bytes_shift_loop(Register from, Register to, Register count, int count_dec,
+                                Label& L_loop, bool use_prefetch, bool use_bis) {
+
+    const Register left_shift  = G1; // left  shift bit counter
+    const Register right_shift = G5; // right shift bit counter
+
+    __ align(OptoLoopAlignment);
+    __ BIND(L_loop);
+    if (use_prefetch) {
+      if (ArraycopySrcPrefetchDistance > 0) {
+        __ prefetch(from, ArraycopySrcPrefetchDistance, Assembler::severalReads);
+      }
+      if (ArraycopyDstPrefetchDistance > 0) {
+        __ prefetch(to, ArraycopyDstPrefetchDistance, Assembler::severalWritesAndPossiblyReads);
+      }
+    }
+    __ ldx(from, 0, O4);
+    __ ldx(from, 8, G4);
+    __ inc(to, 16);
+    __ inc(from, 16);
+    __ deccc(count, count_dec); // Can we do next iteration after this one?
+    __ srlx(O4, right_shift, G3);
+    __ bset(G3, O3);
+    __ sllx(O4, left_shift,  O4);
+    __ srlx(G4, right_shift, G3);
+    __ bset(G3, O4);
+    if (use_bis) {
+      __ stxa(O3, to, -16);
+      __ stxa(O4, to, -8);
+    } else {
+      __ stx(O3, to, -16);
+      __ stx(O4, to, -8);
+    }
+    __ brx(Assembler::greaterEqual, false, Assembler::pt, L_loop);
+    __ delayed()->sllx(G4, left_shift,  O3);
+  }
 
   // Copy big chunks forward with shift
   //
@@ -1135,64 +1250,51 @@
   //   L_copy_bytes - copy exit label
   //
   void copy_16_bytes_forward_with_shift(Register from, Register to,
-                     Register count, int count_dec, Label& L_copy_bytes) {
-    Label L_loop, L_aligned_copy, L_copy_last_bytes;
+                     Register count, int log2_elem_size, Label& L_copy_bytes) {
+    Label L_aligned_copy, L_copy_last_bytes;
+    assert(log2_elem_size <= 3, "the following code should be changed");
+    int count_dec = 16>>log2_elem_size;
 
     // if both arrays have the same alignment mod 8, do 8 bytes aligned copy
-      __ andcc(from, 7, G1); // misaligned bytes
-      __ br(Assembler::zero, false, Assembler::pt, L_aligned_copy);
-      __ delayed()->nop();
+    __ andcc(from, 7, G1); // misaligned bytes
+    __ br(Assembler::zero, false, Assembler::pt, L_aligned_copy);
+    __ delayed()->nop();
 
     const Register left_shift  = G1; // left  shift bit counter
     const Register right_shift = G5; // right shift bit counter
 
-      __ sll(G1, LogBitsPerByte, left_shift);
-      __ mov(64, right_shift);
-      __ sub(right_shift, left_shift, right_shift);
+    __ sll(G1, LogBitsPerByte, left_shift);
+    __ mov(64, right_shift);
+    __ sub(right_shift, left_shift, right_shift);
 
     //
     // Load 2 aligned 8-bytes chunks and use one from previous iteration
     // to form 2 aligned 8-bytes chunks to store.
     //
-      __ deccc(count, count_dec); // Pre-decrement 'count'
-      __ andn(from, 7, from);     // Align address
-      __ ldx(from, 0, O3);
-      __ inc(from, 8);
-      __ align(OptoLoopAlignment);
-    __ BIND(L_loop);
-      __ ldx(from, 0, O4);
-      __ deccc(count, count_dec); // Can we do next iteration after this one?
-      __ ldx(from, 8, G4);
-      __ inc(to, 16);
-      __ inc(from, 16);
-      __ sllx(O3, left_shift,  O3);
-      __ srlx(O4, right_shift, G3);
-      __ bset(G3, O3);
-      __ stx(O3, to, -16);
-      __ sllx(O4, left_shift,  O4);
-      __ srlx(G4, right_shift, G3);
-      __ bset(G3, O4);
-      __ stx(O4, to, -8);
-      __ brx(Assembler::greaterEqual, false, Assembler::pt, L_loop);
-      __ delayed()->mov(G4, O3);
-
-      __ inccc(count, count_dec>>1 ); // + 8 bytes
-      __ brx(Assembler::negative, true, Assembler::pn, L_copy_last_bytes);
-      __ delayed()->inc(count, count_dec>>1); // restore 'count'
-
-      // copy 8 bytes, part of them already loaded in O3
-      __ ldx(from, 0, O4);
-      __ inc(to, 8);
-      __ inc(from, 8);
-      __ sllx(O3, left_shift,  O3);
-      __ srlx(O4, right_shift, G3);
-      __ bset(O3, G3);
-      __ stx(G3, to, -8);
+    __ dec(count, count_dec);   // Pre-decrement 'count'
+    __ andn(from, 7, from);     // Align address
+    __ ldx(from, 0, O3);
+    __ inc(from, 8);
+    __ sllx(O3, left_shift,  O3);
+
+    disjoint_copy_core(from, to, count, log2_elem_size, 16, copy_16_bytes_shift_loop);
+
+    __ inccc(count, count_dec>>1 ); // + 8 bytes
+    __ brx(Assembler::negative, true, Assembler::pn, L_copy_last_bytes);
+    __ delayed()->inc(count, count_dec>>1); // restore 'count'
+
+    // copy 8 bytes, part of them already loaded in O3
+    __ ldx(from, 0, O4);
+    __ inc(to, 8);
+    __ inc(from, 8);
+    __ srlx(O4, right_shift, G3);
+    __ bset(O3, G3);
+    __ stx(G3, to, -8);
 
     __ BIND(L_copy_last_bytes);
-      __ srl(right_shift, LogBitsPerByte, right_shift); // misaligned bytes
-      __ br(Assembler::always, false, Assembler::pt, L_copy_bytes);
-      __ delayed()->sub(from, right_shift, from);       // restore address
+    __ srl(right_shift, LogBitsPerByte, right_shift); // misaligned bytes
+    __ br(Assembler::always, false, Assembler::pt, L_copy_bytes);
+    __ delayed()->sub(from, right_shift, from);       // restore address
 
     __ BIND(L_aligned_copy);
   }
@@ -1348,7 +1450,7 @@
       // The compare above (count >= 23) guarantes 'count' >= 16 bytes.
       // Also jump over aligned copy after the copy with shift completed.
 
-      copy_16_bytes_forward_with_shift(from, to, count, 16, L_copy_byte);
+      copy_16_bytes_forward_with_shift(from, to, count, 0, L_copy_byte);
     }
 
     // Both array are 8 bytes aligned, copy 16 bytes at a time
@@ -1576,7 +1678,7 @@
       // The compare above (count >= 11) guarantes 'count' >= 16 bytes.
       // Also jump over aligned copy after the copy with shift completed.
 
-      copy_16_bytes_forward_with_shift(from, to, count, 8, L_copy_2_bytes);
+      copy_16_bytes_forward_with_shift(from, to, count, 1, L_copy_2_bytes);
     }
 
     // Both array are 8 bytes aligned, copy 16 bytes at a time
@@ -1950,6 +2052,45 @@
   }
 
   //
+  // Helper methods for generate_disjoint_int_copy_core()
+  //
+  void copy_16_bytes_loop(Register from, Register to, Register count, int count_dec,
+                          Label& L_loop, bool use_prefetch, bool use_bis) {
+
+    __ align(OptoLoopAlignment);
+    __ BIND(L_loop);
+    if (use_prefetch) {
+      if (ArraycopySrcPrefetchDistance > 0) {
+        __ prefetch(from, ArraycopySrcPrefetchDistance, Assembler::severalReads);
+      }
+      if (ArraycopyDstPrefetchDistance > 0) {
+        __ prefetch(to, ArraycopyDstPrefetchDistance, Assembler::severalWritesAndPossiblyReads);
+      }
+    }
+    __ ldx(from, 4, O4);
+    __ ldx(from, 12, G4);
+    __ inc(to, 16);
+    __ inc(from, 16);
+    __ deccc(count, 4); // Can we do next iteration after this one?
+
+    __ srlx(O4, 32, G3);
+    __ bset(G3, O3);
+    __ sllx(O4, 32, O4);
+    __ srlx(G4, 32, G3);
+    __ bset(G3, O4);
+    if (use_bis) {
+      __ stxa(O3, to, -16);
+      __ stxa(O4, to, -8);
+    } else {
+      __ stx(O3, to, -16);
+      __ stx(O4, to, -8);
+    }
+    __ brx(Assembler::greaterEqual, false, Assembler::pt, L_loop);
+    __ delayed()->sllx(G4, 32,  O3);
+
+  }
+
+  //
   //  Generate core code for disjoint int copy (and oop copy on 32-bit).
   //  If "aligned" is true, the "from" and "to" addresses are assumed
   //  to be heapword aligned.
@@ -1962,7 +2103,7 @@
   void generate_disjoint_int_copy_core(bool aligned) {
 
     Label L_skip_alignment, L_aligned_copy;
-    Label L_copy_16_bytes,  L_copy_4_bytes, L_copy_4_bytes_loop, L_exit;
+    Label L_copy_4_bytes, L_copy_4_bytes_loop, L_exit;
 
     const Register from      = O0;   // source array address
     const Register to        = O1;   // destination array address
@@ -2013,30 +2154,16 @@
 
     // copy with shift 4 elements (16 bytes) at a time
       __ dec(count, 4);   // The cmp at the beginning guaranty count >= 4
-
-      __ align(OptoLoopAlignment);
-    __ BIND(L_copy_16_bytes);
-      __ ldx(from, 4, O4);
-      __ deccc(count, 4); // Can we do next iteration after this one?
-      __ ldx(from, 12, G4);
-      __ inc(to, 16);
-      __ inc(from, 16);
-      __ sllx(O3, 32, O3);
-      __ srlx(O4, 32, G3);
-      __ bset(G3, O3);
-      __ stx(O3, to, -16);
-      __ sllx(O4, 32, O4);
-      __ srlx(G4, 32, G3);
-      __ bset(G3, O4);
-      __ stx(O4, to, -8);
-      __ brx(Assembler::greaterEqual, false, Assembler::pt, L_copy_16_bytes);
-      __ delayed()->mov(G4, O3);
+      __ sllx(O3, 32,  O3);
+
+      disjoint_copy_core(from, to, count, 2, 16, copy_16_bytes_loop);
 
       __ br(Assembler::always, false, Assembler::pt, L_copy_4_bytes);
       __ delayed()->inc(count, 4); // restore 'count'
 
     __ BIND(L_aligned_copy);
-    }
+    } // !aligned
+
     // copy 4 elements (16 bytes) at a time
       __ and3(count, 1, G4); // Save
       __ srl(count, 1, count);
@@ -2223,6 +2350,38 @@
   }
 
   //
+  // Helper methods for generate_disjoint_long_copy_core()
+  //
+  void copy_64_bytes_loop(Register from, Register to, Register count, int count_dec,
+                          Label& L_loop, bool use_prefetch, bool use_bis) {
+    __ align(OptoLoopAlignment);
+    __ BIND(L_loop);
+    for (int off = 0; off < 64; off += 16) {
+      if (use_prefetch && (off & 31) == 0) {
+        if (ArraycopySrcPrefetchDistance > 0) {
+          __ prefetch(from, ArraycopySrcPrefetchDistance+off, Assembler::severalReads);
+        }
+        if (ArraycopyDstPrefetchDistance > 0) {
+          __ prefetch(to, ArraycopyDstPrefetchDistance+off, Assembler::severalWritesAndPossiblyReads);
+        }
+      }
+      __ ldx(from,  off+0, O4);
+      __ ldx(from,  off+8, O5);
+      if (use_bis) {
+        __ stxa(O4, to,  off+0);
+        __ stxa(O5, to,  off+8);
+      } else {
+        __ stx(O4, to,  off+0);
+        __ stx(O5, to,  off+8);
+      }
+    }
+    __ deccc(count, 8);
+    __ inc(from, 64);
+    __ brx(Assembler::greaterEqual, false, Assembler::pt, L_loop);
+    __ delayed()->inc(to, 64);
+  }
+
+  //
   //  Generate core code for disjoint long copy (and oop copy on 64-bit).
   //  "aligned" is ignored, because we must make the stronger
   //  assumption that both addresses are always 64-bit aligned.
@@ -2261,38 +2420,28 @@
     const Register offset0 = O4;  // element offset
     const Register offset8 = O5;  // next element offset
 
-      __ deccc(count, 2);
-      __ mov(G0, offset0);   // offset from start of arrays (0)
-      __ brx(Assembler::negative, false, Assembler::pn, L_copy_8_bytes );
-      __ delayed()->add(offset0, 8, offset8);
+    __ deccc(count, 2);
+    __ mov(G0, offset0);   // offset from start of arrays (0)
+    __ brx(Assembler::negative, false, Assembler::pn, L_copy_8_bytes );
+    __ delayed()->add(offset0, 8, offset8);
 
     // Copy by 64 bytes chunks
-    Label L_copy_64_bytes;
+
     const Register from64 = O3;  // source address
     const Register to64   = G3;  // destination address
-      __ subcc(count, 6, O3);
-      __ brx(Assembler::negative, false, Assembler::pt, L_copy_16_bytes );
-      __ delayed()->mov(to,   to64);
-      // Now we can use O4(offset0), O5(offset8) as temps
-      __ mov(O3, count);
-      __ mov(from, from64);
-
-      __ align(OptoLoopAlignment);
-    __ BIND(L_copy_64_bytes);
-      for( int off = 0; off < 64; off += 16 ) {
-        __ ldx(from64,  off+0, O4);
-        __ ldx(from64,  off+8, O5);
-        __ stx(O4, to64,  off+0);
-        __ stx(O5, to64,  off+8);
-      }
-      __ deccc(count, 8);
-      __ inc(from64, 64);
-      __ brx(Assembler::greaterEqual, false, Assembler::pt, L_copy_64_bytes);
-      __ delayed()->inc(to64, 64);
+    __ subcc(count, 6, O3);
+    __ brx(Assembler::negative, false, Assembler::pt, L_copy_16_bytes );
+    __ delayed()->mov(to,   to64);
+    // Now we can use O4(offset0), O5(offset8) as temps
+    __ mov(O3, count);
+    // count >= 0 (original count - 8)
+    __ mov(from, from64);
+
+    disjoint_copy_core(from64, to64, count, 3, 64, copy_64_bytes_loop);
 
       // Restore O4(offset0), O5(offset8)
       __ sub(from64, from, offset0);
-      __ inccc(count, 6);
+      __ inccc(count, 6); // restore count
       __ brx(Assembler::negative, false, Assembler::pn, L_copy_8_bytes );
       __ delayed()->add(offset0, 8, offset8);
 
@@ -3069,6 +3218,34 @@
     return start;
   }
 
+  //
+  //  Generate stub for heap zeroing.
+  //  "to" address is aligned to jlong (8 bytes).
+  //
+  // Arguments for generated stub:
+  //      to:    O0
+  //      count: O1 treated as signed (count of HeapWord)
+  //             count could be 0
+  //
+  address generate_zero_aligned_words(const char* name) {
+    __ align(CodeEntryAlignment);
+    StubCodeMark mark(this, "StubRoutines", name);
+    address start = __ pc();
+
+    const Register to    = O0;   // source array address
+    const Register count = O1;   // HeapWords count
+    const Register temp  = O2;   // scratch
+
+    Label Ldone;
+    __ sllx(count, LogHeapWordSize, count); // to bytes count
+    // Use BIS for zeroing
+    __ bis_zeroing(to, count, temp, Ldone);
+    __ bind(Ldone);
+    __ retl();
+    __ delayed()->nop();
+    return start;
+}
+
   void generate_arraycopy_stubs() {
     address entry;
     address entry_jbyte_arraycopy;
@@ -3195,6 +3372,10 @@
     StubRoutines::_arrayof_jbyte_fill = generate_fill(T_BYTE, true, "arrayof_jbyte_fill");
     StubRoutines::_arrayof_jshort_fill = generate_fill(T_SHORT, true, "arrayof_jshort_fill");
     StubRoutines::_arrayof_jint_fill = generate_fill(T_INT, true, "arrayof_jint_fill");
+
+    if (UseBlockZeroing) {
+      StubRoutines::_zero_aligned_words = generate_zero_aligned_words("zero_aligned_words");
+    }
   }
 
   void generate_initial() {
@@ -3232,7 +3413,7 @@
     StubRoutines::_throw_WrongMethodTypeException_entry =
       generate_throw_exception("WrongMethodTypeException throw_exception",
                                CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException),
-                               false, G5_method_type, G3_method_handle);
+                               G5_method_type, G3_method_handle);
   }
 
 
@@ -3243,12 +3424,10 @@
     // UseZeroBaseCompressedOops which is defined after heap initialization.
     StubRoutines::Sparc::_partial_subtype_check                = generate_partial_subtype_check();
     // These entry points require SharedInfo::stack0 to be set up in non-core builds
-    StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError),  false);
-    StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError),  false);
-    StubRoutines::_throw_ArithmeticException_entry         = generate_throw_exception("ArithmeticException throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_ArithmeticException),  true);
-    StubRoutines::_throw_NullPointerException_entry        = generate_throw_exception("NullPointerException throw_exception",         CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException), true);
-    StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
-    StubRoutines::_throw_StackOverflowError_entry          = generate_throw_exception("StackOverflowError throw_exception",           CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError),   false);
+    StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
+    StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
+    StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
+    StubRoutines::_throw_StackOverflowError_entry          = generate_throw_exception("StackOverflowError throw_exception",           CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));
 
     StubRoutines::_handler_for_unsafe_access_entry =
       generate_handler_for_unsafe_access();
--- a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -3374,7 +3374,7 @@
 
   if(UseTLAB) {
     Register RoldTopValue = RallocatedObject;
-    Register RtopAddr = G3_scratch, RtlabWasteLimitValue = G3_scratch;
+    Register RtlabWasteLimitValue = G3_scratch;
     Register RnewTopValue = G1_scratch;
     Register RendValue = Rscratch;
     Register RfreeValue = RnewTopValue;
@@ -3455,7 +3455,11 @@
     __ delayed()->add(RallocatedObject, sizeof(oopDesc), G3_scratch);
 
     // initialize remaining object fields
-    { Label loop;
+    if (UseBlockZeroing) {
+      // Use BIS for zeroing
+      __ bis_zeroing(G3_scratch, Roffset, G1_scratch, initialize_header);
+    } else {
+      Label loop;
       __ subcc(Roffset, wordSize, Roffset);
       __ bind(loop);
       //__ subcc(Roffset, wordSize, Roffset);      // executed above loop or in delay slot
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -75,6 +75,24 @@
     FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
   }
 
+  if (has_v9()) {
+    assert(ArraycopySrcPrefetchDistance < 4096, "invalid value");
+    if (ArraycopySrcPrefetchDistance >= 4096)
+      ArraycopySrcPrefetchDistance = 4064;
+    assert(ArraycopyDstPrefetchDistance < 4096, "invalid value");
+    if (ArraycopyDstPrefetchDistance >= 4096)
+      ArraycopyDstPrefetchDistance = 4064;
+  } else {
+    if (ArraycopySrcPrefetchDistance > 0) {
+      warning("prefetch instructions are not available on this CPU");
+      FLAG_SET_DEFAULT(ArraycopySrcPrefetchDistance, 0);
+    }
+    if (ArraycopyDstPrefetchDistance > 0) {
+      warning("prefetch instructions are not available on this CPU");
+      FLAG_SET_DEFAULT(ArraycopyDstPrefetchDistance, 0);
+    }
+  }
+
   UseSSE = 0; // Only on x86 and x64
 
   _supports_cx8 = has_v9();
@@ -170,6 +188,26 @@
     FLAG_SET_DEFAULT(UseCBCond, false);
   }
 
+  assert(BlockZeroingLowLimit > 0, "invalid value");
+  if (has_block_zeroing()) {
+    if (FLAG_IS_DEFAULT(UseBlockZeroing)) {
+      FLAG_SET_DEFAULT(UseBlockZeroing, true);
+    }
+  } else if (UseBlockZeroing) {
+    warning("BIS zeroing instructions are not available on this CPU");
+    FLAG_SET_DEFAULT(UseBlockZeroing, false);
+  }
+
+  assert(BlockCopyLowLimit > 0, "invalid value");
+  if (has_block_zeroing()) { // has_blk_init() && is_T4(): core's local L2 cache
+    if (FLAG_IS_DEFAULT(UseBlockCopy)) {
+      FLAG_SET_DEFAULT(UseBlockCopy, true);
+    }
+  } else if (UseBlockCopy) {
+    warning("BIS instructions are not available or expensive on this CPU");
+    FLAG_SET_DEFAULT(UseBlockCopy, false);
+  }
+
 #ifdef COMPILER2
   // T4 and newer Sparc cpus have fast RDPC.
   if (has_fast_rdpc() && FLAG_IS_DEFAULT(UseRDPCForConstantTableBase)) {
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -135,8 +135,8 @@
   // T4 and newer Sparc have fast RDPC instruction.
   static bool has_fast_rdpc()           { return is_T4(); }
 
-  // T4 and newer Sparc have Most-Recently-Used (MRU) BIS.
-  static bool has_mru_blk_init()        { return has_blk_init() && is_T4(); }
+  // On T4 and newer Sparc BIS to the beginning of cache line always zeros it.
+  static bool has_block_zeroing()       { return has_blk_init() && is_T4(); }
 
   static const char* cpu_features()     { return _features_str; }
 
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -8004,15 +8004,10 @@
                                                 Register temp_reg) {
   assert_different_registers(vmslots_reg, mh_reg, temp_reg);
   // load mh.type.form.vmslots
-  if (java_lang_invoke_MethodHandle::vmslots_offset_in_bytes() != 0) {
-    // hoist vmslots into every mh to avoid dependent load chain
-    movl(vmslots_reg, Address(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmslots_offset_in_bytes, temp_reg)));
-  } else {
-    Register temp2_reg = vmslots_reg;
-    load_heap_oop(temp2_reg, Address(mh_reg,    delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)));
-    load_heap_oop(temp2_reg, Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)));
-    movl(vmslots_reg, Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
-  }
+  Register temp2_reg = vmslots_reg;
+  load_heap_oop(temp2_reg, Address(mh_reg,    delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)));
+  load_heap_oop(temp2_reg, Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)));
+  movl(vmslots_reg, Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
 }
 
 
--- a/hotspot/src/cpu/x86/vm/bytes_x86.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/bytes_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -81,6 +81,9 @@
 #ifdef TARGET_OS_ARCH_windows_x86
 # include "bytes_windows_x86.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "bytes_bsd_x86.inline.hpp"
+#endif
 
 
 #endif // CPU_X86_VM_BYTES_X86_HPP
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -129,10 +129,6 @@
   return FrameMap::receiver_opr;
 }
 
-LIR_Opr LIR_Assembler::incomingReceiverOpr() {
-  return receiverOpr();
-}
-
 LIR_Opr LIR_Assembler::osrBufferPointer() {
   return FrameMap::as_pointer_opr(receiverOpr()->as_register());
 }
@@ -371,55 +367,6 @@
 }
 
 
-void LIR_Assembler::monitorexit(LIR_Opr obj_opr, LIR_Opr lock_opr, Register new_hdr, int monitor_no, Register exception) {
-  if (exception->is_valid()) {
-    // preserve exception
-    // note: the monitor_exit runtime call is a leaf routine
-    //       and cannot block => no GC can happen
-    // The slow case (MonitorAccessStub) uses the first two stack slots
-    // ([esp+0] and [esp+4]), therefore we store the exception at [esp+8]
-    __ movptr (Address(rsp, 2*wordSize), exception);
-  }
-
-  Register obj_reg  = obj_opr->as_register();
-  Register lock_reg = lock_opr->as_register();
-
-  // setup registers (lock_reg must be rax, for lock_object)
-  assert(obj_reg != SYNC_header && lock_reg != SYNC_header, "rax, must be available here");
-  Register hdr = lock_reg;
-  assert(new_hdr == SYNC_header, "wrong register");
-  lock_reg = new_hdr;
-  // compute pointer to BasicLock
-  Address lock_addr = frame_map()->address_for_monitor_lock(monitor_no);
-  __ lea(lock_reg, lock_addr);
-  // unlock object
-  MonitorAccessStub* slow_case = new MonitorExitStub(lock_opr, true, monitor_no);
-  // _slow_case_stubs->append(slow_case);
-  // temporary fix: must be created after exceptionhandler, therefore as call stub
-  _slow_case_stubs->append(slow_case);
-  if (UseFastLocking) {
-    // try inlined fast unlocking first, revert to slow locking if it fails
-    // note: lock_reg points to the displaced header since the displaced header offset is 0!
-    assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
-    __ unlock_object(hdr, obj_reg, lock_reg, *slow_case->entry());
-  } else {
-    // always do slow unlocking
-    // note: the slow unlocking code could be inlined here, however if we use
-    //       slow unlocking, speed doesn't matter anyway and this solution is
-    //       simpler and requires less duplicated code - additionally, the
-    //       slow unlocking code is the same in either case which simplifies
-    //       debugging
-    __ jmp(*slow_case->entry());
-  }
-  // done
-  __ bind(*slow_case->continuation());
-
-  if (exception->is_valid()) {
-    // restore exception
-    __ movptr (exception, Address(rsp, 2 * wordSize));
-  }
-}
-
 // This specifies the rsp decrement needed to build the frame
 int LIR_Assembler::initial_frame_size_in_bytes() {
   // if rounding, must let FrameMap know!
@@ -480,8 +427,8 @@
   // Fetch the exception from TLS and clear out exception related thread state
   __ get_thread(rsi);
   __ movptr(rax, Address(rsi, JavaThread::exception_oop_offset()));
-  __ movptr(Address(rsi, JavaThread::exception_oop_offset()), (int32_t)NULL_WORD);
-  __ movptr(Address(rsi, JavaThread::exception_pc_offset()), (int32_t)NULL_WORD);
+  __ movptr(Address(rsi, JavaThread::exception_oop_offset()), (intptr_t)NULL_WORD);
+  __ movptr(Address(rsi, JavaThread::exception_pc_offset()), (intptr_t)NULL_WORD);
 
   __ bind(_unwind_handler_entry);
   __ verify_not_null_oop(rax);
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -29,8 +29,6 @@
 
   Address::ScaleFactor array_element_size(BasicType type) const;
 
-  void monitorexit(LIR_Opr obj_opr, LIR_Opr lock_opr, Register new_hdr, int monitor_no, Register exception);
-
   void arith_fpu_implementation(LIR_Code code, int left_index, int right_index, int dest_index, bool pop_fpu_stack);
 
   // helper functions which checks for overflow and sets bailout if it
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -267,7 +267,8 @@
   bool use_length = x->length() != NULL;
   bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT;
   bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
-                                         !get_jobject_constant(x->value())->is_null_object());
+                                         !get_jobject_constant(x->value())->is_null_object() ||
+                                         x->should_profile());
 
   LIRItem array(x->array(), this);
   LIRItem index(x->index(), this);
@@ -321,7 +322,7 @@
     LIR_Opr tmp3 = new_register(objectType);
 
     CodeEmitInfo* store_check_info = new CodeEmitInfo(range_check_info);
-    __ store_check(value.result(), array.result(), tmp1, tmp2, tmp3, store_check_info);
+    __ store_check(value.result(), array.result(), tmp1, tmp2, tmp3, store_check_info, x->profiled_method(), x->profiled_bci());
   }
 
   if (obj_store) {
--- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1465,19 +1465,6 @@
       }
       break;
 
-    case jvmti_exception_throw_id:
-      { // rax,: exception oop
-        StubFrame f(sasm, "jvmti_exception_throw", dont_gc_arguments);
-        // Preserve all registers across this potentially blocking call
-        const int num_rt_args = 2;  // thread, exception oop
-        OopMap* map = save_live_registers(sasm, num_rt_args);
-        int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, Runtime1::post_jvmti_exception_throw), rax);
-        oop_maps = new OopMapSet();
-        oop_maps->add_gc_map(call_offset, map);
-        restore_live_registers(sasm);
-      }
-      break;
-
     case dtrace_object_alloc_id:
       { // rax,: object
         StubFrame f(sasm, "dtrace_object_alloc", dont_gc_arguments);
--- a/hotspot/src/cpu/x86/vm/copy_x86.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/copy_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_ARCH_windows_x86
 # include "copy_windows_x86.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "copy_bsd_x86.inline.hpp"
+#endif
 
 
 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
--- a/hotspot/src/cpu/x86/vm/frame_x86.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/frame_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -232,11 +232,13 @@
 
 
 void frame::patch_pc(Thread* thread, address pc) {
+  address* pc_addr = &(((address*) sp())[-1]);
   if (TracePcPatching) {
-    tty->print_cr("patch_pc at address" INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "] ",
-                  &((address *)sp())[-1], ((address *)sp())[-1], pc);
+    tty->print_cr("patch_pc at address " INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "] ",
+                  pc_addr, *pc_addr, pc);
   }
-  ((address *)sp())[-1] = pc;
+  assert(_pc == *pc_addr, err_msg("must be: " INTPTR_FORMAT " == " INTPTR_FORMAT, _pc, *pc_addr));
+  *pc_addr = pc;
   _cb = CodeCache::find_blob(pc);
   address original_pc = nmethod::get_deopt_original_pc(this);
   if (original_pc != NULL) {
@@ -666,3 +668,8 @@
 
 }
 #endif
+
+intptr_t *frame::initial_deoptimization_info() {
+  // used to reset the saved FP
+  return fp();
+}
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -70,7 +70,11 @@
 define_pd_global(bool, RewriteBytecodes,     true);
 define_pd_global(bool, RewriteFrequentPairs, true);
 
+#ifdef _ALLBSD_SOURCE
+define_pd_global(bool, UseMembar,            true);
+#else
 define_pd_global(bool, UseMembar,            false);
+#endif
 
 // GC Ergo Flags
 define_pd_global(intx, CMSYoungGenPerWorker, 64*M);  // default max size of CMS young gen, per GC worker thread
--- a/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -45,6 +45,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 // Implementation of InterpreterMacroAssembler
@@ -1158,7 +1161,7 @@
   int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row));
   set_mdp_data_at(mdp, recvr_offset, receiver);
   int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row));
-  movptr(reg2, (int32_t)DataLayout::counter_increment);
+  movptr(reg2, (intptr_t)DataLayout::counter_increment);
   set_mdp_data_at(mdp, count_offset, reg2);
   if (start_row > 0) {
     jmp(done);
@@ -1301,7 +1304,7 @@
     test_method_data_pointer(mdp, profile_continue);
 
     // Build the base (index * per_case_size_in_bytes()) + case_array_offset_in_bytes()
-    movptr(reg2, (int32_t)in_bytes(MultiBranchData::per_case_size()));
+    movptr(reg2, (intptr_t)in_bytes(MultiBranchData::per_case_size()));
     // index is positive and so should have correct value if this code were
     // used on 64bits
     imulptr(index, reg2);
--- a/hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -45,6 +45,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 // Implementation of InterpreterMacroAssembler
--- a/hotspot/src/cpu/x86/vm/jni_x86.h	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/jni_x86.h	Wed Oct 26 17:59:13 2011 -0700
@@ -26,7 +26,7 @@
 #ifndef _JAVASOFT_JNI_MD_H_
 #define _JAVASOFT_JNI_MD_H_
 
-#if defined(SOLARIS) || defined(LINUX)
+#if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE)
 
 #if defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2)
   #define JNIEXPORT     __attribute__((visibility("default")))
@@ -38,10 +38,14 @@
 
   #define JNICALL
   typedef int jint;
-
-#ifdef _LP64
+#if defined(_LP64) && !defined(__APPLE__)
   typedef long jlong;
 #else
+  /*
+   * On _LP64 __APPLE__ "long" and "long long" are both 64 bits,
+   * but we use the "long long" typedef to avoid complaints from
+   * the __APPLE__ compiler about fprintf formats.
+   */
   typedef long long jlong;
 #endif
 
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -410,8 +410,8 @@
 
 void MethodHandles::RicochetFrame::verify() const {
   verify_offsets();
-  assert(magic_number_1() == MAGIC_NUMBER_1, "");
-  assert(magic_number_2() == MAGIC_NUMBER_2, "");
+  assert(magic_number_1() == MAGIC_NUMBER_1, err_msg(PTR_FORMAT " == " PTR_FORMAT, magic_number_1(), MAGIC_NUMBER_1));
+  assert(magic_number_2() == MAGIC_NUMBER_2, err_msg(PTR_FORMAT " == " PTR_FORMAT, magic_number_2(), MAGIC_NUMBER_2));
   if (!Universe::heap()->is_gc_active()) {
     if (saved_args_layout() != NULL) {
       assert(saved_args_layout()->is_method(), "must be valid oop");
@@ -624,6 +624,11 @@
 
   // error path for invokeExact (only)
   __ bind(invoke_exact_error_path);
+  // ensure that the top of stack is properly aligned.
+  __ mov(rdi, rsp);
+  __ andptr(rsp, -StackAlignmentInBytes); // Align the stack for the ABI
+  __ pushptr(Address(rdi, 0));  // Pick up the return address
+
   // Stub wants expected type in rax and the actual type in rcx
   __ jump(ExternalAddress(StubRoutines::throw_WrongMethodTypeException_entry()));
 
@@ -1343,6 +1348,13 @@
     }
     break;
 
+  case _adapter_opt_profiling:
+    if (java_lang_invoke_CountingMethodHandle::vmcount_offset_in_bytes() != 0) {
+      Address rcx_mh_vmcount(rcx_recv, java_lang_invoke_CountingMethodHandle::vmcount_offset_in_bytes());
+      __ incrementl(rcx_mh_vmcount);
+    }
+    // fall through
+
   case _adapter_retype_only:
   case _adapter_retype_raw:
     // immediately jump to the next MH layer:
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -110,6 +110,7 @@
 
 class RicochetFrame {
   friend class MethodHandles;
+  friend class VMStructs;
 
  private:
   intptr_t* _continuation;          // what to do when control gets back here
@@ -131,7 +132,10 @@
   intptr_t* sender_link() const         { return _sender_link; }
   address   sender_pc() const           { return _sender_pc; }
 
-  intptr_t* extended_sender_sp() const  { return saved_args_base(); }
+  intptr_t* extended_sender_sp() const {
+    // The extended sender SP is above the current RicochetFrame.
+    return (intptr_t*) (((address) this) + sizeof(RicochetFrame));
+  }
 
   intptr_t  return_value_slot_number() const {
     return adapter_conversion_vminfo(conversion());
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -2471,7 +2471,7 @@
   __ movl(counter, rbx);
 
   // Pick up the initial fp we should save
-  __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_fp_offset_in_bytes()));
+  __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
 
   // Now adjust the caller's stack to make up for the extra locals
   // but record the original sp so that we can save it in the skeletal interpreter
@@ -2691,7 +2691,7 @@
   __ movl(counter, rbx);
 
   // Pick up the initial fp we should save
-  __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_fp_offset_in_bytes()));
+  __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
 
   // Now adjust the caller's stack to make up for the extra locals
   // but record the original sp so that we can save it in the skeletal interpreter
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -2730,7 +2730,7 @@
   __ movl(rdx, Address(rdi, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes()));
 
   // Pick up the initial fp we should save
-  __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_fp_offset_in_bytes()));
+  __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
 
   // Now adjust the caller's stack to make up for the extra locals
   // but record the original sp so that we can save it in the skeletal interpreter
@@ -2922,7 +2922,7 @@
   // Pick up the initial fp we should save
   __ movptr(rbp,
             Address(rdi,
-                    Deoptimization::UnrollBlock::initial_fp_offset_in_bytes()));
+                    Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
 
   // Now adjust the caller's stack to make up for the extra locals but
   // record the original sp so that we can save it in the skeletal
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -47,6 +47,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef COMPILER2
 #include "opto/runtime.hpp"
 #endif
@@ -2187,7 +2190,7 @@
   // either at call sites or otherwise assume that stack unwinding will be initiated,
   // so caller saved registers were assumed volatile in the compiler.
   address generate_throw_exception(const char* name, address runtime_entry,
-                                   bool restore_saved_exception_pc, Register arg1 = noreg, Register arg2 = noreg) {
+                                   Register arg1 = noreg, Register arg2 = noreg) {
 
     int insts_size = 256;
     int locs_size  = 32;
@@ -2204,10 +2207,6 @@
     // differently than the real call_VM
     Register java_thread = rbx;
     __ get_thread(java_thread);
-    if (restore_saved_exception_pc) {
-      __ movptr(rax, Address(java_thread, in_bytes(JavaThread::saved_exception_pc_offset())));
-      __ push(rax);
-    }
 
     __ enter(); // required for proper stackwalking of RuntimeStub frame
 
@@ -2323,7 +2322,7 @@
     StubRoutines::_throw_WrongMethodTypeException_entry =
       generate_throw_exception("WrongMethodTypeException throw_exception",
                                CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException),
-                               false, rax, rcx);
+                               rax, rcx);
   }
 
 
@@ -2332,12 +2331,10 @@
 
     // These entry points require SharedInfo::stack0 to be set up in non-core builds
     // and need to be relocatable, so they each fabricate a RuntimeStub internally.
-    StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError),  false);
-    StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError),  false);
-    StubRoutines::_throw_ArithmeticException_entry         = generate_throw_exception("ArithmeticException throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_ArithmeticException),  true);
-    StubRoutines::_throw_NullPointerException_entry        = generate_throw_exception("NullPointerException throw_exception",         CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException), true);
-    StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
-    StubRoutines::_throw_StackOverflowError_entry          = generate_throw_exception("StackOverflowError throw_exception",           CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError),   false);
+    StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
+    StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
+    StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
+    StubRoutines::_throw_StackOverflowError_entry          = generate_throw_exception("StackOverflowError throw_exception",           CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));
 
     //------------------------------------------------------------------------------------------------------------------------
     // entry points that are platform specific
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -47,6 +47,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef COMPILER2
 #include "opto/runtime.hpp"
 #endif
@@ -935,6 +938,8 @@
     __ pusha();                       // push registers
     Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord);
 
+    // FIXME: this probably needs alignment logic
+
     __ subptr(rsp, frame::arg_reg_save_area_bytes);
     BLOCK_COMMENT("call handle_unsafe_access");
     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access)));
@@ -2934,7 +2939,6 @@
   // caller saved registers were assumed volatile in the compiler.
   address generate_throw_exception(const char* name,
                                    address runtime_entry,
-                                   bool restore_saved_exception_pc,
                                    Register arg1 = noreg,
                                    Register arg2 = noreg) {
     // Information about frame layout at time of blocking runtime call.
@@ -2962,12 +2966,6 @@
     // which has the ability to fetch the return PC out of
     // thread-local storage and also sets up last_Java_sp slightly
     // differently than the real call_VM
-    if (restore_saved_exception_pc) {
-      __ movptr(rax,
-                Address(r15_thread,
-                        in_bytes(JavaThread::saved_exception_pc_offset())));
-      __ push(rax);
-    }
 
     __ enter(); // required for proper stackwalking of RuntimeStub frame
 
@@ -3068,7 +3066,7 @@
     StubRoutines::_throw_WrongMethodTypeException_entry =
       generate_throw_exception("WrongMethodTypeException throw_exception",
                                CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException),
-                               false, rax, rcx);
+                               rax, rcx);
   }
 
   void generate_all() {
@@ -3081,43 +3079,25 @@
       generate_throw_exception("AbstractMethodError throw_exception",
                                CAST_FROM_FN_PTR(address,
                                                 SharedRuntime::
-                                                throw_AbstractMethodError),
-                               false);
+                                                throw_AbstractMethodError));
 
     StubRoutines::_throw_IncompatibleClassChangeError_entry =
       generate_throw_exception("IncompatibleClassChangeError throw_exception",
                                CAST_FROM_FN_PTR(address,
                                                 SharedRuntime::
-                                                throw_IncompatibleClassChangeError),
-                               false);
-
-    StubRoutines::_throw_ArithmeticException_entry =
-      generate_throw_exception("ArithmeticException throw_exception",
-                               CAST_FROM_FN_PTR(address,
-                                                SharedRuntime::
-                                                throw_ArithmeticException),
-                               true);
-
-    StubRoutines::_throw_NullPointerException_entry =
-      generate_throw_exception("NullPointerException throw_exception",
-                               CAST_FROM_FN_PTR(address,
-                                                SharedRuntime::
-                                                throw_NullPointerException),
-                               true);
+                                                throw_IncompatibleClassChangeError));
 
     StubRoutines::_throw_NullPointerException_at_call_entry =
       generate_throw_exception("NullPointerException at call throw_exception",
                                CAST_FROM_FN_PTR(address,
                                                 SharedRuntime::
-                                                throw_NullPointerException_at_call),
-                               false);
+                                                throw_NullPointerException_at_call));
 
     StubRoutines::_throw_StackOverflowError_entry =
       generate_throw_exception("StackOverflowError throw_exception",
                                CAST_FROM_FN_PTR(address,
                                                 SharedRuntime::
-                                                throw_StackOverflowError),
-                               false);
+                                                throw_StackOverflowError));
 
     // entry points that are platform specific
     StubRoutines::x86::_f2i_fixup = generate_f2i_fixup();
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Implementation of the platform-specific part of StubRoutines - for
 // a description of how to extend it, see the stubRoutines.hpp file.
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_64.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_64.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Implementation of the platform-specific part of StubRoutines - for
 // a description of how to extend it, see the stubRoutines.hpp file.
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 int VM_Version::_cpu;
--- a/hotspot/src/cpu/zero/vm/bytes_zero.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/zero/vm/bytes_zero.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -168,6 +168,9 @@
 #ifdef TARGET_OS_ARCH_linux_zero
 # include "bytes_linux_zero.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "bytes_bsd_zero.inline.hpp"
+#endif
 
 #endif // VM_LITTLE_ENDIAN
 
--- a/hotspot/src/cpu/zero/vm/frame_zero.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/zero/vm/frame_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -425,3 +425,9 @@
 }
 
 #endif
+
+intptr_t *frame::initial_deoptimization_info() {
+  // unused... but returns fp() to minimize changes introduced by 7087445
+  return fp();
+}
+
--- a/hotspot/src/cpu/zero/vm/globals_zero.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -52,7 +52,11 @@
 define_pd_global(bool,  RewriteBytecodes,     true);
 define_pd_global(bool,  RewriteFrequentPairs, true);
 
+#ifdef _ALLBSD_SOURCE
+define_pd_global(bool,  UseMembar,            true);
+#else
 define_pd_global(bool,  UseMembar,            false);
+#endif
 
 // GC Ergo Flags
 define_pd_global(intx, CMSYoungGenPerWorker, 16*M);  // default max size of CMS young gen, per GC worker thread
--- a/hotspot/src/cpu/zero/vm/interp_masm_zero.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/zero/vm/interp_masm_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -40,5 +40,8 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "thread_linux.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // This file is intentionally empty
--- a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -43,6 +43,9 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "thread_linux.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef COMPILER2
 #include "opto/runtime.hpp"
 #endif
@@ -215,12 +218,6 @@
     StubRoutines::_throw_AbstractMethodError_entry =
       ShouldNotCallThisStub();
 
-    StubRoutines::_throw_ArithmeticException_entry =
-      ShouldNotCallThisStub();
-
-    StubRoutines::_throw_NullPointerException_entry =
-      ShouldNotCallThisStub();
-
     StubRoutines::_throw_NullPointerException_at_call_entry =
       ShouldNotCallThisStub();
 
--- a/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -30,3 +30,6 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "thread_linux.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
--- a/hotspot/src/cpu/zero/vm/vm_version_zero.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/cpu/zero/vm/vm_version_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -32,5 +32,8 @@
 #ifdef TARGET_OS_FAMILY_linux
 # include "os_linux.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // This file is intentionally empty
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/*
+ * This is to provide sanity check in jhelper.d which compares SCCS
+ * versions of generateJvmOffsets.cpp used to create and extract
+ * contents of __JvmOffsets[] table.
+ * The __JvmOffsets[] table is located in generated JvmOffsets.cpp.
+ *
+ * GENOFFS_SCCS_VER 34
+ */
+
+#include "generateJvmOffsets.h"
+
+/* A workaround for private and protected fields */
+#define private   public
+#define protected public
+
+// not on macosx #include <proc_service.h>
+#include "code/codeBlob.hpp"
+#include "code/nmethod.hpp"
+#include "code/pcDesc.hpp"
+#include "gc_interface/collectedHeap.hpp"
+#include "memory/heap.hpp"
+#include "memory/memRegion.hpp"
+#include "memory/universe.hpp"
+#include "oops/constMethodOop.hpp"
+#include "oops/klass.hpp"
+#include "oops/methodOop.hpp"
+#include "oops/oop.hpp"
+#include "oops/symbol.hpp"
+#include "runtime/virtualspace.hpp"
+#include "runtime/vmStructs.hpp"
+#include "utilities/accessFlags.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+// These are defined somewhere for Solaris
+#define PR_MODEL_ILP32 1
+#define PR_MODEL_LP64  2
+
+#ifdef COMPILER1
+#if defined(DEBUG) || defined(FASTDEBUG)
+
+/*
+ * To avoid the most part of potential link errors
+ * we link this program with -z nodefs .
+ *
+ * But for 'debug1' and 'fastdebug1' we still have to provide
+ * a particular workaround for the following symbols bellow.
+ * It will be good to find out a generic way in the future.
+ */
+
+#pragma weak tty
+#pragma weak CMSExpAvgFactor
+
+#if defined(i386) || defined(__i386) || defined(__amd64)
+#pragma weak noreg
+#endif /* i386 */
+
+LIR_Opr LIR_OprFact::illegalOpr = (LIR_Opr) 0;
+
+address StubRoutines::_call_stub_return_address = NULL;
+
+StubQueue* AbstractInterpreter::_code = NULL;
+
+#endif /* defined(DEBUG) || defined(FASTDEBUG) */
+#endif /* COMPILER1 */
+
+#define GEN_OFFS(Type,Name)                             \
+  switch(gen_variant) {                                 \
+  case GEN_OFFSET:                                      \
+    printf("#define OFFSET_%-33s %ld\n",                 \
+           #Type #Name, offset_of(Type, Name)); \
+    break;                                              \
+  case GEN_INDEX:                                       \
+    printf("#define IDX_OFFSET_%-33s %d\n",             \
+            #Type #Name, index++);                      \
+    break;                                              \
+  case GEN_TABLE:                                       \
+    printf("\tOFFSET_%s,\n", #Type #Name);              \
+    break;                                              \
+  }
+
+#define GEN_SIZE(Type)                                  \
+  switch(gen_variant) {                                 \
+  case GEN_OFFSET:                                      \
+    printf("#define SIZE_%-35s %ld\n",                   \
+            #Type, sizeof(Type));                       \
+    break;                                              \
+  case GEN_INDEX:                                       \
+    printf("#define IDX_SIZE_%-35s %d\n",               \
+            #Type, index++);                            \
+    break;                                              \
+  case GEN_TABLE:                                       \
+    printf("\tSIZE_%s,\n", #Type);                      \
+    break;                                              \
+  }
+
+#define GEN_VALUE(String,Value)                         \
+  switch(gen_variant) {                                 \
+  case GEN_OFFSET:                                      \
+    printf("#define %-40s %d\n", #String, Value);       \
+    break;                                              \
+  case GEN_INDEX:                                       \
+    printf("#define IDX_%-40s %d\n", #String, index++); \
+    break;                                              \
+  case GEN_TABLE:                                       \
+    printf("\t" #String ",\n");                         \
+    break;                                              \
+  }
+
+void gen_prologue(GEN_variant gen_variant) {
+    const char *suffix;
+
+    switch(gen_variant) {
+      case GEN_OFFSET: suffix = ".h";        break;
+      case GEN_INDEX:  suffix = "Index.h";   break;
+      case GEN_TABLE:  suffix = ".cpp";      break;
+    }
+
+    printf("/*\n");
+    printf(" * JvmOffsets%s !!!DO NOT EDIT!!! \n", suffix);
+    printf(" * The generateJvmOffsets program generates this file!\n");
+    printf(" */\n\n");
+    switch(gen_variant) {
+
+      case GEN_OFFSET:
+      case GEN_INDEX:
+        break;
+
+      case GEN_TABLE:
+        printf("#include \"JvmOffsets.h\"\n");
+        printf("\n");
+        printf("int __JvmOffsets[] = {\n");
+        break;
+    }
+}
+
+void gen_epilogue(GEN_variant gen_variant) {
+    if (gen_variant != GEN_TABLE) {
+        return;
+    }
+    printf("};\n\n");
+    return;
+}
+
+int generateJvmOffsets(GEN_variant gen_variant) {
+  int index = 0;        /* It is used to generate JvmOffsetsIndex.h */
+  int pointer_size = sizeof(void *);
+  int data_model = (pointer_size == 4) ? PR_MODEL_ILP32 : PR_MODEL_LP64;
+
+  gen_prologue(gen_variant);
+
+  GEN_VALUE(DATA_MODEL, data_model);
+  GEN_VALUE(POINTER_SIZE, pointer_size);
+#if defined(TIERED)
+  GEN_VALUE(COMPILER, 3);
+#elif COMPILER1
+  GEN_VALUE(COMPILER, 1);
+#elif COMPILER2
+  GEN_VALUE(COMPILER, 2);
+#else
+  GEN_VALUE(COMPILER, 0);
+#endif // COMPILER1 && COMPILER2
+  printf("\n");
+
+  GEN_OFFS(CollectedHeap, _reserved);
+  GEN_OFFS(MemRegion, _start);
+  GEN_OFFS(MemRegion, _word_size);
+  GEN_SIZE(HeapWord);
+  printf("\n");
+
+  GEN_OFFS(VMStructEntry, typeName);
+  GEN_OFFS(VMStructEntry, fieldName);
+  GEN_OFFS(VMStructEntry, address);
+  GEN_SIZE(VMStructEntry);
+  printf("\n");
+
+  GEN_VALUE(MAX_METHOD_CODE_SIZE, max_method_code_size);
+#if defined(sparc) || defined(__sparc)
+  GEN_VALUE(OFFSET_interpreter_frame_method, 2 * pointer_size);     /* L2 in saved window */
+  GEN_VALUE(OFFSET_interpreter_frame_sender_sp, 13 * pointer_size); /* I5 in saved window */
+  // Fake value for consistency. It is not going to be used.
+  GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, 0xFFFF);
+#elif defined(i386) || defined(__i386) || defined(__amd64)
+  GEN_VALUE(OFFSET_interpreter_frame_sender_sp, -1 * pointer_size);
+  GEN_VALUE(OFFSET_interpreter_frame_method, -3 * pointer_size);
+  GEN_VALUE(OFFSET_interpreter_frame_bcx_offset, -7 * pointer_size);
+#endif
+
+  GEN_OFFS(Klass, _name);
+  GEN_OFFS(constantPoolOopDesc, _pool_holder);
+  printf("\n");
+
+  GEN_VALUE(OFFSET_HeapBlockHeader_used, (int) offset_of(HeapBlock::Header, _used));
+  GEN_OFFS(oopDesc, _metadata);
+  printf("\n");
+
+  GEN_VALUE(AccessFlags_NATIVE, JVM_ACC_NATIVE);
+  GEN_VALUE(constMethodOopDesc_has_linenumber_table, constMethodOopDesc::_has_linenumber_table);
+  GEN_OFFS(AccessFlags, _flags);
+  GEN_OFFS(Symbol, _length);
+  GEN_OFFS(Symbol, _body);
+  printf("\n");
+
+  GEN_OFFS(methodOopDesc, _constMethod);
+  GEN_OFFS(methodOopDesc, _constants);
+  GEN_OFFS(methodOopDesc, _access_flags);
+  printf("\n");
+
+  GEN_OFFS(constMethodOopDesc, _flags);
+  GEN_OFFS(constMethodOopDesc, _code_size);
+  GEN_OFFS(constMethodOopDesc, _name_index);
+  GEN_OFFS(constMethodOopDesc, _signature_index);
+  printf("\n");
+
+  GEN_OFFS(CodeHeap, _memory);
+  GEN_OFFS(CodeHeap, _segmap);
+  GEN_OFFS(CodeHeap, _log2_segment_size);
+  printf("\n");
+
+  GEN_OFFS(VirtualSpace, _low_boundary);
+  GEN_OFFS(VirtualSpace, _high_boundary);
+  GEN_OFFS(VirtualSpace, _low);
+  GEN_OFFS(VirtualSpace, _high);
+  printf("\n");
+
+  GEN_OFFS(CodeBlob, _name);
+  GEN_OFFS(CodeBlob, _header_size);
+  GEN_OFFS(CodeBlob, _content_offset);
+  GEN_OFFS(CodeBlob, _code_offset);
+  GEN_OFFS(CodeBlob, _data_offset);
+  GEN_OFFS(CodeBlob, _frame_size);
+  printf("\n");
+
+  GEN_OFFS(nmethod, _method);
+  GEN_OFFS(nmethod, _oops_offset);
+  GEN_OFFS(nmethod, _scopes_data_offset);
+  GEN_OFFS(nmethod, _scopes_pcs_offset);
+  GEN_OFFS(nmethod, _handler_table_offset);
+  GEN_OFFS(nmethod, _deoptimize_offset);
+  GEN_OFFS(nmethod, _orig_pc_offset);
+
+  GEN_OFFS(PcDesc, _pc_offset);
+  GEN_OFFS(PcDesc, _scope_decode_offset);
+
+  printf("\n");
+
+  GEN_OFFS(NarrowOopStruct, _base);
+  GEN_OFFS(NarrowOopStruct, _shift);
+  printf("\n");
+
+  GEN_VALUE(SIZE_HeapBlockHeader, (int) sizeof(HeapBlock::Header));
+  GEN_SIZE(oopDesc);
+  GEN_SIZE(constantPoolOopDesc);
+  printf("\n");
+
+  GEN_SIZE(PcDesc);
+  GEN_SIZE(methodOopDesc);
+  GEN_SIZE(constMethodOopDesc);
+  GEN_SIZE(nmethod);
+  GEN_SIZE(CodeBlob);
+  GEN_SIZE(BufferBlob);
+  GEN_SIZE(SingletonBlob);
+  GEN_SIZE(RuntimeStub);
+  GEN_SIZE(SafepointBlob);
+
+  gen_epilogue(gen_variant);
+  printf("\n");
+
+  fflush(stdout);
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/generateJvmOffsets.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_SOLARIS_DTRACE_GENERATEJVMOFFSETS_H
+#define OS_SOLARIS_DTRACE_GENERATEJVMOFFSETS_H
+
+#include <stdio.h>
+#include <strings.h>
+
+typedef enum GEN_variant {
+        GEN_OFFSET = 0,
+        GEN_INDEX  = 1,
+        GEN_TABLE  = 2
+} GEN_variant;
+
+extern "C" {
+        int generateJvmOffsets(GEN_variant gen_var);
+        void gen_prologue(GEN_variant gen_var);
+        void gen_epilogue(GEN_variant gen_var);
+}
+
+#endif // OS_SOLARIS_DTRACE_GENERATEJVMOFFSETS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/generateJvmOffsetsMain.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "generateJvmOffsets.h"
+
+const char *HELP =
+    "HELP: generateJvmOffsets {-header | -index | -table} \n";
+
+int main(int argc, const char *argv[]) {
+    GEN_variant gen_var;
+
+    if (argc != 2) {
+        printf("%s", HELP);
+        return 1;
+    }
+
+    if (0 == strcmp(argv[1], "-header")) {
+        gen_var = GEN_OFFSET;
+    }
+    else if (0 == strcmp(argv[1], "-index")) {
+        gen_var = GEN_INDEX;
+    }
+    else if (0 == strcmp(argv[1], "-table")) {
+        gen_var = GEN_TABLE;
+    }
+    else {
+        printf("%s", HELP);
+        return 1;
+    }
+    return generateJvmOffsets(gen_var);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/hotspot.d	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ *  
+ */
+
+provider hotspot {
+  probe class__loaded(char*, uintptr_t, void*, uintptr_t);
+  probe class__unloaded(char*, uintptr_t, void*, uintptr_t);
+  probe class__initialization__required(char*, uintptr_t, void*, intptr_t);
+  probe class__initialization__recursive(char*, uintptr_t, void*, intptr_t,int);
+  probe class__initialization__concurrent(char*, uintptr_t, void*, intptr_t,int);
+  probe class__initialization__erroneous(char*, uintptr_t, void*, intptr_t, int);
+  probe class__initialization__super__failed(char*, uintptr_t, void*, intptr_t,int);
+  probe class__initialization__clinit(char*, uintptr_t, void*, intptr_t,int);
+  probe class__initialization__error(char*, uintptr_t, void*, intptr_t,int);
+  probe class__initialization__end(char*, uintptr_t, void*, intptr_t,int);
+  probe vm__init__begin();
+  probe vm__init__end();
+  probe vm__shutdown();
+  probe vmops__request(char*, uintptr_t, int);
+  probe vmops__begin(char*, uintptr_t, int);
+  probe vmops__end(char*, uintptr_t, int);
+  probe gc__begin(uintptr_t);
+  probe gc__end();
+  probe mem__pool__gc__begin(
+    char*, uintptr_t, char*, uintptr_t, 
+    uintptr_t, uintptr_t, uintptr_t, uintptr_t);
+  probe mem__pool__gc__end(
+    char*, uintptr_t, char*, uintptr_t, 
+    uintptr_t, uintptr_t, uintptr_t, uintptr_t);
+  probe thread__probe__start(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
+  probe thread__probe__stop(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
+  probe thread__sleep__begin(long long);
+  probe thread__sleep__end(int);
+  probe thread__yield();
+  probe thread__park__begin(uintptr_t, int, long long);
+  probe thread__park__end(uintptr_t);
+  probe thread__unpark(uintptr_t);
+  probe method__compile__begin(
+    const char*, uintptr_t, const char*, uintptr_t, const char*, uintptr_t, const char*, uintptr_t); 
+  probe method__compile__end(
+    char*, uintptr_t, char*, uintptr_t, char*, uintptr_t, 
+    char*, uintptr_t, uintptr_t); 
+  probe compiled__method__load(
+    char*, uintptr_t, char*, uintptr_t, char*, uintptr_t, void*, uintptr_t);
+  probe compiled__method__unload(
+    char*, uintptr_t, char*, uintptr_t, char*, uintptr_t); 
+  probe monitor__contended__enter(uintptr_t, uintptr_t, char*, uintptr_t);
+  probe monitor__contended__entered(uintptr_t, uintptr_t, char*, uintptr_t);
+  probe monitor__contended__exit(uintptr_t, uintptr_t, char*, uintptr_t);
+  probe monitor__wait(uintptr_t, uintptr_t, char*, uintptr_t, uintptr_t);
+  probe monitor__probe__waited(uintptr_t, uintptr_t, char*, uintptr_t);
+  probe monitor__notify(uintptr_t, uintptr_t, char*, uintptr_t);
+  probe monitor__notifyAll(uintptr_t, uintptr_t, char*, uintptr_t);
+
+  probe object__alloc(int, char*, uintptr_t, uintptr_t);
+  probe method__entry(
+    int, char*, int, char*, int, char*, int);
+  probe method__return(
+    int, char*, int, char*, int, char*, int);
+};
+
+#pragma D attributes Evolving/Evolving/Common provider hotspot provider
+#pragma D attributes Private/Private/Unknown provider hotspot module
+#pragma D attributes Private/Private/Unknown provider hotspot function
+#pragma D attributes Evolving/Evolving/Common provider hotspot name
+#pragma D attributes Evolving/Evolving/Common provider hotspot args
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/hotspot_jni.d	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,506 @@
+/*
+ * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ *  
+ */
+
+provider hotspot_jni {
+  probe AllocObject__entry(void*, void*);
+  probe AllocObject__return(void*);
+  probe AttachCurrentThreadAsDaemon__entry(void*, void**, void*);
+  probe AttachCurrentThreadAsDaemon__return(uint32_t);
+  probe AttachCurrentThread__entry(void*, void**, void*);
+  probe AttachCurrentThread__return(uint32_t);
+  probe CallBooleanMethodA__entry(void*, void*, uintptr_t);
+  probe CallBooleanMethodA__return(uintptr_t);
+  probe CallBooleanMethod__entry(void*, void*, uintptr_t);
+  probe CallBooleanMethod__return(uintptr_t);
+  probe CallBooleanMethodV__entry(void*, void*, uintptr_t);
+  probe CallBooleanMethodV__return(uintptr_t);
+  probe CallByteMethodA__entry(void*, void*, uintptr_t);
+  probe CallByteMethodA__return(char);
+  probe CallByteMethod__entry(void*, void*, uintptr_t);
+  probe CallByteMethod__return(char);
+  probe CallByteMethodV__entry(void*, void*, uintptr_t);
+  probe CallByteMethodV__return(char);
+  probe CallCharMethodA__entry(void*, void*, uintptr_t);
+  probe CallCharMethodA__return(uint16_t);
+  probe CallCharMethod__entry(void*, void*, uintptr_t);
+  probe CallCharMethod__return(uint16_t);
+  probe CallCharMethodV__entry(void*, void*, uintptr_t);
+  probe CallCharMethodV__return(uint16_t);
+  probe CallDoubleMethodA__entry(void*, void*, uintptr_t);
+  probe CallDoubleMethodA__return();
+  probe CallDoubleMethod__entry(void*, void*, uintptr_t);
+  probe CallDoubleMethod__return();
+  probe CallDoubleMethodV__entry(void*, void*, uintptr_t);
+  probe CallDoubleMethodV__return();
+  probe CallFloatMethodA__entry(void*, void*, uintptr_t);
+  probe CallFloatMethodA__return();
+  probe CallFloatMethod__entry(void*, void*, uintptr_t);
+  probe CallFloatMethod__return();
+  probe CallFloatMethodV__entry(void*, void*, uintptr_t);
+  probe CallFloatMethodV__return();
+  probe CallIntMethodA__entry(void*, void*, uintptr_t);
+  probe CallIntMethodA__return(uint32_t);
+  probe CallIntMethod__entry(void*, void*, uintptr_t);
+  probe CallIntMethod__return(uint32_t);
+  probe CallIntMethodV__entry(void*, void*, uintptr_t);
+  probe CallIntMethodV__return(uint32_t);
+  probe CallLongMethodA__entry(void*, void*, uintptr_t);
+  probe CallLongMethodA__return(uintptr_t);
+  probe CallLongMethod__entry(void*, void*, uintptr_t);
+  probe CallLongMethod__return(uintptr_t);
+  probe CallLongMethodV__entry(void*, void*, uintptr_t);
+  probe CallLongMethodV__return(uintptr_t);
+  probe CallNonvirtualBooleanMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualBooleanMethodA__return(uintptr_t);
+  probe CallNonvirtualBooleanMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualBooleanMethod__return(uintptr_t);
+  probe CallNonvirtualBooleanMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualBooleanMethodV__return(uintptr_t);
+  probe CallNonvirtualByteMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualByteMethodA__return(char);
+  probe CallNonvirtualByteMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualByteMethod__return(char);
+  probe CallNonvirtualByteMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualByteMethodV__return(char);
+  probe CallNonvirtualCharMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualCharMethodA__return(uint16_t);
+  probe CallNonvirtualCharMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualCharMethod__return(uint16_t);
+  probe CallNonvirtualCharMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualCharMethodV__return(uint16_t);
+  probe CallNonvirtualDoubleMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualDoubleMethodA__return();
+  probe CallNonvirtualDoubleMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualDoubleMethod__return();
+  probe CallNonvirtualDoubleMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualDoubleMethodV__return();
+  probe CallNonvirtualFloatMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualFloatMethodA__return();
+  probe CallNonvirtualFloatMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualFloatMethod__return();
+  probe CallNonvirtualFloatMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualFloatMethodV__return();
+  probe CallNonvirtualIntMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualIntMethodA__return(uint32_t);
+  probe CallNonvirtualIntMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualIntMethod__return(uint32_t);
+  probe CallNonvirtualIntMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualIntMethodV__return(uint32_t);
+  probe CallNonvirtualLongMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualLongMethodA__return(uintptr_t);
+  probe CallNonvirtualLongMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualLongMethod__return(uintptr_t);
+  probe CallNonvirtualLongMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualLongMethodV__return(uintptr_t);
+  probe CallNonvirtualObjectMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualObjectMethodA__return(void*);
+  probe CallNonvirtualObjectMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualObjectMethod__return(void*);
+  probe CallNonvirtualObjectMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualObjectMethodV__return(void*);
+  probe CallNonvirtualShortMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualShortMethodA__return(uint16_t);
+  probe CallNonvirtualShortMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualShortMethod__return(uint16_t);
+  probe CallNonvirtualShortMethodV__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualShortMethodV__return(uint16_t);
+  probe CallNonvirtualVoidMethodA__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualVoidMethodA__return();
+  probe CallNonvirtualVoidMethod__entry(void*, void*, void*, uintptr_t);
+  probe CallNonvirtualVoidMethod__return();
+  probe CallNonvirtualVoidMethodV__entry(void*, void*, void*, uintptr_t);  
+  probe CallNonvirtualVoidMethodV__return();
+  probe CallObjectMethodA__entry(void*, void*, uintptr_t);
+  probe CallObjectMethodA__return(void*);
+  probe CallObjectMethod__entry(void*, void*, uintptr_t);
+  probe CallObjectMethod__return(void*);
+  probe CallObjectMethodV__entry(void*, void*, uintptr_t);
+  probe CallObjectMethodV__return(void*);
+  probe CallShortMethodA__entry(void*, void*, uintptr_t);
+  probe CallShortMethodA__return(uint16_t);
+  probe CallShortMethod__entry(void*, void*, uintptr_t);
+  probe CallShortMethod__return(uint16_t);
+  probe CallShortMethodV__entry(void*, void*, uintptr_t);
+  probe CallShortMethodV__return(uint16_t);
+  probe CallStaticBooleanMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticBooleanMethodA__return(uintptr_t);
+  probe CallStaticBooleanMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticBooleanMethod__return(uintptr_t);
+  probe CallStaticBooleanMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticBooleanMethodV__return(uintptr_t);
+  probe CallStaticByteMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticByteMethodA__return(char);
+  probe CallStaticByteMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticByteMethod__return(char);
+  probe CallStaticByteMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticByteMethodV__return(char);
+  probe CallStaticCharMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticCharMethodA__return(uint16_t);
+  probe CallStaticCharMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticCharMethod__return(uint16_t);
+  probe CallStaticCharMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticCharMethodV__return(uint16_t);
+  probe CallStaticDoubleMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticDoubleMethodA__return();
+  probe CallStaticDoubleMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticDoubleMethod__return();
+  probe CallStaticDoubleMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticDoubleMethodV__return();
+  probe CallStaticFloatMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticFloatMethodA__return();
+  probe CallStaticFloatMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticFloatMethod__return();
+  probe CallStaticFloatMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticFloatMethodV__return();
+  probe CallStaticIntMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticIntMethodA__return(uint32_t);
+  probe CallStaticIntMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticIntMethod__return(uint32_t);
+  probe CallStaticIntMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticIntMethodV__return(uint32_t);
+  probe CallStaticLongMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticLongMethodA__return(uintptr_t);
+  probe CallStaticLongMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticLongMethod__return(uintptr_t);
+  probe CallStaticLongMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticLongMethodV__return(uintptr_t);
+  probe CallStaticObjectMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticObjectMethodA__return(void*);
+  probe CallStaticObjectMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticObjectMethod__return(void*);
+  probe CallStaticObjectMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticObjectMethodV__return(void*);
+  probe CallStaticShortMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticShortMethodA__return(uint16_t);
+  probe CallStaticShortMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticShortMethod__return(uint16_t);
+  probe CallStaticShortMethodV__entry(void*, void*, uintptr_t);
+  probe CallStaticShortMethodV__return(uint16_t);
+  probe CallStaticVoidMethodA__entry(void*, void*, uintptr_t);
+  probe CallStaticVoidMethodA__return();
+  probe CallStaticVoidMethod__entry(void*, void*, uintptr_t);
+  probe CallStaticVoidMethod__return(); 
+  probe CallStaticVoidMethodV__entry(void*, void*, uintptr_t);  
+  probe CallStaticVoidMethodV__return();
+  probe CallVoidMethodA__entry(void*, void*, uintptr_t);  
+  probe CallVoidMethodA__return();
+  probe CallVoidMethod__entry(void*, void*, uintptr_t);  
+  probe CallVoidMethod__return(); 
+  probe CallVoidMethodV__entry(void*, void*, uintptr_t);  
+  probe CallVoidMethodV__return();
+  probe CreateJavaVM__entry(void**, void**, void*);
+  probe CreateJavaVM__return(uint32_t);
+  probe DefineClass__entry(void*, const char*, void*, char*, uintptr_t);
+  probe DefineClass__return(void*);
+  probe DeleteGlobalRef__entry(void*, void*);
+  probe DeleteGlobalRef__return();
+  probe DeleteLocalRef__entry(void*, void*);
+  probe DeleteLocalRef__return();
+  probe DeleteWeakGlobalRef__entry(void*, void*);
+  probe DeleteWeakGlobalRef__return();
+  probe DestroyJavaVM__entry(void*);
+  probe DestroyJavaVM__return(uint32_t);
+  probe DetachCurrentThread__entry(void*);
+  probe DetachCurrentThread__return(uint32_t);
+  probe EnsureLocalCapacity__entry(void*, uint32_t);
+  probe EnsureLocalCapacity__return(uint32_t);
+  probe ExceptionCheck__entry(void*);
+  probe ExceptionCheck__return(uintptr_t);
+  probe ExceptionClear__entry(void*);
+  probe ExceptionClear__return();
+  probe ExceptionDescribe__entry(void*);  
+  probe ExceptionDescribe__return();
+  probe ExceptionOccurred__entry(void*);
+  probe ExceptionOccurred__return(void*);
+  probe FatalError__entry(void* env, const char*);
+  probe FindClass__entry(void*, const char*);
+  probe FindClass__return(void*);
+  probe FromReflectedField__entry(void*, void*);
+  probe FromReflectedField__return(uintptr_t);
+  probe FromReflectedMethod__entry(void*, void*);
+  probe FromReflectedMethod__return(uintptr_t);
+  probe GetArrayLength__entry(void*, void*);
+  probe GetArrayLength__return(uintptr_t);
+  probe GetBooleanArrayElements__entry(void*, void*, uintptr_t*);
+  probe GetBooleanArrayElements__return(uintptr_t*);
+  probe GetBooleanArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, uintptr_t*);
+  probe GetBooleanArrayRegion__return();
+  probe GetBooleanField__entry(void*, void*, uintptr_t);
+  probe GetBooleanField__return(uintptr_t);
+  probe GetByteArrayElements__entry(void*, void*, uintptr_t*);
+  probe GetByteArrayElements__return(char*);
+  probe GetByteArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, char*);
+  probe GetByteArrayRegion__return();
+  probe GetByteField__entry(void*, void*, uintptr_t);
+  probe GetByteField__return(char);
+  probe GetCharArrayElements__entry(void*, void*, uintptr_t*);
+  probe GetCharArrayElements__return(uint16_t*);
+  probe GetCharArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, uint16_t*);
+  probe GetCharArrayRegion__return();
+  probe GetCharField__entry(void*, void*, uintptr_t);
+  probe GetCharField__return(uint16_t);
+  probe GetCreatedJavaVMs__entry(void**, uintptr_t, uintptr_t*);
+  probe GetCreatedJavaVMs__return(uintptr_t);
+  probe GetDefaultJavaVMInitArgs__entry(void*);
+  probe GetDefaultJavaVMInitArgs__return(uint32_t);
+  probe GetDirectBufferAddress__entry(void*, void*);
+  probe GetDirectBufferAddress__return(void*);
+  probe GetDirectBufferCapacity__entry(void*, void*);
+  probe GetDirectBufferCapacity__return(uintptr_t);
+  probe GetDoubleArrayElements__entry(void*, void*, uintptr_t*);
+  probe GetDoubleArrayElements__return(double*);
+  probe GetDoubleArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, double*);
+  probe GetDoubleArrayRegion__return();
+  probe GetDoubleField__entry(void*, void*, uintptr_t);
+  probe GetDoubleField__return();
+  probe GetEnv__entry(void*, void*, uint32_t);
+  probe GetEnv__return(uint32_t);
+  probe GetFieldID__entry(void*, void*, const char*, const char*);
+  probe GetFieldID__return(uintptr_t);
+  probe GetFloatArrayElements__entry(void*, void*, uintptr_t*);
+  probe GetFloatArrayElements__return(float*);
+  probe GetFloatArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, float*);
+  probe GetFloatArrayRegion__return();
+  probe GetFloatField__entry(void*, void*, uintptr_t);
+  probe GetFloatField__return();
+  probe GetIntArrayElements__entry(void*, void*, uintptr_t*);
+  probe GetIntArrayElements__return(uint32_t*);
+  probe GetIntArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, uint32_t*);
+  probe GetIntArrayRegion__return();
+  probe GetIntField__entry(void*, void*, uintptr_t);
+  probe GetIntField__return(uint32_t);
+  probe GetJavaVM__entry(void*, void**);
+  probe GetJavaVM__return(uint32_t);
+  probe GetLongArrayElements__entry(void*, void*, uintptr_t*);
+  probe GetLongArrayElements__return(uintptr_t*);
+  probe GetLongArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, uintptr_t*);
+  probe GetLongArrayRegion__return();
+  probe GetLongField__entry(void*, void*, uintptr_t);
+  probe GetLongField__return(uintptr_t);
+  probe GetMethodID__entry(void*, void*, const char*, const char*);
+  probe GetMethodID__return(uintptr_t);
+  probe GetObjectArrayElement__entry(void*, void*, uintptr_t);
+  probe GetObjectArrayElement__return(void*);
+  probe GetObjectClass__entry(void*, void*);
+  probe GetObjectClass__return(void*);
+  probe GetObjectField__entry(void*, void*, uintptr_t);
+  probe GetObjectField__return(void*);
+  probe GetObjectRefType__entry(void*, void*);
+  probe GetObjectRefType__return(void*);
+  probe GetPrimitiveArrayCritical__entry(void*, void*, uintptr_t*);
+  probe GetPrimitiveArrayCritical__return(void*);
+  probe GetShortArrayElements__entry(void*, void*, uintptr_t*);
+  probe GetShortArrayElements__return(uint16_t*);
+  probe GetShortArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, uint16_t*);
+  probe GetShortArrayRegion__return();
+  probe GetShortField__entry(void*, void*, uintptr_t);
+  probe GetShortField__return(uint16_t);
+  probe GetStaticBooleanField__entry(void*, void*, uintptr_t);
+  probe GetStaticBooleanField__return(uintptr_t);
+  probe GetStaticByteField__entry(void*, void*, uintptr_t);
+  probe GetStaticByteField__return(char);
+  probe GetStaticCharField__entry(void*, void*, uintptr_t);
+  probe GetStaticCharField__return(uint16_t);
+  probe GetStaticDoubleField__entry(void*, void*, uintptr_t);
+  probe GetStaticDoubleField__return();
+  probe GetStaticFieldID__entry(void*, void*, const char*, const char*);
+  probe GetStaticFieldID__return(uintptr_t);
+  probe GetStaticFloatField__entry(void*, void*, uintptr_t);
+  probe GetStaticFloatField__return();
+  probe GetStaticIntField__entry(void*, void*, uintptr_t);
+  probe GetStaticIntField__return(uint32_t);
+  probe GetStaticLongField__entry(void*, void*, uintptr_t);
+  probe GetStaticLongField__return(uintptr_t);
+  probe GetStaticMethodID__entry(void*, void*, const char*, const char*);
+  probe GetStaticMethodID__return(uintptr_t);
+  probe GetStaticObjectField__entry(void*, void*, uintptr_t);
+  probe GetStaticObjectField__return(void*);
+  probe GetStaticShortField__entry(void*, void*, uintptr_t);
+  probe GetStaticShortField__return(uint16_t);
+  probe GetStringChars__entry(void*, void*, uintptr_t*);
+  probe GetStringChars__return(const uint16_t*);
+  probe GetStringCritical__entry(void*, void*, uintptr_t*);
+  probe GetStringCritical__return(const uint16_t*);
+  probe GetStringLength__entry(void*, void*);
+  probe GetStringLength__return(uintptr_t);
+  probe GetStringRegion__entry(void*, void*, uintptr_t, uintptr_t, uint16_t*);
+  probe GetStringRegion__return();
+  probe GetStringUTFChars__entry(void*, void*, uintptr_t*);
+  probe GetStringUTFChars__return(const char*);
+  probe GetStringUTFLength__entry(void*, void*);
+  probe GetStringUTFLength__return(uintptr_t);
+  probe GetStringUTFRegion__entry(void*, void*, uintptr_t, uintptr_t, char*);
+  probe GetStringUTFRegion__return();
+  probe GetSuperclass__entry(void*, void*);
+  probe GetSuperclass__return(void*);
+  probe GetVersion__entry(void*);
+  probe GetVersion__return(uint32_t);
+  probe IsAssignableFrom__entry(void*, void*, void*);
+  probe IsAssignableFrom__return(uintptr_t);
+  probe IsInstanceOf__entry(void*, void*, void*);
+  probe IsInstanceOf__return(uintptr_t);
+  probe IsSameObject__entry(void*, void*, void*);
+  probe IsSameObject__return(uintptr_t);
+  probe MonitorEnter__entry(void*, void*);
+  probe MonitorEnter__return(uint32_t);
+  probe MonitorExit__entry(void*, void*);
+  probe MonitorExit__return(uint32_t);
+  probe NewBooleanArray__entry(void*, uintptr_t);
+  probe NewBooleanArray__return(void*);
+  probe NewByteArray__entry(void*, uintptr_t);
+  probe NewByteArray__return(void*);
+  probe NewCharArray__entry(void*, uintptr_t);
+  probe NewCharArray__return(void*);
+  probe NewDirectByteBuffer__entry(void*, void*, uintptr_t);
+  probe NewDirectByteBuffer__return(void*);
+  probe NewDoubleArray__entry(void*, uintptr_t);
+  probe NewDoubleArray__return(void*);
+  probe NewFloatArray__entry(void*, uintptr_t);
+  probe NewFloatArray__return(void*);
+  probe NewGlobalRef__entry(void*, void*);
+  probe NewGlobalRef__return(void*);
+  probe NewIntArray__entry(void*, uintptr_t);
+  probe NewIntArray__return(void*);
+  probe NewLocalRef__entry(void*, void*);
+  probe NewLocalRef__return(void*);
+  probe NewLongArray__entry(void*, uintptr_t);
+  probe NewLongArray__return(void*);
+  probe NewObjectA__entry(void*, void*, uintptr_t);  
+  probe NewObjectA__return(void*);
+  probe NewObjectArray__entry(void*, uintptr_t, void*, void*);
+  probe NewObjectArray__return(void*);
+  probe NewObject__entry(void*, void*, uintptr_t); 
+  probe NewObject__return(void*);
+  probe NewObjectV__entry(void*, void*, uintptr_t);  
+  probe NewObjectV__return(void*);
+  probe NewShortArray__entry(void*, uintptr_t);
+  probe NewShortArray__return(void*);
+  probe NewString__entry(void*, const uint16_t*, uintptr_t);
+  probe NewString__return(void*);
+  probe NewStringUTF__entry(void*, const char*);
+  probe NewStringUTF__return(void*);
+  probe NewWeakGlobalRef__entry(void*, void*);
+  probe NewWeakGlobalRef__return(void*);
+  probe PopLocalFrame__entry(void*, void*);
+  probe PopLocalFrame__return(void*);
+  probe PushLocalFrame__entry(void*, uint32_t);
+  probe PushLocalFrame__return(uint32_t);
+  probe RegisterNatives__entry(void*, void*, const void*, uint32_t);  
+  probe RegisterNatives__return(uint32_t);
+  probe ReleaseBooleanArrayElements__entry(void*, void*, uintptr_t*, uint32_t);
+  probe ReleaseBooleanArrayElements__return();
+  probe ReleaseByteArrayElements__entry(void*, void*, char*, uint32_t);
+  probe ReleaseByteArrayElements__return();
+  probe ReleaseCharArrayElements__entry(void*, void*, uint16_t*, uint32_t);
+  probe ReleaseCharArrayElements__return();
+  probe ReleaseDoubleArrayElements__entry(void*, void*, double*, uint32_t);
+  probe ReleaseDoubleArrayElements__return();
+  probe ReleaseFloatArrayElements__entry(void*, void*, float*, uint32_t);
+  probe ReleaseFloatArrayElements__return();
+  probe ReleaseIntArrayElements__entry(void*, void*, uint32_t*, uint32_t);
+  probe ReleaseIntArrayElements__return();
+  probe ReleaseLongArrayElements__entry(void*, void*, uintptr_t*, uint32_t);
+  probe ReleaseLongArrayElements__return();
+  probe ReleasePrimitiveArrayCritical__entry(void*, void*, void*, uint32_t);
+  probe ReleasePrimitiveArrayCritical__return();
+  probe ReleaseShortArrayElements__entry(void*, void*, uint16_t*, uint32_t);
+  probe ReleaseShortArrayElements__return();
+  probe ReleaseStringChars__entry(void*, void*, const uint16_t*);
+  probe ReleaseStringChars__return();
+  probe ReleaseStringCritical__entry(void*, void*, const uint16_t*);
+  probe ReleaseStringCritical__return();
+  probe ReleaseStringUTFChars__entry(void*, void*, const char*);
+  probe ReleaseStringUTFChars__return();
+  probe SetBooleanArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, const uintptr_t*);
+  probe SetBooleanArrayRegion__return();
+  probe SetBooleanField__entry(void*, void*, uintptr_t, uintptr_t);
+  probe SetBooleanField__return();
+  probe SetByteArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, const char*);
+  probe SetByteArrayRegion__return();
+  probe SetByteField__entry(void*, void*, uintptr_t, char);
+  probe SetByteField__return();
+  probe SetCharArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, const uint16_t*);
+  probe SetCharArrayRegion__return();
+  probe SetCharField__entry(void*, void*, uintptr_t, uint16_t);
+  probe SetCharField__return();
+  probe SetDoubleArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, const double*);
+  probe SetDoubleArrayRegion__return();
+  probe SetDoubleField__entry(void*, void*, uintptr_t);
+  probe SetDoubleField__return();
+  probe SetFloatArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, const float*);
+  probe SetFloatArrayRegion__return();
+  probe SetFloatField__entry(void*, void*, uintptr_t);
+  probe SetFloatField__return();
+  probe SetIntArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, const uint32_t*);
+  probe SetIntArrayRegion__return();
+  probe SetIntField__entry(void*, void*, uintptr_t, uint32_t);
+  probe SetIntField__return();
+  probe SetLongArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, const uintptr_t*);
+  probe SetLongArrayRegion__return();
+  probe SetLongField__entry(void*, void*, uintptr_t, uintptr_t);
+  probe SetLongField__return();
+  probe SetObjectArrayElement__entry(void*, void*, uintptr_t, void*);
+  probe SetObjectArrayElement__return();
+  probe SetObjectField__entry(void*, void*, uintptr_t, void*);
+  probe SetObjectField__return();
+  probe SetShortArrayRegion__entry(void*, void*, uintptr_t, uintptr_t, const uint16_t*);
+  probe SetShortArrayRegion__return();
+  probe SetShortField__entry(void*, void*, uintptr_t, uint16_t);
+  probe SetShortField__return();
+  probe SetStaticBooleanField__entry(void*, void*, uintptr_t, uintptr_t);
+  probe SetStaticBooleanField__return();
+  probe SetStaticByteField__entry(void*, void*, uintptr_t, char);
+  probe SetStaticByteField__return();
+  probe SetStaticCharField__entry(void*, void*, uintptr_t, uint16_t);
+  probe SetStaticCharField__return();
+  probe SetStaticDoubleField__entry(void*, void*, uintptr_t);
+  probe SetStaticDoubleField__return();
+  probe SetStaticFloatField__entry(void*, void*, uintptr_t);
+  probe SetStaticFloatField__return();
+  probe SetStaticIntField__entry(void*, void*, uintptr_t, uint32_t);
+  probe SetStaticIntField__return();
+  probe SetStaticLongField__entry(void*, void*, uintptr_t, uintptr_t);
+  probe SetStaticLongField__return();
+  probe SetStaticObjectField__entry(void*, void*, uintptr_t, void*);
+  probe SetStaticObjectField__return();
+  probe SetStaticShortField__entry(void*, void*, uintptr_t, uint16_t);
+  probe SetStaticShortField__return();
+  probe Throw__entry(void*, void*);
+  probe Throw__return(intptr_t);
+  probe ThrowNew__entry(void*, void*, const char*);  
+  probe ThrowNew__return(intptr_t);  
+  probe ToReflectedField__entry(void*, void*, uintptr_t, uintptr_t);
+  probe ToReflectedField__return(void*);
+  probe ToReflectedMethod__entry(void*, void*, uintptr_t, uintptr_t);
+  probe ToReflectedMethod__return(void*);
+  probe UnregisterNatives__entry(void*, void*);  
+  probe UnregisterNatives__return(uint32_t);
+};
+
+#pragma D attributes Standard/Standard/Common provider hotspot_jni provider
+#pragma D attributes Private/Private/Unknown provider hotspot_jni module
+#pragma D attributes Private/Private/Unknown provider hotspot_jni function
+#pragma D attributes Standard/Standard/Common provider hotspot_jni name
+#pragma D attributes Evolving/Evolving/Common provider hotspot_jni args
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/hs_private.d	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ *  
+ */
+
+provider hs_private {
+  probe hashtable__new_entry(void*, uint32_t, uintptr_t, void*); 
+  probe safepoint__begin();
+  probe safepoint__end();
+  probe cms__initmark__begin();
+  probe cms__initmark__end();
+  probe cms__remark__begin();
+  probe cms__remark__end();
+};
+
+#pragma D attributes Private/Private/Common provider hs_private provider
+#pragma D attributes Private/Private/Unknown provider hs_private module
+#pragma D attributes Private/Private/Unknown provider hs_private function
+#pragma D attributes Private/Private/Common provider hs_private name
+#pragma D attributes Private/Private/Common provider hs_private args
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/jhelper.d	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *  
+ */
+
+/* This file is auto-generated */
+#include "JvmOffsetsIndex.h"
+
+#define DEBUG
+
+#ifdef DEBUG
+#define MARK_LINE this->line = __LINE__
+#else
+#define MARK_LINE 
+#endif
+
+#ifdef _LP64
+#define STACK_BIAS 0x7ff
+#define pointer uint64_t
+#else
+#define STACK_BIAS 0
+#define pointer uint32_t
+#endif
+
+extern pointer __JvmOffsets;
+
+extern pointer __1cJCodeCacheF_heap_;
+extern pointer __1cIUniverseP_methodKlassObj_;
+extern pointer __1cIUniverseO_collectedHeap_;
+extern pointer __1cIUniverseL_narrow_oop_;
+#ifdef _LP64
+extern pointer UseCompressedOops;
+#endif
+
+extern pointer __1cHnmethodG__vtbl_;
+extern pointer __1cKBufferBlobG__vtbl_;
+
+#define copyin_ptr(ADDR)    *(pointer*)  copyin((pointer) (ADDR), sizeof(pointer))
+#define copyin_uchar(ADDR)  *(uchar_t*)  copyin((pointer) (ADDR), sizeof(uchar_t))
+#define copyin_uint16(ADDR) *(uint16_t*) copyin((pointer) (ADDR), sizeof(uint16_t))
+#define copyin_uint32(ADDR) *(uint32_t*) copyin((pointer) (ADDR), sizeof(uint32_t))
+#define copyin_int32(ADDR)  *(int32_t*)  copyin((pointer) (ADDR), sizeof(int32_t))
+#define copyin_uint8(ADDR)  *(uint8_t*)  copyin((pointer) (ADDR), sizeof(uint8_t))
+
+#define SAME(x) x
+#define copyin_offset(JVM_CONST)  JVM_CONST = \
+	copyin_int32(JvmOffsetsPtr + SAME(IDX_)JVM_CONST * sizeof(int32_t))
+
+int init_done;
+
+dtrace:helper:ustack:
+{
+  MARK_LINE;
+  this->done = 0;
+  /*
+   * TBD:
+   * Here we initialize init_done, otherwise jhelper does not work.
+   * Therefore, copyin_offset() statements work multiple times now.
+   * There is a hope we could avoid it in the future, and so,
+   * this initialization can be removed.
+   */
+  init_done  = 0;
+  this->error = (char *) NULL;
+  this->result = (char *) NULL;
+  this->methodOop = 0;
+  this->codecache = 0;
+  this->klass = (pointer) NULL;
+  this->vtbl  = (pointer) NULL;
+  this->suffix = '\0';
+}
+
+dtrace:helper:ustack:
+{
+  MARK_LINE;
+  /* Initialization of JvmOffsets constants */
+  JvmOffsetsPtr = (pointer) &``__JvmOffsets;
+}
+
+dtrace:helper:ustack:
+/!init_done && !this->done/
+{
+  MARK_LINE;
+  init_done = 1;
+
+  copyin_offset(COMPILER);
+  copyin_offset(OFFSET_CollectedHeap_reserved);
+  copyin_offset(OFFSET_MemRegion_start);
+  copyin_offset(OFFSET_MemRegion_word_size);
+  copyin_offset(SIZE_HeapWord);
+
+  copyin_offset(OFFSET_interpreter_frame_method);
+  copyin_offset(OFFSET_Klass_name);
+  copyin_offset(OFFSET_constantPoolOopDesc_pool_holder);
+
+  copyin_offset(OFFSET_HeapBlockHeader_used);
+  copyin_offset(OFFSET_oopDesc_metadata);
+
+  copyin_offset(OFFSET_Symbol_length);
+  copyin_offset(OFFSET_Symbol_body);
+
+  copyin_offset(OFFSET_methodOopDesc_constMethod);
+  copyin_offset(OFFSET_methodOopDesc_constants);
+  copyin_offset(OFFSET_constMethodOopDesc_name_index);
+  copyin_offset(OFFSET_constMethodOopDesc_signature_index);
+
+  copyin_offset(OFFSET_CodeHeap_memory);
+  copyin_offset(OFFSET_CodeHeap_segmap);
+  copyin_offset(OFFSET_CodeHeap_log2_segment_size);
+
+  copyin_offset(OFFSET_VirtualSpace_low);
+  copyin_offset(OFFSET_VirtualSpace_high);
+
+  copyin_offset(OFFSET_CodeBlob_name);
+
+  copyin_offset(OFFSET_nmethod_method);
+  copyin_offset(SIZE_HeapBlockHeader);
+  copyin_offset(SIZE_oopDesc);
+  copyin_offset(SIZE_constantPoolOopDesc);
+
+  copyin_offset(OFFSET_NarrowOopStruct_base);
+  copyin_offset(OFFSET_NarrowOopStruct_shift);
+
+  /*
+   * The PC to translate is in arg0.
+   */
+  this->pc = arg0;
+
+  /*
+   * The methodOopPtr is in %l2 on SPARC.  This can be found at
+   * offset 8 from the frame pointer on 32-bit processes.
+   */
+#if   defined(__sparc)
+  this->methodOopPtr = copyin_ptr(arg1 + 2 * sizeof(pointer) + STACK_BIAS);
+#elif defined(__i386) || defined(__amd64)
+  this->methodOopPtr = copyin_ptr(arg1 + OFFSET_interpreter_frame_method);
+#else
+#error "Don't know architecture"
+#endif
+
+  this->Universe_methodKlassOop = copyin_ptr(&``__1cIUniverseP_methodKlassObj_);
+  this->CodeCache_heap_address = copyin_ptr(&``__1cJCodeCacheF_heap_);
+
+  /* Reading volatile values */
+#ifdef _LP64
+  this->Use_Compressed_Oops  = copyin_uint8(&``UseCompressedOops);
+#else
+  this->Use_Compressed_Oops  = 0;
+#endif
+
+  this->Universe_narrow_oop_base  = copyin_ptr(&``__1cIUniverseL_narrow_oop_ +
+                                               OFFSET_NarrowOopStruct_base);
+  this->Universe_narrow_oop_shift = copyin_int32(&``__1cIUniverseL_narrow_oop_ +
+                                                 OFFSET_NarrowOopStruct_shift);
+
+  this->CodeCache_low = copyin_ptr(this->CodeCache_heap_address + 
+      OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
+
+  this->CodeCache_high = copyin_ptr(this->CodeCache_heap_address +
+      OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
+
+  this->CodeCache_segmap_low = copyin_ptr(this->CodeCache_heap_address +
+      OFFSET_CodeHeap_segmap + OFFSET_VirtualSpace_low);
+
+  this->CodeCache_segmap_high = copyin_ptr(this->CodeCache_heap_address +
+      OFFSET_CodeHeap_segmap + OFFSET_VirtualSpace_high);
+
+  this->CodeHeap_log2_segment_size = copyin_uint32(
+      this->CodeCache_heap_address + OFFSET_CodeHeap_log2_segment_size);
+
+  /*
+   * Get Java heap bounds
+   */
+  this->Universe_collectedHeap = copyin_ptr(&``__1cIUniverseO_collectedHeap_);
+  this->heap_start = copyin_ptr(this->Universe_collectedHeap +
+      OFFSET_CollectedHeap_reserved +
+      OFFSET_MemRegion_start);
+  this->heap_size = SIZE_HeapWord *
+    copyin_ptr(this->Universe_collectedHeap +
+        OFFSET_CollectedHeap_reserved +
+        OFFSET_MemRegion_word_size
+        );
+  this->heap_end = this->heap_start + this->heap_size;
+}
+
+dtrace:helper:ustack:
+/!this->done &&
+this->CodeCache_low <= this->pc && this->pc < this->CodeCache_high/
+{
+  MARK_LINE;
+  this->codecache = 1;
+
+  /*
+   * Find start.
+   */
+  this->segment = (this->pc - this->CodeCache_low) >>
+    this->CodeHeap_log2_segment_size;
+  this->block = this->CodeCache_segmap_low;
+  this->tag = copyin_uchar(this->block + this->segment);
+  "second";
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache && this->tag > 0/
+{
+  MARK_LINE;
+  this->tag = copyin_uchar(this->block + this->segment);
+  this->segment = this->segment - this->tag;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache && this->tag > 0/
+{
+  MARK_LINE;
+  this->tag = copyin_uchar(this->block + this->segment);
+  this->segment = this->segment - this->tag;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache && this->tag > 0/
+{
+  MARK_LINE;
+  this->tag = copyin_uchar(this->block + this->segment);
+  this->segment = this->segment - this->tag;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache && this->tag > 0/
+{
+  MARK_LINE;
+  this->tag = copyin_uchar(this->block + this->segment);
+  this->segment = this->segment - this->tag;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache && this->tag > 0/
+{
+  MARK_LINE;
+  this->tag = copyin_uchar(this->block + this->segment);
+  this->segment = this->segment - this->tag;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache && this->tag > 0/
+{
+  MARK_LINE;
+  this->error = "<couldn't find start>";
+  this->done = 1;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache/
+{
+  MARK_LINE;
+  this->block = this->CodeCache_low +
+    (this->segment << this->CodeHeap_log2_segment_size);
+  this->used = copyin_uint32(this->block + OFFSET_HeapBlockHeader_used);
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache && !this->used/
+{
+  MARK_LINE;
+  this->error = "<block not in use>";
+  this->done = 1;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache/
+{
+  MARK_LINE;
+  this->start = this->block + SIZE_HeapBlockHeader;
+  this->vtbl = copyin_ptr(this->start);
+
+  this->nmethod_vtbl            = (pointer) &``__1cHnmethodG__vtbl_;
+  this->BufferBlob_vtbl         = (pointer) &``__1cKBufferBlobG__vtbl_;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->vtbl == this->nmethod_vtbl/
+{
+  MARK_LINE;
+  this->methodOopPtr = copyin_ptr(this->start + OFFSET_nmethod_method);
+  this->suffix = '*';
+  this->methodOop = 1;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->vtbl == this->BufferBlob_vtbl/
+{
+  MARK_LINE;
+  this->name = copyin_ptr(this->start + OFFSET_CodeBlob_name);
+}
+
+dtrace:helper:ustack:
+/!this->done && this->vtbl == this->BufferBlob_vtbl &&
+this->Use_Compressed_Oops == 0 &&
+this->methodOopPtr > this->heap_start && this->methodOopPtr < this->heap_end/
+{
+  MARK_LINE;
+  this->klass = copyin_ptr(this->methodOopPtr + OFFSET_oopDesc_metadata);
+  this->methodOop = this->klass == this->Universe_methodKlassOop;
+  this->done = !this->methodOop;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->vtbl == this->BufferBlob_vtbl &&
+this->Use_Compressed_Oops != 0 &&
+this->methodOopPtr > this->heap_start && this->methodOopPtr < this->heap_end/
+{
+  MARK_LINE;
+  /*
+   * Read compressed pointer and  decode heap oop, same as oop.inline.hpp
+   */
+  this->cklass = copyin_uint32(this->methodOopPtr + OFFSET_oopDesc_metadata);
+  this->klass = (uint64_t)((uintptr_t)this->Universe_narrow_oop_base +
+                ((uintptr_t)this->cklass << this->Universe_narrow_oop_shift));
+  this->methodOop = this->klass == this->Universe_methodKlassOop;
+  this->done = !this->methodOop;
+}
+
+dtrace:helper:ustack:
+/!this->done && !this->methodOop/
+{
+  MARK_LINE;
+  this->name = copyin_ptr(this->start + OFFSET_CodeBlob_name);
+  this->result = this->name != 0 ? copyinstr(this->name) : "<CodeBlob>";
+  this->done = 1;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->methodOop/
+{
+  MARK_LINE;
+  this->constMethod = copyin_ptr(this->methodOopPtr +
+      OFFSET_methodOopDesc_constMethod);
+
+  this->nameIndex = copyin_uint16(this->constMethod +
+      OFFSET_constMethodOopDesc_name_index);
+
+  this->signatureIndex = copyin_uint16(this->constMethod +
+      OFFSET_constMethodOopDesc_signature_index);
+
+  this->constantPool = copyin_ptr(this->methodOopPtr +
+      OFFSET_methodOopDesc_constants);
+
+  this->nameSymbol = copyin_ptr(this->constantPool +
+      this->nameIndex * sizeof (pointer) + SIZE_constantPoolOopDesc);
+
+  this->nameSymbolLength = copyin_uint16(this->nameSymbol +
+      OFFSET_Symbol_length);
+
+  this->signatureSymbol = copyin_ptr(this->constantPool +
+      this->signatureIndex * sizeof (pointer) + SIZE_constantPoolOopDesc);
+
+  this->signatureSymbolLength = copyin_uint16(this->signatureSymbol +
+      OFFSET_Symbol_length);
+
+  this->klassPtr = copyin_ptr(this->constantPool +
+      OFFSET_constantPoolOopDesc_pool_holder);
+
+  this->klassSymbol = copyin_ptr(this->klassPtr +
+      OFFSET_Klass_name + SIZE_oopDesc);
+
+  this->klassSymbolLength = copyin_uint16(this->klassSymbol +
+      OFFSET_Symbol_length);
+
+  /*
+   * Enough for three strings, plus the '.', plus the trailing '\0'.
+   */
+  this->result = (char *) alloca(this->klassSymbolLength +
+      this->nameSymbolLength +
+      this->signatureSymbolLength + 2 + 1);
+
+  copyinto(this->klassSymbol + OFFSET_Symbol_body,
+      this->klassSymbolLength, this->result);
+
+  /*
+   * Add the '.' between the class and the name.
+   */
+  this->result[this->klassSymbolLength] = '.';
+
+  copyinto(this->nameSymbol + OFFSET_Symbol_body,
+      this->nameSymbolLength,
+      this->result + this->klassSymbolLength + 1);
+
+  copyinto(this->signatureSymbol + OFFSET_Symbol_body,
+      this->signatureSymbolLength,
+      this->result + this->klassSymbolLength +
+      this->nameSymbolLength + 1);
+
+  /*
+   * Now we need to add a trailing '\0' and possibly a tag character.
+   */
+  this->result[this->klassSymbolLength + 1 + 
+      this->nameSymbolLength +
+      this->signatureSymbolLength] = this->suffix;
+  this->result[this->klassSymbolLength + 2 + 
+      this->nameSymbolLength +
+      this->signatureSymbolLength] = '\0';
+
+  this->done = 1;
+}
+
+dtrace:helper:ustack:
+/this->done && this->error == (char *) NULL/
+{
+  this->result;   
+}
+
+dtrace:helper:ustack:
+/this->done && this->error != (char *) NULL/
+{
+  this->error;
+}
+
+dtrace:helper:ustack:
+/!this->done && this->codecache/
+{
+  this->done = 1;
+  "error";
+}
+
+
+dtrace:helper:ustack:
+/!this->done/
+{
+  NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/jvm_dtrace.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,565 @@
+/*
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 <door.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <thread.h>
+#include <unistd.h>
+#include "jvm_dtrace.h"
+
+// NOTE: These constants are used in JVM code as well.
+// KEEP JVM CODE IN SYNC if you are going to change these...
+
+#define DTRACE_ALLOC_PROBES   0x1
+#define DTRACE_METHOD_PROBES  0x2
+#define DTRACE_MONITOR_PROBES 0x4
+#define DTRACE_ALL_PROBES     -1
+
+// generic error messages
+#define JVM_ERR_OUT_OF_MEMORY            "out of memory (native heap)"
+#define JVM_ERR_INVALID_PARAM            "invalid input parameter(s)"
+#define JVM_ERR_NULL_PARAM               "input paramater is NULL"
+
+// error messages for attach
+#define JVM_ERR_CANT_OPEN_DOOR           "cannot open door file"
+#define JVM_ERR_CANT_CREATE_ATTACH_FILE  "cannot create attach file"
+#define JVM_ERR_DOOR_FILE_PERMISSION     "door file is not secure"
+#define JVM_ERR_CANT_SIGNAL              "cannot send SIGQUIT to target"
+
+// error messages for enable probe
+#define JVM_ERR_DOOR_CMD_SEND            "door command send failed"
+#define JVM_ERR_DOOR_CANT_READ_STATUS    "cannot read door command status"
+#define JVM_ERR_DOOR_CMD_STATUS          "door command error status"
+
+// error message for detach
+#define JVM_ERR_CANT_CLOSE_DOOR          "cannot close door file"
+
+#define RESTARTABLE(_cmd, _result) do { \
+    do { \
+        _result = _cmd; \
+    } while((_result == -1) && (errno == EINTR)); \
+} while(0)
+
+struct _jvm_t {
+    pid_t pid;
+    int door_fd;
+};
+
+static int libjvm_dtrace_debug;
+static void print_debug(const char* fmt,...) {
+    if (libjvm_dtrace_debug) {
+        va_list alist;
+        va_start(alist, fmt);
+        fputs("libjvm_dtrace DEBUG: ", stderr);
+        vfprintf(stderr, fmt, alist);
+        va_end(alist);
+    }
+}
+
+/* Key for thread local error message */
+static thread_key_t jvm_error_key;
+
+/* init function for this library */
+static void init_jvm_dtrace() {
+    /* check for env. var for debug mode */
+    libjvm_dtrace_debug = getenv("LIBJVM_DTRACE_DEBUG") != NULL;
+    /* create key for thread local error message */
+    if (thr_keycreate(&jvm_error_key, NULL) != 0) {
+        print_debug("can't create thread_key_t for jvm error key\n");
+        // exit(1); ?
+    }
+}
+
+#pragma init(init_jvm_dtrace)
+
+/* set thread local error message */
+static void set_jvm_error(const char* msg) {
+    thr_setspecific(jvm_error_key, (void*)msg);
+}
+
+/* clear thread local error message */
+static void clear_jvm_error() {
+    thr_setspecific(jvm_error_key, NULL);
+}
+
+/* file handling functions that can handle interrupt */
+
+static int file_open(const char* path, int flag) {
+    int ret;
+    RESTARTABLE(open(path, flag), ret);
+    return ret;
+}
+
+static int file_close(int fd) {
+    int ret;
+    RESTARTABLE(close(fd), ret);
+    return ret;
+}
+
+static int file_read(int fd, char* buf, int len) {
+    int ret;
+    RESTARTABLE(read(fd, buf, len), ret);
+    return ret;
+}
+
+/* send SIGQUIT signal to given process */
+static int send_sigquit(pid_t pid) {
+    int ret;
+    RESTARTABLE(kill(pid, SIGQUIT), ret);
+    return ret;
+}
+
+/* called to check permissions on attach file */
+static int check_permission(const char* path) {
+    struct stat64 sb;
+    uid_t uid, gid;
+    int res;
+
+    /*
+     * Check that the path is owned by the effective uid/gid of this
+     * process. Also check that group/other access is not allowed.
+     */
+    uid = geteuid();
+    gid = getegid();
+
+    res = stat64(path, &sb);
+    if (res != 0) {
+        print_debug("stat failed for %s\n", path);
+        return -1;
+    }
+
+    if ((sb.st_uid != uid) || (sb.st_gid != gid) ||
+        ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0)) {
+        print_debug("well-known file %s is not secure\n", path);
+        return -1;
+    }
+    return 0;
+}
+
+#define ATTACH_FILE_PATTERN "/tmp/.attach_pid%d"
+
+/* fill-in the name of attach file name in given buffer */
+static void fill_attach_file_name(char* path, int len, pid_t pid) {
+    memset(path, 0, len);
+    sprintf(path, ATTACH_FILE_PATTERN, pid);
+}
+
+#define DOOR_FILE_PATTERN "/tmp/.java_pid%d"
+
+/* open door file for the given JVM */
+static int open_door(pid_t pid) {
+    char path[PATH_MAX + 1];
+    int fd;
+
+    sprintf(path, DOOR_FILE_PATTERN, pid);
+    fd = file_open(path, O_RDONLY);
+    if (fd < 0) {
+        set_jvm_error(JVM_ERR_CANT_OPEN_DOOR);
+        print_debug("cannot open door file %s\n", path);
+        return -1;
+    }
+    print_debug("opened door file %s\n", path);
+    if (check_permission(path) != 0) {
+        set_jvm_error(JVM_ERR_DOOR_FILE_PERMISSION);
+        print_debug("check permission failed for %s\n", path);
+        file_close(fd);
+        fd = -1;
+    }
+    return fd;
+}
+
+/* create attach file for given process */
+static int create_attach_file(pid_t pid) {
+    char path[PATH_MAX + 1];
+    int fd;
+    fill_attach_file_name(path, sizeof(path), pid);
+    fd = file_open(path, O_CREAT | O_RDWR);
+    if (fd < 0) {
+        set_jvm_error(JVM_ERR_CANT_CREATE_ATTACH_FILE);
+        print_debug("cannot create file %s\n", path);
+    } else {
+        print_debug("created attach file %s\n", path);
+    }
+    return fd;
+}
+
+/* delete attach file for given process */
+static void delete_attach_file(pid_t pid) {
+    char path[PATH_MAX + 1];
+    fill_attach_file_name(path, sizeof(path), pid);
+    int res = unlink(path);
+    if (res) {
+        print_debug("cannot delete attach file %s\n", path);
+    } else {
+        print_debug("deleted attach file %s\n", path);
+    }
+}
+
+/* attach to given JVM */
+jvm_t* jvm_attach(pid_t pid) {
+    jvm_t* jvm;
+    int door_fd, attach_fd, i;
+
+    jvm = (jvm_t*) calloc(1, sizeof(jvm_t));
+    if (jvm == NULL) {
+        set_jvm_error(JVM_ERR_OUT_OF_MEMORY);
+        print_debug("calloc failed in %s at %d\n", __FILE__, __LINE__);
+        return NULL;
+    }
+    jvm->pid = pid;
+    attach_fd = -1;
+
+    door_fd = open_door(pid);
+    if (door_fd < 0) {
+        print_debug("trying to create attach file\n");
+        if ((attach_fd = create_attach_file(pid)) < 0) {
+            goto quit;
+        }
+
+        /* send QUIT signal to the target so that it will
+         * check for the attach file.
+         */
+        if (send_sigquit(pid) != 0) {
+            set_jvm_error(JVM_ERR_CANT_SIGNAL);
+            print_debug("sending SIGQUIT failed\n");
+            goto quit;
+        }
+
+        /* give the target VM time to start the attach mechanism */
+        do {
+            int res;
+            RESTARTABLE(poll(0, 0, 200), res);
+            door_fd = open_door(pid);
+            i++;
+        } while (i <= 50 && door_fd == -1);
+        if (door_fd < 0) {
+            print_debug("Unable to open door to process %d\n", pid);
+            goto quit;
+        }
+    }
+
+quit:
+    if (attach_fd >= 0) {
+        file_close(attach_fd);
+        delete_attach_file(jvm->pid);
+    }
+    if (door_fd >= 0) {
+        jvm->door_fd = door_fd;
+        clear_jvm_error();
+    } else {
+        free(jvm);
+        jvm = NULL;
+    }
+    return jvm;
+}
+
+/* return the last thread local error message */
+const char* jvm_get_last_error() {
+    const char* res = NULL;
+    thr_getspecific(jvm_error_key, (void**)&res);
+    return res;
+}
+
+/* detach the givenb JVM */
+int jvm_detach(jvm_t* jvm) {
+    if (jvm) {
+        int res;
+        if (jvm->door_fd != -1) {
+            if (file_close(jvm->door_fd) != 0) {
+                set_jvm_error(JVM_ERR_CANT_CLOSE_DOOR);
+                res = -1;
+            } else {
+                clear_jvm_error();
+                res = 0;
+            }
+        }
+        free(jvm);
+        return res;
+    } else {
+        set_jvm_error(JVM_ERR_NULL_PARAM);
+        print_debug("jvm_t* is NULL\n");
+        return -1;
+    }
+}
+
+/*
+ * A simple table to translate some known errors into reasonable
+ * error messages
+ */
+static struct {
+    int err;
+    const char* msg;
+} const error_messages[] = {
+    { 100,      "Bad request" },
+    { 101,      "Protocol mismatch" },
+    { 102,      "Resource failure" },
+    { 103,      "Internal error" },
+    { 104,      "Permission denied" },
+};
+
+/*
+ * Lookup the given error code and return the appropriate
+ * message. If not found return NULL.
+ */
+static const char* translate_error(int err) {
+    int table_size = sizeof(error_messages) / sizeof(error_messages[0]);
+    int i;
+
+    for (i=0; i<table_size; i++) {
+        if (err == error_messages[i].err) {
+            return error_messages[i].msg;
+        }
+    }
+    return NULL;
+}
+
+/*
+ * Current protocol version
+ */
+static const char* PROTOCOL_VERSION = "1";
+
+#define RES_BUF_SIZE 128
+
+/*
+ * Enqueue attach-on-demand command to the given JVM
+ */
+static
+int enqueue_command(jvm_t* jvm, const char* cstr, int arg_count, const char** args) {
+    size_t size;
+    door_arg_t door_args;
+    char res_buffer[RES_BUF_SIZE];
+    int rc, i;
+    char* buf = NULL;
+    int result = -1;
+
+    /*
+     * First we get the command string and create the start of the
+     * argument string to send to the target VM:
+     * <ver>\0<cmd>\0
+     */
+    if (cstr == NULL) {
+        print_debug("command name is NULL\n");
+        goto quit;
+    }
+    size = strlen(PROTOCOL_VERSION) + strlen(cstr) + 2;
+    buf = (char*)malloc(size);
+    if (buf != NULL) {
+        char* pos = buf;
+        strcpy(buf, PROTOCOL_VERSION);
+        pos += strlen(PROTOCOL_VERSION)+1;
+        strcpy(pos, cstr);
+    } else {
+        set_jvm_error(JVM_ERR_OUT_OF_MEMORY);
+        print_debug("malloc failed at %d in %s\n", __LINE__, __FILE__);
+        goto quit;
+    }
+
+    /*
+     * Next we iterate over the arguments and extend the buffer
+     * to include them.
+     */
+    for (i=0; i<arg_count; i++) {
+        cstr = args[i];
+        if (cstr != NULL) {
+            size_t len = strlen(cstr);
+            char* newbuf = (char*)realloc(buf, size+len+1);
+            if (newbuf == NULL) {
+                set_jvm_error(JVM_ERR_OUT_OF_MEMORY);
+                print_debug("realloc failed in %s at %d\n", __FILE__, __LINE__);
+                goto quit;
+            }
+            buf = newbuf;
+            strcpy(buf+size, cstr);
+            size += len+1;
+        }
+    }
+
+    /*
+     * The arguments to the door function are in 'buf' so we now
+     * do the door call
+     */
+    door_args.data_ptr = buf;
+    door_args.data_size = size;
+    door_args.desc_ptr = NULL;
+    door_args.desc_num = 0;
+    door_args.rbuf = (char*)&res_buffer;
+    door_args.rsize = sizeof(res_buffer);
+
+    RESTARTABLE(door_call(jvm->door_fd, &door_args), rc);
+
+    /*
+     * door_call failed
+     */
+    if (rc == -1) {
+        print_debug("door_call failed\n");
+    } else {
+        /*
+         * door_call succeeded but the call didn't return the the expected jint.
+         */
+        if (door_args.data_size < sizeof(int)) {
+            print_debug("Enqueue error - reason unknown as result is truncated!");
+        } else {
+            int* res = (int*)(door_args.data_ptr);
+            if (*res != 0) {
+                const char* msg = translate_error(*res);
+                if (msg == NULL) {
+                    print_debug("Unable to enqueue command to target VM: %d\n", *res);
+                } else {
+                    print_debug("Unable to enqueue command to target VM: %s\n", msg);
+                }
+            } else {
+                /*
+                 * The door call should return a file descriptor to one end of
+                 * a socket pair
+                 */
+                if ((door_args.desc_ptr != NULL) &&
+                    (door_args.desc_num == 1) &&
+                    (door_args.desc_ptr->d_attributes & DOOR_DESCRIPTOR)) {
+                    result = door_args.desc_ptr->d_data.d_desc.d_descriptor;
+                } else {
+                    print_debug("Reply from enqueue missing descriptor!\n");
+                }
+            }
+        }
+    }
+
+quit:
+    if (buf) free(buf);
+    return result;
+}
+
+/* read status code for a door command */
+static int read_status(int fd) {
+    char ch, buf[16];
+    int index = 0;
+
+    while (1) {
+        if (file_read(fd, &ch, sizeof(ch)) != sizeof(ch)) {
+            set_jvm_error(JVM_ERR_DOOR_CANT_READ_STATUS);
+            print_debug("door cmd status: read status failed\n");
+            return -1;
+        }
+        buf[index++] = ch;
+        if (ch == '\n') {
+            buf[index - 1] = '\0';
+            return atoi(buf);
+        }
+        if (index == sizeof(buf)) {
+            set_jvm_error(JVM_ERR_DOOR_CANT_READ_STATUS);
+            print_debug("door cmd status: read status overflow\n");
+            return -1;
+        }
+    }
+}
+
+static const char* ENABLE_DPROBES_CMD = "enabledprobes";
+
+/* enable one or more DTrace probes for a given JVM */
+int jvm_enable_dtprobes(jvm_t* jvm, int num_probe_types, const char** probe_types) {
+    int fd, status = 0;
+    char ch;
+    const char* args[1];
+    char buf[16];
+    int probe_type = 0, index;
+    int count = 0;
+
+    if (jvm == NULL) {
+        set_jvm_error(JVM_ERR_NULL_PARAM);
+        print_debug("jvm_t* is NULL\n");
+        return -1;
+    }
+
+    if (num_probe_types == 0 || probe_types == NULL ||
+        probe_types[0] == NULL) {
+        set_jvm_error(JVM_ERR_INVALID_PARAM);
+        print_debug("invalid probe type argument(s)\n");
+        return -1;
+    }
+
+    for (index = 0; index < num_probe_types; index++) {
+        const char* p = probe_types[index];
+        if (strcmp(p, JVM_DTPROBE_OBJECT_ALLOC) == 0) {
+            probe_type |= DTRACE_ALLOC_PROBES;
+            count++;
+        } else if (strcmp(p, JVM_DTPROBE_METHOD_ENTRY) == 0 ||
+                   strcmp(p, JVM_DTPROBE_METHOD_RETURN) == 0) {
+            probe_type |= DTRACE_METHOD_PROBES;
+            count++;
+        } else if (strcmp(p, JVM_DTPROBE_MONITOR_ENTER) == 0   ||
+                   strcmp(p, JVM_DTPROBE_MONITOR_ENTERED) == 0 ||
+                   strcmp(p, JVM_DTPROBE_MONITOR_EXIT) == 0    ||
+                   strcmp(p, JVM_DTPROBE_MONITOR_WAIT) == 0    ||
+                   strcmp(p, JVM_DTPROBE_MONITOR_WAITED) == 0  ||
+                   strcmp(p, JVM_DTPROBE_MONITOR_NOTIFY) == 0  ||
+                   strcmp(p, JVM_DTPROBE_MONITOR_NOTIFYALL) == 0) {
+            probe_type |= DTRACE_MONITOR_PROBES;
+            count++;
+        } else if (strcmp(p, JVM_DTPROBE_ALL) == 0) {
+            probe_type |= DTRACE_ALL_PROBES;
+            count++;
+        }
+    }
+
+    if (count == 0) {
+        return count;
+    }
+    sprintf(buf, "%d", probe_type);
+    args[0] = buf;
+
+    fd = enqueue_command(jvm, ENABLE_DPROBES_CMD, 1, args);
+    if (fd < 0) {
+        set_jvm_error(JVM_ERR_DOOR_CMD_SEND);
+        return -1;
+    }
+
+    status = read_status(fd);
+    // non-zero status is error
+    if (status) {
+        set_jvm_error(JVM_ERR_DOOR_CMD_STATUS);
+        print_debug("%s command failed (status: %d) in target JVM\n",
+                    ENABLE_DPROBES_CMD, status);
+        file_close(fd);
+        return -1;
+    }
+    // read from stream until EOF
+    while (file_read(fd, &ch, sizeof(ch)) == sizeof(ch)) {
+        if (libjvm_dtrace_debug) {
+            printf("%c", ch);
+        }
+    }
+
+    file_close(fd);
+    clear_jvm_error();
+    return count;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/jvm_dtrace.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 _JVM_DTRACE_H_
+#define _JVM_DTRACE_H_
+
+/*
+ * Interface to dynamically turn on probes in Hotspot JVM. Currently,
+ * this interface can be used to dynamically enable certain DTrace
+ * probe points that are costly to have "always on".
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+
+
+struct _jvm_t;
+typedef struct _jvm_t jvm_t;
+
+
+/* Attach to the given JVM process. Returns NULL on failure.
+   jvm_get_last_error() returns last error message. */
+jvm_t* jvm_attach(pid_t pid);
+
+/* Returns the last error message from this library or NULL if none. */
+const char* jvm_get_last_error();
+
+/* few well-known probe type constants for 'probe_types' param below */
+
+#define JVM_DTPROBE_METHOD_ENTRY         "method-entry"
+#define JVM_DTPROBE_METHOD_RETURN        "method-return"
+#define JVM_DTPROBE_MONITOR_ENTER        "monitor-contended-enter"
+#define JVM_DTPROBE_MONITOR_ENTERED      "monitor-contended-entered"
+#define JVM_DTPROBE_MONITOR_EXIT         "monitor-contended-exit"
+#define JVM_DTPROBE_MONITOR_WAIT         "monitor-wait"
+#define JVM_DTPROBE_MONITOR_WAITED       "monitor-waited"
+#define JVM_DTPROBE_MONITOR_NOTIFY       "monitor-notify"
+#define JVM_DTPROBE_MONITOR_NOTIFYALL    "monitor-notifyall"
+#define JVM_DTPROBE_OBJECT_ALLOC         "object-alloc"
+#define JVM_DTPROBE_ALL                  "*"
+
+/* Enable the specified DTrace probes of given probe types on
+ * the specified JVM. Returns >= 0 on success, -1 on failure.
+ * On success, this returns number of probe_types enabled.
+ * On failure, jvm_get_last_error() returns the last error message.
+ */
+int jvm_enable_dtprobes(jvm_t* jvm, int num_probe_types, const char** probe_types);
+
+/* Note: There is no jvm_disable_dtprobes function. Probes are automatically
+ * disabled when there are no more clients requiring those probes.
+ */
+
+/* Detach the given JVM. Returns 0 on success, -1 on failure.
+ * jvm_get_last_error() returns the last error message.
+ */
+int jvm_detach(jvm_t* jvm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _JVM_DTRACE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/libjvm_db.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,1548 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+// not available on macosx #include <gelf.h>
+
+#include "libjvm_db.h"
+#include "JvmOffsets.h"
+
+#define LIBJVM_SO "libjvm.so"
+
+#if defined(i386) || defined(__i386) || defined(__amd64)
+#ifdef COMPILER2
+#define X86_COMPILER2
+#endif /* COMPILER2 */
+#endif /* i386 */
+
+typedef struct {
+    short     vf_cnt; /* number of recognized java vframes */
+    short     bci;    /* current frame method byte code index */
+    int       line;   /* current frame method source line */
+    uint64_t new_fp; /* fp for the next frame */
+    uint64_t new_pc; /* pc for the next frame */
+    uint64_t new_sp; /* "raw" sp for the next frame (includes extension by interpreter/adapter */
+    char      locinf; /* indicates there is valid location info */
+} Jframe_t;
+
+int Jlookup_by_regs(jvm_agent_t* J, const prgregset_t regs, char *name,
+                    size_t size, Jframe_t *jframe);
+
+int main(int arg) { return arg; }
+
+static int debug = 0;
+
+static void failed(int err, const char * file, int line) {
+  if (debug) {
+    fprintf(stderr, "failed %d at %s:%d\n", err, file, line);
+  }
+}
+
+static void warn(const char * file, int line, const char * msg) {
+  if (debug) {
+    fprintf(stderr, "warning: %s at %s:%d\n", msg, file, line);
+  }
+}
+
+static void warn1(const char * file, int line, const char * msg, intptr_t arg1) {
+  if (debug) {
+    fprintf(stderr, "warning: ");
+    fprintf(stderr, msg, arg1);
+    fprintf(stderr, " at %s:%d\n", file, line);
+  }
+}
+
+#define CHECK_FAIL(err) \
+        if (err != PS_OK) { failed(err, __FILE__, __LINE__); goto fail; }
+#define WARN(msg)  warn(__FILE__, __LINE__, msg)
+#define WARN1(msg, arg1)  warn1(__FILE__, __LINE__, msg, arg1)
+
+typedef struct VMStructEntry {
+  const char * typeName;           /* The type name containing the given field (example: "Klass") */
+  const char * fieldName;          /* The field name within the type           (example: "_name") */
+  uint64_t address;                /* Address of field; only used for static fields */
+                                   /* ("offset" can not be reused because of apparent SparcWorks compiler bug */
+                                   /* in generation of initializer data) */
+} VMStructEntry;
+
+/* Prototyping inlined methods */
+
+int sprintf(char *s, const char *format, ...);
+
+#define SZ16  sizeof(int16_t)
+#define SZ32  sizeof(int32_t)
+
+#define COMP_METHOD_SIGN '*'
+
+#define MAX_VFRAMES_CNT 256
+
+typedef struct vframe {
+  uint64_t methodOop;
+  int32_t  sender_decode_offset;
+  int32_t  methodIdx;
+  int32_t  bci;
+  int32_t  line;
+} Vframe_t;
+
+typedef struct frame {
+  uintptr_t fp;
+  uintptr_t pc;
+  uintptr_t sp;
+  uintptr_t sender_sp; // The unextended sp of the caller
+} Frame_t;
+
+typedef struct Nmethod_t {
+  struct jvm_agent* J;
+  Jframe_t *jframe;
+
+  uint64_t nm;                  /* _nmethod */
+  uint64_t pc;
+  uint64_t pc_desc;
+
+  int32_t  orig_pc_offset;      /* _orig_pc_offset */
+  int32_t  instrs_beg;          /* _code_offset */
+  int32_t  instrs_end;
+  int32_t  deopt_beg;           /* _deoptimize_offset */
+  int32_t  scopes_data_beg;     /* _scopes_data_offset */
+  int32_t  scopes_data_end;
+  int32_t  oops_beg;            /* _oops_offset */
+  int32_t  oops_end;
+  int32_t  scopes_pcs_beg;      /* _scopes_pcs_offset */
+  int32_t  scopes_pcs_end;
+
+  int      vf_cnt;
+  Vframe_t vframes[MAX_VFRAMES_CNT];
+} Nmethod_t;
+
+struct jvm_agent {
+  struct ps_prochandle* P;
+
+  uint64_t nmethod_vtbl;
+  uint64_t CodeBlob_vtbl;
+  uint64_t BufferBlob_vtbl;
+  uint64_t RuntimeStub_vtbl;
+
+  uint64_t Use_Compressed_Oops_address;
+  uint64_t Universe_methodKlassObj_address;
+  uint64_t Universe_narrow_oop_base_address;
+  uint64_t Universe_narrow_oop_shift_address;
+  uint64_t CodeCache_heap_address;
+
+  /* Volatiles */
+  uint8_t  Use_Compressed_Oops;
+  uint64_t Universe_methodKlassObj;
+  uint64_t Universe_narrow_oop_base;
+  uint32_t Universe_narrow_oop_shift;
+  uint64_t CodeCache_low;
+  uint64_t CodeCache_high;
+  uint64_t CodeCache_segmap_low;
+  uint64_t CodeCache_segmap_high;
+
+  int32_t  SIZE_CodeCache_log2_segment;
+
+  uint64_t methodOopPtr;
+  uint64_t bcx;
+
+  Nmethod_t *N;                 /*Inlined methods support */
+  Frame_t   prev_fr;
+  Frame_t   curr_fr;
+};
+
+static int
+read_string(struct ps_prochandle *P,
+        char *buf,              /* caller's buffer */
+        size_t size,            /* upper limit on bytes to read */
+        uintptr_t addr)         /* address in process */
+{
+  int err = PS_OK;
+  while (size-- > 1 && err == PS_OK) {
+    err = ps_pread(P, addr, buf, 1);
+    if (*buf == '\0') {
+      return PS_OK;
+    }
+    addr += 1;
+    buf += 1;
+  }
+  return -1;
+}
+
+static int read_compressed_pointer(jvm_agent_t* J, uint64_t base, uint32_t *ptr) {
+  int err = -1;
+  uint32_t ptr32;
+  err = ps_pread(J->P, base, &ptr32, sizeof(uint32_t));
+  *ptr = ptr32;
+  return err;
+}
+
+static int read_pointer(jvm_agent_t* J, uint64_t base, uint64_t* ptr) {
+  int err = -1;
+  uint32_t ptr32;
+
+  switch (DATA_MODEL) {
+  case PR_MODEL_LP64:
+    err = ps_pread(J->P, base, ptr, sizeof(uint64_t));
+    break;
+  case PR_MODEL_ILP32:
+    err = ps_pread(J->P, base, &ptr32, sizeof(uint32_t));
+    *ptr = ptr32;
+    break;
+  }
+
+  return err;
+}
+
+static int read_string_pointer(jvm_agent_t* J, uint64_t base, const char ** stringp) {
+  uint64_t ptr;
+  int err;
+  char buffer[1024];
+
+  *stringp = NULL;
+  err = read_pointer(J, base, &ptr);
+  CHECK_FAIL(err);
+  if (ptr != 0) {
+    err = read_string(J->P, buffer, sizeof(buffer), ptr);
+    CHECK_FAIL(err);
+    *stringp = strdup(buffer);
+  }
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+static int parse_vmstruct_entry(jvm_agent_t* J, uint64_t base, VMStructEntry* vmp) {
+  uint64_t ptr;
+  int err;
+
+  err = read_string_pointer(J, base + OFFSET_VMStructEntrytypeName, &vmp->typeName);
+  CHECK_FAIL(err);
+  err = read_string_pointer(J, base + OFFSET_VMStructEntryfieldName, &vmp->fieldName);
+  CHECK_FAIL(err);
+  err = read_pointer(J, base + OFFSET_VMStructEntryaddress, &vmp->address);
+  CHECK_FAIL(err);
+
+  return PS_OK;
+
+ fail:
+  if (vmp->typeName != NULL) free((void*)vmp->typeName);
+  if (vmp->fieldName != NULL) free((void*)vmp->fieldName);
+  return err;
+}
+
+static int parse_vmstructs(jvm_agent_t* J) {
+  VMStructEntry  vmVar;
+  VMStructEntry* vmp = &vmVar;
+  uint64_t gHotSpotVMStructs;
+  psaddr_t sym_addr;
+  uint64_t base;
+  int err;
+
+  err = ps_pglobal_lookup(J->P, LIBJVM_SO, "gHotSpotVMStructs", &sym_addr);
+  CHECK_FAIL(err);
+  err = read_pointer(J, sym_addr, &gHotSpotVMStructs);
+  CHECK_FAIL(err);
+  base = gHotSpotVMStructs;
+
+  err = PS_OK;
+  while (err == PS_OK) {
+    memset(vmp, 0, sizeof(VMStructEntry));
+    err = parse_vmstruct_entry(J, base, vmp);
+    if (err != PS_OK || vmp->typeName == NULL) {
+      break;
+    }
+
+    if (vmp->typeName[0] == 'C' && strcmp("CodeCache", vmp->typeName) == 0) {
+      if (strcmp("_heap", vmp->fieldName) == 0) {
+        err = read_pointer(J, vmp->address, &J->CodeCache_heap_address);
+      }
+    } else if (vmp->typeName[0] == 'U' && strcmp("Universe", vmp->typeName) == 0) {
+      if (strcmp("_methodKlassObj", vmp->fieldName) == 0) {
+        J->Universe_methodKlassObj_address = vmp->address;
+      }
+      if (strcmp("_narrow_oop._base", vmp->fieldName) == 0) {
+        J->Universe_narrow_oop_base_address = vmp->address;
+      }
+      if (strcmp("_narrow_oop._shift", vmp->fieldName) == 0) {
+        J->Universe_narrow_oop_shift_address = vmp->address;
+      }
+    }
+    CHECK_FAIL(err);
+
+    base += SIZE_VMStructEntry;
+    if (vmp->typeName != NULL) free((void*)vmp->typeName);
+    if (vmp->fieldName != NULL) free((void*)vmp->fieldName);
+  }
+
+  return PS_OK;
+
+ fail:
+  if (vmp->typeName != NULL) free((void*)vmp->typeName);
+  if (vmp->fieldName != NULL) free((void*)vmp->fieldName);
+  return -1;
+}
+
+static int find_symbol(jvm_agent_t* J, const char *name, uint64_t* valuep) {
+  psaddr_t sym_addr;
+  int err;
+
+  err = ps_pglobal_lookup(J->P, LIBJVM_SO, name, &sym_addr);
+  if (err != PS_OK) goto fail;
+  *valuep = sym_addr;
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+static int read_volatiles(jvm_agent_t* J) {
+  uint64_t ptr;
+  int err;
+
+  err = find_symbol(J, "UseCompressedOops", &J->Use_Compressed_Oops_address);
+  if (err == PS_OK) {
+    err = ps_pread(J->P,  J->Use_Compressed_Oops_address, &J->Use_Compressed_Oops, sizeof(uint8_t));
+    CHECK_FAIL(err);
+  } else {
+    J->Use_Compressed_Oops = 0;
+  }
+
+  err = read_pointer(J, J->Universe_methodKlassObj_address, &J->Universe_methodKlassObj);
+  CHECK_FAIL(err);
+
+  err = read_pointer(J, J->Universe_narrow_oop_base_address, &J->Universe_narrow_oop_base);
+  CHECK_FAIL(err);
+  err = ps_pread(J->P,  J->Universe_narrow_oop_shift_address, &J->Universe_narrow_oop_shift, sizeof(uint32_t));
+  CHECK_FAIL(err);
+
+  err = read_pointer(J, J->CodeCache_heap_address + OFFSET_CodeHeap_memory +
+                     OFFSET_VirtualSpace_low, &J->CodeCache_low);
+  CHECK_FAIL(err);
+  err = read_pointer(J, J->CodeCache_heap_address + OFFSET_CodeHeap_memory +
+                     OFFSET_VirtualSpace_high, &J->CodeCache_high);
+  CHECK_FAIL(err);
+  err = read_pointer(J, J->CodeCache_heap_address + OFFSET_CodeHeap_segmap +
+                     OFFSET_VirtualSpace_low, &J->CodeCache_segmap_low);
+  CHECK_FAIL(err);
+  err = read_pointer(J, J->CodeCache_heap_address + OFFSET_CodeHeap_segmap +
+                     OFFSET_VirtualSpace_high, &J->CodeCache_segmap_high);
+  CHECK_FAIL(err);
+
+  err = ps_pread(J->P, J->CodeCache_heap_address + OFFSET_CodeHeap_log2_segment_size,
+                 &J->SIZE_CodeCache_log2_segment, sizeof(J->SIZE_CodeCache_log2_segment));
+  CHECK_FAIL(err);
+
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+
+static int codecache_contains(jvm_agent_t* J, uint64_t ptr) {
+  /* make sure the code cache is up to date */
+  return (J->CodeCache_low <= ptr && ptr < J->CodeCache_high);
+}
+
+static uint64_t segment_for(jvm_agent_t* J, uint64_t p) {
+  return (p - J->CodeCache_low) >> J->SIZE_CodeCache_log2_segment;
+}
+
+static uint64_t block_at(jvm_agent_t* J, int i) {
+  return J->CodeCache_low + (i << J->SIZE_CodeCache_log2_segment);
+}
+
+static int find_start(jvm_agent_t* J, uint64_t ptr, uint64_t *startp) {
+  int err;
+
+  *startp = 0;
+  if (J->CodeCache_low <= ptr && ptr < J->CodeCache_high) {
+    int32_t used;
+    uint64_t segment = segment_for(J, ptr);
+    uint64_t block = J->CodeCache_segmap_low;
+    uint8_t tag;
+    err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
+    CHECK_FAIL(err);
+    if (tag == 0xff)
+      return PS_OK;
+    while (tag > 0) {
+      err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
+      CHECK_FAIL(err);
+      segment -= tag;
+    }
+    block = block_at(J, segment);
+    err = ps_pread(J->P, block + OFFSET_HeapBlockHeader_used, &used, sizeof(used));
+    CHECK_FAIL(err);
+    if (used) {
+      *startp = block + SIZE_HeapBlockHeader;
+    }
+  }
+  return PS_OK;
+
+ fail:
+  return -1;
+}
+
+static int find_jlong_constant(jvm_agent_t* J, const char *name, uint64_t* valuep) {
+  psaddr_t sym_addr;
+  int err = ps_pglobal_lookup(J->P, LIBJVM_SO, name, &sym_addr);
+  if (err == PS_OK) {
+    err = ps_pread(J->P, sym_addr, valuep, sizeof(uint64_t));
+    return err;
+  }
+  *valuep = -1;
+  return -1;
+}
+
+jvm_agent_t *Jagent_create(struct ps_prochandle *P, int vers) {
+  jvm_agent_t* J;
+  int err;
+
+  if (vers != JVM_DB_VERSION) {
+    errno = ENOTSUP;
+    return NULL;
+  }
+
+  J = (jvm_agent_t*)calloc(sizeof(struct jvm_agent), 1);
+
+  debug = getenv("LIBJVMDB_DEBUG") != NULL;
+  if (debug) debug = 3;
+
+  if (debug) {
+      fprintf(stderr, "Jagent_create: debug=%d\n", debug);
+#ifdef X86_COMPILER2
+      fprintf(stderr, "Jagent_create: R_SP=%d, R_FP=%d, POINTER_SIZE=%d\n", R_SP, R_FP, POINTER_SIZE);
+#endif  /* X86_COMPILER2 */
+  }
+
+  J->P = P;
+
+  // Initialize the initial previous frame
+
+  J->prev_fr.fp = 0;
+  J->prev_fr.pc = 0;
+  J->prev_fr.sp = 0;
+  J->prev_fr.sender_sp = 0;
+
+  err = find_symbol(J, "__1cHnmethodG__vtbl_", &J->nmethod_vtbl);
+  CHECK_FAIL(err);
+  err = find_symbol(J, "__1cKBufferBlobG__vtbl_", &J->BufferBlob_vtbl);
+  if (err != PS_OK) J->BufferBlob_vtbl = 0;
+  err = find_symbol(J, "__1cICodeBlobG__vtbl_", &J->CodeBlob_vtbl);
+  CHECK_FAIL(err);
+  err = find_symbol(J, "__1cLRuntimeStubG__vtbl_", &J->RuntimeStub_vtbl);
+  CHECK_FAIL(err);
+
+  err = parse_vmstructs(J);
+  CHECK_FAIL(err);
+  err = read_volatiles(J);
+  CHECK_FAIL(err);
+
+  return J;
+
+ fail:
+  Jagent_destroy(J);
+  return NULL;
+}
+
+void Jagent_destroy(jvm_agent_t *J) {
+  if (J != NULL) {
+    free(J);
+  }
+}
+
+static int is_methodOop(jvm_agent_t* J, uint64_t methodOopPtr) {
+  uint64_t klass;
+  int err;
+  // If UseCompressedOops, this was a compressed oop.
+  if (J->Use_Compressed_Oops != 0) {
+    uint32_t cklass;
+    err = read_compressed_pointer(J, methodOopPtr + OFFSET_oopDesc_metadata,
+          &cklass);
+    // decode heap oop, same as oop.inline.hpp
+    klass = (uint64_t)((uintptr_t)J->Universe_narrow_oop_base +
+            ((uintptr_t)cklass << J->Universe_narrow_oop_shift));
+  } else {
+    err = read_pointer(J, methodOopPtr + OFFSET_oopDesc_metadata, &klass);
+  }
+  if (err != PS_OK) goto fail;
+  return klass == J->Universe_methodKlassObj;
+
+ fail:
+  return 0;
+}
+
+static int
+name_for_methodOop(jvm_agent_t* J, uint64_t methodOopPtr, char * result, size_t size)
+{
+  short nameIndex;
+  short signatureIndex;
+  uint64_t constantPool;
+  uint64_t constMethod;
+  uint64_t nameSymbol;
+  uint64_t signatureSymbol;
+  uint64_t klassPtr;
+  uint64_t klassSymbol;
+  short klassSymbolLength;
+  short nameSymbolLength;
+  short signatureSymbolLength;
+  char * nameString = NULL;
+  char * klassString = NULL;
+  char * signatureString = NULL;
+  int err;
+
+  err = read_pointer(J, methodOopPtr + OFFSET_methodOopDesc_constants, &constantPool);
+  CHECK_FAIL(err);
+  err = read_pointer(J, methodOopPtr + OFFSET_methodOopDesc_constMethod, &constMethod);
+  CHECK_FAIL(err);
+
+  /* To get name string */
+  err = ps_pread(J->P, constMethod + OFFSET_constMethodOopDesc_name_index, &nameIndex, 2);
+  CHECK_FAIL(err);
+  err = read_pointer(J, constantPool + nameIndex * POINTER_SIZE + SIZE_constantPoolOopDesc, &nameSymbol);
+  CHECK_FAIL(err);
+  // The symbol is a CPSlot and has lower bit set to indicate metadata
+  nameSymbol &= (~1); // remove metadata lsb
+  err = ps_pread(J->P, nameSymbol + OFFSET_Symbol_length, &nameSymbolLength, 2);
+  CHECK_FAIL(err);
+  nameString = (char*)calloc(nameSymbolLength + 1, 1);
+  err = ps_pread(J->P, nameSymbol + OFFSET_Symbol_body, nameString, nameSymbolLength);
+  CHECK_FAIL(err);
+
+  /* To get signature string */
+  err = ps_pread(J->P, constMethod + OFFSET_constMethodOopDesc_signature_index, &signatureIndex, 2);
+  CHECK_FAIL(err);
+  err = read_pointer(J, constantPool + signatureIndex * POINTER_SIZE + SIZE_constantPoolOopDesc, &signatureSymbol);
+  CHECK_FAIL(err);
+  signatureSymbol &= (~1);  // remove metadata lsb
+  err = ps_pread(J->P, signatureSymbol + OFFSET_Symbol_length, &signatureSymbolLength, 2);
+  CHECK_FAIL(err);
+  signatureString = (char*)calloc(signatureSymbolLength + 1, 1);
+  err = ps_pread(J->P, signatureSymbol + OFFSET_Symbol_body, signatureString, signatureSymbolLength);
+  CHECK_FAIL(err);
+
+  /* To get klass string */
+  err = read_pointer(J, constantPool + OFFSET_constantPoolOopDesc_pool_holder, &klassPtr);
+  CHECK_FAIL(err);
+  err = read_pointer(J, klassPtr + OFFSET_Klass_name + SIZE_oopDesc, &klassSymbol);
+  CHECK_FAIL(err);
+  err = ps_pread(J->P, klassSymbol + OFFSET_Symbol_length, &klassSymbolLength, 2);
+  CHECK_FAIL(err);
+  klassString = (char*)calloc(klassSymbolLength + 1, 1);
+  err = ps_pread(J->P, klassSymbol + OFFSET_Symbol_body, klassString, klassSymbolLength);
+  CHECK_FAIL(err);
+
+  result[0] = '\0';
+  strncat(result, klassString, size);
+  size -= strlen(klassString);
+  strncat(result, ".", size);
+  size -= 1;
+  strncat(result, nameString, size);
+  size -= strlen(nameString);
+  strncat(result, signatureString, size);
+
+  if (nameString != NULL) free(nameString);
+  if (klassString != NULL) free(klassString);
+  if (signatureString != NULL) free(signatureString);
+
+  return PS_OK;
+
+ fail:
+  if (debug) {
+      fprintf(stderr, "name_for_methodOop: FAIL \n\n");
+  }
+  if (nameString != NULL) free(nameString);
+  if (klassString != NULL) free(klassString);
+  if (signatureString != NULL) free(signatureString);
+  return -1;
+}
+
+static int nmethod_info(Nmethod_t *N)
+{
+  jvm_agent_t *J = N->J;
+  uint64_t    nm = N->nm;
+  int32_t err;
+
+  if (debug > 2 )
+      fprintf(stderr, "\t nmethod_info: BEGIN \n");
+
+  /* Instructions */
+  err = ps_pread(J->P, nm + OFFSET_CodeBlob_code_offset, &N->instrs_beg, SZ32);
+  CHECK_FAIL(err);
+  err = ps_pread(J->P, nm + OFFSET_CodeBlob_data_offset, &N->instrs_end, SZ32);
+  CHECK_FAIL(err);
+  err = ps_pread(J->P, nm + OFFSET_nmethod_deoptimize_offset, &N->deopt_beg, SZ32);
+  CHECK_FAIL(err);
+  err = ps_pread(J->P, nm + OFFSET_nmethod_orig_pc_offset, &N->orig_pc_offset, SZ32);
+  CHECK_FAIL(err);
+
+  /* Oops */
+  err = ps_pread(J->P, nm + OFFSET_nmethod_oops_offset, &N->oops_beg, SZ32);
+  CHECK_FAIL(err);
+  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_offset, &N->oops_end, SZ32);
+  CHECK_FAIL(err);
+
+  /* scopes_pcs */
+  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_pcs_offset, &N->scopes_pcs_beg, SZ32);
+  CHECK_FAIL(err);
+  err = ps_pread(J->P, nm + OFFSET_nmethod_handler_table_offset, &N->scopes_pcs_end, SZ32);
+  CHECK_FAIL(err);
+
+  /* scopes_data */
+  err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_offset, &N->scopes_data_beg, SZ32);
+  CHECK_FAIL(err);
+
+  if (debug > 2 ) {
+      N->scopes_data_end = N->scopes_pcs_beg;
+
+      fprintf(stderr, "\t nmethod_info: instrs_beg: %#x, instrs_end: %#x\n",
+                       N->instrs_beg, N->instrs_end);
+
+      fprintf(stderr, "\t nmethod_info: deopt_beg: %#x \n",
+                       N->deopt_beg);
+
+      fprintf(stderr, "\t nmethod_info: orig_pc_offset: %#x \n",
+                       N->orig_pc_offset);
+
+      fprintf(stderr, "\t nmethod_info: oops_beg: %#x, oops_end: %#x\n",
+                       N->oops_beg, N->oops_end);
+
+      fprintf(stderr, "\t nmethod_info: scopes_data_beg: %#x, scopes_data_end: %#x\n",
+                       N->scopes_data_beg, N->scopes_data_end);
+
+      fprintf(stderr, "\t nmethod_info: scopes_pcs_beg: %#x, scopes_pcs_end: %#x\n",
+                       N->scopes_pcs_beg, N->scopes_pcs_end);
+
+      fprintf(stderr, "\t nmethod_info: END \n\n");
+  }
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+static int
+raw_read_int(jvm_agent_t* J, uint64_t *buffer, int32_t *val)
+{
+  int shift = 0;
+  int value = 0;
+  uint8_t ch = 0;
+  int32_t  err;
+  int32_t sum;
+  // Constants for UNSIGNED5 coding of Pack200
+  // see compressedStream.hpp
+  enum {
+    lg_H = 6,
+    H = 1<<lg_H,
+    BitsPerByte = 8,
+    L = (1<<BitsPerByte)-H,
+  };
+  int i;
+
+  err = ps_pread(J->P, (*buffer)++, &ch, sizeof(uint8_t));
+  CHECK_FAIL(err);
+  if (debug > 2)
+      fprintf(stderr, "\t\t\t raw_read_int: *buffer: %#llx, ch: %#x\n", *buffer, ch);
+
+  sum = ch;
+  if ( sum >= L ) {
+    int32_t lg_H_i = lg_H;
+    // Read maximum of 5 total bytes (we've already read 1).
+    // See CompressedReadStream::read_int_mb
+    for ( i = 0;  i < 4; i++) {
+      err = ps_pread(J->P, (*buffer)++, &ch, sizeof(uint8_t));
+      CHECK_FAIL(err);
+      sum += ch << lg_H_i;
+      if (ch < L ) {
+        *val = sum;
+        return PS_OK;
+      }
+      lg_H_i += lg_H;
+    }
+  }
+  *val = sum;
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+static int
+read_pair(jvm_agent_t* J, uint64_t *buffer, int32_t *bci, int32_t *line)
+{
+  uint8_t next = 0;
+  int32_t bci_delta;
+  int32_t line_delta;
+  int32_t err;
+
+  if (debug > 2)
+      fprintf(stderr, "\t\t read_pair: BEGIN\n");
+
+  err = ps_pread(J->P, (*buffer)++, &next, sizeof(uint8_t));
+  CHECK_FAIL(err);
+
+  if (next == 0) {
+      if (debug > 2)
+          fprintf(stderr, "\t\t read_pair: END: next == 0\n");
+      return 1; /* stream terminated */
+  }
+  if (next == 0xFF) {
+      if (debug > 2)
+          fprintf(stderr, "\t\t read_pair: END: next == 0xFF\n");
+
+      /* Escape character, regular compression used */
+
+      err = raw_read_int(J, buffer, &bci_delta);
+      CHECK_FAIL(err);
+
+      err = raw_read_int(J, buffer, &line_delta);
+      CHECK_FAIL(err);
+
+      *bci  += bci_delta;
+      *line += line_delta;
+
+      if (debug > 2) {
+          fprintf(stderr, "\t\t read_pair: delta = (line %d: %d)\n",
+                          line_delta, bci_delta);
+          fprintf(stderr, "\t\t read_pair: unpack= (line %d: %d)\n",
+                          *line, *bci);
+      }
+  } else {
+      /* Single byte compression used */
+      *bci  += next >> 3;
+      *line += next & 0x7;
+      if (debug > 2) {
+          fprintf(stderr, "\t\t read_pair: delta = (line %d: %d)\n",
+                          next & 0x7, next >> 3);
+          fprintf(stderr, "\t\t read_pair: unpack= (line %d: %d)\n",
+                          *line, *bci);
+      }
+  }
+  if (debug > 2)
+      fprintf(stderr, "\t\t read_pair: END\n");
+  return PS_OK;
+
+ fail:
+  if (debug)
+      fprintf(stderr, "\t\t read_pair: FAIL\n");
+  return err;
+}
+
+static int
+line_number_from_bci(jvm_agent_t* J, Vframe_t *vf)
+{
+  uint64_t buffer;
+  uint16_t code_size;
+  uint64_t code_end_delta;
+  uint64_t constMethod;
+  int8_t   access_flags;
+  int32_t  best_bci    = 0;
+  int32_t  stream_bci  = 0;
+  int32_t  stream_line = 0;
+  int32_t  err;
+
+  if (debug > 2) {
+      char name[256];
+      err = name_for_methodOop(J, vf->methodOop, name, 256);
+      CHECK_FAIL(err);
+      fprintf(stderr, "\t line_number_from_bci: BEGIN, method name: %s, targ bci: %d\n",
+                       name, vf->bci);
+  }
+
+  err = read_pointer(J, vf->methodOop + OFFSET_methodOopDesc_constMethod, &constMethod);
+  CHECK_FAIL(err);
+
+  vf->line = 0;
+  err = ps_pread(J->P, constMethod + OFFSET_constMethodOopDesc_flags, &access_flags, sizeof(int8_t));
+  CHECK_FAIL(err);
+
+  if (!(access_flags & constMethodOopDesc_has_linenumber_table)) {
+      if (debug > 2)
+          fprintf(stderr, "\t line_number_from_bci: END: !HAS_LINE_NUMBER_TABLE \n\n");
+      return PS_OK;
+  }
+
+  /*  The line numbers are a short array of 2-tuples [start_pc, line_number].
+   *  Not necessarily sorted and not necessarily one-to-one.
+   */
+
+  err = ps_pread(J->P, constMethod + OFFSET_constMethodOopDesc_code_size, &code_size, SZ16);
+  CHECK_FAIL(err);
+
+  /* inlined_table_start() */
+  code_end_delta = (uint64_t) (access_flags & AccessFlags_NATIVE) ? 2*POINTER_SIZE : 0;
+  buffer = constMethod + (uint64_t) SIZE_constMethodOopDesc + (uint64_t) code_size + code_end_delta;
+
+  if (debug > 2) {
+      fprintf(stderr, "\t\t line_number_from_bci: methodOop: %#llx, native: %d\n",
+                      vf->methodOop, (access_flags & AccessFlags_NATIVE));
+      fprintf(stderr, "\t\t line_number_from_bci: buffer: %#llx, code_size: %d\n",
+                      buffer, (int) code_size);
+  }
+
+  while (read_pair(J, &buffer, &stream_bci, &stream_line) == 0) {
+      if (stream_bci == vf->bci) {
+          /* perfect match */
+          if (debug > 2)
+              fprintf(stderr, "\t line_number_from_bci: END: exact line: %ld \n\n", vf->line);
+          vf->line = stream_line;
+          return PS_OK;
+      } else {
+          /* update best_bci/line */
+          if (stream_bci < vf->bci && stream_bci >= best_bci) {
+              best_bci = stream_bci;
+              vf->line = stream_line;
+              if (debug > 2) {
+                  fprintf(stderr, "\t line_number_from_bci: best_bci: %ld, best_line: %ld\n",
+                                   best_bci, vf->line);
+              }
+          }
+      }
+  }
+  if (debug > 2)
+      fprintf(stderr, "\t line_number_from_bci: END: line: %ld \n\n", vf->line);
+  return PS_OK;
+
+ fail:
+  if (debug)
+      fprintf(stderr, "\t line_number_from_bci: FAIL\n");
+  return err;
+}
+
+static int
+get_real_pc(Nmethod_t *N, uint64_t pc_desc, uint64_t *real_pc)
+{
+  int32_t pc_offset;
+  int32_t err;
+
+  err = ps_pread(N->J->P, pc_desc + OFFSET_PcDesc_pc_offset, &pc_offset, SZ32);
+  CHECK_FAIL(err);
+
+  *real_pc = N->nm + N->instrs_beg + pc_offset;
+  if (debug > 2) {
+      fprintf(stderr, "\t\t get_real_pc: pc_offset: %lx, real_pc: %llx\n",
+                       pc_offset, *real_pc);
+  }
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+/* Finds a PcDesc with real-pc equal to N->pc */
+static int pc_desc_at(Nmethod_t *N)
+{
+  uint64_t pc_diff;
+  int32_t offs;
+  int32_t err;
+
+  if (debug > 2)
+      fprintf(stderr, "\t pc_desc_at: BEGIN\n");
+
+  N->vf_cnt  = 0;
+  N->pc_desc = 0;
+
+  for (offs = N->scopes_pcs_beg; offs < N->scopes_pcs_end; offs += SIZE_PcDesc) {
+      uint64_t pd;
+      uint64_t best_pc_diff = 16;       /* some approximation */
+      uint64_t real_pc = 0;
+
+      pd = N->nm + offs;
+      err = get_real_pc(N, pd, &real_pc);
+      CHECK_FAIL(err);
+
+      pc_diff = real_pc - N->pc;
+
+      /* In general, this fragment should work */
+      if (pc_diff == 0) {
+          N->pc_desc = pd;
+          if (debug) {
+            fprintf(stderr, "\t pc_desc_at: END: pc_desc: FOUND: %#lx \n\n", pd);
+          }
+          return PS_OK;
+      }
+      /* This fragment is to be able to find out an appropriate
+       * pc_desc entry even if pc_desc info is inaccurate.
+       */
+      if (best_pc_diff > pc_diff && pc_diff > 0) {
+          best_pc_diff = pc_diff;
+          N->pc_desc = pd;
+      }
+  }
+  if (debug) {
+      fprintf(stderr, "\t pc_desc_at: END: pc_desc NOT FOUND");
+      if (pc_diff < 20)
+          fprintf(stderr, ", best pc_diff: %d\n\n", pc_diff);
+      else
+          fprintf(stderr, "\n\n");
+  }
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+static int
+scope_desc_at(Nmethod_t *N, int32_t decode_offset, Vframe_t *vf)
+{
+  uint64_t buffer;
+  int32_t  err;
+
+  if (debug > 2) {
+      fprintf(stderr, "\t\t scope_desc_at: BEGIN \n");
+  }
+
+  buffer = N->nm + N->scopes_data_beg + decode_offset;
+
+  err = raw_read_int(N->J, &buffer, &vf->sender_decode_offset);
+  CHECK_FAIL(err);
+
+  err = raw_read_int(N->J, &buffer, &vf->methodIdx);
+  CHECK_FAIL(err);
+
+  err = raw_read_int(N->J, &buffer, &vf->bci);
+  CHECK_FAIL(err);
+
+  if (debug > 2) {
+      fprintf(stderr, "\t\t scope_desc_at: sender_decode_offset: %#x\n",
+                      vf->sender_decode_offset);
+      fprintf(stderr, "\t\t scope_desc_at: methodIdx: %d\n", vf->methodIdx);
+      fprintf(stderr, "\t\t scope_desc_at: bci: %d\n", vf->bci);
+
+      fprintf(stderr, "\t\t scope_desc_at: END \n\n");
+  }
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+static int scopeDesc_chain(Nmethod_t *N) {
+  int32_t decode_offset = 0;
+  int32_t err;
+
+  if (debug > 2) {
+    fprintf(stderr, "\t scopeDesc_chain: BEGIN\n");
+  }
+
+  err = ps_pread(N->J->P, N->pc_desc + OFFSET_PcDesc_scope_decode_offset,
+                 &decode_offset, SZ32);
+  CHECK_FAIL(err);
+
+  while (decode_offset > 0) {
+    Vframe_t *vf = &N->vframes[N->vf_cnt];
+
+    if (debug > 2) {
+      fprintf(stderr, "\t scopeDesc_chain: decode_offset: %#x\n", decode_offset);
+    }
+
+    err = scope_desc_at(N, decode_offset, vf);
+    CHECK_FAIL(err);
+
+    if (vf->methodIdx > ((N->oops_end - N->oops_beg) / POINTER_SIZE)) {
+      fprintf(stderr, "\t scopeDesc_chain: (methodIdx > oops length) !\n");
+      return -1;
+    }
+    err = read_pointer(N->J, N->nm + N->oops_beg + (vf->methodIdx-1)*POINTER_SIZE,
+                       &vf->methodOop);
+    CHECK_FAIL(err);
+
+    if (vf->methodOop) {
+      N->vf_cnt++;
+      err = line_number_from_bci(N->J, vf);
+      CHECK_FAIL(err);
+      if (debug > 2) {
+        fprintf(stderr, "\t scopeDesc_chain: methodOop: %#8llx, line: %ld\n",
+                vf->methodOop, vf->line);
+      }
+    }
+    decode_offset = vf->sender_decode_offset;
+  }
+  if (debug > 2) {
+    fprintf(stderr, "\t scopeDesc_chain: END \n\n");
+  }
+  return PS_OK;
+
+ fail:
+  if (debug) {
+    fprintf(stderr, "\t scopeDesc_chain: FAIL \n\n");
+  }
+  return err;
+}
+
+
+static int
+name_for_nmethod(jvm_agent_t* J,
+                 uint64_t nm,
+                 uint64_t pc,
+                 uint64_t methodOop,
+                 char *result,
+                 size_t size,
+                 Jframe_t *jframe
+) {
+  Nmethod_t *N;
+  Vframe_t *vf;
+  int32_t err;
+  int deoptimized = 0;
+
+  if (debug) {
+      fprintf(stderr, "name_for_nmethod: BEGIN: nmethod: %#llx, pc: %#llx\n", nm, pc);
+  }
+  if (J->N == NULL) {
+    J->N = (Nmethod_t *) malloc(sizeof(Nmethod_t));
+  }
+  memset(J->N, 0, sizeof(Nmethod_t));   /* Initial stat: all values are zeros */
+  N     = J->N;
+  N->J  = J;
+  N->nm = nm;
+  N->pc = pc;
+  N->jframe = jframe;
+
+  err = nmethod_info(N);
+  CHECK_FAIL(err);
+  if (debug) {
+      fprintf(stderr, "name_for_nmethod: pc: %#llx, deopt_pc:  %#llx\n",
+              pc, N->nm + N->deopt_beg);
+  }
+
+  /* check for a deoptimized frame */
+  if ( pc == N->nm + N->deopt_beg) {
+    uint64_t base;
+    if (debug) {
+        fprintf(stderr, "name_for_nmethod: found deoptimized frame\n");
+    }
+    if (J->prev_fr.sender_sp != 0) {
+      base = J->prev_fr.sender_sp + N->orig_pc_offset;
+    } else {
+      base = J->curr_fr.sp + N->orig_pc_offset;
+    }
+    err = read_pointer(J, base, &N->pc);
+    CHECK_FAIL(err);
+    if (debug) {
+        fprintf(stderr, "name_for_nmethod: found deoptimized frame converting pc from %#8llx to %#8llx\n",
+        pc,  N->pc);
+    }
+    deoptimized = 1;
+  }
+
+  err = pc_desc_at(N);
+  CHECK_FAIL(err);
+
+  if (N->pc_desc > 0) {
+      jframe->locinf = 1;
+      err = scopeDesc_chain(N);
+      CHECK_FAIL(err);
+  }
+  result[0] = COMP_METHOD_SIGN;
+  vf = &N->vframes[0];
+  if (N->vf_cnt > 0) {
+      jframe->vf_cnt = N->vf_cnt;
+      jframe->bci  = vf->bci;
+      jframe->line = vf->line;
+      err = name_for_methodOop(J, N->vframes[0].methodOop, result+1, size-1);
+      CHECK_FAIL(err);
+  } else {
+      err = name_for_methodOop(J, methodOop, result+1, size-1);
+      CHECK_FAIL(err);
+  }
+  if (deoptimized) {
+    strncat(result + 1, " [deoptimized frame]; ", size-1);
+  } else {
+    strncat(result + 1, " [compiled] ", size-1);
+  }
+  if (debug)
+      fprintf(stderr, "name_for_nmethod: END: method name: %s, vf_cnt: %d\n\n",
+                      result, N->vf_cnt);
+  return PS_OK;
+
+ fail:
+  if (debug)
+      fprintf(stderr, "name_for_nmethod: FAIL \n\n");
+  return err;
+}
+
+int is_bci(intptr_t bcx) {
+  switch (DATA_MODEL) {
+  case PR_MODEL_LP64:
+    return ((uintptr_t) bcx) <= ((uintptr_t) MAX_METHOD_CODE_SIZE) ;
+  case PR_MODEL_ILP32:
+  default:
+    return 0 <= bcx && bcx <= MAX_METHOD_CODE_SIZE;
+  }
+}
+
+static int
+name_for_imethod(jvm_agent_t* J,
+                 uint64_t bcx,
+                 uint64_t methodOop,
+                 char *result,
+                 size_t size,
+                 Jframe_t *jframe
+) {
+  uint64_t bci;
+  uint64_t constMethod;
+  Vframe_t vframe = {0};
+  Vframe_t *vf = &vframe;
+  int32_t   err;
+
+  err = read_pointer(J, methodOop + OFFSET_methodOopDesc_constMethod, &constMethod);
+  CHECK_FAIL(err);
+
+  bci = is_bci(bcx) ? bcx : bcx - (constMethod + (uint64_t) SIZE_constMethodOopDesc);
+
+  if (debug)
+      fprintf(stderr, "\t name_for_imethod: BEGIN: methodOop: %#llx\n", methodOop);
+
+  err = name_for_methodOop(J, methodOop, result, size);
+  CHECK_FAIL(err);
+  if (debug)
+      fprintf(stderr, "\t name_for_imethod: method name: %s\n", result);
+
+  if (bci > 0) {
+      vf->methodOop = methodOop;
+      vf->bci       = bci;
+      err = line_number_from_bci(J, vf);
+      CHECK_FAIL(err);
+  }
+  jframe->bci  = vf->bci;
+  jframe->line = vf->line;
+  jframe->locinf = 1;
+
+  if (debug) {
+      fprintf(stderr, "\t name_for_imethod: END: bci: %d, line: %d\n\n",
+                      vf->bci, vf->line);
+  }
+  return PS_OK;
+
+ fail:
+  if (debug)
+      fprintf(stderr, "\t name_for_imethod: FAIL\n");
+  return err;
+}
+
+static int
+name_for_codecache(jvm_agent_t* J, uint64_t fp, uint64_t pc, char * result,
+                   size_t size, Jframe_t *jframe, int* is_interpreted)
+{
+  uint64_t start;
+  uint64_t vtbl;
+  int32_t err;
+  *is_interpreted = 0;
+
+  result[0] = '\0';
+
+  err = find_start(J, pc, &start);
+  CHECK_FAIL(err);
+
+  err = read_pointer(J, start, &vtbl);
+  CHECK_FAIL(err);
+
+  if (vtbl == J->nmethod_vtbl) {
+    uint64_t methodOop;
+
+    err = read_pointer(J, start + OFFSET_nmethod_method, &methodOop);
+    CHECK_FAIL(err);
+
+    if (debug) {
+        fprintf(stderr, "name_for_codecache: start: %#8llx, pc: %#8llx, methodOop: %#8llx \n",
+                        start, pc, methodOop);
+    }
+    err = name_for_nmethod(J, start, pc, methodOop, result, size, jframe);
+    CHECK_FAIL(err);
+  } else if (vtbl == J->BufferBlob_vtbl) {
+    const char * name;
+
+    err = read_string_pointer(J, start + OFFSET_CodeBlob_name, &name);
+
+    /*
+     * Temporary usage of string "Interpreter".
+     * We need some other way to distinguish "StubRoutines"
+     * and regular interpreted frames.
+     */
+    if (err == PS_OK && strncmp(name, "Interpreter", 11) == 0) {
+      *is_interpreted = 1;
+      if (is_methodOop(J, J->methodOopPtr)) {
+        return name_for_imethod(J, J->bcx, J->methodOopPtr, result, size, jframe);
+      }
+    }
+
+    if (err == PS_OK) {
+      strncpy(result, name, size);
+      free((void*)name);
+    } else {
+      strncpy(result, "<unknown BufferBlob>", size);
+    }
+    /* return PS_OK; */
+  } else {
+    const char * name;
+
+    err = read_string_pointer(J, start + OFFSET_CodeBlob_name, &name);
+    if (err == PS_OK) {
+      strncpy(result, name, size);
+      free((void*)name);
+    } else {
+      strncpy(result, "<unknown CodeBlob>", size);
+      WARN1("unknown CodeBlob: vtbl = 0x%x", vtbl);
+    }
+  }
+  result[size-1] = '\0';
+
+#ifdef X86_COMPILER2
+  if (vtbl != J->RuntimeStub_vtbl) {
+    uint64_t trial_pc;
+    int frame_size;
+    err = ps_pread(J->P, start + OFFSET_CodeBlob_frame_size,
+                         &frame_size, SZ32);
+    CHECK_FAIL(err);
+
+    // frame_size is in words, we want bytes.
+    frame_size *= POINTER_SIZE; /* word => byte conversion */
+
+    /*
+      Because c2 doesn't use FP as a framepointer the value of sp/fp we receive
+      in the initial entry to a set of stack frames containing server frames
+      will pretty much be nonsense. We can detect that nonsense by looking to
+      see if the PC we received is correct if we look at the expected storage
+      location in relation to the FP (ie. POINTER_SIZE(FP) )
+    */
+
+    err = read_pointer(J, fp + POINTER_SIZE , &trial_pc);
+    if ( (err != PS_OK || trial_pc != pc) && frame_size > 0 ) {
+      // Either we couldn't even read at the "fp" or the pc didn't match
+      // both are sure clues that the fp is bogus. We no search the stack
+      // for a reasonable number of words trying to find the bogus fp
+      // and the current pc in adjacent words. The we will be able to
+      // deduce an approximation of the frame pointer and actually get
+      // the correct stack pointer. Which we can then unwind for the
+      // next frame.
+      int i;
+      uint64_t check;
+      uint64_t base = J->curr_fr.sp;
+      uint64_t prev_fp = 0;
+      for ( i = 0; i < frame_size * 5 ; i++, base += POINTER_SIZE ) {
+        err = read_pointer(J, base , &check);
+        CHECK_FAIL(err);
+        if (check == fp) {
+          base += POINTER_SIZE;
+          err = read_pointer(J, base , &check);
+          CHECK_FAIL(err);
+          if (check == pc) {
+            if (debug) {
+              fprintf(stderr, "name_for_codecache: found matching fp/pc combo at 0x%llx\n", base - POINTER_SIZE);
+            }
+            prev_fp = base - 2 * POINTER_SIZE;
+            break;
+          }
+        }
+      }
+      if ( prev_fp != 0 ) {
+        // real_sp is the sp we should have received for this frame
+        uint64_t real_sp = prev_fp + 2 * POINTER_SIZE;
+        // +POINTER_SIZE because callee owns the return address so caller's sp is +1 word
+        jframe->new_sp = real_sp + frame_size + POINTER_SIZE;
+        err = read_pointer(J, jframe->new_sp - POINTER_SIZE , &jframe->new_pc);
+        CHECK_FAIL(err);
+        err = read_pointer(J, jframe->new_sp - 2*POINTER_SIZE, &jframe->new_fp);
+        CHECK_FAIL(err);
+        return PS_OK;
+      }
+    }
+
+    /* A prototype to workaround FP absence */
+    /*
+     * frame_size can be 0 for StubRoutines (1) frame.
+     * In this case it should work with fp as usual.
+     */
+    if (frame_size > 0) {
+      jframe->new_fp = J->prev_fr.fp + frame_size;
+      jframe->new_sp = jframe->new_fp + 2 * POINTER_SIZE;
+    } else {
+      memset(&J->curr_fr, 0, sizeof(Frame_t));
+      err = read_pointer(J,  fp, &jframe->new_fp);
+      CHECK_FAIL(err);
+
+      err = read_pointer(J,  jframe->new_fp + POINTER_SIZE,  &jframe->new_pc);
+      CHECK_FAIL(err);
+    }
+    if (debug) {
+      fprintf(stderr, "name_for_codecache: %s, frame_size=%#lx\n",
+                       result, frame_size);
+      fprintf(stderr, "name_for_codecache: prev_fr.fp=%#lx, fp=%#lx\n",
+                       J->prev_fr.fp, jframe->new_fp);
+    }
+  }
+#endif /* X86_COMPILER2 */
+
+  return PS_OK;
+
+ fail:
+  return err;
+}
+
+int Jget_vframe(jvm_agent_t* J, int vframe_no,
+                char *name, size_t size, Jframe_t *jframe)
+{
+  Nmethod_t *N = J->N;
+  Vframe_t  *vf;
+  int32_t   err;
+
+  if (vframe_no >= N->vf_cnt) {
+     (void) sprintf(name, "Wrong inlinedMethod%1d()", vframe_no);
+     return -1;
+  }
+  vf = N->vframes + vframe_no;
+  name[0] = COMP_METHOD_SIGN;
+  err = name_for_methodOop(J, vf->methodOop, name + 1, size);
+  CHECK_FAIL(err);
+
+  jframe->bci = vf->bci;
+  jframe->line = vf->line;
+  if (debug) {
+      fprintf(stderr, "\t Jget_vframe: method name: %s, line: %ld\n",
+                       name, vf->line);
+  }
+  return PS_OK;
+
+ fail:
+  if (debug) {
+      fprintf(stderr, "\t Jget_vframe: FAIL\n");
+  }
+  return err;
+}
+
+#define MAX_SYM_SIZE 256
+
+int Jlookup_by_regs(jvm_agent_t* J, const prgregset_t regs, char *name,
+                    size_t size, Jframe_t *jframe) {
+  uintptr_t fp;
+  uintptr_t pc;
+  /* arguments given to read_pointer need to be worst case sized */
+  uint64_t methodOopPtr = 0;
+  uint64_t sender_sp;
+  uint64_t bcx = 0;
+  int is_interpreted = 0;
+  int result = PS_OK;
+  int err = PS_OK;
+
+  if (J == NULL) {
+    return -1;
+  }
+
+  jframe->vf_cnt = 1;
+  jframe->new_fp = 0;
+  jframe->new_pc = 0;
+  jframe->line   = 0;
+  jframe->bci    = 0;
+  jframe->locinf = 0;
+
+  read_volatiles(J);
+  pc = (uintptr_t) regs[R_PC];
+  J->curr_fr.pc = pc;
+  J->curr_fr.fp = regs[R_FP];
+  J->curr_fr.sp = regs[R_SP];
+
+  if (debug)
+      fprintf(stderr, "Jlookup_by_regs: BEGINs: fp=%#lx, pc=%#lx\n", regs[R_FP], pc);
+
+#if defined(sparc) || defined(__sparc)
+    /* The following workaround is for SPARC. CALL instruction occupates 8 bytes.
+     * In the pcDesc structure return pc offset is recorded for CALL instructions.
+     * regs[R_PC] contains a CALL instruction pc offset.
+     */
+    pc += 8;
+    bcx          = (uintptr_t) regs[R_L1];
+    methodOopPtr = (uintptr_t) regs[R_L2];
+    sender_sp = regs[R_I5];
+    if (debug > 2) {
+        fprintf(stderr, "\nregs[R_I1]=%lx, regs[R_I2]=%lx, regs[R_I5]=%lx, regs[R_L1]=%lx, regs[R_L2]=%lx\n",
+                         regs[R_I1], regs[R_I2], regs[R_I5], regs[R_L1], regs[R_L2]);
+    }
+#elif defined(i386) || defined(__i386) || defined(__amd64)
+
+    fp = (uintptr_t) regs[R_FP];
+    if (J->prev_fr.fp == 0) {
+#ifdef X86_COMPILER2
+        /* A workaround for top java frames */
+        J->prev_fr.fp = (uintptr_t)(regs[R_SP] - 2 * POINTER_SIZE);
+#else
+        J->prev_fr.fp = (uintptr_t)(regs[R_SP] - POINTER_SIZE);
+#endif /* COMPILER2 */
+    }
+    if (debug > 2) {
+        printf("Jlookup_by_regs: J->prev_fr.fp = %#lx\n", J->prev_fr.fp);
+    }
+
+    if (read_pointer(J,  fp + OFFSET_interpreter_frame_method, &methodOopPtr) != PS_OK) {
+      methodOopPtr = 0;
+    }
+    if (read_pointer(J,  fp + OFFSET_interpreter_frame_sender_sp, &sender_sp) != PS_OK) {
+      sender_sp = 0;
+    }
+    if (read_pointer(J,  fp + OFFSET_interpreter_frame_bcx_offset, &bcx) != PS_OK) {
+      bcx = 0;
+    }
+#endif /* i386 */
+
+  J->methodOopPtr = methodOopPtr;
+  J->bcx = bcx;
+
+  /* On x86 with C2 JVM: native frame may have wrong regs[R_FP]
+   * For example: JVM_SuspendThread frame poins to the top interpreted frame.
+   * If we call is_methodOop(J, methodOopPtr) before codecache_contains(J, pc)
+   * then we go over and omit both: nmethod and I2CAdapter frames.
+   * Note, that regs[R_PC] is always correct if frame defined correctly.
+   * So it is better to call codecache_contains(J, pc) from the beginning.
+   */
+#ifndef X86_COMPILER2
+  if (is_methodOop(J, J->methodOopPtr)) {
+    result = name_for_imethod(J, bcx, J->methodOopPtr, name, size, jframe);
+    /* If the methodOopPtr is a method then this is highly likely to be
+       an interpreter frame */
+    if (result >= 0) {
+      is_interpreted = 1;
+    }
+  } else
+#endif /* ! X86_COMPILER2 */
+
+  if (codecache_contains(J, pc)) {
+    result = name_for_codecache(J, fp, pc, name, size, jframe, &is_interpreted);
+  }
+#ifdef X86_COMPILER2
+  else if (is_methodOop(J, J->methodOopPtr)) {
+    result = name_for_imethod(J, bcx, J->methodOopPtr, name, size, jframe);
+    /* If the methodOopPtr is a method then this is highly likely to be
+       an interpreter frame */
+    if (result >= 0) {
+      is_interpreted = 1;
+    }
+  }
+#endif /* X86_COMPILER2 */
+  else {
+    if (debug) {
+        fprintf(stderr, "Jlookup_by_regs: END with -1\n\n");
+    }
+    result = -1;
+  }
+  if (!is_interpreted) {
+    sender_sp = 0;
+  }
+  J->curr_fr.sender_sp = sender_sp;
+
+#ifdef X86_COMPILER2
+  if (!J->curr_fr.fp) {
+    J->curr_fr.fp = (jframe->new_fp) ? jframe->new_fp : (uintptr_t)regs[R_FP];
+  }
+  if (!jframe->new_pc && jframe->new_fp) {
+    // This seems dubious
+    read_pointer(J,  jframe->new_fp + POINTER_SIZE,  &jframe->new_pc);
+    CHECK_FAIL(err);
+    if (debug > 2) {
+        printf("Jlookup_by_regs: (update pc) jframe->new_fp: %#llx, jframe->new_pc: %#llx\n",
+               jframe->new_fp, jframe->new_pc);
+    }
+  }
+
+#endif /* X86_COMPILER2 */
+  J->prev_fr = J->curr_fr;
+
+  if (debug)
+      fprintf(stderr, "Jlookup_by_regs: END\n\n");
+
+  return result;
+
+ fail:
+  return err;
+}
+
+void update_gregs(prgregset_t gregs, Jframe_t jframe) {
+#ifdef X86_COMPILER2
+    if (debug > 0) {
+      fprintf(stderr, "update_gregs: before update sp = 0x%llx, fp = 0x%llx, pc = 0x%llx\n", gregs[R_SP], gregs[R_FP], gregs[R_PC]);
+    }
+    /*
+     * A workaround for java C2 frames with unconventional FP.
+     * may have to modify regset with new values for FP/PC/SP when needed.
+     */
+     if (jframe.new_sp) {
+         *((uintptr_t *) &gregs[R_SP]) = (uintptr_t) jframe.new_sp;
+     } else {
+         // *((uintptr_t *) &gregs[R_SP]) = (uintptr_t) gregs[R_FP] + 2 * POINTER_SIZE;
+     }
+
+     if (jframe.new_fp) {
+         *((uintptr_t *) &gregs[R_FP]) = (uintptr_t) jframe.new_fp;
+     }
+     if (jframe.new_pc) {
+         *((uintptr_t *) &gregs[R_PC]) = (uintptr_t) jframe.new_pc;
+     }
+    if (debug > 0) {
+      fprintf(stderr, "update_gregs: after update sp = 0x%llx, fp = 0x%llx, pc = 0x%llx\n", gregs[R_SP], gregs[R_FP], gregs[R_PC]);
+    }
+#endif  /* X86_COMPILER2 */
+}
+
+/*
+ * Iterates over java frames at current location given by 'gregs'.
+ *
+ *  Returns -1 if no java frames are present or if an error is encountered.
+ *  Returns the result of calling 'func' if the return value is non-zero.
+ *  Returns 0 otherwise.
+ */
+int Jframe_iter(jvm_agent_t *J, prgregset_t gregs, java_stack_f *func, void* cld) {
+    char buf[MAX_SYM_SIZE + 1];
+    Jframe_t jframe;
+    int i = 0, res;
+#ifdef X86_COMPILER2
+    if (debug > 0) {
+      fprintf(stderr, "Jframe_iter: Entry sp = 0x%llx, fp = 0x%llx, pc = 0x%llx\n", gregs[R_SP], gregs[R_FP], gregs[R_PC]);
+    }
+#endif  /* X86_COMPILER2 */
+
+    memset(&jframe, 0, sizeof(Jframe_t));
+    memset(buf, 0, sizeof(buf));
+    res =  Jlookup_by_regs(J, gregs, buf, sizeof(buf), &jframe);
+    if (res != PS_OK)
+        return (-1);
+
+
+    res = func(cld, gregs, buf, (jframe.locinf)? jframe.bci : -1,
+               jframe.line, NULL);
+    if (res != 0) {
+        update_gregs(gregs, jframe);
+        return (res);
+    }
+    for (i = 1; i < jframe.vf_cnt; i++) {
+        Jget_vframe(J, i, buf, sizeof(buf), &jframe);
+        res = func(cld, gregs, buf, (jframe.locinf)? jframe.bci : -1,
+                   jframe.line, NULL);
+        if (res != 0) {
+            update_gregs(gregs, jframe);
+            return (res);
+        }
+    }
+    update_gregs(gregs, jframe);
+    return (0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/dtrace/libjvm_db.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_SOLARIS_DTRACE_LIBJVM_DB_H
+#define OS_SOLARIS_DTRACE_LIBJVM_DB_H
+
+// not available on macosx #include <proc_service.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct jvm_agent jvm_agent_t;
+
+#define JVM_DB_VERSION  1
+
+jvm_agent_t *Jagent_create(struct ps_prochandle *P, int vers);
+
+/*
+ * Called from Jframe_iter() for each java frame.  If it returns 0, then
+ * Jframe_iter() proceeds to the next frame.  Otherwise, the return value is
+ * immediately returned to the caller of Jframe_iter().
+ *
+ * Parameters:
+ *    'cld' is client supplied data (to maintain iterator state, if any).
+ *    'name' is java method name.
+ *    'bci' is byte code index. it will be -1 if not available.
+ *    'line' is java source line number. it will be 0 if not available.
+ *    'handle' is an abstract client handle, reserved for future expansions
+ */
+
+typedef int java_stack_f(void *cld, const prgregset_t regs, const char* name, int bci, int line, void *handle);
+
+/*
+ * Iterates over the java frames at the current location.  Returns -1 if no java
+ * frames were found, or if there was some unrecoverable error.  Otherwise,
+ * returns the last value returned from 'func'.
+ */
+int Jframe_iter(jvm_agent_t *agent, prgregset_t gregs, java_stack_f *func, void* cld);
+
+void Jagent_destroy(jvm_agent_t *J);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+#endif // OS_SOLARIS_DTRACE_LIBJVM_DB_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/attachListener_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,520 @@
+/*
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "runtime/interfaceSupport.hpp"
+#include "runtime/os.hpp"
+#include "services/attachListener.hpp"
+#include "services/dtraceAttacher.hpp"
+
+#include <unistd.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+
+#ifndef UNIX_PATH_MAX
+#define UNIX_PATH_MAX   sizeof(((struct sockaddr_un *)0)->sun_path)
+#endif
+
+// The attach mechanism on Bsd uses a UNIX domain socket. An attach listener
+// thread is created at startup or is created on-demand via a signal from
+// the client tool. The attach listener creates a socket and binds it to a file
+// in the filesystem. The attach listener then acts as a simple (single-
+// threaded) server - it waits for a client to connect, reads the request,
+// executes it, and returns the response to the client via the socket
+// connection.
+//
+// As the socket is a UNIX domain socket it means that only clients on the
+// local machine can connect. In addition there are two other aspects to
+// the security:
+// 1. The well known file that the socket is bound to has permission 400
+// 2. When a client connect, the SO_PEERCRED socket option is used to
+//    obtain the credentials of client. We check that the effective uid
+//    of the client matches this process.
+
+// forward reference
+class BsdAttachOperation;
+
+class BsdAttachListener: AllStatic {
+ private:
+  // the path to which we bind the UNIX domain socket
+  static char _path[UNIX_PATH_MAX];
+  static bool _has_path;
+
+  // the file descriptor for the listening socket
+  static int _listener;
+
+  static void set_path(char* path) {
+    if (path == NULL) {
+      _has_path = false;
+    } else {
+      strncpy(_path, path, UNIX_PATH_MAX);
+      _path[UNIX_PATH_MAX-1] = '\0';
+      _has_path = true;
+    }
+  }
+
+  static void set_listener(int s)               { _listener = s; }
+
+  // reads a request from the given connected socket
+  static BsdAttachOperation* read_request(int s);
+
+ public:
+  enum {
+    ATTACH_PROTOCOL_VER = 1                     // protocol version
+  };
+  enum {
+    ATTACH_ERROR_BADVERSION     = 101           // error codes
+  };
+
+  // initialize the listener, returns 0 if okay
+  static int init();
+
+  static char* path()                   { return _path; }
+  static bool has_path()                { return _has_path; }
+  static int listener()                 { return _listener; }
+
+  // write the given buffer to a socket
+  static int write_fully(int s, char* buf, int len);
+
+  static BsdAttachOperation* dequeue();
+};
+
+class BsdAttachOperation: public AttachOperation {
+ private:
+  // the connection to the client
+  int _socket;
+
+ public:
+  void complete(jint res, bufferedStream* st);
+
+  void set_socket(int s)                                { _socket = s; }
+  int socket() const                                    { return _socket; }
+
+  BsdAttachOperation(char* name) : AttachOperation(name) {
+    set_socket(-1);
+  }
+};
+
+// statics
+char BsdAttachListener::_path[UNIX_PATH_MAX];
+bool BsdAttachListener::_has_path;
+int BsdAttachListener::_listener = -1;
+
+// Supporting class to help split a buffer into individual components
+class ArgumentIterator : public StackObj {
+ private:
+  char* _pos;
+  char* _end;
+ public:
+  ArgumentIterator(char* arg_buffer, size_t arg_size) {
+    _pos = arg_buffer;
+    _end = _pos + arg_size - 1;
+  }
+  char* next() {
+    if (*_pos == '\0') {
+      return NULL;
+    }
+    char* res = _pos;
+    char* next_pos = strchr(_pos, '\0');
+    if (next_pos < _end)  {
+      next_pos++;
+    }
+    _pos = next_pos;
+    return res;
+  }
+};
+
+
+// atexit hook to stop listener and unlink the file that it is
+// bound too.
+extern "C" {
+  static void listener_cleanup() {
+    static int cleanup_done;
+    if (!cleanup_done) {
+      cleanup_done = 1;
+      int s = BsdAttachListener::listener();
+      if (s != -1) {
+        ::close(s);
+      }
+      if (BsdAttachListener::has_path()) {
+        ::unlink(BsdAttachListener::path());
+      }
+    }
+  }
+}
+
+// Initialization - create a listener socket and bind it to a file
+
+int BsdAttachListener::init() {
+  char path[UNIX_PATH_MAX];          // socket file
+  char initial_path[UNIX_PATH_MAX];  // socket file during setup
+  int listener;                      // listener socket (file descriptor)
+
+  // register function to cleanup
+  ::atexit(listener_cleanup);
+
+  int n = snprintf(path, UNIX_PATH_MAX, "%s/.java_pid%d",
+                   os::get_temp_directory(), os::current_process_id());
+  if (n < (int)UNIX_PATH_MAX) {
+    n = snprintf(initial_path, UNIX_PATH_MAX, "%s.tmp", path);
+  }
+  if (n >= (int)UNIX_PATH_MAX) {
+    return -1;
+  }
+
+  // create the listener socket
+  listener = ::socket(PF_UNIX, SOCK_STREAM, 0);
+  if (listener == -1) {
+    return -1;
+  }
+
+  // bind socket
+  struct sockaddr_un addr;
+  addr.sun_family = AF_UNIX;
+  strcpy(addr.sun_path, initial_path);
+  ::unlink(initial_path);
+  int res = ::bind(listener, (struct sockaddr*)&addr, sizeof(addr));
+  if (res == -1) {
+    RESTARTABLE(::close(listener), res);
+    return -1;
+  }
+
+  // put in listen mode, set permissions, and rename into place
+  res = ::listen(listener, 5);
+  if (res == 0) {
+      RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res);
+      if (res == 0) {
+          res = ::rename(initial_path, path);
+      }
+  }
+  if (res == -1) {
+    RESTARTABLE(::close(listener), res);
+    ::unlink(initial_path);
+    return -1;
+  }
+  set_path(path);
+  set_listener(listener);
+
+  return 0;
+}
+
+// Given a socket that is connected to a peer we read the request and
+// create an AttachOperation. As the socket is blocking there is potential
+// for a denial-of-service if the peer does not response. However this happens
+// after the peer credentials have been checked and in the worst case it just
+// means that the attach listener thread is blocked.
+//
+BsdAttachOperation* BsdAttachListener::read_request(int s) {
+  char ver_str[8];
+  sprintf(ver_str, "%d", ATTACH_PROTOCOL_VER);
+
+  // The request is a sequence of strings so we first figure out the
+  // expected count and the maximum possible length of the request.
+  // The request is:
+  //   <ver>0<cmd>0<arg>0<arg>0<arg>0
+  // where <ver> is the protocol version (1), <cmd> is the command
+  // name ("load", "datadump", ...), and <arg> is an argument
+  int expected_str_count = 2 + AttachOperation::arg_count_max;
+  const int max_len = (sizeof(ver_str) + 1) + (AttachOperation::name_length_max + 1) +
+    AttachOperation::arg_count_max*(AttachOperation::arg_length_max + 1);
+
+  char buf[max_len];
+  int str_count = 0;
+
+  // Read until all (expected) strings have been read, the buffer is
+  // full, or EOF.
+
+  int off = 0;
+  int left = max_len;
+
+  do {
+    int n;
+    RESTARTABLE(read(s, buf+off, left), n);
+    if (n == -1) {
+      return NULL;      // reset by peer or other error
+    }
+    if (n == 0) {
+      break;
+    }
+    for (int i=0; i<n; i++) {
+      if (buf[off+i] == 0) {
+        // EOS found
+        str_count++;
+
+        // The first string is <ver> so check it now to
+        // check for protocol mis-match
+        if (str_count == 1) {
+          if ((strlen(buf) != strlen(ver_str)) ||
+              (atoi(buf) != ATTACH_PROTOCOL_VER)) {
+            char msg[32];
+            sprintf(msg, "%d\n", ATTACH_ERROR_BADVERSION);
+            write_fully(s, msg, strlen(msg));
+            return NULL;
+          }
+        }
+      }
+    }
+    off += n;
+    left -= n;
+  } while (left > 0 && str_count < expected_str_count);
+
+  if (str_count != expected_str_count) {
+    return NULL;        // incomplete request
+  }
+
+  // parse request
+
+  ArgumentIterator args(buf, (max_len)-left);
+
+  // version already checked
+  char* v = args.next();
+
+  char* name = args.next();
+  if (name == NULL || strlen(name) > AttachOperation::name_length_max) {
+    return NULL;
+  }
+
+  BsdAttachOperation* op = new BsdAttachOperation(name);
+
+  for (int i=0; i<AttachOperation::arg_count_max; i++) {
+    char* arg = args.next();
+    if (arg == NULL) {
+      op->set_arg(i, NULL);
+    } else {
+      if (strlen(arg) > AttachOperation::arg_length_max) {
+        delete op;
+        return NULL;
+      }
+      op->set_arg(i, arg);
+    }
+  }
+
+  op->set_socket(s);
+  return op;
+}
+
+
+// Dequeue an operation
+//
+// In the Bsd implementation there is only a single operation and clients
+// cannot queue commands (except at the socket level).
+//
+BsdAttachOperation* BsdAttachListener::dequeue() {
+  for (;;) {
+    int s;
+
+    // wait for client to connect
+    struct sockaddr addr;
+    socklen_t len = sizeof(addr);
+    RESTARTABLE(::accept(listener(), &addr, &len), s);
+    if (s == -1) {
+      return NULL;      // log a warning?
+    }
+
+    // get the credentials of the peer and check the effective uid/guid
+    // - check with jeff on this.
+#ifdef _ALLBSD_SOURCE
+    uid_t puid;
+    gid_t pgid;
+    if (::getpeereid(s, &puid, &pgid) != 0) {
+      int res;
+      RESTARTABLE(::close(s), res);
+      continue;
+    }
+#else
+    struct ucred cred_info;
+    socklen_t optlen = sizeof(cred_info);
+    if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) == -1) {
+      int res;
+      RESTARTABLE(::close(s), res);
+      continue;
+    }
+    uid_t puid = cred_info.uid;
+    gid_t pgid = cred_info.gid;
+#endif
+    uid_t euid = geteuid();
+    gid_t egid = getegid();
+
+    if (puid != euid || pgid != egid) {
+      int res;
+      RESTARTABLE(::close(s), res);
+      continue;
+    }
+
+    // peer credential look okay so we read the request
+    BsdAttachOperation* op = read_request(s);
+    if (op == NULL) {
+      int res;
+      RESTARTABLE(::close(s), res);
+      continue;
+    } else {
+      return op;
+    }
+  }
+}
+
+// write the given buffer to the socket
+int BsdAttachListener::write_fully(int s, char* buf, int len) {
+  do {
+    int n = ::write(s, buf, len);
+    if (n == -1) {
+      if (errno != EINTR) return -1;
+    } else {
+      buf += n;
+      len -= n;
+    }
+  }
+  while (len > 0);
+  return 0;
+}
+
+// Complete an operation by sending the operation result and any result
+// output to the client. At this time the socket is in blocking mode so
+// potentially we can block if there is a lot of data and the client is
+// non-responsive. For most operations this is a non-issue because the
+// default send buffer is sufficient to buffer everything. In the future
+// if there are operations that involves a very big reply then it the
+// socket could be made non-blocking and a timeout could be used.
+
+void BsdAttachOperation::complete(jint result, bufferedStream* st) {
+  JavaThread* thread = JavaThread::current();
+  ThreadBlockInVM tbivm(thread);
+
+  thread->set_suspend_equivalent();
+  // cleared by handle_special_suspend_equivalent_condition() or
+  // java_suspend_self() via check_and_wait_while_suspended()
+
+  // write operation result
+  char msg[32];
+  sprintf(msg, "%d\n", result);
+  int rc = BsdAttachListener::write_fully(this->socket(), msg, strlen(msg));
+
+  // write any result data
+  if (rc == 0) {
+    BsdAttachListener::write_fully(this->socket(), (char*) st->base(), st->size());
+    ::shutdown(this->socket(), 2);
+  }
+
+  // done
+  RESTARTABLE(::close(this->socket()), rc);
+
+  // were we externally suspended while we were waiting?
+  thread->check_and_wait_while_suspended();
+
+  delete this;
+}
+
+
+// AttachListener functions
+
+AttachOperation* AttachListener::dequeue() {
+  JavaThread* thread = JavaThread::current();
+  ThreadBlockInVM tbivm(thread);
+
+  thread->set_suspend_equivalent();
+  // cleared by handle_special_suspend_equivalent_condition() or
+  // java_suspend_self() via check_and_wait_while_suspended()
+
+  AttachOperation* op = BsdAttachListener::dequeue();
+
+  // were we externally suspended while we were waiting?
+  thread->check_and_wait_while_suspended();
+
+  return op;
+}
+
+int AttachListener::pd_init() {
+  JavaThread* thread = JavaThread::current();
+  ThreadBlockInVM tbivm(thread);
+
+  thread->set_suspend_equivalent();
+  // cleared by handle_special_suspend_equivalent_condition() or
+  // java_suspend_self() via check_and_wait_while_suspended()
+
+  int ret_code = BsdAttachListener::init();
+
+  // were we externally suspended while we were waiting?
+  thread->check_and_wait_while_suspended();
+
+  return ret_code;
+}
+
+// Attach Listener is started lazily except in the case when
+// +ReduseSignalUsage is used
+bool AttachListener::init_at_startup() {
+  if (ReduceSignalUsage) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+// If the file .attach_pid<pid> exists in the working directory
+// or /tmp then this is the trigger to start the attach mechanism
+bool AttachListener::is_init_trigger() {
+  if (init_at_startup() || is_initialized()) {
+    return false;               // initialized at startup or already initialized
+  }
+  char path[PATH_MAX + 1];
+  int ret;
+  struct stat st;
+
+  snprintf(path, PATH_MAX + 1, "%s/.attach_pid%d",
+           os::get_temp_directory(), os::current_process_id());
+  RESTARTABLE(::stat(path, &st), ret);
+  if (ret == 0) {
+    // simple check to avoid starting the attach mechanism when
+    // a bogus user creates the file
+    if (st.st_uid == geteuid()) {
+      init();
+      return true;
+    }
+  }
+  return false;
+}
+
+// if VM aborts then remove listener
+void AttachListener::abort() {
+  listener_cleanup();
+}
+
+void AttachListener::pd_data_dump() {
+  os::signal_notify(SIGQUIT);
+}
+
+AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* n) {
+  return NULL;
+}
+
+jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) {
+  out->print_cr("flag '%s' cannot be changed", op->arg(0));
+  return JNI_ERR;
+}
+
+void AttachListener::pd_detachall() {
+  // do nothing for now
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/c1_globals_bsd.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_BSD_VM_C1_GLOBALS_BSD_HPP
+#define OS_BSD_VM_C1_GLOBALS_BSD_HPP
+
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/macros.hpp"
+
+//
+// Sets the default values for operating system dependent flags used by the
+// client compiler. (see c1_globals.hpp)
+//
+
+#endif // OS_BSD_VM_C1_GLOBALS_BSD_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/c2_globals_bsd.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_BSD_VM_C2_GLOBALS_BSD_HPP
+#define OS_BSD_VM_C2_GLOBALS_BSD_HPP
+
+#include "utilities/globalDefinitions.hpp"
+#include "utilities/macros.hpp"
+
+//
+// Sets the default values for operating system dependent flags used by the
+// server compiler. (see c2_globals.hpp)
+//
+
+#endif // OS_BSD_VM_C2_GLOBALS_BSD_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/chaitin_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "opto/chaitin.hpp"
+#include "opto/machnode.hpp"
+
+void PhaseRegAlloc::pd_preallocate_hook() {
+  // no action
+}
+
+#ifdef ASSERT
+void PhaseRegAlloc::pd_postallocate_verify_hook() {
+  // no action
+}
+#endif
+
+
+// Reconciliation History
+// chaitin_solaris.cpp  1.7 99/07/12 23:54:22
+// End
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/decoder_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "prims/jvm.h"
+#include "utilities/decoder.hpp"
+
+#include <cxxabi.h>
+
+#ifdef __APPLE__
+
+void Decoder::initialize() {
+  _initialized = true;
+}
+
+void Decoder::uninitialize() {
+  _initialized = false;
+}
+
+bool Decoder::can_decode_C_frame_in_vm() {
+  return false;
+}
+
+Decoder::decoder_status Decoder::decode(address addr, const char* filepath, char *buf, int buflen, int *offset) {
+  return symbol_not_found;
+}
+
+
+#endif
+
+bool Decoder::demangle(const char* symbol, char *buf, int buflen) {
+  int   status;
+  char* result;
+  size_t size = (size_t)buflen;
+
+  // Don't pass buf to __cxa_demangle. In case of the 'buf' is too small,
+  // __cxa_demangle will call system "realloc" for additional memory, which
+  // may use different malloc/realloc mechanism that allocates 'buf'.
+  if ((result = abi::__cxa_demangle(symbol, NULL, NULL, &status)) != NULL) {
+    jio_snprintf(buf, buflen, "%s", result);
+      // call c library's free
+      ::free(result);
+      return true;
+  }
+  return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/dtraceJSDT_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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/javaClasses.hpp"
+#include "code/codeBlob.hpp"
+#include "memory/allocation.hpp"
+#include "prims/jvm.h"
+#include "runtime/dtraceJSDT.hpp"
+#include "runtime/jniHandles.hpp"
+#include "runtime/os.hpp"
+#include "runtime/signature.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+/*
+ * JSDT java dtrace probes have never been implemented in macosx.  It is unknown if the solaris implementation
+ * is close or if significant implementation work is necessary.  The future of the solaris implementation also
+ * appears to be unclear since compiling code with JSDT probes produces the following warning:
+ * "warning: ProviderFactory is internal proprietary API and may be removed in a future release"
+ */
+
+int DTraceJSDT::pd_activate(
+    void* baseAddress, jstring module,
+    jint providers_count, JVM_DTraceProvider* providers) {
+  return -1;
+}
+
+void DTraceJSDT::pd_dispose(int handle) {
+}
+
+jboolean DTraceJSDT::pd_is_supported() {
+  return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/globals_bsd.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 OS_BSD_VM_GLOBALS_BSD_HPP
+#define OS_BSD_VM_GLOBALS_BSD_HPP
+
+//
+// Defines Bsd specific flags. They are not available on other platforms.
+//
+#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct) \
+  product(bool, UseOprofile, false,                                     \
+        "enable support for Oprofile profiler")                         \
+                                                                        \
+  product(bool, UseBsdPosixThreadCPUClocks, true,                     \
+          "enable fast Bsd Posix clocks where available")             \
+/*  NB: The default value of UseBsdPosixThreadCPUClocks may be        \
+    overridden in Arguments::parse_each_vm_init_arg.  */                \
+                                                                        \
+  product(bool, UseHugeTLBFS, false,                                    \
+          "Use MAP_HUGETLB for large pages")                            \
+                                                                        \
+  product(bool, UseSHM, false,                                          \
+          "Use SYSV shared memory for large pages")
+
+//
+// Defines Bsd-specific default values. The flags are available on all
+// platforms, but they may have different default values on other platforms.
+//
+define_pd_global(bool, UseLargePages, false);
+define_pd_global(bool, UseLargePagesIndividualAllocation, false);
+define_pd_global(bool, UseOSErrorReporting, false);
+define_pd_global(bool, UseThreadPriorities, true) ;
+
+#endif // OS_BSD_VM_GLOBALS_BSD_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/interfaceSupport_bsd.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_BSD_VM_INTERFACESUPPORT_BSD_HPP
+#define OS_BSD_VM_INTERFACESUPPORT_BSD_HPP
+
+// Contains inlined functions for class InterfaceSupport
+
+static inline void serialize_memory(JavaThread *thread) {
+  os::write_memory_serialize_page(thread);
+}
+
+#endif // OS_BSD_VM_INTERFACESUPPORT_BSD_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/jsig.c	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ *
+ */
+
+/* CopyrightVersion 1.2 */
+
+/* This is a special library that should be loaded before libc &
+ * libthread to interpose the signal handler installation functions:
+ * sigaction(), signal(), sigset().
+ * Used for signal-chaining. See RFE 4381843.
+ */
+
+#include <signal.h>
+#include <dlfcn.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#define MAXSIGNUM 32
+#define MASK(sig) ((unsigned int)1 << sig)
+
+static struct sigaction sact[MAXSIGNUM]; /* saved signal handlers */
+static unsigned int jvmsigs = 0; /* signals used by jvm */
+
+/* used to synchronize the installation of signal handlers */
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_t tid = 0;
+
+typedef void (*sa_handler_t)(int);
+typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
+typedef sa_handler_t (*signal_t)(int, sa_handler_t);
+typedef int (*sigaction_t)(int, const struct sigaction *, struct sigaction *);
+
+static signal_t os_signal = 0; /* os's version of signal()/sigset() */
+static sigaction_t os_sigaction = 0; /* os's version of sigaction() */
+
+static bool jvm_signal_installing = false;
+static bool jvm_signal_installed = false;
+
+static void signal_lock() {
+  pthread_mutex_lock(&mutex);
+  /* When the jvm is installing its set of signal handlers, threads
+   * other than the jvm thread should wait */
+  if (jvm_signal_installing) {
+    if (tid != pthread_self()) {
+      pthread_cond_wait(&cond, &mutex);
+    }
+  }
+}
+
+static void signal_unlock() {
+  pthread_mutex_unlock(&mutex);
+}
+
+static sa_handler_t call_os_signal(int sig, sa_handler_t disp,
+                                   bool is_sigset) {
+  if (os_signal == NULL) {
+    if (!is_sigset) {
+      os_signal = (signal_t)dlsym(RTLD_NEXT, "signal");
+    } else {
+      os_signal = (signal_t)dlsym(RTLD_NEXT, "sigset");
+    }
+    if (os_signal == NULL) {
+      printf("%s\n", dlerror());
+      exit(0);
+    }
+  }
+  return (*os_signal)(sig, disp);
+}
+
+static void save_signal_handler(int sig, sa_handler_t disp) {
+  sigset_t set;
+  sact[sig].sa_handler = disp;
+  sigemptyset(&set);
+  sact[sig].sa_mask = set;
+  sact[sig].sa_flags = 0;
+}
+
+static sa_handler_t set_signal(int sig, sa_handler_t disp, bool is_sigset) {
+  sa_handler_t oldhandler;
+  bool sigused;
+
+  signal_lock();
+
+  sigused = (MASK(sig) & jvmsigs) != 0;
+  if (jvm_signal_installed && sigused) {
+    /* jvm has installed its signal handler for this signal. */
+    /* Save the handler. Don't really install it. */
+    oldhandler = sact[sig].sa_handler;
+    save_signal_handler(sig, disp);
+
+    signal_unlock();
+    return oldhandler;
+  } else if (jvm_signal_installing) {
+    /* jvm is installing its signal handlers. Install the new
+     * handlers and save the old ones. jvm uses sigaction().
+     * Leave the piece here just in case. */
+    oldhandler = call_os_signal(sig, disp, is_sigset);
+    save_signal_handler(sig, oldhandler);
+
+    /* Record the signals used by jvm */
+    jvmsigs |= MASK(sig);
+
+    signal_unlock();
+    return oldhandler;
+  } else {
+    /* jvm has no relation with this signal (yet). Install the
+     * the handler. */
+    oldhandler = call_os_signal(sig, disp, is_sigset);
+
+    signal_unlock();
+    return oldhandler;
+  }
+}
+
+sa_handler_t signal(int sig, sa_handler_t disp) {
+  return set_signal(sig, disp, false);
+}
+
+sa_handler_t sigset(int sig, sa_handler_t disp) {
+  printf("sigset() is not supported by BSD");
+  exit(0);
+ }
+
+static int call_os_sigaction(int sig, const struct sigaction  *act,
+                             struct sigaction *oact) {
+  if (os_sigaction == NULL) {
+    os_sigaction = (sigaction_t)dlsym(RTLD_NEXT, "sigaction");
+    if (os_sigaction == NULL) {
+      printf("%s\n", dlerror());
+      exit(0);
+    }
+  }
+  return (*os_sigaction)(sig, act, oact);
+}
+
+int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
+  int res;
+  bool sigused;
+  struct sigaction oldAct;
+
+  signal_lock();
+
+  sigused = (MASK(sig) & jvmsigs) != 0;
+  if (jvm_signal_installed && sigused) {
+    /* jvm has installed its signal handler for this signal. */
+    /* Save the handler. Don't really install it. */
+    if (oact != NULL) {
+      *oact = sact[sig];
+    }
+    if (act != NULL) {
+      sact[sig] = *act;
+    }
+
+    signal_unlock();
+    return 0;
+  } else if (jvm_signal_installing) {
+    /* jvm is installing its signal handlers. Install the new
+     * handlers and save the old ones. */
+    res = call_os_sigaction(sig, act, &oldAct);
+    sact[sig] = oldAct;
+    if (oact != NULL) {
+      *oact = oldAct;
+    }
+
+    /* Record the signals used by jvm */
+    jvmsigs |= MASK(sig);
+
+    signal_unlock();
+    return res;
+  } else {
+    /* jvm has no relation with this signal (yet). Install the
+     * the handler. */
+    res = call_os_sigaction(sig, act, oact);
+
+    signal_unlock();
+    return res;
+  }
+}
+
+/* The three functions for the jvm to call into */
+void JVM_begin_signal_setting() {
+  signal_lock();
+  jvm_signal_installing = true;
+  tid = pthread_self();
+  signal_unlock();
+}
+
+void JVM_end_signal_setting() {
+  signal_lock();
+  jvm_signal_installed = true;
+  jvm_signal_installing = false;
+  pthread_cond_broadcast(&cond);
+  signal_unlock();
+}
+
+struct sigaction *JVM_get_signal_action(int sig) {
+  /* Does race condition make sense here? */
+  if ((MASK(sig) & jvmsigs) != 0) {
+    return &sact[sig];
+  }
+  return NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/jvm_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "prims/jvm.h"
+#include "runtime/interfaceSupport.hpp"
+#include "runtime/osThread.hpp"
+
+#include <signal.h>
+
+
+// sun.misc.Signal ///////////////////////////////////////////////////////////
+// Signal code is mostly copied from classic vm, signals_md.c   1.4 98/08/23
+/*
+ * This function is included primarily as a debugging aid. If Java is
+ * running in a console window, then pressing <CTRL-\\> will cause
+ * the current state of all active threads and monitors to be written
+ * to the console window.
+ */
+
+JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
+  // Copied from classic vm
+  // signals_md.c       1.4 98/08/23
+  void* newHandler = handler == (void *)2
+                   ? os::user_handler()
+                   : handler;
+  switch (sig) {
+    /* The following are already used by the VM. */
+    case INTERRUPT_SIGNAL:
+    case SIGFPE:
+    case SIGILL:
+    case SIGSEGV:
+
+    /* The following signal is used by the VM to dump thread stacks unless
+       ReduceSignalUsage is set, in which case the user is allowed to set
+       his own _native_ handler for this signal; thus, in either case,
+       we do not allow JVM_RegisterSignal to change the handler. */
+    case BREAK_SIGNAL:
+      return (void *)-1;
+
+    /* The following signals are used for Shutdown Hooks support. However, if
+       ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
+       System.exit(), Java is not allowed to use these signals, and the the
+       user is allowed to set his own _native_ handler for these signals and
+       invoke System.exit() as needed. Terminator.setup() is avoiding
+       registration of these signals when -Xrs is present.
+       - If the HUP signal is ignored (from the nohup) command, then Java
+         is not allowed to use this signal.
+     */
+
+    case SHUTDOWN1_SIGNAL:
+    case SHUTDOWN2_SIGNAL:
+    case SHUTDOWN3_SIGNAL:
+      if (ReduceSignalUsage) return (void*)-1;
+      if (os::Bsd::is_sig_ignored(sig)) return (void*)1;
+  }
+
+  void* oldHandler = os::signal(sig, newHandler);
+  if (oldHandler == os::user_handler()) {
+      return (void *)2;
+  } else {
+      return oldHandler;
+  }
+JVM_END
+
+
+JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
+  if (ReduceSignalUsage) {
+    // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,SHUTDOWN3_SIGNAL,
+    // BREAK_SIGNAL to be raised when ReduceSignalUsage is set, since
+    // no handler for them is actually registered in JVM or via
+    // JVM_RegisterSignal.
+    if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
+        sig == SHUTDOWN3_SIGNAL || sig == BREAK_SIGNAL) {
+      return JNI_FALSE;
+    }
+  }
+  else if ((sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
+            sig == SHUTDOWN3_SIGNAL) && os::Bsd::is_sig_ignored(sig)) {
+    // do not allow SHUTDOWN1_SIGNAL to be raised when SHUTDOWN1_SIGNAL
+    // is ignored, since no handler for them is actually registered in JVM
+    // or via JVM_RegisterSignal.
+    // This also applies for SHUTDOWN2_SIGNAL and SHUTDOWN3_SIGNAL
+    return JNI_FALSE;
+  }
+
+  os::signal_raise(sig);
+  return JNI_TRUE;
+JVM_END
+
+/*
+  All the defined signal names for Bsd.
+
+  NOTE that not all of these names are accepted by our Java implementation
+
+  Via an existing claim by the VM, sigaction restrictions, or
+  the "rules of Unix" some of these names will be rejected at runtime.
+  For example the VM sets up to handle USR1, sigaction returns EINVAL for
+  STOP, and Bsd simply doesn't allow catching of KILL.
+
+  Here are the names currently accepted by a user of sun.misc.Signal with
+  1.4.1 (ignoring potential interaction with use of chaining, etc):
+
+    HUP, INT, TRAP, ABRT, IOT, BUS, USR2, PIPE, ALRM, TERM, STKFLT,
+    CLD, CHLD, CONT, TSTP, TTIN, TTOU, URG, XCPU, XFSZ, VTALRM, PROF,
+    WINCH, POLL, IO, PWR, SYS
+
+*/
+
+struct siglabel {
+  const char *name;
+  int   number;
+};
+
+struct siglabel siglabels[] = {
+  /* derived from /usr/include/bits/signum.h on RH7.2 */
+   "HUP",       SIGHUP,         /* Hangup (POSIX).  */
+  "INT",        SIGINT,         /* Interrupt (ANSI).  */
+  "QUIT",       SIGQUIT,        /* Quit (POSIX).  */
+  "ILL",        SIGILL,         /* Illegal instruction (ANSI).  */
+  "TRAP",       SIGTRAP,        /* Trace trap (POSIX).  */
+  "ABRT",       SIGABRT,        /* Abort (ANSI).  */
+  "EMT",        SIGEMT,         /* EMT trap  */
+  "FPE",        SIGFPE,         /* Floating-point exception (ANSI).  */
+  "KILL",       SIGKILL,        /* Kill, unblockable (POSIX).  */
+  "BUS",        SIGBUS,         /* BUS error (4.2 BSD).  */
+  "SEGV",       SIGSEGV,        /* Segmentation violation (ANSI).  */
+  "SYS",        SIGSYS,         /* Bad system call. Only on some Bsden! */
+  "PIPE",       SIGPIPE,        /* Broken pipe (POSIX).  */
+  "ALRM",       SIGALRM,        /* Alarm clock (POSIX).  */
+  "TERM",       SIGTERM,        /* Termination (ANSI).  */
+  "URG",        SIGURG,         /* Urgent condition on socket (4.2 BSD).  */
+  "STOP",       SIGSTOP,        /* Stop, unblockable (POSIX).  */
+  "TSTP",       SIGTSTP,        /* Keyboard stop (POSIX).  */
+  "CONT",       SIGCONT,        /* Continue (POSIX).  */
+  "CHLD",       SIGCHLD,        /* Child status has changed (POSIX).  */
+  "TTIN",       SIGTTIN,        /* Background read from tty (POSIX).  */
+  "TTOU",       SIGTTOU,        /* Background write to tty (POSIX).  */
+  "IO",         SIGIO,          /* I/O now possible (4.2 BSD).  */
+  "XCPU",       SIGXCPU,        /* CPU limit exceeded (4.2 BSD).  */
+  "XFSZ",       SIGXFSZ,        /* File size limit exceeded (4.2 BSD).  */
+  "VTALRM",     SIGVTALRM,      /* Virtual alarm clock (4.2 BSD).  */
+  "PROF",       SIGPROF,        /* Profiling alarm clock (4.2 BSD).  */
+  "WINCH",      SIGWINCH,       /* Window size change (4.3 BSD, Sun).  */
+  "INFO",       SIGINFO,        /* Information request.  */
+  "USR1",       SIGUSR1,        /* User-defined signal 1 (POSIX).  */
+  "USR2",       SIGUSR2         /* User-defined signal 2 (POSIX).  */
+  };
+
+JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))
+
+  /* find and return the named signal's number */
+
+  for(uint i=0; i<ARRAY_SIZE(siglabels); i++)
+    if(!strcmp(name, siglabels[i].name))
+      return siglabels[i].number;
+
+  return -1;
+
+JVM_END
+
+// used by os::exception_name()
+extern bool signal_name(int signo, char* buf, size_t len) {
+  for(uint i = 0; i < ARRAY_SIZE(siglabels); i++) {
+    if (signo == siglabels[i].number) {
+      jio_snprintf(buf, len, "SIG%s", siglabels[i].name);
+      return true;
+    }
+  }
+  return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/jvm_bsd.h	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_BSD_VM_JVM_BSD_H
+#define OS_BSD_VM_JVM_BSD_H
+
+/*
+// HotSpot integration note:
+//
+// This is derived from the JDK classic file:
+// "$JDK/src/solaris/javavm/export/jvm_md.h":15 (ver. 1.10 98/04/22)
+// All local includes have been commented out.
+*/
+
+
+#ifndef JVM_MD_H
+#define JVM_MD_H
+
+/*
+ * This file is currently collecting system-specific dregs for the
+ * JNI conversion, which should be sorted out later.
+ */
+#ifdef __NetBSD__
+/*
+ * Since we are compiling with c++, we need the following to make c macros
+ * visible.
+ */
+# if !defined(__STDC_LIMIT_MACROS)
+#  define __STDC_LIMIT_MACROS           1
+# endif
+# if !defined(__STDC_CONSTANT_MACROS)
+#  define __STDC_CONSTANT_MACROS        1
+# endif
+# if !defined(__STDC_FORMAT_MACROS)
+#  define __STDC_FORMAT_MACROS          1
+# endif
+#endif
+
+#include <dirent.h>             /* For DIR */
+#include <sys/param.h>          /* For MAXPATHLEN */
+#include <unistd.h>             /* For F_OK, R_OK, W_OK */
+
+#define JNI_ONLOAD_SYMBOLS      {"JNI_OnLoad"}
+#define JNI_ONUNLOAD_SYMBOLS    {"JNI_OnUnload"}
+#define JVM_ONLOAD_SYMBOLS      {"JVM_OnLoad"}
+#define AGENT_ONLOAD_SYMBOLS    {"Agent_OnLoad"}
+#define AGENT_ONUNLOAD_SYMBOLS  {"Agent_OnUnload"}
+#define AGENT_ONATTACH_SYMBOLS  {"Agent_OnAttach"}
+
+#define JNI_LIB_PREFIX "lib"
+#ifdef __APPLE__
+#define JNI_LIB_SUFFIX ".dylib"
+#else
+#define JNI_LIB_SUFFIX ".so"
+#endif
+
+// Hack: MAXPATHLEN is 4095 on some Bsd and 4096 on others. This may
+//       cause problems if JVM and the rest of JDK are built on different
+//       Bsd releases. Here we define JVM_MAXPATHLEN to be MAXPATHLEN + 1,
+//       so buffers declared in VM are always >= 4096.
+#define JVM_MAXPATHLEN MAXPATHLEN + 1
+
+#define JVM_R_OK    R_OK
+#define JVM_W_OK    W_OK
+#define JVM_X_OK    X_OK
+#define JVM_F_OK    F_OK
+
+/*
+ * File I/O
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+/* O Flags */
+
+#define JVM_O_RDONLY     O_RDONLY
+#define JVM_O_WRONLY     O_WRONLY
+#define JVM_O_RDWR       O_RDWR
+#define JVM_O_O_APPEND   O_APPEND
+#define JVM_O_EXCL       O_EXCL
+#define JVM_O_CREAT      O_CREAT
+
+/* Signal definitions */
+
+#define BREAK_SIGNAL     SIGQUIT           /* Thread dumping support.    */
+#define INTERRUPT_SIGNAL SIGUSR1           /* Interruptible I/O support. */
+#define SHUTDOWN1_SIGNAL SIGHUP            /* Shutdown Hooks support.    */
+#define SHUTDOWN2_SIGNAL SIGINT
+#define SHUTDOWN3_SIGNAL SIGTERM
+
+#ifndef SIGRTMIN
+#ifdef __OpenBSD__
+#define SIGRTMIN        1
+#else
+#define SIGRTMIN        33
+#endif
+#endif
+#ifndef SIGRTMAX
+#ifdef __OpenBSD__
+#define SIGRTMAX        31
+#else
+#define SIGRTMAX        63
+#endif
+#endif
+#endif /* JVM_MD_H */
+
+// Reconciliation History
+// jvm_solaris.h        1.6 99/06/22 16:38:47
+// End
+
+#endif // OS_BSD_VM_JVM_BSD_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/mutex_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "mutex_bsd.inline.hpp"
+#include "runtime/interfaceSupport.hpp"
+#include "runtime/mutex.hpp"
+#include "thread_bsd.inline.hpp"
+#include "utilities/events.hpp"
+
+// put OS-includes here
+# include <signal.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/mutex_bsd.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_BSD_VM_MUTEX_BSD_INLINE_HPP
+#define OS_BSD_VM_MUTEX_BSD_INLINE_HPP
+
+#include "os_bsd.inline.hpp"
+#include "runtime/interfaceSupport.hpp"
+#include "thread_bsd.inline.hpp"
+
+
+// Reconciliation History
+// mutex_solaris.inline.hpp     1.5 99/06/22 16:38:49
+// End
+
+#endif // OS_BSD_VM_MUTEX_BSD_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/osThread_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+// no precompiled headers
+#include "runtime/atomic.hpp"
+#include "runtime/handles.inline.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/os.hpp"
+#include "runtime/osThread.hpp"
+#include "runtime/safepoint.hpp"
+#include "runtime/vmThread.hpp"
+#ifdef TARGET_ARCH_x86
+# include "assembler_x86.inline.hpp"
+#endif
+#ifdef TARGET_ARCH_sparc
+# include "assembler_sparc.inline.hpp"
+#endif
+#ifdef TARGET_ARCH_zero
+# include "assembler_zero.inline.hpp"
+#endif
+#ifdef TARGET_ARCH_arm
+# include "assembler_arm.inline.hpp"
+#endif
+#ifdef TARGET_ARCH_ppc
+# include "assembler_ppc.inline.hpp"
+#endif
+
+
+void OSThread::pd_initialize() {
+  assert(this != NULL, "check");
+  _thread_id        = NULL;
+  _pthread_id       = NULL;
+  _siginfo = NULL;
+  _ucontext = NULL;
+  _expanding_stack = 0;
+  _alt_sig_stack = NULL;
+
+  sigemptyset(&_caller_sigmask);
+
+  _startThread_lock = new Monitor(Mutex::event, "startThread_lock", true);
+  assert(_startThread_lock !=NULL, "check");
+}
+
+void OSThread::pd_destroy() {
+  delete _startThread_lock;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/osThread_bsd.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_BSD_VM_OSTHREAD_BSD_HPP
+#define OS_BSD_VM_OSTHREAD_BSD_HPP
+
+ private:
+  int _thread_type;
+
+ public:
+
+  int thread_type() const {
+    return _thread_type;
+  }
+  void set_thread_type(int type) {
+    _thread_type = type;
+  }
+
+ private:
+
+#ifdef _ALLBSD_SOURCE
+  // _thread_id and _pthread_id are the same on BSD
+  // keep both to minimize code divergence in os_bsd.cpp
+  pthread_t _thread_id;
+  pthread_t _pthread_id;
+#else
+  // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
+  // thread has a unique thread_id (BsdThreads or NPTL). It can be used
+  // to access /proc.
+  pid_t     _thread_id;
+
+  // _pthread_id is the pthread id, which is used by library calls
+  // (e.g. pthread_kill).
+  pthread_t _pthread_id;
+#endif
+
+  sigset_t _caller_sigmask; // Caller's signal mask
+
+ public:
+
+  // Methods to save/restore caller's signal mask
+  sigset_t  caller_sigmask() const       { return _caller_sigmask; }
+  void    set_caller_sigmask(sigset_t sigmask)  { _caller_sigmask = sigmask; }
+
+#ifdef _ALLBSD_SOURCE
+  pthread_t thread_id() const {
+    return _thread_id;
+  }
+#else
+  pid_t thread_id() const {
+    return _thread_id;
+  }
+#endif
+#ifndef PRODUCT
+  // Used for debugging, return a unique integer for each thread.
+  intptr_t thread_identifier() const   { return (intptr_t)_pthread_id; }
+#endif
+#ifdef ASSERT
+  // We expect no reposition failures so kill vm if we get one.
+  //
+  bool valid_reposition_failure() {
+    return false;
+  }
+#endif // ASSERT
+#ifdef _ALLBSD_SOURCE
+  void set_thread_id(pthread_t id) {
+    _thread_id = id;
+  }
+#else
+  void set_thread_id(pid_t id) {
+    _thread_id = id;
+  }
+#endif
+  pthread_t pthread_id() const {
+    return _pthread_id;
+  }
+  void set_pthread_id(pthread_t tid) {
+    _pthread_id = tid;
+  }
+
+  // ***************************************************************
+  // suspension support.
+  // ***************************************************************
+
+public:
+  // flags that support signal based suspend/resume on Bsd are in a
+  // separate class to avoid confusion with many flags in OSThread that
+  // are used by VM level suspend/resume.
+  os::Bsd::SuspendResume sr;
+
+  // _ucontext and _siginfo are used by SR_handler() to save thread context,
+  // and they will later be used to walk the stack or reposition thread PC.
+  // If the thread is not suspended in SR_handler() (e.g. self suspend),
+  // the value in _ucontext is meaningless, so we must use the last Java
+  // frame information as the frame. This will mean that for threads
+  // that are parked on a mutex the profiler (and safepoint mechanism)
+  // will see the thread as if it were still in the Java frame. This
+  // not a problem for the profiler since the Java frame is a close
+  // enough result. For the safepoint mechanism when the give it the
+  // Java frame we are not at a point where the safepoint needs the
+  // frame to that accurate (like for a compiled safepoint) since we
+  // should be in a place where we are native and will block ourselves
+  // if we transition.
+private:
+  void* _siginfo;
+  ucontext_t* _ucontext;
+  int _expanding_stack;                 /* non zero if manually expanding stack */
+  address _alt_sig_stack;               /* address of base of alternate signal stack */
+
+public:
+  void* siginfo() const                   { return _siginfo;  }
+  void set_siginfo(void* ptr)             { _siginfo = ptr;   }
+  ucontext_t* ucontext() const            { return _ucontext; }
+  void set_ucontext(ucontext_t* ptr)      { _ucontext = ptr;  }
+  void set_expanding_stack(void)          { _expanding_stack = 1;  }
+  void clear_expanding_stack(void)        { _expanding_stack = 0;  }
+  int  expanding_stack(void)              { return _expanding_stack;  }
+
+  void set_alt_sig_stack(address val)     { _alt_sig_stack = val; }
+  address alt_sig_stack(void)             { return _alt_sig_stack; }
+
+private:
+  Monitor* _startThread_lock;     // sync parent and child in thread creation
+
+public:
+
+  Monitor* startThread_lock() const {
+    return _startThread_lock;
+  }
+
+  // ***************************************************************
+  // Platform dependent initialization and cleanup
+  // ***************************************************************
+
+private:
+
+  void pd_initialize();
+  void pd_destroy();
+
+// Reconciliation History
+// osThread_solaris.hpp 1.24 99/08/27 13:11:54
+// End
+
+#endif // OS_BSD_VM_OSTHREAD_BSD_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,5816 @@
+/*
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+// no precompiled headers
+#include "classfile/classLoader.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "classfile/vmSymbols.hpp"
+#include "code/icBuffer.hpp"
+#include "code/vtableStubs.hpp"
+#include "compiler/compileBroker.hpp"
+#include "interpreter/interpreter.hpp"
+#include "jvm_bsd.h"
+#include "memory/allocation.inline.hpp"
+#include "memory/filemap.hpp"
+#include "mutex_bsd.inline.hpp"
+#include "oops/oop.inline.hpp"
+#include "os_share_bsd.hpp"
+#include "prims/jniFastGetField.hpp"
+#include "prims/jvm.h"
+#include "prims/jvm_misc.hpp"
+#include "runtime/arguments.hpp"
+#include "runtime/extendedPC.hpp"
+#include "runtime/globals.hpp"
+#include "runtime/interfaceSupport.hpp"
+#include "runtime/java.hpp"
+#include "runtime/javaCalls.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/objectMonitor.hpp"
+#include "runtime/osThread.hpp"
+#include "runtime/perfMemory.hpp"
+#include "runtime/sharedRuntime.hpp"
+#include "runtime/statSampler.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "runtime/threadCritical.hpp"
+#include "runtime/timer.hpp"
+#include "services/attachListener.hpp"
+#include "services/runtimeService.hpp"
+#include "thread_bsd.inline.hpp"
+#include "utilities/decoder.hpp"
+#include "utilities/defaultStream.hpp"
+#include "utilities/events.hpp"
+#include "utilities/growableArray.hpp"
+#include "utilities/vmError.hpp"
+#ifdef TARGET_ARCH_x86
+# include "assembler_x86.inline.hpp"
+# include "nativeInst_x86.hpp"
+#endif
+#ifdef TARGET_ARCH_sparc
+# include "assembler_sparc.inline.hpp"
+# include "nativeInst_sparc.hpp"
+#endif
+#ifdef TARGET_ARCH_zero
+# include "assembler_zero.inline.hpp"
+# include "nativeInst_zero.hpp"
+#endif
+#ifdef TARGET_ARCH_arm
+# include "assembler_arm.inline.hpp"
+# include "nativeInst_arm.hpp"
+#endif
+#ifdef TARGET_ARCH_ppc
+# include "assembler_ppc.inline.hpp"
+# include "nativeInst_ppc.hpp"
+#endif
+#ifdef COMPILER1
+#include "c1/c1_Runtime1.hpp"
+#endif
+#ifdef COMPILER2
+#include "opto/runtime.hpp"
+#endif
+
+// put OS-includes here
+# include <sys/types.h>
+# include <sys/mman.h>
+# include <sys/stat.h>
+# include <sys/select.h>
+# include <pthread.h>
+# include <signal.h>
+# include <errno.h>
+# include <dlfcn.h>
+# include <stdio.h>
+# include <unistd.h>
+# include <sys/resource.h>
+# include <pthread.h>
+# include <sys/stat.h>
+# include <sys/time.h>
+# include <sys/times.h>
+# include <sys/utsname.h>
+# include <sys/socket.h>
+# include <sys/wait.h>
+# include <time.h>
+# include <pwd.h>
+# include <poll.h>
+# include <semaphore.h>
+# include <fcntl.h>
+# include <string.h>
+#ifdef _ALLBSD_SOURCE
+# include <sys/param.h>
+# include <sys/sysctl.h>
+#else
+# include <syscall.h>
+# include <sys/sysinfo.h>
+# include <gnu/libc-version.h>
+#endif
+# include <sys/ipc.h>
+# include <sys/shm.h>
+#ifndef __APPLE__
+# include <link.h>
+#endif
+# include <stdint.h>
+# include <inttypes.h>
+# include <sys/ioctl.h>
+
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+# include <elf.h>
+#endif
+
+#ifdef __APPLE__
+# include <mach/mach.h> // semaphore_* API
+# include <mach-o/dyld.h>
+# include <sys/proc_info.h>
+# include <objc/objc-auto.h>
+#endif
+
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+#define MAX_PATH    (2 * K)
+
+// for timer info max values which include all bits
+#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
+#define SEC_IN_NANOSECS  1000000000LL
+
+#define LARGEPAGES_BIT (1 << 6)
+////////////////////////////////////////////////////////////////////////////////
+// global variables
+julong os::Bsd::_physical_memory = 0;
+
+#ifndef _ALLBSD_SOURCE
+address   os::Bsd::_initial_thread_stack_bottom = NULL;
+uintptr_t os::Bsd::_initial_thread_stack_size   = 0;
+#endif
+
+int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL;
+#ifndef _ALLBSD_SOURCE
+int (*os::Bsd::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
+Mutex* os::Bsd::_createThread_lock = NULL;
+#endif
+pthread_t os::Bsd::_main_thread;
+int os::Bsd::_page_size = -1;
+#ifndef _ALLBSD_SOURCE
+bool os::Bsd::_is_floating_stack = false;
+bool os::Bsd::_is_NPTL = false;
+bool os::Bsd::_supports_fast_thread_cpu_time = false;
+const char * os::Bsd::_glibc_version = NULL;
+const char * os::Bsd::_libpthread_version = NULL;
+#endif
+
+static jlong initial_time_count=0;
+
+static int clock_tics_per_sec = 100;
+
+// For diagnostics to print a message once. see run_periodic_checks
+static sigset_t check_signal_done;
+static bool check_signals = true;;
+
+static pid_t _initial_pid = 0;
+
+/* Signal number used to suspend/resume a thread */
+
+/* do not use any signal number less than SIGSEGV, see 4355769 */
+static int SR_signum = SIGUSR2;
+sigset_t SR_sigset;
+
+
+////////////////////////////////////////////////////////////////////////////////
+// utility functions
+
+static int SR_initialize();
+static int SR_finalize();
+
+julong os::available_memory() {
+  return Bsd::available_memory();
+}
+
+julong os::Bsd::available_memory() {
+#ifdef _ALLBSD_SOURCE
+  // XXXBSD: this is just a stopgap implementation
+  return physical_memory() >> 2;
+#else
+  // values in struct sysinfo are "unsigned long"
+  struct sysinfo si;
+  sysinfo(&si);
+
+  return (julong)si.freeram * si.mem_unit;
+#endif
+}
+
+julong os::physical_memory() {
+  return Bsd::physical_memory();
+}
+
+julong os::allocatable_physical_memory(julong size) {
+#ifdef _LP64
+  return size;
+#else
+  julong result = MIN2(size, (julong)3800*M);
+   if (!is_allocatable(result)) {
+     // See comments under solaris for alignment considerations
+     julong reasonable_size = (julong)2*G - 2 * os::vm_page_size();
+     result =  MIN2(size, reasonable_size);
+   }
+   return result;
+#endif // _LP64
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// environment support
+
+bool os::getenv(const char* name, char* buf, int len) {
+  const char* val = ::getenv(name);
+  if (val != NULL && strlen(val) < (size_t)len) {
+    strcpy(buf, val);
+    return true;
+  }
+  if (len > 0) buf[0] = 0;  // return a null string
+  return false;
+}
+
+
+// Return true if user is running as root.
+
+bool os::have_special_privileges() {
+  static bool init = false;
+  static bool privileges = false;
+  if (!init) {
+    privileges = (getuid() != geteuid()) || (getgid() != getegid());
+    init = true;
+  }
+  return privileges;
+}
+
+
+#ifndef _ALLBSD_SOURCE
+#ifndef SYS_gettid
+// i386: 224, ia64: 1105, amd64: 186, sparc 143
+#ifdef __ia64__
+#define SYS_gettid 1105
+#elif __i386__
+#define SYS_gettid 224
+#elif __amd64__
+#define SYS_gettid 186
+#elif __sparc__
+#define SYS_gettid 143
+#else
+#error define gettid for the arch
+#endif
+#endif
+#endif
+
+// Cpu architecture string
+#if   defined(ZERO)
+static char cpu_arch[] = ZERO_LIBARCH;
+#elif defined(IA64)
+static char cpu_arch[] = "ia64";
+#elif defined(IA32)
+static char cpu_arch[] = "i386";
+#elif defined(AMD64)
+static char cpu_arch[] = "amd64";
+#elif defined(ARM)
+static char cpu_arch[] = "arm";
+#elif defined(PPC)
+static char cpu_arch[] = "ppc";
+#elif defined(SPARC)
+#  ifdef _LP64
+static char cpu_arch[] = "sparcv9";
+#  else
+static char cpu_arch[] = "sparc";
+#  endif
+#else
+#error Add appropriate cpu_arch setting
+#endif
+
+
+#ifndef _ALLBSD_SOURCE
+// pid_t gettid()
+//
+// Returns the kernel thread id of the currently running thread. Kernel
+// thread id is used to access /proc.
+//
+// (Note that getpid() on BsdThreads returns kernel thread id too; but
+// on NPTL, it returns the same pid for all threads, as required by POSIX.)
+//
+pid_t os::Bsd::gettid() {
+  int rslt = syscall(SYS_gettid);
+  if (rslt == -1) {
+     // old kernel, no NPTL support
+     return getpid();
+  } else {
+     return (pid_t)rslt;
+  }
+}
+
+// Most versions of bsd have a bug where the number of processors are
+// determined by looking at the /proc file system.  In a chroot environment,
+// the system call returns 1.  This causes the VM to act as if it is
+// a single processor and elide locking (see is_MP() call).
+static bool unsafe_chroot_detected = false;
+static const char *unstable_chroot_error = "/proc file system not found.\n"
+                     "Java may be unstable running multithreaded in a chroot "
+                     "environment on Bsd when /proc filesystem is not mounted.";
+#endif
+
+#ifdef _ALLBSD_SOURCE
+void os::Bsd::initialize_system_info() {
+  int mib[2];
+  size_t len;
+  int cpu_val;
+  u_long mem_val;
+
+  /* get processors count via hw.ncpus sysctl */
+  mib[0] = CTL_HW;
+  mib[1] = HW_NCPU;
+  len = sizeof(cpu_val);
+  if (sysctl(mib, 2, &cpu_val, &len, NULL, 0) != -1 && cpu_val >= 1) {
+       set_processor_count(cpu_val);
+  }
+  else {
+       set_processor_count(1);   // fallback
+  }
+
+  /* get physical memory via hw.usermem sysctl (hw.usermem is used
+   * instead of hw.physmem because we need size of allocatable memory
+   */
+  mib[0] = CTL_HW;
+  mib[1] = HW_USERMEM;
+  len = sizeof(mem_val);
+  if (sysctl(mib, 2, &mem_val, &len, NULL, 0) != -1)
+       _physical_memory = mem_val;
+  else
+       _physical_memory = 256*1024*1024;       // fallback (XXXBSD?)
+
+#ifdef __OpenBSD__
+  {
+       // limit _physical_memory memory view on OpenBSD since
+       // datasize rlimit restricts us anyway.
+       struct rlimit limits;
+       getrlimit(RLIMIT_DATA, &limits);
+       _physical_memory = MIN2(_physical_memory, (julong)limits.rlim_cur);
+  }
+#endif
+}
+#else
+void os::Bsd::initialize_system_info() {
+  set_processor_count(sysconf(_SC_NPROCESSORS_CONF));
+  if (processor_count() == 1) {
+    pid_t pid = os::Bsd::gettid();
+    char fname[32];
+    jio_snprintf(fname, sizeof(fname), "/proc/%d", pid);
+    FILE *fp = fopen(fname, "r");
+    if (fp == NULL) {
+      unsafe_chroot_detected = true;
+    } else {
+      fclose(fp);
+    }
+  }
+  _physical_memory = (julong)sysconf(_SC_PHYS_PAGES) * (julong)sysconf(_SC_PAGESIZE);
+  assert(processor_count() > 0, "bsd error");
+}
+#endif
+
+#ifdef __APPLE__
+static const char *get_home() {
+  const char *home_dir = ::getenv("HOME");
+  if ((home_dir == NULL) || (*home_dir == '\0')) {
+    struct passwd *passwd_info = getpwuid(geteuid());
+    if (passwd_info != NULL) {
+      home_dir = passwd_info->pw_dir;
+    }
+  }
+
+  return home_dir;
+}
+#endif
+
+void os::init_system_properties_values() {
+//  char arch[12];
+//  sysinfo(SI_ARCHITECTURE, arch, sizeof(arch));
+
+  // The next steps are taken in the product version:
+  //
+  // Obtain the JAVA_HOME value from the location of libjvm[_g].so.
+  // This library should be located at:
+  // <JAVA_HOME>/jre/lib/<arch>/{client|server}/libjvm[_g].so.
+  //
+  // If "/jre/lib/" appears at the right place in the path, then we
+  // assume libjvm[_g].so is installed in a JDK and we use this path.
+  //
+  // Otherwise exit with message: "Could not create the Java virtual machine."
+  //
+  // The following extra steps are taken in the debugging version:
+  //
+  // If "/jre/lib/" does NOT appear at the right place in the path
+  // instead of exit check for $JAVA_HOME environment variable.
+  //
+  // If it is defined and we are able to locate $JAVA_HOME/jre/lib/<arch>,
+  // then we append a fake suffix "hotspot/libjvm[_g].so" to this path so
+  // it looks like libjvm[_g].so is installed there
+  // <JAVA_HOME>/jre/lib/<arch>/hotspot/libjvm[_g].so.
+  //
+  // Otherwise exit.
+  //
+  // Important note: if the location of libjvm.so changes this
+  // code needs to be changed accordingly.
+
+  // The next few definitions allow the code to be verbatim:
+#define malloc(n) (char*)NEW_C_HEAP_ARRAY(char, (n))
+#define getenv(n) ::getenv(n)
+
+/*
+ * See ld(1):
+ *      The linker uses the following search paths to locate required
+ *      shared libraries:
+ *        1: ...
+ *        ...
+ *        7: The default directories, normally /lib and /usr/lib.
+ */
+#ifndef DEFAULT_LIBPATH
+#define DEFAULT_LIBPATH "/lib:/usr/lib"
+#endif
+
+#define EXTENSIONS_DIR  "/lib/ext"
+#define ENDORSED_DIR    "/lib/endorsed"
+#define REG_DIR         "/usr/java/packages"
+
+#ifdef __APPLE__
+#define SYS_EXTENSIONS_DIR   "/Library/Java/Extensions"
+#define SYS_EXTENSIONS_DIRS  SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java"
+        const char *user_home_dir = get_home();
+        // the null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir
+        int system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) +
+            sizeof(SYS_EXTENSIONS_DIRS);
+#endif
+
+  {
+    /* sysclasspath, java_home, dll_dir */
+    {
+        char *home_path;
+        char *dll_path;
+        char *pslash;
+        char buf[MAXPATHLEN];
+        os::jvm_path(buf, sizeof(buf));
+
+        // Found the full path to libjvm.so.
+        // Now cut the path to <java_home>/jre if we can.
+        *(strrchr(buf, '/')) = '\0';  /* get rid of /libjvm.so */
+        pslash = strrchr(buf, '/');
+        if (pslash != NULL)
+            *pslash = '\0';           /* get rid of /{client|server|hotspot} */
+        dll_path = malloc(strlen(buf) + 1);
+        if (dll_path == NULL)
+            return;
+        strcpy(dll_path, buf);
+        Arguments::set_dll_dir(dll_path);
+
+        if (pslash != NULL) {
+            pslash = strrchr(buf, '/');
+            if (pslash != NULL) {
+                *pslash = '\0';       /* get rid of /<arch> (/lib on macosx) */
+#ifndef __APPLE__
+                pslash = strrchr(buf, '/');
+                if (pslash != NULL)
+                    *pslash = '\0';   /* get rid of /lib */
+#endif
+            }
+        }
+
+        home_path = malloc(strlen(buf) + 1);
+        if (home_path == NULL)
+            return;
+        strcpy(home_path, buf);
+        Arguments::set_java_home(home_path);
+
+        if (!set_boot_path('/', ':'))
+            return;
+    }
+
+    /*
+     * Where to look for native libraries
+     *
+     * Note: Due to a legacy implementation, most of the library path
+     * is set in the launcher.  This was to accomodate linking restrictions
+     * on legacy Bsd implementations (which are no longer supported).
+     * Eventually, all the library path setting will be done here.
+     *
+     * However, to prevent the proliferation of improperly built native
+     * libraries, the new path component /usr/java/packages is added here.
+     * Eventually, all the library path setting will be done here.
+     */
+    {
+        char *ld_library_path;
+
+        /*
+         * Construct the invariant part of ld_library_path. Note that the
+         * space for the colon and the trailing null are provided by the
+         * nulls included by the sizeof operator (so actually we allocate
+         * a byte more than necessary).
+         */
+#ifdef __APPLE__
+        ld_library_path = (char *) malloc(system_ext_size);
+        sprintf(ld_library_path, "%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS, user_home_dir);
+#else
+        ld_library_path = (char *) malloc(sizeof(REG_DIR) + sizeof("/lib/") +
+            strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH));
+        sprintf(ld_library_path, REG_DIR "/lib/%s:" DEFAULT_LIBPATH, cpu_arch);
+#endif
+
+        /*
+         * Get the user setting of LD_LIBRARY_PATH, and prepended it.  It
+         * should always exist (until the legacy problem cited above is
+         * addressed).
+         */
+#ifdef __APPLE__
+        // Prepend the default path with the JAVA_LIBRARY_PATH so that the app launcher code can specify a directory inside an app wrapper
+        char *l = getenv("JAVA_LIBRARY_PATH");
+        if (l != NULL) {
+            char *t = ld_library_path;
+            /* That's +1 for the colon and +1 for the trailing '\0' */
+            ld_library_path = (char *) malloc(strlen(l) + 1 + strlen(t) + 1);
+            sprintf(ld_library_path, "%s:%s", l, t);
+            free(t);
+        }
+
+        char *v = getenv("DYLD_LIBRARY_PATH");
+#else
+        char *v = getenv("LD_LIBRARY_PATH");
+#endif
+        if (v != NULL) {
+            char *t = ld_library_path;
+            /* That's +1 for the colon and +1 for the trailing '\0' */
+            ld_library_path = (char *) malloc(strlen(v) + 1 + strlen(t) + 1);
+            sprintf(ld_library_path, "%s:%s", v, t);
+            free(t);
+        }
+        Arguments::set_library_path(ld_library_path);
+    }
+
+    /*
+     * Extensions directories.
+     *
+     * Note that the space for the colon and the trailing null are provided
+     * by the nulls included by the sizeof operator (so actually one byte more
+     * than necessary is allocated).
+     */
+    {
+#ifdef __APPLE__
+        char *buf = malloc(strlen(Arguments::get_java_home()) +
+            sizeof(EXTENSIONS_DIR) + system_ext_size);
+        sprintf(buf, "%s" SYS_EXTENSIONS_DIR ":%s" EXTENSIONS_DIR ":"
+            SYS_EXTENSIONS_DIRS, user_home_dir, Arguments::get_java_home());
+#else
+        char *buf = malloc(strlen(Arguments::get_java_home()) +
+            sizeof(EXTENSIONS_DIR) + sizeof(REG_DIR) + sizeof(EXTENSIONS_DIR));
+        sprintf(buf, "%s" EXTENSIONS_DIR ":" REG_DIR EXTENSIONS_DIR,
+            Arguments::get_java_home());
+#endif
+
+        Arguments::set_ext_dirs(buf);
+    }
+
+    /* Endorsed standards default directory. */
+    {
+        char * buf;
+        buf = malloc(strlen(Arguments::get_java_home()) + sizeof(ENDORSED_DIR));
+        sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
+        Arguments::set_endorsed_dirs(buf);
+    }
+  }
+
+#ifdef __APPLE__
+#undef SYS_EXTENSIONS_DIR
+#endif
+#undef malloc
+#undef getenv
+#undef EXTENSIONS_DIR
+#undef ENDORSED_DIR
+
+  // Done
+  return;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// breakpoint support
+
+void os::breakpoint() {
+  BREAKPOINT;
+}
+
+extern "C" void breakpoint() {
+  // use debugger to set breakpoint here
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// signal support
+
+debug_only(static bool signal_sets_initialized = false);
+static sigset_t unblocked_sigs, vm_sigs, allowdebug_blocked_sigs;
+
+bool os::Bsd::is_sig_ignored(int sig) {
+      struct sigaction oact;
+      sigaction(sig, (struct sigaction*)NULL, &oact);
+      void* ohlr = oact.sa_sigaction ? CAST_FROM_FN_PTR(void*,  oact.sa_sigaction)
+                                     : CAST_FROM_FN_PTR(void*,  oact.sa_handler);
+      if (ohlr == CAST_FROM_FN_PTR(void*, SIG_IGN))
+           return true;
+      else
+           return false;
+}
+
+void os::Bsd::signal_sets_init() {
+  // Should also have an assertion stating we are still single-threaded.
+  assert(!signal_sets_initialized, "Already initialized");
+  // Fill in signals that are necessarily unblocked for all threads in
+  // the VM. Currently, we unblock the following signals:
+  // SHUTDOWN{1,2,3}_SIGNAL: for shutdown hooks support (unless over-ridden
+  //                         by -Xrs (=ReduceSignalUsage));
+  // BREAK_SIGNAL which is unblocked only by the VM thread and blocked by all
+  // other threads. The "ReduceSignalUsage" boolean tells us not to alter
+  // the dispositions or masks wrt these signals.
+  // Programs embedding the VM that want to use the above signals for their
+  // own purposes must, at this time, use the "-Xrs" option to prevent
+  // interference with shutdown hooks and BREAK_SIGNAL thread dumping.
+  // (See bug 4345157, and other related bugs).
+  // In reality, though, unblocking these signals is really a nop, since
+  // these signals are not blocked by default.
+  sigemptyset(&unblocked_sigs);
+  sigemptyset(&allowdebug_blocked_sigs);
+  sigaddset(&unblocked_sigs, SIGILL);
+  sigaddset(&unblocked_sigs, SIGSEGV);
+  sigaddset(&unblocked_sigs, SIGBUS);
+  sigaddset(&unblocked_sigs, SIGFPE);
+  sigaddset(&unblocked_sigs, SR_signum);
+
+  if (!ReduceSignalUsage) {
+   if (!os::Bsd::is_sig_ignored(SHUTDOWN1_SIGNAL)) {
+      sigaddset(&unblocked_sigs, SHUTDOWN1_SIGNAL);
+      sigaddset(&allowdebug_blocked_sigs, SHUTDOWN1_SIGNAL);
+   }
+   if (!os::Bsd::is_sig_ignored(SHUTDOWN2_SIGNAL)) {
+      sigaddset(&unblocked_sigs, SHUTDOWN2_SIGNAL);
+      sigaddset(&allowdebug_blocked_sigs, SHUTDOWN2_SIGNAL);
+   }
+   if (!os::Bsd::is_sig_ignored(SHUTDOWN3_SIGNAL)) {
+      sigaddset(&unblocked_sigs, SHUTDOWN3_SIGNAL);
+      sigaddset(&allowdebug_blocked_sigs, SHUTDOWN3_SIGNAL);
+   }
+  }
+  // Fill in signals that are blocked by all but the VM thread.
+  sigemptyset(&vm_sigs);
+  if (!ReduceSignalUsage)
+    sigaddset(&vm_sigs, BREAK_SIGNAL);
+  debug_only(signal_sets_initialized = true);
+
+}
+
+// These are signals that are unblocked while a thread is running Java.
+// (For some reason, they get blocked by default.)
+sigset_t* os::Bsd::unblocked_signals() {
+  assert(signal_sets_initialized, "Not initialized");
+  return &unblocked_sigs;
+}
+
+// These are the signals that are blocked while a (non-VM) thread is
+// running Java. Only the VM thread handles these signals.
+sigset_t* os::Bsd::vm_signals() {
+  assert(signal_sets_initialized, "Not initialized");
+  return &vm_sigs;
+}
+
+// These are signals that are blocked during cond_wait to allow debugger in
+sigset_t* os::Bsd::allowdebug_blocked_signals() {
+  assert(signal_sets_initialized, "Not initialized");
+  return &allowdebug_blocked_sigs;
+}
+
+void os::Bsd::hotspot_sigmask(Thread* thread) {
+
+  //Save caller's signal mask before setting VM signal mask
+  sigset_t caller_sigmask;
+  pthread_sigmask(SIG_BLOCK, NULL, &caller_sigmask);
+
+  OSThread* osthread = thread->osthread();
+  osthread->set_caller_sigmask(caller_sigmask);
+
+  pthread_sigmask(SIG_UNBLOCK, os::Bsd::unblocked_signals(), NULL);
+
+  if (!ReduceSignalUsage) {
+    if (thread->is_VM_thread()) {
+      // Only the VM thread handles BREAK_SIGNAL ...
+      pthread_sigmask(SIG_UNBLOCK, vm_signals(), NULL);
+    } else {
+      // ... all other threads block BREAK_SIGNAL
+      pthread_sigmask(SIG_BLOCK, vm_signals(), NULL);
+    }
+  }
+}
+
+#ifndef _ALLBSD_SOURCE
+//////////////////////////////////////////////////////////////////////////////
+// detecting pthread library
+
+void os::Bsd::libpthread_init() {
+  // Save glibc and pthread version strings. Note that _CS_GNU_LIBC_VERSION
+  // and _CS_GNU_LIBPTHREAD_VERSION are supported in glibc >= 2.3.2. Use a
+  // generic name for earlier versions.
+  // Define macros here so we can build HotSpot on old systems.
+# ifndef _CS_GNU_LIBC_VERSION
+# define _CS_GNU_LIBC_VERSION 2
+# endif
+# ifndef _CS_GNU_LIBPTHREAD_VERSION
+# define _CS_GNU_LIBPTHREAD_VERSION 3
+# endif
+
+  size_t n = confstr(_CS_GNU_LIBC_VERSION, NULL, 0);
+  if (n > 0) {
+     char *str = (char *)malloc(n);
+     confstr(_CS_GNU_LIBC_VERSION, str, n);
+     os::Bsd::set_glibc_version(str);
+  } else {
+     // _CS_GNU_LIBC_VERSION is not supported, try gnu_get_libc_version()
+     static char _gnu_libc_version[32];
+     jio_snprintf(_gnu_libc_version, sizeof(_gnu_libc_version),
+              "glibc %s %s", gnu_get_libc_version(), gnu_get_libc_release());
+     os::Bsd::set_glibc_version(_gnu_libc_version);
+  }
+
+  n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0);
+  if (n > 0) {
+     char *str = (char *)malloc(n);
+     confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n);
+     // Vanilla RH-9 (glibc 2.3.2) has a bug that confstr() always tells
+     // us "NPTL-0.29" even we are running with BsdThreads. Check if this
+     // is the case. BsdThreads has a hard limit on max number of threads.
+     // So sysconf(_SC_THREAD_THREADS_MAX) will return a positive value.
+     // On the other hand, NPTL does not have such a limit, sysconf()
+     // will return -1 and errno is not changed. Check if it is really NPTL.
+     if (strcmp(os::Bsd::glibc_version(), "glibc 2.3.2") == 0 &&
+         strstr(str, "NPTL") &&
+         sysconf(_SC_THREAD_THREADS_MAX) > 0) {
+       free(str);
+       os::Bsd::set_libpthread_version("bsdthreads");
+     } else {
+       os::Bsd::set_libpthread_version(str);
+     }
+  } else {
+    // glibc before 2.3.2 only has BsdThreads.
+    os::Bsd::set_libpthread_version("bsdthreads");
+  }
+
+  if (strstr(libpthread_version(), "NPTL")) {
+     os::Bsd::set_is_NPTL();
+  } else {
+     os::Bsd::set_is_BsdThreads();
+  }
+
+  // BsdThreads have two flavors: floating-stack mode, which allows variable
+  // stack size; and fixed-stack mode. NPTL is always floating-stack.
+  if (os::Bsd::is_NPTL() || os::Bsd::supports_variable_stack_size()) {
+     os::Bsd::set_is_floating_stack();
+  }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// thread stack
+
+// Force Bsd kernel to expand current thread stack. If "bottom" is close
+// to the stack guard, caller should block all signals.
+//
+// MAP_GROWSDOWN:
+//   A special mmap() flag that is used to implement thread stacks. It tells
+//   kernel that the memory region should extend downwards when needed. This
+//   allows early versions of BsdThreads to only mmap the first few pages
+//   when creating a new thread. Bsd kernel will automatically expand thread
+//   stack as needed (on page faults).
+//
+//   However, because the memory region of a MAP_GROWSDOWN stack can grow on
+//   demand, if a page fault happens outside an already mapped MAP_GROWSDOWN
+//   region, it's hard to tell if the fault is due to a legitimate stack
+//   access or because of reading/writing non-exist memory (e.g. buffer
+//   overrun). As a rule, if the fault happens below current stack pointer,
+//   Bsd kernel does not expand stack, instead a SIGSEGV is sent to the
+//   application (see Bsd kernel fault.c).
+//
+//   This Bsd feature can cause SIGSEGV when VM bangs thread stack for
+//   stack overflow detection.
+//
+//   Newer version of BsdThreads (since glibc-2.2, or, RH-7.x) and NPTL do
+//   not use this flag. However, the stack of initial thread is not created
+//   by pthread, it is still MAP_GROWSDOWN. Also it's possible (though
+//   unlikely) that user code can create a thread with MAP_GROWSDOWN stack
+//   and then attach the thread to JVM.
+//
+// To get around the problem and allow stack banging on Bsd, we need to
+// manually expand thread stack after receiving the SIGSEGV.
+//
+// There are two ways to expand thread stack to address "bottom", we used
+// both of them in JVM before 1.5:
+//   1. adjust stack pointer first so that it is below "bottom", and then
+//      touch "bottom"
+//   2. mmap() the page in question
+//
+// Now alternate signal stack is gone, it's harder to use 2. For instance,
+// if current sp is already near the lower end of page 101, and we need to
+// call mmap() to map page 100, it is possible that part of the mmap() frame
+// will be placed in page 100. When page 100 is mapped, it is zero-filled.
+// That will destroy the mmap() frame and cause VM to crash.
+//
+// The following code works by adjusting sp first, then accessing the "bottom"
+// page to force a page fault. Bsd kernel will then automatically expand the
+// stack mapping.
+//
+// _expand_stack_to() assumes its frame size is less than page size, which
+// should always be true if the function is not inlined.
+
+#if __GNUC__ < 3    // gcc 2.x does not support noinline attribute
+#define NOINLINE
+#else
+#define NOINLINE __attribute__ ((noinline))
+#endif
+
+static void _expand_stack_to(address bottom) NOINLINE;
+
+static void _expand_stack_to(address bottom) {
+  address sp;
+  size_t size;
+  volatile char *p;
+
+  // Adjust bottom to point to the largest address within the same page, it
+  // gives us a one-page buffer if alloca() allocates slightly more memory.
+  bottom = (address)align_size_down((uintptr_t)bottom, os::Bsd::page_size());
+  bottom += os::Bsd::page_size() - 1;
+
+  // sp might be slightly above current stack pointer; if that's the case, we
+  // will alloca() a little more space than necessary, which is OK. Don't use
+  // os::current_stack_pointer(), as its result can be slightly below current
+  // stack pointer, causing us to not alloca enough to reach "bottom".
+  sp = (address)&sp;
+
+  if (sp > bottom) {
+    size = sp - bottom;
+    p = (volatile char *)alloca(size);
+    assert(p != NULL && p <= (volatile char *)bottom, "alloca problem?");
+    p[0] = '\0';
+  }
+}
+
+bool os::Bsd::manually_expand_stack(JavaThread * t, address addr) {
+  assert(t!=NULL, "just checking");
+  assert(t->osthread()->expanding_stack(), "expand should be set");
+  assert(t->stack_base() != NULL, "stack_base was not initialized");
+
+  if (addr <  t->stack_base() && addr >= t->stack_yellow_zone_base()) {
+    sigset_t mask_all, old_sigset;
+    sigfillset(&mask_all);
+    pthread_sigmask(SIG_SETMASK, &mask_all, &old_sigset);
+    _expand_stack_to(addr);
+    pthread_sigmask(SIG_SETMASK, &old_sigset, NULL);
+    return true;
+  }
+  return false;
+}
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+// create new thread
+
+static address highest_vm_reserved_address();
+
+// check if it's safe to start a new thread
+static bool _thread_safety_check(Thread* thread) {
+#ifdef _ALLBSD_SOURCE
+    return true;
+#else
+  if (os::Bsd::is_BsdThreads() && !os::Bsd::is_floating_stack()) {
+    // Fixed stack BsdThreads (SuSE Bsd/x86, and some versions of Redhat)
+    //   Heap is mmap'ed at lower end of memory space. Thread stacks are
+    //   allocated (MAP_FIXED) from high address space. Every thread stack
+    //   occupies a fixed size slot (usually 2Mbytes, but user can change
+    //   it to other values if they rebuild BsdThreads).
+    //
+    // Problem with MAP_FIXED is that mmap() can still succeed even part of
+    // the memory region has already been mmap'ed. That means if we have too
+    // many threads and/or very large heap, eventually thread stack will
+    // collide with heap.
+    //
+    // Here we try to prevent heap/stack collision by comparing current
+    // stack bottom with the highest address that has been mmap'ed by JVM
+    // plus a safety margin for memory maps created by native code.
+    //
+    // This feature can be disabled by setting ThreadSafetyMargin to 0
+    //
+    if (ThreadSafetyMargin > 0) {
+      address stack_bottom = os::current_stack_base() - os::current_stack_size();
+
+      // not safe if our stack extends below the safety margin
+      return stack_bottom - ThreadSafetyMargin >= highest_vm_reserved_address();
+    } else {
+      return true;
+    }
+  } else {
+    // Floating stack BsdThreads or NPTL:
+    //   Unlike fixed stack BsdThreads, thread stacks are not MAP_FIXED. When
+    //   there's not enough space left, pthread_create() will fail. If we come
+    //   here, that means enough space has been reserved for stack.
+    return true;
+  }
+#endif
+}
+
+#ifdef __APPLE__
+// library handle for calling objc_registerThreadWithCollector()
+// without static linking to the libobjc library
+#define OBJC_LIB "/usr/lib/libobjc.dylib"
+#define OBJC_GCREGISTER "objc_registerThreadWithCollector"
+typedef void (*objc_registerThreadWithCollector_t)();
+extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction;
+objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NULL;
+#endif
+
+// Thread start routine for all newly created threads
+static void *java_start(Thread *thread) {
+  // Try to randomize the cache line index of hot stack frames.
+  // This helps when threads of the same stack traces evict each other's
+  // cache lines. The threads can be either from the same JVM instance, or
+  // from different JVM instances. The benefit is especially true for
+  // processors with hyperthreading technology.
+  static int counter = 0;
+  int pid = os::current_process_id();
+  alloca(((pid ^ counter++) & 7) * 128);
+
+  ThreadLocalStorage::set_thread(thread);
+
+  OSThread* osthread = thread->osthread();
+  Monitor* sync = osthread->startThread_lock();
+
+  // non floating stack BsdThreads needs extra check, see above
+  if (!_thread_safety_check(thread)) {
+    // notify parent thread
+    MutexLockerEx ml(sync, Mutex::_no_safepoint_check_flag);
+    osthread->set_state(ZOMBIE);
+    sync->notify_all();
+    return NULL;
+  }
+
+#ifdef _ALLBSD_SOURCE
+  // thread_id is pthread_id on BSD
+  osthread->set_thread_id(::pthread_self());
+#else
+  // thread_id is kernel thread id (similar to Solaris LWP id)
+  osthread->set_thread_id(os::Bsd::gettid());
+
+  if (UseNUMA) {
+    int lgrp_id = os::numa_get_group_id();
+    if (lgrp_id != -1) {
+      thread->set_lgrp_id(lgrp_id);
+    }
+  }
+#endif
+  // initialize signal mask for this thread
+  os::Bsd::hotspot_sigmask(thread);
+
+  // initialize floating point control register
+  os::Bsd::init_thread_fpu_state();
+
+#ifdef __APPLE__
+  // register thread with objc gc
+  if (objc_registerThreadWithCollectorFunction != NULL) {
+    objc_registerThreadWithCollectorFunction();
+  }
+#endif
+
+  // handshaking with parent thread
+  {
+    MutexLockerEx ml(sync, Mutex::_no_safepoint_check_flag);
+
+    // notify parent thread
+    osthread->set_state(INITIALIZED);
+    sync->notify_all();
+
+    // wait until os::start_thread()
+    while (osthread->get_state() == INITIALIZED) {
+      sync->wait(Mutex::_no_safepoint_check_flag);
+    }
+  }
+
+  // call one more level start routine
+  thread->run();
+
+  return 0;
+}
+
+bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) {
+  assert(thread->osthread() == NULL, "caller responsible");
+
+  // Allocate the OSThread object
+  OSThread* osthread = new OSThread(NULL, NULL);
+  if (osthread == NULL) {
+    return false;
+  }
+
+  // set the correct thread state
+  osthread->set_thread_type(thr_type);
+
+  // Initial state is ALLOCATED but not INITIALIZED
+  osthread->set_state(ALLOCATED);
+
+  thread->set_osthread(osthread);
+
+  // init thread attributes
+  pthread_attr_t attr;
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+  // stack size
+  if (os::Bsd::supports_variable_stack_size()) {
+    // calculate stack size if it's not specified by caller
+    if (stack_size == 0) {
+      stack_size = os::Bsd::default_stack_size(thr_type);
+
+      switch (thr_type) {
+      case os::java_thread:
+        // Java threads use ThreadStackSize which default value can be
+        // changed with the flag -Xss
+        assert (JavaThread::stack_size_at_create() > 0, "this should be set");
+        stack_size = JavaThread::stack_size_at_create();
+        break;
+      case os::compiler_thread:
+        if (CompilerThreadStackSize > 0) {
+          stack_size = (size_t)(CompilerThreadStackSize * K);
+          break;
+        } // else fall through:
+          // use VMThreadStackSize if CompilerThreadStackSize is not defined
+      case os::vm_thread:
+      case os::pgc_thread:
+      case os::cgc_thread:
+      case os::watcher_thread:
+        if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
+        break;
+      }
+    }
+
+    stack_size = MAX2(stack_size, os::Bsd::min_stack_allowed);
+    pthread_attr_setstacksize(&attr, stack_size);
+  } else {
+    // let pthread_create() pick the default value.
+  }
+
+#ifndef _ALLBSD_SOURCE
+  // glibc guard page
+  pthread_attr_setguardsize(&attr, os::Bsd::default_guard_size(thr_type));
+#endif
+
+  ThreadState state;
+
+  {
+
+#ifndef _ALLBSD_SOURCE
+    // Serialize thread creation if we are running with fixed stack BsdThreads
+    bool lock = os::Bsd::is_BsdThreads() && !os::Bsd::is_floating_stack();
+    if (lock) {
+      os::Bsd::createThread_lock()->lock_without_safepoint_check();
+    }
+#endif
+
+    pthread_t tid;
+    int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);
+
+    pthread_attr_destroy(&attr);
+
+    if (ret != 0) {
+      if (PrintMiscellaneous && (Verbose || WizardMode)) {
+        perror("pthread_create()");
+      }
+      // Need to clean up stuff we've allocated so far
+      thread->set_osthread(NULL);
+      delete osthread;
+#ifndef _ALLBSD_SOURCE
+      if (lock) os::Bsd::createThread_lock()->unlock();
+#endif
+      return false;
+    }
+
+    // Store pthread info into the OSThread
+    osthread->set_pthread_id(tid);
+
+    // Wait until child thread is either initialized or aborted
+    {
+      Monitor* sync_with_child = osthread->startThread_lock();
+      MutexLockerEx ml(sync_with_child, Mutex::_no_safepoint_check_flag);
+      while ((state = osthread->get_state()) == ALLOCATED) {
+        sync_with_child->wait(Mutex::_no_safepoint_check_flag);
+      }
+    }
+
+#ifndef _ALLBSD_SOURCE
+    if (lock) {
+      os::Bsd::createThread_lock()->unlock();
+    }
+#endif
+  }
+
+  // Aborted due to thread limit being reached
+  if (state == ZOMBIE) {
+      thread->set_osthread(NULL);
+      delete osthread;
+      return false;
+  }
+
+  // The thread is returned suspended (in state INITIALIZED),
+  // and is started higher up in the call chain
+  assert(state == INITIALIZED, "race condition");
+  return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// attach existing thread
+
+// bootstrap the main thread
+bool os::create_main_thread(JavaThread* thread) {
+  assert(os::Bsd::_main_thread == pthread_self(), "should be called inside main thread");
+  return create_attached_thread(thread);
+}
+
+bool os::create_attached_thread(JavaThread* thread) {
+#ifdef ASSERT
+    thread->verify_not_published();
+#endif
+
+  // Allocate the OSThread object
+  OSThread* osthread = new OSThread(NULL, NULL);
+
+  if (osthread == NULL) {
+    return false;
+  }
+
+  // Store pthread info into the OSThread
+#ifdef _ALLBSD_SOURCE
+  osthread->set_thread_id(::pthread_self());
+#else
+  osthread->set_thread_id(os::Bsd::gettid());
+#endif
+  osthread->set_pthread_id(::pthread_self());
+
+  // initialize floating point control register
+  os::Bsd::init_thread_fpu_state();
+
+  // Initial thread state is RUNNABLE
+  osthread->set_state(RUNNABLE);
+
+  thread->set_osthread(osthread);
+
+#ifndef _ALLBSD_SOURCE
+  if (UseNUMA) {
+    int lgrp_id = os::numa_get_group_id();
+    if (lgrp_id != -1) {
+      thread->set_lgrp_id(lgrp_id);
+    }
+  }
+
+  if (os::Bsd::is_initial_thread()) {
+    // If current thread is initial thread, its stack is mapped on demand,
+    // see notes about MAP_GROWSDOWN. Here we try to force kernel to map
+    // the entire stack region to avoid SEGV in stack banging.
+    // It is also useful to get around the heap-stack-gap problem on SuSE
+    // kernel (see 4821821 for details). We first expand stack to the top
+    // of yellow zone, then enable stack yellow zone (order is significant,
+    // enabling yellow zone first will crash JVM on SuSE Bsd), so there
+    // is no gap between the last two virtual memory regions.
+
+    JavaThread *jt = (JavaThread *)thread;
+    address addr = jt->stack_yellow_zone_base();
+    assert(addr != NULL, "initialization problem?");
+    assert(jt->stack_available(addr) > 0, "stack guard should not be enabled");
+
+    osthread->set_expanding_stack();
+    os::Bsd::manually_expand_stack(jt, addr);
+    osthread->clear_expanding_stack();
+  }
+#endif
+
+  // initialize signal mask for this thread
+  // and save the caller's signal mask
+  os::Bsd::hotspot_sigmask(thread);
+
+  return true;
+}
+
+void os::pd_start_thread(Thread* thread) {
+  OSThread * osthread = thread->osthread();
+  assert(osthread->get_state() != INITIALIZED, "just checking");
+  Monitor* sync_with_child = osthread->startThread_lock();
+  MutexLockerEx ml(sync_with_child, Mutex::_no_safepoint_check_flag);
+  sync_with_child->notify();
+}
+
+// Free Bsd resources related to the OSThread
+void os::free_thread(OSThread* osthread) {
+  assert(osthread != NULL, "osthread not set");
+
+  if (Thread::current()->osthread() == osthread) {
+    // Restore caller's signal mask
+    sigset_t sigmask = osthread->caller_sigmask();
+    pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
+   }
+
+  delete osthread;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// thread local storage
+
+int os::allocate_thread_local_storage() {
+  pthread_key_t key;
+  int rslt = pthread_key_create(&key, NULL);
+  assert(rslt == 0, "cannot allocate thread local storage");
+  return (int)key;
+}
+
+// Note: This is currently not used by VM, as we don't destroy TLS key
+// on VM exit.
+void os::free_thread_local_storage(int index) {
+  int rslt = pthread_key_delete((pthread_key_t)index);
+  assert(rslt == 0, "invalid index");
+}
+
+void os::thread_local_storage_at_put(int index, void* value) {
+  int rslt = pthread_setspecific((pthread_key_t)index, value);
+  assert(rslt == 0, "pthread_setspecific failed");
+}
+
+extern "C" Thread* get_thread() {
+  return ThreadLocalStorage::thread();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// initial thread
+
+#ifndef _ALLBSD_SOURCE
+// Check if current thread is the initial thread, similar to Solaris thr_main.
+bool os::Bsd::is_initial_thread(void) {
+  char dummy;
+  // If called before init complete, thread stack bottom will be null.
+  // Can be called if fatal error occurs before initialization.
+  if (initial_thread_stack_bottom() == NULL) return false;
+  assert(initial_thread_stack_bottom() != NULL &&
+         initial_thread_stack_size()   != 0,
+         "os::init did not locate initial thread's stack region");
+  if ((address)&dummy >= initial_thread_stack_bottom() &&
+      (address)&dummy < initial_thread_stack_bottom() + initial_thread_stack_size())
+       return true;
+  else return false;
+}
+
+// Find the virtual memory area that contains addr
+static bool find_vma(address addr, address* vma_low, address* vma_high) {
+  FILE *fp = fopen("/proc/self/maps", "r");
+  if (fp) {
+    address low, high;
+    while (!feof(fp)) {
+      if (fscanf(fp, "%p-%p", &low, &high) == 2) {
+        if (low <= addr && addr < high) {
+           if (vma_low)  *vma_low  = low;
+           if (vma_high) *vma_high = high;
+           fclose (fp);
+           return true;
+        }
+      }
+      for (;;) {
+        int ch = fgetc(fp);
+        if (ch == EOF || ch == (int)'\n') break;
+      }
+    }
+    fclose(fp);
+  }
+  return false;
+}
+
+// Locate initial thread stack. This special handling of initial thread stack
+// is needed because pthread_getattr_np() on most (all?) Bsd distros returns
+// bogus value for initial thread.
+void os::Bsd::capture_initial_stack(size_t max_size) {
+  // stack size is the easy part, get it from RLIMIT_STACK
+  size_t stack_size;
+  struct rlimit rlim;
+  getrlimit(RLIMIT_STACK, &rlim);
+  stack_size = rlim.rlim_cur;
+
+  // 6308388: a bug in ld.so will relocate its own .data section to the
+  //   lower end of primordial stack; reduce ulimit -s value a little bit
+  //   so we won't install guard page on ld.so's data section.
+  stack_size -= 2 * page_size();
+
+  // 4441425: avoid crash with "unlimited" stack size on SuSE 7.1 or Redhat
+  //   7.1, in both cases we will get 2G in return value.
+  // 4466587: glibc 2.2.x compiled w/o "--enable-kernel=2.4.0" (RH 7.0,
+  //   SuSE 7.2, Debian) can not handle alternate signal stack correctly
+  //   for initial thread if its stack size exceeds 6M. Cap it at 2M,
+  //   in case other parts in glibc still assumes 2M max stack size.
+  // FIXME: alt signal stack is gone, maybe we can relax this constraint?
+#ifndef IA64
+  if (stack_size > 2 * K * K) stack_size = 2 * K * K;
+#else
+  // Problem still exists RH7.2 (IA64 anyway) but 2MB is a little small
+  if (stack_size > 4 * K * K) stack_size = 4 * K * K;
+#endif
+
+  // Try to figure out where the stack base (top) is. This is harder.
+  //
+  // When an application is started, glibc saves the initial stack pointer in
+  // a global variable "__libc_stack_end", which is then used by system
+  // libraries. __libc_stack_end should be pretty close to stack top. The
+  // variable is available since the very early days. However, because it is
+  // a private interface, it could disappear in the future.
+  //
+  // Bsd kernel saves start_stack information in /proc/<pid>/stat. Similar
+  // to __libc_stack_end, it is very close to stack top, but isn't the real
+  // stack top. Note that /proc may not exist if VM is running as a chroot
+  // program, so reading /proc/<pid>/stat could fail. Also the contents of
+  // /proc/<pid>/stat could change in the future (though unlikely).
+  //
+  // We try __libc_stack_end first. If that doesn't work, look for
+  // /proc/<pid>/stat. If neither of them works, we use current stack pointer
+  // as a hint, which should work well in most cases.
+
+  uintptr_t stack_start;
+
+  // try __libc_stack_end first
+  uintptr_t *p = (uintptr_t *)dlsym(RTLD_DEFAULT, "__libc_stack_end");
+  if (p && *p) {
+    stack_start = *p;
+  } else {
+    // see if we can get the start_stack field from /proc/self/stat
+    FILE *fp;
+    int pid;
+    char state;
+    int ppid;
+    int pgrp;
+    int session;
+    int nr;
+    int tpgrp;
+    unsigned long flags;
+    unsigned long minflt;
+    unsigned long cminflt;
+    unsigned long majflt;
+    unsigned long cmajflt;
+    unsigned long utime;
+    unsigned long stime;
+    long cutime;
+    long cstime;
+    long prio;
+    long nice;
+    long junk;
+    long it_real;
+    uintptr_t start;
+    uintptr_t vsize;
+    intptr_t rss;
+    uintptr_t rsslim;
+    uintptr_t scodes;
+    uintptr_t ecode;
+    int i;
+
+    // Figure what the primordial thread stack base is. Code is inspired
+    // by email from Hans Boehm. /proc/self/stat begins with current pid,
+    // followed by command name surrounded by parentheses, state, etc.
+    char stat[2048];
+    int statlen;
+
+    fp = fopen("/proc/self/stat", "r");
+    if (fp) {
+      statlen = fread(stat, 1, 2047, fp);
+      stat[statlen] = '\0';
+      fclose(fp);
+
+      // Skip pid and the command string. Note that we could be dealing with
+      // weird command names, e.g. user could decide to rename java launcher
+      // to "java 1.4.2 :)", then the stat file would look like
+      //                1234 (java 1.4.2 :)) R ... ...
+      // We don't really need to know the command string, just find the last
+      // occurrence of ")" and then start parsing from there. See bug 4726580.
+      char * s = strrchr(stat, ')');
+
+      i = 0;
+      if (s) {
+        // Skip blank chars
+        do s++; while (isspace(*s));
+
+#define _UFM UINTX_FORMAT
+#define _DFM INTX_FORMAT
+
+        /*                                     1   1   1   1   1   1   1   1   1   1   2   2    2    2    2    2    2    2    2 */
+        /*              3  4  5  6  7  8   9   0   1   2   3   4   5   6   7   8   9   0   1    2    3    4    5    6    7    8 */
+        i = sscanf(s, "%c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld " _UFM _UFM _DFM _UFM _UFM _UFM _UFM,
+             &state,          /* 3  %c  */
+             &ppid,           /* 4  %d  */
+             &pgrp,           /* 5  %d  */
+             &session,        /* 6  %d  */
+             &nr,             /* 7  %d  */
+             &tpgrp,          /* 8  %d  */
+             &flags,          /* 9  %lu  */
+             &minflt,         /* 10 %lu  */
+             &cminflt,        /* 11 %lu  */
+             &majflt,         /* 12 %lu  */
+             &cmajflt,        /* 13 %lu  */
+             &utime,          /* 14 %lu  */
+             &stime,          /* 15 %lu  */
+             &cutime,         /* 16 %ld  */
+             &cstime,         /* 17 %ld  */
+             &prio,           /* 18 %ld  */
+             &nice,           /* 19 %ld  */
+             &junk,           /* 20 %ld  */
+             &it_real,        /* 21 %ld  */
+             &start,          /* 22 UINTX_FORMAT */
+             &vsize,          /* 23 UINTX_FORMAT */
+             &rss,            /* 24 INTX_FORMAT  */
+             &rsslim,         /* 25 UINTX_FORMAT */
+             &scodes,         /* 26 UINTX_FORMAT */
+             &ecode,          /* 27 UINTX_FORMAT */
+             &stack_start);   /* 28 UINTX_FORMAT */
+      }
+
+#undef _UFM
+#undef _DFM
+
+      if (i != 28 - 2) {
+         assert(false, "Bad conversion from /proc/self/stat");
+         // product mode - assume we are the initial thread, good luck in the
+         // embedded case.
+         warning("Can't detect initial thread stack location - bad conversion");
+         stack_start = (uintptr_t) &rlim;
+      }
+    } else {
+      // For some reason we can't open /proc/self/stat (for example, running on
+      // FreeBSD with a Bsd emulator, or inside chroot), this should work for
+      // most cases, so don't abort:
+      warning("Can't detect initial thread stack location - no /proc/self/stat");
+      stack_start = (uintptr_t) &rlim;
+    }
+  }
+
+  // Now we have a pointer (stack_start) very close to the stack top, the
+  // next thing to do is to figure out the exact location of stack top. We
+  // can find out the virtual memory area that contains stack_start by
+  // reading /proc/self/maps, it should be the last vma in /proc/self/maps,
+  // and its upper limit is the real stack top. (again, this would fail if
+  // running inside chroot, because /proc may not exist.)
+
+  uintptr_t stack_top;
+  address low, high;
+  if (find_vma((address)stack_start, &low, &high)) {
+    // success, "high" is the true stack top. (ignore "low", because initial
+    // thread stack grows on demand, its real bottom is high - RLIMIT_STACK.)
+    stack_top = (uintptr_t)high;
+  } else {
+    // failed, likely because /proc/self/maps does not exist
+    warning("Can't detect initial thread stack location - find_vma failed");
+    // best effort: stack_start is normally within a few pages below the real
+    // stack top, use it as stack top, and reduce stack size so we won't put
+    // guard page outside stack.
+    stack_top = stack_start;
+    stack_size -= 16 * page_size();
+  }
+
+  // stack_top could be partially down the page so align it
+  stack_top = align_size_up(stack_top, page_size());
+
+  if (max_size && stack_size > max_size) {
+     _initial_thread_stack_size = max_size;
+  } else {
+     _initial_thread_stack_size = stack_size;
+  }
+
+  _initial_thread_stack_size = align_size_down(_initial_thread_stack_size, page_size());
+  _initial_thread_stack_bottom = (address)stack_top - _initial_thread_stack_size;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// time support
+
+// Time since start-up in seconds to a fine granularity.
+// Used by VMSelfDestructTimer and the MemProfiler.
+double os::elapsedTime() {
+
+  return (double)(os::elapsed_counter()) * 0.000001;
+}
+
+jlong os::elapsed_counter() {
+  timeval time;
+  int status = gettimeofday(&time, NULL);
+  return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count;
+}
+
+jlong os::elapsed_frequency() {
+  return (1000 * 1000);
+}
+
+// XXX: For now, code this as if BSD does not support vtime.
+bool os::supports_vtime() { return false; }
+bool os::enable_vtime()   { return false; }
+bool os::vtime_enabled()  { return false; }
+double os::elapsedVTime() {
+  // better than nothing, but not much
+  return elapsedTime();
+}
+
+jlong os::javaTimeMillis() {
+  timeval time;
+  int status = gettimeofday(&time, NULL);
+  assert(status != -1, "bsd error");
+  return jlong(time.tv_sec) * 1000  +  jlong(time.tv_usec / 1000);
+}
+
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC (1)
+#endif
+
+#ifdef __APPLE__
+void os::Bsd::clock_init() {
+        // XXXDARWIN: Investigate replacement monotonic clock
+}
+#elif defined(_ALLBSD_SOURCE)
+void os::Bsd::clock_init() {
+  struct timespec res;
+  struct timespec tp;
+  if (::clock_getres(CLOCK_MONOTONIC, &res) == 0 &&
+      ::clock_gettime(CLOCK_MONOTONIC, &tp)  == 0) {
+    // yes, monotonic clock is supported
+    _clock_gettime = ::clock_gettime;
+  }
+}
+#else
+void os::Bsd::clock_init() {
+  // we do dlopen's in this particular order due to bug in bsd
+  // dynamical loader (see 6348968) leading to crash on exit
+  void* handle = dlopen("librt.so.1", RTLD_LAZY);
+  if (handle == NULL) {
+    handle = dlopen("librt.so", RTLD_LAZY);
+  }
+
+  if (handle) {
+    int (*clock_getres_func)(clockid_t, struct timespec*) =
+           (int(*)(clockid_t, struct timespec*))dlsym(handle, "clock_getres");
+    int (*clock_gettime_func)(clockid_t, struct timespec*) =
+           (int(*)(clockid_t, struct timespec*))dlsym(handle, "clock_gettime");
+    if (clock_getres_func && clock_gettime_func) {
+      // See if monotonic clock is supported by the kernel. Note that some
+      // early implementations simply return kernel jiffies (updated every
+      // 1/100 or 1/1000 second). It would be bad to use such a low res clock
+      // for nano time (though the monotonic property is still nice to have).
+      // It's fixed in newer kernels, however clock_getres() still returns
+      // 1/HZ. We check if clock_getres() works, but will ignore its reported
+      // resolution for now. Hopefully as people move to new kernels, this
+      // won't be a problem.
+      struct timespec res;
+      struct timespec tp;
+      if (clock_getres_func (CLOCK_MONOTONIC, &res) == 0 &&
+          clock_gettime_func(CLOCK_MONOTONIC, &tp)  == 0) {
+        // yes, monotonic clock is supported
+        _clock_gettime = clock_gettime_func;
+      } else {
+        // close librt if there is no monotonic clock
+        dlclose(handle);
+      }
+    }
+  }
+}
+#endif
+
+#ifndef _ALLBSD_SOURCE
+#ifndef SYS_clock_getres
+
+#if defined(IA32) || defined(AMD64)
+#define SYS_clock_getres IA32_ONLY(266)  AMD64_ONLY(229)
+#define sys_clock_getres(x,y)  ::syscall(SYS_clock_getres, x, y)
+#else
+#warning "SYS_clock_getres not defined for this platform, disabling fast_thread_cpu_time"
+#define sys_clock_getres(x,y)  -1
+#endif
+
+#else
+#define sys_clock_getres(x,y)  ::syscall(SYS_clock_getres, x, y)
+#endif
+
+void os::Bsd::fast_thread_clock_init() {
+  if (!UseBsdPosixThreadCPUClocks) {
+    return;
+  }
+  clockid_t clockid;
+  struct timespec tp;
+  int (*pthread_getcpuclockid_func)(pthread_t, clockid_t *) =
+      (int(*)(pthread_t, clockid_t *)) dlsym(RTLD_DEFAULT, "pthread_getcpuclockid");
+
+  // Switch to using fast clocks for thread cpu time if
+  // the sys_clock_getres() returns 0 error code.
+  // Note, that some kernels may support the current thread
+  // clock (CLOCK_THREAD_CPUTIME_ID) but not the clocks
+  // returned by the pthread_getcpuclockid().
+  // If the fast Posix clocks are supported then the sys_clock_getres()
+  // must return at least tp.tv_sec == 0 which means a resolution
+  // better than 1 sec. This is extra check for reliability.
+
+  if(pthread_getcpuclockid_func &&
+     pthread_getcpuclockid_func(_main_thread, &clockid) == 0 &&
+     sys_clock_getres(clockid, &tp) == 0 && tp.tv_sec == 0) {
+
+    _supports_fast_thread_cpu_time = true;
+    _pthread_getcpuclockid = pthread_getcpuclockid_func;
+  }
+}
+#endif
+
+jlong os::javaTimeNanos() {
+  if (Bsd::supports_monotonic_clock()) {
+    struct timespec tp;
+    int status = Bsd::clock_gettime(CLOCK_MONOTONIC, &tp);
+    assert(status == 0, "gettime error");
+    jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) + jlong(tp.tv_nsec);
+    return result;
+  } else {
+    timeval time;
+    int status = gettimeofday(&time, NULL);
+    assert(status != -1, "bsd error");
+    jlong usecs = jlong(time.tv_sec) * (1000 * 1000) + jlong(time.tv_usec);
+    return 1000 * usecs;
+  }
+}
+
+void os::javaTimeNanos_info(jvmtiTimerInfo *info_ptr) {
+  if (Bsd::supports_monotonic_clock()) {
+    info_ptr->max_value = ALL_64_BITS;
+
+    // CLOCK_MONOTONIC - amount of time since some arbitrary point in the past
+    info_ptr->may_skip_backward = false;      // not subject to resetting or drifting
+    info_ptr->may_skip_forward = false;       // not subject to resetting or drifting
+  } else {
+    // gettimeofday - based on time in seconds since the Epoch thus does not wrap
+    info_ptr->max_value = ALL_64_BITS;
+
+    // gettimeofday is a real time clock so it skips
+    info_ptr->may_skip_backward = true;
+    info_ptr->may_skip_forward = true;
+  }
+
+  info_ptr->kind = JVMTI_TIMER_ELAPSED;                // elapsed not CPU time
+}
+
+// Return the real, user, and system times in seconds from an
+// arbitrary fixed point in the past.
+bool os::getTimesSecs(double* process_real_time,
+                      double* process_user_time,
+                      double* process_system_time) {
+  struct tms ticks;
+  clock_t real_ticks = times(&ticks);
+
+  if (real_ticks == (clock_t) (-1)) {
+    return false;
+  } else {
+    double ticks_per_second = (double) clock_tics_per_sec;
+    *process_user_time = ((double) ticks.tms_utime) / ticks_per_second;
+    *process_system_time = ((double) ticks.tms_stime) / ticks_per_second;
+    *process_real_time = ((double) real_ticks) / ticks_per_second;
+
+    return true;
+  }
+}
+
+
+char * os::local_time_string(char *buf, size_t buflen) {
+  struct tm t;
+  time_t long_time;
+  time(&long_time);
+  localtime_r(&long_time, &t);
+  jio_snprintf(buf, buflen, "%d-%02d-%02d %02d:%02d:%02d",
+               t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
+               t.tm_hour, t.tm_min, t.tm_sec);
+  return buf;
+}
+
+struct tm* os::localtime_pd(const time_t* clock, struct tm*  res) {
+  return localtime_r(clock, res);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// runtime exit support
+
+// Note: os::shutdown() might be called very early during initialization, or
+// called from signal handler. Before adding something to os::shutdown(), make
+// sure it is async-safe and can handle partially initialized VM.
+void os::shutdown() {
+
+  // allow PerfMemory to attempt cleanup of any persistent resources
+  perfMemory_exit();
+
+  // needs to remove object in file system
+  AttachListener::abort();
+
+  // flush buffered output, finish log files
+  ostream_abort();
+
+  // Check for abort hook
+  abort_hook_t abort_hook = Arguments::abort_hook();
+  if (abort_hook != NULL) {
+    abort_hook();
+  }
+
+}
+
+// Note: os::abort() might be called very early during initialization, or
+// called from signal handler. Before adding something to os::abort(), make
+// sure it is async-safe and can handle partially initialized VM.
+void os::abort(bool dump_core) {
+  os::shutdown();
+  if (dump_core) {
+#ifndef PRODUCT
+    fdStream out(defaultStream::output_fd());
+    out.print_raw("Current thread is ");
+    char buf[16];
+    jio_snprintf(buf, sizeof(buf), UINTX_FORMAT, os::current_thread_id());
+    out.print_raw_cr(buf);
+    out.print_raw_cr("Dumping core ...");
+#endif
+    ::abort(); // dump core
+  }
+
+  ::exit(1);
+}
+
+// Die immediately, no exit hook, no abort hook, no cleanup.
+void os::die() {
+  // _exit() on BsdThreads only kills current thread
+  ::abort();
+}
+
+// unused on bsd for now.
+void os::set_error_file(const char *logfile) {}
+
+
+// This method is a copy of JDK's sysGetLastErrorString
+// from src/solaris/hpi/src/system_md.c
+
+size_t os::lasterror(char *buf, size_t len) {
+
+  if (errno == 0)  return 0;
+
+  const char *s = ::strerror(errno);
+  size_t n = ::strlen(s);
+  if (n >= len) {
+    n = len - 1;
+  }
+  ::strncpy(buf, s, n);
+  buf[n] = '\0';
+  return n;
+}
+
+intx os::current_thread_id() { return (intx)pthread_self(); }
+int os::current_process_id() {
+
+  // Under the old bsd thread library, bsd gives each thread
+  // its own process id. Because of this each thread will return
+  // a different pid if this method were to return the result
+  // of getpid(2). Bsd provides no api that returns the pid
+  // of the launcher thread for the vm. This implementation
+  // returns a unique pid, the pid of the launcher thread
+  // that starts the vm 'process'.
+
+  // Under the NPTL, getpid() returns the same pid as the
+  // launcher thread rather than a unique pid per thread.
+  // Use gettid() if you want the old pre NPTL behaviour.
+
+  // if you are looking for the result of a call to getpid() that
+  // returns a unique pid for the calling thread, then look at the
+  // OSThread::thread_id() method in osThread_bsd.hpp file
+
+  return (int)(_initial_pid ? _initial_pid : getpid());
+}
+
+// DLL functions
+
+#define JNI_LIB_PREFIX "lib"
+#ifdef __APPLE__
+#define JNI_LIB_SUFFIX ".dylib"
+#else
+#define JNI_LIB_SUFFIX ".so"
+#endif
+
+const char* os::dll_file_extension() { return JNI_LIB_SUFFIX; }
+
+// This must be hard coded because it's the system's temporary
+// directory not the java application's temp directory, ala java.io.tmpdir.
+#ifdef __APPLE__
+// macosx has a secure per-user temporary directory
+char temp_path_storage[PATH_MAX];
+const char* os::get_temp_directory() {
+  static char *temp_path = NULL;
+  if (temp_path == NULL) {
+    int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX);
+    if (pathSize == 0 || pathSize > PATH_MAX) {
+      strlcpy(temp_path_storage, "/tmp/", sizeof(temp_path_storage));
+    }
+    temp_path = temp_path_storage;
+  }
+  return temp_path;
+}
+#else /* __APPLE__ */
+const char* os::get_temp_directory() { return "/tmp"; }
+#endif /* __APPLE__ */
+
+static bool file_exists(const char* filename) {
+  struct stat statbuf;
+  if (filename == NULL || strlen(filename) == 0) {
+    return false;
+  }
+  return os::stat(filename, &statbuf) == 0;
+}
+
+void os::dll_build_name(char* buffer, size_t buflen,
+                        const char* pname, const char* fname) {
+  // Copied from libhpi
+  const size_t pnamelen = pname ? strlen(pname) : 0;
+
+  // Quietly truncate on buffer overflow.  Should be an error.
+  if (pnamelen + strlen(fname) + strlen(JNI_LIB_PREFIX) + strlen(JNI_LIB_SUFFIX) + 2 > buflen) {
+      *buffer = '\0';
+      return;
+  }
+
+  if (pnamelen == 0) {
+    snprintf(buffer, buflen, JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, fname);
+  } else if (strchr(pname, *os::path_separator()) != NULL) {
+    int n;
+    char** pelements = split_path(pname, &n);
+    for (int i = 0 ; i < n ; i++) {
+      // Really shouldn't be NULL, but check can't hurt
+      if (pelements[i] == NULL || strlen(pelements[i]) == 0) {
+        continue; // skip the empty path values
+      }
+      snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX,
+          pelements[i], fname);
+      if (file_exists(buffer)) {
+        break;
+      }
+    }
+    // release the storage
+    for (int i = 0 ; i < n ; i++) {
+      if (pelements[i] != NULL) {
+        FREE_C_HEAP_ARRAY(char, pelements[i]);
+      }
+    }
+    if (pelements != NULL) {
+      FREE_C_HEAP_ARRAY(char*, pelements);
+    }
+  } else {
+    snprintf(buffer, buflen, "%s/" JNI_LIB_PREFIX "%s" JNI_LIB_SUFFIX, pname, fname);
+  }
+}
+
+const char* os::get_current_directory(char *buf, int buflen) {
+  return getcwd(buf, buflen);
+}
+
+// check if addr is inside libjvm[_g].so
+bool os::address_is_in_vm(address addr) {
+  static address libjvm_base_addr;
+  Dl_info dlinfo;
+
+  if (libjvm_base_addr == NULL) {
+    dladdr(CAST_FROM_FN_PTR(void *, os::address_is_in_vm), &dlinfo);
+    libjvm_base_addr = (address)dlinfo.dli_fbase;
+    assert(libjvm_base_addr !=NULL, "Cannot obtain base address for libjvm");
+  }
+
+  if (dladdr((void *)addr, &dlinfo)) {
+    if (libjvm_base_addr == (address)dlinfo.dli_fbase) return true;
+  }
+
+  return false;
+}
+
+bool os::dll_address_to_function_name(address addr, char *buf,
+                                      int buflen, int *offset) {
+  Dl_info dlinfo;
+
+  if (dladdr((void*)addr, &dlinfo) && dlinfo.dli_sname != NULL) {
+    if (buf != NULL) {
+      if(!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) {
+        jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
+      }
+    }
+    if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr;
+    return true;
+  } else if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) {
+    if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
+       dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) {
+       return true;
+    }
+  }
+
+  if (buf != NULL) buf[0] = '\0';
+  if (offset != NULL) *offset = -1;
+  return false;
+}
+
+#ifdef _ALLBSD_SOURCE
+// ported from solaris version
+bool os::dll_address_to_library_name(address addr, char* buf,
+                                     int buflen, int* offset) {
+  Dl_info dlinfo;
+
+  if (dladdr((void*)addr, &dlinfo)){
+     if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname);
+     if (offset) *offset = addr - (address)dlinfo.dli_fbase;
+     return true;
+  } else {
+     if (buf) buf[0] = '\0';
+     if (offset) *offset = -1;
+     return false;
+  }
+}
+#else
+struct _address_to_library_name {
+  address addr;          // input : memory address
+  size_t  buflen;        //         size of fname
+  char*   fname;         // output: library name
+  address base;          //         library base addr
+};
+
+static int address_to_library_name_callback(struct dl_phdr_info *info,
+                                            size_t size, void *data) {
+  int i;
+  bool found = false;
+  address libbase = NULL;
+  struct _address_to_library_name * d = (struct _address_to_library_name *)data;
+
+  // iterate through all loadable segments
+  for (i = 0; i < info->dlpi_phnum; i++) {
+    address segbase = (address)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
+    if (info->dlpi_phdr[i].p_type == PT_LOAD) {
+      // base address of a library is the lowest address of its loaded
+      // segments.
+      if (libbase == NULL || libbase > segbase) {
+        libbase = segbase;
+      }
+      // see if 'addr' is within current segment
+      if (segbase <= d->addr &&
+          d->addr < segbase + info->dlpi_phdr[i].p_memsz) {
+        found = true;
+      }
+    }
+  }
+
+  // dlpi_name is NULL or empty if the ELF file is executable, return 0
+  // so dll_address_to_library_name() can fall through to use dladdr() which
+  // can figure out executable name from argv[0].
+  if (found && info->dlpi_name && info->dlpi_name[0]) {
+    d->base = libbase;
+    if (d->fname) {
+      jio_snprintf(d->fname, d->buflen, "%s", info->dlpi_name);
+    }
+    return 1;
+  }
+  return 0;
+}
+
+bool os::dll_address_to_library_name(address addr, char* buf,
+                                     int buflen, int* offset) {
+  Dl_info dlinfo;
+  struct _address_to_library_name data;
+
+  // There is a bug in old glibc dladdr() implementation that it could resolve
+  // to wrong library name if the .so file has a base address != NULL. Here
+  // we iterate through the program headers of all loaded libraries to find
+  // out which library 'addr' really belongs to. This workaround can be
+  // removed once the minimum requirement for glibc is moved to 2.3.x.
+  data.addr = addr;
+  data.fname = buf;
+  data.buflen = buflen;
+  data.base = NULL;
+  int rslt = dl_iterate_phdr(address_to_library_name_callback, (void *)&data);
+
+  if (rslt) {
+     // buf already contains library name
+     if (offset) *offset = addr - data.base;
+     return true;
+  } else if (dladdr((void*)addr, &dlinfo)){
+     if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname);
+     if (offset) *offset = addr - (address)dlinfo.dli_fbase;
+     return true;
+  } else {
+     if (buf) buf[0] = '\0';
+     if (offset) *offset = -1;
+     return false;
+  }
+}
+#endif
+
+  // Loads .dll/.so and
+  // in case of error it checks if .dll/.so was built for the
+  // same architecture as Hotspot is running on
+
+#ifdef __APPLE__
+void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
+  void * result= ::dlopen(filename, RTLD_LAZY);
+  if (result != NULL) {
+    // Successful loading
+    return result;
+  }
+
+  // Read system error message into ebuf
+  ::strncpy(ebuf, ::dlerror(), ebuflen-1);
+  ebuf[ebuflen-1]='\0';
+
+  return NULL;
+}
+#else
+void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
+{
+  void * result= ::dlopen(filename, RTLD_LAZY);
+  if (result != NULL) {
+    // Successful loading
+    return result;
+  }
+
+  Elf32_Ehdr elf_head;
+
+  // Read system error message into ebuf
+  // It may or may not be overwritten below
+  ::strncpy(ebuf, ::dlerror(), ebuflen-1);
+  ebuf[ebuflen-1]='\0';
+  int diag_msg_max_length=ebuflen-strlen(ebuf);
+  char* diag_msg_buf=ebuf+strlen(ebuf);
+
+  if (diag_msg_max_length==0) {
+    // No more space in ebuf for additional diagnostics message
+    return NULL;
+  }
+
+
+  int file_descriptor= ::open(filename, O_RDONLY | O_NONBLOCK);
+
+  if (file_descriptor < 0) {
+    // Can't open library, report dlerror() message
+    return NULL;
+  }
+
+  bool failed_to_read_elf_head=
+    (sizeof(elf_head)!=
+        (::read(file_descriptor, &elf_head,sizeof(elf_head)))) ;
+
+  ::close(file_descriptor);
+  if (failed_to_read_elf_head) {
+    // file i/o error - report dlerror() msg
+    return NULL;
+  }
+
+  typedef struct {
+    Elf32_Half  code;         // Actual value as defined in elf.h
+    Elf32_Half  compat_class; // Compatibility of archs at VM's sense
+    char        elf_class;    // 32 or 64 bit
+    char        endianess;    // MSB or LSB
+    char*       name;         // String representation
+  } arch_t;
+
+  #ifndef EM_486
+  #define EM_486          6               /* Intel 80486 */
+  #endif
+
+  #ifndef EM_MIPS_RS3_LE
+  #define EM_MIPS_RS3_LE  10              /* MIPS */
+  #endif
+
+  #ifndef EM_PPC64
+  #define EM_PPC64        21              /* PowerPC64 */
+  #endif
+
+  #ifndef EM_S390
+  #define EM_S390         22              /* IBM System/390 */
+  #endif
+
+  #ifndef EM_IA_64
+  #define EM_IA_64        50              /* HP/Intel IA-64 */
+  #endif
+
+  #ifndef EM_X86_64
+  #define EM_X86_64       62              /* AMD x86-64 */
+  #endif
+
+  static const arch_t arch_array[]={
+    {EM_386,         EM_386,     ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
+    {EM_486,         EM_386,     ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
+    {EM_IA_64,       EM_IA_64,   ELFCLASS64, ELFDATA2LSB, (char*)"IA 64"},
+    {EM_X86_64,      EM_X86_64,  ELFCLASS64, ELFDATA2LSB, (char*)"AMD 64"},
+    {EM_SPARC,       EM_SPARC,   ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"},
+    {EM_SPARC32PLUS, EM_SPARC,   ELFCLASS32, ELFDATA2MSB, (char*)"Sparc 32"},
+    {EM_SPARCV9,     EM_SPARCV9, ELFCLASS64, ELFDATA2MSB, (char*)"Sparc v9 64"},
+    {EM_PPC,         EM_PPC,     ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"},
+    {EM_PPC64,       EM_PPC64,   ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"},
+    {EM_ARM,         EM_ARM,     ELFCLASS32,   ELFDATA2LSB, (char*)"ARM"},
+    {EM_S390,        EM_S390,    ELFCLASSNONE, ELFDATA2MSB, (char*)"IBM System/390"},
+    {EM_ALPHA,       EM_ALPHA,   ELFCLASS64, ELFDATA2LSB, (char*)"Alpha"},
+    {EM_MIPS_RS3_LE, EM_MIPS_RS3_LE, ELFCLASS32, ELFDATA2LSB, (char*)"MIPSel"},
+    {EM_MIPS,        EM_MIPS,    ELFCLASS32, ELFDATA2MSB, (char*)"MIPS"},
+    {EM_PARISC,      EM_PARISC,  ELFCLASS32, ELFDATA2MSB, (char*)"PARISC"},
+    {EM_68K,         EM_68K,     ELFCLASS32, ELFDATA2MSB, (char*)"M68k"}
+  };
+
+  #if  (defined IA32)
+    static  Elf32_Half running_arch_code=EM_386;
+  #elif   (defined AMD64)
+    static  Elf32_Half running_arch_code=EM_X86_64;
+  #elif  (defined IA64)
+    static  Elf32_Half running_arch_code=EM_IA_64;
+  #elif  (defined __sparc) && (defined _LP64)
+    static  Elf32_Half running_arch_code=EM_SPARCV9;
+  #elif  (defined __sparc) && (!defined _LP64)
+    static  Elf32_Half running_arch_code=EM_SPARC;
+  #elif  (defined __powerpc64__)
+    static  Elf32_Half running_arch_code=EM_PPC64;
+  #elif  (defined __powerpc__)
+    static  Elf32_Half running_arch_code=EM_PPC;
+  #elif  (defined ARM)
+    static  Elf32_Half running_arch_code=EM_ARM;
+  #elif  (defined S390)
+    static  Elf32_Half running_arch_code=EM_S390;
+  #elif  (defined ALPHA)
+    static  Elf32_Half running_arch_code=EM_ALPHA;
+  #elif  (defined MIPSEL)
+    static  Elf32_Half running_arch_code=EM_MIPS_RS3_LE;
+  #elif  (defined PARISC)
+    static  Elf32_Half running_arch_code=EM_PARISC;
+  #elif  (defined MIPS)
+    static  Elf32_Half running_arch_code=EM_MIPS;
+  #elif  (defined M68K)
+    static  Elf32_Half running_arch_code=EM_68K;
+  #else
+    #error Method os::dll_load requires that one of following is defined:\
+         IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K
+  #endif
+
+  // Identify compatability class for VM's architecture and library's architecture
+  // Obtain string descriptions for architectures
+
+  arch_t lib_arch={elf_head.e_machine,0,elf_head.e_ident[EI_CLASS], elf_head.e_ident[EI_DATA], NULL};
+  int running_arch_index=-1;
+
+  for (unsigned int i=0 ; i < ARRAY_SIZE(arch_array) ; i++ ) {
+    if (running_arch_code == arch_array[i].code) {
+      running_arch_index    = i;
+    }
+    if (lib_arch.code == arch_array[i].code) {
+      lib_arch.compat_class = arch_array[i].compat_class;
+      lib_arch.name         = arch_array[i].name;
+    }
+  }
+
+  assert(running_arch_index != -1,
+    "Didn't find running architecture code (running_arch_code) in arch_array");
+  if (running_arch_index == -1) {
+    // Even though running architecture detection failed
+    // we may still continue with reporting dlerror() message
+    return NULL;
+  }
+
+  if (lib_arch.endianess != arch_array[running_arch_index].endianess) {
+    ::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: endianness mismatch)");
+    return NULL;
+  }
+
+#ifndef S390
+  if (lib_arch.elf_class != arch_array[running_arch_index].elf_class) {
+    ::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: architecture word width mismatch)");
+    return NULL;
+  }
+#endif // !S390
+
+  if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) {
+    if ( lib_arch.name!=NULL ) {
+      ::snprintf(diag_msg_buf, diag_msg_max_length-1,
+        " (Possible cause: can't load %s-bit .so on a %s-bit platform)",
+        lib_arch.name, arch_array[running_arch_index].name);
+    } else {
+      ::snprintf(diag_msg_buf, diag_msg_max_length-1,
+      " (Possible cause: can't load this .so (machine code=0x%x) on a %s-bit platform)",
+        lib_arch.code,
+        arch_array[running_arch_index].name);
+    }
+  }
+
+  return NULL;
+}
+#endif /* !__APPLE__ */
+
+// XXX: Do we need a lock around this as per Linux?
+void* os::dll_lookup(void* handle, const char* name) {
+  return dlsym(handle, name);
+}
+
+
+static bool _print_ascii_file(const char* filename, outputStream* st) {
+  int fd = ::open(filename, O_RDONLY);
+  if (fd == -1) {
+     return false;
+  }
+
+  char buf[32];
+  int bytes;
+  while ((bytes = ::read(fd, buf, sizeof(buf))) > 0) {
+    st->print_raw(buf, bytes);
+  }
+
+  ::close(fd);
+
+  return true;
+}
+
+void os::print_dll_info(outputStream *st) {
+   st->print_cr("Dynamic libraries:");
+#ifdef _ALLBSD_SOURCE
+#ifdef RTLD_DI_LINKMAP
+    Dl_info dli;
+    void *handle;
+    Link_map *map;
+    Link_map *p;
+
+    if (!dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli)) {
+        st->print_cr("Error: Cannot print dynamic libraries.");
+        return;
+    }
+    handle = dlopen(dli.dli_fname, RTLD_LAZY);
+    if (handle == NULL) {
+        st->print_cr("Error: Cannot print dynamic libraries.");
+        return;
+    }
+    dlinfo(handle, RTLD_DI_LINKMAP, &map);
+    if (map == NULL) {
+        st->print_cr("Error: Cannot print dynamic libraries.");
+        return;
+    }
+
+    while (map->l_prev != NULL)
+        map = map->l_prev;
+
+    while (map != NULL) {
+        st->print_cr(PTR_FORMAT " \t%s", map->l_addr, map->l_name);
+        map = map->l_next;
+    }
+
+    dlclose(handle);
+#elif defined(__APPLE__)
+    uint32_t count;
+    uint32_t i;
+
+    count = _dyld_image_count();
+    for (i = 1; i < count; i++) {
+        const char *name = _dyld_get_image_name(i);
+        intptr_t slide = _dyld_get_image_vmaddr_slide(i);
+        st->print_cr(PTR_FORMAT " \t%s", slide, name);
+    }
+#else
+   st->print_cr("Error: Cannot print dynamic libraries.");
+#endif
+#else
+   char fname[32];
+   pid_t pid = os::Bsd::gettid();
+
+   jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
+
+   if (!_print_ascii_file(fname, st)) {
+     st->print("Can not get library information for pid = %d\n", pid);
+   }
+#endif
+}
+
+
+void os::print_os_info(outputStream* st) {
+  st->print("OS:");
+
+  // Try to identify popular distros.
+  // Most Bsd distributions have /etc/XXX-release file, which contains
+  // the OS version string. Some have more than one /etc/XXX-release file
+  // (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.),
+  // so the order is important.
+  if (!_print_ascii_file("/etc/mandrake-release", st) &&
+      !_print_ascii_file("/etc/sun-release", st) &&
+      !_print_ascii_file("/etc/redhat-release", st) &&
+      !_print_ascii_file("/etc/SuSE-release", st) &&
+      !_print_ascii_file("/etc/turbobsd-release", st) &&
+      !_print_ascii_file("/etc/gentoo-release", st) &&
+      !_print_ascii_file("/etc/debian_version", st) &&
+      !_print_ascii_file("/etc/ltib-release", st) &&
+      !_print_ascii_file("/etc/angstrom-version", st)) {
+      st->print("Bsd");
+  }
+  st->cr();
+
+  // kernel
+  st->print("uname:");
+  struct utsname name;
+  uname(&name);
+  st->print(name.sysname); st->print(" ");
+  st->print(name.release); st->print(" ");
+  st->print(name.version); st->print(" ");
+  st->print(name.machine);
+  st->cr();
+
+#ifndef _ALLBSD_SOURCE
+  // Print warning if unsafe chroot environment detected
+  if (unsafe_chroot_detected) {
+    st->print("WARNING!! ");
+    st->print_cr(unstable_chroot_error);
+  }
+
+  // libc, pthread
+  st->print("libc:");
+  st->print(os::Bsd::glibc_version()); st->print(" ");
+  st->print(os::Bsd::libpthread_version()); st->print(" ");
+  if (os::Bsd::is_BsdThreads()) {
+     st->print("(%s stack)", os::Bsd::is_floating_stack() ? "floating" : "fixed");
+  }
+  st->cr();
+#endif
+
+  // rlimit
+  st->print("rlimit:");
+  struct rlimit rlim;
+
+  st->print(" STACK ");
+  getrlimit(RLIMIT_STACK, &rlim);
+  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
+  else st->print("%uk", rlim.rlim_cur >> 10);
+
+  st->print(", CORE ");
+  getrlimit(RLIMIT_CORE, &rlim);
+  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
+  else st->print("%uk", rlim.rlim_cur >> 10);
+
+  st->print(", NPROC ");
+  getrlimit(RLIMIT_NPROC, &rlim);
+  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
+  else st->print("%d", rlim.rlim_cur);
+
+  st->print(", NOFILE ");
+  getrlimit(RLIMIT_NOFILE, &rlim);
+  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
+  else st->print("%d", rlim.rlim_cur);
+
+#ifndef _ALLBSD_SOURCE
+  st->print(", AS ");
+  getrlimit(RLIMIT_AS, &rlim);
+  if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
+  else st->print("%uk", rlim.rlim_cur >> 10);
+  st->cr();
+
+  // load average
+  st->print("load average:");
+  double loadavg[3];
+  os::loadavg(loadavg, 3);
+  st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
+  st->cr();
+#endif
+}
+
+void os::pd_print_cpu_info(outputStream* st) {
+  // Nothing to do for now.
+}
+
+void os::print_memory_info(outputStream* st) {
+
+  st->print("Memory:");
+  st->print(" %dk page", os::vm_page_size()>>10);
+
+#ifndef _ALLBSD_SOURCE
+  // values in struct sysinfo are "unsigned long"
+  struct sysinfo si;
+  sysinfo(&si);
+#endif
+
+  st->print(", physical " UINT64_FORMAT "k",
+            os::physical_memory() >> 10);
+  st->print("(" UINT64_FORMAT "k free)",
+            os::available_memory() >> 10);
+#ifndef _ALLBSD_SOURCE
+  st->print(", swap " UINT64_FORMAT "k",
+            ((jlong)si.totalswap * si.mem_unit) >> 10);
+  st->print("(" UINT64_FORMAT "k free)",
+            ((jlong)si.freeswap * si.mem_unit) >> 10);
+#endif
+  st->cr();
+
+  // meminfo
+  st->print("\n/proc/meminfo:\n");
+  _print_ascii_file("/proc/meminfo", st);
+  st->cr();
+}
+
+// Taken from /usr/include/bits/siginfo.h  Supposed to be architecture specific
+// but they're the same for all the bsd arch that we support
+// and they're the same for solaris but there's no common place to put this.
+const char *ill_names[] = { "ILL0", "ILL_ILLOPC", "ILL_ILLOPN", "ILL_ILLADR",
+                          "ILL_ILLTRP", "ILL_PRVOPC", "ILL_PRVREG",
+                          "ILL_COPROC", "ILL_BADSTK" };
+
+const char *fpe_names[] = { "FPE0", "FPE_INTDIV", "FPE_INTOVF", "FPE_FLTDIV",
+                          "FPE_FLTOVF", "FPE_FLTUND", "FPE_FLTRES",
+                          "FPE_FLTINV", "FPE_FLTSUB", "FPE_FLTDEN" };
+
+const char *segv_names[] = { "SEGV0", "SEGV_MAPERR", "SEGV_ACCERR" };
+
+const char *bus_names[] = { "BUS0", "BUS_ADRALN", "BUS_ADRERR", "BUS_OBJERR" };
+
+void os::print_siginfo(outputStream* st, void* siginfo) {
+  st->print("siginfo:");
+
+  const int buflen = 100;
+  char buf[buflen];
+  siginfo_t *si = (siginfo_t*)siginfo;
+  st->print("si_signo=%s: ", os::exception_name(si->si_signo, buf, buflen));
+  if (si->si_errno != 0 && strerror_r(si->si_errno, buf, buflen) == 0) {
+    st->print("si_errno=%s", buf);
+  } else {
+    st->print("si_errno=%d", si->si_errno);
+  }
+  const int c = si->si_code;
+  assert(c > 0, "unexpected si_code");
+  switch (si->si_signo) {
+  case SIGILL:
+    st->print(", si_code=%d (%s)", c, c > 8 ? "" : ill_names[c]);
+    st->print(", si_addr=" PTR_FORMAT, si->si_addr);
+    break;
+  case SIGFPE:
+    st->print(", si_code=%d (%s)", c, c > 9 ? "" : fpe_names[c]);
+    st->print(", si_addr=" PTR_FORMAT, si->si_addr);
+    break;
+  case SIGSEGV:
+    st->print(", si_code=%d (%s)", c, c > 2 ? "" : segv_names[c]);
+    st->print(", si_addr=" PTR_FORMAT, si->si_addr);
+    break;
+  case SIGBUS:
+    st->print(", si_code=%d (%s)", c, c > 3 ? "" : bus_names[c]);
+    st->print(", si_addr=" PTR_FORMAT, si->si_addr);
+    break;
+  default:
+    st->print(", si_code=%d", si->si_code);
+    // no si_addr
+  }
+
+  if ((si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
+      UseSharedSpaces) {
+    FileMapInfo* mapinfo = FileMapInfo::current_info();
+    if (mapinfo->is_in_shared_space(si->si_addr)) {
+      st->print("\n\nError accessing class data sharing archive."   \
+                " Mapped file inaccessible during execution, "      \
+                " possible disk/network problem.");
+    }
+  }
+  st->cr();
+}
+
+
+static void print_signal_handler(outputStream* st, int sig,
+                                 char* buf, size_t buflen);
+
+void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
+  st->print_cr("Signal Handlers:");
+  print_signal_handler(st, SIGSEGV, buf, buflen);
+  print_signal_handler(st, SIGBUS , buf, buflen);
+  print_signal_handler(st, SIGFPE , buf, buflen);
+  print_signal_handler(st, SIGPIPE, buf, buflen);
+  print_signal_handler(st, SIGXFSZ, buf, buflen);
+  print_signal_handler(st, SIGILL , buf, buflen);
+  print_signal_handler(st, INTERRUPT_SIGNAL, buf, buflen);
+  print_signal_handler(st, SR_signum, buf, buflen);
+  print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
+  print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
+  print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
+  print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
+}
+
+static char saved_jvm_path[MAXPATHLEN] = {0};
+
+// Find the full path to the current module, libjvm.so or libjvm_g.so
+void os::jvm_path(char *buf, jint buflen) {
+  // Error checking.
+  if (buflen < MAXPATHLEN) {
+    assert(false, "must use a large-enough buffer");
+    buf[0] = '\0';
+    return;
+  }
+  // Lazy resolve the path to current module.
+  if (saved_jvm_path[0] != 0) {
+    strcpy(buf, saved_jvm_path);
+    return;
+  }
+
+  char dli_fname[MAXPATHLEN];
+  bool ret = dll_address_to_library_name(
+                CAST_FROM_FN_PTR(address, os::jvm_path),
+                dli_fname, sizeof(dli_fname), NULL);
+  assert(ret != 0, "cannot locate libjvm");
+  char *rp = realpath(dli_fname, buf);
+  if (rp == NULL)
+    return;
+
+  if (Arguments::created_by_gamma_launcher()) {
+    // Support for the gamma launcher.  Typical value for buf is
+    // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".  If "/jre/lib/" appears at
+    // the right place in the string, then assume we are installed in a JDK and
+    // we're done.  Otherwise, check for a JAVA_HOME environment variable and fix
+    // up the path so it looks like libjvm.so is installed there (append a
+    // fake suffix hotspot/libjvm.so).
+    const char *p = buf + strlen(buf) - 1;
+    for (int count = 0; p > buf && count < 5; ++count) {
+      for (--p; p > buf && *p != '/'; --p)
+        /* empty */ ;
+    }
+
+    if (strncmp(p, "/jre/lib/", 9) != 0) {
+      // Look for JAVA_HOME in the environment.
+      char* java_home_var = ::getenv("JAVA_HOME");
+      if (java_home_var != NULL && java_home_var[0] != 0) {
+        char* jrelib_p;
+        int len;
+
+        // Check the current module name "libjvm.so" or "libjvm_g.so".
+        p = strrchr(buf, '/');
+        assert(strstr(p, "/libjvm") == p, "invalid library name");
+        p = strstr(p, "_g") ? "_g" : "";
+
+        rp = realpath(java_home_var, buf);
+        if (rp == NULL)
+          return;
+
+        // determine if this is a legacy image or modules image
+        // modules image doesn't have "jre" subdirectory
+        len = strlen(buf);
+        jrelib_p = buf + len;
+        snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch);
+        if (0 != access(buf, F_OK)) {
+          snprintf(jrelib_p, buflen-len, "/lib/%s", cpu_arch);
+        }
+
+        if (0 == access(buf, F_OK)) {
+          // Use current module name "libjvm[_g].so" instead of
+          // "libjvm"debug_only("_g")".so" since for fastdebug version
+          // we should have "libjvm.so" but debug_only("_g") adds "_g"!
+          len = strlen(buf);
+          snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p);
+        } else {
+          // Go back to path of .so
+          rp = realpath(dli_fname, buf);
+          if (rp == NULL)
+            return;
+        }
+      }
+    }
+  }
+
+  strcpy(saved_jvm_path, buf);
+}
+
+void os::print_jni_name_prefix_on(outputStream* st, int args_size) {
+  // no prefix required, not even "_"
+}
+
+void os::print_jni_name_suffix_on(outputStream* st, int args_size) {
+  // no suffix required
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// sun.misc.Signal support
+
+static volatile jint sigint_count = 0;
+
+static void
+UserHandler(int sig, void *siginfo, void *context) {
+  // 4511530 - sem_post is serialized and handled by the manager thread. When
+  // the program is interrupted by Ctrl-C, SIGINT is sent to every thread. We
+  // don't want to flood the manager thread with sem_post requests.
+  if (sig == SIGINT && Atomic::add(1, &sigint_count) > 1)
+      return;
+
+  // Ctrl-C is pressed during error reporting, likely because the error
+  // handler fails to abort. Let VM die immediately.
+  if (sig == SIGINT && is_error_reported()) {
+     os::die();
+  }
+
+  os::signal_notify(sig);
+}
+
+void* os::user_handler() {
+  return CAST_FROM_FN_PTR(void*, UserHandler);
+}
+
+extern "C" {
+  typedef void (*sa_handler_t)(int);
+  typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
+}
+
+void* os::signal(int signal_number, void* handler) {
+  struct sigaction sigAct, oldSigAct;
+
+  sigfillset(&(sigAct.sa_mask));
+  sigAct.sa_flags   = SA_RESTART|SA_SIGINFO;
+  sigAct.sa_handler = CAST_TO_FN_PTR(sa_handler_t, handler);
+
+  if (sigaction(signal_number, &sigAct, &oldSigAct)) {
+    // -1 means registration failed
+    return (void *)-1;
+  }
+
+  return CAST_FROM_FN_PTR(void*, oldSigAct.sa_handler);
+}
+
+void os::signal_raise(int signal_number) {
+  ::raise(signal_number);
+}
+
+/*
+ * The following code is moved from os.cpp for making this
+ * code platform specific, which it is by its very nature.
+ */
+
+// Will be modified when max signal is changed to be dynamic
+int os::sigexitnum_pd() {
+  return NSIG;
+}
+
+// a counter for each possible signal value
+static volatile jint pending_signals[NSIG+1] = { 0 };
+
+// Bsd(POSIX) specific hand shaking semaphore.
+#ifdef __APPLE__
+static semaphore_t sig_sem;
+#define SEM_INIT(sem, value)    semaphore_create(mach_task_self(), &sem, SYNC_POLICY_FIFO, value)
+#define SEM_WAIT(sem)           semaphore_wait(sem);
+#define SEM_POST(sem)           semaphore_signal(sem);
+#else
+static sem_t sig_sem;
+#define SEM_INIT(sem, value)    sem_init(&sem, 0, value)
+#define SEM_WAIT(sem)           sem_wait(&sem);
+#define SEM_POST(sem)           sem_post(&sem);
+#endif
+
+void os::signal_init_pd() {
+  // Initialize signal structures
+  ::memset((void*)pending_signals, 0, sizeof(pending_signals));
+
+  // Initialize signal semaphore
+  ::SEM_INIT(sig_sem, 0);
+}
+
+void os::signal_notify(int sig) {
+  Atomic::inc(&pending_signals[sig]);
+  ::SEM_POST(sig_sem);
+}
+
+static int check_pending_signals(bool wait) {
+  Atomic::store(0, &sigint_count);
+  for (;;) {
+    for (int i = 0; i < NSIG + 1; i++) {
+      jint n = pending_signals[i];
+      if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) {
+        return i;
+      }
+    }
+    if (!wait) {
+      return -1;
+    }
+    JavaThread *thread = JavaThread::current();
+    ThreadBlockInVM tbivm(thread);
+
+    bool threadIsSuspended;
+    do {
+      thread->set_suspend_equivalent();
+      // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self()
+      ::SEM_WAIT(sig_sem);
+
+      // were we externally suspended while we were waiting?
+      threadIsSuspended = thread->handle_special_suspend_equivalent_condition();
+      if (threadIsSuspended) {
+        //
+        // The semaphore has been incremented, but while we were waiting
+        // another thread suspended us. We don't want to continue running
+        // while suspended because that would surprise the thread that
+        // suspended us.
+        //
+        ::SEM_POST(sig_sem);
+
+        thread->java_suspend_self();
+      }
+    } while (threadIsSuspended);
+  }
+}
+
+int os::signal_lookup() {
+  return check_pending_signals(false);
+}
+
+int os::signal_wait() {
+  return check_pending_signals(true);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Virtual Memory
+
+int os::vm_page_size() {
+  // Seems redundant as all get out
+  assert(os::Bsd::page_size() != -1, "must call os::init");
+  return os::Bsd::page_size();
+}
+
+// Solaris allocates memory by pages.
+int os::vm_allocation_granularity() {
+  assert(os::Bsd::page_size() != -1, "must call os::init");
+  return os::Bsd::page_size();
+}
+
+// Rationale behind this function:
+//  current (Mon Apr 25 20:12:18 MSD 2005) oprofile drops samples without executable
+//  mapping for address (see lookup_dcookie() in the kernel module), thus we cannot get
+//  samples for JITted code. Here we create private executable mapping over the code cache
+//  and then we can use standard (well, almost, as mapping can change) way to provide
+//  info for the reporting script by storing timestamp and location of symbol
+void bsd_wrap_code(char* base, size_t size) {
+  static volatile jint cnt = 0;
+
+  if (!UseOprofile) {
+    return;
+  }
+
+  char buf[PATH_MAX + 1];
+  int num = Atomic::add(1, &cnt);
+
+  snprintf(buf, PATH_MAX + 1, "%s/hs-vm-%d-%d",
+           os::get_temp_directory(), os::current_process_id(), num);
+  unlink(buf);
+
+  int fd = ::open(buf, O_CREAT | O_RDWR, S_IRWXU);
+
+  if (fd != -1) {
+    off_t rv = ::lseek(fd, size-2, SEEK_SET);
+    if (rv != (off_t)-1) {
+      if (::write(fd, "", 1) == 1) {
+        mmap(base, size,
+             PROT_READ|PROT_WRITE|PROT_EXEC,
+             MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE, fd, 0);
+      }
+    }
+    ::close(fd);
+    unlink(buf);
+  }
+}
+
+// NOTE: Bsd kernel does not really reserve the pages for us.
+//       All it does is to check if there are enough free pages
+//       left at the time of mmap(). This could be a potential
+//       problem.
+bool os::commit_memory(char* addr, size_t size, bool exec) {
+  int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
+#ifdef __OpenBSD__
+  // XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
+  return ::mprotect(addr, size, prot) == 0;
+#else
+  uintptr_t res = (uintptr_t) ::mmap(addr, size, prot,
+                                   MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
+  return res != (uintptr_t) MAP_FAILED;
+#endif
+}
+
+#ifndef _ALLBSD_SOURCE
+// Define MAP_HUGETLB here so we can build HotSpot on old systems.
+#ifndef MAP_HUGETLB
+#define MAP_HUGETLB 0x40000
+#endif
+
+// Define MADV_HUGEPAGE here so we can build HotSpot on old systems.
+#ifndef MADV_HUGEPAGE
+#define MADV_HUGEPAGE 14
+#endif
+#endif
+
+bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
+                       bool exec) {
+#ifndef _ALLBSD_SOURCE
+  if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
+    int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
+    uintptr_t res =
+      (uintptr_t) ::mmap(addr, size, prot,
+                         MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_HUGETLB,
+                         -1, 0);
+    return res != (uintptr_t) MAP_FAILED;
+  }
+#endif
+
+  return commit_memory(addr, size, exec);
+}
+
+void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
+#ifndef _ALLBSD_SOURCE
+  if (UseHugeTLBFS && alignment_hint > (size_t)vm_page_size()) {
+    // We don't check the return value: madvise(MADV_HUGEPAGE) may not
+    // be supported or the memory may already be backed by huge pages.
+    ::madvise(addr, bytes, MADV_HUGEPAGE);
+  }
+#endif
+}
+
+void os::free_memory(char *addr, size_t bytes) {
+  ::madvise(addr, bytes, MADV_DONTNEED);
+}
+
+void os::numa_make_global(char *addr, size_t bytes) {
+}
+
+void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint) {
+}
+
+bool os::numa_topology_changed()   { return false; }
+
+size_t os::numa_get_groups_num() {
+  return 1;
+}
+
+int os::numa_get_group_id() {
+  return 0;
+}
+
+size_t os::numa_get_leaf_groups(int *ids, size_t size) {
+  if (size > 0) {
+    ids[0] = 0;
+    return 1;
+  }
+  return 0;
+}
+
+bool os::get_page_info(char *start, page_info* info) {
+  return false;
+}
+
+char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info* page_found) {
+  return end;
+}
+
+#ifndef _ALLBSD_SOURCE
+// Something to do with the numa-aware allocator needs these symbols
+extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { }
+extern "C" JNIEXPORT void numa_error(char *where) { }
+extern "C" JNIEXPORT int fork1() { return fork(); }
+
+
+// If we are running with libnuma version > 2, then we should
+// be trying to use symbols with versions 1.1
+// If we are running with earlier version, which did not have symbol versions,
+// we should use the base version.
+void* os::Bsd::libnuma_dlsym(void* handle, const char *name) {
+  void *f = dlvsym(handle, name, "libnuma_1.1");
+  if (f == NULL) {
+    f = dlsym(handle, name);
+  }
+  return f;
+}
+
+bool os::Bsd::libnuma_init() {
+  // sched_getcpu() should be in libc.
+  set_sched_getcpu(CAST_TO_FN_PTR(sched_getcpu_func_t,
+                                  dlsym(RTLD_DEFAULT, "sched_getcpu")));
+
+  if (sched_getcpu() != -1) { // Does it work?
+    void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
+    if (handle != NULL) {
+      set_numa_node_to_cpus(CAST_TO_FN_PTR(numa_node_to_cpus_func_t,
+                                           libnuma_dlsym(handle, "numa_node_to_cpus")));
+      set_numa_max_node(CAST_TO_FN_PTR(numa_max_node_func_t,
+                                       libnuma_dlsym(handle, "numa_max_node")));
+      set_numa_available(CAST_TO_FN_PTR(numa_available_func_t,
+                                        libnuma_dlsym(handle, "numa_available")));
+      set_numa_tonode_memory(CAST_TO_FN_PTR(numa_tonode_memory_func_t,
+                                            libnuma_dlsym(handle, "numa_tonode_memory")));
+      set_numa_interleave_memory(CAST_TO_FN_PTR(numa_interleave_memory_func_t,
+                                            libnuma_dlsym(handle, "numa_interleave_memory")));
+
+
+      if (numa_available() != -1) {
+        set_numa_all_nodes((unsigned long*)libnuma_dlsym(handle, "numa_all_nodes"));
+        // Create a cpu -> node mapping
+        _cpu_to_node = new (ResourceObj::C_HEAP) GrowableArray<int>(0, true);
+        rebuild_cpu_to_node_map();
+        return true;
+      }
+    }
+  }
+  return false;
+}
+
+// rebuild_cpu_to_node_map() constructs a table mapping cpud id to node id.
+// The table is later used in get_node_by_cpu().
+void os::Bsd::rebuild_cpu_to_node_map() {
+  const size_t NCPUS = 32768; // Since the buffer size computation is very obscure
+                              // in libnuma (possible values are starting from 16,
+                              // and continuing up with every other power of 2, but less
+                              // than the maximum number of CPUs supported by kernel), and
+                              // is a subject to change (in libnuma version 2 the requirements
+                              // are more reasonable) we'll just hardcode the number they use
+                              // in the library.
+  const size_t BitsPerCLong = sizeof(long) * CHAR_BIT;
+
+  size_t cpu_num = os::active_processor_count();
+  size_t cpu_map_size = NCPUS / BitsPerCLong;
+  size_t cpu_map_valid_size =
+    MIN2((cpu_num + BitsPerCLong - 1) / BitsPerCLong, cpu_map_size);
+
+  cpu_to_node()->clear();
+  cpu_to_node()->at_grow(cpu_num - 1);
+  size_t node_num = numa_get_groups_num();
+
+  unsigned long *cpu_map = NEW_C_HEAP_ARRAY(unsigned long, cpu_map_size);
+  for (size_t i = 0; i < node_num; i++) {
+    if (numa_node_to_cpus(i, cpu_map, cpu_map_size * sizeof(unsigned long)) != -1) {
+      for (size_t j = 0; j < cpu_map_valid_size; j++) {
+        if (cpu_map[j] != 0) {
+          for (size_t k = 0; k < BitsPerCLong; k++) {
+            if (cpu_map[j] & (1UL << k)) {
+              cpu_to_node()->at_put(j * BitsPerCLong + k, i);
+            }
+          }
+        }
+      }
+    }
+  }
+  FREE_C_HEAP_ARRAY(unsigned long, cpu_map);
+}
+
+int os::Bsd::get_node_by_cpu(int cpu_id) {
+  if (cpu_to_node() != NULL && cpu_id >= 0 && cpu_id < cpu_to_node()->length()) {
+    return cpu_to_node()->at(cpu_id);
+  }
+  return -1;
+}
+
+GrowableArray<int>* os::Bsd::_cpu_to_node;
+os::Bsd::sched_getcpu_func_t os::Bsd::_sched_getcpu;
+os::Bsd::numa_node_to_cpus_func_t os::Bsd::_numa_node_to_cpus;
+os::Bsd::numa_max_node_func_t os::Bsd::_numa_max_node;
+os::Bsd::numa_available_func_t os::Bsd::_numa_available;
+os::Bsd::numa_tonode_memory_func_t os::Bsd::_numa_tonode_memory;
+os::Bsd::numa_interleave_memory_func_t os::Bsd::_numa_interleave_memory;
+unsigned long* os::Bsd::_numa_all_nodes;
+#endif
+
+bool os::uncommit_memory(char* addr, size_t size) {
+#ifdef __OpenBSD__
+  // XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
+  return ::mprotect(addr, size, PROT_NONE) == 0;
+#else
+  uintptr_t res = (uintptr_t) ::mmap(addr, size, PROT_NONE,
+                MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE|MAP_ANONYMOUS, -1, 0);
+  return res  != (uintptr_t) MAP_FAILED;
+#endif
+}
+
+bool os::create_stack_guard_pages(char* addr, size_t size) {
+  return os::commit_memory(addr, size);
+}
+
+// If this is a growable mapping, remove the guard pages entirely by
+// munmap()ping them.  If not, just call uncommit_memory().
+bool os::remove_stack_guard_pages(char* addr, size_t size) {
+  return os::uncommit_memory(addr, size);
+}
+
+static address _highest_vm_reserved_address = NULL;
+
+// If 'fixed' is true, anon_mmap() will attempt to reserve anonymous memory
+// at 'requested_addr'. If there are existing memory mappings at the same
+// location, however, they will be overwritten. If 'fixed' is false,
+// 'requested_addr' is only treated as a hint, the return value may or
+// may not start from the requested address. Unlike Bsd mmap(), this
+// function returns NULL to indicate failure.
+static char* anon_mmap(char* requested_addr, size_t bytes, bool fixed) {
+  char * addr;
+  int flags;
+
+  flags = MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS;
+  if (fixed) {
+    assert((uintptr_t)requested_addr % os::Bsd::page_size() == 0, "unaligned address");
+    flags |= MAP_FIXED;
+  }
+
+  // Map uncommitted pages PROT_READ and PROT_WRITE, change access
+  // to PROT_EXEC if executable when we commit the page.
+  addr = (char*)::mmap(requested_addr, bytes, PROT_READ|PROT_WRITE,
+                       flags, -1, 0);
+
+  if (addr != MAP_FAILED) {
+    // anon_mmap() should only get called during VM initialization,
+    // don't need lock (actually we can skip locking even it can be called
+    // from multiple threads, because _highest_vm_reserved_address is just a
+    // hint about the upper limit of non-stack memory regions.)
+    if ((address)addr + bytes > _highest_vm_reserved_address) {
+      _highest_vm_reserved_address = (address)addr + bytes;
+    }
+  }
+
+  return addr == MAP_FAILED ? NULL : addr;
+}
+
+// Don't update _highest_vm_reserved_address, because there might be memory
+// regions above addr + size. If so, releasing a memory region only creates
+// a hole in the address space, it doesn't help prevent heap-stack collision.
+//
+static int anon_munmap(char * addr, size_t size) {
+  return ::munmap(addr, size) == 0;
+}
+
+char* os::reserve_memory(size_t bytes, char* requested_addr,
+                         size_t alignment_hint) {
+  return anon_mmap(requested_addr, bytes, (requested_addr != NULL));
+}
+
+bool os::release_memory(char* addr, size_t size) {
+  return anon_munmap(addr, size);
+}
+
+static address highest_vm_reserved_address() {
+  return _highest_vm_reserved_address;
+}
+
+static bool bsd_mprotect(char* addr, size_t size, int prot) {
+  // Bsd wants the mprotect address argument to be page aligned.
+  char* bottom = (char*)align_size_down((intptr_t)addr, os::Bsd::page_size());
+
+  // According to SUSv3, mprotect() should only be used with mappings
+  // established by mmap(), and mmap() always maps whole pages. Unaligned
+  // 'addr' likely indicates problem in the VM (e.g. trying to change
+  // protection of malloc'ed or statically allocated memory). Check the
+  // caller if you hit this assert.
+  assert(addr == bottom, "sanity check");
+
+  size = align_size_up(pointer_delta(addr, bottom, 1) + size, os::Bsd::page_size());
+  return ::mprotect(bottom, size, prot) == 0;
+}
+
+// Set protections specified
+bool os::protect_memory(char* addr, size_t bytes, ProtType prot,
+                        bool is_committed) {
+  unsigned int p = 0;
+  switch (prot) {
+  case MEM_PROT_NONE: p = PROT_NONE; break;
+  case MEM_PROT_READ: p = PROT_READ; break;
+  case MEM_PROT_RW:   p = PROT_READ|PROT_WRITE; break;
+  case MEM_PROT_RWX:  p = PROT_READ|PROT_WRITE|PROT_EXEC; break;
+  default:
+    ShouldNotReachHere();
+  }
+  // is_committed is unused.
+  return bsd_mprotect(addr, bytes, p);
+}
+
+bool os::guard_memory(char* addr, size_t size) {
+  return bsd_mprotect(addr, size, PROT_NONE);
+}
+
+bool os::unguard_memory(char* addr, size_t size) {
+  return bsd_mprotect(addr, size, PROT_READ|PROT_WRITE);
+}
+
+bool os::Bsd::hugetlbfs_sanity_check(bool warn, size_t page_size) {
+  bool result = false;
+#ifndef _ALLBSD_SOURCE
+  void *p = mmap (NULL, page_size, PROT_READ|PROT_WRITE,
+                  MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB,
+                  -1, 0);
+
+  if (p != (void *) -1) {
+    // We don't know if this really is a huge page or not.
+    FILE *fp = fopen("/proc/self/maps", "r");
+    if (fp) {
+      while (!feof(fp)) {
+        char chars[257];
+        long x = 0;
+        if (fgets(chars, sizeof(chars), fp)) {
+          if (sscanf(chars, "%lx-%*x", &x) == 1
+              && x == (long)p) {
+            if (strstr (chars, "hugepage")) {
+              result = true;
+              break;
+            }
+          }
+        }
+      }
+      fclose(fp);
+    }
+    munmap (p, page_size);
+    if (result)
+      return true;
+  }
+
+  if (warn) {
+    warning("HugeTLBFS is not supported by the operating system.");
+  }
+#endif
+
+  return result;
+}
+
+/*
+* Set the coredump_filter bits to include largepages in core dump (bit 6)
+*
+* From the coredump_filter documentation:
+*
+* - (bit 0) anonymous private memory
+* - (bit 1) anonymous shared memory
+* - (bit 2) file-backed private memory
+* - (bit 3) file-backed shared memory
+* - (bit 4) ELF header pages in file-backed private memory areas (it is
+*           effective only if the bit 2 is cleared)
+* - (bit 5) hugetlb private memory
+* - (bit 6) hugetlb shared memory
+*/
+static void set_coredump_filter(void) {
+  FILE *f;
+  long cdm;
+
+  if ((f = fopen("/proc/self/coredump_filter", "r+")) == NULL) {
+    return;
+  }
+
+  if (fscanf(f, "%lx", &cdm) != 1) {
+    fclose(f);
+    return;
+  }
+
+  rewind(f);
+
+  if ((cdm & LARGEPAGES_BIT) == 0) {
+    cdm |= LARGEPAGES_BIT;
+    fprintf(f, "%#lx", cdm);
+  }
+
+  fclose(f);
+}
+
+// Large page support
+
+static size_t _large_page_size = 0;
+
+void os::large_page_init() {
+#ifndef _ALLBSD_SOURCE
+  if (!UseLargePages) {
+    UseHugeTLBFS = false;
+    UseSHM = false;
+    return;
+  }
+
+  if (FLAG_IS_DEFAULT(UseHugeTLBFS) && FLAG_IS_DEFAULT(UseSHM)) {
+    // If UseLargePages is specified on the command line try both methods,
+    // if it's default, then try only HugeTLBFS.
+    if (FLAG_IS_DEFAULT(UseLargePages)) {
+      UseHugeTLBFS = true;
+    } else {
+      UseHugeTLBFS = UseSHM = true;
+    }
+  }
+
+  if (LargePageSizeInBytes) {
+    _large_page_size = LargePageSizeInBytes;
+  } else {
+    // large_page_size on Bsd is used to round up heap size. x86 uses either
+    // 2M or 4M page, depending on whether PAE (Physical Address Extensions)
+    // mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. IA64 can use
+    // page as large as 256M.
+    //
+    // Here we try to figure out page size by parsing /proc/meminfo and looking
+    // for a line with the following format:
+    //    Hugepagesize:     2048 kB
+    //
+    // If we can't determine the value (e.g. /proc is not mounted, or the text
+    // format has been changed), we'll use the largest page size supported by
+    // the processor.
+
+#ifndef ZERO
+    _large_page_size = IA32_ONLY(4 * M) AMD64_ONLY(2 * M) IA64_ONLY(256 * M) SPARC_ONLY(4 * M)
+                       ARM_ONLY(2 * M) PPC_ONLY(4 * M);
+#endif // ZERO
+
+    FILE *fp = fopen("/proc/meminfo", "r");
+    if (fp) {
+      while (!feof(fp)) {
+        int x = 0;
+        char buf[16];
+        if (fscanf(fp, "Hugepagesize: %d", &x) == 1) {
+          if (x && fgets(buf, sizeof(buf), fp) && strcmp(buf, " kB\n") == 0) {
+            _large_page_size = x * K;
+            break;
+          }
+        } else {
+          // skip to next line
+          for (;;) {
+            int ch = fgetc(fp);
+            if (ch == EOF || ch == (int)'\n') break;
+          }
+        }
+      }
+      fclose(fp);
+    }
+  }
+
+  // print a warning if any large page related flag is specified on command line
+  bool warn_on_failure = !FLAG_IS_DEFAULT(UseHugeTLBFS);
+
+  const size_t default_page_size = (size_t)Bsd::page_size();
+  if (_large_page_size > default_page_size) {
+    _page_sizes[0] = _large_page_size;
+    _page_sizes[1] = default_page_size;
+    _page_sizes[2] = 0;
+  }
+  UseHugeTLBFS = UseHugeTLBFS &&
+                 Bsd::hugetlbfs_sanity_check(warn_on_failure, _large_page_size);
+
+  if (UseHugeTLBFS)
+    UseSHM = false;
+
+  UseLargePages = UseHugeTLBFS || UseSHM;
+
+  set_coredump_filter();
+#endif
+}
+
+#ifndef _ALLBSD_SOURCE
+#ifndef SHM_HUGETLB
+#define SHM_HUGETLB 04000
+#endif
+#endif
+
+char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) {
+  // "exec" is passed in but not used.  Creating the shared image for
+  // the code cache doesn't have an SHM_X executable permission to check.
+  assert(UseLargePages && UseSHM, "only for SHM large pages");
+
+  key_t key = IPC_PRIVATE;
+  char *addr;
+
+  bool warn_on_failure = UseLargePages &&
+                        (!FLAG_IS_DEFAULT(UseLargePages) ||
+                         !FLAG_IS_DEFAULT(LargePageSizeInBytes)
+                        );
+  char msg[128];
+
+  // Create a large shared memory region to attach to based on size.
+  // Currently, size is the total size of the heap
+#ifndef _ALLBSD_SOURCE
+  int shmid = shmget(key, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W);
+#else
+  int shmid = shmget(key, bytes, IPC_CREAT|SHM_R|SHM_W);
+#endif
+  if (shmid == -1) {
+     // Possible reasons for shmget failure:
+     // 1. shmmax is too small for Java heap.
+     //    > check shmmax value: cat /proc/sys/kernel/shmmax
+     //    > increase shmmax value: echo "0xffffffff" > /proc/sys/kernel/shmmax
+     // 2. not enough large page memory.
+     //    > check available large pages: cat /proc/meminfo
+     //    > increase amount of large pages:
+     //          echo new_value > /proc/sys/vm/nr_hugepages
+     //      Note 1: different Bsd may use different name for this property,
+     //            e.g. on Redhat AS-3 it is "hugetlb_pool".
+     //      Note 2: it's possible there's enough physical memory available but
+     //            they are so fragmented after a long run that they can't
+     //            coalesce into large pages. Try to reserve large pages when
+     //            the system is still "fresh".
+     if (warn_on_failure) {
+       jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno);
+       warning(msg);
+     }
+     return NULL;
+  }
+
+  // attach to the region
+  addr = (char*)shmat(shmid, req_addr, 0);
+  int err = errno;
+
+  // Remove shmid. If shmat() is successful, the actual shared memory segment
+  // will be deleted when it's detached by shmdt() or when the process
+  // terminates. If shmat() is not successful this will remove the shared
+  // segment immediately.
+  shmctl(shmid, IPC_RMID, NULL);
+
+  if ((intptr_t)addr == -1) {
+     if (warn_on_failure) {
+       jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err);
+       warning(msg);
+     }
+     return NULL;
+  }
+
+  return addr;
+}
+
+bool os::release_memory_special(char* base, size_t bytes) {
+  // detaching the SHM segment will also delete it, see reserve_memory_special()
+  int rslt = shmdt(base);
+  return rslt == 0;
+}
+
+size_t os::large_page_size() {
+  return _large_page_size;
+}
+
+// HugeTLBFS allows application to commit large page memory on demand;
+// with SysV SHM the entire memory region must be allocated as shared
+// memory.
+bool os::can_commit_large_page_memory() {
+  return UseHugeTLBFS;
+}
+
+bool os::can_execute_large_page_memory() {
+  return UseHugeTLBFS;
+}
+
+// Reserve memory at an arbitrary address, only if that area is
+// available (and not reserved for something else).
+
+char* os::attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
+  const int max_tries = 10;
+  char* base[max_tries];
+  size_t size[max_tries];
+  const size_t gap = 0x000000;
+
+  // Assert only that the size is a multiple of the page size, since
+  // that's all that mmap requires, and since that's all we really know
+  // about at this low abstraction level.  If we need higher alignment,
+  // we can either pass an alignment to this method or verify alignment
+  // in one of the methods further up the call chain.  See bug 5044738.
+  assert(bytes % os::vm_page_size() == 0, "reserving unexpected size block");
+
+  // Repeatedly allocate blocks until the block is allocated at the
+  // right spot. Give up after max_tries. Note that reserve_memory() will
+  // automatically update _highest_vm_reserved_address if the call is
+  // successful. The variable tracks the highest memory address every reserved
+  // by JVM. It is used to detect heap-stack collision if running with
+  // fixed-stack BsdThreads. Because here we may attempt to reserve more
+  // space than needed, it could confuse the collision detecting code. To
+  // solve the problem, save current _highest_vm_reserved_address and
+  // calculate the correct value before return.
+  address old_highest = _highest_vm_reserved_address;
+
+  // Bsd mmap allows caller to pass an address as hint; give it a try first,
+  // if kernel honors the hint then we can return immediately.
+  char * addr = anon_mmap(requested_addr, bytes, false);
+  if (addr == requested_addr) {
+     return requested_addr;
+  }
+
+  if (addr != NULL) {
+     // mmap() is successful but it fails to reserve at the requested address
+     anon_munmap(addr, bytes);
+  }
+
+  int i;
+  for (i = 0; i < max_tries; ++i) {
+    base[i] = reserve_memory(bytes);
+
+    if (base[i] != NULL) {
+      // Is this the block we wanted?
+      if (base[i] == requested_addr) {
+        size[i] = bytes;
+        break;
+      }
+
+      // Does this overlap the block we wanted? Give back the overlapped
+      // parts and try again.
+
+      size_t top_overlap = requested_addr + (bytes + gap) - base[i];
+      if (top_overlap >= 0 && top_overlap < bytes) {
+        unmap_memory(base[i], top_overlap);
+        base[i] += top_overlap;
+        size[i] = bytes - top_overlap;
+      } else {
+        size_t bottom_overlap = base[i] + bytes - requested_addr;
+        if (bottom_overlap >= 0 && bottom_overlap < bytes) {
+          unmap_memory(requested_addr, bottom_overlap);
+          size[i] = bytes - bottom_overlap;
+        } else {
+          size[i] = bytes;
+        }
+      }
+    }
+  }
+
+  // Give back the unused reserved pieces.
+
+  for (int j = 0; j < i; ++j) {
+    if (base[j] != NULL) {
+      unmap_memory(base[j], size[j]);
+    }
+  }
+
+  if (i < max_tries) {
+    _highest_vm_reserved_address = MAX2(old_highest, (address)requested_addr + bytes);
+    return requested_addr;
+  } else {
+    _highest_vm_reserved_address = old_highest;
+    return NULL;
+  }
+}
+
+size_t os::read(int fd, void *buf, unsigned int nBytes) {
+  RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes));
+}
+
+// TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation.
+// Solaris uses poll(), bsd uses park().
+// Poll() is likely a better choice, assuming that Thread.interrupt()
+// generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
+// SIGSEGV, see 4355769.
+
+const int NANOSECS_PER_MILLISECS = 1000000;
+
+int os::sleep(Thread* thread, jlong millis, bool interruptible) {
+  assert(thread == Thread::current(),  "thread consistency check");
+
+  ParkEvent * const slp = thread->_SleepEvent ;
+  slp->reset() ;
+  OrderAccess::fence() ;
+
+  if (interruptible) {
+    jlong prevtime = javaTimeNanos();
+
+    for (;;) {
+      if (os::is_interrupted(thread, true)) {
+        return OS_INTRPT;
+      }
+
+      jlong newtime = javaTimeNanos();
+
+      if (newtime - prevtime < 0) {
+        // time moving backwards, should only happen if no monotonic clock
+        // not a guarantee() because JVM should not abort on kernel/glibc bugs
+        assert(!Bsd::supports_monotonic_clock(), "time moving backwards");
+      } else {
+        millis -= (newtime - prevtime) / NANOSECS_PER_MILLISECS;
+      }
+
+      if(millis <= 0) {
+        return OS_OK;
+      }
+
+      prevtime = newtime;
+
+      {
+        assert(thread->is_Java_thread(), "sanity check");
+        JavaThread *jt = (JavaThread *) thread;
+        ThreadBlockInVM tbivm(jt);
+        OSThreadWaitState osts(jt->osthread(), false /* not Object.wait() */);
+
+        jt->set_suspend_equivalent();
+        // cleared by handle_special_suspend_equivalent_condition() or
+        // java_suspend_self() via check_and_wait_while_suspended()
+
+        slp->park(millis);
+
+        // were we externally suspended while we were waiting?
+        jt->check_and_wait_while_suspended();
+      }
+    }
+  } else {
+    OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
+    jlong prevtime = javaTimeNanos();
+
+    for (;;) {
+      // It'd be nice to avoid the back-to-back javaTimeNanos() calls on
+      // the 1st iteration ...
+      jlong newtime = javaTimeNanos();
+
+      if (newtime - prevtime < 0) {
+        // time moving backwards, should only happen if no monotonic clock
+        // not a guarantee() because JVM should not abort on kernel/glibc bugs
+        assert(!Bsd::supports_monotonic_clock(), "time moving backwards");
+      } else {
+        millis -= (newtime - prevtime) / NANOSECS_PER_MILLISECS;
+      }
+
+      if(millis <= 0) break ;
+
+      prevtime = newtime;
+      slp->park(millis);
+    }
+    return OS_OK ;
+  }
+}
+
+int os::naked_sleep() {
+  // %% make the sleep time an integer flag. for now use 1 millisec.
+  return os::sleep(Thread::current(), 1, false);
+}
+
+// Sleep forever; naked call to OS-specific sleep; use with CAUTION
+void os::infinite_sleep() {
+  while (true) {    // sleep forever ...
+    ::sleep(100);   // ... 100 seconds at a time
+  }
+}
+
+// Used to convert frequent JVM_Yield() to nops
+bool os::dont_yield() {
+  return DontYieldALot;
+}
+
+void os::yield() {
+  sched_yield();
+}
+
+os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;}
+
+void os::yield_all(int attempts) {
+  // Yields to all threads, including threads with lower priorities
+  // Threads on Bsd are all with same priority. The Solaris style
+  // os::yield_all() with nanosleep(1ms) is not necessary.
+  sched_yield();
+}
+
+// Called from the tight loops to possibly influence time-sharing heuristics
+void os::loop_breaker(int attempts) {
+  os::yield_all(attempts);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// thread priority support
+
+// Note: Normal Bsd applications are run with SCHED_OTHER policy. SCHED_OTHER
+// only supports dynamic priority, static priority must be zero. For real-time
+// applications, Bsd supports SCHED_RR which allows static priority (1-99).
+// However, for large multi-threaded applications, SCHED_RR is not only slower
+// than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out
+// of 5 runs - Sep 2005).
+//
+// The following code actually changes the niceness of kernel-thread/LWP. It
+// has an assumption that setpriority() only modifies one kernel-thread/LWP,
+// not the entire user process, and user level threads are 1:1 mapped to kernel
+// threads. It has always been the case, but could change in the future. For
+// this reason, the code should not be used as default (ThreadPriorityPolicy=0).
+// It is only used when ThreadPriorityPolicy=1 and requires root privilege.
+
+#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__)
+int os::java_to_os_priority[MaxPriority + 1] = {
+  19,              // 0 Entry should never be used
+
+   0,              // 1 MinPriority
+   3,              // 2
+   6,              // 3
+
+   10,              // 4
+   15,              // 5 NormPriority
+   18,              // 6
+
+   21,              // 7
+   25,              // 8
+   28,              // 9 NearMaxPriority
+
+   31              // 10 MaxPriority
+};
+#elif defined(__APPLE__)
+/* Using Mach high-level priority assignments */
+int os::java_to_os_priority[MaxPriority + 1] = {
+   0,              // 0 Entry should never be used (MINPRI_USER)
+
+  27,              // 1 MinPriority
+  28,              // 2
+  29,              // 3
+
+  30,              // 4
+  31,              // 5 NormPriority (BASEPRI_DEFAULT)
+  32,              // 6
+
+  33,              // 7
+  34,              // 8
+  35,              // 9 NearMaxPriority
+
+  36               // 10 MaxPriority
+};
+#else
+int os::java_to_os_priority[MaxPriority + 1] = {
+  19,              // 0 Entry should never be used
+
+   4,              // 1 MinPriority
+   3,              // 2
+   2,              // 3
+
+   1,              // 4
+   0,              // 5 NormPriority
+  -1,              // 6
+
+  -2,              // 7
+  -3,              // 8
+  -4,              // 9 NearMaxPriority
+
+  -5               // 10 MaxPriority
+};
+#endif
+
+static int prio_init() {
+  if (ThreadPriorityPolicy == 1) {
+    // Only root can raise thread priority. Don't allow ThreadPriorityPolicy=1
+    // if effective uid is not root. Perhaps, a more elegant way of doing
+    // this is to test CAP_SYS_NICE capability, but that will require libcap.so
+    if (geteuid() != 0) {
+      if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) {
+        warning("-XX:ThreadPriorityPolicy requires root privilege on Bsd");
+      }
+      ThreadPriorityPolicy = 0;
+    }
+  }
+  return 0;
+}
+
+OSReturn os::set_native_priority(Thread* thread, int newpri) {
+  if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK;
+
+#ifdef __OpenBSD__
+  // OpenBSD pthread_setprio starves low priority threads
+  return OS_OK;
+#elif defined(__FreeBSD__)
+  int ret = pthread_setprio(thread->osthread()->pthread_id(), newpri);
+#elif defined(__APPLE__) || defined(__NetBSD__)
+  struct sched_param sp;
+  int policy;
+  pthread_t self = pthread_self();
+
+  if (pthread_getschedparam(self, &policy, &sp) != 0)
+    return OS_ERR;
+
+  sp.sched_priority = newpri;
+  if (pthread_setschedparam(self, policy, &sp) != 0)
+    return OS_ERR;
+
+  return OS_OK;
+#else
+  int ret = setpriority(PRIO_PROCESS, thread->osthread()->thread_id(), newpri);
+  return (ret == 0) ? OS_OK : OS_ERR;
+#endif
+}
+
+OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) {
+  if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) {
+    *priority_ptr = java_to_os_priority[NormPriority];
+    return OS_OK;
+  }
+
+  errno = 0;
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
+  *priority_ptr = pthread_getprio(thread->osthread()->pthread_id());
+#elif defined(__APPLE__) || defined(__NetBSD__)
+  int policy;
+  struct sched_param sp;
+
+  pthread_getschedparam(pthread_self(), &policy, &sp);
+  *priority_ptr = sp.sched_priority;
+#else
+  *priority_ptr = getpriority(PRIO_PROCESS, thread->osthread()->thread_id());
+#endif
+  return (*priority_ptr != -1 || errno == 0 ? OS_OK : OS_ERR);
+}
+
+// Hint to the underlying OS that a task switch would not be good.
+// Void return because it's a hint and can fail.
+void os::hint_no_preempt() {}
+
+////////////////////////////////////////////////////////////////////////////////
+// suspend/resume support
+
+//  the low-level signal-based suspend/resume support is a remnant from the
+//  old VM-suspension that used to be for java-suspension, safepoints etc,
+//  within hotspot. Now there is a single use-case for this:
+//    - calling get_thread_pc() on the VMThread by the flat-profiler task
+//      that runs in the watcher thread.
+//  The remaining code is greatly simplified from the more general suspension
+//  code that used to be used.
+//
+//  The protocol is quite simple:
+//  - suspend:
+//      - sends a signal to the target thread
+//      - polls the suspend state of the osthread using a yield loop
+//      - target thread signal handler (SR_handler) sets suspend state
+//        and blocks in sigsuspend until continued
+//  - resume:
+//      - sets target osthread state to continue
+//      - sends signal to end the sigsuspend loop in the SR_handler
+//
+//  Note that the SR_lock plays no role in this suspend/resume protocol.
+//
+
+static void resume_clear_context(OSThread *osthread) {
+  osthread->set_ucontext(NULL);
+  osthread->set_siginfo(NULL);
+
+  // notify the suspend action is completed, we have now resumed
+  osthread->sr.clear_suspended();
+}
+
+static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, ucontext_t* context) {
+  osthread->set_ucontext(context);
+  osthread->set_siginfo(siginfo);
+}
+
+//
+// Handler function invoked when a thread's execution is suspended or
+// resumed. We have to be careful that only async-safe functions are
+// called here (Note: most pthread functions are not async safe and
+// should be avoided.)
+//
+// Note: sigwait() is a more natural fit than sigsuspend() from an
+// interface point of view, but sigwait() prevents the signal hander
+// from being run. libpthread would get very confused by not having
+// its signal handlers run and prevents sigwait()'s use with the
+// mutex granting granting signal.
+//
+// Currently only ever called on the VMThread
+//
+static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
+  // Save and restore errno to avoid confusing native code with EINTR
+  // after sigsuspend.
+  int old_errno = errno;
+
+  Thread* thread = Thread::current();
+  OSThread* osthread = thread->osthread();
+  assert(thread->is_VM_thread(), "Must be VMThread");
+  // read current suspend action
+  int action = osthread->sr.suspend_action();
+  if (action == SR_SUSPEND) {
+    suspend_save_context(osthread, siginfo, context);
+
+    // Notify the suspend action is about to be completed. do_suspend()
+    // waits until SR_SUSPENDED is set and then returns. We will wait
+    // here for a resume signal and that completes the suspend-other
+    // action. do_suspend/do_resume is always called as a pair from
+    // the same thread - so there are no races
+
+    // notify the caller
+    osthread->sr.set_suspended();
+
+    sigset_t suspend_set;  // signals for sigsuspend()
+
+    // get current set of blocked signals and unblock resume signal
+    pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
+    sigdelset(&suspend_set, SR_signum);
+
+    // wait here until we are resumed
+    do {
+      sigsuspend(&suspend_set);
+      // ignore all returns until we get a resume signal
+    } while (osthread->sr.suspend_action() != SR_CONTINUE);
+
+    resume_clear_context(osthread);
+
+  } else {
+    assert(action == SR_CONTINUE, "unexpected sr action");
+    // nothing special to do - just leave the handler
+  }
+
+  errno = old_errno;
+}
+
+
+static int SR_initialize() {
+  struct sigaction act;
+  char *s;
+  /* Get signal number to use for suspend/resume */
+  if ((s = ::getenv("_JAVA_SR_SIGNUM")) != 0) {
+    int sig = ::strtol(s, 0, 10);
+    if (sig > 0 || sig < NSIG) {
+        SR_signum = sig;
+    }
+  }
+
+  assert(SR_signum > SIGSEGV && SR_signum > SIGBUS,
+        "SR_signum must be greater than max(SIGSEGV, SIGBUS), see 4355769");
+
+  sigemptyset(&SR_sigset);
+  sigaddset(&SR_sigset, SR_signum);
+
+  /* Set up signal handler for suspend/resume */
+  act.sa_flags = SA_RESTART|SA_SIGINFO;
+  act.sa_handler = (void (*)(int)) SR_handler;
+
+  // SR_signum is blocked by default.
+  // 4528190 - We also need to block pthread restart signal (32 on all
+  // supported Bsd platforms). Note that BsdThreads need to block
+  // this signal for all threads to work properly. So we don't have
+  // to use hard-coded signal number when setting up the mask.
+  pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask);
+
+  if (sigaction(SR_signum, &act, 0) == -1) {
+    return -1;
+  }
+
+  // Save signal flag
+  os::Bsd::set_our_sigflags(SR_signum, act.sa_flags);
+  return 0;
+}
+
+static int SR_finalize() {
+  return 0;
+}
+
+
+// returns true on success and false on error - really an error is fatal
+// but this seems the normal response to library errors
+static bool do_suspend(OSThread* osthread) {
+  // mark as suspended and send signal
+  osthread->sr.set_suspend_action(SR_SUSPEND);
+  int status = pthread_kill(osthread->pthread_id(), SR_signum);
+  assert_status(status == 0, status, "pthread_kill");
+
+  // check status and wait until notified of suspension
+  if (status == 0) {
+    for (int i = 0; !osthread->sr.is_suspended(); i++) {
+      os::yield_all(i);
+    }
+    osthread->sr.set_suspend_action(SR_NONE);
+    return true;
+  }
+  else {
+    osthread->sr.set_suspend_action(SR_NONE);
+    return false;
+  }
+}
+
+static void do_resume(OSThread* osthread) {
+  assert(osthread->sr.is_suspended(), "thread should be suspended");
+  osthread->sr.set_suspend_action(SR_CONTINUE);
+
+  int status = pthread_kill(osthread->pthread_id(), SR_signum);
+  assert_status(status == 0, status, "pthread_kill");
+  // check status and wait unit notified of resumption
+  if (status == 0) {
+    for (int i = 0; osthread->sr.is_suspended(); i++) {
+      os::yield_all(i);
+    }
+  }
+  osthread->sr.set_suspend_action(SR_NONE);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// interrupt support
+
+void os::interrupt(Thread* thread) {
+  assert(Thread::current() == thread || Threads_lock->owned_by_self(),
+    "possibility of dangling Thread pointer");
+
+  OSThread* osthread = thread->osthread();
+
+  if (!osthread->interrupted()) {
+    osthread->set_interrupted(true);
+    // More than one thread can get here with the same value of osthread,
+    // resulting in multiple notifications.  We do, however, want the store
+    // to interrupted() to be visible to other threads before we execute unpark().
+    OrderAccess::fence();
+    ParkEvent * const slp = thread->_SleepEvent ;
+    if (slp != NULL) slp->unpark() ;
+  }
+
+  // For JSR166. Unpark even if interrupt status already was set
+  if (thread->is_Java_thread())
+    ((JavaThread*)thread)->parker()->unpark();
+
+  ParkEvent * ev = thread->_ParkEvent ;
+  if (ev != NULL) ev->unpark() ;
+
+}
+
+bool os::is_interrupted(Thread* thread, bool clear_interrupted) {
+  assert(Thread::current() == thread || Threads_lock->owned_by_self(),
+    "possibility of dangling Thread pointer");
+
+  OSThread* osthread = thread->osthread();
+
+  bool interrupted = osthread->interrupted();
+
+  if (interrupted && clear_interrupted) {
+    osthread->set_interrupted(false);
+    // consider thread->_SleepEvent->reset() ... optional optimization
+  }
+
+  return interrupted;
+}
+
+///////////////////////////////////////////////////////////////////////////////////
+// signal handling (except suspend/resume)
+
+// This routine may be used by user applications as a "hook" to catch signals.
+// The user-defined signal handler must pass unrecognized signals to this
+// routine, and if it returns true (non-zero), then the signal handler must
+// return immediately.  If the flag "abort_if_unrecognized" is true, then this
+// routine will never retun false (zero), but instead will execute a VM panic
+// routine kill the process.
+//
+// If this routine returns false, it is OK to call it again.  This allows
+// the user-defined signal handler to perform checks either before or after
+// the VM performs its own checks.  Naturally, the user code would be making
+// a serious error if it tried to handle an exception (such as a null check
+// or breakpoint) that the VM was generating for its own correct operation.
+//
+// This routine may recognize any of the following kinds of signals:
+//    SIGBUS, SIGSEGV, SIGILL, SIGFPE, SIGQUIT, SIGPIPE, SIGXFSZ, SIGUSR1.
+// It should be consulted by handlers for any of those signals.
+//
+// The caller of this routine must pass in the three arguments supplied
+// to the function referred to in the "sa_sigaction" (not the "sa_handler")
+// field of the structure passed to sigaction().  This routine assumes that
+// the sa_flags field passed to sigaction() includes SA_SIGINFO and SA_RESTART.
+//
+// Note that the VM will print warnings if it detects conflicting signal
+// handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers".
+//
+extern "C" JNIEXPORT int
+JVM_handle_bsd_signal(int signo, siginfo_t* siginfo,
+                        void* ucontext, int abort_if_unrecognized);
+
+void signalHandler(int sig, siginfo_t* info, void* uc) {
+  assert(info != NULL && uc != NULL, "it must be old kernel");
+  JVM_handle_bsd_signal(sig, info, uc, true);
+}
+
+
+// This boolean allows users to forward their own non-matching signals
+// to JVM_handle_bsd_signal, harmlessly.
+bool os::Bsd::signal_handlers_are_installed = false;
+
+// For signal-chaining
+struct sigaction os::Bsd::sigact[MAXSIGNUM];
+unsigned int os::Bsd::sigs = 0;
+bool os::Bsd::libjsig_is_loaded = false;
+typedef struct sigaction *(*get_signal_t)(int);
+get_signal_t os::Bsd::get_signal_action = NULL;
+
+struct sigaction* os::Bsd::get_chained_signal_action(int sig) {
+  struct sigaction *actp = NULL;
+
+  if (libjsig_is_loaded) {
+    // Retrieve the old signal handler from libjsig
+    actp = (*get_signal_action)(sig);
+  }
+  if (actp == NULL) {
+    // Retrieve the preinstalled signal handler from jvm
+    actp = get_preinstalled_handler(sig);
+  }
+
+  return actp;
+}
+
+static bool call_chained_handler(struct sigaction *actp, int sig,
+                                 siginfo_t *siginfo, void *context) {
+  // Call the old signal handler
+  if (actp->sa_handler == SIG_DFL) {
+    // It's more reasonable to let jvm treat it as an unexpected exception
+    // instead of taking the default action.
+    return false;
+  } else if (actp->sa_handler != SIG_IGN) {
+    if ((actp->sa_flags & SA_NODEFER) == 0) {
+      // automaticlly block the signal
+      sigaddset(&(actp->sa_mask), sig);
+    }
+
+    sa_handler_t hand;
+    sa_sigaction_t sa;
+    bool siginfo_flag_set = (actp->sa_flags & SA_SIGINFO) != 0;
+    // retrieve the chained handler
+    if (siginfo_flag_set) {
+      sa = actp->sa_sigaction;
+    } else {
+      hand = actp->sa_handler;
+    }
+
+    if ((actp->sa_flags & SA_RESETHAND) != 0) {
+      actp->sa_handler = SIG_DFL;
+    }
+
+    // try to honor the signal mask
+    sigset_t oset;
+    pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset);
+
+    // call into the chained handler
+    if (siginfo_flag_set) {
+      (*sa)(sig, siginfo, context);
+    } else {
+      (*hand)(sig);
+    }
+
+    // restore the signal mask
+    pthread_sigmask(SIG_SETMASK, &oset, 0);
+  }
+  // Tell jvm's signal handler the signal is taken care of.
+  return true;
+}
+
+bool os::Bsd::chained_handler(int sig, siginfo_t* siginfo, void* context) {
+  bool chained = false;
+  // signal-chaining
+  if (UseSignalChaining) {
+    struct sigaction *actp = get_chained_signal_action(sig);
+    if (actp != NULL) {
+      chained = call_chained_handler(actp, sig, siginfo, context);
+    }
+  }
+  return chained;
+}
+
+struct sigaction* os::Bsd::get_preinstalled_handler(int sig) {
+  if ((( (unsigned int)1 << sig ) & sigs) != 0) {
+    return &sigact[sig];
+  }
+  return NULL;
+}
+
+void os::Bsd::save_preinstalled_handler(int sig, struct sigaction& oldAct) {
+  assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
+  sigact[sig] = oldAct;
+  sigs |= (unsigned int)1 << sig;
+}
+
+// for diagnostic
+int os::Bsd::sigflags[MAXSIGNUM];
+
+int os::Bsd::get_our_sigflags(int sig) {
+  assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
+  return sigflags[sig];
+}
+
+void os::Bsd::set_our_sigflags(int sig, int flags) {
+  assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
+  sigflags[sig] = flags;
+}
+
+void os::Bsd::set_signal_handler(int sig, bool set_installed) {
+  // Check for overwrite.
+  struct sigaction oldAct;
+  sigaction(sig, (struct sigaction*)NULL, &oldAct);
+
+  void* oldhand = oldAct.sa_sigaction
+                ? CAST_FROM_FN_PTR(void*,  oldAct.sa_sigaction)
+                : CAST_FROM_FN_PTR(void*,  oldAct.sa_handler);
+  if (oldhand != CAST_FROM_FN_PTR(void*, SIG_DFL) &&
+      oldhand != CAST_FROM_FN_PTR(void*, SIG_IGN) &&
+      oldhand != CAST_FROM_FN_PTR(void*, (sa_sigaction_t)signalHandler)) {
+    if (AllowUserSignalHandlers || !set_installed) {
+      // Do not overwrite; user takes responsibility to forward to us.
+      return;
+    } else if (UseSignalChaining) {
+      // save the old handler in jvm
+      save_preinstalled_handler(sig, oldAct);
+      // libjsig also interposes the sigaction() call below and saves the
+      // old sigaction on it own.
+    } else {
+      fatal(err_msg("Encountered unexpected pre-existing sigaction handler "
+                    "%#lx for signal %d.", (long)oldhand, sig));
+    }
+  }
+
+  struct sigaction sigAct;
+  sigfillset(&(sigAct.sa_mask));
+  sigAct.sa_handler = SIG_DFL;
+  if (!set_installed) {
+    sigAct.sa_flags = SA_SIGINFO|SA_RESTART;
+  } else {
+    sigAct.sa_sigaction = signalHandler;
+    sigAct.sa_flags = SA_SIGINFO|SA_RESTART;
+  }
+  // Save flags, which are set by ours
+  assert(sig > 0 && sig < MAXSIGNUM, "vm signal out of expected range");
+  sigflags[sig] = sigAct.sa_flags;
+
+  int ret = sigaction(sig, &sigAct, &oldAct);
+  assert(ret == 0, "check");
+
+  void* oldhand2  = oldAct.sa_sigaction
+                  ? CAST_FROM_FN_PTR(void*, oldAct.sa_sigaction)
+                  : CAST_FROM_FN_PTR(void*, oldAct.sa_handler);
+  assert(oldhand2 == oldhand, "no concurrent signal handler installation");
+}
+
+// install signal handlers for signals that HotSpot needs to
+// handle in order to support Java-level exception handling.
+
+void os::Bsd::install_signal_handlers() {
+  if (!signal_handlers_are_installed) {
+    signal_handlers_are_installed = true;
+
+    // signal-chaining
+    typedef void (*signal_setting_t)();
+    signal_setting_t begin_signal_setting = NULL;
+    signal_setting_t end_signal_setting = NULL;
+    begin_signal_setting = CAST_TO_FN_PTR(signal_setting_t,
+                             dlsym(RTLD_DEFAULT, "JVM_begin_signal_setting"));
+    if (begin_signal_setting != NULL) {
+      end_signal_setting = CAST_TO_FN_PTR(signal_setting_t,
+                             dlsym(RTLD_DEFAULT, "JVM_end_signal_setting"));
+      get_signal_action = CAST_TO_FN_PTR(get_signal_t,
+                            dlsym(RTLD_DEFAULT, "JVM_get_signal_action"));
+      libjsig_is_loaded = true;
+      assert(UseSignalChaining, "should enable signal-chaining");
+    }
+    if (libjsig_is_loaded) {
+      // Tell libjsig jvm is setting signal handlers
+      (*begin_signal_setting)();
+    }
+
+    set_signal_handler(SIGSEGV, true);
+    set_signal_handler(SIGPIPE, true);
+    set_signal_handler(SIGBUS, true);
+    set_signal_handler(SIGILL, true);
+    set_signal_handler(SIGFPE, true);
+    set_signal_handler(SIGXFSZ, true);
+
+#if defined(__APPLE__)
+    // In Mac OS X 10.4, CrashReporter will write a crash log for all 'fatal' signals, including
+    // signals caught and handled by the JVM. To work around this, we reset the mach task
+    // signal handler that's placed on our process by CrashReporter. This disables
+    // CrashReporter-based reporting.
+    //
+    // This work-around is not necessary for 10.5+, as CrashReporter no longer intercedes
+    // on caught fatal signals.
+    //
+    // Additionally, gdb installs both standard BSD signal handlers, and mach exception
+    // handlers. By replacing the existing task exception handler, we disable gdb's mach
+    // exception handling, while leaving the standard BSD signal handlers functional.
+    kern_return_t kr;
+    kr = task_set_exception_ports(mach_task_self(),
+        EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC,
+        MACH_PORT_NULL,
+        EXCEPTION_STATE_IDENTITY,
+        MACHINE_THREAD_STATE);
+
+    assert(kr == KERN_SUCCESS, "could not set mach task signal handler");
+#endif
+
+    if (libjsig_is_loaded) {
+      // Tell libjsig jvm finishes setting signal handlers
+      (*end_signal_setting)();
+    }
+
+    // We don't activate signal checker if libjsig is in place, we trust ourselves
+    // and if UserSignalHandler is installed all bets are off
+    if (CheckJNICalls) {
+      if (libjsig_is_loaded) {
+        tty->print_cr("Info: libjsig is activated, all active signal checking is disabled");
+        check_signals = false;
+      }
+      if (AllowUserSignalHandlers) {
+        tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
+        check_signals = false;
+      }
+    }
+  }
+}
+
+#ifndef _ALLBSD_SOURCE
+// This is the fastest way to get thread cpu time on Bsd.
+// Returns cpu time (user+sys) for any thread, not only for current.
+// POSIX compliant clocks are implemented in the kernels 2.6.16+.
+// It might work on 2.6.10+ with a special kernel/glibc patch.
+// For reference, please, see IEEE Std 1003.1-2004:
+//   http://www.unix.org/single_unix_specification
+
+jlong os::Bsd::fast_thread_cpu_time(clockid_t clockid) {
+  struct timespec tp;
+  int rc = os::Bsd::clock_gettime(clockid, &tp);
+  assert(rc == 0, "clock_gettime is expected to return 0 code");
+
+  return (tp.tv_sec * SEC_IN_NANOSECS) + tp.tv_nsec;
+}
+#endif
+
+/////
+// glibc on Bsd platform uses non-documented flag
+// to indicate, that some special sort of signal
+// trampoline is used.
+// We will never set this flag, and we should
+// ignore this flag in our diagnostic
+#ifdef SIGNIFICANT_SIGNAL_MASK
+#undef SIGNIFICANT_SIGNAL_MASK
+#endif
+#define SIGNIFICANT_SIGNAL_MASK (~0x04000000)
+
+static const char* get_signal_handler_name(address handler,
+                                           char* buf, int buflen) {
+  int offset;
+  bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset);
+  if (found) {
+    // skip directory names
+    const char *p1, *p2;
+    p1 = buf;
+    size_t len = strlen(os::file_separator());
+    while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len;
+    jio_snprintf(buf, buflen, "%s+0x%x", p1, offset);
+  } else {
+    jio_snprintf(buf, buflen, PTR_FORMAT, handler);
+  }
+  return buf;
+}
+
+static void print_signal_handler(outputStream* st, int sig,
+                                 char* buf, size_t buflen) {
+  struct sigaction sa;
+
+  sigaction(sig, NULL, &sa);
+
+  // See comment for SIGNIFICANT_SIGNAL_MASK define
+  sa.sa_flags &= SIGNIFICANT_SIGNAL_MASK;
+
+  st->print("%s: ", os::exception_name(sig, buf, buflen));
+
+  address handler = (sa.sa_flags & SA_SIGINFO)
+    ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
+    : CAST_FROM_FN_PTR(address, sa.sa_handler);
+
+  if (handler == CAST_FROM_FN_PTR(address, SIG_DFL)) {
+    st->print("SIG_DFL");
+  } else if (handler == CAST_FROM_FN_PTR(address, SIG_IGN)) {
+    st->print("SIG_IGN");
+  } else {
+    st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
+  }
+
+  st->print(", sa_mask[0]=" PTR32_FORMAT, *(uint32_t*)&sa.sa_mask);
+
+  address rh = VMError::get_resetted_sighandler(sig);
+  // May be, handler was resetted by VMError?
+  if(rh != NULL) {
+    handler = rh;
+    sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK;
+  }
+
+  st->print(", sa_flags="   PTR32_FORMAT, sa.sa_flags);
+
+  // Check: is it our handler?
+  if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) ||
+     handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) {
+    // It is our signal handler
+    // check for flags, reset system-used one!
+    if((int)sa.sa_flags != os::Bsd::get_our_sigflags(sig)) {
+      st->print(
+                ", flags was changed from " PTR32_FORMAT ", consider using jsig library",
+                os::Bsd::get_our_sigflags(sig));
+    }
+  }
+  st->cr();
+}
+
+
+#define DO_SIGNAL_CHECK(sig) \
+  if (!sigismember(&check_signal_done, sig)) \
+    os::Bsd::check_signal_handler(sig)
+
+// This method is a periodic task to check for misbehaving JNI applications
+// under CheckJNI, we can add any periodic checks here
+
+void os::run_periodic_checks() {
+
+  if (check_signals == false) return;
+
+  // SEGV and BUS if overridden could potentially prevent
+  // generation of hs*.log in the event of a crash, debugging
+  // such a case can be very challenging, so we absolutely
+  // check the following for a good measure:
+  DO_SIGNAL_CHECK(SIGSEGV);
+  DO_SIGNAL_CHECK(SIGILL);
+  DO_SIGNAL_CHECK(SIGFPE);
+  DO_SIGNAL_CHECK(SIGBUS);
+  DO_SIGNAL_CHECK(SIGPIPE);
+  DO_SIGNAL_CHECK(SIGXFSZ);
+
+
+  // ReduceSignalUsage allows the user to override these handlers
+  // see comments at the very top and jvm_solaris.h
+  if (!ReduceSignalUsage) {
+    DO_SIGNAL_CHECK(SHUTDOWN1_SIGNAL);
+    DO_SIGNAL_CHECK(SHUTDOWN2_SIGNAL);
+    DO_SIGNAL_CHECK(SHUTDOWN3_SIGNAL);
+    DO_SIGNAL_CHECK(BREAK_SIGNAL);
+  }
+
+  DO_SIGNAL_CHECK(SR_signum);
+  DO_SIGNAL_CHECK(INTERRUPT_SIGNAL);
+}
+
+typedef int (*os_sigaction_t)(int, const struct sigaction *, struct sigaction *);
+
+static os_sigaction_t os_sigaction = NULL;
+
+void os::Bsd::check_signal_handler(int sig) {
+  char buf[O_BUFLEN];
+  address jvmHandler = NULL;
+
+
+  struct sigaction act;
+  if (os_sigaction == NULL) {
+    // only trust the default sigaction, in case it has been interposed
+    os_sigaction = (os_sigaction_t)dlsym(RTLD_DEFAULT, "sigaction");
+    if (os_sigaction == NULL) return;
+  }
+
+  os_sigaction(sig, (struct sigaction*)NULL, &act);
+
+
+  act.sa_flags &= SIGNIFICANT_SIGNAL_MASK;
+
+  address thisHandler = (act.sa_flags & SA_SIGINFO)
+    ? CAST_FROM_FN_PTR(address, act.sa_sigaction)
+    : CAST_FROM_FN_PTR(address, act.sa_handler) ;
+
+
+  switch(sig) {
+  case SIGSEGV:
+  case SIGBUS:
+  case SIGFPE:
+  case SIGPIPE:
+  case SIGILL:
+  case SIGXFSZ:
+    jvmHandler = CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler);
+    break;
+
+  case SHUTDOWN1_SIGNAL:
+  case SHUTDOWN2_SIGNAL:
+  case SHUTDOWN3_SIGNAL:
+  case BREAK_SIGNAL:
+    jvmHandler = (address)user_handler();
+    break;
+
+  case INTERRUPT_SIGNAL:
+    jvmHandler = CAST_FROM_FN_PTR(address, SIG_DFL);
+    break;
+
+  default:
+    if (sig == SR_signum) {
+      jvmHandler = CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler);
+    } else {
+      return;
+    }
+    break;
+  }
+
+  if (thisHandler != jvmHandler) {
+    tty->print("Warning: %s handler ", exception_name(sig, buf, O_BUFLEN));
+    tty->print("expected:%s", get_signal_handler_name(jvmHandler, buf, O_BUFLEN));
+    tty->print_cr("  found:%s", get_signal_handler_name(thisHandler, buf, O_BUFLEN));
+    // No need to check this sig any longer
+    sigaddset(&check_signal_done, sig);
+  } else if(os::Bsd::get_our_sigflags(sig) != 0 && (int)act.sa_flags != os::Bsd::get_our_sigflags(sig)) {
+    tty->print("Warning: %s handler flags ", exception_name(sig, buf, O_BUFLEN));
+    tty->print("expected:" PTR32_FORMAT, os::Bsd::get_our_sigflags(sig));
+    tty->print_cr("  found:" PTR32_FORMAT, act.sa_flags);
+    // No need to check this sig any longer
+    sigaddset(&check_signal_done, sig);
+  }
+
+  // Dump all the signal
+  if (sigismember(&check_signal_done, sig)) {
+    print_signal_handlers(tty, buf, O_BUFLEN);
+  }
+}
+
+extern void report_error(char* file_name, int line_no, char* title, char* format, ...);
+
+extern bool signal_name(int signo, char* buf, size_t len);
+
+const char* os::exception_name(int exception_code, char* buf, size_t size) {
+  if (0 < exception_code && exception_code <= SIGRTMAX) {
+    // signal
+    if (!signal_name(exception_code, buf, size)) {
+      jio_snprintf(buf, size, "SIG%d", exception_code);
+    }
+    return buf;
+  } else {
+    return NULL;
+  }
+}
+
+// this is called _before_ the most of global arguments have been parsed
+void os::init(void) {
+  char dummy;   /* used to get a guess on initial stack address */
+//  first_hrtime = gethrtime();
+
+  // With BsdThreads the JavaMain thread pid (primordial thread)
+  // is different than the pid of the java launcher thread.
+  // So, on Bsd, the launcher thread pid is passed to the VM
+  // via the sun.java.launcher.pid property.
+  // Use this property instead of getpid() if it was correctly passed.
+  // See bug 6351349.
+  pid_t java_launcher_pid = (pid_t) Arguments::sun_java_launcher_pid();
+
+  _initial_pid = (java_launcher_pid > 0) ? java_launcher_pid : getpid();
+
+  clock_tics_per_sec = CLK_TCK;
+
+  init_random(1234567);
+
+  ThreadCritical::initialize();
+
+  Bsd::set_page_size(getpagesize());
+  if (Bsd::page_size() == -1) {
+    fatal(err_msg("os_bsd.cpp: os::init: sysconf failed (%s)",
+                  strerror(errno)));
+  }
+  init_page_sizes((size_t) Bsd::page_size());
+
+  Bsd::initialize_system_info();
+
+  // main_thread points to the aboriginal thread
+  Bsd::_main_thread = pthread_self();
+
+  Bsd::clock_init();
+  initial_time_count = os::elapsed_counter();
+
+#ifdef __APPLE__
+  // XXXDARWIN
+  // Work around the unaligned VM callbacks in hotspot's
+  // sharedRuntime. The callbacks don't use SSE2 instructions, and work on
+  // Linux, Solaris, and FreeBSD. On Mac OS X, dyld (rightly so) enforces
+  // alignment when doing symbol lookup. To work around this, we force early
+  // binding of all symbols now, thus binding when alignment is known-good.
+  _dyld_bind_fully_image_containing_address((const void *) &os::init);
+#endif
+}
+
+// To install functions for atexit system call
+extern "C" {
+  static void perfMemory_exit_helper() {
+    perfMemory_exit();
+  }
+}
+
+// this is called _after_ the global arguments have been parsed
+jint os::init_2(void)
+{
+#ifndef _ALLBSD_SOURCE
+  Bsd::fast_thread_clock_init();
+#endif
+
+  // Allocate a single page and mark it as readable for safepoint polling
+  address polling_page = (address) ::mmap(NULL, Bsd::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+  guarantee( polling_page != MAP_FAILED, "os::init_2: failed to allocate polling page" );
+
+  os::set_polling_page( polling_page );
+
+#ifndef PRODUCT
+  if(Verbose && PrintMiscellaneous)
+    tty->print("[SafePoint Polling address: " INTPTR_FORMAT "]\n", (intptr_t)polling_page);
+#endif
+
+  if (!UseMembar) {
+    address mem_serialize_page = (address) ::mmap(NULL, Bsd::page_size(), PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+    guarantee( mem_serialize_page != NULL, "mmap Failed for memory serialize page");
+    os::set_memory_serialize_page( mem_serialize_page );
+
+#ifndef PRODUCT
+    if(Verbose && PrintMiscellaneous)
+      tty->print("[Memory Serialize  Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page);
+#endif
+  }
+
+  os::large_page_init();
+
+  // initialize suspend/resume support - must do this before signal_sets_init()
+  if (SR_initialize() != 0) {
+    perror("SR_initialize failed");
+    return JNI_ERR;
+  }
+
+  Bsd::signal_sets_init();
+  Bsd::install_signal_handlers();
+
+  // Check minimum allowable stack size for thread creation and to initialize
+  // the java system classes, including StackOverflowError - depends on page
+  // size.  Add a page for compiler2 recursion in main thread.
+  // Add in 2*BytesPerWord times page size to account for VM stack during
+  // class initialization depending on 32 or 64 bit VM.
+  os::Bsd::min_stack_allowed = MAX2(os::Bsd::min_stack_allowed,
+            (size_t)(StackYellowPages+StackRedPages+StackShadowPages+
+                    2*BytesPerWord COMPILER2_PRESENT(+1)) * Bsd::page_size());
+
+  size_t threadStackSizeInBytes = ThreadStackSize * K;
+  if (threadStackSizeInBytes != 0 &&
+      threadStackSizeInBytes < os::Bsd::min_stack_allowed) {
+        tty->print_cr("\nThe stack size specified is too small, "
+                      "Specify at least %dk",
+                      os::Bsd::min_stack_allowed/ K);
+        return JNI_ERR;
+  }
+
+  // Make the stack size a multiple of the page size so that
+  // the yellow/red zones can be guarded.
+  JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes,
+        vm_page_size()));
+
+#ifndef _ALLBSD_SOURCE
+  Bsd::capture_initial_stack(JavaThread::stack_size_at_create());
+
+  Bsd::libpthread_init();
+  if (PrintMiscellaneous && (Verbose || WizardMode)) {
+     tty->print_cr("[HotSpot is running with %s, %s(%s)]\n",
+          Bsd::glibc_version(), Bsd::libpthread_version(),
+          Bsd::is_floating_stack() ? "floating stack" : "fixed stack");
+  }
+
+  if (UseNUMA) {
+    if (!Bsd::libnuma_init()) {
+      UseNUMA = false;
+    } else {
+      if ((Bsd::numa_max_node() < 1)) {
+        // There's only one node(they start from 0), disable NUMA.
+        UseNUMA = false;
+      }
+    }
+    // With SHM large pages we cannot uncommit a page, so there's not way
+    // we can make the adaptive lgrp chunk resizing work. If the user specified
+    // both UseNUMA and UseLargePages (or UseSHM) on the command line - warn and
+    // disable adaptive resizing.
+    if (UseNUMA && UseLargePages && UseSHM) {
+      if (!FLAG_IS_DEFAULT(UseNUMA)) {
+        if (FLAG_IS_DEFAULT(UseLargePages) && FLAG_IS_DEFAULT(UseSHM)) {
+          UseLargePages = false;
+        } else {
+          warning("UseNUMA is not fully compatible with SHM large pages, disabling adaptive resizing");
+          UseAdaptiveSizePolicy = false;
+          UseAdaptiveNUMAChunkSizing = false;
+        }
+      } else {
+        UseNUMA = false;
+      }
+    }
+    if (!UseNUMA && ForceNUMA) {
+      UseNUMA = true;
+    }
+  }
+#endif
+
+  if (MaxFDLimit) {
+    // set the number of file descriptors to max. print out error
+    // if getrlimit/setrlimit fails but continue regardless.
+    struct rlimit nbr_files;
+    int status = getrlimit(RLIMIT_NOFILE, &nbr_files);
+    if (status != 0) {
+      if (PrintMiscellaneous && (Verbose || WizardMode))
+        perror("os::init_2 getrlimit failed");
+    } else {
+      nbr_files.rlim_cur = nbr_files.rlim_max;
+
+#ifdef __APPLE__
+      // Darwin returns RLIM_INFINITY for rlim_max, but fails with EINVAL if
+      // you attempt to use RLIM_INFINITY. As per setrlimit(2), OPEN_MAX must
+      // be used instead
+      nbr_files.rlim_cur = MIN(OPEN_MAX, nbr_files.rlim_cur);
+#endif
+
+      status = setrlimit(RLIMIT_NOFILE, &nbr_files);
+      if (status != 0) {
+        if (PrintMiscellaneous && (Verbose || WizardMode))
+          perror("os::init_2 setrlimit failed");
+      }
+    }
+  }
+
+#ifndef _ALLBSD_SOURCE
+  // Initialize lock used to serialize thread creation (see os::create_thread)
+  Bsd::set_createThread_lock(new Mutex(Mutex::leaf, "createThread_lock", false));
+#endif
+
+  // at-exit methods are called in the reverse order of their registration.
+  // atexit functions are called on return from main or as a result of a
+  // call to exit(3C). There can be only 32 of these functions registered
+  // and atexit() does not set errno.
+
+  if (PerfAllowAtExitRegistration) {
+    // only register atexit functions if PerfAllowAtExitRegistration is set.
+    // atexit functions can be delayed until process exit time, which
+    // can be problematic for embedded VM situations. Embedded VMs should
+    // call DestroyJavaVM() to assure that VM resources are released.
+
+    // note: perfMemory_exit_helper atexit function may be removed in
+    // the future if the appropriate cleanup code can be added to the
+    // VM_Exit VMOperation's doit method.
+    if (atexit(perfMemory_exit_helper) != 0) {
+      warning("os::init2 atexit(perfMemory_exit_helper) failed");
+    }
+  }
+
+  // initialize thread priority policy
+  prio_init();
+
+#ifdef __APPLE__
+  // dynamically link to objective c gc registration
+  void *handleLibObjc = dlopen(OBJC_LIB, RTLD_LAZY);
+  if (handleLibObjc != NULL) {
+    objc_registerThreadWithCollectorFunction = (objc_registerThreadWithCollector_t) dlsym(handleLibObjc, OBJC_GCREGISTER);
+  }
+#endif
+
+  return JNI_OK;
+}
+
+// this is called at the end of vm_initialization
+void os::init_3(void) { }
+
+// Mark the polling page as unreadable
+void os::make_polling_page_unreadable(void) {
+  if( !guard_memory((char*)_polling_page, Bsd::page_size()) )
+    fatal("Could not disable polling page");
+};
+
+// Mark the polling page as readable
+void os::make_polling_page_readable(void) {
+  if( !bsd_mprotect((char *)_polling_page, Bsd::page_size(), PROT_READ)) {
+    fatal("Could not enable polling page");
+  }
+};
+
+int os::active_processor_count() {
+#ifdef _ALLBSD_SOURCE
+  return _processor_count;
+#else
+  // Bsd doesn't yet have a (official) notion of processor sets,
+  // so just return the number of online processors.
+  int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
+  assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
+  return online_cpus;
+#endif
+}
+
+void os::set_native_thread_name(const char *name) {
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
+  // This is only supported in Snow Leopard and beyond
+  if (name != NULL) {
+    // Add a "Java: " prefix to the name
+    char buf[MAXTHREADNAMESIZE];
+    snprintf(buf, sizeof(buf), "Java: %s", name);
+    pthread_setname_np(buf);
+  }
+#endif
+}
+
+bool os::distribute_processes(uint length, uint* distribution) {
+  // Not yet implemented.
+  return false;
+}
+
+bool os::bind_to_processor(uint processor_id) {
+  // Not yet implemented.
+  return false;
+}
+
+///
+
+// Suspends the target using the signal mechanism and then grabs the PC before
+// resuming the target. Used by the flat-profiler only
+ExtendedPC os::get_thread_pc(Thread* thread) {
+  // Make sure that it is called by the watcher for the VMThread
+  assert(Thread::current()->is_Watcher_thread(), "Must be watcher");
+  assert(thread->is_VM_thread(), "Can only be called for VMThread");
+
+  ExtendedPC epc;
+
+  OSThread* osthread = thread->osthread();
+  if (do_suspend(osthread)) {
+    if (osthread->ucontext() != NULL) {
+      epc = os::Bsd::ucontext_get_pc(osthread->ucontext());
+    } else {
+      // NULL context is unexpected, double-check this is the VMThread
+      guarantee(thread->is_VM_thread(), "can only be called for VMThread");
+    }
+    do_resume(osthread);
+  }
+  // failure means pthread_kill failed for some reason - arguably this is
+  // a fatal problem, but such problems are ignored elsewhere
+
+  return epc;
+}
+
+int os::Bsd::safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime)
+{
+#ifdef _ALLBSD_SOURCE
+  return pthread_cond_timedwait(_cond, _mutex, _abstime);
+#else
+   if (is_NPTL()) {
+      return pthread_cond_timedwait(_cond, _mutex, _abstime);
+   } else {
+#ifndef IA64
+      // 6292965: BsdThreads pthread_cond_timedwait() resets FPU control
+      // word back to default 64bit precision if condvar is signaled. Java
+      // wants 53bit precision.  Save and restore current value.
+      int fpu = get_fpu_control_word();
+#endif // IA64
+      int status = pthread_cond_timedwait(_cond, _mutex, _abstime);
+#ifndef IA64
+      set_fpu_control_word(fpu);
+#endif // IA64
+      return status;
+   }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// debug support
+
+static address same_page(address x, address y) {
+  int page_bits = -os::vm_page_size();
+  if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits))
+    return x;
+  else if (x > y)
+    return (address)(intptr_t(y) | ~page_bits) + 1;
+  else
+    return (address)(intptr_t(y) & page_bits);
+}
+
+bool os::find(address addr, outputStream* st) {
+  Dl_info dlinfo;
+  memset(&dlinfo, 0, sizeof(dlinfo));
+  if (dladdr(addr, &dlinfo)) {
+    st->print(PTR_FORMAT ": ", addr);
+    if (dlinfo.dli_sname != NULL) {
+      st->print("%s+%#x", dlinfo.dli_sname,
+                 addr - (intptr_t)dlinfo.dli_saddr);
+    } else if (dlinfo.dli_fname) {
+      st->print("<offset %#x>", addr - (intptr_t)dlinfo.dli_fbase);
+    } else {
+      st->print("<absolute address>");
+    }
+    if (dlinfo.dli_fname) {
+      st->print(" in %s", dlinfo.dli_fname);
+    }
+    if (dlinfo.dli_fbase) {
+      st->print(" at " PTR_FORMAT, dlinfo.dli_fbase);
+    }
+    st->cr();
+
+    if (Verbose) {
+      // decode some bytes around the PC
+      address begin = same_page(addr-40, addr);
+      address end   = same_page(addr+40, addr);
+      address       lowest = (address) dlinfo.dli_sname;
+      if (!lowest)  lowest = (address) dlinfo.dli_fbase;
+      if (begin < lowest)  begin = lowest;
+      Dl_info dlinfo2;
+      if (dladdr(end, &dlinfo2) && dlinfo2.dli_saddr != dlinfo.dli_saddr
+          && end > dlinfo2.dli_saddr && dlinfo2.dli_saddr > begin)
+        end = (address) dlinfo2.dli_saddr;
+      Disassembler::decode(begin, end, st);
+    }
+    return true;
+  }
+  return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// misc
+
+// This does not do anything on Bsd. This is basically a hook for being
+// able to use structured exception handling (thread-local exception filters)
+// on, e.g., Win32.
+void
+os::os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method,
+                         JavaCallArguments* args, Thread* thread) {
+  f(value, method, args, thread);
+}
+
+void os::print_statistics() {
+}
+
+int os::message_box(const char* title, const char* message) {
+  int i;
+  fdStream err(defaultStream::error_fd());
+  for (i = 0; i < 78; i++) err.print_raw("=");
+  err.cr();
+  err.print_raw_cr(title);
+  for (i = 0; i < 78; i++) err.print_raw("-");
+  err.cr();
+  err.print_raw_cr(message);
+  for (i = 0; i < 78; i++) err.print_raw("=");
+  err.cr();
+
+  char buf[16];
+  // Prevent process from exiting upon "read error" without consuming all CPU
+  while (::read(0, buf, sizeof(buf)) <= 0) { ::sleep(100); }
+
+  return buf[0] == 'y' || buf[0] == 'Y';
+}
+
+int os::stat(const char *path, struct stat *sbuf) {
+  char pathbuf[MAX_PATH];
+  if (strlen(path) > MAX_PATH - 1) {
+    errno = ENAMETOOLONG;
+    return -1;
+  }
+  os::native_path(strcpy(pathbuf, path));
+  return ::stat(pathbuf, sbuf);
+}
+
+bool os::check_heap(bool force) {
+  return true;
+}
+
+int local_vsnprintf(char* buf, size_t count, const char* format, va_list args) {
+  return ::vsnprintf(buf, count, format, args);
+}
+
+// Is a (classpath) directory empty?
+bool os::dir_is_empty(const char* path) {
+  DIR *dir = NULL;
+  struct dirent *ptr;
+
+  dir = opendir(path);
+  if (dir == NULL) return true;
+
+  /* Scan the directory */
+  bool result = true;
+  char buf[sizeof(struct dirent) + MAX_PATH];
+  while (result && (ptr = ::readdir(dir)) != NULL) {
+    if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
+      result = false;
+    }
+  }
+  closedir(dir);
+  return result;
+}
+
+// This code originates from JDK's sysOpen and open64_w
+// from src/solaris/hpi/src/system_md.c
+
+#ifndef O_DELETE
+#define O_DELETE 0x10000
+#endif
+
+// Open a file. Unlink the file immediately after open returns
+// if the specified oflag has the O_DELETE flag set.
+// O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
+
+int os::open(const char *path, int oflag, int mode) {
+
+  if (strlen(path) > MAX_PATH - 1) {
+    errno = ENAMETOOLONG;
+    return -1;
+  }
+  int fd;
+  int o_delete = (oflag & O_DELETE);
+  oflag = oflag & ~O_DELETE;
+
+  fd = ::open(path, oflag, mode);
+  if (fd == -1) return -1;
+
+  //If the open succeeded, the file might still be a directory
+  {
+    struct stat buf;
+    int ret = ::fstat(fd, &buf);
+    int st_mode = buf.st_mode;
+
+    if (ret != -1) {
+      if ((st_mode & S_IFMT) == S_IFDIR) {
+        errno = EISDIR;
+        ::close(fd);
+        return -1;
+      }
+    } else {
+      ::close(fd);
+      return -1;
+    }
+  }
+
+    /*
+     * All file descriptors that are opened in the JVM and not
+     * specifically destined for a subprocess should have the
+     * close-on-exec flag set.  If we don't set it, then careless 3rd
+     * party native code might fork and exec without closing all
+     * appropriate file descriptors (e.g. as we do in closeDescriptors in
+     * UNIXProcess.c), and this in turn might:
+     *
+     * - cause end-of-file to fail to be detected on some file
+     *   descriptors, resulting in mysterious hangs, or
+     *
+     * - might cause an fopen in the subprocess to fail on a system
+     *   suffering from bug 1085341.
+     *
+     * (Yes, the default setting of the close-on-exec flag is a Unix
+     * design flaw)
+     *
+     * See:
+     * 1085341: 32-bit stdio routines should support file descriptors >255
+     * 4843136: (process) pipe file descriptor from Runtime.exec not being closed
+     * 6339493: (process) Runtime.exec does not close all file descriptors on Solaris 9
+     */
+#ifdef FD_CLOEXEC
+    {
+        int flags = ::fcntl(fd, F_GETFD);
+        if (flags != -1)
+            ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+    }
+#endif
+
+  if (o_delete != 0) {
+    ::unlink(path);
+  }
+  return fd;
+}
+
+
+// create binary file, rewriting existing file if required
+int os::create_binary_file(const char* path, bool rewrite_existing) {
+  int oflags = O_WRONLY | O_CREAT;
+  if (!rewrite_existing) {
+    oflags |= O_EXCL;
+  }
+  return ::open(path, oflags, S_IREAD | S_IWRITE);
+}
+
+// return current position of file pointer
+jlong os::current_file_offset(int fd) {
+  return (jlong)::lseek(fd, (off_t)0, SEEK_CUR);
+}
+
+// move file pointer to the specified offset
+jlong os::seek_to_file_offset(int fd, jlong offset) {
+  return (jlong)::lseek(fd, (off_t)offset, SEEK_SET);
+}
+
+// This code originates from JDK's sysAvailable
+// from src/solaris/hpi/src/native_threads/src/sys_api_td.c
+
+int os::available(int fd, jlong *bytes) {
+  jlong cur, end;
+  int mode;
+  struct stat buf;
+
+  if (::fstat(fd, &buf) >= 0) {
+    mode = buf.st_mode;
+    if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
+      /*
+      * XXX: is the following call interruptible? If so, this might
+      * need to go through the INTERRUPT_IO() wrapper as for other
+      * blocking, interruptible calls in this file.
+      */
+      int n;
+      if (::ioctl(fd, FIONREAD, &n) >= 0) {
+        *bytes = n;
+        return 1;
+      }
+    }
+  }
+  if ((cur = ::lseek(fd, 0L, SEEK_CUR)) == -1) {
+    return 0;
+  } else if ((end = ::lseek(fd, 0L, SEEK_END)) == -1) {
+    return 0;
+  } else if (::lseek(fd, cur, SEEK_SET) == -1) {
+    return 0;
+  }
+  *bytes = end - cur;
+  return 1;
+}
+
+int os::socket_available(int fd, jint *pbytes) {
+   if (fd < 0)
+     return OS_OK;
+
+   int ret;
+
+   RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret);
+
+   //%% note ioctl can return 0 when successful, JVM_SocketAvailable
+   // is expected to return 0 on failure and 1 on success to the jdk.
+
+   return (ret == OS_ERR) ? 0 : 1;
+}
+
+// Map a block of memory.
+char* os::map_memory(int fd, const char* file_name, size_t file_offset,
+                     char *addr, size_t bytes, bool read_only,
+                     bool allow_exec) {
+  int prot;
+  int flags;
+
+  if (read_only) {
+    prot = PROT_READ;
+    flags = MAP_SHARED;
+  } else {
+    prot = PROT_READ | PROT_WRITE;
+    flags = MAP_PRIVATE;
+  }
+
+  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;
+}
+
+
+// Remap a block of memory.
+char* os::remap_memory(int fd, const char* file_name, size_t file_offset,
+                       char *addr, size_t bytes, bool read_only,
+                       bool allow_exec) {
+  // same as map_memory() on this OS
+  return os::map_memory(fd, file_name, file_offset, addr, bytes, read_only,
+                        allow_exec);
+}
+
+
+// Unmap a block of memory.
+bool os::unmap_memory(char* addr, size_t bytes) {
+  return munmap(addr, bytes) == 0;
+}
+
+#ifndef _ALLBSD_SOURCE
+static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time);
+
+static clockid_t thread_cpu_clockid(Thread* thread) {
+  pthread_t tid = thread->osthread()->pthread_id();
+  clockid_t clockid;
+
+  // Get thread clockid
+  int rc = os::Bsd::pthread_getcpuclockid(tid, &clockid);
+  assert(rc == 0, "pthread_getcpuclockid is expected to return 0 code");
+  return clockid;
+}
+#endif
+
+// current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool)
+// are used by JVM M&M and JVMTI to get user+sys or user CPU time
+// of a thread.
+//
+// current_thread_cpu_time() and thread_cpu_time(Thread*) returns
+// the fast estimate available on the platform.
+
+jlong os::current_thread_cpu_time() {
+#ifdef __APPLE__
+  return os::thread_cpu_time(Thread::current(), true /* user + sys */);
+#elif !defined(_ALLBSD_SOURCE)
+  if (os::Bsd::supports_fast_thread_cpu_time()) {
+    return os::Bsd::fast_thread_cpu_time(CLOCK_THREAD_CPUTIME_ID);
+  } else {
+    // return user + sys since the cost is the same
+    return slow_thread_cpu_time(Thread::current(), true /* user + sys */);
+  }
+#endif
+}
+
+jlong os::thread_cpu_time(Thread* thread) {
+#ifndef _ALLBSD_SOURCE
+  // consistent with what current_thread_cpu_time() returns
+  if (os::Bsd::supports_fast_thread_cpu_time()) {
+    return os::Bsd::fast_thread_cpu_time(thread_cpu_clockid(thread));
+  } else {
+    return slow_thread_cpu_time(thread, true /* user + sys */);
+  }
+#endif
+}
+
+jlong os::current_thread_cpu_time(bool user_sys_cpu_time) {
+#ifdef __APPLE__
+  return os::thread_cpu_time(Thread::current(), user_sys_cpu_time);
+#elif !defined(_ALLBSD_SOURCE)
+  if (user_sys_cpu_time && os::Bsd::supports_fast_thread_cpu_time()) {
+    return os::Bsd::fast_thread_cpu_time(CLOCK_THREAD_CPUTIME_ID);
+  } else {
+    return slow_thread_cpu_time(Thread::current(), user_sys_cpu_time);
+  }
+#endif
+}
+
+jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
+#ifdef __APPLE__
+  struct thread_basic_info tinfo;
+  mach_msg_type_number_t tcount = THREAD_INFO_MAX;
+  kern_return_t kr;
+  mach_port_t mach_thread;
+
+  mach_thread = pthread_mach_thread_np(thread->osthread()->thread_id());
+  kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
+  if (kr != KERN_SUCCESS)
+    return -1;
+
+  if (user_sys_cpu_time) {
+    jlong nanos;
+    nanos = ((jlong) tinfo.system_time.seconds + tinfo.user_time.seconds) * (jlong)1000000000;
+    nanos += ((jlong) tinfo.system_time.microseconds + (jlong) tinfo.user_time.microseconds) * (jlong)1000;
+    return nanos;
+  } else {
+    return ((jlong)tinfo.user_time.seconds * 1000000000) + ((jlong)tinfo.user_time.microseconds * (jlong)1000);
+  }
+#elif !defined(_ALLBSD_SOURCE)
+  if (user_sys_cpu_time && os::Bsd::supports_fast_thread_cpu_time()) {
+    return os::Bsd::fast_thread_cpu_time(thread_cpu_clockid(thread));
+  } else {
+    return slow_thread_cpu_time(thread, user_sys_cpu_time);
+  }
+#endif
+}
+
+#ifndef _ALLBSD_SOURCE
+//
+//  -1 on error.
+//
+
+static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
+  static bool proc_pid_cpu_avail = true;
+  static bool proc_task_unchecked = true;
+  static const char *proc_stat_path = "/proc/%d/stat";
+  pid_t  tid = thread->osthread()->thread_id();
+  int i;
+  char *s;
+  char stat[2048];
+  int statlen;
+  char proc_name[64];
+  int count;
+  long sys_time, user_time;
+  char string[64];
+  char cdummy;
+  int idummy;
+  long ldummy;
+  FILE *fp;
+
+  // We first try accessing /proc/<pid>/cpu since this is faster to
+  // process.  If this file is not present (bsd kernels 2.5 and above)
+  // then we open /proc/<pid>/stat.
+  if ( proc_pid_cpu_avail ) {
+    sprintf(proc_name, "/proc/%d/cpu", tid);
+    fp =  fopen(proc_name, "r");
+    if ( fp != NULL ) {
+      count = fscanf( fp, "%s %lu %lu\n", string, &user_time, &sys_time);
+      fclose(fp);
+      if ( count != 3 ) return -1;
+
+      if (user_sys_cpu_time) {
+        return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec);
+      } else {
+        return (jlong)user_time * (1000000000 / clock_tics_per_sec);
+      }
+    }
+    else proc_pid_cpu_avail = false;
+  }
+
+  // The /proc/<tid>/stat aggregates per-process usage on
+  // new Bsd kernels 2.6+ where NPTL is supported.
+  // The /proc/self/task/<tid>/stat still has the per-thread usage.
+  // See bug 6328462.
+  // There can be no directory /proc/self/task on kernels 2.4 with NPTL
+  // and possibly in some other cases, so we check its availability.
+  if (proc_task_unchecked && os::Bsd::is_NPTL()) {
+    // This is executed only once
+    proc_task_unchecked = false;
+    fp = fopen("/proc/self/task", "r");
+    if (fp != NULL) {
+      proc_stat_path = "/proc/self/task/%d/stat";
+      fclose(fp);
+    }
+  }
+
+  sprintf(proc_name, proc_stat_path, tid);
+  fp = fopen(proc_name, "r");
+  if ( fp == NULL ) return -1;
+  statlen = fread(stat, 1, 2047, fp);
+  stat[statlen] = '\0';
+  fclose(fp);
+
+  // Skip pid and the command string. Note that we could be dealing with
+  // weird command names, e.g. user could decide to rename java launcher
+  // to "java 1.4.2 :)", then the stat file would look like
+  //                1234 (java 1.4.2 :)) R ... ...
+  // We don't really need to know the command string, just find the last
+  // occurrence of ")" and then start parsing from there. See bug 4726580.
+  s = strrchr(stat, ')');
+  i = 0;
+  if (s == NULL ) return -1;
+
+  // Skip blank chars
+  do s++; while (isspace(*s));
+
+  count = sscanf(s,"%c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu",
+                 &cdummy, &idummy, &idummy, &idummy, &idummy, &idummy,
+                 &ldummy, &ldummy, &ldummy, &ldummy, &ldummy,
+                 &user_time, &sys_time);
+  if ( count != 13 ) return -1;
+  if (user_sys_cpu_time) {
+    return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec);
+  } else {
+    return (jlong)user_time * (1000000000 / clock_tics_per_sec);
+  }
+}
+#endif
+
+void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) {
+  info_ptr->max_value = ALL_64_BITS;       // will not wrap in less than 64 bits
+  info_ptr->may_skip_backward = false;     // elapsed time not wall time
+  info_ptr->may_skip_forward = false;      // elapsed time not wall time
+  info_ptr->kind = JVMTI_TIMER_TOTAL_CPU;  // user+system time is returned
+}
+
+void os::thread_cpu_time_info(jvmtiTimerInfo *info_ptr) {
+  info_ptr->max_value = ALL_64_BITS;       // will not wrap in less than 64 bits
+  info_ptr->may_skip_backward = false;     // elapsed time not wall time
+  info_ptr->may_skip_forward = false;      // elapsed time not wall time
+  info_ptr->kind = JVMTI_TIMER_TOTAL_CPU;  // user+system time is returned
+}
+
+bool os::is_thread_cpu_time_supported() {
+#ifdef __APPLE__
+  return true;
+#elif defined(_ALLBSD_SOURCE)
+  return false;
+#else
+  return true;
+#endif
+}
+
+// System loadavg support.  Returns -1 if load average cannot be obtained.
+// Bsd doesn't yet have a (official) notion of processor sets,
+// so just return the system wide load average.
+int os::loadavg(double loadavg[], int nelem) {
+  return ::getloadavg(loadavg, nelem);
+}
+
+void os::pause() {
+  char filename[MAX_PATH];
+  if (PauseAtStartupFile && PauseAtStartupFile[0]) {
+    jio_snprintf(filename, MAX_PATH, PauseAtStartupFile);
+  } else {
+    jio_snprintf(filename, MAX_PATH, "./vm.paused.%d", current_process_id());
+  }
+
+  int fd = ::open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+  if (fd != -1) {
+    struct stat buf;
+    ::close(fd);
+    while (::stat(filename, &buf) == 0) {
+      (void)::poll(NULL, 0, 100);
+    }
+  } else {
+    jio_fprintf(stderr,
+      "Could not open pause file '%s', continuing immediately.\n", filename);
+  }
+}
+
+
+// Refer to the comments in os_solaris.cpp park-unpark.
+//
+// Beware -- Some versions of NPTL embody a flaw where pthread_cond_timedwait() can
+// hang indefinitely.  For instance NPTL 0.60 on 2.4.21-4ELsmp is vulnerable.
+// For specifics regarding the bug see GLIBC BUGID 261237 :
+//    http://www.mail-archive.com/debian-glibc@lists.debian.org/msg10837.html.
+// Briefly, pthread_cond_timedwait() calls with an expiry time that's not in the future
+// will either hang or corrupt the condvar, resulting in subsequent hangs if the condvar
+// is used.  (The simple C test-case provided in the GLIBC bug report manifests the
+// hang).  The JVM is vulernable via sleep(), Object.wait(timo), LockSupport.parkNanos()
+// and monitorenter when we're using 1-0 locking.  All those operations may result in
+// calls to pthread_cond_timedwait().  Using LD_ASSUME_KERNEL to use an older version
+// of libpthread avoids the problem, but isn't practical.
+//
+// Possible remedies:
+//
+// 1.   Establish a minimum relative wait time.  50 to 100 msecs seems to work.
+//      This is palliative and probabilistic, however.  If the thread is preempted
+//      between the call to compute_abstime() and pthread_cond_timedwait(), more
+//      than the minimum period may have passed, and the abstime may be stale (in the
+//      past) resultin in a hang.   Using this technique reduces the odds of a hang
+//      but the JVM is still vulnerable, particularly on heavily loaded systems.
+//
+// 2.   Modify park-unpark to use per-thread (per ParkEvent) pipe-pairs instead
+//      of the usual flag-condvar-mutex idiom.  The write side of the pipe is set
+//      NDELAY. unpark() reduces to write(), park() reduces to read() and park(timo)
+//      reduces to poll()+read().  This works well, but consumes 2 FDs per extant
+//      thread.
+//
+// 3.   Embargo pthread_cond_timedwait() and implement a native "chron" thread
+//      that manages timeouts.  We'd emulate pthread_cond_timedwait() by enqueuing
+//      a timeout request to the chron thread and then blocking via pthread_cond_wait().
+//      This also works well.  In fact it avoids kernel-level scalability impediments
+//      on certain platforms that don't handle lots of active pthread_cond_timedwait()
+//      timers in a graceful fashion.
+//
+// 4.   When the abstime value is in the past it appears that control returns
+//      correctly from pthread_cond_timedwait(), but the condvar is left corrupt.
+//      Subsequent timedwait/wait calls may hang indefinitely.  Given that, we
+//      can avoid the problem by reinitializing the condvar -- by cond_destroy()
+//      followed by cond_init() -- after all calls to pthread_cond_timedwait().
+//      It may be possible to avoid reinitialization by checking the return
+//      value from pthread_cond_timedwait().  In addition to reinitializing the
+//      condvar we must establish the invariant that cond_signal() is only called
+//      within critical sections protected by the adjunct mutex.  This prevents
+//      cond_signal() from "seeing" a condvar that's in the midst of being
+//      reinitialized or that is corrupt.  Sadly, this invariant obviates the
+//      desirable signal-after-unlock optimization that avoids futile context switching.
+//
+//      I'm also concerned that some versions of NTPL might allocate an auxilliary
+//      structure when a condvar is used or initialized.  cond_destroy()  would
+//      release the helper structure.  Our reinitialize-after-timedwait fix
+//      put excessive stress on malloc/free and locks protecting the c-heap.
+//
+// We currently use (4).  See the WorkAroundNTPLTimedWaitHang flag.
+// It may be possible to refine (4) by checking the kernel and NTPL verisons
+// and only enabling the work-around for vulnerable environments.
+
+// utility to compute the abstime argument to timedwait:
+// millis is the relative timeout time
+// abstime will be the absolute timeout time
+// TODO: replace compute_abstime() with unpackTime()
+
+static struct timespec* compute_abstime(struct timespec* abstime, jlong millis) {
+  if (millis < 0)  millis = 0;
+  struct timeval now;
+  int status = gettimeofday(&now, NULL);
+  assert(status == 0, "gettimeofday");
+  jlong seconds = millis / 1000;
+  millis %= 1000;
+  if (seconds > 50000000) { // see man cond_timedwait(3T)
+    seconds = 50000000;
+  }
+  abstime->tv_sec = now.tv_sec  + seconds;
+  long       usec = now.tv_usec + millis * 1000;
+  if (usec >= 1000000) {
+    abstime->tv_sec += 1;
+    usec -= 1000000;
+  }
+  abstime->tv_nsec = usec * 1000;
+  return abstime;
+}
+
+
+// Test-and-clear _Event, always leaves _Event set to 0, returns immediately.
+// Conceptually TryPark() should be equivalent to park(0).
+
+int os::PlatformEvent::TryPark() {
+  for (;;) {
+    const int v = _Event ;
+    guarantee ((v == 0) || (v == 1), "invariant") ;
+    if (Atomic::cmpxchg (0, &_Event, v) == v) return v  ;
+  }
+}
+
+void os::PlatformEvent::park() {       // AKA "down()"
+  // Invariant: Only the thread associated with the Event/PlatformEvent
+  // may call park().
+  // TODO: assert that _Assoc != NULL or _Assoc == Self
+  int v ;
+  for (;;) {
+      v = _Event ;
+      if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ;
+  }
+  guarantee (v >= 0, "invariant") ;
+  if (v == 0) {
+     // Do this the hard way by blocking ...
+     int status = pthread_mutex_lock(_mutex);
+     assert_status(status == 0, status, "mutex_lock");
+     guarantee (_nParked == 0, "invariant") ;
+     ++ _nParked ;
+     while (_Event < 0) {
+        status = pthread_cond_wait(_cond, _mutex);
+        // for some reason, under 2.7 lwp_cond_wait() may return ETIME ...
+        // Treat this the same as if the wait was interrupted
+        if (status == ETIMEDOUT) { status = EINTR; }
+        assert_status(status == 0 || status == EINTR, status, "cond_wait");
+     }
+     -- _nParked ;
+
+    // In theory we could move the ST of 0 into _Event past the unlock(),
+    // but then we'd need a MEMBAR after the ST.
+    _Event = 0 ;
+     status = pthread_mutex_unlock(_mutex);
+     assert_status(status == 0, status, "mutex_unlock");
+  }
+  guarantee (_Event >= 0, "invariant") ;
+}
+
+int os::PlatformEvent::park(jlong millis) {
+  guarantee (_nParked == 0, "invariant") ;
+
+  int v ;
+  for (;;) {
+      v = _Event ;
+      if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ;
+  }
+  guarantee (v >= 0, "invariant") ;
+  if (v != 0) return OS_OK ;
+
+  // We do this the hard way, by blocking the thread.
+  // Consider enforcing a minimum timeout value.
+  struct timespec abst;
+  compute_abstime(&abst, millis);
+
+  int ret = OS_TIMEOUT;
+  int status = pthread_mutex_lock(_mutex);
+  assert_status(status == 0, status, "mutex_lock");
+  guarantee (_nParked == 0, "invariant") ;
+  ++_nParked ;
+
+  // Object.wait(timo) will return because of
+  // (a) notification
+  // (b) timeout
+  // (c) thread.interrupt
+  //
+  // Thread.interrupt and object.notify{All} both call Event::set.
+  // That is, we treat thread.interrupt as a special case of notification.
+  // The underlying Solaris implementation, cond_timedwait, admits
+  // spurious/premature wakeups, but the JLS/JVM spec prevents the
+  // JVM from making those visible to Java code.  As such, we must
+  // filter out spurious wakeups.  We assume all ETIME returns are valid.
+  //
+  // TODO: properly differentiate simultaneous notify+interrupt.
+  // In that case, we should propagate the notify to another waiter.
+
+  while (_Event < 0) {
+    status = os::Bsd::safe_cond_timedwait(_cond, _mutex, &abst);
+    if (status != 0 && WorkAroundNPTLTimedWaitHang) {
+      pthread_cond_destroy (_cond);
+      pthread_cond_init (_cond, NULL) ;
+    }
+    assert_status(status == 0 || status == EINTR ||
+                  status == ETIMEDOUT,
+                  status, "cond_timedwait");
+    if (!FilterSpuriousWakeups) break ;                 // previous semantics
+    if (status == ETIMEDOUT) break ;
+    // We consume and ignore EINTR and spurious wakeups.
+  }
+  --_nParked ;
+  if (_Event >= 0) {
+     ret = OS_OK;
+  }
+  _Event = 0 ;
+  status = pthread_mutex_unlock(_mutex);
+  assert_status(status == 0, status, "mutex_unlock");
+  assert (_nParked == 0, "invariant") ;
+  return ret;
+}
+
+void os::PlatformEvent::unpark() {
+  int v, AnyWaiters ;
+  for (;;) {
+      v = _Event ;
+      if (v > 0) {
+         // The LD of _Event could have reordered or be satisfied
+         // by a read-aside from this processor's write buffer.
+         // To avoid problems execute a barrier and then
+         // ratify the value.
+         OrderAccess::fence() ;
+         if (_Event == v) return ;
+         continue ;
+      }
+      if (Atomic::cmpxchg (v+1, &_Event, v) == v) break ;
+  }
+  if (v < 0) {
+     // Wait for the thread associated with the event to vacate
+     int status = pthread_mutex_lock(_mutex);
+     assert_status(status == 0, status, "mutex_lock");
+     AnyWaiters = _nParked ;
+     assert (AnyWaiters == 0 || AnyWaiters == 1, "invariant") ;
+     if (AnyWaiters != 0 && WorkAroundNPTLTimedWaitHang) {
+        AnyWaiters = 0 ;
+        pthread_cond_signal (_cond);
+     }
+     status = pthread_mutex_unlock(_mutex);
+     assert_status(status == 0, status, "mutex_unlock");
+     if (AnyWaiters != 0) {
+        status = pthread_cond_signal(_cond);
+        assert_status(status == 0, status, "cond_signal");
+     }
+  }
+
+  // Note that we signal() _after dropping the lock for "immortal" Events.
+  // This is safe and avoids a common class of  futile wakeups.  In rare
+  // circumstances this can cause a thread to return prematurely from
+  // cond_{timed}wait() but the spurious wakeup is benign and the victim will
+  // simply re-test the condition and re-park itself.
+}
+
+
+// JSR166
+// -------------------------------------------------------
+
+/*
+ * The solaris and bsd implementations of park/unpark are fairly
+ * conservative for now, but can be improved. They currently use a
+ * mutex/condvar pair, plus a a count.
+ * Park decrements count if > 0, else does a condvar wait.  Unpark
+ * sets count to 1 and signals condvar.  Only one thread ever waits
+ * on the condvar. Contention seen when trying to park implies that someone
+ * is unparking you, so don't wait. And spurious returns are fine, so there
+ * is no need to track notifications.
+ */
+
+
+#define NANOSECS_PER_SEC 1000000000
+#define NANOSECS_PER_MILLISEC 1000000
+#define MAX_SECS 100000000
+/*
+ * This code is common to bsd and solaris and will be moved to a
+ * common place in dolphin.
+ *
+ * The passed in time value is either a relative time in nanoseconds
+ * or an absolute time in milliseconds. Either way it has to be unpacked
+ * into suitable seconds and nanoseconds components and stored in the
+ * given timespec structure.
+ * Given time is a 64-bit value and the time_t used in the timespec is only
+ * a signed-32-bit value (except on 64-bit Bsd) we have to watch for
+ * overflow if times way in the future are given. Further on Solaris versions
+ * prior to 10 there is a restriction (see cond_timedwait) that the specified
+ * number of seconds, in abstime, is less than current_time  + 100,000,000.
+ * As it will be 28 years before "now + 100000000" will overflow we can
+ * ignore overflow and just impose a hard-limit on seconds using the value
+ * of "now + 100,000,000". This places a limit on the timeout of about 3.17
+ * years from "now".
+ */
+
+static void unpackTime(struct timespec* absTime, bool isAbsolute, jlong time) {
+  assert (time > 0, "convertTime");
+
+  struct timeval now;
+  int status = gettimeofday(&now, NULL);
+  assert(status == 0, "gettimeofday");
+
+  time_t max_secs = now.tv_sec + MAX_SECS;
+
+  if (isAbsolute) {
+    jlong secs = time / 1000;
+    if (secs > max_secs) {
+      absTime->tv_sec = max_secs;
+    }
+    else {
+      absTime->tv_sec = secs;
+    }
+    absTime->tv_nsec = (time % 1000) * NANOSECS_PER_MILLISEC;
+  }
+  else {
+    jlong secs = time / NANOSECS_PER_SEC;
+    if (secs >= MAX_SECS) {
+      absTime->tv_sec = max_secs;
+      absTime->tv_nsec = 0;
+    }
+    else {
+      absTime->tv_sec = now.tv_sec + secs;
+      absTime->tv_nsec = (time % NANOSECS_PER_SEC) + now.tv_usec*1000;
+      if (absTime->tv_nsec >= NANOSECS_PER_SEC) {
+        absTime->tv_nsec -= NANOSECS_PER_SEC;
+        ++absTime->tv_sec; // note: this must be <= max_secs
+      }
+    }
+  }
+  assert(absTime->tv_sec >= 0, "tv_sec < 0");
+  assert(absTime->tv_sec <= max_secs, "tv_sec > max_secs");
+  assert(absTime->tv_nsec >= 0, "tv_nsec < 0");
+  assert(absTime->tv_nsec < NANOSECS_PER_SEC, "tv_nsec >= nanos_per_sec");
+}
+
+void Parker::park(bool isAbsolute, jlong time) {
+  // Optional fast-path check:
+  // Return immediately if a permit is available.
+  if (_counter > 0) {
+      _counter = 0 ;
+      OrderAccess::fence();
+      return ;
+  }
+
+  Thread* thread = Thread::current();
+  assert(thread->is_Java_thread(), "Must be JavaThread");
+  JavaThread *jt = (JavaThread *)thread;
+
+  // Optional optimization -- avoid state transitions if there's an interrupt pending.
+  // Check interrupt before trying to wait
+  if (Thread::is_interrupted(thread, false)) {
+    return;
+  }
+
+  // Next, demultiplex/decode time arguments
+  struct timespec absTime;
+  if (time < 0 || (isAbsolute && time == 0) ) { // don't wait at all
+    return;
+  }
+  if (time > 0) {
+    unpackTime(&absTime, isAbsolute, time);
+  }
+
+
+  // Enter safepoint region
+  // Beware of deadlocks such as 6317397.
+  // The per-thread Parker:: mutex is a classic leaf-lock.
+  // In particular a thread must never block on the Threads_lock while
+  // holding the Parker:: mutex.  If safepoints are pending both the
+  // the ThreadBlockInVM() CTOR and DTOR may grab Threads_lock.
+  ThreadBlockInVM tbivm(jt);
+
+  // Don't wait if cannot get lock since interference arises from
+  // unblocking.  Also. check interrupt before trying wait
+  if (Thread::is_interrupted(thread, false) || pthread_mutex_trylock(_mutex) != 0) {
+    return;
+  }
+
+  int status ;
+  if (_counter > 0)  { // no wait needed
+    _counter = 0;
+    status = pthread_mutex_unlock(_mutex);
+    assert (status == 0, "invariant") ;
+    OrderAccess::fence();
+    return;
+  }
+
+#ifdef ASSERT
+  // Don't catch signals while blocked; let the running threads have the signals.
+  // (This allows a debugger to break into the running thread.)
+  sigset_t oldsigs;
+  sigset_t* allowdebug_blocked = os::Bsd::allowdebug_blocked_signals();
+  pthread_sigmask(SIG_BLOCK, allowdebug_blocked, &oldsigs);
+#endif
+
+  OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
+  jt->set_suspend_equivalent();
+  // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self()
+
+  if (time == 0) {
+    status = pthread_cond_wait (_cond, _mutex) ;
+  } else {
+    status = os::Bsd::safe_cond_timedwait (_cond, _mutex, &absTime) ;
+    if (status != 0 && WorkAroundNPTLTimedWaitHang) {
+      pthread_cond_destroy (_cond) ;
+      pthread_cond_init    (_cond, NULL);
+    }
+  }
+  assert_status(status == 0 || status == EINTR ||
+                status == ETIMEDOUT,
+                status, "cond_timedwait");
+
+#ifdef ASSERT
+  pthread_sigmask(SIG_SETMASK, &oldsigs, NULL);
+#endif
+
+  _counter = 0 ;
+  status = pthread_mutex_unlock(_mutex) ;
+  assert_status(status == 0, status, "invariant") ;
+  // If externally suspended while waiting, re-suspend
+  if (jt->handle_special_suspend_equivalent_condition()) {
+    jt->java_suspend_self();
+  }
+
+  OrderAccess::fence();
+}
+
+void Parker::unpark() {
+  int s, status ;
+  status = pthread_mutex_lock(_mutex);
+  assert (status == 0, "invariant") ;
+  s = _counter;
+  _counter = 1;
+  if (s < 1) {
+     if (WorkAroundNPTLTimedWaitHang) {
+        status = pthread_cond_signal (_cond) ;
+        assert (status == 0, "invariant") ;
+        status = pthread_mutex_unlock(_mutex);
+        assert (status == 0, "invariant") ;
+     } else {
+        status = pthread_mutex_unlock(_mutex);
+        assert (status == 0, "invariant") ;
+        status = pthread_cond_signal (_cond) ;
+        assert (status == 0, "invariant") ;
+     }
+  } else {
+    pthread_mutex_unlock(_mutex);
+    assert (status == 0, "invariant") ;
+  }
+}
+
+
+/* Darwin has no "environ" in a dynamic library. */
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
+extern char** environ;
+#endif
+
+// Run the specified command in a separate process. Return its exit value,
+// or -1 on failure (e.g. can't fork a new process).
+// Unlike system(), this function can be called from signal handler. It
+// doesn't block SIGINT et al.
+int os::fork_and_exec(char* cmd) {
+  const char * argv[4] = {"sh", "-c", cmd, NULL};
+
+  // fork() in BsdThreads/NPTL is not async-safe. It needs to run
+  // pthread_atfork handlers and reset pthread library. All we need is a
+  // separate process to execve. Make a direct syscall to fork process.
+  // On IA64 there's no fork syscall, we have to use fork() and hope for
+  // the best...
+  pid_t pid = fork();
+
+  if (pid < 0) {
+    // fork failed
+    return -1;
+
+  } else if (pid == 0) {
+    // child process
+
+    // execve() in BsdThreads will call pthread_kill_other_threads_np()
+    // first to kill every thread on the thread list. Because this list is
+    // not reset by fork() (see notes above), execve() will instead kill
+    // every thread in the parent process. We know this is the only thread
+    // in the new process, so make a system call directly.
+    // IA64 should use normal execve() from glibc to match the glibc fork()
+    // above.
+    execve("/bin/sh", (char* const*)argv, environ);
+
+    // execve failed
+    _exit(-1);
+
+  } else  {
+    // copied from J2SE ..._waitForProcessExit() in UNIXProcess_md.c; we don't
+    // care about the actual exit code, for now.
+
+    int status;
+
+    // Wait for the child process to exit.  This returns immediately if
+    // the child has already exited. */
+    while (waitpid(pid, &status, 0) < 0) {
+        switch (errno) {
+        case ECHILD: return 0;
+        case EINTR: break;
+        default: return -1;
+        }
+    }
+
+    if (WIFEXITED(status)) {
+       // The child exited normally; get its exit code.
+       return WEXITSTATUS(status);
+    } else if (WIFSIGNALED(status)) {
+       // The child exited because of a signal
+       // The best value to return is 0x80 + signal number,
+       // because that is what all Unix shells do, and because
+       // it allows callers to distinguish between process exit and
+       // process death by signal.
+       return 0x80 + WTERMSIG(status);
+    } else {
+       // Unknown exit code; pass it through
+       return status;
+    }
+  }
+}
+
+// is_headless_jre()
+//
+// Test for the existence of libmawt in motif21 or xawt directories
+// in order to report if we are running in a headless jre
+//
+bool os::is_headless_jre() {
+    struct stat statbuf;
+    char buf[MAXPATHLEN];
+    char libmawtpath[MAXPATHLEN];
+    const char *xawtstr  = "/xawt/libmawt" JNI_LIB_SUFFIX;
+    const char *motifstr = "/motif21/libmawt" JNI_LIB_SUFFIX;
+    char *p;
+
+    // Get path to libjvm.so
+    os::jvm_path(buf, sizeof(buf));
+
+    // Get rid of libjvm.so
+    p = strrchr(buf, '/');
+    if (p == NULL) return false;
+    else *p = '\0';
+
+    // Get rid of client or server
+    p = strrchr(buf, '/');
+    if (p == NULL) return false;
+    else *p = '\0';
+
+    // check xawt/libmawt.so
+    strcpy(libmawtpath, buf);
+    strcat(libmawtpath, xawtstr);
+    if (::stat(libmawtpath, &statbuf) == 0) return false;
+
+    // check motif21/libmawt.so
+    strcpy(libmawtpath, buf);
+    strcat(libmawtpath, motifstr);
+    if (::stat(libmawtpath, &statbuf) == 0) return false;
+
+    return true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/os_bsd.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_BSD_VM_OS_BSD_HPP
+#define OS_BSD_VM_OS_BSD_HPP
+
+// Bsd_OS defines the interface to Bsd operating systems
+
+/* pthread_getattr_np comes with BsdThreads-0.9-7 on RedHat 7.1 */
+typedef int (*pthread_getattr_func_type) (pthread_t, pthread_attr_t *);
+
+#ifdef __APPLE__
+// Mac OS X doesn't support clock_gettime. Stub out the type, it is
+// unused
+typedef int clockid_t;
+#endif
+
+class Bsd {
+  friend class os;
+
+  // For signal-chaining
+#define MAXSIGNUM 32
+  static struct sigaction sigact[MAXSIGNUM]; // saved preinstalled sigactions
+  static unsigned int sigs;             // mask of signals that have
+                                        // preinstalled signal handlers
+  static bool libjsig_is_loaded;        // libjsig that interposes sigaction(),
+                                        // __sigaction(), signal() is loaded
+  static struct sigaction *(*get_signal_action)(int);
+  static struct sigaction *get_preinstalled_handler(int);
+  static void save_preinstalled_handler(int, struct sigaction&);
+
+  static void check_signal_handler(int sig);
+
+  // For signal flags diagnostics
+  static int sigflags[MAXSIGNUM];
+
+  static int (*_clock_gettime)(clockid_t, struct timespec *);
+#ifndef _ALLBSD_SOURCE
+  static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
+
+  static address   _initial_thread_stack_bottom;
+  static uintptr_t _initial_thread_stack_size;
+
+  static const char *_glibc_version;
+  static const char *_libpthread_version;
+
+  static bool _is_floating_stack;
+  static bool _is_NPTL;
+  static bool _supports_fast_thread_cpu_time;
+#endif
+
+  static GrowableArray<int>* _cpu_to_node;
+
+ protected:
+
+  static julong _physical_memory;
+  static pthread_t _main_thread;
+#ifndef _ALLBSD_SOURCE
+  static Mutex* _createThread_lock;
+#endif
+  static int _page_size;
+
+  static julong available_memory();
+  static julong physical_memory() { return _physical_memory; }
+  static void initialize_system_info();
+
+#ifndef _ALLBSD_SOURCE
+  static void set_glibc_version(const char *s)      { _glibc_version = s; }
+  static void set_libpthread_version(const char *s) { _libpthread_version = s; }
+#endif
+
+  static bool supports_variable_stack_size();
+
+#ifndef _ALLBSD_SOURCE
+  static void set_is_NPTL()                   { _is_NPTL = true;  }
+  static void set_is_BsdThreads()           { _is_NPTL = false; }
+  static void set_is_floating_stack()         { _is_floating_stack = true; }
+#endif
+
+  static void rebuild_cpu_to_node_map();
+  static GrowableArray<int>* cpu_to_node()    { return _cpu_to_node; }
+
+  static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
+
+ public:
+
+  static void init_thread_fpu_state();
+#ifndef _ALLBSD_SOURCE
+  static int  get_fpu_control_word();
+  static void set_fpu_control_word(int fpu_control);
+#endif
+  static pthread_t main_thread(void)                                { return _main_thread; }
+
+#ifndef _ALLBSD_SOURCE
+  // returns kernel thread id (similar to LWP id on Solaris), which can be
+  // used to access /proc
+  static pid_t gettid();
+  static void set_createThread_lock(Mutex* lk)                      { _createThread_lock = lk; }
+  static Mutex* createThread_lock(void)                             { return _createThread_lock; }
+#endif
+  static void hotspot_sigmask(Thread* thread);
+
+#ifndef _ALLBSD_SOURCE
+  static address   initial_thread_stack_bottom(void)                { return _initial_thread_stack_bottom; }
+  static uintptr_t initial_thread_stack_size(void)                  { return _initial_thread_stack_size; }
+#endif
+  static bool is_initial_thread(void);
+
+  static int page_size(void)                                        { return _page_size; }
+  static void set_page_size(int val)                                { _page_size = val; }
+
+  static address   ucontext_get_pc(ucontext_t* uc);
+  static intptr_t* ucontext_get_sp(ucontext_t* uc);
+  static intptr_t* ucontext_get_fp(ucontext_t* uc);
+
+  // For Analyzer Forte AsyncGetCallTrace profiling support:
+  //
+  // This interface should be declared in os_bsd_i486.hpp, but
+  // that file provides extensions to the os class and not the
+  // Bsd class.
+  static ExtendedPC fetch_frame_from_ucontext(Thread* thread, ucontext_t* uc,
+    intptr_t** ret_sp, intptr_t** ret_fp);
+
+  // This boolean allows users to forward their own non-matching signals
+  // to JVM_handle_bsd_signal, harmlessly.
+  static bool signal_handlers_are_installed;
+
+  static int get_our_sigflags(int);
+  static void set_our_sigflags(int, int);
+  static void signal_sets_init();
+  static void install_signal_handlers();
+  static void set_signal_handler(int, bool);
+  static bool is_sig_ignored(int sig);
+
+  static sigset_t* unblocked_signals();
+  static sigset_t* vm_signals();
+  static sigset_t* allowdebug_blocked_signals();
+
+  // For signal-chaining
+  static struct sigaction *get_chained_signal_action(int sig);
+  static bool chained_handler(int sig, siginfo_t* siginfo, void* context);
+
+#ifndef _ALLBSD_SOURCE
+  // GNU libc and libpthread version strings
+  static const char *glibc_version()          { return _glibc_version; }
+  static const char *libpthread_version()     { return _libpthread_version; }
+
+  // NPTL or BsdThreads?
+  static bool is_BsdThreads()               { return !_is_NPTL; }
+  static bool is_NPTL()                       { return _is_NPTL;  }
+
+  // NPTL is always floating stack. BsdThreads could be using floating
+  // stack or fixed stack.
+  static bool is_floating_stack()             { return _is_floating_stack; }
+
+  static void libpthread_init();
+  static bool libnuma_init();
+  static void* libnuma_dlsym(void* handle, const char* name);
+#endif
+  // Minimum stack size a thread can be created with (allowing
+  // the VM to completely create the thread and enter user code)
+  static size_t min_stack_allowed;
+
+  // Return default stack size or guard size for the specified thread type
+  static size_t default_stack_size(os::ThreadType thr_type);
+  static size_t default_guard_size(os::ThreadType thr_type);
+
+#ifndef _ALLBSD_SOURCE
+  static void capture_initial_stack(size_t max_size);
+
+  // Stack overflow handling
+  static bool manually_expand_stack(JavaThread * t, address addr);
+  static int max_register_window_saves_before_flushing();
+#endif
+
+  // Real-time clock functions
+  static void clock_init(void);
+
+#ifndef _ALLBSD_SOURCE
+  // fast POSIX clocks support
+  static void fast_thread_clock_init(void);
+#endif
+
+  static bool supports_monotonic_clock() {
+    return _clock_gettime != NULL;
+  }
+
+  static int clock_gettime(clockid_t clock_id, struct timespec *tp) {
+    return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
+  }
+
+#ifndef _ALLBSD_SOURCE
+  static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
+    return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
+  }
+
+  static bool supports_fast_thread_cpu_time() {
+    return _supports_fast_thread_cpu_time;
+  }
+
+  static jlong fast_thread_cpu_time(clockid_t clockid);
+#endif
+
+  // Stack repair handling
+
+  // none present
+
+  // BsdThreads work-around for 6292965
+  static int safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime);
+
+
+  // Bsd suspend/resume support - this helper is a shadow of its former
+  // self now that low-level suspension is barely used, and old workarounds
+  // for BsdThreads are no longer needed.
+  class SuspendResume {
+  private:
+    volatile int _suspend_action;
+    // values for suspend_action:
+    #define SR_NONE               (0x00)
+    #define SR_SUSPEND            (0x01)  // suspend request
+    #define SR_CONTINUE           (0x02)  // resume request
+
+    volatile jint _state;
+    // values for _state: + SR_NONE
+    #define SR_SUSPENDED          (0x20)
+  public:
+    SuspendResume() { _suspend_action = SR_NONE; _state = SR_NONE; }
+
+    int suspend_action() const     { return _suspend_action; }
+    void set_suspend_action(int x) { _suspend_action = x;    }
+
+    // atomic updates for _state
+    void set_suspended()           {
+      jint temp, temp2;
+      do {
+        temp = _state;
+        temp2 = Atomic::cmpxchg(temp | SR_SUSPENDED, &_state, temp);
+      } while (temp2 != temp);
+    }
+    void clear_suspended()        {
+      jint temp, temp2;
+      do {
+        temp = _state;
+        temp2 = Atomic::cmpxchg(temp & ~SR_SUSPENDED, &_state, temp);
+      } while (temp2 != temp);
+    }
+    bool is_suspended()            { return _state & SR_SUSPENDED;       }
+
+    #undef SR_SUSPENDED
+  };
+
+private:
+  typedef int (*sched_getcpu_func_t)(void);
+  typedef int (*numa_node_to_cpus_func_t)(int node, unsigned long *buffer, int bufferlen);
+  typedef int (*numa_max_node_func_t)(void);
+  typedef int (*numa_available_func_t)(void);
+  typedef int (*numa_tonode_memory_func_t)(void *start, size_t size, int node);
+  typedef void (*numa_interleave_memory_func_t)(void *start, size_t size, unsigned long *nodemask);
+
+  static sched_getcpu_func_t _sched_getcpu;
+  static numa_node_to_cpus_func_t _numa_node_to_cpus;
+  static numa_max_node_func_t _numa_max_node;
+  static numa_available_func_t _numa_available;
+  static numa_tonode_memory_func_t _numa_tonode_memory;
+  static numa_interleave_memory_func_t _numa_interleave_memory;
+  static unsigned long* _numa_all_nodes;
+
+  static void set_sched_getcpu(sched_getcpu_func_t func) { _sched_getcpu = func; }
+  static void set_numa_node_to_cpus(numa_node_to_cpus_func_t func) { _numa_node_to_cpus = func; }
+  static void set_numa_max_node(numa_max_node_func_t func) { _numa_max_node = func; }
+  static void set_numa_available(numa_available_func_t func) { _numa_available = func; }
+  static void set_numa_tonode_memory(numa_tonode_memory_func_t func) { _numa_tonode_memory = func; }
+  static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
+  static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
+public:
+  static int sched_getcpu()  { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
+  static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
+    return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;
+  }
+  static int numa_max_node() { return _numa_max_node != NULL ? _numa_max_node() : -1; }
+  static int numa_available() { return _numa_available != NULL ? _numa_available() : -1; }
+  static int numa_tonode_memory(void *start, size_t size, int node) {
+    return _numa_tonode_memory != NULL ? _numa_tonode_memory(start, size, node) : -1;
+  }
+  static void numa_interleave_memory(void *start, size_t size) {
+    if (_numa_interleave_memory != NULL && _numa_all_nodes != NULL) {
+      _numa_interleave_memory(start, size, _numa_all_nodes);
+    }
+  }
+  static int get_node_by_cpu(int cpu_id);
+};
+
+
+class PlatformEvent : public CHeapObj {
+  private:
+    double CachePad [4] ;   // increase odds that _mutex is sole occupant of cache line
+    volatile int _Event ;
+    volatile int _nParked ;
+    pthread_mutex_t _mutex  [1] ;
+    pthread_cond_t  _cond   [1] ;
+    double PostPad  [2] ;
+    Thread * _Assoc ;
+
+  public:       // TODO-FIXME: make dtor private
+    ~PlatformEvent() { guarantee (0, "invariant") ; }
+
+  public:
+    PlatformEvent() {
+      int status;
+      status = pthread_cond_init (_cond, NULL);
+      assert_status(status == 0, status, "cond_init");
+      status = pthread_mutex_init (_mutex, NULL);
+      assert_status(status == 0, status, "mutex_init");
+      _Event   = 0 ;
+      _nParked = 0 ;
+      _Assoc   = NULL ;
+    }
+
+    // Use caution with reset() and fired() -- they may require MEMBARs
+    void reset() { _Event = 0 ; }
+    int  fired() { return _Event; }
+    void park () ;
+    void unpark () ;
+    int  TryPark () ;
+    int  park (jlong millis) ;
+    void SetAssociation (Thread * a) { _Assoc = a ; }
+} ;
+
+class PlatformParker : public CHeapObj {
+  protected:
+    pthread_mutex_t _mutex [1] ;
+    pthread_cond_t  _cond  [1] ;
+
+  public:       // TODO-FIXME: make dtor private
+    ~PlatformParker() { guarantee (0, "invariant") ; }
+
+  public:
+    PlatformParker() {
+      int status;
+      status = pthread_cond_init (_cond, NULL);
+      assert_status(status == 0, status, "cond_init");
+      status = pthread_mutex_init (_mutex, NULL);
+      assert_status(status == 0, status, "mutex_init");
+    }
+} ;
+
+#endif // OS_BSD_VM_OS_BSD_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/os_bsd.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef OS_BSD_VM_OS_BSD_INLINE_HPP
+#define OS_BSD_VM_OS_BSD_INLINE_HPP
+
+#include "runtime/atomic.hpp"
+#include "runtime/os.hpp"
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "atomic_bsd_x86.inline.hpp"
+# include "orderAccess_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "atomic_bsd_zero.inline.hpp"
+# include "orderAccess_bsd_zero.inline.hpp"
+#endif
+
+// System includes
+
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/poll.h>
+#include <netdb.h>
+
+inline void* os::thread_local_storage_at(int index) {
+  return pthread_getspecific((pthread_key_t)index);
+}
+
+inline const char* os::file_separator() {
+  return "/";
+}
+
+inline const char* os::line_separator() {
+  return "\n";
+}
+
+inline const char* os::path_separator() {
+  return ":";
+}
+
+inline const char* os::jlong_format_specifier() {
+  return "%lld";
+}
+
+inline const char* os::julong_format_specifier() {
+  return "%llu";
+}
+
+// File names are case-sensitive on windows only
+inline int os::file_name_strcmp(const char* s1, const char* s2) {
+  return strcmp(s1, s2);
+}
+
+inline bool os::obsolete_option(const JavaVMOption *option) {
+  return false;
+}
+
+inline bool os::uses_stack_guard_pages() {
+  return true;
+}
+
+inline bool os::allocate_stack_guard_pages() {
+  assert(uses_stack_guard_pages(), "sanity check");
+#if !defined(__FreeBSD__) || __FreeBSD__ < 5
+  // Since FreeBSD 4 uses malloc() for allocating the thread stack
+  // there is no need to do anything extra to allocate the guard pages
+  return false;
+#else
+  // FreeBSD 5+ uses mmap MAP_STACK for allocating the thread stacks.
+  // Must 'allocate' them or guard pages are ignored.
+  return true;
+#endif
+}
+
+
+// On Bsd, reservations are made on a page by page basis, nothing to do.
+inline void os::split_reserved_memory(char *base, size_t size,
+                                      size_t split, bool realloc) {
+}
+
+
+// Bang the shadow pages if they need to be touched to be mapped.
+inline void os::bang_stack_shadow_pages() {
+}
+
+inline void os::dll_unload(void *lib) {
+  ::dlclose(lib);
+}
+
+inline const int os::default_file_open_flags() { return 0;}
+
+inline DIR* os::opendir(const char* dirname)
+{
+  assert(dirname != NULL, "just checking");
+  return ::opendir(dirname);
+}
+
+inline int os::readdir_buf_size(const char *path)
+{
+  return NAME_MAX + sizeof(dirent) + 1;
+}
+
+inline jlong os::lseek(int fd, jlong offset, int whence) {
+  return (jlong) ::lseek(fd, offset, whence);
+}
+
+inline int os::fsync(int fd) {
+  return ::fsync(fd);
+}
+
+inline char* os::native_path(char *path) {
+  return path;
+}
+
+inline int os::ftruncate(int fd, jlong length) {
+  return ::ftruncate(fd, length);
+}
+
+inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
+{
+  dirent* p;
+  int status;
+  assert(dirp != NULL, "just checking");
+
+  // NOTE: Bsd readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
+  // version. Here is the doc for this function:
+  // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
+
+  if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
+    errno = status;
+    return NULL;
+  } else
+    return p;
+}
+
+inline int os::closedir(DIR *dirp) {
+  assert(dirp != NULL, "argument is NULL");
+  return ::closedir(dirp);
+}
+
+// macros for restartable system calls
+
+#define RESTARTABLE(_cmd, _result) do { \
+    _result = _cmd; \
+  } while(((int)_result == OS_ERR) && (errno == EINTR))
+
+#define RESTARTABLE_RETURN_INT(_cmd) do { \
+  int _result; \
+  RESTARTABLE(_cmd, _result); \
+  return _result; \
+} while(false)
+
+inline bool os::numa_has_static_binding()   { return true; }
+inline bool os::numa_has_group_homing()     { return false;  }
+
+inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
+  size_t res;
+  RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
+  return res;
+}
+
+inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
+  size_t res;
+  RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
+  return res;
+}
+
+inline int os::close(int fd) {
+  RESTARTABLE_RETURN_INT(::close(fd));
+}
+
+inline int os::socket_close(int fd) {
+  RESTARTABLE_RETURN_INT(::close(fd));
+}
+
+inline int os::socket(int domain, int type, int protocol) {
+  return ::socket(domain, type, protocol);
+}
+
+inline int os::recv(int fd, char *buf, int nBytes, int flags) {
+  RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags));
+}
+
+inline int os::send(int fd, char *buf, int nBytes, int flags) {
+  RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
+}
+
+inline int os::raw_send(int fd, char *buf, int nBytes, int flags) {
+  return os::send(fd, buf, nBytes, flags);
+}
+
+inline int os::timeout(int fd, long timeout) {
+  julong prevtime,newtime;
+  struct timeval t;
+
+  gettimeofday(&t, NULL);
+  prevtime = ((julong)t.tv_sec * 1000)  +  t.tv_usec / 1000;
+
+  for(;;) {
+    struct pollfd pfd;
+
+    pfd.fd = fd;
+    pfd.events = POLLIN | POLLERR;
+
+    int res = ::poll(&pfd, 1, timeout);
+
+    if (res == OS_ERR && errno == EINTR) {
+
+      // On Bsd any value < 0 means "forever"
+
+      if(timeout >= 0) {
+        gettimeofday(&t, NULL);
+        newtime = ((julong)t.tv_sec * 1000)  +  t.tv_usec / 1000;
+        timeout -= newtime - prevtime;
+        if(timeout <= 0)
+          return OS_OK;
+        prevtime = newtime;
+      }
+    } else
+      return res;
+  }
+}
+
+inline int os::listen(int fd, int count) {
+  return ::listen(fd, count);
+}
+
+inline int os::connect(int fd, struct sockaddr *him, int len) {
+  RESTARTABLE_RETURN_INT(::connect(fd, him, len));
+}
+
+inline int os::accept(int fd, struct sockaddr *him, int *len) {
+  // This cast is from int to unsigned int on bsd.  Since we
+  // only pass the parameter "len" around the vm and don't try to
+  // fetch it's value, this cast is safe for now. The java.net group
+  // may need and want to change this interface someday if socklen_t goes
+  // to 64 bits on some platform that we support.
+
+  // At least OpenBSD and FreeBSD can return EINTR from accept.
+  RESTARTABLE_RETURN_INT(::accept(fd, him, (socklen_t *)len));
+}
+
+inline int os::recvfrom(int fd, char *buf, int nBytes, int flags,
+                         sockaddr *from, int *fromlen) {
+  RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen));
+}
+
+inline int os::sendto(int fd, char *buf, int len, int flags,
+                        struct sockaddr *to, int tolen) {
+  RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen));
+}
+
+inline int os::socket_shutdown(int fd, int howto){
+  return ::shutdown(fd, howto);
+}
+
+inline int os::bind(int fd, struct sockaddr *him, int len){
+  return ::bind(fd, him, len);
+}
+
+inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){
+  return ::getsockname(fd, him, (socklen_t *)len);
+}
+
+inline int os::get_host_name(char* name, int namelen){
+  return ::gethostname(name, namelen);
+}
+
+inline struct hostent*  os::get_host_by_name(char* name) {
+  return ::gethostbyname(name);
+}
+inline int os::get_sock_opt(int fd, int level, int optname,
+                             char *optval, int* optlen){
+  return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen);
+}
+
+inline int os::set_sock_opt(int fd, int level, int optname,
+                             const char *optval, int optlen){
+  return ::setsockopt(fd, level, optname, optval, optlen);
+}
+#endif // OS_BSD_VM_OS_BSD_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/os_share_bsd.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_BSD_VM_OS_SHARE_BSD_HPP
+#define OS_BSD_VM_OS_SHARE_BSD_HPP
+
+// misc
+void signalHandler(int, siginfo_t*, ucontext_t*);
+void handle_unexpected_exception(Thread* thread, int sig, siginfo_t* info, address pc, address adjusted_pc);
+#ifndef PRODUCT
+void continue_with_dump(void);
+#endif
+
+#define PROCFILE_LENGTH 128
+
+#endif // OS_BSD_VM_OS_SHARE_BSD_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/perfMemory_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,1041 @@
+/*
+ * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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/vmSymbols.hpp"
+#include "memory/allocation.inline.hpp"
+#include "memory/resourceArea.hpp"
+#include "oops/oop.inline.hpp"
+#include "os_bsd.inline.hpp"
+#include "runtime/handles.inline.hpp"
+#include "runtime/perfMemory.hpp"
+#include "utilities/exceptions.hpp"
+
+// put OS-includes here
+# include <sys/types.h>
+# include <sys/mman.h>
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+# include <sys/stat.h>
+# include <signal.h>
+# include <pwd.h>
+
+static char* backing_store_file_name = NULL;  // name of the backing store
+                                              // file, if successfully created.
+
+// Standard Memory Implementation Details
+
+// create the PerfData memory region in standard memory.
+//
+static char* create_standard_memory(size_t size) {
+
+  // allocate an aligned chuck of memory
+  char* mapAddress = os::reserve_memory(size);
+
+  if (mapAddress == NULL) {
+    return NULL;
+  }
+
+  // commit memory
+  if (!os::commit_memory(mapAddress, size)) {
+    if (PrintMiscellaneous && Verbose) {
+      warning("Could not commit PerfData memory\n");
+    }
+    os::release_memory(mapAddress, size);
+    return NULL;
+  }
+
+  return mapAddress;
+}
+
+// delete the PerfData memory region
+//
+static void delete_standard_memory(char* addr, size_t size) {
+
+  // there are no persistent external resources to cleanup for standard
+  // memory. since DestroyJavaVM does not support unloading of the JVM,
+  // cleanup of the memory resource is not performed. The memory will be
+  // reclaimed by the OS upon termination of the process.
+  //
+  return;
+}
+
+// save the specified memory region to the given file
+//
+// Note: this function might be called from signal handler (by os::abort()),
+// don't allocate heap memory.
+//
+static void save_memory_to_file(char* addr, size_t size) {
+
+ const char* destfile = PerfMemory::get_perfdata_file_path();
+ assert(destfile[0] != '\0', "invalid PerfData file path");
+
+  int result;
+
+  RESTARTABLE(::open(destfile, O_CREAT|O_WRONLY|O_TRUNC, S_IREAD|S_IWRITE),
+              result);;
+  if (result == OS_ERR) {
+    if (PrintMiscellaneous && Verbose) {
+      warning("Could not create Perfdata save file: %s: %s\n",
+              destfile, strerror(errno));
+    }
+  } else {
+    int fd = result;
+
+    for (size_t remaining = size; remaining > 0;) {
+
+      RESTARTABLE(::write(fd, addr, remaining), result);
+      if (result == OS_ERR) {
+        if (PrintMiscellaneous && Verbose) {
+          warning("Could not write Perfdata save file: %s: %s\n",
+                  destfile, strerror(errno));
+        }
+        break;
+      }
+
+      remaining -= (size_t)result;
+      addr += result;
+    }
+
+    RESTARTABLE(::close(fd), result);
+    if (PrintMiscellaneous && Verbose) {
+      if (result == OS_ERR) {
+        warning("Could not close %s: %s\n", destfile, strerror(errno));
+      }
+    }
+  }
+  FREE_C_HEAP_ARRAY(char, destfile);
+}
+
+
+// Shared Memory Implementation Details
+
+// Note: the solaris and bsd shared memory implementation uses the mmap
+// interface with a backing store file to implement named shared memory.
+// Using the file system as the name space for shared memory allows a
+// common name space to be supported across a variety of platforms. It
+// also provides a name space that Java applications can deal with through
+// simple file apis.
+//
+// The solaris and bsd implementations store the backing store file in
+// a user specific temporary directory located in the /tmp file system,
+// which is always a local file system and is sometimes a RAM based file
+// system.
+
+// return the user specific temporary directory name.
+//
+// the caller is expected to free the allocated memory.
+//
+static char* get_user_tmp_dir(const char* user) {
+
+  const char* tmpdir = os::get_temp_directory();
+  const char* perfdir = PERFDATA_NAME;
+  size_t nbytes = strlen(tmpdir) + strlen(perfdir) + strlen(user) + 3;
+  char* dirname = NEW_C_HEAP_ARRAY(char, nbytes);
+
+  // construct the path name to user specific tmp directory
+  snprintf(dirname, nbytes, "%s/%s_%s", tmpdir, perfdir, user);
+
+  return dirname;
+}
+
+// convert the given file name into a process id. if the file
+// does not meet the file naming constraints, return 0.
+//
+static pid_t filename_to_pid(const char* filename) {
+
+  // a filename that doesn't begin with a digit is not a
+  // candidate for conversion.
+  //
+  if (!isdigit(*filename)) {
+    return 0;
+  }
+
+  // check if file name can be converted to an integer without
+  // any leftover characters.
+  //
+  char* remainder = NULL;
+  errno = 0;
+  pid_t pid = (pid_t)strtol(filename, &remainder, 10);
+
+  if (errno != 0) {
+    return 0;
+  }
+
+  // check for left over characters. If any, then the filename is
+  // not a candidate for conversion.
+  //
+  if (remainder != NULL && *remainder != '\0') {
+    return 0;
+  }
+
+  // successful conversion, return the pid
+  return pid;
+}
+
+
+// check if the given path is considered a secure directory for
+// the backing store files. Returns true if the directory exists
+// and is considered a secure location. Returns false if the path
+// is a symbolic link or if an error occurred.
+//
+static bool is_directory_secure(const char* path) {
+  struct stat statbuf;
+  int result = 0;
+
+  RESTARTABLE(::lstat(path, &statbuf), result);
+  if (result == OS_ERR) {
+    return false;
+  }
+
+  // the path exists, now check it's mode
+  if (S_ISLNK(statbuf.st_mode) || !S_ISDIR(statbuf.st_mode)) {
+    // the path represents a link or some non-directory file type,
+    // which is not what we expected. declare it insecure.
+    //
+    return false;
+  }
+  else {
+    // we have an existing directory, check if the permissions are safe.
+    //
+    if ((statbuf.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
+      // the directory is open for writing and could be subjected
+      // to a symlnk attack. declare it insecure.
+      //
+      return false;
+    }
+  }
+  return true;
+}
+
+
+// return the user name for the given user id
+//
+// the caller is expected to free the allocated memory.
+//
+static char* get_user_name(uid_t uid) {
+
+  struct passwd pwent;
+
+  // determine the max pwbuf size from sysconf, and hardcode
+  // a default if this not available through sysconf.
+  //
+  long bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
+  if (bufsize == -1)
+    bufsize = 1024;
+
+  char* pwbuf = NEW_C_HEAP_ARRAY(char, bufsize);
+
+  // POSIX interface to getpwuid_r is used on LINUX
+  struct passwd* p;
+  int result = getpwuid_r(uid, &pwent, pwbuf, (size_t)bufsize, &p);
+
+  if (result != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') {
+    if (PrintMiscellaneous && Verbose) {
+      if (result != 0) {
+        warning("Could not retrieve passwd entry: %s\n",
+                strerror(result));
+      }
+      else if (p == NULL) {
+        // this check is added to protect against an observed problem
+        // with getpwuid_r() on RedHat 9 where getpwuid_r returns 0,
+        // indicating success, but has p == NULL. This was observed when
+        // inserting a file descriptor exhaustion fault prior to the call
+        // getpwuid_r() call. In this case, error is set to the appropriate
+        // error condition, but this is undocumented behavior. This check
+        // is safe under any condition, but the use of errno in the output
+        // message may result in an erroneous message.
+        // Bug Id 89052 was opened with RedHat.
+        //
+        warning("Could not retrieve passwd entry: %s\n",
+                strerror(errno));
+      }
+      else {
+        warning("Could not determine user name: %s\n",
+                p->pw_name == NULL ? "pw_name = NULL" :
+                                     "pw_name zero length");
+      }
+    }
+    FREE_C_HEAP_ARRAY(char, pwbuf);
+    return NULL;
+  }
+
+  char* user_name = NEW_C_HEAP_ARRAY(char, strlen(p->pw_name) + 1);
+  strcpy(user_name, p->pw_name);
+
+  FREE_C_HEAP_ARRAY(char, pwbuf);
+  return user_name;
+}
+
+// return the name of the user that owns the process identified by vmid.
+//
+// This method uses a slow directory search algorithm to find the backing
+// store file for the specified vmid and returns the user name, as determined
+// by the user name suffix of the hsperfdata_<username> directory name.
+//
+// the caller is expected to free the allocated memory.
+//
+static char* get_user_name_slow(int vmid, TRAPS) {
+
+  // short circuit the directory search if the process doesn't even exist.
+  if (kill(vmid, 0) == OS_ERR) {
+    if (errno == ESRCH) {
+      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Process not found");
+    }
+    else /* EPERM */ {
+      THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno));
+    }
+  }
+
+  // directory search
+  char* oldest_user = NULL;
+  time_t oldest_ctime = 0;
+
+  const char* tmpdirname = os::get_temp_directory();
+
+  DIR* tmpdirp = os::opendir(tmpdirname);
+
+  if (tmpdirp == NULL) {
+    return NULL;
+  }
+
+  // for each entry in the directory that matches the pattern hsperfdata_*,
+  // open the directory and check if the file for the given vmid exists.
+  // The file with the expected name and the latest creation date is used
+  // to determine the user name for the process id.
+  //
+  struct dirent* dentry;
+  char* tdbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(tmpdirname));
+  errno = 0;
+  while ((dentry = os::readdir(tmpdirp, (struct dirent *)tdbuf)) != NULL) {
+
+    // check if the directory entry is a hsperfdata file
+    if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
+      continue;
+    }
+
+    char* usrdir_name = NEW_C_HEAP_ARRAY(char,
+                              strlen(tmpdirname) + strlen(dentry->d_name) + 2);
+    strcpy(usrdir_name, tmpdirname);
+    strcat(usrdir_name, "/");
+    strcat(usrdir_name, dentry->d_name);
+
+    DIR* subdirp = os::opendir(usrdir_name);
+
+    if (subdirp == NULL) {
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
+      continue;
+    }
+
+    // Since we don't create the backing store files in directories
+    // pointed to by symbolic links, we also don't follow them when
+    // looking for the files. We check for a symbolic link after the
+    // call to opendir in order to eliminate a small window where the
+    // symlink can be exploited.
+    //
+    if (!is_directory_secure(usrdir_name)) {
+      FREE_C_HEAP_ARRAY(char, usrdir_name);
+      os::closedir(subdirp);
+      continue;
+    }
+
+    struct dirent* udentry;
+    char* udbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(usrdir_name));
+    errno = 0;
+    while ((udentry = os::readdir(subdirp, (struct dirent *)udbuf)) != NULL) {
+
+      if (filename_to_pid(udentry->d_name) == vmid) {
+        struct stat statbuf;
+        int result;
+
+        char* filename = NEW_C_HEAP_ARRAY(char,
+                            strlen(usrdir_name) + strlen(udentry->d_name) + 2);
+
+        strcpy(filename, usrdir_name);
+        strcat(filename, "/");
+        strcat(filename, udentry->d_name);
+
+        // don't follow symbolic links for the file
+        RESTARTABLE(::lstat(filename, &statbuf), result);
+        if (result == OS_ERR) {
+           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);
+          continue;
+        }
+
+        // compare and save filename with latest creation time
+        if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) {
+
+          if (statbuf.st_ctime > oldest_ctime) {
+            char* user = strchr(dentry->d_name, '_') + 1;
+
+            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
+            oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1);
+
+            strcpy(oldest_user, user);
+            oldest_ctime = statbuf.st_ctime;
+          }
+        }
+
+        FREE_C_HEAP_ARRAY(char, filename);
+      }
+    }
+    os::closedir(subdirp);
+    FREE_C_HEAP_ARRAY(char, udbuf);
+    FREE_C_HEAP_ARRAY(char, usrdir_name);
+  }
+  os::closedir(tmpdirp);
+  FREE_C_HEAP_ARRAY(char, tdbuf);
+
+  return(oldest_user);
+}
+
+// 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 the file name of the backing store file for the named
+// shared memory region for the given user name and vmid.
+//
+// the caller is expected to free the allocated memory.
+//
+static char* get_sharedmem_filename(const char* dirname, int vmid) {
+
+  // add 2 for the file separator and a null terminator.
+  size_t nbytes = strlen(dirname) + UINT_CHARS + 2;
+
+  char* name = NEW_C_HEAP_ARRAY(char, nbytes);
+  snprintf(name, nbytes, "%s/%d", dirname, vmid);
+
+  return name;
+}
+
+
+// remove file
+//
+// this method removes the file specified by the given path
+//
+static void remove_file(const char* path) {
+
+  int result;
+
+  // if the file is a directory, the following unlink will fail. since
+  // we don't expect to find directories in the user temp directory, we
+  // won't try to handle this situation. even if accidentially or
+  // maliciously planted, the directory's presence won't hurt anything.
+  //
+  RESTARTABLE(::unlink(path), result);
+  if (PrintMiscellaneous && Verbose && result == OS_ERR) {
+    if (errno != ENOENT) {
+      warning("Could not unlink shared memory backing"
+              " store file %s : %s\n", path, strerror(errno));
+    }
+  }
+}
+
+
+// remove file
+//
+// this method removes the file with the given file name in the
+// named directory.
+//
+static void remove_file(const char* dirname, const char* filename) {
+
+  size_t nbytes = strlen(dirname) + strlen(filename) + 2;
+  char* path = NEW_C_HEAP_ARRAY(char, nbytes);
+
+  strcpy(path, dirname);
+  strcat(path, "/");
+  strcat(path, filename);
+
+  remove_file(path);
+
+  FREE_C_HEAP_ARRAY(char, path);
+}
+
+
+// cleanup stale shared memory resources
+//
+// This method attempts to remove all stale shared memory files in
+// the named user temporary directory. It scans the named directory
+// for files matching the pattern ^$[0-9]*$. For each file found, the
+// process id is extracted from the file name and a test is run to
+// determine if the process is alive. If the process is not alive,
+// any stale file resources are removed.
+//
+static void cleanup_sharedmem_resources(const char* dirname) {
+
+  // open the user temp directory
+  DIR* dirp = os::opendir(dirname);
+
+  if (dirp == NULL) {
+    // directory doesn't exist, so there is nothing to cleanup
+    return;
+  }
+
+  if (!is_directory_secure(dirname)) {
+    // the directory is not a secure directory
+    return;
+  }
+
+  // for each entry in the directory that matches the expected file
+  // name pattern, determine if the file resources are stale and if
+  // so, remove the file resources. Note, instrumented HotSpot processes
+  // for this user may start and/or terminate during this search and
+  // remove or create new files in this directory. The behavior of this
+  // loop under these conditions is dependent upon the implementation of
+  // opendir/readdir.
+  //
+  struct dirent* entry;
+  char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(dirname));
+  errno = 0;
+  while ((entry = os::readdir(dirp, (struct dirent *)dbuf)) != NULL) {
+
+    pid_t pid = filename_to_pid(entry->d_name);
+
+    if (pid == 0) {
+
+      if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
+
+        // attempt to remove all unexpected files, except "." and ".."
+        remove_file(dirname, entry->d_name);
+      }
+
+      errno = 0;
+      continue;
+    }
+
+    // we now have a file name that converts to a valid integer
+    // that could represent a process id . if this process id
+    // matches the current process id or the process is not running,
+    // then remove the stale file resources.
+    //
+    // process liveness is detected by sending signal number 0 to
+    // the process id (see kill(2)). if kill determines that the
+    // process does not exist, then the file resources are removed.
+    // if kill determines that that we don't have permission to
+    // signal the process, then the file resources are assumed to
+    // be stale and are removed because the resources for such a
+    // process should be in a different user specific directory.
+    //
+    if ((pid == os::current_process_id()) ||
+        (kill(pid, 0) == OS_ERR && (errno == ESRCH || errno == EPERM))) {
+
+        remove_file(dirname, entry->d_name);
+    }
+    errno = 0;
+  }
+  os::closedir(dirp);
+  FREE_C_HEAP_ARRAY(char, dbuf);
+}
+
+// make the user specific temporary directory. Returns true if
+// the directory exists and is secure upon return. Returns false
+// if the directory exists but is either a symlink, is otherwise
+// insecure, or if an error occurred.
+//
+static bool make_user_tmp_dir(const char* dirname) {
+
+  // create the directory with 0755 permissions. note that the directory
+  // will be owned by euid::egid, which may not be the same as uid::gid.
+  //
+  if (mkdir(dirname, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) == OS_ERR) {
+    if (errno == EEXIST) {
+      // The directory already exists and was probably created by another
+      // JVM instance. However, this could also be the result of a
+      // deliberate symlink. Verify that the existing directory is safe.
+      //
+      if (!is_directory_secure(dirname)) {
+        // directory is not secure
+        if (PrintMiscellaneous && Verbose) {
+          warning("%s directory is insecure\n", dirname);
+        }
+        return false;
+      }
+    }
+    else {
+      // we encountered some other failure while attempting
+      // to create the directory
+      //
+      if (PrintMiscellaneous && Verbose) {
+        warning("could not create directory %s: %s\n",
+                dirname, strerror(errno));
+      }
+      return false;
+    }
+  }
+  return true;
+}
+
+// create the shared memory file resources
+//
+// This method creates the shared memory file with the given size
+// This method also creates the user specific temporary directory, if
+// it does not yet exist.
+//
+static int create_sharedmem_resources(const char* dirname, const char* filename, size_t size) {
+
+  // make the user temporary directory
+  if (!make_user_tmp_dir(dirname)) {
+    // could not make/find the directory or the found directory
+    // was not secure
+    return -1;
+  }
+
+  int result;
+
+  RESTARTABLE(::open(filename, O_RDWR|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE), result);
+  if (result == OS_ERR) {
+    if (PrintMiscellaneous && Verbose) {
+      warning("could not create file %s: %s\n", filename, strerror(errno));
+    }
+    return -1;
+  }
+
+  // save the file descriptor
+  int fd = result;
+
+  // set the file size
+  RESTARTABLE(::ftruncate(fd, (off_t)size), result);
+  if (result == OS_ERR) {
+    if (PrintMiscellaneous && Verbose) {
+      warning("could not set shared memory file size: %s\n", strerror(errno));
+    }
+    RESTARTABLE(::close(fd), result);
+    return -1;
+  }
+
+  // Verify that we have enough disk space for this file.
+  // We'll get random SIGBUS crashes on memory accesses if
+  // we don't.
+
+  for (size_t seekpos = 0; seekpos < size; seekpos += os::vm_page_size()) {
+    int zero_int = 0;
+    result = (int)os::seek_to_file_offset(fd, (jlong)(seekpos));
+    if (result == -1 ) break;
+    RESTARTABLE(::write(fd, &zero_int, 1), result);
+    if (result != 1) {
+      if (errno == ENOSPC) {
+        warning("Insufficient space for shared memory file:\n   %s\nTry using the -Djava.io.tmpdir= option to select an alternate temp location.\n", filename);
+      }
+      break;
+    }
+  }
+
+  if (result != -1) {
+    return fd;
+  } else {
+    RESTARTABLE(::close(fd), result);
+    return -1;
+  }
+}
+
+// open the shared memory file for the given user and vmid. returns
+// the file descriptor for the open file or -1 if the file could not
+// be opened.
+//
+static int open_sharedmem_file(const char* filename, int oflags, TRAPS) {
+
+  // open the file
+  int result;
+  RESTARTABLE(::open(filename, oflags), result);
+  if (result == OS_ERR) {
+    if (errno == ENOENT) {
+      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Process not found");
+    }
+    else if (errno == EACCES) {
+      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
+                  "Permission denied");
+    }
+    else {
+      THROW_MSG_0(vmSymbols::java_io_IOException(), strerror(errno));
+    }
+  }
+
+  return result;
+}
+
+// create a named shared memory region. returns the address of the
+// memory region on success or NULL on failure. A return value of
+// NULL will ultimately disable the shared memory feature.
+//
+// On Solaris and Bsd, the name space for shared memory objects
+// is the file system name space.
+//
+// A monitoring application attaching to a JVM does not need to know
+// the file system name of the shared memory object. However, it may
+// be convenient for applications to discover the existence of newly
+// created and terminating JVMs by watching the file system name space
+// for files being created or removed.
+//
+static char* mmap_create_shared(size_t size) {
+
+  int result;
+  int fd;
+  char* mapAddress;
+
+  int vmid = os::current_process_id();
+
+  char* user_name = get_user_name(geteuid());
+
+  if (user_name == NULL)
+    return NULL;
+
+  char* dirname = get_user_tmp_dir(user_name);
+  char* filename = get_sharedmem_filename(dirname, vmid);
+
+  // cleanup any stale shared memory files
+  cleanup_sharedmem_resources(dirname);
+
+  assert(((size > 0) && (size % os::vm_page_size() == 0)),
+         "unexpected PerfMemory region size");
+
+  fd = create_sharedmem_resources(dirname, filename, size);
+
+  FREE_C_HEAP_ARRAY(char, user_name);
+  FREE_C_HEAP_ARRAY(char, dirname);
+
+  if (fd == -1) {
+    FREE_C_HEAP_ARRAY(char, filename);
+    return NULL;
+  }
+
+  mapAddress = (char*)::mmap((char*)0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+
+  // attempt to close the file - restart it if it was interrupted,
+  // but ignore other failures
+  RESTARTABLE(::close(fd), result);
+  assert(result != OS_ERR, "could not close file");
+
+  if (mapAddress == MAP_FAILED) {
+    if (PrintMiscellaneous && Verbose) {
+      warning("mmap failed -  %s\n", strerror(errno));
+    }
+    remove_file(filename);
+    FREE_C_HEAP_ARRAY(char, filename);
+    return NULL;
+  }
+
+  // save the file name for use in delete_shared_memory()
+  backing_store_file_name = filename;
+
+  // clear the shared memory region
+  (void)::memset((void*) mapAddress, 0, size);
+
+  return mapAddress;
+}
+
+// release a named shared memory region
+//
+static void unmap_shared(char* addr, size_t bytes) {
+  os::release_memory(addr, bytes);
+}
+
+// create the PerfData memory region in shared memory.
+//
+static char* create_shared_memory(size_t size) {
+
+  // create the shared memory region.
+  return mmap_create_shared(size);
+}
+
+// delete the shared PerfData memory region
+//
+static void delete_shared_memory(char* addr, size_t size) {
+
+  // cleanup the persistent shared memory resources. since DestroyJavaVM does
+  // not support unloading of the JVM, unmapping of the memory resource is
+  // not performed. The memory will be reclaimed by the OS upon termination of
+  // the process. The backing store file is deleted from the file system.
+
+  assert(!PerfDisableSharedMem, "shouldn't be here");
+
+  if (backing_store_file_name != NULL) {
+    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);
+    backing_store_file_name = NULL;
+  }
+}
+
+// return the size of the file for the given file descriptor
+// or 0 if it is not a valid size for a shared memory file
+//
+static size_t sharedmem_filesize(int fd, TRAPS) {
+
+  struct stat statbuf;
+  int result;
+
+  RESTARTABLE(::fstat(fd, &statbuf), result);
+  if (result == OS_ERR) {
+    if (PrintMiscellaneous && Verbose) {
+      warning("fstat failed: %s\n", strerror(errno));
+    }
+    THROW_MSG_0(vmSymbols::java_io_IOException(),
+                "Could not determine PerfMemory size");
+  }
+
+  if ((statbuf.st_size == 0) ||
+     ((size_t)statbuf.st_size % os::vm_page_size() != 0)) {
+    THROW_MSG_0(vmSymbols::java_lang_Exception(),
+                "Invalid PerfMemory size");
+  }
+
+  return (size_t)statbuf.st_size;
+}
+
+// attach to a named shared memory region.
+//
+static void mmap_attach_shared(const char* user, int vmid, PerfMemory::PerfMemoryMode mode, char** addr, size_t* sizep, TRAPS) {
+
+  char* mapAddress;
+  int result;
+  int fd;
+  size_t size;
+  const char* luser = NULL;
+
+  int mmap_prot;
+  int file_flags;
+
+  ResourceMark rm;
+
+  // map the high level access mode to the appropriate permission
+  // constructs for the file and the shared memory mapping.
+  if (mode == PerfMemory::PERF_MODE_RO) {
+    mmap_prot = PROT_READ;
+    file_flags = O_RDONLY;
+  }
+  else if (mode == PerfMemory::PERF_MODE_RW) {
+#ifdef LATER
+    mmap_prot = PROT_READ | PROT_WRITE;
+    file_flags = O_RDWR;
+#else
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "Unsupported access mode");
+#endif
+  }
+  else {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "Illegal access mode");
+  }
+
+  if (user == NULL || strlen(user) == 0) {
+    luser = get_user_name(vmid, CHECK);
+  }
+  else {
+    luser = user;
+  }
+
+  if (luser == NULL) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "Could not map vmid to user Name");
+  }
+
+  char* dirname = get_user_tmp_dir(luser);
+
+  // since we don't follow symbolic links when creating the backing
+  // store file, we don't follow them when attaching either.
+  //
+  if (!is_directory_secure(dirname)) {
+    FREE_C_HEAP_ARRAY(char, dirname);
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "Process not found");
+  }
+
+  char* filename = get_sharedmem_filename(dirname, vmid);
+
+  // copy heap memory to resource memory. the open_sharedmem_file
+  // method below need to use the filename, but could throw an
+  // exception. using a resource array prevents the leak that
+  // would otherwise occur.
+  char* rfilename = NEW_RESOURCE_ARRAY(char, strlen(filename) + 1);
+  strcpy(rfilename, filename);
+
+  // free the c heap resources that are no longer needed
+  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);
+  assert(fd != OS_ERR, "unexpected value");
+
+  if (*sizep == 0) {
+    size = sharedmem_filesize(fd, CHECK);
+    assert(size != 0, "unexpected size");
+  }
+
+  mapAddress = (char*)::mmap((char*)0, size, mmap_prot, MAP_SHARED, fd, 0);
+
+  // attempt to close the file - restart if it gets interrupted,
+  // but ignore other failures
+  RESTARTABLE(::close(fd), result);
+  assert(result != OS_ERR, "could not close file");
+
+  if (mapAddress == MAP_FAILED) {
+    if (PrintMiscellaneous && Verbose) {
+      warning("mmap failed: %s\n", strerror(errno));
+    }
+    THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(),
+              "Could not map PerfMemory");
+  }
+
+  *addr = mapAddress;
+  *sizep = size;
+
+  if (PerfTraceMemOps) {
+    tty->print("mapped " SIZE_FORMAT " bytes for vmid %d at "
+               INTPTR_FORMAT "\n", size, vmid, (void*)mapAddress);
+  }
+}
+
+
+
+
+// create the PerfData memory region
+//
+// This method creates the memory region used to store performance
+// data for the JVM. The memory may be created in standard or
+// shared memory.
+//
+void PerfMemory::create_memory_region(size_t size) {
+
+  if (PerfDisableSharedMem) {
+    // do not share the memory for the performance data.
+    _start = create_standard_memory(size);
+  }
+  else {
+    _start = create_shared_memory(size);
+    if (_start == NULL) {
+
+      // creation of the shared memory region failed, attempt
+      // to create a contiguous, non-shared memory region instead.
+      //
+      if (PrintMiscellaneous && Verbose) {
+        warning("Reverting to non-shared PerfMemory region.\n");
+      }
+      PerfDisableSharedMem = true;
+      _start = create_standard_memory(size);
+    }
+  }
+
+  if (_start != NULL) _capacity = size;
+
+}
+
+// delete the PerfData memory region
+//
+// This method deletes the memory region used to store performance
+// data for the JVM. The memory region indicated by the <address, size>
+// tuple will be inaccessible after a call to this method.
+//
+void PerfMemory::delete_memory_region() {
+
+  assert((start() != NULL && capacity() > 0), "verify proper state");
+
+  // If user specifies PerfDataSaveFile, it will save the performance data
+  // to the specified file name no matter whether PerfDataSaveToFile is specified
+  // or not. In other word, -XX:PerfDataSaveFile=.. overrides flag
+  // -XX:+PerfDataSaveToFile.
+  if (PerfDataSaveToFile || PerfDataSaveFile != NULL) {
+    save_memory_to_file(start(), capacity());
+  }
+
+  if (PerfDisableSharedMem) {
+    delete_standard_memory(start(), capacity());
+  }
+  else {
+    delete_shared_memory(start(), capacity());
+  }
+}
+
+// attach to the PerfData memory region for another JVM
+//
+// This method returns an <address, size> tuple that points to
+// a memory buffer that is kept reasonably synchronized with
+// the PerfData memory region for the indicated JVM. This
+// buffer may be kept in synchronization via shared memory
+// or some other mechanism that keeps the buffer updated.
+//
+// If the JVM chooses not to support the attachability feature,
+// this method should throw an UnsupportedOperation exception.
+//
+// This implementation utilizes named shared memory to map
+// the indicated process's PerfData memory region into this JVMs
+// address space.
+//
+void PerfMemory::attach(const char* user, int vmid, PerfMemoryMode mode, char** addrp, size_t* sizep, TRAPS) {
+
+  if (vmid == 0 || vmid == os::current_process_id()) {
+     *addrp = start();
+     *sizep = capacity();
+     return;
+  }
+
+  mmap_attach_shared(user, vmid, mode, addrp, sizep, CHECK);
+}
+
+// detach from the PerfData memory region of another JVM
+//
+// This method detaches the PerfData memory region of another
+// JVM, specified as an <address, size> tuple of a buffer
+// in this process's address space. This method may perform
+// arbitrary actions to accomplish the detachment. The memory
+// region specified by <address, size> will be inaccessible after
+// a call to this method.
+//
+// If the JVM chooses not to support the attachability feature,
+// this method should throw an UnsupportedOperation exception.
+//
+// This implementation utilizes named shared memory to detach
+// the indicated process's PerfData memory region from this
+// process's address space.
+//
+void PerfMemory::detach(char* addr, size_t bytes, TRAPS) {
+
+  assert(addr != 0, "address sanity check");
+  assert(bytes > 0, "capacity sanity check");
+
+  if (PerfMemory::contains(addr) || PerfMemory::contains(addr + bytes - 1)) {
+    // prevent accidental detachment of this process's PerfMemory region
+    return;
+  }
+
+  unmap_shared(addr, bytes);
+}
+
+char* PerfMemory::backing_store_filename() {
+  return backing_store_file_name;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/stubRoutines_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "runtime/os.hpp"
+#include "runtime/stubRoutines.hpp"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/threadCritical_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "runtime/threadCritical.hpp"
+#include "thread_bsd.inline.hpp"
+
+// put OS-includes here
+# include <pthread.h>
+
+//
+// See threadCritical.hpp for details of this class.
+//
+
+static pthread_t             tc_owner = 0;
+static pthread_mutex_t       tc_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int                   tc_count = 0;
+
+void ThreadCritical::initialize() {
+}
+
+void ThreadCritical::release() {
+}
+
+ThreadCritical::ThreadCritical() {
+  pthread_t self = pthread_self();
+  if (self != tc_owner) {
+    int ret = pthread_mutex_lock(&tc_mutex);
+    guarantee(ret == 0, "fatal error with pthread_mutex_lock()");
+    assert(tc_count == 0, "Lock acquired with illegal reentry count.");
+    tc_owner = self;
+  }
+  tc_count++;
+}
+
+ThreadCritical::~ThreadCritical() {
+  assert(tc_owner == pthread_self(), "must have correct owner");
+  assert(tc_count > 0, "must have correct count");
+
+  tc_count--;
+  if (tc_count == 0) {
+    tc_owner = 0;
+    int ret = pthread_mutex_unlock(&tc_mutex);
+    guarantee(ret == 0, "fatal error with pthread_mutex_unlock()");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/thread_bsd.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef OS_BSD_VM_THREAD_BSD_INLINE_HPP
+#define OS_BSD_VM_THREAD_BSD_INLINE_HPP
+
+#include "runtime/atomic.hpp"
+#include "runtime/prefetch.hpp"
+#include "runtime/thread.hpp"
+#include "runtime/threadLocalStorage.hpp"
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "atomic_bsd_x86.inline.hpp"
+# include "orderAccess_bsd_x86.inline.hpp"
+# include "prefetch_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "atomic_bsd_zero.inline.hpp"
+# include "orderAccess_bsd_zero.inline.hpp"
+# include "prefetch_bsd_zero.inline.hpp"
+#endif
+
+// Contains inlined functions for class Thread and ThreadLocalStorage
+
+inline void ThreadLocalStorage::pd_invalidate_all() {} // nothing to do
+
+#endif // OS_BSD_VM_THREAD_BSD_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os/bsd/vm/vmError_bsd.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "runtime/arguments.hpp"
+#include "runtime/os.hpp"
+#include "runtime/thread.hpp"
+#include "utilities/vmError.hpp"
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <signal.h>
+
+void VMError::show_message_box(char *buf, int buflen) {
+  bool yes;
+  do {
+    error_string(buf, buflen);
+    int len = (int)strlen(buf);
+    char *p = &buf[len];
+
+    jio_snprintf(p, buflen - len,
+               "\n\n"
+               "Do you want to debug the problem?\n\n"
+               "To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " INTX_FORMAT " (" INTPTR_FORMAT ")\n"
+               "Enter 'yes' to launch gdb automatically (PATH must include gdb)\n"
+               "Otherwise, press RETURN to abort...",
+               os::current_process_id(), os::current_process_id(),
+               os::current_thread_id(), os::current_thread_id());
+
+    yes = os::message_box("Unexpected Error", buf);
+
+    if (yes) {
+      // yes, user asked VM to launch debugger
+      jio_snprintf(buf, buflen, "gdb /proc/%d/exe %d",
+                   os::current_process_id(), os::current_process_id());
+
+      os::fork_and_exec(buf);
+      yes = false;
+    }
+  } while (yes);
+}
+
+// Space for our "saved" signal flags and handlers
+static int resettedSigflags[2];
+static address resettedSighandler[2];
+
+static void save_signal(int idx, int sig)
+{
+  struct sigaction sa;
+  sigaction(sig, NULL, &sa);
+  resettedSigflags[idx]   = sa.sa_flags;
+  resettedSighandler[idx] = (sa.sa_flags & SA_SIGINFO)
+                              ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
+                              : CAST_FROM_FN_PTR(address, sa.sa_handler);
+}
+
+int VMError::get_resetted_sigflags(int sig) {
+  if(SIGSEGV == sig) {
+    return resettedSigflags[0];
+  } else if(SIGBUS == sig) {
+    return resettedSigflags[1];
+  }
+  return -1;
+}
+
+address VMError::get_resetted_sighandler(int sig) {
+  if(SIGSEGV == sig) {
+    return resettedSighandler[0];
+  } else if(SIGBUS == sig) {
+    return resettedSighandler[1];
+  }
+  return NULL;
+}
+
+static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
+  // unmask current signal
+  sigset_t newset;
+  sigemptyset(&newset);
+  sigaddset(&newset, sig);
+  sigprocmask(SIG_UNBLOCK, &newset, NULL);
+
+  VMError err(NULL, sig, NULL, info, ucVoid);
+  err.report_and_die();
+}
+
+void VMError::reset_signal_handlers() {
+  // Save sigflags for resetted signals
+  save_signal(0, SIGSEGV);
+  save_signal(1, SIGBUS);
+  os::signal(SIGSEGV, CAST_FROM_FN_PTR(void *, crash_handler));
+  os::signal(SIGBUS, CAST_FROM_FN_PTR(void *, crash_handler));
+}
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -22,8 +22,6 @@
  *
  */
 
-# define __STDC_FORMAT_MACROS
-
 // no precompiled headers
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
@@ -125,10 +123,6 @@
 # include <inttypes.h>
 # include <sys/ioctl.h>
 
-#ifdef AMD64
-#include <asm/vsyscall.h>
-#endif
-
 #define MAX_PATH    (2 * K)
 
 // for timer info max values which include all bits
@@ -2502,7 +2496,13 @@
   int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
   uintptr_t res = (uintptr_t) ::mmap(addr, size, prot,
                                    MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
-  return res != (uintptr_t) MAP_FAILED;
+  if (res != (uintptr_t) MAP_FAILED) {
+    if (UseNUMAInterleaving) {
+      numa_make_global(addr, size);
+    }
+    return true;
+  }
+  return false;
 }
 
 // Define MAP_HUGETLB here so we can build HotSpot on old systems.
@@ -2523,10 +2523,20 @@
       (uintptr_t) ::mmap(addr, size, prot,
                          MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_HUGETLB,
                          -1, 0);
-    return res != (uintptr_t) MAP_FAILED;
-  }
-
-  return commit_memory(addr, size, exec);
+    if (res != (uintptr_t) MAP_FAILED) {
+      if (UseNUMAInterleaving) {
+        numa_make_global(addr, size);
+      }
+      return true;
+    }
+    // Fall through and try to use small pages
+  }
+
+  if (commit_memory(addr, size, exec)) {
+    realign_memory(addr, size, alignment_hint);
+    return true;
+  }
+  return false;
 }
 
 void os::realign_memory(char *addr, size_t bytes, size_t alignment_hint) {
@@ -2588,8 +2598,17 @@
   int retval = -1;
 
 #if defined(IA32)
+# ifndef SYS_getcpu
+# define SYS_getcpu 318
+# endif
   retval = syscall(SYS_getcpu, &cpu, NULL, NULL);
 #elif defined(AMD64)
+// Unfortunately we have to bring all these macros here from vsyscall.h
+// to be able to compile on old linuxes.
+# define __NR_vgetcpu 2
+# define VSYSCALL_START (-10UL << 20)
+# define VSYSCALL_SIZE 1024
+# define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
   typedef long (*vgetcpu_t)(unsigned int *cpu, unsigned int *node, unsigned long *tcache);
   vgetcpu_t vgetcpu = (vgetcpu_t)VSYSCALL_ADDR(__NR_vgetcpu);
   retval = vgetcpu(&cpu, NULL, NULL);
@@ -3115,6 +3134,10 @@
      return NULL;
   }
 
+  if ((addr != NULL) && UseNUMAInterleaving) {
+    numa_make_global(addr, bytes);
+  }
+
   return addr;
 }
 
@@ -3870,14 +3893,19 @@
     }
 
     // We don't activate signal checker if libjsig is in place, we trust ourselves
-    // and if UserSignalHandler is installed all bets are off
+    // and if UserSignalHandler is installed all bets are off.
+    // Log that signal checking is off only if -verbose:jni is specified.
     if (CheckJNICalls) {
       if (libjsig_is_loaded) {
-        tty->print_cr("Info: libjsig is activated, all active signal checking is disabled");
+        if (PrintJNIResolving) {
+          tty->print_cr("Info: libjsig is activated, all active signal checking is disabled");
+        }
         check_signals = false;
       }
       if (AllowUserSignalHandlers) {
-        tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
+        if (PrintJNIResolving) {
+          tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
+        }
         check_signals = false;
       }
     }
@@ -4329,6 +4357,11 @@
   return online_cpus;
 }
 
+void os::set_native_thread_name(const char *name) {
+  // Not yet implemented.
+  return;
+}
+
 bool os::distribute_processes(uint length, uint* distribution) {
   // Not yet implemented.
   return false;
--- a/hotspot/src/os/posix/launcher/java_md.c	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/os/posix/launcher/java_md.c	Wed Oct 26 17:59:13 2011 -0700
@@ -41,14 +41,21 @@
 #include "version_comp.h"
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <pthread.h>
 #else
 #include <thread.h>
 #endif
 
+#ifdef __APPLE__
+#define JVM_DLL "libjvm.dylib"
+#define JAVA_DLL "libjava.dylib"
+#define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH"
+#else
 #define JVM_DLL "libjvm.so"
 #define JAVA_DLL "libjava.so"
+#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
+#endif
 
 #ifndef GAMMA   /* launcher.make defines ARCH */
 /*
@@ -423,10 +430,10 @@
        * If not on Solaris, assume only a single LD_LIBRARY_PATH
        * variable.
        */
-      runpath = getenv("LD_LIBRARY_PATH");
+      runpath = getenv(LD_LIBRARY_PATH);
 #endif /* __sun */
 
-#ifdef __linux
+#if defined(__linux__)
       /*
        * On linux, if a binary is running as sgid or suid, glibc sets
        * LD_LIBRARY_PATH to the empty string for security purposes.  (In
@@ -442,6 +449,22 @@
       if((getgid() != getegid()) || (getuid() != geteuid()) ) {
         return;
       }
+#elif defined(_ALLBSD_SOURCE)
+      /*
+       * On BSD, if a binary is running as sgid or suid, libc sets
+       * LD_LIBRARY_PATH to the empty string for security purposes.  (In
+       * contrast, on Solaris the LD_LIBRARY_PATH variable for a
+       * privileged binary does not lose its settings; but the dynamic
+       * linker does apply more scrutiny to the path.) The launcher uses
+       * the value of LD_LIBRARY_PATH to prevent an exec loop.
+       * Therefore, if we are running sgid or suid, this function's
+       * setting of LD_LIBRARY_PATH will be ineffective and we should
+       * return from the function now.  Getting the right libraries to
+       * be found must be handled through other mechanisms.
+       */
+      if(issetugid()) {
+        return;
+      }
 #endif
 
       /* runpath contains current effective LD_LIBRARY_PATH setting */
@@ -450,7 +473,7 @@
       new_runpath = JLI_MemAlloc( ((runpath!=NULL)?strlen(runpath):0) +
                               2*strlen(jrepath) + 2*strlen(arch) +
                               strlen(jvmpath) + 52);
-      newpath = new_runpath + strlen("LD_LIBRARY_PATH=");
+      newpath = new_runpath + strlen(LD_LIBRARY_PATH "=");
 
 
       /*
@@ -465,7 +488,7 @@
 
         /* jvmpath, ((running != wanted)?((wanted==64)?"/"LIBARCH64NAME:"/.."):""), */
 
-        sprintf(new_runpath, "LD_LIBRARY_PATH="
+        sprintf(new_runpath, LD_LIBRARY_PATH "="
                 "%s:"
                 "%s/lib/%s:"
                 "%s/../lib/%s",
@@ -792,7 +815,7 @@
 jboolean
 GetApplicationHome(char *buf, jint bufsize)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     char *execname = GetExecname();
     if (execname) {
         strncpy(buf, execname, bufsize-1);
@@ -1175,7 +1198,7 @@
 
 #endif /* __sun && i586 */
 
-#if defined(__linux__) && defined(i586)
+#if (defined(__linux__) || defined(_ALLBSD_SOURCE)) && defined(i586)
 
 /*
  * A utility method for asking the CPU about itself.
@@ -1452,6 +1475,39 @@
 
 #endif /* __linux__ && i586 */
 
+#if defined(_ALLBSD_SOURCE) && defined(i586)
+
+/* The definition of a server-class machine for bsd-i586 */
+jboolean
+bsd_i586_ServerClassMachine(void) {
+  jboolean            result            = JNI_FALSE;
+  /* How big is a server class machine? */
+  const unsigned long server_processors = 2UL;
+  const uint64_t      server_memory     = 2UL * GB;
+  /*
+   * We seem not to get our full complement of memory.
+   *     We allow some part (1/8?) of the memory to be "missing",
+   *     based on the sizes of DIMMs, and maybe graphics cards.
+   */
+  const uint64_t      missing_memory    = 256UL * MB;
+  const uint64_t      actual_memory     = physical_memory();
+
+  /* Is this a server class machine? */
+  if (actual_memory >= (server_memory - missing_memory)) {
+    const unsigned long actual_processors = physical_processors();
+    if (actual_processors >= server_processors) {
+      result = JNI_TRUE;
+    }
+  }
+  if (_launcher_debug) {
+    printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n",
+           (result == JNI_TRUE ? "true" : "false"));
+  }
+  return result;
+}
+
+#endif /* _ALLBSD_SOURCE && i586 */
+
 /* Dispatch to the platform-specific definition of "server-class" */
 jboolean
 ServerClassMachine(void) {
@@ -1466,6 +1522,8 @@
   result = solaris_i586_ServerClassMachine();
 #elif defined(__linux__) && defined(i586)
   result = linux_i586_ServerClassMachine();
+#elif defined(_ALLBSD_SOURCE) && defined(i586)
+  result = bsd_i586_ServerClassMachine();
 #else
   if (_launcher_debug) {
     printf("ServerClassMachine: returns default value of %s\n",
@@ -1821,7 +1879,7 @@
 int
 ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
     int rslt;
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     pthread_t tid;
     pthread_attr_t attr;
     pthread_attr_init(&attr);
--- a/hotspot/src/os/posix/launcher/launcher.script	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/os/posix/launcher/launcher.script	Wed Oct 26 17:59:13 2011 -0700
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
 
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -69,8 +69,8 @@
 #
 
 # Make sure the paths are fully specified, i.e. they must begin with /.
-SCRIPT=$(cd $(dirname $0) && pwd)/$(basename $0)
-RUNDIR=$(pwd)
+REL_MYDIR=`dirname $0`
+MYDIR=`cd $REL_MYDIR && pwd`
 
 # Look whether the user wants to run inside gdb
 case "$1" in
@@ -95,12 +95,9 @@
         ;;
 esac
 
-# Find out the absolute path to this script
-MYDIR=$(cd $(dirname $SCRIPT) && pwd)
-
 JDK=
 if [ "${ALT_JAVA_HOME}" = "" ]; then
-    source ${MYDIR}/jdkpath.sh
+    . ${MYDIR}/jdkpath.sh
 else 
     JDK=${ALT_JAVA_HOME%%/jre};
 fi
@@ -119,9 +116,6 @@
 JAVA_HOME=$JDK
 ARCH=@@LIBARCH@@
 
-# Find out the absolute path to this script
-MYDIR=$(cd $(dirname $SCRIPT) && pwd)
-
 SBP=${MYDIR}:${JRE}/lib/${ARCH}
 
 # Set up a suitable LD_LIBRARY_PATH
@@ -146,7 +140,7 @@
 fi
 
 GDBSRCDIR=$MYDIR
-BASEDIR=$(cd $MYDIR/../../.. && pwd)
+BASEDIR=`cd $MYDIR/../../.. && pwd`
 
 init_gdb() {
 # Create a gdb script in case we should run inside gdb
@@ -179,7 +173,7 @@
 	init_gdb
 # First find out what emacs version we're using, so that we can
 # use the new pretty GDB mode if emacs -version >= 22.1
-	case $($EMACS -version 2> /dev/null) in
+	case `$EMACS -version 2> /dev/null` in
 	    *GNU\ Emacs\ 2[23]*)
 	    emacs_gud_cmd="gdba"
 	    emacs_gud_args="--annotate=3"
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -669,6 +669,11 @@
   return true;
 }
 
+void os::set_native_thread_name(const char *name) {
+  // Not yet implemented.
+  return;
+}
+
 bool os::distribute_processes(uint length, uint* distribution) {
   bool result = false;
   // Find the processor id's of all the available CPUs.
@@ -2777,8 +2782,14 @@
 bool os::commit_memory(char* addr, size_t bytes, bool exec) {
   int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
   size_t size = bytes;
-  return
-     NULL != Solaris::mmap_chunk(addr, size, MAP_PRIVATE|MAP_FIXED, prot);
+  char *res = Solaris::mmap_chunk(addr, size, MAP_PRIVATE|MAP_FIXED, prot);
+  if (res != NULL) {
+    if (UseNUMAInterleaving) {
+      numa_make_global(addr, bytes);
+    }
+    return true;
+  }
+  return false;
 }
 
 bool os::commit_memory(char* addr, size_t bytes, size_t alignment_hint,
@@ -3389,12 +3400,11 @@
   return true;
 }
 
-char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
+char* os::reserve_memory_special(size_t size, char* addr, bool exec) {
   // "exec" is passed in but not used.  Creating the shared image for
   // the code cache doesn't have an SHM_X executable permission to check.
   assert(UseLargePages && UseISM, "only for ISM large pages");
 
-  size_t size = bytes;
   char* retAddr = NULL;
   int shmid;
   key_t ismKey;
@@ -3436,7 +3446,9 @@
     }
     return NULL;
   }
-
+  if ((retAddr != NULL) && UseNUMAInterleaving) {
+    numa_make_global(retAddr, size);
+  }
   return retAddr;
 }
 
@@ -4585,14 +4597,19 @@
   }
 
   // We don't activate signal checker if libjsig is in place, we trust ourselves
-  // and if UserSignalHandler is installed all bets are off
+  // and if UserSignalHandler is installed all bets are off.
+  // Log that signal checking is off only if -verbose:jni is specified.
   if (CheckJNICalls) {
     if (libjsig_is_loaded) {
-      tty->print_cr("Info: libjsig is activated, all active signal checking is disabled");
+      if (PrintJNIResolving) {
+        tty->print_cr("Info: libjsig is activated, all active signal checking is disabled");
+      }
       check_signals = false;
     }
     if (AllowUserSignalHandlers) {
-      tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
+      if (PrintJNIResolving) {
+        tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
+      }
       check_signals = false;
     }
   }
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -710,6 +710,11 @@
   }
 }
 
+void os::set_native_thread_name(const char *name) {
+  // Not yet implemented.
+  return;
+}
+
 bool os::distribute_processes(uint length, uint* distribution) {
   // Not yet implemented.
   return false;
@@ -2614,6 +2619,57 @@
 static HANDLE    _hProcess;
 static HANDLE    _hToken;
 
+// Container for NUMA node list info
+class NUMANodeListHolder {
+private:
+  int *_numa_used_node_list;  // allocated below
+  int _numa_used_node_count;
+
+  void free_node_list() {
+    if (_numa_used_node_list != NULL) {
+      FREE_C_HEAP_ARRAY(int, _numa_used_node_list);
+    }
+  }
+
+public:
+  NUMANodeListHolder() {
+    _numa_used_node_count = 0;
+    _numa_used_node_list = NULL;
+    // do rest of initialization in build routine (after function pointers are set up)
+  }
+
+  ~NUMANodeListHolder() {
+    free_node_list();
+  }
+
+  bool build() {
+    DWORD_PTR proc_aff_mask;
+    DWORD_PTR sys_aff_mask;
+    if (!GetProcessAffinityMask(GetCurrentProcess(), &proc_aff_mask, &sys_aff_mask)) return false;
+    ULONG highest_node_number;
+    if (!os::Kernel32Dll::GetNumaHighestNodeNumber(&highest_node_number)) return false;
+    free_node_list();
+    _numa_used_node_list = NEW_C_HEAP_ARRAY(int, highest_node_number + 1);
+    for (unsigned int i = 0; i <= highest_node_number; i++) {
+      ULONGLONG proc_mask_numa_node;
+      if (!os::Kernel32Dll::GetNumaNodeProcessorMask(i, &proc_mask_numa_node)) return false;
+      if ((proc_aff_mask & proc_mask_numa_node)!=0) {
+        _numa_used_node_list[_numa_used_node_count++] = i;
+      }
+    }
+    return (_numa_used_node_count > 1);
+  }
+
+  int get_count() {return _numa_used_node_count;}
+  int get_node_list_entry(int n) {
+    // for indexes out of range, returns -1
+    return (n < _numa_used_node_count ? _numa_used_node_list[n] : -1);
+  }
+
+} numa_node_list_holder;
+
+
+
 static size_t _large_page_size = 0;
 
 static bool resolve_functions_for_large_page_init() {
@@ -2653,6 +2709,153 @@
   _hToken = NULL;
 }
 
+static bool numa_interleaving_init() {
+  bool success = false;
+  bool use_numa_interleaving_specified = !FLAG_IS_DEFAULT(UseNUMAInterleaving);
+
+  // print a warning if UseNUMAInterleaving flag is specified on command line
+  bool warn_on_failure = use_numa_interleaving_specified;
+# define WARN(msg) if (warn_on_failure) { warning(msg); }
+
+  // NUMAInterleaveGranularity cannot be less than vm_allocation_granularity (or _large_page_size if using large pages)
+  size_t min_interleave_granularity = UseLargePages ? _large_page_size : os::vm_allocation_granularity();
+  NUMAInterleaveGranularity = align_size_up(NUMAInterleaveGranularity, min_interleave_granularity);
+
+  if (os::Kernel32Dll::NumaCallsAvailable()) {
+    if (numa_node_list_holder.build()) {
+      if (PrintMiscellaneous && Verbose) {
+        tty->print("NUMA UsedNodeCount=%d, namely ", numa_node_list_holder.get_count());
+        for (int i = 0; i < numa_node_list_holder.get_count(); i++) {
+          tty->print("%d ", numa_node_list_holder.get_node_list_entry(i));
+        }
+        tty->print("\n");
+      }
+      success = true;
+    } else {
+      WARN("Process does not cover multiple NUMA nodes.");
+    }
+  } else {
+    WARN("NUMA Interleaving is not supported by the operating system.");
+  }
+  if (!success) {
+    if (use_numa_interleaving_specified) WARN("...Ignoring UseNUMAInterleaving flag.");
+  }
+  return success;
+#undef WARN
+}
+
+// this routine is used whenever we need to reserve a contiguous VA range
+// but we need to make separate VirtualAlloc calls for each piece of the range
+// Reasons for doing this:
+//  * UseLargePagesIndividualAllocation was set (normally only needed on WS2003 but possible to be set otherwise)
+//  * UseNUMAInterleaving requires a separate node for each piece
+static char* allocate_pages_individually(size_t bytes, char* addr, DWORD flags, DWORD prot,
+                                         bool should_inject_error=false) {
+  char * p_buf;
+  // note: at setup time we guaranteed that NUMAInterleaveGranularity was aligned up to a page size
+  size_t page_size = UseLargePages ? _large_page_size : os::vm_allocation_granularity();
+  size_t chunk_size = UseNUMAInterleaving ? NUMAInterleaveGranularity : page_size;
+
+  // first reserve enough address space in advance since we want to be
+  // able to break a single contiguous virtual address range into multiple
+  // large page commits but WS2003 does not allow reserving large page space
+  // so we just use 4K pages for reserve, this gives us a legal contiguous
+  // address space. then we will deallocate that reservation, and re alloc
+  // using large pages
+  const size_t size_of_reserve = bytes + chunk_size;
+  if (bytes > size_of_reserve) {
+    // Overflowed.
+    return NULL;
+  }
+  p_buf = (char *) VirtualAlloc(addr,
+                                size_of_reserve,  // size of Reserve
+                                MEM_RESERVE,
+                                PAGE_READWRITE);
+  // If reservation failed, return NULL
+  if (p_buf == NULL) return NULL;
+
+  os::release_memory(p_buf, bytes + chunk_size);
+
+  // we still need to round up to a page boundary (in case we are using large pages)
+  // but not to a chunk boundary (in case InterleavingGranularity doesn't align with page size)
+  // instead we handle this in the bytes_to_rq computation below
+  p_buf = (char *) align_size_up((size_t)p_buf, page_size);
+
+  // now go through and allocate one chunk at a time until all bytes are
+  // allocated
+  size_t  bytes_remaining = bytes;
+  // An overflow of align_size_up() would have been caught above
+  // in the calculation of size_of_reserve.
+  char * next_alloc_addr = p_buf;
+  HANDLE hProc = GetCurrentProcess();
+
+#ifdef ASSERT
+  // Variable for the failure injection
+  long ran_num = os::random();
+  size_t fail_after = ran_num % bytes;
+#endif
+
+  int count=0;
+  while (bytes_remaining) {
+    // select bytes_to_rq to get to the next chunk_size boundary
+
+    size_t bytes_to_rq = MIN2(bytes_remaining, chunk_size - ((size_t)next_alloc_addr % chunk_size));
+    // Note allocate and commit
+    char * p_new;
+
+#ifdef ASSERT
+    bool inject_error_now = should_inject_error && (bytes_remaining <= fail_after);
+#else
+    const bool inject_error_now = false;
+#endif
+
+    if (inject_error_now) {
+      p_new = NULL;
+    } else {
+      if (!UseNUMAInterleaving) {
+        p_new = (char *) VirtualAlloc(next_alloc_addr,
+                                      bytes_to_rq,
+                                      flags,
+                                      prot);
+      } else {
+        // get the next node to use from the used_node_list
+        assert(numa_node_list_holder.get_count() > 0, "Multiple NUMA nodes expected");
+        DWORD node = numa_node_list_holder.get_node_list_entry(count % numa_node_list_holder.get_count());
+        p_new = (char *)os::Kernel32Dll::VirtualAllocExNuma(hProc,
+                                                            next_alloc_addr,
+                                                            bytes_to_rq,
+                                                            flags,
+                                                            prot,
+                                                            node);
+      }
+    }
+
+    if (p_new == NULL) {
+      // Free any allocated pages
+      if (next_alloc_addr > p_buf) {
+        // Some memory was committed so release it.
+        size_t bytes_to_release = bytes - bytes_remaining;
+        os::release_memory(p_buf, bytes_to_release);
+      }
+#ifdef ASSERT
+      if (should_inject_error) {
+        if (TracePageSizes && Verbose) {
+          tty->print_cr("Reserving pages individually failed.");
+        }
+      }
+#endif
+      return NULL;
+    }
+    bytes_remaining -= bytes_to_rq;
+    next_alloc_addr += bytes_to_rq;
+    count++;
+  }
+  // made it this far, success
+  return p_buf;
+}
+
+
+
 void os::large_page_init() {
   if (!UseLargePages) return;
 
@@ -2722,9 +2925,30 @@
   assert((size_t)addr % os::vm_allocation_granularity() == 0,
          "reserve alignment");
   assert(bytes % os::vm_allocation_granularity() == 0, "reserve block size");
-  char* res = (char*)VirtualAlloc(addr, bytes, MEM_RESERVE, PAGE_READWRITE);
+  char* res;
+  // note that if UseLargePages is on, all the areas that require interleaving
+  // will go thru reserve_memory_special rather than thru here.
+  bool use_individual = (UseNUMAInterleaving && !UseLargePages);
+  if (!use_individual) {
+    res = (char*)VirtualAlloc(addr, bytes, MEM_RESERVE, PAGE_READWRITE);
+  } else {
+    elapsedTimer reserveTimer;
+    if( Verbose && PrintMiscellaneous ) reserveTimer.start();
+    // in numa interleaving, we have to allocate pages individually
+    // (well really chunks of NUMAInterleaveGranularity size)
+    res = allocate_pages_individually(bytes, addr, MEM_RESERVE, PAGE_READWRITE);
+    if (res == NULL) {
+      warning("NUMA page allocation failed");
+    }
+    if( Verbose && PrintMiscellaneous ) {
+      reserveTimer.stop();
+      tty->print_cr("reserve_memory of %Ix bytes took %ld ms (%ld ticks)", bytes,
+                    reserveTimer.milliseconds(), reserveTimer.ticks());
+    }
+  }
   assert(res == NULL || addr == NULL || addr == res,
          "Unexpected address from reserve.");
+
   return res;
 }
 
@@ -2754,92 +2978,27 @@
 char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
 
   const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
-
-  if (UseLargePagesIndividualAllocation) {
+  const DWORD flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
+
+  // with large pages, there are two cases where we need to use Individual Allocation
+  // 1) the UseLargePagesIndividualAllocation flag is set (set by default on WS2003)
+  // 2) NUMA Interleaving is enabled, in which case we use a different node for each page
+  if (UseLargePagesIndividualAllocation || UseNUMAInterleaving) {
     if (TracePageSizes && Verbose) {
        tty->print_cr("Reserving large pages individually.");
     }
-    char * p_buf;
-    // first reserve enough address space in advance since we want to be
-    // able to break a single contiguous virtual address range into multiple
-    // large page commits but WS2003 does not allow reserving large page space
-    // so we just use 4K pages for reserve, this gives us a legal contiguous
-    // address space. then we will deallocate that reservation, and re alloc
-    // using large pages
-    const size_t size_of_reserve = bytes + _large_page_size;
-    if (bytes > size_of_reserve) {
-      // Overflowed.
-      warning("Individually allocated large pages failed, "
-        "use -XX:-UseLargePagesIndividualAllocation to turn off");
+    char * p_buf = allocate_pages_individually(bytes, addr, flags, prot, LargePagesIndividualAllocationInjectError);
+    if (p_buf == NULL) {
+      // give an appropriate warning message
+      if (UseNUMAInterleaving) {
+        warning("NUMA large page allocation failed, UseLargePages flag ignored");
+      }
+      if (UseLargePagesIndividualAllocation) {
+        warning("Individually allocated large pages failed, "
+                "use -XX:-UseLargePagesIndividualAllocation to turn off");
+      }
       return NULL;
     }
-    p_buf = (char *) VirtualAlloc(addr,
-                                 size_of_reserve,  // size of Reserve
-                                 MEM_RESERVE,
-                                 PAGE_READWRITE);
-    // If reservation failed, return NULL
-    if (p_buf == NULL) return NULL;
-
-    release_memory(p_buf, bytes + _large_page_size);
-    // round up to page boundary.  If the size_of_reserve did not
-    // overflow and the reservation did not fail, this align up
-    // should not overflow.
-    p_buf = (char *) align_size_up((size_t)p_buf, _large_page_size);
-
-    // now go through and allocate one page at a time until all bytes are
-    // allocated
-    size_t  bytes_remaining = align_size_up(bytes, _large_page_size);
-    // An overflow of align_size_up() would have been caught above
-    // in the calculation of size_of_reserve.
-    char * next_alloc_addr = p_buf;
-
-#ifdef ASSERT
-    // Variable for the failure injection
-    long ran_num = os::random();
-    size_t fail_after = ran_num % bytes;
-#endif
-
-    while (bytes_remaining) {
-      size_t bytes_to_rq = MIN2(bytes_remaining, _large_page_size);
-      // Note allocate and commit
-      char * p_new;
-
-#ifdef ASSERT
-      bool inject_error = LargePagesIndividualAllocationInjectError &&
-          (bytes_remaining <= fail_after);
-#else
-      const bool inject_error = false;
-#endif
-
-      if (inject_error) {
-        p_new = NULL;
-      } else {
-        p_new = (char *) VirtualAlloc(next_alloc_addr,
-                                    bytes_to_rq,
-                                    MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES,
-                                    prot);
-      }
-
-      if (p_new == NULL) {
-        // Free any allocated pages
-        if (next_alloc_addr > p_buf) {
-          // Some memory was committed so release it.
-          size_t bytes_to_release = bytes - bytes_remaining;
-          release_memory(p_buf, bytes_to_release);
-        }
-#ifdef ASSERT
-        if (UseLargePagesIndividualAllocation &&
-            LargePagesIndividualAllocationInjectError) {
-          if (TracePageSizes && Verbose) {
-             tty->print_cr("Reserving large pages individually failed.");
-          }
-        }
-#endif
-        return NULL;
-      }
-      bytes_remaining -= bytes_to_rq;
-      next_alloc_addr += bytes_to_rq;
-    }
 
     return p_buf;
 
@@ -2867,14 +3026,43 @@
   assert(bytes % os::vm_page_size() == 0, "commit in page-sized chunks");
   // Don't attempt to print anything if the OS call fails. We're
   // probably low on resources, so the print itself may cause crashes.
-  bool result = VirtualAlloc(addr, bytes, MEM_COMMIT, PAGE_READWRITE) != 0;
-  if (result != NULL && exec) {
-    DWORD oldprot;
-    // Windows doc says to use VirtualProtect to get execute permissions
-    return VirtualProtect(addr, bytes, PAGE_EXECUTE_READWRITE, &oldprot) != 0;
+
+  // unless we have NUMAInterleaving enabled, the range of a commit
+  // is always within a reserve covered by a single VirtualAlloc
+  // in that case we can just do a single commit for the requested size
+  if (!UseNUMAInterleaving) {
+    if (VirtualAlloc(addr, bytes, MEM_COMMIT, PAGE_READWRITE) == NULL) return false;
+    if (exec) {
+      DWORD oldprot;
+      // Windows doc says to use VirtualProtect to get execute permissions
+      if (!VirtualProtect(addr, bytes, PAGE_EXECUTE_READWRITE, &oldprot)) return false;
+    }
+    return true;
   } else {
-    return result;
-  }
+
+    // when NUMAInterleaving is enabled, the commit might cover a range that
+    // came from multiple VirtualAlloc reserves (using allocate_pages_individually).
+    // VirtualQuery can help us determine that.  The RegionSize that VirtualQuery
+    // returns represents the number of bytes that can be committed in one step.
+    size_t bytes_remaining = bytes;
+    char * next_alloc_addr = addr;
+    while (bytes_remaining > 0) {
+      MEMORY_BASIC_INFORMATION alloc_info;
+      VirtualQuery(next_alloc_addr, &alloc_info, sizeof(alloc_info));
+      size_t bytes_to_rq = MIN2(bytes_remaining, (size_t)alloc_info.RegionSize);
+      if (VirtualAlloc(next_alloc_addr, bytes_to_rq, MEM_COMMIT, PAGE_READWRITE) == NULL)
+        return false;
+      if (exec) {
+        DWORD oldprot;
+        if (!VirtualProtect(next_alloc_addr, bytes_to_rq, PAGE_EXECUTE_READWRITE, &oldprot))
+          return false;
+      }
+      bytes_remaining -= bytes_to_rq;
+      next_alloc_addr += bytes_to_rq;
+    }
+  }
+  // if we made it this far, return true
+  return true;
 }
 
 bool os::commit_memory(char* addr, size_t size, size_t alignment_hint,
@@ -2948,14 +3136,21 @@
 void os::numa_make_global(char *addr, size_t bytes)    { }
 void os::numa_make_local(char *addr, size_t bytes, int lgrp_hint)    { }
 bool os::numa_topology_changed()                       { return false; }
-size_t os::numa_get_groups_num()                       { return 1; }
+size_t os::numa_get_groups_num()                       { return MAX2(numa_node_list_holder.get_count(), 1); }
 int os::numa_get_group_id()                            { return 0; }
 size_t os::numa_get_leaf_groups(int *ids, size_t size) {
-  if (size > 0) {
+  if (numa_node_list_holder.get_count() == 0 && size > 0) {
+    // Provide an answer for UMA systems
     ids[0] = 0;
     return 1;
-  }
-  return 0;
+  } else {
+    // check for size bigger than actual groups_num
+    size = MIN2(size, numa_get_groups_num());
+    for (int i = 0; i < (int)size; i++) {
+      ids[i] = numa_node_list_holder.get_node_list_entry(i);
+    }
+    return size;
+  }
 }
 
 bool os::get_page_info(char *start, page_info* info) {
@@ -3480,7 +3675,7 @@
     if(Verbose && PrintMiscellaneous)
       tty->print("[Memory Serialize  Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page);
 #endif
-}
+  }
 
   os::large_page_init();
 
@@ -3584,7 +3779,13 @@
   prio_init();
 
   if (UseNUMA && !ForceNUMA) {
-    UseNUMA = false; // Currently unsupported.
+    UseNUMA = false; // We don't fully support this yet
+  }
+
+  if (UseNUMAInterleaving) {
+    // first check whether this Windows OS supports VirtualAllocExNuma, if not ignore this flag
+    bool success = numa_interleaving_init();
+    if (!success) UseNUMAInterleaving = false;
   }
 
   return JNI_OK;
@@ -4758,7 +4959,14 @@
 
 // Kernel32 API
 typedef SIZE_T (WINAPI* GetLargePageMinimum_Fn)(void);
+typedef LPVOID (WINAPI *VirtualAllocExNuma_Fn) (HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD);
+typedef BOOL (WINAPI *GetNumaHighestNodeNumber_Fn) (PULONG);
+typedef BOOL (WINAPI *GetNumaNodeProcessorMask_Fn) (UCHAR, PULONGLONG);
+
 GetLargePageMinimum_Fn      os::Kernel32Dll::_GetLargePageMinimum = NULL;
+VirtualAllocExNuma_Fn       os::Kernel32Dll::_VirtualAllocExNuma = NULL;
+GetNumaHighestNodeNumber_Fn os::Kernel32Dll::_GetNumaHighestNodeNumber = NULL;
+GetNumaNodeProcessorMask_Fn os::Kernel32Dll::_GetNumaNodeProcessorMask = NULL;
 BOOL                        os::Kernel32Dll::initialized = FALSE;
 SIZE_T os::Kernel32Dll::GetLargePageMinimum() {
   assert(initialized && _GetLargePageMinimum != NULL,
@@ -4773,16 +4981,53 @@
   return _GetLargePageMinimum != NULL;
 }
 
+BOOL os::Kernel32Dll::NumaCallsAvailable() {
+  if (!initialized) {
+    initialize();
+  }
+  return _VirtualAllocExNuma != NULL;
+}
+
+LPVOID os::Kernel32Dll::VirtualAllocExNuma(HANDLE hProc, LPVOID addr, SIZE_T bytes, DWORD flags, DWORD prot, DWORD node) {
+  assert(initialized && _VirtualAllocExNuma != NULL,
+    "NUMACallsAvailable() not yet called");
+
+  return _VirtualAllocExNuma(hProc, addr, bytes, flags, prot, node);
+}
+
+BOOL os::Kernel32Dll::GetNumaHighestNodeNumber(PULONG ptr_highest_node_number) {
+  assert(initialized && _GetNumaHighestNodeNumber != NULL,
+    "NUMACallsAvailable() not yet called");
+
+  return _GetNumaHighestNodeNumber(ptr_highest_node_number);
+}
+
+BOOL os::Kernel32Dll::GetNumaNodeProcessorMask(UCHAR node, PULONGLONG proc_mask) {
+  assert(initialized && _GetNumaNodeProcessorMask != NULL,
+    "NUMACallsAvailable() not yet called");
+
+  return _GetNumaNodeProcessorMask(node, proc_mask);
+}
+
+
+void os::Kernel32Dll::initializeCommon() {
+  if (!initialized) {
+    HMODULE handle = ::GetModuleHandle("Kernel32.dll");
+    assert(handle != NULL, "Just check");
+    _GetLargePageMinimum = (GetLargePageMinimum_Fn)::GetProcAddress(handle, "GetLargePageMinimum");
+    _VirtualAllocExNuma = (VirtualAllocExNuma_Fn)::GetProcAddress(handle, "VirtualAllocExNuma");
+    _GetNumaHighestNodeNumber = (GetNumaHighestNodeNumber_Fn)::GetProcAddress(handle, "GetNumaHighestNodeNumber");
+    _GetNumaNodeProcessorMask = (GetNumaNodeProcessorMask_Fn)::GetProcAddress(handle, "GetNumaNodeProcessorMask");
+    initialized = TRUE;
+  }
+}
+
+
 
 #ifndef JDK6_OR_EARLIER
 
 void os::Kernel32Dll::initialize() {
-  if (!initialized) {
-    HMODULE handle = ::GetModuleHandle("Kernel32.dll");
-    assert(handle != NULL, "Just check");
-    _GetLargePageMinimum = (GetLargePageMinimum_Fn)::GetProcAddress(handle, "GetLargePageMinimum");
-    initialized = TRUE;
-  }
+  initializeCommon();
 }
 
 
@@ -4887,18 +5132,19 @@
 Module32Next_Fn             os::Kernel32Dll::_Module32Next = NULL;
 GetNativeSystemInfo_Fn      os::Kernel32Dll::_GetNativeSystemInfo = NULL;
 
+
 void os::Kernel32Dll::initialize() {
   if (!initialized) {
     HMODULE handle = ::GetModuleHandle("Kernel32.dll");
     assert(handle != NULL, "Just check");
 
     _SwitchToThread = (SwitchToThread_Fn)::GetProcAddress(handle, "SwitchToThread");
-    _GetLargePageMinimum = (GetLargePageMinimum_Fn)::GetProcAddress(handle, "GetLargePageMinimum");
     _CreateToolhelp32Snapshot = (CreateToolhelp32Snapshot_Fn)
       ::GetProcAddress(handle, "CreateToolhelp32Snapshot");
     _Module32First = (Module32First_Fn)::GetProcAddress(handle, "Module32First");
     _Module32Next = (Module32Next_Fn)::GetProcAddress(handle, "Module32Next");
     _GetNativeSystemInfo = (GetNativeSystemInfo_Fn)::GetProcAddress(handle, "GetNativeSystemInfo");
+    initializeCommon();  // resolve the functions that always need resolving
 
     initialized = TRUE;
   }
@@ -4964,6 +5210,8 @@
   _GetNativeSystemInfo(lpSystemInfo);
 }
 
+
+
 // PSAPI API
 
 
--- a/hotspot/src/os/windows/vm/os_windows.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/os/windows/vm/os_windows.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -173,13 +173,25 @@
   static BOOL GetNativeSystemInfoAvailable();
   static void GetNativeSystemInfo(LPSYSTEM_INFO);
 
+  // NUMA calls
+  static BOOL NumaCallsAvailable();
+  static LPVOID VirtualAllocExNuma(HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD);
+  static BOOL GetNumaHighestNodeNumber(PULONG);
+  static BOOL GetNumaNodeProcessorMask(UCHAR, PULONGLONG);
+
 private:
   // GetLargePageMinimum available on Windows Vista/Windows Server 2003
   // and later
+  // NUMA calls available Windows Vista/WS2008 and later
+
   static SIZE_T (WINAPI *_GetLargePageMinimum)(void);
+  static LPVOID (WINAPI *_VirtualAllocExNuma) (HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD);
+  static BOOL (WINAPI *_GetNumaHighestNodeNumber) (PULONG);
+  static BOOL (WINAPI *_GetNumaNodeProcessorMask) (UCHAR, PULONGLONG);
   static BOOL initialized;
 
   static void initialize();
+  static void initializeCommon();
 
 #ifdef JDK6_OR_EARLIER
 private:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/assembler_bsd_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "asm/assembler.hpp"
+#include "assembler_x86.inline.hpp"
+#include "runtime/os.hpp"
+#include "runtime/threadLocalStorage.hpp"
+
+#ifndef _LP64
+void MacroAssembler::int3() {
+  call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
+}
+
+void MacroAssembler::get_thread(Register thread) {
+  movl(thread, rsp);
+  shrl(thread, PAGE_SHIFT);
+
+  ExternalAddress tls_base((address)ThreadLocalStorage::sp_map_addr());
+  Address index(noreg, thread, Address::times_4);
+  ArrayAddress tls(tls_base, index);
+
+  movptr(thread, tls);
+}
+#else
+void MacroAssembler::int3() {
+  call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
+}
+
+void MacroAssembler::get_thread(Register thread) {
+  // call pthread_getspecific
+  // void * pthread_getspecific(pthread_key_t key);
+   if (thread != rax) {
+     push(rax);
+   }
+   push(rdi);
+   push(rsi);
+   push(rdx);
+   push(rcx);
+   push(r8);
+   push(r9);
+   push(r10);
+   // XXX
+   mov(r10, rsp);
+   andq(rsp, -16);
+   push(r10);
+   push(r11);
+
+   movl(rdi, ThreadLocalStorage::thread_index());
+   call(RuntimeAddress(CAST_FROM_FN_PTR(address, pthread_getspecific)));
+
+   pop(r11);
+   pop(rsp);
+   pop(r10);
+   pop(r9);
+   pop(r8);
+   pop(rcx);
+   pop(rdx);
+   pop(rsi);
+   pop(rdi);
+   if (thread != rax) {
+       mov(thread, rax);
+       pop(rax);
+   }
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/atomic_bsd_x86.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef OS_CPU_BSD_X86_VM_ATOMIC_BSD_X86_INLINE_HPP
+#define OS_CPU_BSD_X86_VM_ATOMIC_BSD_X86_INLINE_HPP
+
+#include "orderAccess_bsd_x86.inline.hpp"
+#include "runtime/atomic.hpp"
+#include "runtime/os.hpp"
+#include "vm_version_x86.hpp"
+
+// Implementation of class atomic
+
+inline void Atomic::store    (jbyte    store_value, jbyte*    dest) { *dest = store_value; }
+inline void Atomic::store    (jshort   store_value, jshort*   dest) { *dest = store_value; }
+inline void Atomic::store    (jint     store_value, jint*     dest) { *dest = store_value; }
+inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; }
+inline void Atomic::store_ptr(void*    store_value, void*     dest) { *(void**)dest = store_value; }
+
+inline void Atomic::store    (jbyte    store_value, volatile jbyte*    dest) { *dest = store_value; }
+inline void Atomic::store    (jshort   store_value, volatile jshort*   dest) { *dest = store_value; }
+inline void Atomic::store    (jint     store_value, volatile jint*     dest) { *dest = store_value; }
+inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; }
+inline void Atomic::store_ptr(void*    store_value, volatile void*     dest) { *(void* volatile *)dest = store_value; }
+
+
+// Adding a lock prefix to an instruction on MP machine
+#define LOCK_IF_MP(mp) "cmp $0, " #mp "; je 1f; lock; 1: "
+
+inline jint     Atomic::add    (jint     add_value, volatile jint*     dest) {
+  jint addend = add_value;
+  int mp = os::is_MP();
+  __asm__ volatile (  LOCK_IF_MP(%3) "xaddl %0,(%2)"
+                    : "=r" (addend)
+                    : "0" (addend), "r" (dest), "r" (mp)
+                    : "cc", "memory");
+  return addend + add_value;
+}
+
+inline void Atomic::inc    (volatile jint*     dest) {
+  int mp = os::is_MP();
+  __asm__ volatile (LOCK_IF_MP(%1) "addl $1,(%0)" :
+                    : "r" (dest), "r" (mp) : "cc", "memory");
+}
+
+inline void Atomic::inc_ptr(volatile void*     dest) {
+  inc_ptr((volatile intptr_t*)dest);
+}
+
+inline void Atomic::dec    (volatile jint*     dest) {
+  int mp = os::is_MP();
+  __asm__ volatile (LOCK_IF_MP(%1) "subl $1,(%0)" :
+                    : "r" (dest), "r" (mp) : "cc", "memory");
+}
+
+inline void Atomic::dec_ptr(volatile void*     dest) {
+  dec_ptr((volatile intptr_t*)dest);
+}
+
+inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
+  __asm__ volatile (  "xchgl (%2),%0"
+                    : "=r" (exchange_value)
+                    : "0" (exchange_value), "r" (dest)
+                    : "memory");
+  return exchange_value;
+}
+
+inline void*    Atomic::xchg_ptr(void*    exchange_value, volatile void*     dest) {
+  return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
+}
+
+
+inline jint     Atomic::cmpxchg    (jint     exchange_value, volatile jint*     dest, jint     compare_value) {
+  int mp = os::is_MP();
+  __asm__ volatile (LOCK_IF_MP(%4) "cmpxchgl %1,(%3)"
+                    : "=a" (exchange_value)
+                    : "r" (exchange_value), "a" (compare_value), "r" (dest), "r" (mp)
+                    : "cc", "memory");
+  return exchange_value;
+}
+
+#ifdef AMD64
+inline void Atomic::store    (jlong    store_value, jlong*    dest) { *dest = store_value; }
+inline void Atomic::store    (jlong    store_value, volatile jlong*    dest) { *dest = store_value; }
+
+inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
+  intptr_t addend = add_value;
+  bool mp = os::is_MP();
+  __asm__ __volatile__ (LOCK_IF_MP(%3) "xaddq %0,(%2)"
+                        : "=r" (addend)
+                        : "0" (addend), "r" (dest), "r" (mp)
+                        : "cc", "memory");
+  return addend + add_value;
+}
+
+inline void*    Atomic::add_ptr(intptr_t add_value, volatile void*     dest) {
+  return (void*)add_ptr(add_value, (volatile intptr_t*)dest);
+}
+
+inline void Atomic::inc_ptr(volatile intptr_t* dest) {
+  bool mp = os::is_MP();
+  __asm__ __volatile__ (LOCK_IF_MP(%1) "addq $1,(%0)"
+                        :
+                        : "r" (dest), "r" (mp)
+                        : "cc", "memory");
+}
+
+inline void Atomic::dec_ptr(volatile intptr_t* dest) {
+  bool mp = os::is_MP();
+  __asm__ __volatile__ (LOCK_IF_MP(%1) "subq $1,(%0)"
+                        :
+                        : "r" (dest), "r" (mp)
+                        : "cc", "memory");
+}
+
+inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
+  __asm__ __volatile__ ("xchgq (%2),%0"
+                        : "=r" (exchange_value)
+                        : "0" (exchange_value), "r" (dest)
+                        : "memory");
+  return exchange_value;
+}
+
+inline jlong    Atomic::cmpxchg    (jlong    exchange_value, volatile jlong*    dest, jlong    compare_value) {
+  bool mp = os::is_MP();
+  __asm__ __volatile__ (LOCK_IF_MP(%4) "cmpxchgq %1,(%3)"
+                        : "=a" (exchange_value)
+                        : "r" (exchange_value), "a" (compare_value), "r" (dest), "r" (mp)
+                        : "cc", "memory");
+  return exchange_value;
+}
+
+inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) {
+  return (intptr_t)cmpxchg((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value);
+}
+
+inline void*    Atomic::cmpxchg_ptr(void*    exchange_value, volatile void*     dest, void*    compare_value) {
+  return (void*)cmpxchg((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value);
+}
+
+inline jlong Atomic::load(volatile jlong* src) { return *src; }
+
+#else // !AMD64
+
+inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
+  return (intptr_t)Atomic::add((jint)add_value, (volatile jint*)dest);
+}
+
+inline void*    Atomic::add_ptr(intptr_t add_value, volatile void*     dest) {
+  return (void*)Atomic::add((jint)add_value, (volatile jint*)dest);
+}
+
+
+inline void Atomic::inc_ptr(volatile intptr_t* dest) {
+  inc((volatile jint*)dest);
+}
+
+inline void Atomic::dec_ptr(volatile intptr_t* dest) {
+  dec((volatile jint*)dest);
+}
+
+inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
+  return (intptr_t)xchg((jint)exchange_value, (volatile jint*)dest);
+}
+
+extern "C" {
+  // defined in bsd_x86.s
+  jlong _Atomic_cmpxchg_long(jlong, volatile jlong*, jlong, bool);
+  void _Atomic_move_long(volatile jlong* src, volatile jlong* dst);
+}
+
+inline jlong    Atomic::cmpxchg    (jlong    exchange_value, volatile jlong*    dest, jlong    compare_value) {
+  return _Atomic_cmpxchg_long(exchange_value, dest, compare_value, os::is_MP());
+}
+
+inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value) {
+  return (intptr_t)cmpxchg((jint)exchange_value, (volatile jint*)dest, (jint)compare_value);
+}
+
+inline void*    Atomic::cmpxchg_ptr(void*    exchange_value, volatile void*     dest, void*    compare_value) {
+  return (void*)cmpxchg((jint)exchange_value, (volatile jint*)dest, (jint)compare_value);
+}
+
+inline jlong Atomic::load(volatile jlong* src) {
+  volatile jlong dest;
+  _Atomic_move_long(src, &dest);
+  return dest;
+}
+
+inline void Atomic::store(jlong store_value, jlong* dest) {
+  _Atomic_move_long((volatile jlong*)&store_value, (volatile jlong*)dest);
+}
+
+inline void Atomic::store(jlong store_value, volatile jlong* dest) {
+  _Atomic_move_long((volatile jlong*)&store_value, dest);
+}
+
+#endif // AMD64
+
+#endif // OS_CPU_BSD_X86_VM_ATOMIC_BSD_X86_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,160 @@
+//
+// Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+// 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.
+//
+//
+
+// X86 Bsd Architecture Description File
+
+//----------OS-DEPENDENT ENCODING BLOCK-----------------------------------------------------
+// This block specifies the encoding classes used by the compiler to output
+// byte streams.  Encoding classes generate functions which are called by
+// Machine Instruction Nodes in order to generate the bit encoding of the
+// instruction.  Operands specify their base encoding interface with the
+// interface keyword.  There are currently supported four interfaces,
+// REG_INTER, CONST_INTER, MEMORY_INTER, & COND_INTER.  REG_INTER causes an
+// operand to generate a function which returns its register number when
+// queried.   CONST_INTER causes an operand to generate a function which
+// returns the value of the constant when queried.  MEMORY_INTER causes an
+// operand to generate four functions which return the Base Register, the
+// Index Register, the Scale Value, and the Offset Value of the operand when
+// queried.  COND_INTER causes an operand to generate six functions which
+// return the encoding code (ie - encoding bits for the instruction)
+// associated with each basic boolean condition for a conditional instruction.
+// Instructions specify two basic values for encoding.  They use the
+// ins_encode keyword to specify their encoding class (which must be one of
+// the class names specified in the encoding block), and they use the
+// opcode keyword to specify, in order, their primary, secondary, and
+// tertiary opcode.  Only the opcode sections which a particular instruction
+// needs for encoding need to be specified.
+encode %{
+  // Build emit functions for each basic byte or larger field in the intel
+  // encoding scheme (opcode, rm, sib, immediate), and call them from C++
+  // code in the enc_class source block.  Emit functions will live in the
+  // main source block for now.  In future, we can generalize this by
+  // adding a syntax that specifies the sizes of fields in an order,
+  // so that the adlc can build the emit functions automagically
+
+  enc_class bsd_tlsencode (eRegP dst) %{
+    Register dstReg = as_Register($dst$$reg);
+    MacroAssembler* masm = new MacroAssembler(&cbuf);
+      masm->get_thread(dstReg);
+  %}
+
+  enc_class bsd_breakpoint  %{
+    MacroAssembler* masm = new MacroAssembler(&cbuf);
+    masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
+  %}
+
+  enc_class call_epilog %{
+    if( VerifyStackAtCalls ) {
+      // Check that stack depth is unchanged: find majik cookie on stack
+      int framesize = ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP,-3*VMRegImpl::slots_per_word));
+      if(framesize >= 128) {
+        emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood
+        emit_d8(cbuf,0xBC);
+        emit_d8(cbuf,0x24);
+        emit_d32(cbuf,framesize); // Find majik cookie from ESP
+        emit_d32(cbuf, 0xbadb100d);
+      }
+      else {
+        emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood
+        emit_d8(cbuf,0x7C);
+        emit_d8(cbuf,0x24);
+        emit_d8(cbuf,framesize); // Find majik cookie from ESP
+        emit_d32(cbuf, 0xbadb100d);
+      }
+      // jmp EQ around INT3
+      // QQQ TODO
+      const int jump_around = 5; // size of call to breakpoint, 1 for CC
+      emit_opcode(cbuf,0x74);
+      emit_d8(cbuf, jump_around);
+      // QQQ temporary
+      emit_break(cbuf);
+      // Die if stack mismatch
+      // emit_opcode(cbuf,0xCC);
+    }
+  %}
+
+%}
+
+// INSTRUCTIONS -- Platform dependent
+
+//----------OS and Locking Instructions----------------------------------------
+
+// This name is KNOWN by the ADLC and cannot be changed.
+// The ADLC forces a 'TypeRawPtr::BOTTOM' output type
+// for this guy.
+instruct tlsLoadP(eRegP dst, eFlagsReg cr) %{
+  match(Set dst (ThreadLocal));
+  effect(DEF dst, KILL cr);
+
+  format %{ "MOV    $dst, Thread::current()" %}
+  ins_encode( bsd_tlsencode(dst) );
+  ins_pipe( ialu_reg_fat );
+%}
+
+instruct TLS(eRegP dst) %{
+  match(Set dst (ThreadLocal));
+
+  expand %{
+    tlsLoadP(dst);
+  %}
+%}
+
+// Die now
+instruct ShouldNotReachHere( )
+%{
+  match(Halt);
+
+  // Use the following format syntax
+  format %{ "INT3   ; ShouldNotReachHere" %}
+  // QQQ TODO for now call breakpoint
+  // opcode(0xCC);
+  // ins_encode(Opc);
+  ins_encode(bsd_breakpoint);
+  ins_pipe( pipe_slow );
+%}
+
+
+
+// Platform dependent source
+
+source %{
+
+// emit an interrupt that is caught by the debugger
+void emit_break(CodeBuffer &cbuf) {
+
+  // Debugger doesn't really catch this but best we can do so far QQQ
+  MacroAssembler* masm = new MacroAssembler(&cbuf);
+  masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
+}
+
+void MachBreakpointNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
+  emit_break(cbuf);
+}
+
+
+uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const {
+  return 5;
+}
+
+%}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.s	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,689 @@
+#
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+
+#ifdef __APPLE__
+# Darwin uses _ prefixed global symbols
+#define SYMBOL(s) _ ## s
+#define ELF_TYPE(name, description)
+#else
+#define SYMBOL(s) s
+#define ELF_TYPE(name, description) .type name,description
+#endif
+
+        .globl SYMBOL(fixcw)
+
+        # NOTE WELL!  The _Copy functions are called directly
+        # from server-compiler-generated code via CallLeafNoFP,
+        # which means that they *must* either not use floating
+        # point or use it in the same manner as does the server
+        # compiler.
+
+        .globl SYMBOL(_Copy_conjoint_bytes)
+        .globl SYMBOL(_Copy_arrayof_conjoint_bytes)
+        .globl SYMBOL(_Copy_conjoint_jshorts_atomic)
+        .globl SYMBOL(_Copy_arrayof_conjoint_jshorts)
+        .globl SYMBOL(_Copy_conjoint_jints_atomic)
+        .globl SYMBOL(_Copy_arrayof_conjoint_jints)
+        .globl SYMBOL(_Copy_conjoint_jlongs_atomic)
+        .globl SYMBOL(_mmx_Copy_arrayof_conjoint_jshorts)
+
+        .globl SYMBOL(_Atomic_cmpxchg_long)
+        .globl SYMBOL(_Atomic_move_long)
+
+        .text
+
+# Support for void os::Solaris::init_thread_fpu_state() in os_solaris_i486.cpp
+# Set fpu to 53 bit precision.  This happens too early to use a stub.
+# ported from solaris_x86_32.s
+        .p2align 4,,15
+SYMBOL(fixcw):
+        pushl    $0x27f
+        fldcw    0(%esp)
+        popl     %eax
+        ret
+
+        .globl  SYMBOL(SafeFetch32), SYMBOL(Fetch32PFI), SYMBOL(Fetch32Resume)
+        .globl  SYMBOL(SafeFetchN)
+        ## TODO: avoid exposing Fetch32PFI and Fetch32Resume.
+        ## Instead, the signal handler would call a new SafeFetchTriage(FaultingEIP)
+        ## routine to vet the address.  If the address is the faulting LD then
+        ## SafeFetchTriage() would return the resume-at EIP, otherwise null.
+        ELF_TYPE(SafeFetch32,@function)
+        .p2align 4,,15
+SYMBOL(SafeFetch32):
+SYMBOL(SafeFetchN):
+         movl    0x8(%esp), %eax
+         movl    0x4(%esp), %ecx
+SYMBOL(Fetch32PFI):
+         movl    (%ecx), %eax
+SYMBOL(Fetch32Resume):
+         ret
+
+
+        .globl  SYMBOL(SpinPause)
+        ELF_TYPE(SpinPause,@function)
+        .p2align 4,,15
+SYMBOL(SpinPause):
+        rep
+        nop
+        movl    $1, %eax
+        ret
+
+        # Support for void Copy::conjoint_bytes(void* from,
+        #                                       void* to,
+        #                                       size_t count)
+        .p2align 4,,15
+        ELF_TYPE(_Copy_conjoint_bytes,@function)
+SYMBOL(_Copy_conjoint_bytes):
+        pushl    %esi
+        movl     4+12(%esp),%ecx      # count
+        pushl    %edi
+        movl     8+ 4(%esp),%esi      # from
+        movl     8+ 8(%esp),%edi      # to
+        cmpl     %esi,%edi
+        leal     -1(%esi,%ecx),%eax   # from + count - 1
+        jbe      cb_CopyRight
+        cmpl     %eax,%edi
+        jbe      cb_CopyLeft
+        # copy from low to high
+cb_CopyRight:
+        cmpl     $3,%ecx
+        jbe      5f                   # <= 3 bytes
+        # align source address at dword address boundary
+        movl     %ecx,%eax            # original count
+        movl     $4,%ecx
+        subl     %esi,%ecx
+        andl     $3,%ecx              # prefix byte count
+        jz       1f                   # no prefix
+        subl     %ecx,%eax            # byte count less prefix
+        # copy prefix
+        subl     %esi,%edi
+0:      movb     (%esi),%dl
+        movb     %dl,(%edi,%esi,1)
+        addl     $1,%esi
+        subl     $1,%ecx
+        jnz      0b
+        addl     %esi,%edi
+1:      movl     %eax,%ecx            # byte count less prefix
+        shrl     $2,%ecx              # dword count
+        jz       4f                   # no dwords to move
+        cmpl     $32,%ecx
+        jbe      2f                   # <= 32 dwords
+        # copy aligned dwords
+        rep;     smovl
+        jmp      4f
+        # copy aligned dwords
+2:      subl     %esi,%edi
+        .p2align 4,,15
+3:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        addl     $4,%esi
+        subl     $1,%ecx
+        jnz      3b
+        addl     %esi,%edi
+4:      movl     %eax,%ecx            # byte count less prefix
+5:      andl     $3,%ecx              # suffix byte count
+        jz       7f                   # no suffix
+        # copy suffix
+        xorl     %eax,%eax
+6:      movb     (%esi,%eax,1),%dl
+        movb     %dl,(%edi,%eax,1)
+        addl     $1,%eax
+        subl     $1,%ecx
+        jnz      6b
+7:      popl     %edi
+        popl     %esi
+        ret
+        # copy from high to low
+cb_CopyLeft:
+        std
+        leal     -4(%edi,%ecx),%edi   # to + count - 4
+        movl     %eax,%esi            # from + count - 1
+        movl     %ecx,%eax
+        subl     $3,%esi              # from + count - 4
+        cmpl     $3,%ecx
+        jbe      5f                   # <= 3 bytes
+1:      shrl     $2,%ecx              # dword count
+        jz       4f                   # no dwords to move
+        cmpl     $32,%ecx
+        ja       3f                   # > 32 dwords
+        # copy dwords, aligned or not
+        subl     %esi,%edi
+        .p2align 4,,15
+2:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        subl     $4,%esi
+        subl     $1,%ecx
+        jnz      2b
+        addl     %esi,%edi
+        jmp      4f
+        # copy dwords, aligned or not
+3:      rep;     smovl
+4:      movl     %eax,%ecx            # byte count
+5:      andl     $3,%ecx              # suffix byte count
+        jz       7f                   # no suffix
+        # copy suffix
+        subl     %esi,%edi
+        addl     $3,%esi
+6:      movb     (%esi),%dl
+        movb     %dl,(%edi,%esi,1)
+        subl     $1,%esi
+        subl     $1,%ecx
+        jnz      6b
+7:      cld
+        popl     %edi
+        popl     %esi
+        ret
+
+        # Support for void Copy::arrayof_conjoint_bytes(void* from,
+        #                                               void* to,
+        #                                               size_t count)
+        #
+        # Same as _Copy_conjoint_bytes, except no source alignment check.
+        .p2align 4,,15
+        ELF_TYPE(_Copy_arrayof_conjoint_bytes,@function)
+SYMBOL(_Copy_arrayof_conjoint_bytes):
+        pushl    %esi
+        movl     4+12(%esp),%ecx      # count
+        pushl    %edi
+        movl     8+ 4(%esp),%esi      # from
+        movl     8+ 8(%esp),%edi      # to
+        cmpl     %esi,%edi
+        leal     -1(%esi,%ecx),%eax   # from + count - 1
+        jbe      acb_CopyRight
+        cmpl     %eax,%edi
+        jbe      acb_CopyLeft
+        # copy from low to high
+acb_CopyRight:
+        cmpl     $3,%ecx
+        jbe      5f
+1:      movl     %ecx,%eax
+        shrl     $2,%ecx
+        jz       4f
+        cmpl     $32,%ecx
+        ja       3f
+        # copy aligned dwords
+        subl     %esi,%edi
+        .p2align 4,,15
+2:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        addl     $4,%esi
+        subl     $1,%ecx
+        jnz      2b
+        addl     %esi,%edi
+        jmp      4f
+        # copy aligned dwords
+3:      rep;     smovl
+4:      movl     %eax,%ecx
+5:      andl     $3,%ecx
+        jz       7f
+        # copy suffix
+        xorl     %eax,%eax
+6:      movb     (%esi,%eax,1),%dl
+        movb     %dl,(%edi,%eax,1)
+        addl     $1,%eax
+        subl     $1,%ecx
+        jnz      6b
+7:      popl     %edi
+        popl     %esi
+        ret
+acb_CopyLeft:
+        std
+        leal     -4(%edi,%ecx),%edi   # to + count - 4
+        movl     %eax,%esi            # from + count - 1
+        movl     %ecx,%eax
+        subl     $3,%esi              # from + count - 4
+        cmpl     $3,%ecx
+        jbe      5f
+1:      shrl     $2,%ecx
+        jz       4f
+        cmpl     $32,%ecx
+        jbe      2f                   # <= 32 dwords
+        rep;     smovl
+        jmp      4f
+        .space 8
+2:      subl     %esi,%edi
+        .p2align 4,,15
+3:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        subl     $4,%esi
+        subl     $1,%ecx
+        jnz      3b
+        addl     %esi,%edi
+4:      movl     %eax,%ecx
+5:      andl     $3,%ecx
+        jz       7f
+        subl     %esi,%edi
+        addl     $3,%esi
+6:      movb     (%esi),%dl
+        movb     %dl,(%edi,%esi,1)
+        subl     $1,%esi
+        subl     $1,%ecx
+        jnz      6b
+7:      cld
+        popl     %edi
+        popl     %esi
+        ret
+
+        # Support for void Copy::conjoint_jshorts_atomic(void* from,
+        #                                                void* to,
+        #                                                size_t count)
+        .p2align 4,,15
+        ELF_TYPE(_Copy_conjoint_jshorts_atomic,@function)
+SYMBOL(_Copy_conjoint_jshorts_atomic):
+        pushl    %esi
+        movl     4+12(%esp),%ecx      # count
+        pushl    %edi
+        movl     8+ 4(%esp),%esi      # from
+        movl     8+ 8(%esp),%edi      # to
+        cmpl     %esi,%edi
+        leal     -2(%esi,%ecx,2),%eax # from + count*2 - 2
+        jbe      cs_CopyRight
+        cmpl     %eax,%edi
+        jbe      cs_CopyLeft
+        # copy from low to high
+cs_CopyRight:
+        # align source address at dword address boundary
+        movl     %esi,%eax            # original from
+        andl     $3,%eax              # either 0 or 2
+        jz       1f                   # no prefix
+        # copy prefix
+        subl     $1,%ecx
+        jl       5f                   # zero count
+        movw     (%esi),%dx
+        movw     %dx,(%edi)
+        addl     %eax,%esi            # %eax == 2
+        addl     %eax,%edi
+1:      movl     %ecx,%eax            # word count less prefix
+        sarl     %ecx                 # dword count
+        jz       4f                   # no dwords to move
+        cmpl     $32,%ecx
+        jbe      2f                   # <= 32 dwords
+        # copy aligned dwords
+        rep;     smovl
+        jmp      4f
+        # copy aligned dwords
+2:      subl     %esi,%edi
+        .p2align 4,,15
+3:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        addl     $4,%esi
+        subl     $1,%ecx
+        jnz      3b
+        addl     %esi,%edi
+4:      andl     $1,%eax              # suffix count
+        jz       5f                   # no suffix
+        # copy suffix
+        movw     (%esi),%dx
+        movw     %dx,(%edi)
+5:      popl     %edi
+        popl     %esi
+        ret
+        # copy from high to low
+cs_CopyLeft:
+        std
+        leal     -4(%edi,%ecx,2),%edi # to + count*2 - 4
+        movl     %eax,%esi            # from + count*2 - 2
+        movl     %ecx,%eax
+        subl     $2,%esi              # from + count*2 - 4
+1:      sarl     %ecx                 # dword count
+        jz       4f                   # no dwords to move
+        cmpl     $32,%ecx
+        ja       3f                   # > 32 dwords
+        subl     %esi,%edi
+        .p2align 4,,15
+2:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        subl     $4,%esi
+        subl     $1,%ecx
+        jnz      2b
+        addl     %esi,%edi
+        jmp      4f
+3:      rep;     smovl
+4:      andl     $1,%eax              # suffix count
+        jz       5f                   # no suffix
+        # copy suffix
+        addl     $2,%esi
+        addl     $2,%edi
+        movw     (%esi),%dx
+        movw     %dx,(%edi)
+5:      cld
+        popl     %edi
+        popl     %esi
+        ret
+
+        # Support for void Copy::arrayof_conjoint_jshorts(void* from,
+        #                                                 void* to,
+        #                                                 size_t count)
+        .p2align 4,,15
+        ELF_TYPE(_Copy_arrayof_conjoint_jshorts,@function)
+SYMBOL(_Copy_arrayof_conjoint_jshorts):
+        pushl    %esi
+        movl     4+12(%esp),%ecx      # count
+        pushl    %edi
+        movl     8+ 4(%esp),%esi      # from
+        movl     8+ 8(%esp),%edi      # to
+        cmpl     %esi,%edi
+        leal     -2(%esi,%ecx,2),%eax # from + count*2 - 2
+        jbe      acs_CopyRight
+        cmpl     %eax,%edi
+        jbe      acs_CopyLeft
+acs_CopyRight:
+        movl     %ecx,%eax            # word count
+        sarl     %ecx                 # dword count
+        jz       4f                   # no dwords to move
+        cmpl     $32,%ecx
+        jbe      2f                   # <= 32 dwords
+        # copy aligned dwords
+        rep;     smovl
+        jmp      4f
+        # copy aligned dwords
+        .space 5
+2:      subl     %esi,%edi
+        .p2align 4,,15
+3:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        addl     $4,%esi
+        subl     $1,%ecx
+        jnz      3b
+        addl     %esi,%edi
+4:      andl     $1,%eax              # suffix count
+        jz       5f                   # no suffix
+        # copy suffix
+        movw     (%esi),%dx
+        movw     %dx,(%edi)
+5:      popl     %edi
+        popl     %esi
+        ret
+acs_CopyLeft:
+        std
+        leal     -4(%edi,%ecx,2),%edi # to + count*2 - 4
+        movl     %eax,%esi            # from + count*2 - 2
+        movl     %ecx,%eax
+        subl     $2,%esi              # from + count*2 - 4
+        sarl     %ecx                 # dword count
+        jz       4f                   # no dwords to move
+        cmpl     $32,%ecx
+        ja       3f                   # > 32 dwords
+        subl     %esi,%edi
+        .p2align 4,,15
+2:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        subl     $4,%esi
+        subl     $1,%ecx
+        jnz      2b
+        addl     %esi,%edi
+        jmp      4f
+3:      rep;     smovl
+4:      andl     $1,%eax              # suffix count
+        jz       5f                   # no suffix
+        # copy suffix
+        addl     $2,%esi
+        addl     $2,%edi
+        movw     (%esi),%dx
+        movw     %dx,(%edi)
+5:      cld
+        popl     %edi
+        popl     %esi
+        ret
+
+        # Support for void Copy::conjoint_jints_atomic(void* from,
+        #                                              void* to,
+        #                                              size_t count)
+        # Equivalent to
+        #   arrayof_conjoint_jints
+        .p2align 4,,15
+        ELF_TYPE(_Copy_conjoint_jints_atomic,@function)
+        ELF_TYPE(_Copy_arrayof_conjoint_jints,@function)
+SYMBOL(_Copy_conjoint_jints_atomic):
+SYMBOL(_Copy_arrayof_conjoint_jints):
+        pushl    %esi
+        movl     4+12(%esp),%ecx      # count
+        pushl    %edi
+        movl     8+ 4(%esp),%esi      # from
+        movl     8+ 8(%esp),%edi      # to
+        cmpl     %esi,%edi
+        leal     -4(%esi,%ecx,4),%eax # from + count*4 - 4
+        jbe      ci_CopyRight
+        cmpl     %eax,%edi
+        jbe      ci_CopyLeft
+ci_CopyRight:
+        cmpl     $32,%ecx
+        jbe      2f                   # <= 32 dwords
+        rep;     smovl
+        popl     %edi
+        popl     %esi
+        ret
+        .space 10
+2:      subl     %esi,%edi
+        jmp      4f
+        .p2align 4,,15
+3:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        addl     $4,%esi
+4:      subl     $1,%ecx
+        jge      3b
+        popl     %edi
+        popl     %esi
+        ret
+ci_CopyLeft:
+        std
+        leal     -4(%edi,%ecx,4),%edi # to + count*4 - 4
+        cmpl     $32,%ecx
+        ja       4f                   # > 32 dwords
+        subl     %eax,%edi            # eax == from + count*4 - 4
+        jmp      3f
+        .p2align 4,,15
+2:      movl     (%eax),%edx
+        movl     %edx,(%edi,%eax,1)
+        subl     $4,%eax
+3:      subl     $1,%ecx
+        jge      2b
+        cld
+        popl     %edi
+        popl     %esi
+        ret
+4:      movl     %eax,%esi            # from + count*4 - 4
+        rep;     smovl
+        cld
+        popl     %edi
+        popl     %esi
+        ret
+
+        # Support for void Copy::conjoint_jlongs_atomic(jlong* from,
+        #                                               jlong* to,
+        #                                               size_t count)
+        #
+        # 32-bit
+        #
+        # count treated as signed
+        #
+        # // if (from > to) {
+        #   while (--count >= 0) {
+        #     *to++ = *from++;
+        #   }
+        # } else {
+        #   while (--count >= 0) {
+        #     to[count] = from[count];
+        #   }
+        # }
+        .p2align 4,,15
+        ELF_TYPE(_Copy_conjoint_jlongs_atomic,@function)
+SYMBOL(_Copy_conjoint_jlongs_atomic):
+        movl     4+8(%esp),%ecx       # count
+        movl     4+0(%esp),%eax       # from
+        movl     4+4(%esp),%edx       # to
+        cmpl     %eax,%edx
+        jae      cla_CopyLeft
+cla_CopyRight:
+        subl     %eax,%edx
+        jmp      2f
+        .p2align 4,,15
+1:      fildll   (%eax)
+        fistpll  (%edx,%eax,1)
+        addl     $8,%eax
+2:      subl     $1,%ecx
+        jge      1b
+        ret
+        .p2align 4,,15
+3:      fildll   (%eax,%ecx,8)
+        fistpll  (%edx,%ecx,8)
+cla_CopyLeft:
+        subl     $1,%ecx
+        jge      3b
+        ret
+
+        # Support for void Copy::arrayof_conjoint_jshorts(void* from,
+        #                                                 void* to,
+        #                                                 size_t count)
+        .p2align 4,,15
+        ELF_TYPE(_mmx_Copy_arrayof_conjoint_jshorts,@function)
+SYMBOL(_mmx_Copy_arrayof_conjoint_jshorts):
+        pushl    %esi
+        movl     4+12(%esp),%ecx
+        pushl    %edi
+        movl     8+ 4(%esp),%esi
+        movl     8+ 8(%esp),%edi
+        cmpl     %esi,%edi
+        leal     -2(%esi,%ecx,2),%eax
+        jbe      mmx_acs_CopyRight
+        cmpl     %eax,%edi
+        jbe      mmx_acs_CopyLeft
+mmx_acs_CopyRight:
+        movl     %ecx,%eax
+        sarl     %ecx
+        je       5f
+        cmpl     $33,%ecx
+        jae      3f
+1:      subl     %esi,%edi
+        .p2align 4,,15
+2:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        addl     $4,%esi
+        subl     $1,%ecx
+        jnz      2b
+        addl     %esi,%edi
+        jmp      5f
+3:      smovl # align to 8 bytes, we know we are 4 byte aligned to start
+        subl     $1,%ecx
+4:      .p2align 4,,15
+        movq     0(%esi),%mm0
+        addl     $64,%edi
+        movq     8(%esi),%mm1
+        subl     $16,%ecx
+        movq     16(%esi),%mm2
+        movq     %mm0,-64(%edi)
+        movq     24(%esi),%mm0
+        movq     %mm1,-56(%edi)
+        movq     32(%esi),%mm1
+        movq     %mm2,-48(%edi)
+        movq     40(%esi),%mm2
+        movq     %mm0,-40(%edi)
+        movq     48(%esi),%mm0
+        movq     %mm1,-32(%edi)
+        movq     56(%esi),%mm1
+        movq     %mm2,-24(%edi)
+        movq     %mm0,-16(%edi)
+        addl     $64,%esi
+        movq     %mm1,-8(%edi)
+        cmpl     $16,%ecx
+        jge      4b
+        emms
+        testl    %ecx,%ecx
+        ja       1b
+5:      andl     $1,%eax
+        je       7f
+6:      movw     (%esi),%dx
+        movw     %dx,(%edi)
+7:      popl     %edi
+        popl     %esi
+        ret
+mmx_acs_CopyLeft:
+        std
+        leal     -4(%edi,%ecx,2),%edi
+        movl     %eax,%esi
+        movl     %ecx,%eax
+        subl     $2,%esi
+        sarl     %ecx
+        je       4f
+        cmpl     $32,%ecx
+        ja       3f
+        subl     %esi,%edi
+        .p2align 4,,15
+2:      movl     (%esi),%edx
+        movl     %edx,(%edi,%esi,1)
+        subl     $4,%esi
+        subl     $1,%ecx
+        jnz      2b
+        addl     %esi,%edi
+        jmp      4f
+3:      rep;     smovl
+4:      andl     $1,%eax
+        je       6f
+        addl     $2,%esi
+        addl     $2,%edi
+5:      movw     (%esi),%dx
+        movw     %dx,(%edi)
+6:      cld
+        popl     %edi
+        popl     %esi
+        ret
+
+
+        # Support for jlong Atomic::cmpxchg(jlong exchange_value,
+        #                                   volatile jlong* dest,
+        #                                   jlong compare_value,
+        #                                   bool is_MP)
+        #
+        .p2align 4,,15
+        ELF_TYPE(_Atomic_cmpxchg_long,@function)
+SYMBOL(_Atomic_cmpxchg_long):
+                                   #  8(%esp) : return PC
+        pushl    %ebx              #  4(%esp) : old %ebx
+        pushl    %edi              #  0(%esp) : old %edi
+        movl     12(%esp), %ebx    # 12(%esp) : exchange_value (low)
+        movl     16(%esp), %ecx    # 16(%esp) : exchange_value (high)
+        movl     24(%esp), %eax    # 24(%esp) : compare_value (low)
+        movl     28(%esp), %edx    # 28(%esp) : compare_value (high)
+        movl     20(%esp), %edi    # 20(%esp) : dest
+        cmpl     $0, 32(%esp)      # 32(%esp) : is_MP
+        je       1f
+        lock
+1:      cmpxchg8b (%edi)
+        popl     %edi
+        popl     %ebx
+        ret
+
+
+        # Support for jlong Atomic::load and Atomic::store.
+        # void _Atomic_move_long(volatile jlong* src, volatile jlong* dst)
+        .p2align 4,,15
+        ELF_TYPE(_Atomic_move_long,@function)
+SYMBOL(_Atomic_move_long):
+        movl     4(%esp), %eax   # src
+        fildll    (%eax)
+        movl     8(%esp), %eax   # dest
+        fistpll   (%eax)
+        ret
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,173 @@
+//
+// Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+// 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.
+//
+//
+
+// AMD64 Bsd Architecture Description File
+
+//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------
+// This block specifies the encoding classes used by the compiler to
+// output byte streams.  Encoding classes generate functions which are
+// called by Machine Instruction Nodes in order to generate the bit
+// encoding of the instruction.  Operands specify their base encoding
+// interface with the interface keyword.  There are currently
+// supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
+// COND_INTER.  REG_INTER causes an operand to generate a function
+// which returns its register number when queried.  CONST_INTER causes
+// an operand to generate a function which returns the value of the
+// constant when queried.  MEMORY_INTER causes an operand to generate
+// four functions which return the Base Register, the Index Register,
+// the Scale Value, and the Offset Value of the operand when queried.
+// COND_INTER causes an operand to generate six functions which return
+// the encoding code (ie - encoding bits for the instruction)
+// associated with each basic boolean condition for a conditional
+// instruction.  Instructions specify two basic values for encoding.
+// They use the ins_encode keyword to specify their encoding class
+// (which must be one of the class names specified in the encoding
+// block), and they use the opcode keyword to specify, in order, their
+// primary, secondary, and tertiary opcode.  Only the opcode sections
+// which a particular instruction needs for encoding need to be
+// specified.
+encode %{
+  // Build emit functions for each basic byte or larger field in the intel
+  // encoding scheme (opcode, rm, sib, immediate), and call them from C++
+  // code in the enc_class source block.  Emit functions will live in the
+  // main source block for now.  In future, we can generalize this by
+  // adding a syntax that specifies the sizes of fields in an order,
+  // so that the adlc can build the emit functions automagically
+
+  enc_class Java_To_Runtime(method meth)
+  %{
+    // No relocation needed
+
+    // movq r10, <meth>
+    emit_opcode(cbuf, Assembler::REX_WB);
+    emit_opcode(cbuf, 0xB8 | (R10_enc - 8));
+    emit_d64(cbuf, (int64_t) $meth$$method);
+
+    // call (r10)
+    emit_opcode(cbuf, Assembler::REX_B);
+    emit_opcode(cbuf, 0xFF);
+    emit_opcode(cbuf, 0xD0 | (R10_enc - 8));
+  %}
+
+  enc_class bsd_breakpoint
+  %{
+    MacroAssembler* masm = new MacroAssembler(&cbuf);
+    masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
+  %}
+
+  enc_class call_epilog
+  %{
+    if (VerifyStackAtCalls) {
+      // Check that stack depth is unchanged: find majik cookie on stack
+      int framesize =
+        ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP, -3*VMRegImpl::slots_per_word));
+      if (framesize) {
+        if (framesize < 0x80) {
+          emit_opcode(cbuf, Assembler::REX_W);
+          emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood
+          emit_d8(cbuf, 0x7C);
+          emit_d8(cbuf, 0x24);
+          emit_d8(cbuf, framesize); // Find majik cookie from ESP
+          emit_d32(cbuf, 0xbadb100d);
+        } else {
+          emit_opcode(cbuf, Assembler::REX_W);
+          emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood
+          emit_d8(cbuf, 0xBC);
+          emit_d8(cbuf, 0x24);
+          emit_d32(cbuf, framesize); // Find majik cookie from ESP
+          emit_d32(cbuf, 0xbadb100d);
+        }
+      }
+      // jmp EQ around INT3
+      // QQQ TODO
+      const int jump_around = 5; // size of call to breakpoint, 1 for CC
+      emit_opcode(cbuf, 0x74);
+      emit_d8(cbuf, jump_around);
+      // QQQ temporary
+      emit_break(cbuf);
+      // Die if stack mismatch
+      // emit_opcode(cbuf,0xCC);
+    }
+  %}
+
+%}
+
+// INSTRUCTIONS -- Platform dependent
+
+//----------OS and Locking Instructions----------------------------------------
+
+// This name is KNOWN by the ADLC and cannot be changed.
+// The ADLC forces a 'TypeRawPtr::BOTTOM' output type
+// for this guy.
+instruct tlsLoadP(r15_RegP dst)
+%{
+  match(Set dst (ThreadLocal));
+  effect(DEF dst);
+
+  size(0);
+  format %{ "# TLS is in R15" %}
+  ins_encode( /*empty encoding*/ );
+  ins_pipe(ialu_reg_reg);
+%}
+
+// Die now
+instruct ShouldNotReachHere()
+%{
+  match(Halt);
+
+  // Use the following format syntax
+  format %{ "int3\t# ShouldNotReachHere" %}
+  // QQQ TODO for now call breakpoint
+  // opcode(0xCC);
+  // ins_encode(Opc);
+  ins_encode(bsd_breakpoint);
+  ins_pipe(pipe_slow);
+%}
+
+
+// Platform dependent source
+
+source
+%{
+
+int MachCallRuntimeNode::ret_addr_offset() {
+  return 13; // movq r10,#addr; callq (r10)
+}
+
+// emit an interrupt that is caught by the debugger
+void emit_break(CodeBuffer& cbuf) {
+  // Debugger doesn't really catch this but best we can do so far QQQ
+  MacroAssembler* masm = new MacroAssembler(&cbuf);
+  masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
+}
+
+void MachBreakpointNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const {
+  emit_break(cbuf);
+}
+
+uint MachBreakpointNode::size(PhaseRegAlloc* ra_) const {
+  return 5;
+}
+
+%}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.s	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,410 @@
+# 
+# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#
+
+#ifdef __APPLE__
+# Darwin uses _ prefixed global symbols
+#define SYMBOL(s) _ ## s
+#define ELF_TYPE(name, description)
+#else
+#define SYMBOL(s) s
+#define ELF_TYPE(name, description) .type name,description
+#endif
+
+        # NOTE WELL!  The _Copy functions are called directly
+	# from server-compiler-generated code via CallLeafNoFP,
+	# which means that they *must* either not use floating
+	# point or use it in the same manner as does the server
+	# compiler.
+	
+        .globl SYMBOL(_Copy_arrayof_conjoint_bytes)
+	.globl SYMBOL(_Copy_arrayof_conjoint_jshorts)
+        .globl SYMBOL(_Copy_conjoint_jshorts_atomic)
+        .globl SYMBOL(_Copy_arrayof_conjoint_jints)
+        .globl SYMBOL(_Copy_conjoint_jints_atomic)
+        .globl SYMBOL(_Copy_arrayof_conjoint_jlongs)
+        .globl SYMBOL(_Copy_conjoint_jlongs_atomic)
+
+	.text
+
+        .globl SYMBOL(SafeFetch32), SYMBOL(Fetch32PFI), SYMBOL(Fetch32Resume)
+        .p2align 4,,15
+        ELF_TYPE(SafeFetch32,@function)
+        // Prototype: int SafeFetch32 (int * Adr, int ErrValue) 
+SYMBOL(SafeFetch32):
+        movl    %esi, %eax
+SYMBOL(Fetch32PFI):
+        movl    (%rdi), %eax
+SYMBOL(Fetch32Resume):
+        ret
+
+        .globl SYMBOL(SafeFetchN), SYMBOL(FetchNPFI), SYMBOL(FetchNResume)
+        .p2align 4,,15
+        ELF_TYPE(SafeFetchN,@function)
+        // Prototype: intptr_t SafeFetchN (intptr_t * Adr, intptr_t ErrValue) 
+SYMBOL(SafeFetchN):
+        movq    %rsi, %rax
+SYMBOL(FetchNPFI):
+        movq    (%rdi), %rax
+SYMBOL(FetchNResume):
+        ret
+
+        .globl SYMBOL(SpinPause)
+        .p2align 4,,15
+        ELF_TYPE(SpinPause,@function)
+SYMBOL(SpinPause):
+        rep
+        nop
+        movq   $1, %rax
+        ret
+
+        # Support for void Copy::arrayof_conjoint_bytes(void* from,
+        #                                               void* to,
+        #                                               size_t count)
+        # rdi - from
+        # rsi - to
+        # rdx - count, treated as ssize_t
+        #
+        .p2align 4,,15
+	ELF_TYPE(_Copy_arrayof_conjoint_bytes,@function)
+SYMBOL(_Copy_arrayof_conjoint_bytes):
+        movq     %rdx,%r8             # byte count
+        shrq     $3,%rdx              # qword count
+        cmpq     %rdi,%rsi
+        leaq     -1(%rdi,%r8,1),%rax  # from + bcount*1 - 1
+        jbe      acb_CopyRight
+        cmpq     %rax,%rsi
+        jbe      acb_CopyLeft 
+acb_CopyRight:
+        leaq     -8(%rdi,%rdx,8),%rax # from + qcount*8 - 8
+        leaq     -8(%rsi,%rdx,8),%rcx # to + qcount*8 - 8
+        negq     %rdx
+        jmp      7f
+        .p2align 4,,15
+1:      movq     8(%rax,%rdx,8),%rsi
+        movq     %rsi,8(%rcx,%rdx,8)
+        addq     $1,%rdx
+        jnz      1b
+2:      testq    $4,%r8               # check for trailing dword
+        jz       3f
+        movl     8(%rax),%esi         # copy trailing dword
+        movl     %esi,8(%rcx)
+        addq     $4,%rax
+        addq     $4,%rcx              # original %rsi is trashed, so we
+                                      #  can't use it as a base register
+3:      testq    $2,%r8               # check for trailing word
+        jz       4f
+        movw     8(%rax),%si          # copy trailing word
+        movw     %si,8(%rcx)
+        addq     $2,%rcx
+4:      testq    $1,%r8               # check for trailing byte
+        jz       5f
+        movb     -1(%rdi,%r8,1),%al   # copy trailing byte
+        movb     %al,8(%rcx)
+5:      ret
+        .p2align 4,,15
+6:      movq     -24(%rax,%rdx,8),%rsi
+        movq     %rsi,-24(%rcx,%rdx,8)
+        movq     -16(%rax,%rdx,8),%rsi
+        movq     %rsi,-16(%rcx,%rdx,8)
+        movq     -8(%rax,%rdx,8),%rsi
+        movq     %rsi,-8(%rcx,%rdx,8)
+        movq     (%rax,%rdx,8),%rsi
+        movq     %rsi,(%rcx,%rdx,8)
+7:      addq     $4,%rdx
+        jle      6b
+        subq     $4,%rdx
+        jl       1b
+        jmp      2b
+acb_CopyLeft:
+        testq    $1,%r8               # check for trailing byte
+        jz       1f
+        movb     -1(%rdi,%r8,1),%cl   # copy trailing byte
+        movb     %cl,-1(%rsi,%r8,1)
+        subq     $1,%r8               # adjust for possible trailing word
+1:      testq    $2,%r8               # check for trailing word
+        jz       2f
+        movw     -2(%rdi,%r8,1),%cx   # copy trailing word
+        movw     %cx,-2(%rsi,%r8,1)
+2:      testq    $4,%r8               # check for trailing dword
+        jz       5f
+        movl     (%rdi,%rdx,8),%ecx   # copy trailing dword
+        movl     %ecx,(%rsi,%rdx,8)
+        jmp      5f
+        .p2align 4,,15
+3:      movq     -8(%rdi,%rdx,8),%rcx
+        movq     %rcx,-8(%rsi,%rdx,8)
+        subq     $1,%rdx
+        jnz      3b
+        ret
+        .p2align 4,,15
+4:      movq     24(%rdi,%rdx,8),%rcx
+        movq     %rcx,24(%rsi,%rdx,8)
+        movq     16(%rdi,%rdx,8),%rcx
+        movq     %rcx,16(%rsi,%rdx,8)
+        movq     8(%rdi,%rdx,8),%rcx
+        movq     %rcx,8(%rsi,%rdx,8)
+        movq     (%rdi,%rdx,8),%rcx
+        movq     %rcx,(%rsi,%rdx,8)
+5:      subq     $4,%rdx
+        jge      4b
+        addq     $4,%rdx
+        jg       3b
+        ret
+
+        # Support for void Copy::arrayof_conjoint_jshorts(void* from,
+        #                                                 void* to,
+        #                                                 size_t count)
+        # Equivalent to
+        #   conjoint_jshorts_atomic
+        #
+        # If 'from' and/or 'to' are aligned on 4- or 2-byte boundaries, we
+        # let the hardware handle it.  The tow or four words within dwords
+        # or qwords that span cache line boundaries will still be loaded
+        # and stored atomically.
+        #
+        # rdi - from
+        # rsi - to
+        # rdx - count, treated as ssize_t
+        #
+        .p2align 4,,15
+	ELF_TYPE(_Copy_arrayof_conjoint_jshorts,@function)
+	ELF_TYPE(_Copy_conjoint_jshorts_atomic,@function)
+SYMBOL(_Copy_arrayof_conjoint_jshorts):
+SYMBOL(_Copy_conjoint_jshorts_atomic):
+        movq     %rdx,%r8             # word count
+        shrq     $2,%rdx              # qword count
+        cmpq     %rdi,%rsi
+        leaq     -2(%rdi,%r8,2),%rax  # from + wcount*2 - 2
+        jbe      acs_CopyRight
+        cmpq     %rax,%rsi
+        jbe      acs_CopyLeft 
+acs_CopyRight:
+        leaq     -8(%rdi,%rdx,8),%rax # from + qcount*8 - 8
+        leaq     -8(%rsi,%rdx,8),%rcx # to + qcount*8 - 8
+        negq     %rdx
+        jmp      6f
+1:      movq     8(%rax,%rdx,8),%rsi
+        movq     %rsi,8(%rcx,%rdx,8)
+        addq     $1,%rdx
+        jnz      1b
+2:      testq    $2,%r8               # check for trailing dword
+        jz       3f
+        movl     8(%rax),%esi         # copy trailing dword
+        movl     %esi,8(%rcx)
+        addq     $4,%rcx              # original %rsi is trashed, so we
+                                      #  can't use it as a base register
+3:      testq    $1,%r8               # check for trailing word
+        jz       4f
+        movw     -2(%rdi,%r8,2),%si   # copy trailing word
+        movw     %si,8(%rcx)
+4:      ret
+        .p2align 4,,15
+5:      movq     -24(%rax,%rdx,8),%rsi
+        movq     %rsi,-24(%rcx,%rdx,8)
+        movq     -16(%rax,%rdx,8),%rsi
+        movq     %rsi,-16(%rcx,%rdx,8)
+        movq     -8(%rax,%rdx,8),%rsi
+        movq     %rsi,-8(%rcx,%rdx,8)
+        movq     (%rax,%rdx,8),%rsi
+        movq     %rsi,(%rcx,%rdx,8)
+6:      addq     $4,%rdx
+        jle      5b
+        subq     $4,%rdx
+        jl       1b
+        jmp      2b
+acs_CopyLeft:
+        testq    $1,%r8               # check for trailing word
+        jz       1f
+        movw     -2(%rdi,%r8,2),%cx   # copy trailing word
+        movw     %cx,-2(%rsi,%r8,2)
+1:      testq    $2,%r8               # check for trailing dword
+        jz       4f
+        movl     (%rdi,%rdx,8),%ecx   # copy trailing dword
+        movl     %ecx,(%rsi,%rdx,8)
+        jmp      4f
+2:      movq     -8(%rdi,%rdx,8),%rcx
+        movq     %rcx,-8(%rsi,%rdx,8)
+        subq     $1,%rdx
+        jnz      2b
+        ret
+        .p2align 4,,15
+3:      movq     24(%rdi,%rdx,8),%rcx
+        movq     %rcx,24(%rsi,%rdx,8)
+        movq     16(%rdi,%rdx,8),%rcx
+        movq     %rcx,16(%rsi,%rdx,8)
+        movq     8(%rdi,%rdx,8),%rcx
+        movq     %rcx,8(%rsi,%rdx,8)
+        movq     (%rdi,%rdx,8),%rcx
+        movq     %rcx,(%rsi,%rdx,8)
+4:      subq     $4,%rdx
+        jge      3b
+        addq     $4,%rdx
+        jg       2b
+        ret
+
+        # Support for void Copy::arrayof_conjoint_jints(jint* from,
+        #                                               jint* to,
+        #                                               size_t count)
+        # Equivalent to
+        #   conjoint_jints_atomic
+        #
+        # If 'from' and/or 'to' are aligned on 4-byte boundaries, we let
+        # the hardware handle it.  The two dwords within qwords that span
+        # cache line boundaries will still be loaded and stored atomically.
+        #
+        # rdi - from
+        # rsi - to
+        # rdx - count, treated as ssize_t
+        #
+        .p2align 4,,15
+	ELF_TYPE(_Copy_arrayof_conjoint_jints,@function)
+	ELF_TYPE(_Copy_conjoint_jints_atomic,@function)
+SYMBOL(_Copy_arrayof_conjoint_jints):
+SYMBOL(_Copy_conjoint_jints_atomic):
+        movq     %rdx,%r8             # dword count
+        shrq     %rdx                 # qword count
+        cmpq     %rdi,%rsi
+        leaq     -4(%rdi,%r8,4),%rax  # from + dcount*4 - 4
+        jbe      aci_CopyRight
+        cmpq     %rax,%rsi
+        jbe      aci_CopyLeft 
+aci_CopyRight:
+        leaq     -8(%rdi,%rdx,8),%rax # from + qcount*8 - 8
+        leaq     -8(%rsi,%rdx,8),%rcx # to + qcount*8 - 8
+        negq     %rdx
+        jmp      5f
+        .p2align 4,,15
+1:      movq     8(%rax,%rdx,8),%rsi
+        movq     %rsi,8(%rcx,%rdx,8)
+        addq     $1,%rdx
+        jnz       1b
+2:      testq    $1,%r8               # check for trailing dword
+        jz       3f
+        movl     8(%rax),%esi         # copy trailing dword
+        movl     %esi,8(%rcx)
+3:      ret
+        .p2align 4,,15
+4:      movq     -24(%rax,%rdx,8),%rsi
+        movq     %rsi,-24(%rcx,%rdx,8)
+        movq     -16(%rax,%rdx,8),%rsi
+        movq     %rsi,-16(%rcx,%rdx,8)
+        movq     -8(%rax,%rdx,8),%rsi
+        movq     %rsi,-8(%rcx,%rdx,8)
+        movq     (%rax,%rdx,8),%rsi
+        movq     %rsi,(%rcx,%rdx,8)
+5:      addq     $4,%rdx
+        jle      4b
+        subq     $4,%rdx
+        jl       1b
+        jmp      2b
+aci_CopyLeft:
+        testq    $1,%r8               # check for trailing dword
+        jz       3f
+        movl     -4(%rdi,%r8,4),%ecx  # copy trailing dword
+        movl     %ecx,-4(%rsi,%r8,4)
+        jmp      3f
+1:      movq     -8(%rdi,%rdx,8),%rcx
+        movq     %rcx,-8(%rsi,%rdx,8)
+        subq     $1,%rdx
+        jnz      1b
+        ret
+        .p2align 4,,15
+2:      movq     24(%rdi,%rdx,8),%rcx
+        movq     %rcx,24(%rsi,%rdx,8)
+        movq     16(%rdi,%rdx,8),%rcx
+        movq     %rcx,16(%rsi,%rdx,8)
+        movq     8(%rdi,%rdx,8),%rcx
+        movq     %rcx,8(%rsi,%rdx,8)
+        movq     (%rdi,%rdx,8),%rcx
+        movq     %rcx,(%rsi,%rdx,8)
+3:      subq     $4,%rdx
+        jge      2b
+        addq     $4,%rdx
+        jg       1b
+        ret
+
+        # Support for void Copy::arrayof_conjoint_jlongs(jlong* from,
+        #                                                jlong* to,
+        #                                                size_t count)
+        # Equivalent to
+        #   conjoint_jlongs_atomic
+        #   arrayof_conjoint_oops
+        #   conjoint_oops_atomic
+        #
+        # rdi - from
+        # rsi - to
+        # rdx - count, treated as ssize_t
+        #
+        .p2align 4,,15
+	ELF_TYPE(_Copy_arrayof_conjoint_jlongs,@function)
+	ELF_TYPE(_Copy_conjoint_jlongs_atomic,@function)
+SYMBOL(_Copy_arrayof_conjoint_jlongs):
+SYMBOL(_Copy_conjoint_jlongs_atomic):
+        cmpq     %rdi,%rsi
+        leaq     -8(%rdi,%rdx,8),%rax # from + count*8 - 8
+        jbe      acl_CopyRight
+        cmpq     %rax,%rsi
+        jbe      acl_CopyLeft 
+acl_CopyRight:
+        leaq     -8(%rsi,%rdx,8),%rcx # to + count*8 - 8
+        negq     %rdx
+        jmp      3f
+1:      movq     8(%rax,%rdx,8),%rsi
+        movq     %rsi,8(%rcx,%rdx,8)
+        addq     $1,%rdx
+        jnz      1b
+        ret
+        .p2align 4,,15
+2:      movq     -24(%rax,%rdx,8),%rsi
+        movq     %rsi,-24(%rcx,%rdx,8)
+        movq     -16(%rax,%rdx,8),%rsi
+        movq     %rsi,-16(%rcx,%rdx,8)
+        movq     -8(%rax,%rdx,8),%rsi
+        movq     %rsi,-8(%rcx,%rdx,8)
+        movq     (%rax,%rdx,8),%rsi
+        movq     %rsi,(%rcx,%rdx,8)
+3:      addq     $4,%rdx
+        jle      2b
+        subq     $4,%rdx
+        jl       1b
+        ret
+4:      movq     -8(%rdi,%rdx,8),%rcx
+        movq     %rcx,-8(%rsi,%rdx,8)
+        subq     $1,%rdx
+        jnz      4b
+        ret
+        .p2align 4,,15
+5:      movq     24(%rdi,%rdx,8),%rcx
+        movq     %rcx,24(%rsi,%rdx,8)
+        movq     16(%rdi,%rdx,8),%rcx
+        movq     %rcx,16(%rsi,%rdx,8)
+        movq     8(%rdi,%rdx,8),%rcx
+        movq     %rcx,8(%rsi,%rdx,8)
+        movq     (%rdi,%rdx,8),%rcx
+        movq     %rcx,(%rsi,%rdx,8)
+acl_CopyLeft:
+        subq     $4,%rdx
+        jge      5b
+        addq     $4,%rdx
+        jg       4b
+        ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/bytes_bsd_x86.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_X86_VM_BYTES_BSD_X86_INLINE_HPP
+#define OS_CPU_BSD_X86_VM_BYTES_BSD_X86_INLINE_HPP
+
+#ifndef _ALLBSD_SOURCE
+#include <byteswap.h>
+#endif
+
+#ifdef __APPLE__
+#include <libkern/OSByteOrder.h>
+#endif
+
+#if defined(AMD64)
+#  if defined(__APPLE__)
+#    define bswap_16(x) OSSwapInt16(x)
+#    define bswap_32(x) OSSwapInt32(x)
+#    define bswap_64(x) OSSwapInt64(x)
+#  elif defined(__OpenBSD__)
+#    define bswap_16(x) swap16(x)
+#    define bswap_32(x) swap32(x)
+#    define bswap_64(x) swap64(x)
+#  elif defined(__NetBSD__)
+#    define bswap_16(x) bswap16(x)
+#    define bswap_32(x) bswap32(x)
+#    define bswap_64(x) bswap64(x)
+#  else
+#    define bswap_16(x) __bswap16(x)
+#    define bswap_32(x) __bswap32(x)
+#    define bswap_64(x) __bswap64(x)
+#  endif
+#endif
+
+// Efficient swapping of data bytes from Java byte
+// ordering to native byte ordering and vice versa.
+inline u2   Bytes::swap_u2(u2 x) {
+#ifdef AMD64
+  return bswap_16(x);
+#else
+  u2 ret;
+  __asm__ __volatile__ (
+    "movw %0, %%ax;"
+    "xchg %%al, %%ah;"
+    "movw %%ax, %0"
+    :"=r" (ret)      // output : register 0 => ret
+    :"0"  (x)        // input  : x => register 0
+    :"ax", "0"       // clobbered registers
+  );
+  return ret;
+#endif // AMD64
+}
+
+inline u4   Bytes::swap_u4(u4 x) {
+#ifdef AMD64
+  return bswap_32(x);
+#else
+  u4 ret;
+  __asm__ __volatile__ (
+    "bswap %0"
+    :"=r" (ret)      // output : register 0 => ret
+    :"0"  (x)        // input  : x => register 0
+    :"0"             // clobbered register
+  );
+  return ret;
+#endif // AMD64
+}
+
+#ifdef AMD64
+inline u8 Bytes::swap_u8(u8 x) {
+#ifdef SPARC_WORKS
+  // workaround for SunStudio12 CR6615391
+  __asm__ __volatile__ (
+    "bswapq %0"
+    :"=r" (x)        // output : register 0 => x
+    :"0"  (x)        // input  : x => register 0
+    :"0"             // clobbered register
+  );
+  return x;
+#else
+  return bswap_64(x);
+#endif
+}
+#else
+// Helper function for swap_u8
+inline u8   Bytes::swap_u8_base(u4 x, u4 y) {
+  return (((u8)swap_u4(x))<<32) | swap_u4(y);
+}
+
+inline u8 Bytes::swap_u8(u8 x) {
+  return swap_u8_base(*(u4*)&x, *(((u4*)&x)+1));
+}
+#endif // !AMD64
+
+#endif // OS_CPU_BSD_X86_VM_BYTES_BSD_X86_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/copy_bsd_x86.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,309 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_X86_VM_COPY_BSD_X86_INLINE_HPP
+#define OS_CPU_BSD_X86_VM_COPY_BSD_X86_INLINE_HPP
+
+static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
+#ifdef AMD64
+  (void)memmove(to, from, count * HeapWordSize);
+#else
+  // Includes a zero-count check.
+  intx temp;
+  __asm__ volatile("        testl   %6,%6         ;"
+                   "        jz      7f            ;"
+                   "        cmpl    %4,%5         ;"
+                   "        leal    -4(%4,%6,4),%3;"
+                   "        jbe     1f            ;"
+                   "        cmpl    %7,%5         ;"
+                   "        jbe     4f            ;"
+                   "1:      cmpl    $32,%6        ;"
+                   "        ja      3f            ;"
+                   "        subl    %4,%1         ;"
+                   "2:      movl    (%4),%3       ;"
+                   "        movl    %7,(%5,%4,1)  ;"
+                   "        addl    $4,%0         ;"
+                   "        subl    $1,%2          ;"
+                   "        jnz     2b            ;"
+                   "        jmp     7f            ;"
+                   "3:      rep;    smovl         ;"
+                   "        jmp     7f            ;"
+                   "4:      cmpl    $32,%2        ;"
+                   "        movl    %7,%0         ;"
+                   "        leal    -4(%5,%6,4),%1;"
+                   "        ja      6f            ;"
+                   "        subl    %4,%1         ;"
+                   "5:      movl    (%4),%3       ;"
+                   "        movl    %7,(%5,%4,1)  ;"
+                   "        subl    $4,%0         ;"
+                   "        subl    $1,%2          ;"
+                   "        jnz     5b            ;"
+                   "        jmp     7f            ;"
+                   "6:      std                   ;"
+                   "        rep;    smovl         ;"
+                   "        cld                   ;"
+                   "7:      nop                    "
+                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
+                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
+                   : "memory", "flags");
+#endif // AMD64
+}
+
+static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
+#ifdef AMD64
+  switch (count) {
+  case 8:  to[7] = from[7];
+  case 7:  to[6] = from[6];
+  case 6:  to[5] = from[5];
+  case 5:  to[4] = from[4];
+  case 4:  to[3] = from[3];
+  case 3:  to[2] = from[2];
+  case 2:  to[1] = from[1];
+  case 1:  to[0] = from[0];
+  case 0:  break;
+  default:
+    (void)memcpy(to, from, count * HeapWordSize);
+    break;
+  }
+#else
+  // Includes a zero-count check.
+  intx temp;
+  __asm__ volatile("        testl   %6,%6       ;"
+                   "        jz      3f          ;"
+                   "        cmpl    $32,%6      ;"
+                   "        ja      2f          ;"
+                   "        subl    %4,%1       ;"
+                   "1:      movl    (%4),%3     ;"
+                   "        movl    %7,(%5,%4,1);"
+                   "        addl    $4,%0       ;"
+                   "        subl    $1,%2        ;"
+                   "        jnz     1b          ;"
+                   "        jmp     3f          ;"
+                   "2:      rep;    smovl       ;"
+                   "3:      nop                  "
+                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
+                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
+                   : "memory", "cc");
+#endif // AMD64
+}
+
+static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
+#ifdef AMD64
+  switch (count) {
+  case 8:  to[7] = from[7];
+  case 7:  to[6] = from[6];
+  case 6:  to[5] = from[5];
+  case 5:  to[4] = from[4];
+  case 4:  to[3] = from[3];
+  case 3:  to[2] = from[2];
+  case 2:  to[1] = from[1];
+  case 1:  to[0] = from[0];
+  case 0:  break;
+  default:
+    while (count-- > 0) {
+      *to++ = *from++;
+    }
+    break;
+  }
+#else
+  // pd_disjoint_words is word-atomic in this implementation.
+  pd_disjoint_words(from, to, count);
+#endif // AMD64
+}
+
+static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
+  pd_conjoint_words(from, to, count);
+}
+
+static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
+  pd_disjoint_words(from, to, count);
+}
+
+static void pd_conjoint_bytes(void* from, void* to, size_t count) {
+#ifdef AMD64
+  (void)memmove(to, from, count);
+#else
+  // Includes a zero-count check.
+  intx temp;
+  __asm__ volatile("        testl   %6,%6          ;"
+                   "        jz      13f            ;"
+                   "        cmpl    %4,%5          ;"
+                   "        leal    -1(%4,%6),%3   ;"
+                   "        jbe     1f             ;"
+                   "        cmpl    %7,%5          ;"
+                   "        jbe     8f             ;"
+                   "1:      cmpl    $3,%6          ;"
+                   "        jbe     6f             ;"
+                   "        movl    %6,%3          ;"
+                   "        movl    $4,%2          ;"
+                   "        subl    %4,%2          ;"
+                   "        andl    $3,%2          ;"
+                   "        jz      2f             ;"
+                   "        subl    %6,%3          ;"
+                   "        rep;    smovb          ;"
+                   "2:      movl    %7,%2          ;"
+                   "        shrl    $2,%2          ;"
+                   "        jz      5f             ;"
+                   "        cmpl    $32,%2         ;"
+                   "        ja      4f             ;"
+                   "        subl    %4,%1          ;"
+                   "3:      movl    (%4),%%edx     ;"
+                   "        movl    %%edx,(%5,%4,1);"
+                   "        addl    $4,%0          ;"
+                   "        subl    $1,%2           ;"
+                   "        jnz     3b             ;"
+                   "        addl    %4,%1          ;"
+                   "        jmp     5f             ;"
+                   "4:      rep;    smovl          ;"
+                   "5:      movl    %7,%2          ;"
+                   "        andl    $3,%2          ;"
+                   "        jz      13f            ;"
+                   "6:      xorl    %7,%3          ;"
+                   "7:      movb    (%4,%7,1),%%dl ;"
+                   "        movb    %%dl,(%5,%7,1) ;"
+                   "        addl    $1,%3          ;"
+                   "        subl    $1,%2           ;"
+                   "        jnz     7b             ;"
+                   "        jmp     13f            ;"
+                   "8:      std                    ;"
+                   "        cmpl    $12,%2         ;"
+                   "        ja      9f             ;"
+                   "        movl    %7,%0          ;"
+                   "        leal    -1(%6,%5),%1   ;"
+                   "        jmp     11f            ;"
+                   "9:      xchgl   %3,%2          ;"
+                   "        movl    %6,%0          ;"
+                   "        addl    $1,%2          ;"
+                   "        leal    -1(%7,%5),%1   ;"
+                   "        andl    $3,%2          ;"
+                   "        jz      10f            ;"
+                   "        subl    %6,%3          ;"
+                   "        rep;    smovb          ;"
+                   "10:     movl    %7,%2          ;"
+                   "        subl    $3,%0          ;"
+                   "        shrl    $2,%2          ;"
+                   "        subl    $3,%1          ;"
+                   "        rep;    smovl          ;"
+                   "        andl    $3,%3          ;"
+                   "        jz      12f            ;"
+                   "        movl    %7,%2          ;"
+                   "        addl    $3,%0          ;"
+                   "        addl    $3,%1          ;"
+                   "11:     rep;    smovb          ;"
+                   "12:     cld                    ;"
+                   "13:     nop                    ;"
+                   : "=S" (from), "=D" (to), "=c" (count), "=r" (temp)
+                   : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
+                   : "memory", "flags", "%edx");
+#endif // AMD64
+}
+
+static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
+  pd_conjoint_bytes(from, to, count);
+}
+
+static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
+  _Copy_conjoint_jshorts_atomic(from, to, count);
+}
+
+static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
+#ifdef AMD64
+  _Copy_conjoint_jints_atomic(from, to, count);
+#else
+  assert(HeapWordSize == BytesPerInt, "heapwords and jints must be the same size");
+  // pd_conjoint_words is word-atomic in this implementation.
+  pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
+#endif // AMD64
+}
+
+static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
+#ifdef AMD64
+  _Copy_conjoint_jlongs_atomic(from, to, count);
+#else
+  // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
+  if (from > to) {
+    while (count-- > 0) {
+      __asm__ volatile("fildll (%0); fistpll (%1)"
+                       :
+                       : "r" (from), "r" (to)
+                       : "memory" );
+      ++from;
+      ++to;
+    }
+  } else {
+    while (count-- > 0) {
+      __asm__ volatile("fildll (%0,%2,8); fistpll (%1,%2,8)"
+                       :
+                       : "r" (from), "r" (to), "r" (count)
+                       : "memory" );
+    }
+  }
+#endif // AMD64
+}
+
+static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
+#ifdef AMD64
+  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
+  _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
+#else
+  assert(HeapWordSize == BytesPerOop, "heapwords and oops must be the same size");
+  // pd_conjoint_words is word-atomic in this implementation.
+  pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
+#endif // AMD64
+}
+
+static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
+  _Copy_arrayof_conjoint_bytes(from, to, count);
+}
+
+static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
+  _Copy_arrayof_conjoint_jshorts(from, to, count);
+}
+
+static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
+#ifdef AMD64
+   _Copy_arrayof_conjoint_jints(from, to, count);
+#else
+  pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
+#endif // AMD64
+}
+
+static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
+#ifdef AMD64
+  _Copy_arrayof_conjoint_jlongs(from, to, count);
+#else
+  pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
+#endif // AMD64
+}
+
+static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
+#ifdef AMD64
+  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
+  _Copy_arrayof_conjoint_jlongs(from, to, count);
+#else
+  pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
+#endif // AMD64
+}
+
+#endif // OS_CPU_BSD_X86_VM_COPY_BSD_X86_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_X86_VM_GLOBALS_BSD_X86_HPP
+#define OS_CPU_BSD_X86_VM_GLOBALS_BSD_X86_HPP
+
+//
+// Sets the default values for platform dependent flags used by the runtime system.
+// (see globals.hpp)
+//
+define_pd_global(bool, DontYieldALot,            false);
+#ifdef AMD64
+define_pd_global(intx, ThreadStackSize,          1024); // 0 => use system default
+define_pd_global(intx, VMThreadStackSize,        1024);
+#else
+// ThreadStackSize 320 allows a couple of test cases to run while
+// keeping the number of threads that can be created high.  System
+// default ThreadStackSize appears to be 512 which is too big.
+define_pd_global(intx, ThreadStackSize,          320);
+define_pd_global(intx, VMThreadStackSize,        512);
+#endif // AMD64
+
+define_pd_global(intx, CompilerThreadStackSize,  0);
+define_pd_global(intx, SurvivorRatio,            8);
+
+define_pd_global(uintx, JVMInvokeMethodSlack,    8192);
+
+// Only used on 64 bit platforms
+define_pd_global(uintx, HeapBaseMinAddress,      2*G);
+// Only used on 64 bit Windows platforms
+define_pd_global(bool, UseVectoredExceptions,    false);
+
+#endif // OS_CPU_BSD_X86_VM_GLOBALS_BSD_X86_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/orderAccess_bsd_x86.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 OS_CPU_BSD_X86_VM_ORDERACCESS_BSD_X86_INLINE_HPP
+#define OS_CPU_BSD_X86_VM_ORDERACCESS_BSD_X86_INLINE_HPP
+
+#include "runtime/atomic.hpp"
+#include "runtime/orderAccess.hpp"
+#include "vm_version_x86.hpp"
+
+// Implementation of class OrderAccess.
+
+inline void OrderAccess::loadload()   { acquire(); }
+inline void OrderAccess::storestore() { release(); }
+inline void OrderAccess::loadstore()  { acquire(); }
+inline void OrderAccess::storeload()  { fence(); }
+
+inline void OrderAccess::acquire() {
+  volatile intptr_t local_dummy;
+#ifdef AMD64
+  __asm__ volatile ("movq 0(%%rsp), %0" : "=r" (local_dummy) : : "memory");
+#else
+  __asm__ volatile ("movl 0(%%esp),%0" : "=r" (local_dummy) : : "memory");
+#endif // AMD64
+}
+
+inline void OrderAccess::release() {
+  // Avoid hitting the same cache-line from
+  // different threads.
+  volatile jint local_dummy = 0;
+}
+
+inline void OrderAccess::fence() {
+  if (os::is_MP()) {
+    // always use locked addl since mfence is sometimes expensive
+#ifdef AMD64
+    __asm__ volatile ("lock; addl $0,0(%%rsp)" : : : "cc", "memory");
+#else
+    __asm__ volatile ("lock; addl $0,0(%%esp)" : : : "cc", "memory");
+#endif
+  }
+}
+
+inline jbyte    OrderAccess::load_acquire(volatile jbyte*   p) { return *p; }
+inline jshort   OrderAccess::load_acquire(volatile jshort*  p) { return *p; }
+inline jint     OrderAccess::load_acquire(volatile jint*    p) { return *p; }
+inline jlong    OrderAccess::load_acquire(volatile jlong*   p) { return Atomic::load(p); }
+inline jubyte   OrderAccess::load_acquire(volatile jubyte*  p) { return *p; }
+inline jushort  OrderAccess::load_acquire(volatile jushort* p) { return *p; }
+inline juint    OrderAccess::load_acquire(volatile juint*   p) { return *p; }
+inline julong   OrderAccess::load_acquire(volatile julong*  p) { return Atomic::load((volatile jlong*)p); }
+inline jfloat   OrderAccess::load_acquire(volatile jfloat*  p) { return *p; }
+inline jdouble  OrderAccess::load_acquire(volatile jdouble* p) { return *p; }
+
+inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t*   p) { return *p; }
+inline void*    OrderAccess::load_ptr_acquire(volatile void*       p) { return *(void* volatile *)p; }
+inline void*    OrderAccess::load_ptr_acquire(const volatile void* p) { return *(void* const volatile *)p; }
+
+inline void     OrderAccess::release_store(volatile jbyte*   p, jbyte   v) { *p = v; }
+inline void     OrderAccess::release_store(volatile jshort*  p, jshort  v) { *p = v; }
+inline void     OrderAccess::release_store(volatile jint*    p, jint    v) { *p = v; }
+inline void     OrderAccess::release_store(volatile jlong*   p, jlong   v) { Atomic::store(v, p); }
+inline void     OrderAccess::release_store(volatile jubyte*  p, jubyte  v) { *p = v; }
+inline void     OrderAccess::release_store(volatile jushort* p, jushort v) { *p = v; }
+inline void     OrderAccess::release_store(volatile juint*   p, juint   v) { *p = v; }
+inline void     OrderAccess::release_store(volatile julong*  p, julong  v) { Atomic::store((jlong)v, (volatile jlong*)p); }
+inline void     OrderAccess::release_store(volatile jfloat*  p, jfloat  v) { *p = v; }
+inline void     OrderAccess::release_store(volatile jdouble* p, jdouble v) { *p = v; }
+
+inline void     OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { *p = v; }
+inline void     OrderAccess::release_store_ptr(volatile void*     p, void*    v) { *(void* volatile *)p = v; }
+
+inline void     OrderAccess::store_fence(jbyte*  p, jbyte  v) {
+  __asm__ volatile (  "xchgb (%2),%0"
+                    : "=q" (v)
+                    : "0" (v), "r" (p)
+                    : "memory");
+}
+inline void     OrderAccess::store_fence(jshort* p, jshort v) {
+  __asm__ volatile (  "xchgw (%2),%0"
+                    : "=r" (v)
+                    : "0" (v), "r" (p)
+                    : "memory");
+}
+inline void     OrderAccess::store_fence(jint*   p, jint   v) {
+  __asm__ volatile (  "xchgl (%2),%0"
+                    : "=r" (v)
+                    : "0" (v), "r" (p)
+                    : "memory");
+}
+
+inline void     OrderAccess::store_fence(jlong*   p, jlong   v) {
+#ifdef AMD64
+  __asm__ __volatile__ ("xchgq (%2), %0"
+                        : "=r" (v)
+                        : "0" (v), "r" (p)
+                        : "memory");
+#else
+  *p = v; fence();
+#endif // AMD64
+}
+
+// AMD64 copied the bodies for the the signed version. 32bit did this. As long as the
+// compiler does the inlining this is simpler.
+inline void     OrderAccess::store_fence(jubyte*  p, jubyte  v) { store_fence((jbyte*)p,  (jbyte)v);  }
+inline void     OrderAccess::store_fence(jushort* p, jushort v) { store_fence((jshort*)p, (jshort)v); }
+inline void     OrderAccess::store_fence(juint*   p, juint   v) { store_fence((jint*)p,   (jint)v);   }
+inline void     OrderAccess::store_fence(julong*  p, julong  v) { store_fence((jlong*)p,  (jlong)v);  }
+inline void     OrderAccess::store_fence(jfloat*  p, jfloat  v) { *p = v; fence(); }
+inline void     OrderAccess::store_fence(jdouble* p, jdouble v) { *p = v; fence(); }
+
+inline void     OrderAccess::store_ptr_fence(intptr_t* p, intptr_t v) {
+#ifdef AMD64
+  __asm__ __volatile__ ("xchgq (%2), %0"
+                        : "=r" (v)
+                        : "0" (v), "r" (p)
+                        : "memory");
+#else
+  store_fence((jint*)p, (jint)v);
+#endif // AMD64
+}
+
+inline void     OrderAccess::store_ptr_fence(void**    p, void*    v) {
+#ifdef AMD64
+  __asm__ __volatile__ ("xchgq (%2), %0"
+                        : "=r" (v)
+                        : "0" (v), "r" (p)
+                        : "memory");
+#else
+  store_fence((jint*)p, (jint)v);
+#endif // AMD64
+}
+
+// Must duplicate definitions instead of calling store_fence because we don't want to cast away volatile.
+inline void     OrderAccess::release_store_fence(volatile jbyte*  p, jbyte  v) {
+  __asm__ volatile (  "xchgb (%2),%0"
+                    : "=q" (v)
+                    : "0" (v), "r" (p)
+                    : "memory");
+}
+inline void     OrderAccess::release_store_fence(volatile jshort* p, jshort v) {
+  __asm__ volatile (  "xchgw (%2),%0"
+                    : "=r" (v)
+                    : "0" (v), "r" (p)
+                    : "memory");
+}
+inline void     OrderAccess::release_store_fence(volatile jint*   p, jint   v) {
+  __asm__ volatile (  "xchgl (%2),%0"
+                    : "=r" (v)
+                    : "0" (v), "r" (p)
+                    : "memory");
+}
+
+inline void     OrderAccess::release_store_fence(volatile jlong*   p, jlong   v) {
+#ifdef AMD64
+  __asm__ __volatile__ (  "xchgq (%2), %0"
+                          : "=r" (v)
+                          : "0" (v), "r" (p)
+                          : "memory");
+#else
+  release_store(p, v); fence();
+#endif // AMD64
+}
+
+inline void     OrderAccess::release_store_fence(volatile jubyte*  p, jubyte  v) { release_store_fence((volatile jbyte*)p,  (jbyte)v);  }
+inline void     OrderAccess::release_store_fence(volatile jushort* p, jushort v) { release_store_fence((volatile jshort*)p, (jshort)v); }
+inline void     OrderAccess::release_store_fence(volatile juint*   p, juint   v) { release_store_fence((volatile jint*)p,   (jint)v);   }
+inline void     OrderAccess::release_store_fence(volatile julong*  p, julong  v) { release_store_fence((volatile jlong*)p,  (jlong)v);  }
+
+inline void     OrderAccess::release_store_fence(volatile jfloat*  p, jfloat  v) { *p = v; fence(); }
+inline void     OrderAccess::release_store_fence(volatile jdouble* p, jdouble v) { *p = v; fence(); }
+
+inline void     OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) {
+#ifdef AMD64
+  __asm__ __volatile__ (  "xchgq (%2), %0"
+                          : "=r" (v)
+                          : "0" (v), "r" (p)
+                          : "memory");
+#else
+  release_store_fence((volatile jint*)p, (jint)v);
+#endif // AMD64
+}
+inline void     OrderAccess::release_store_ptr_fence(volatile void*     p, void*    v) {
+#ifdef AMD64
+  __asm__ __volatile__ (  "xchgq (%2), %0"
+                          : "=r" (v)
+                          : "0" (v), "r" (p)
+                          : "memory");
+#else
+  release_store_fence((volatile jint*)p, (jint)v);
+#endif // AMD64
+}
+
+#endif // OS_CPU_BSD_X86_VM_ORDERACCESS_BSD_X86_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,1128 @@
+/*
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+// no precompiled headers
+#include "assembler_x86.inline.hpp"
+#include "classfile/classLoader.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "classfile/vmSymbols.hpp"
+#include "code/icBuffer.hpp"
+#include "code/vtableStubs.hpp"
+#include "interpreter/interpreter.hpp"
+#include "jvm_bsd.h"
+#include "memory/allocation.inline.hpp"
+#include "mutex_bsd.inline.hpp"
+#include "nativeInst_x86.hpp"
+#include "os_share_bsd.hpp"
+#include "prims/jniFastGetField.hpp"
+#include "prims/jvm.h"
+#include "prims/jvm_misc.hpp"
+#include "runtime/arguments.hpp"
+#include "runtime/extendedPC.hpp"
+#include "runtime/frame.inline.hpp"
+#include "runtime/interfaceSupport.hpp"
+#include "runtime/java.hpp"
+#include "runtime/javaCalls.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/osThread.hpp"
+#include "runtime/sharedRuntime.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "runtime/timer.hpp"
+#include "thread_bsd.inline.hpp"
+#include "utilities/events.hpp"
+#include "utilities/vmError.hpp"
+#ifdef COMPILER1
+#include "c1/c1_Runtime1.hpp"
+#endif
+#ifdef COMPILER2
+#include "opto/runtime.hpp"
+#endif
+
+// put OS-includes here
+# include <sys/types.h>
+# include <sys/mman.h>
+# include <pthread.h>
+# include <signal.h>
+# include <errno.h>
+# include <dlfcn.h>
+# include <stdlib.h>
+# include <stdio.h>
+# include <unistd.h>
+# include <sys/resource.h>
+# include <pthread.h>
+# include <sys/stat.h>
+# include <sys/time.h>
+# include <sys/utsname.h>
+# include <sys/socket.h>
+# include <sys/wait.h>
+# include <pwd.h>
+# include <poll.h>
+#ifndef __OpenBSD__
+# include <ucontext.h>
+#endif
+
+#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__) && !defined(__NetBSD__)
+# include <pthread_np.h>
+#endif
+
+#ifdef AMD64
+#define SPELL_REG_SP "rsp"
+#define SPELL_REG_FP "rbp"
+#else
+#define SPELL_REG_SP "esp"
+#define SPELL_REG_FP "ebp"
+#endif // AMD64
+
+#ifdef __FreeBSD__
+# define context_trapno uc_mcontext.mc_trapno
+# ifdef AMD64
+#  define context_pc uc_mcontext.mc_rip
+#  define context_sp uc_mcontext.mc_rsp
+#  define context_fp uc_mcontext.mc_rbp
+#  define context_rip uc_mcontext.mc_rip
+#  define context_rsp uc_mcontext.mc_rsp
+#  define context_rbp uc_mcontext.mc_rbp
+#  define context_rax uc_mcontext.mc_rax
+#  define context_rbx uc_mcontext.mc_rbx
+#  define context_rcx uc_mcontext.mc_rcx
+#  define context_rdx uc_mcontext.mc_rdx
+#  define context_rsi uc_mcontext.mc_rsi
+#  define context_rdi uc_mcontext.mc_rdi
+#  define context_r8  uc_mcontext.mc_r8
+#  define context_r9  uc_mcontext.mc_r9
+#  define context_r10 uc_mcontext.mc_r10
+#  define context_r11 uc_mcontext.mc_r11
+#  define context_r12 uc_mcontext.mc_r12
+#  define context_r13 uc_mcontext.mc_r13
+#  define context_r14 uc_mcontext.mc_r14
+#  define context_r15 uc_mcontext.mc_r15
+#  define context_flags uc_mcontext.mc_flags
+#  define context_err uc_mcontext.mc_err
+# else
+#  define context_pc uc_mcontext.mc_eip
+#  define context_sp uc_mcontext.mc_esp
+#  define context_fp uc_mcontext.mc_ebp
+#  define context_eip uc_mcontext.mc_eip
+#  define context_esp uc_mcontext.mc_esp
+#  define context_eax uc_mcontext.mc_eax
+#  define context_ebx uc_mcontext.mc_ebx
+#  define context_ecx uc_mcontext.mc_ecx
+#  define context_edx uc_mcontext.mc_edx
+#  define context_ebp uc_mcontext.mc_ebp
+#  define context_esi uc_mcontext.mc_esi
+#  define context_edi uc_mcontext.mc_edi
+#  define context_eflags uc_mcontext.mc_eflags
+#  define context_trapno uc_mcontext.mc_trapno
+# endif
+#endif
+
+#ifdef __APPLE__
+# if __DARWIN_UNIX03 && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+  // 10.5 UNIX03 member name prefixes
+  #define DU3_PREFIX(s, m) __ ## s.__ ## m
+# else
+  #define DU3_PREFIX(s, m) s ## . ## m
+# endif
+
+# ifdef AMD64
+#  define context_pc context_rip
+#  define context_sp context_rsp
+#  define context_fp context_rbp
+#  define context_rip uc_mcontext->DU3_PREFIX(ss,rip)
+#  define context_rsp uc_mcontext->DU3_PREFIX(ss,rsp)
+#  define context_rax uc_mcontext->DU3_PREFIX(ss,rax)
+#  define context_rbx uc_mcontext->DU3_PREFIX(ss,rbx)
+#  define context_rcx uc_mcontext->DU3_PREFIX(ss,rcx)
+#  define context_rdx uc_mcontext->DU3_PREFIX(ss,rdx)
+#  define context_rbp uc_mcontext->DU3_PREFIX(ss,rbp)
+#  define context_rsi uc_mcontext->DU3_PREFIX(ss,rsi)
+#  define context_rdi uc_mcontext->DU3_PREFIX(ss,rdi)
+#  define context_r8  uc_mcontext->DU3_PREFIX(ss,r8)
+#  define context_r9  uc_mcontext->DU3_PREFIX(ss,r9)
+#  define context_r10 uc_mcontext->DU3_PREFIX(ss,r10)
+#  define context_r11 uc_mcontext->DU3_PREFIX(ss,r11)
+#  define context_r12 uc_mcontext->DU3_PREFIX(ss,r12)
+#  define context_r13 uc_mcontext->DU3_PREFIX(ss,r13)
+#  define context_r14 uc_mcontext->DU3_PREFIX(ss,r14)
+#  define context_r15 uc_mcontext->DU3_PREFIX(ss,r15)
+#  define context_flags uc_mcontext->DU3_PREFIX(ss,rflags)
+#  define context_trapno uc_mcontext->DU3_PREFIX(es,trapno)
+#  define context_err uc_mcontext->DU3_PREFIX(es,err)
+# else
+#  define context_pc context_eip
+#  define context_sp context_esp
+#  define context_fp context_ebp
+#  define context_eip uc_mcontext->DU3_PREFIX(ss,eip)
+#  define context_esp uc_mcontext->DU3_PREFIX(ss,esp)
+#  define context_eax uc_mcontext->DU3_PREFIX(ss,eax)
+#  define context_ebx uc_mcontext->DU3_PREFIX(ss,ebx)
+#  define context_ecx uc_mcontext->DU3_PREFIX(ss,ecx)
+#  define context_edx uc_mcontext->DU3_PREFIX(ss,edx)
+#  define context_ebp uc_mcontext->DU3_PREFIX(ss,ebp)
+#  define context_esi uc_mcontext->DU3_PREFIX(ss,esi)
+#  define context_edi uc_mcontext->DU3_PREFIX(ss,edi)
+#  define context_eflags uc_mcontext->DU3_PREFIX(ss,eflags)
+#  define context_trapno uc_mcontext->DU3_PREFIX(es,trapno)
+# endif
+#endif
+
+#ifdef __OpenBSD__
+# define context_trapno sc_trapno
+# ifdef AMD64
+#  define context_pc sc_rip
+#  define context_sp sc_rsp
+#  define context_fp sc_rbp
+#  define context_rip sc_rip
+#  define context_rsp sc_rsp
+#  define context_rbp sc_rbp
+#  define context_rax sc_rax
+#  define context_rbx sc_rbx
+#  define context_rcx sc_rcx
+#  define context_rdx sc_rdx
+#  define context_rsi sc_rsi
+#  define context_rdi sc_rdi
+#  define context_r8  sc_r8
+#  define context_r9  sc_r9
+#  define context_r10 sc_r10
+#  define context_r11 sc_r11
+#  define context_r12 sc_r12
+#  define context_r13 sc_r13
+#  define context_r14 sc_r14
+#  define context_r15 sc_r15
+#  define context_flags sc_rflags
+#  define context_err sc_err
+# else
+#  define context_pc sc_eip
+#  define context_sp sc_esp
+#  define context_fp sc_ebp
+#  define context_eip sc_eip
+#  define context_esp sc_esp
+#  define context_eax sc_eax
+#  define context_ebx sc_ebx
+#  define context_ecx sc_ecx
+#  define context_edx sc_edx
+#  define context_ebp sc_ebp
+#  define context_esi sc_esi
+#  define context_edi sc_edi
+#  define context_eflags sc_eflags
+#  define context_trapno sc_trapno
+# endif
+#endif
+
+#ifdef __NetBSD__
+# define context_trapno uc_mcontext.__gregs[_REG_TRAPNO]
+# ifdef AMD64
+#  define __register_t __greg_t
+#  define context_pc uc_mcontext.__gregs[_REG_RIP]
+#  define context_sp uc_mcontext.__gregs[_REG_URSP]
+#  define context_fp uc_mcontext.__gregs[_REG_RBP]
+#  define context_rip uc_mcontext.__gregs[_REG_RIP]
+#  define context_rsp uc_mcontext.__gregs[_REG_URSP]
+#  define context_rax uc_mcontext.__gregs[_REG_RAX]
+#  define context_rbx uc_mcontext.__gregs[_REG_RBX]
+#  define context_rcx uc_mcontext.__gregs[_REG_RCX]
+#  define context_rdx uc_mcontext.__gregs[_REG_RDX]
+#  define context_rbp uc_mcontext.__gregs[_REG_RBP]
+#  define context_rsi uc_mcontext.__gregs[_REG_RSI]
+#  define context_rdi uc_mcontext.__gregs[_REG_RDI]
+#  define context_r8  uc_mcontext.__gregs[_REG_R8]
+#  define context_r9  uc_mcontext.__gregs[_REG_R9]
+#  define context_r10 uc_mcontext.__gregs[_REG_R10]
+#  define context_r11 uc_mcontext.__gregs[_REG_R11]
+#  define context_r12 uc_mcontext.__gregs[_REG_R12]
+#  define context_r13 uc_mcontext.__gregs[_REG_R13]
+#  define context_r14 uc_mcontext.__gregs[_REG_R14]
+#  define context_r15 uc_mcontext.__gregs[_REG_R15]
+#  define context_flags uc_mcontext.__gregs[_REG_RFL]
+#  define context_err uc_mcontext.__gregs[_REG_ERR]
+# else
+#  define context_pc uc_mcontext.__gregs[_REG_EIP]
+#  define context_sp uc_mcontext.__gregs[_REG_UESP]
+#  define context_fp uc_mcontext.__gregs[_REG_EBP]
+#  define context_eip uc_mcontext.__gregs[_REG_EIP]
+#  define context_esp uc_mcontext.__gregs[_REG_UESP]
+#  define context_eax uc_mcontext.__gregs[_REG_EAX]
+#  define context_ebx uc_mcontext.__gregs[_REG_EBX]
+#  define context_ecx uc_mcontext.__gregs[_REG_ECX]
+#  define context_edx uc_mcontext.__gregs[_REG_EDX]
+#  define context_ebp uc_mcontext.__gregs[_REG_EBP]
+#  define context_esi uc_mcontext.__gregs[_REG_ESI]
+#  define context_edi uc_mcontext.__gregs[_REG_EDI]
+#  define context_eflags uc_mcontext.__gregs[_REG_EFL]
+#  define context_trapno uc_mcontext.__gregs[_REG_TRAPNO]
+# endif
+#endif
+
+address os::current_stack_pointer() {
+#if defined(__clang__) || defined(__llvm__)
+  register void *esp;
+  __asm__("mov %%"SPELL_REG_SP", %0":"=r"(esp));
+  return (address) esp;
+#elif defined(SPARC_WORKS)
+  register void *esp;
+  __asm__("mov %%"SPELL_REG_SP", %0":"=r"(esp));
+  return (address) ((char*)esp + sizeof(long)*2);
+#else
+  register void *esp __asm__ (SPELL_REG_SP);
+  return (address) esp;
+#endif
+}
+
+char* os::non_memory_address_word() {
+  // Must never look like an address returned by reserve_memory,
+  // even in its subfields (as defined by the CPU immediate fields,
+  // if the CPU splits constants across multiple instructions).
+
+  return (char*) -1;
+}
+
+void os::initialize_thread() {
+// Nothing to do.
+}
+
+address os::Bsd::ucontext_get_pc(ucontext_t * uc) {
+  return (address)uc->context_pc;
+}
+
+intptr_t* os::Bsd::ucontext_get_sp(ucontext_t * uc) {
+  return (intptr_t*)uc->context_sp;
+}
+
+intptr_t* os::Bsd::ucontext_get_fp(ucontext_t * uc) {
+  return (intptr_t*)uc->context_fp;
+}
+
+// For Forte Analyzer AsyncGetCallTrace profiling support - thread
+// is currently interrupted by SIGPROF.
+// os::Solaris::fetch_frame_from_ucontext() tries to skip nested signal
+// frames. Currently we don't do that on Bsd, so it's the same as
+// os::fetch_frame_from_context().
+ExtendedPC os::Bsd::fetch_frame_from_ucontext(Thread* thread,
+  ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) {
+
+  assert(thread != NULL, "just checking");
+  assert(ret_sp != NULL, "just checking");
+  assert(ret_fp != NULL, "just checking");
+
+  return os::fetch_frame_from_context(uc, ret_sp, ret_fp);
+}
+
+ExtendedPC os::fetch_frame_from_context(void* ucVoid,
+                    intptr_t** ret_sp, intptr_t** ret_fp) {
+
+  ExtendedPC  epc;
+  ucontext_t* uc = (ucontext_t*)ucVoid;
+
+  if (uc != NULL) {
+    epc = ExtendedPC(os::Bsd::ucontext_get_pc(uc));
+    if (ret_sp) *ret_sp = os::Bsd::ucontext_get_sp(uc);
+    if (ret_fp) *ret_fp = os::Bsd::ucontext_get_fp(uc);
+  } else {
+    // construct empty ExtendedPC for return value checking
+    epc = ExtendedPC(NULL);
+    if (ret_sp) *ret_sp = (intptr_t *)NULL;
+    if (ret_fp) *ret_fp = (intptr_t *)NULL;
+  }
+
+  return epc;
+}
+
+frame os::fetch_frame_from_context(void* ucVoid) {
+  intptr_t* sp;
+  intptr_t* fp;
+  ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
+  return frame(sp, fp, epc.pc());
+}
+
+// By default, gcc always save frame pointer (%ebp/%rbp) on stack. It may get
+// turned off by -fomit-frame-pointer,
+frame os::get_sender_for_C_frame(frame* fr) {
+  return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
+}
+
+intptr_t* _get_previous_fp() {
+#if defined(SPARC_WORKS) || defined(__clang__)
+  register intptr_t **ebp;
+  __asm__("mov %%"SPELL_REG_FP", %0":"=r"(ebp));
+#else
+  register intptr_t **ebp __asm__ (SPELL_REG_FP);
+#endif
+  return (intptr_t*) *ebp;   // we want what it points to.
+}
+
+
+frame os::current_frame() {
+  intptr_t* fp = _get_previous_fp();
+  frame myframe((intptr_t*)os::current_stack_pointer(),
+                (intptr_t*)fp,
+                CAST_FROM_FN_PTR(address, os::current_frame));
+  if (os::is_first_C_frame(&myframe)) {
+    // stack is not walkable
+    return frame(NULL, NULL, NULL);
+  } else {
+    return os::get_sender_for_C_frame(&myframe);
+  }
+}
+
+// Utility functions
+
+// From IA32 System Programming Guide
+enum {
+  trap_page_fault = 0xE
+};
+
+extern "C" void Fetch32PFI () ;
+extern "C" void Fetch32Resume () ;
+#ifdef AMD64
+extern "C" void FetchNPFI () ;
+extern "C" void FetchNResume () ;
+#endif // AMD64
+
+extern "C" JNIEXPORT int
+JVM_handle_bsd_signal(int sig,
+                        siginfo_t* info,
+                        void* ucVoid,
+                        int abort_if_unrecognized) {
+  ucontext_t* uc = (ucontext_t*) ucVoid;
+
+  Thread* t = ThreadLocalStorage::get_thread_slow();
+
+  SignalHandlerMark shm(t);
+
+  // Note: it's not uncommon that JNI code uses signal/sigset to install
+  // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
+  // or have a SIGILL handler when detecting CPU type). When that happens,
+  // JVM_handle_bsd_signal() might be invoked with junk info/ucVoid. To
+  // avoid unnecessary crash when libjsig is not preloaded, try handle signals
+  // that do not require siginfo/ucontext first.
+
+  if (sig == SIGPIPE || sig == SIGXFSZ) {
+    // allow chained handler to go first
+    if (os::Bsd::chained_handler(sig, info, ucVoid)) {
+      return true;
+    } else {
+      if (PrintMiscellaneous && (WizardMode || Verbose)) {
+        char buf[64];
+        warning("Ignoring %s - see bugs 4229104 or 646499219",
+                os::exception_name(sig, buf, sizeof(buf)));
+      }
+      return true;
+    }
+  }
+
+  JavaThread* thread = NULL;
+  VMThread* vmthread = NULL;
+  if (os::Bsd::signal_handlers_are_installed) {
+    if (t != NULL ){
+      if(t->is_Java_thread()) {
+        thread = (JavaThread*)t;
+      }
+      else if(t->is_VM_thread()){
+        vmthread = (VMThread *)t;
+      }
+    }
+  }
+/*
+  NOTE: does not seem to work on bsd.
+  if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) {
+    // can't decode this kind of signal
+    info = NULL;
+  } else {
+    assert(sig == info->si_signo, "bad siginfo");
+  }
+*/
+  // decide if this trap can be handled by a stub
+  address stub = NULL;
+
+  address pc          = NULL;
+
+  //%note os_trap_1
+  if (info != NULL && uc != NULL && thread != NULL) {
+    pc = (address) os::Bsd::ucontext_get_pc(uc);
+
+    if (pc == (address) Fetch32PFI) {
+       uc->context_pc = intptr_t(Fetch32Resume) ;
+       return 1 ;
+    }
+#ifdef AMD64
+    if (pc == (address) FetchNPFI) {
+       uc->context_pc = intptr_t (FetchNResume) ;
+       return 1 ;
+    }
+#endif // AMD64
+
+    // Handle ALL stack overflow variations here
+    if (sig == SIGSEGV || sig == SIGBUS) {
+      address addr = (address) info->si_addr;
+
+      // check if fault address is within thread stack
+      if (addr < thread->stack_base() &&
+          addr >= thread->stack_base() - thread->stack_size()) {
+        // stack overflow
+        if (thread->in_stack_yellow_zone(addr)) {
+          thread->disable_stack_yellow_zone();
+          if (thread->thread_state() == _thread_in_Java) {
+            // Throw a stack overflow exception.  Guard pages will be reenabled
+            // while unwinding the stack.
+            stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
+          } else {
+            // Thread was in the vm or native code.  Return and try to finish.
+            return 1;
+          }
+        } else if (thread->in_stack_red_zone(addr)) {
+          // Fatal red zone violation.  Disable the guard pages and fall through
+          // to handle_unexpected_exception way down below.
+          thread->disable_stack_red_zone();
+          tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
+#ifndef _ALLBSD_SOURCE
+        } else {
+          // Accessing stack address below sp may cause SEGV if current
+          // thread has MAP_GROWSDOWN stack. This should only happen when
+          // current thread was created by user code with MAP_GROWSDOWN flag
+          // and then attached to VM. See notes in os_bsd.cpp.
+          if (thread->osthread()->expanding_stack() == 0) {
+             thread->osthread()->set_expanding_stack();
+             if (os::Bsd::manually_expand_stack(thread, addr)) {
+               thread->osthread()->clear_expanding_stack();
+               return 1;
+             }
+             thread->osthread()->clear_expanding_stack();
+          } else {
+             fatal("recursive segv. expanding stack.");
+          }
+#endif
+        }
+      }
+    }
+
+    if (thread->thread_state() == _thread_in_Java) {
+      // Java thread running in Java code => find exception handler if any
+      // a fault inside compiled code, the interpreter, or a stub
+
+      if ((sig == SIGSEGV || sig == SIGBUS) && os::is_poll_address((address)info->si_addr)) {
+        stub = SharedRuntime::get_poll_stub(pc);
+#if defined(__APPLE__) && !defined(AMD64)
+      // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.
+      // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from
+      // being called, so only do so if the implicit NULL check is not necessary.
+      } else if (sig == SIGBUS && MacroAssembler::needs_explicit_null_check((int)info->si_addr)) {
+#else
+      } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
+#endif
+        // BugId 4454115: A read from a MappedByteBuffer can fault
+        // here if the underlying file has been truncated.
+        // Do not crash the VM in such a case.
+        CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
+        nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
+        if (nm != NULL && nm->has_unsafe_access()) {
+          stub = StubRoutines::handler_for_unsafe_access();
+        }
+      }
+      else
+
+#ifdef AMD64
+      if (sig == SIGFPE  &&
+          (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
+        stub =
+          SharedRuntime::
+          continuation_for_implicit_exception(thread,
+                                              pc,
+                                              SharedRuntime::
+                                              IMPLICIT_DIVIDE_BY_ZERO);
+#ifdef __APPLE__
+      } else if (sig == SIGFPE && info->si_code == FPE_NOOP) {
+        int op = pc[0];
+
+        // Skip REX
+        if ((pc[0] & 0xf0) == 0x40) {
+          op = pc[1];
+        } else {
+          op = pc[0];
+        }
+
+        // Check for IDIV
+        if (op == 0xF7) {
+          stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime:: IMPLICIT_DIVIDE_BY_ZERO);
+        } else {
+          // TODO: handle more cases if we are using other x86 instructions
+          //   that can generate SIGFPE signal.
+          tty->print_cr("unknown opcode 0x%X with SIGFPE.", op);
+          fatal("please update this code.");
+        }
+#endif /* __APPLE__ */
+
+#else
+      if (sig == SIGFPE /* && info->si_code == FPE_INTDIV */) {
+        // HACK: si_code does not work on bsd 2.2.12-20!!!
+        int op = pc[0];
+        if (op == 0xDB) {
+          // FIST
+          // TODO: The encoding of D2I in i486.ad can cause an exception
+          // prior to the fist instruction if there was an invalid operation
+          // pending. We want to dismiss that exception. From the win_32
+          // side it also seems that if it really was the fist causing
+          // the exception that we do the d2i by hand with different
+          // rounding. Seems kind of weird.
+          // NOTE: that we take the exception at the NEXT floating point instruction.
+          assert(pc[0] == 0xDB, "not a FIST opcode");
+          assert(pc[1] == 0x14, "not a FIST opcode");
+          assert(pc[2] == 0x24, "not a FIST opcode");
+          return true;
+        } else if (op == 0xF7) {
+          // IDIV
+          stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
+        } else {
+          // TODO: handle more cases if we are using other x86 instructions
+          //   that can generate SIGFPE signal on bsd.
+          tty->print_cr("unknown opcode 0x%X with SIGFPE.", op);
+          fatal("please update this code.");
+        }
+#endif // AMD64
+      } else if ((sig == SIGSEGV || sig == SIGBUS) &&
+               !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) {
+          // Determination of interpreter/vtable stub/compiled code null exception
+          stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
+      }
+    } else if (thread->thread_state() == _thread_in_vm &&
+               sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
+               thread->doing_unsafe_access()) {
+        stub = StubRoutines::handler_for_unsafe_access();
+    }
+
+    // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
+    // and the heap gets shrunk before the field access.
+    if ((sig == SIGSEGV) || (sig == SIGBUS)) {
+      address addr = JNI_FastGetField::find_slowcase_pc(pc);
+      if (addr != (address)-1) {
+        stub = addr;
+      }
+    }
+
+    // Check to see if we caught the safepoint code in the
+    // process of write protecting the memory serialization page.
+    // It write enables the page immediately after protecting it
+    // so we can just return to retry the write.
+    if ((sig == SIGSEGV || sig == SIGBUS) &&
+        os::is_memory_serialize_page(thread, (address) info->si_addr)) {
+      // Block current thread until the memory serialize page permission restored.
+      os::block_on_serialize_page_trap();
+      return true;
+    }
+  }
+
+#ifndef AMD64
+  // Execution protection violation
+  //
+  // This should be kept as the last step in the triage.  We don't
+  // have a dedicated trap number for a no-execute fault, so be
+  // conservative and allow other handlers the first shot.
+  //
+  // Note: We don't test that info->si_code == SEGV_ACCERR here.
+  // this si_code is so generic that it is almost meaningless; and
+  // the si_code for this condition may change in the future.
+  // Furthermore, a false-positive should be harmless.
+  if (UnguardOnExecutionViolation > 0 &&
+      (sig == SIGSEGV || sig == SIGBUS) &&
+      uc->context_trapno == trap_page_fault) {
+    int page_size = os::vm_page_size();
+    address addr = (address) info->si_addr;
+    address pc = os::Bsd::ucontext_get_pc(uc);
+    // Make sure the pc and the faulting address are sane.
+    //
+    // If an instruction spans a page boundary, and the page containing
+    // the beginning of the instruction is executable but the following
+    // page is not, the pc and the faulting address might be slightly
+    // different - we still want to unguard the 2nd page in this case.
+    //
+    // 15 bytes seems to be a (very) safe value for max instruction size.
+    bool pc_is_near_addr =
+      (pointer_delta((void*) addr, (void*) pc, sizeof(char)) < 15);
+    bool instr_spans_page_boundary =
+      (align_size_down((intptr_t) pc ^ (intptr_t) addr,
+                       (intptr_t) page_size) > 0);
+
+    if (pc == addr || (pc_is_near_addr && instr_spans_page_boundary)) {
+      static volatile address last_addr =
+        (address) os::non_memory_address_word();
+
+      // In conservative mode, don't unguard unless the address is in the VM
+      if (addr != last_addr &&
+          (UnguardOnExecutionViolation > 1 || os::address_is_in_vm(addr))) {
+
+        // Set memory to RWX and retry
+        address page_start =
+          (address) align_size_down((intptr_t) addr, (intptr_t) page_size);
+        bool res = os::protect_memory((char*) page_start, page_size,
+                                      os::MEM_PROT_RWX);
+
+        if (PrintMiscellaneous && Verbose) {
+          char buf[256];
+          jio_snprintf(buf, sizeof(buf), "Execution protection violation "
+                       "at " INTPTR_FORMAT
+                       ", unguarding " INTPTR_FORMAT ": %s, errno=%d", addr,
+                       page_start, (res ? "success" : "failed"), errno);
+          tty->print_raw_cr(buf);
+        }
+        stub = pc;
+
+        // Set last_addr so if we fault again at the same address, we don't end
+        // up in an endless loop.
+        //
+        // There are two potential complications here.  Two threads trapping at
+        // the same address at the same time could cause one of the threads to
+        // think it already unguarded, and abort the VM.  Likely very rare.
+        //
+        // The other race involves two threads alternately trapping at
+        // different addresses and failing to unguard the page, resulting in
+        // an endless loop.  This condition is probably even more unlikely than
+        // the first.
+        //
+        // Although both cases could be avoided by using locks or thread local
+        // last_addr, these solutions are unnecessary complication: this
+        // handler is a best-effort safety net, not a complete solution.  It is
+        // disabled by default and should only be used as a workaround in case
+        // we missed any no-execute-unsafe VM code.
+
+        last_addr = addr;
+      }
+    }
+  }
+#endif // !AMD64
+
+  if (stub != NULL) {
+    // save all thread context in case we need to restore it
+    if (thread != NULL) thread->set_saved_exception_pc(pc);
+
+    uc->context_pc = (intptr_t)stub;
+    return true;
+  }
+
+  // signal-chaining
+  if (os::Bsd::chained_handler(sig, info, ucVoid)) {
+     return true;
+  }
+
+  if (!abort_if_unrecognized) {
+    // caller wants another chance, so give it to him
+    return false;
+  }
+
+  if (pc == NULL && uc != NULL) {
+    pc = os::Bsd::ucontext_get_pc(uc);
+  }
+
+  // unmask current signal
+  sigset_t newset;
+  sigemptyset(&newset);
+  sigaddset(&newset, sig);
+  sigprocmask(SIG_UNBLOCK, &newset, NULL);
+
+  VMError err(t, sig, pc, info, ucVoid);
+  err.report_and_die();
+
+  ShouldNotReachHere();
+}
+
+#ifdef _ALLBSD_SOURCE
+// From solaris_i486.s ported to bsd_i486.s
+extern "C" void fixcw();
+#endif
+
+void os::Bsd::init_thread_fpu_state(void) {
+#ifndef AMD64
+# ifdef _ALLBSD_SOURCE
+  // Set fpu to 53 bit precision. This happens too early to use a stub.
+  fixcw();
+# else
+  // set fpu to 53 bit precision
+  set_fpu_control_word(0x27f);
+# endif
+#endif // !AMD64
+}
+
+#ifndef _ALLBSD_SOURCE
+int os::Bsd::get_fpu_control_word(void) {
+#ifdef AMD64
+  return 0;
+#else
+  int fpu_control;
+  _FPU_GETCW(fpu_control);
+  return fpu_control & 0xffff;
+#endif // AMD64
+}
+
+void os::Bsd::set_fpu_control_word(int fpu_control) {
+#ifndef AMD64
+  _FPU_SETCW(fpu_control);
+#endif // !AMD64
+}
+#endif
+
+// Check that the bsd kernel version is 2.4 or higher since earlier
+// versions do not support SSE without patches.
+bool os::supports_sse() {
+#if defined(AMD64) || defined(_ALLBSD_SOURCE)
+  return true;
+#else
+  struct utsname uts;
+  if( uname(&uts) != 0 ) return false; // uname fails?
+  char *minor_string;
+  int major = strtol(uts.release,&minor_string,10);
+  int minor = strtol(minor_string+1,NULL,10);
+  bool result = (major > 2 || (major==2 && minor >= 4));
+#ifndef PRODUCT
+  if (PrintMiscellaneous && Verbose) {
+    tty->print("OS version is %d.%d, which %s support SSE/SSE2\n",
+               major,minor, result ? "DOES" : "does NOT");
+  }
+#endif
+  return result;
+#endif // AMD64
+}
+
+bool os::is_allocatable(size_t bytes) {
+#ifdef AMD64
+  // unused on amd64?
+  return true;
+#else
+
+  if (bytes < 2 * G) {
+    return true;
+  }
+
+  char* addr = reserve_memory(bytes, NULL);
+
+  if (addr != NULL) {
+    release_memory(addr, bytes);
+  }
+
+  return addr != NULL;
+#endif // AMD64
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// thread stack
+
+#ifdef AMD64
+size_t os::Bsd::min_stack_allowed  = 64 * K;
+
+// amd64: pthread on amd64 is always in floating stack mode
+bool os::Bsd::supports_variable_stack_size() {  return true; }
+#else
+size_t os::Bsd::min_stack_allowed  =  (48 DEBUG_ONLY(+4))*K;
+
+#ifdef __GNUC__
+#define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;})
+#endif
+
+#ifdef _ALLBSD_SOURCE
+bool os::Bsd::supports_variable_stack_size() { return true; }
+#else
+// Test if pthread library can support variable thread stack size. BsdThreads
+// in fixed stack mode allocates 2M fixed slot for each thread. BsdThreads
+// in floating stack mode and NPTL support variable stack size.
+bool os::Bsd::supports_variable_stack_size() {
+  if (os::Bsd::is_NPTL()) {
+     // NPTL, yes
+     return true;
+
+  } else {
+    // Note: We can't control default stack size when creating a thread.
+    // If we use non-default stack size (pthread_attr_setstacksize), both
+    // floating stack and non-floating stack BsdThreads will return the
+    // same value. This makes it impossible to implement this function by
+    // detecting thread stack size directly.
+    //
+    // An alternative approach is to check %gs. Fixed-stack BsdThreads
+    // do not use %gs, so its value is 0. Floating-stack BsdThreads use
+    // %gs (either as LDT selector or GDT selector, depending on kernel)
+    // to access thread specific data.
+    //
+    // Note that %gs is a reserved glibc register since early 2001, so
+    // applications are not allowed to change its value (Ulrich Drepper from
+    // Redhat confirmed that all known offenders have been modified to use
+    // either %fs or TSD). In the worst case scenario, when VM is embedded in
+    // a native application that plays with %gs, we might see non-zero %gs
+    // even BsdThreads is running in fixed stack mode. As the result, we'll
+    // return true and skip _thread_safety_check(), so we may not be able to
+    // detect stack-heap collisions. But otherwise it's harmless.
+    //
+#ifdef __GNUC__
+    return (GET_GS() != 0);
+#else
+    return false;
+#endif
+  }
+}
+#endif
+#endif // AMD64
+
+// return default stack size for thr_type
+size_t os::Bsd::default_stack_size(os::ThreadType thr_type) {
+  // default stack size (compiler thread needs larger stack)
+#ifdef AMD64
+  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
+#else
+  size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K);
+#endif // AMD64
+  return s;
+}
+
+size_t os::Bsd::default_guard_size(os::ThreadType thr_type) {
+  // Creating guard page is very expensive. Java thread has HotSpot
+  // guard page, only enable glibc guard page for non-Java threads.
+  return (thr_type == java_thread ? 0 : page_size());
+}
+
+// Java thread:
+//
+//   Low memory addresses
+//    +------------------------+
+//    |                        |\  JavaThread created by VM does not have glibc
+//    |    glibc guard page    | - guard, attached Java thread usually has
+//    |                        |/  1 page glibc guard.
+// P1 +------------------------+ Thread::stack_base() - Thread::stack_size()
+//    |                        |\
+//    |  HotSpot Guard Pages   | - red and yellow pages
+//    |                        |/
+//    +------------------------+ JavaThread::stack_yellow_zone_base()
+//    |                        |\
+//    |      Normal Stack      | -
+//    |                        |/
+// P2 +------------------------+ Thread::stack_base()
+//
+// Non-Java thread:
+//
+//   Low memory addresses
+//    +------------------------+
+//    |                        |\
+//    |  glibc guard page      | - usually 1 page
+//    |                        |/
+// P1 +------------------------+ Thread::stack_base() - Thread::stack_size()
+//    |                        |\
+//    |      Normal Stack      | -
+//    |                        |/
+// P2 +------------------------+ Thread::stack_base()
+//
+// ** P1 (aka bottom) and size ( P2 = P1 - size) are the address and stack size returned from
+//    pthread_attr_getstack()
+
+static void current_stack_region(address * bottom, size_t * size) {
+#ifdef __APPLE__
+  pthread_t self = pthread_self();
+  void *stacktop = pthread_get_stackaddr_np(self);
+  *size = pthread_get_stacksize_np(self);
+  *bottom = (address) stacktop - *size;
+#elif defined(__OpenBSD__)
+  stack_t ss;
+  int rslt = pthread_stackseg_np(pthread_self(), &ss);
+
+  if (rslt != 0)
+    fatal(err_msg("pthread_stackseg_np failed with err = %d", rslt));
+
+  *bottom = (address)((char *)ss.ss_sp - ss.ss_size);
+  *size   = ss.ss_size;
+#elif defined(_ALLBSD_SOURCE)
+  pthread_attr_t attr;
+
+  int rslt = pthread_attr_init(&attr);
+
+  // JVM needs to know exact stack location, abort if it fails
+  if (rslt != 0)
+    fatal(err_msg("pthread_attr_init failed with err = %d", rslt));
+
+  rslt = pthread_attr_get_np(pthread_self(), &attr);
+
+  if (rslt != 0)
+    fatal(err_msg("pthread_attr_get_np failed with err = %d", rslt));
+
+  if (pthread_attr_getstackaddr(&attr, (void **)bottom) != 0 ||
+    pthread_attr_getstacksize(&attr, size) != 0) {
+    fatal("Can not locate current stack attributes!");
+  }
+
+  pthread_attr_destroy(&attr);
+#else
+  if (os::Bsd::is_initial_thread()) {
+     // initial thread needs special handling because pthread_getattr_np()
+     // may return bogus value.
+     *bottom = os::Bsd::initial_thread_stack_bottom();
+     *size   = os::Bsd::initial_thread_stack_size();
+  } else {
+     pthread_attr_t attr;
+
+     int rslt = pthread_getattr_np(pthread_self(), &attr);
+
+     // JVM needs to know exact stack location, abort if it fails
+     if (rslt != 0) {
+       if (rslt == ENOMEM) {
+         vm_exit_out_of_memory(0, "pthread_getattr_np");
+       } else {
+         fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
+       }
+     }
+
+     if (pthread_attr_getstack(&attr, (void **)bottom, size) != 0) {
+         fatal("Can not locate current stack attributes!");
+     }
+
+     pthread_attr_destroy(&attr);
+
+  }
+#endif
+  assert(os::current_stack_pointer() >= *bottom &&
+         os::current_stack_pointer() < *bottom + *size, "just checking");
+}
+
+address os::current_stack_base() {
+  address bottom;
+  size_t size;
+  current_stack_region(&bottom, &size);
+  return (bottom + size);
+}
+
+size_t os::current_stack_size() {
+  // stack size includes normal stack and HotSpot guard pages
+  address bottom;
+  size_t size;
+  current_stack_region(&bottom, &size);
+  return size;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// helper functions for fatal error handler
+
+void os::print_context(outputStream *st, void *context) {
+  if (context == NULL) return;
+
+  ucontext_t *uc = (ucontext_t*)context;
+  st->print_cr("Registers:");
+#ifdef AMD64
+  st->print(  "RAX=" INTPTR_FORMAT, uc->context_rax);
+  st->print(", RBX=" INTPTR_FORMAT, uc->context_rbx);
+  st->print(", RCX=" INTPTR_FORMAT, uc->context_rcx);
+  st->print(", RDX=" INTPTR_FORMAT, uc->context_rdx);
+  st->cr();
+  st->print(  "RSP=" INTPTR_FORMAT, uc->context_rsp);
+  st->print(", RBP=" INTPTR_FORMAT, uc->context_rbp);
+  st->print(", RSI=" INTPTR_FORMAT, uc->context_rsi);
+  st->print(", RDI=" INTPTR_FORMAT, uc->context_rdi);
+  st->cr();
+  st->print(  "R8 =" INTPTR_FORMAT, uc->context_r8);
+  st->print(", R9 =" INTPTR_FORMAT, uc->context_r9);
+  st->print(", R10=" INTPTR_FORMAT, uc->context_r10);
+  st->print(", R11=" INTPTR_FORMAT, uc->context_r11);
+  st->cr();
+  st->print(  "R12=" INTPTR_FORMAT, uc->context_r12);
+  st->print(", R13=" INTPTR_FORMAT, uc->context_r13);
+  st->print(", R14=" INTPTR_FORMAT, uc->context_r14);
+  st->print(", R15=" INTPTR_FORMAT, uc->context_r15);
+  st->cr();
+  st->print(  "RIP=" INTPTR_FORMAT, uc->context_rip);
+  st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_flags);
+  st->print(", ERR=" INTPTR_FORMAT, uc->context_err);
+  st->cr();
+  st->print("  TRAPNO=" INTPTR_FORMAT, uc->context_trapno);
+#else
+  st->print(  "EAX=" INTPTR_FORMAT, uc->context_eax);
+  st->print(", EBX=" INTPTR_FORMAT, uc->context_ebx);
+  st->print(", ECX=" INTPTR_FORMAT, uc->context_ecx);
+  st->print(", EDX=" INTPTR_FORMAT, uc->context_edx);
+  st->cr();
+  st->print(  "ESP=" INTPTR_FORMAT, uc->context_esp);
+  st->print(", EBP=" INTPTR_FORMAT, uc->context_ebp);
+  st->print(", ESI=" INTPTR_FORMAT, uc->context_esi);
+  st->print(", EDI=" INTPTR_FORMAT, uc->context_edi);
+  st->cr();
+  st->print(  "EIP=" INTPTR_FORMAT, uc->context_eip);
+  st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_eflags);
+#endif // AMD64
+  st->cr();
+  st->cr();
+
+  intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc);
+  st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
+  print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
+  st->cr();
+
+  // Note: it may be unsafe to inspect memory near pc. For example, pc may
+  // point to garbage if entry point in an nmethod is corrupted. Leave
+  // this at the end, and hope for the best.
+  address pc = os::Bsd::ucontext_get_pc(uc);
+  st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
+  print_hex_dump(st, pc - 32, pc + 32, sizeof(char));
+}
+
+void os::print_register_info(outputStream *st, void *context) {
+  if (context == NULL) return;
+
+  ucontext_t *uc = (ucontext_t*)context;
+
+  st->print_cr("Register to memory mapping:");
+  st->cr();
+
+  // this is horrendously verbose but the layout of the registers in the
+  // context does not match how we defined our abstract Register set, so
+  // we can't just iterate through the gregs area
+
+  // this is only for the "general purpose" registers
+
+#ifdef AMD64
+  st->print("RAX="); print_location(st, uc->context_rax);
+  st->print("RBX="); print_location(st, uc->context_rbx);
+  st->print("RCX="); print_location(st, uc->context_rcx);
+  st->print("RDX="); print_location(st, uc->context_rdx);
+  st->print("RSP="); print_location(st, uc->context_rsp);
+  st->print("RBP="); print_location(st, uc->context_rbp);
+  st->print("RSI="); print_location(st, uc->context_rsi);
+  st->print("RDI="); print_location(st, uc->context_rdi);
+  st->print("R8 ="); print_location(st, uc->context_r8);
+  st->print("R9 ="); print_location(st, uc->context_r9);
+  st->print("R10="); print_location(st, uc->context_r10);
+  st->print("R11="); print_location(st, uc->context_r11);
+  st->print("R12="); print_location(st, uc->context_r12);
+  st->print("R13="); print_location(st, uc->context_r13);
+  st->print("R14="); print_location(st, uc->context_r14);
+  st->print("R15="); print_location(st, uc->context_r15);
+#else
+  st->print("EAX="); print_location(st, uc->context_eax);
+  st->print("EBX="); print_location(st, uc->context_ebx);
+  st->print("ECX="); print_location(st, uc->context_ecx);
+  st->print("EDX="); print_location(st, uc->context_edx);
+  st->print("ESP="); print_location(st, uc->context_esp);
+  st->print("EBP="); print_location(st, uc->context_ebp);
+  st->print("ESI="); print_location(st, uc->context_esi);
+  st->print("EDI="); print_location(st, uc->context_edi);
+#endif // AMD64
+
+  st->cr();
+}
+
+void os::setup_fpu() {
+#ifndef AMD64
+  address fpu_cntrl = StubRoutines::addr_fpu_cntrl_wrd_std();
+  __asm__ volatile (  "fldcw (%0)" :
+                      : "r" (fpu_cntrl) : "memory");
+#endif // !AMD64
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_X86_VM_OS_BSD_X86_HPP
+#define OS_CPU_BSD_X86_VM_OS_BSD_X86_HPP
+
+  static void setup_fpu();
+  static bool supports_sse();
+
+  static bool is_allocatable(size_t bytes);
+
+  // Used to register dynamic code cache area with the OS
+  // Note: Currently only used in 64 bit Windows implementations
+  static bool register_code_area(char *low, char *high) { return true; }
+
+#endif // OS_CPU_BSD_X86_VM_OS_BSD_X86_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/prefetch_bsd_x86.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_X86_VM_PREFETCH_BSD_X86_INLINE_HPP
+#define OS_CPU_BSD_X86_VM_PREFETCH_BSD_X86_INLINE_HPP
+
+#include "runtime/prefetch.hpp"
+
+
+inline void Prefetch::read (void *loc, intx interval) {
+#ifdef AMD64
+  __asm__ ("prefetcht0 (%0,%1,1)" : : "r" (loc), "r" (interval));
+#endif // AMD64
+}
+
+inline void Prefetch::write(void *loc, intx interval) {
+#ifdef AMD64
+
+  // Do not use the 3dnow prefetchw instruction.  It isn't supported on em64t.
+  //  __asm__ ("prefetchw (%0,%1,1)" : : "r" (loc), "r" (interval));
+  __asm__ ("prefetcht0 (%0,%1,1)" : : "r" (loc), "r" (interval));
+
+#endif // AMD64
+}
+
+#endif // OS_CPU_BSD_X86_VM_PREFETCH_BSD_X86_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "runtime/threadLocalStorage.hpp"
+#include "thread_bsd.inline.hpp"
+
+// Map stack pointer (%esp) to thread pointer for faster TLS access
+//
+// Here we use a flat table for better performance. Getting current thread
+// is down to one memory access (read _sp_map[%esp>>12]) in generated code
+// and two in runtime code (-fPIC code needs an extra load for _sp_map).
+//
+// This code assumes stack page is not shared by different threads. It works
+// in 32-bit VM when page size is 4K (or a multiple of 4K, if that matters).
+//
+// Notice that _sp_map is allocated in the bss segment, which is ZFOD
+// (zero-fill-on-demand). While it reserves 4M address space upfront,
+// actual memory pages are committed on demand.
+//
+// If an application creates and destroys a lot of threads, usually the
+// stack space freed by a thread will soon get reused by new thread
+// (this is especially true in NPTL or BsdThreads in fixed-stack mode).
+// No memory page in _sp_map is wasted.
+//
+// However, it's still possible that we might end up populating &
+// committing a large fraction of the 4M table over time, but the actual
+// amount of live data in the table could be quite small. The max wastage
+// is less than 4M bytes. If it becomes an issue, we could use madvise()
+// with MADV_DONTNEED to reclaim unused (i.e. all-zero) pages in _sp_map.
+// MADV_DONTNEED on Bsd keeps the virtual memory mapping, but zaps the
+// physical memory page (i.e. similar to MADV_FREE on Solaris).
+
+#ifndef AMD64
+Thread* ThreadLocalStorage::_sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)];
+#endif // !AMD64
+
+void ThreadLocalStorage::generate_code_for_get_thread() {
+    // nothing we can do here for user-level thread
+}
+
+void ThreadLocalStorage::pd_init() {
+#ifndef AMD64
+  assert(align_size_down(os::vm_page_size(), PAGE_SIZE) == os::vm_page_size(),
+         "page size must be multiple of PAGE_SIZE");
+#endif // !AMD64
+}
+
+void ThreadLocalStorage::pd_set_thread(Thread* thread) {
+  os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);
+
+#ifndef AMD64
+  address stack_top = os::current_stack_base();
+  size_t stack_size = os::current_stack_size();
+
+  for (address p = stack_top - stack_size; p < stack_top; p += PAGE_SIZE) {
+    // pd_set_thread() is called with non-NULL value when a new thread is
+    // created/attached, or with NULL value when a thread is about to exit.
+    // If both "thread" and the corresponding _sp_map[] entry are non-NULL,
+    // they should have the same value. Otherwise it might indicate that the
+    // stack page is shared by multiple threads. However, a more likely cause
+    // for this assertion to fail is that an attached thread exited without
+    // detaching itself from VM, which is a program error and could cause VM
+    // to crash.
+    assert(thread == NULL || _sp_map[(uintptr_t)p >> PAGE_SHIFT] == NULL ||
+           thread == _sp_map[(uintptr_t)p >> PAGE_SHIFT],
+           "thread exited without detaching from VM??");
+    _sp_map[(uintptr_t)p >> PAGE_SHIFT] = thread;
+  }
+#endif // !AMD64
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_X86_VM_THREADLS_BSD_X86_HPP
+#define OS_CPU_BSD_X86_VM_THREADLS_BSD_X86_HPP
+
+  // Processor dependent parts of ThreadLocalStorage
+
+#ifndef AMD64
+  // map stack pointer to thread pointer - see notes in threadLS_bsd_x86.cpp
+  #define SP_BITLENGTH  32
+#ifndef PAGE_SHIFT
+  #define PAGE_SHIFT    12
+  #define PAGE_SIZE     (1UL << PAGE_SHIFT)
+#endif
+  static Thread* _sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)];
+#endif // !AMD64
+
+public:
+
+#ifndef AMD64
+  static Thread** sp_map_addr() { return _sp_map; }
+#endif // !AMD64
+
+  static Thread* thread() {
+#ifdef AMD64
+    return (Thread*) os::thread_local_storage_at(thread_index());
+#else
+    uintptr_t sp;
+    __asm__ volatile ("movl %%esp, %0" : "=r" (sp));
+    return _sp_map[sp >> PAGE_SHIFT];
+#endif // AMD64
+  }
+
+#endif // OS_CPU_BSD_X86_VM_THREADLS_BSD_X86_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "runtime/frame.inline.hpp"
+#include "thread_bsd.inline.hpp"
+
+// For Forte Analyzer AsyncGetCallTrace profiling support - thread is
+// currently interrupted by SIGPROF
+bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
+  void* ucontext, bool isInJava) {
+
+  assert(Thread::current() == this, "caller must be current thread");
+  assert(this->is_Java_thread(), "must be JavaThread");
+
+  JavaThread* jt = (JavaThread *)this;
+
+  // If we have a last_Java_frame, then we should use it even if
+  // isInJava == true.  It should be more reliable than ucontext info.
+  if (jt->has_last_Java_frame()) {
+    *fr_addr = jt->pd_last_frame();
+    return true;
+  }
+
+  // At this point, we don't have a last_Java_frame, so
+  // we try to glean some information out of the ucontext
+  // if we were running Java code when SIGPROF came in.
+  if (isInJava) {
+    ucontext_t* uc = (ucontext_t*) ucontext;
+
+    intptr_t* ret_fp;
+    intptr_t* ret_sp;
+    ExtendedPC addr = os::Bsd::fetch_frame_from_ucontext(this, uc,
+      &ret_sp, &ret_fp);
+    if (addr.pc() == NULL || ret_sp == NULL ) {
+      // ucontext wasn't useful
+      return false;
+    }
+
+    frame ret_frame(ret_sp, ret_fp, addr.pc());
+    if (!ret_frame.safe_for_sender(jt)) {
+#ifdef COMPILER2
+      // C2 uses ebp as a general register see if NULL fp helps
+      frame ret_frame2(ret_sp, NULL, addr.pc());
+      if (!ret_frame2.safe_for_sender(jt)) {
+        // nothing else to try if the frame isn't good
+        return false;
+      }
+      ret_frame = ret_frame2;
+#else
+      // nothing else to try if the frame isn't good
+      return false;
+#endif /* COMPILER2 */
+    }
+    *fr_addr = ret_frame;
+    return true;
+  }
+
+  // nothing else to try
+  return false;
+}
+
+void JavaThread::cache_global_variables() { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/thread_bsd_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_X86_VM_THREAD_BSD_X86_HPP
+#define OS_CPU_BSD_X86_VM_THREAD_BSD_X86_HPP
+
+ private:
+  void pd_initialize() {
+    _anchor.clear();
+  }
+
+  frame pd_last_frame() {
+    assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
+    if (_anchor.last_Java_pc() != NULL) {
+      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
+    } else {
+      // This will pick up pc from sp
+      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
+    }
+  }
+
+ public:
+  // Mutators are highly dangerous....
+  intptr_t* last_Java_fp()                       { return _anchor.last_Java_fp(); }
+  void  set_last_Java_fp(intptr_t* fp)           { _anchor.set_last_Java_fp(fp);   }
+
+  void set_base_of_stack_pointer(intptr_t* base_sp) {
+  }
+
+  static ByteSize last_Java_fp_offset()          {
+    return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_fp_offset();
+  }
+
+  intptr_t* base_of_stack_pointer() {
+    return NULL;
+  }
+  void record_base_of_stack_pointer() {
+  }
+
+  bool pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext,
+    bool isInJava);
+
+  // These routines are only used on cpu architectures that
+  // have separate register stacks (Itanium).
+  static bool register_stack_overflow() { return false; }
+  static void enable_register_stack_guard() {}
+  static void disable_register_stack_guard() {}
+
+#endif // OS_CPU_BSD_X86_VM_THREAD_BSD_X86_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_X86_VM_VMSTRUCTS_BSD_X86_HPP
+#define OS_CPU_BSD_X86_VM_VMSTRUCTS_BSD_X86_HPP
+
+// These are the OS and CPU-specific fields, types and integer
+// constants required by the Serviceability Agent. This file is
+// referenced by vmStructs.cpp.
+
+#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \
+                                                                                                                                     \
+  /******************************/                                                                                                   \
+  /* Threads (NOTE: incomplete) */                                                                                                   \
+  /******************************/                                                                                                   \
+  nonstatic_field(OSThread,                      _thread_id,                                      pthread_t)                             \
+  nonstatic_field(OSThread,                      _pthread_id,                                     pthread_t)                         \
+  /* This must be the last entry, and must be present */                                                                             \
+  last_entry()
+
+
+#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type, last_entry) \
+                                                                          \
+  /**********************/                                                \
+  /* Posix Thread IDs   */                                                \
+  /**********************/                                                \
+                                                                          \
+  declare_integer_type(pid_t)                                             \
+  declare_unsigned_integer_type(pthread_t)                                \
+                                                                          \
+  /* This must be the last entry, and must be present */                  \
+  last_entry()
+
+#define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \
+                                                                        \
+  /* This must be the last entry, and must be present */                \
+  last_entry()
+
+#define VM_LONG_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \
+                                                                        \
+  /* This must be the last entry, and must be present */                \
+  last_entry()
+
+#endif // OS_CPU_BSD_X86_VM_VMSTRUCTS_BSD_X86_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/vm_version_bsd_x86.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 "runtime/os.hpp"
+#include "vm_version_x86.hpp"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/assembler_bsd_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2009 Red Hat, Inc.
+ * 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 "asm/assembler.hpp"
+#include "assembler_zero.inline.hpp"
+#include "runtime/os.hpp"
+#include "runtime/threadLocalStorage.hpp"
+
+// This file is intentionally empty
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/atomic_bsd_zero.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2011 Red Hat, Inc.
+ * 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 OS_CPU_BSD_ZERO_VM_ATOMIC_BSD_ZERO_INLINE_HPP
+#define OS_CPU_BSD_ZERO_VM_ATOMIC_BSD_ZERO_INLINE_HPP
+
+#include "orderAccess_bsd_zero.inline.hpp"
+#include "runtime/atomic.hpp"
+#include "runtime/os.hpp"
+#include "vm_version_zero.hpp"
+
+// Implementation of class atomic
+
+#ifdef M68K
+
+/*
+ * __m68k_cmpxchg
+ *
+ * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
+ * Returns newval on success and oldval if no exchange happened.
+ * This implementation is processor specific and works on
+ * 68020 68030 68040 and 68060.
+ *
+ * It will not work on ColdFire, 68000 and 68010 since they lack the CAS
+ * instruction.
+ * Using a kernelhelper would be better for arch complete implementation.
+ *
+ */
+
+static inline int __m68k_cmpxchg(int oldval, int newval, volatile int *ptr) {
+  int ret;
+  __asm __volatile ("cas%.l %0,%2,%1"
+                   : "=d" (ret), "+m" (*(ptr))
+                   : "d" (newval), "0" (oldval));
+  return ret;
+}
+
+/* Perform an atomic compare and swap: if the current value of `*PTR'
+   is OLDVAL, then write NEWVAL into `*PTR'.  Return the contents of
+   `*PTR' before the operation.*/
+static inline int m68k_compare_and_swap(volatile int *ptr,
+                                        int oldval,
+                                        int newval) {
+  for (;;) {
+      int prev = *ptr;
+      if (prev != oldval)
+        return prev;
+
+      if (__m68k_cmpxchg (prev, newval, ptr) == newval)
+        // Success.
+        return prev;
+
+      // We failed even though prev == oldval.  Try again.
+    }
+}
+
+/* Atomically add an int to memory.  */
+static inline int m68k_add_and_fetch(volatile int *ptr, int add_value) {
+  for (;;) {
+      // Loop until success.
+
+      int prev = *ptr;
+
+      if (__m68k_cmpxchg (prev, prev + add_value, ptr) == prev + add_value)
+        return prev + add_value;
+    }
+}
+
+/* Atomically write VALUE into `*PTR' and returns the previous
+   contents of `*PTR'.  */
+static inline int m68k_lock_test_and_set(volatile int *ptr, int newval) {
+  for (;;) {
+      // Loop until success.
+      int prev = *ptr;
+
+      if (__m68k_cmpxchg (prev, newval, ptr) == prev)
+        return prev;
+    }
+}
+#endif // M68K
+
+#ifdef ARM
+
+/*
+ * __kernel_cmpxchg
+ *
+ * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
+ * Return zero if *ptr was changed or non-zero if no exchange happened.
+ * The C flag is also set if *ptr was changed to allow for assembly
+ * optimization in the calling code.
+ *
+ */
+
+typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr);
+#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *) 0xffff0fc0)
+
+
+
+/* Perform an atomic compare and swap: if the current value of `*PTR'
+   is OLDVAL, then write NEWVAL into `*PTR'.  Return the contents of
+   `*PTR' before the operation.*/
+static inline int arm_compare_and_swap(volatile int *ptr,
+                                       int oldval,
+                                       int newval) {
+  for (;;) {
+      int prev = *ptr;
+      if (prev != oldval)
+        return prev;
+
+      if (__kernel_cmpxchg (prev, newval, ptr) == 0)
+        // Success.
+        return prev;
+
+      // We failed even though prev == oldval.  Try again.
+    }
+}
+
+/* Atomically add an int to memory.  */
+static inline int arm_add_and_fetch(volatile int *ptr, int add_value) {
+  for (;;) {
+      // Loop until a __kernel_cmpxchg succeeds.
+
+      int prev = *ptr;
+
+      if (__kernel_cmpxchg (prev, prev + add_value, ptr) == 0)
+        return prev + add_value;
+    }
+}
+
+/* Atomically write VALUE into `*PTR' and returns the previous
+   contents of `*PTR'.  */
+static inline int arm_lock_test_and_set(volatile int *ptr, int newval) {
+  for (;;) {
+      // Loop until a __kernel_cmpxchg succeeds.
+      int prev = *ptr;
+
+      if (__kernel_cmpxchg (prev, newval, ptr) == 0)
+        return prev;
+    }
+}
+#endif // ARM
+
+inline void Atomic::store(jint store_value, volatile jint* dest) {
+#if !defined(ARM) && !defined(M68K)
+  __sync_synchronize();
+#endif
+  *dest = store_value;
+}
+
+inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) {
+#if !defined(ARM) && !defined(M68K)
+  __sync_synchronize();
+#endif
+  *dest = store_value;
+}
+
+inline jint Atomic::add(jint add_value, volatile jint* dest) {
+#ifdef ARM
+  return arm_add_and_fetch(dest, add_value);
+#else
+#ifdef M68K
+  return m68k_add_and_fetch(dest, add_value);
+#else
+  return __sync_add_and_fetch(dest, add_value);
+#endif // M68K
+#endif // ARM
+}
+
+inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
+#ifdef ARM
+  return arm_add_and_fetch(dest, add_value);
+#else
+#ifdef M68K
+  return m68k_add_and_fetch(dest, add_value);
+#else
+  return __sync_add_and_fetch(dest, add_value);
+#endif // M68K
+#endif // ARM
+}
+
+inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) {
+  return (void *) add_ptr(add_value, (volatile intptr_t *) dest);
+}
+
+inline void Atomic::inc(volatile jint* dest) {
+  add(1, dest);
+}
+
+inline void Atomic::inc_ptr(volatile intptr_t* dest) {
+  add_ptr(1, dest);
+}
+
+inline void Atomic::inc_ptr(volatile void* dest) {
+  add_ptr(1, dest);
+}
+
+inline void Atomic::dec(volatile jint* dest) {
+  add(-1, dest);
+}
+
+inline void Atomic::dec_ptr(volatile intptr_t* dest) {
+  add_ptr(-1, dest);
+}
+
+inline void Atomic::dec_ptr(volatile void* dest) {
+  add_ptr(-1, dest);
+}
+
+inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
+#ifdef ARM
+  return arm_lock_test_and_set(dest, exchange_value);
+#else
+#ifdef M68K
+  return m68k_lock_test_and_set(dest, exchange_value);
+#else
+  // __sync_lock_test_and_set is a bizarrely named atomic exchange
+  // operation.  Note that some platforms only support this with the
+  // limitation that the only valid value to store is the immediate
+  // constant 1.  There is a test for this in JNI_CreateJavaVM().
+  return __sync_lock_test_and_set (dest, exchange_value);
+#endif // M68K
+#endif // ARM
+}
+
+inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
+                                 volatile intptr_t* dest) {
+#ifdef ARM
+  return arm_lock_test_and_set(dest, exchange_value);
+#else
+#ifdef M68K
+  return m68k_lock_test_and_set(dest, exchange_value);
+#else
+  return __sync_lock_test_and_set (dest, exchange_value);
+#endif // M68K
+#endif // ARM
+}
+
+inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {
+  return (void *) xchg_ptr((intptr_t) exchange_value,
+                           (volatile intptr_t*) dest);
+}
+
+inline jint Atomic::cmpxchg(jint exchange_value,
+                            volatile jint* dest,
+                            jint compare_value) {
+#ifdef ARM
+  return arm_compare_and_swap(dest, compare_value, exchange_value);
+#else
+#ifdef M68K
+  return m68k_compare_and_swap(dest, compare_value, exchange_value);
+#else
+  return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
+#endif // M68K
+#endif // ARM
+}
+
+inline jlong Atomic::cmpxchg(jlong exchange_value,
+                             volatile jlong* dest,
+                             jlong compare_value) {
+
+  return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
+}
+
+inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value,
+                                    volatile intptr_t* dest,
+                                    intptr_t compare_value) {
+#ifdef ARM
+  return arm_compare_and_swap(dest, compare_value, exchange_value);
+#else
+#ifdef M68K
+  return m68k_compare_and_swap(dest, compare_value, exchange_value);
+#else
+  return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
+#endif // M68K
+#endif // ARM
+}
+
+inline void* Atomic::cmpxchg_ptr(void* exchange_value,
+                                 volatile void* dest,
+                                 void* compare_value) {
+
+  return (void *) cmpxchg_ptr((intptr_t) exchange_value,
+                              (volatile intptr_t*) dest,
+                              (intptr_t) compare_value);
+}
+
+inline jlong Atomic::load(volatile jlong* src) {
+  volatile jlong dest;
+  os::atomic_copy64(src, &dest);
+  return dest;
+}
+
+inline void Atomic::store(jlong store_value, jlong* dest) {
+  os::atomic_copy64((volatile jlong*)&store_value, (volatile jlong*)dest);
+}
+
+inline void Atomic::store(jlong store_value, volatile jlong* dest) {
+  os::atomic_copy64((volatile jlong*)&store_value, dest);
+}
+
+#endif // OS_CPU_BSD_ZERO_VM_ATOMIC_BSD_ZERO_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/bytes_bsd_zero.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_ZERO_VM_BYTES_BSD_ZERO_INLINE_HPP
+#define OS_CPU_BSD_ZERO_VM_BYTES_BSD_ZERO_INLINE_HPP
+
+// Efficient swapping of data bytes from Java byte
+// ordering to native byte ordering and vice versa.
+
+#ifdef __APPLE__
+#  include <libkern/OSByteOrder.h>
+#else
+#  include <sys/endian.h>
+#endif
+
+#if defined(__APPLE__)
+#  define bswap_16(x)   OSSwapInt16(x)
+#  define bswap_32(x)   OSSwapInt32(x)
+#  define bswap_64(x)   OSSwapInt64(x)
+#elif defined(__OpenBSD__)
+#  define bswap_16(x)   swap16(x)
+#  define bswap_32(x)   swap32(x)
+#  define bswap_64(x)   swap64(x)
+#elif defined(__NetBSD__)
+#  define bswap_16(x)   bswap16(x)
+#  define bswap_32(x)   bswap32(x)
+#  define bswap_64(x)   bswap64(x)
+#else
+#  define bswap_16(x) __bswap16(x)
+#  define bswap_32(x) __bswap32(x)
+#  define bswap_64(x) __bswap64(x)
+#endif
+
+inline u2 Bytes::swap_u2(u2 x) {
+  return bswap_16(x);
+}
+
+inline u4 Bytes::swap_u4(u4 x) {
+  return bswap_32(x);
+}
+
+inline u8 Bytes::swap_u8(u8 x) {
+  return bswap_64(x);
+}
+
+#endif // OS_CPU_BSD_ZERO_VM_BYTES_BSD_ZERO_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2010 Red Hat, Inc.
+ * 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 OS_CPU_BSD_ZERO_VM_GLOBALS_BSD_ZERO_HPP
+#define OS_CPU_BSD_ZERO_VM_GLOBALS_BSD_ZERO_HPP
+
+//
+// Set the default values for platform dependent flags used by the
+// runtime system.  See globals.hpp for details of what they do.
+//
+
+define_pd_global(bool,  DontYieldALot,           false);
+define_pd_global(intx,  ThreadStackSize,         1536);
+#ifdef _LP64
+define_pd_global(intx,  VMThreadStackSize,       1024);
+#else
+define_pd_global(intx,  VMThreadStackSize,       512);
+#endif // _LP64
+define_pd_global(intx,  CompilerThreadStackSize, 0);
+define_pd_global(uintx, JVMInvokeMethodSlack,    8192);
+
+define_pd_global(bool,  UseVectoredExceptions,   false);
+// Only used on 64 bit platforms
+define_pd_global(uintx, HeapBaseMinAddress,      2*G);
+
+#endif // OS_CPU_BSD_ZERO_VM_GLOBALS_BSD_ZERO_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/orderAccess_bsd_zero.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2009 Red Hat, Inc.
+ * 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 OS_CPU_BSD_ZERO_VM_ORDERACCESS_BSD_ZERO_INLINE_HPP
+#define OS_CPU_BSD_ZERO_VM_ORDERACCESS_BSD_ZERO_INLINE_HPP
+
+#include "runtime/orderAccess.hpp"
+#include "vm_version_zero.hpp"
+
+#ifdef ARM
+
+/*
+ * ARM Kernel helper for memory barrier.
+ * Using __asm __volatile ("":::"memory") does not work reliable on ARM
+ * and gcc __sync_synchronize(); implementation does not use the kernel
+ * helper for all gcc versions so it is unreliable to use as well.
+ */
+typedef void (__kernel_dmb_t) (void);
+#define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0)
+
+#define FULL_MEM_BARRIER __kernel_dmb()
+#define READ_MEM_BARRIER __kernel_dmb()
+#define WRITE_MEM_BARRIER __kernel_dmb()
+
+#else // ARM
+
+#define FULL_MEM_BARRIER __sync_synchronize()
+
+#ifdef PPC
+
+#ifdef __NO_LWSYNC__
+#define READ_MEM_BARRIER __asm __volatile ("sync":::"memory")
+#define WRITE_MEM_BARRIER __asm __volatile ("sync":::"memory")
+#else
+#define READ_MEM_BARRIER __asm __volatile ("lwsync":::"memory")
+#define WRITE_MEM_BARRIER __asm __volatile ("lwsync":::"memory")
+#endif
+
+#else // PPC
+
+#define READ_MEM_BARRIER __asm __volatile ("":::"memory")
+#define WRITE_MEM_BARRIER __asm __volatile ("":::"memory")
+
+#endif // PPC
+
+#endif // ARM
+
+
+inline void OrderAccess::loadload()   { acquire(); }
+inline void OrderAccess::storestore() { release(); }
+inline void OrderAccess::loadstore()  { acquire(); }
+inline void OrderAccess::storeload()  { fence(); }
+
+inline void OrderAccess::acquire() {
+  READ_MEM_BARRIER;
+}
+
+inline void OrderAccess::release() {
+  WRITE_MEM_BARRIER;
+}
+
+inline void OrderAccess::fence() {
+  FULL_MEM_BARRIER;
+}
+
+inline jbyte    OrderAccess::load_acquire(volatile jbyte*   p) { jbyte data = *p; acquire(); return data; }
+inline jshort   OrderAccess::load_acquire(volatile jshort*  p) { jshort data = *p; acquire(); return data; }
+inline jint     OrderAccess::load_acquire(volatile jint*    p) { jint data = *p; acquire(); return data; }
+inline jlong    OrderAccess::load_acquire(volatile jlong*   p) {
+  jlong tmp;
+  os::atomic_copy64(p, &tmp);
+  acquire();
+  return tmp;
+}
+inline jubyte    OrderAccess::load_acquire(volatile jubyte*   p) { jubyte data = *p; acquire(); return data; }
+inline jushort   OrderAccess::load_acquire(volatile jushort*  p) { jushort data = *p; acquire(); return data; }
+inline juint     OrderAccess::load_acquire(volatile juint*    p) { juint data = *p; acquire(); return data; }
+inline julong   OrderAccess::load_acquire(volatile julong*  p) {
+  julong tmp;
+  os::atomic_copy64(p, &tmp);
+  acquire();
+  return tmp;
+}
+inline jfloat   OrderAccess::load_acquire(volatile jfloat*  p) { jfloat data = *p; acquire(); return data; }
+inline jdouble  OrderAccess::load_acquire(volatile jdouble* p) {
+  jdouble tmp;
+  os::atomic_copy64(p, &tmp);
+  acquire();
+  return tmp;
+}
+
+inline intptr_t OrderAccess::load_ptr_acquire(volatile intptr_t*   p) {
+  intptr_t data = *p;
+  acquire();
+  return data;
+}
+inline void*    OrderAccess::load_ptr_acquire(volatile void*       p) {
+  void *data = *(void* volatile *)p;
+  acquire();
+  return data;
+}
+inline void*    OrderAccess::load_ptr_acquire(const volatile void* p) {
+  void *data = *(void* const volatile *)p;
+  acquire();
+  return data;
+}
+
+inline void     OrderAccess::release_store(volatile jbyte*   p, jbyte   v) { release(); *p = v; }
+inline void     OrderAccess::release_store(volatile jshort*  p, jshort  v) { release(); *p = v; }
+inline void     OrderAccess::release_store(volatile jint*    p, jint    v) { release(); *p = v; }
+inline void     OrderAccess::release_store(volatile jlong*   p, jlong   v)
+{ release(); os::atomic_copy64(&v, p); }
+inline void     OrderAccess::release_store(volatile jubyte*  p, jubyte  v) { release(); *p = v; }
+inline void     OrderAccess::release_store(volatile jushort* p, jushort v) { release(); *p = v; }
+inline void     OrderAccess::release_store(volatile juint*   p, juint   v) { release(); *p = v; }
+inline void     OrderAccess::release_store(volatile julong*  p, julong  v)
+{ release(); os::atomic_copy64(&v, p); }
+inline void     OrderAccess::release_store(volatile jfloat*  p, jfloat  v) { release(); *p = v; }
+inline void     OrderAccess::release_store(volatile jdouble* p, jdouble v)
+{ release(); os::atomic_copy64(&v, p); }
+
+inline void     OrderAccess::release_store_ptr(volatile intptr_t* p, intptr_t v) { release(); *p = v; }
+inline void     OrderAccess::release_store_ptr(volatile void*     p, void*    v)
+{ release(); *(void* volatile *)p = v; }
+
+inline void     OrderAccess::store_fence(jbyte*   p, jbyte   v) { *p = v; fence(); }
+inline void     OrderAccess::store_fence(jshort*  p, jshort  v) { *p = v; fence(); }
+inline void     OrderAccess::store_fence(jint*    p, jint    v) { *p = v; fence(); }
+inline void     OrderAccess::store_fence(jlong*   p, jlong   v) { os::atomic_copy64(&v, p); fence(); }
+inline void     OrderAccess::store_fence(jubyte*  p, jubyte  v) { *p = v; fence(); }
+inline void     OrderAccess::store_fence(jushort* p, jushort v) { *p = v; fence(); }
+inline void     OrderAccess::store_fence(juint*   p, juint   v) { *p = v; fence(); }
+inline void     OrderAccess::store_fence(julong*  p, julong  v) { os::atomic_copy64(&v, p); fence(); }
+inline void     OrderAccess::store_fence(jfloat*  p, jfloat  v) { *p = v; fence(); }
+inline void     OrderAccess::store_fence(jdouble* p, jdouble v) { os::atomic_copy64(&v, p); fence(); }
+
+inline void     OrderAccess::store_ptr_fence(intptr_t* p, intptr_t v) { *p = v; fence(); }
+inline void     OrderAccess::store_ptr_fence(void**    p, void*    v) { *p = v; fence(); }
+
+inline void     OrderAccess::release_store_fence(volatile jbyte*   p, jbyte   v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile jshort*  p, jshort  v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile jint*    p, jint    v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile jlong*   p, jlong   v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile jubyte*  p, jubyte  v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile jushort* p, jushort v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile juint*   p, juint   v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile julong*  p, julong  v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile jfloat*  p, jfloat  v) { release_store(p, v); fence(); }
+inline void     OrderAccess::release_store_fence(volatile jdouble* p, jdouble v) { release_store(p, v); fence(); }
+
+inline void     OrderAccess::release_store_ptr_fence(volatile intptr_t* p, intptr_t v) { release_store_ptr(p, v); fence(); }
+inline void     OrderAccess::release_store_ptr_fence(volatile void*     p, void*    v) { release_store_ptr(p, v); fence(); }
+
+#endif // OS_CPU_BSD_ZERO_VM_ORDERACCESS_BSD_ZERO_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,564 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
+ * 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.
+ *
+ */
+
+#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__) && !defined(__NetBSD__)
+#include <pthread.h>
+# include <pthread_np.h> /* For pthread_attr_get_np */
+#endif
+
+// no precompiled headers
+#include "assembler_zero.inline.hpp"
+#include "classfile/classLoader.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "classfile/vmSymbols.hpp"
+#include "code/icBuffer.hpp"
+#include "code/vtableStubs.hpp"
+#include "interpreter/interpreter.hpp"
+#include "jvm_bsd.h"
+#include "memory/allocation.inline.hpp"
+#include "mutex_bsd.inline.hpp"
+#include "nativeInst_zero.hpp"
+#include "os_share_bsd.hpp"
+#include "prims/jniFastGetField.hpp"
+#include "prims/jvm.h"
+#include "prims/jvm_misc.hpp"
+#include "runtime/arguments.hpp"
+#include "runtime/extendedPC.hpp"
+#include "runtime/frame.inline.hpp"
+#include "runtime/interfaceSupport.hpp"
+#include "runtime/java.hpp"
+#include "runtime/javaCalls.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/osThread.hpp"
+#include "runtime/sharedRuntime.hpp"
+#include "runtime/stubRoutines.hpp"
+#include "runtime/timer.hpp"
+#include "thread_bsd.inline.hpp"
+#include "utilities/events.hpp"
+#include "utilities/vmError.hpp"
+#ifdef COMPILER1
+#include "c1/c1_Runtime1.hpp"
+#endif
+#ifdef COMPILER2
+#include "opto/runtime.hpp"
+#endif
+
+address os::current_stack_pointer() {
+  address dummy = (address) &dummy;
+  return dummy;
+}
+
+frame os::get_sender_for_C_frame(frame* fr) {
+  ShouldNotCallThis();
+}
+
+frame os::current_frame() {
+  // The only thing that calls this is the stack printing code in
+  // VMError::report:
+  //   - Step 110 (printing stack bounds) uses the sp in the frame
+  //     to determine the amount of free space on the stack.  We
+  //     set the sp to a close approximation of the real value in
+  //     order to allow this step to complete.
+  //   - Step 120 (printing native stack) tries to walk the stack.
+  //     The frame we create has a NULL pc, which is ignored as an
+  //     invalid frame.
+  frame dummy = frame();
+  dummy.set_sp((intptr_t *) current_stack_pointer());
+  return dummy;
+}
+
+char* os::non_memory_address_word() {
+  // Must never look like an address returned by reserve_memory,
+  // even in its subfields (as defined by the CPU immediate fields,
+  // if the CPU splits constants across multiple instructions).
+#ifdef SPARC
+  // On SPARC, 0 != %hi(any real address), because there is no
+  // allocation in the first 1Kb of the virtual address space.
+  return (char *) 0;
+#else
+  // This is the value for x86; works pretty well for PPC too.
+  return (char *) -1;
+#endif // SPARC
+}
+
+void os::initialize_thread() {
+  // Nothing to do.
+}
+
+address os::Bsd::ucontext_get_pc(ucontext_t* uc) {
+  ShouldNotCallThis();
+}
+
+ExtendedPC os::fetch_frame_from_context(void* ucVoid,
+                                        intptr_t** ret_sp,
+                                        intptr_t** ret_fp) {
+  ShouldNotCallThis();
+}
+
+frame os::fetch_frame_from_context(void* ucVoid) {
+  ShouldNotCallThis();
+}
+
+extern "C" JNIEXPORT int
+JVM_handle_bsd_signal(int sig,
+                        siginfo_t* info,
+                        void* ucVoid,
+                        int abort_if_unrecognized) {
+  ucontext_t* uc = (ucontext_t*) ucVoid;
+
+  Thread* t = ThreadLocalStorage::get_thread_slow();
+
+  SignalHandlerMark shm(t);
+
+  // Note: it's not uncommon that JNI code uses signal/sigset to
+  // install then restore certain signal handler (e.g. to temporarily
+  // block SIGPIPE, or have a SIGILL handler when detecting CPU
+  // type). When that happens, JVM_handle_bsd_signal() might be
+  // invoked with junk info/ucVoid. To avoid unnecessary crash when
+  // libjsig is not preloaded, try handle signals that do not require
+  // siginfo/ucontext first.
+
+  if (sig == SIGPIPE || sig == SIGXFSZ) {
+    // allow chained handler to go first
+    if (os::Bsd::chained_handler(sig, info, ucVoid)) {
+      return true;
+    } else {
+      if (PrintMiscellaneous && (WizardMode || Verbose)) {
+        char buf[64];
+        warning("Ignoring %s - see bugs 4229104 or 646499219",
+                os::exception_name(sig, buf, sizeof(buf)));
+      }
+      return true;
+    }
+  }
+
+  JavaThread* thread = NULL;
+  VMThread* vmthread = NULL;
+  if (os::Bsd::signal_handlers_are_installed) {
+    if (t != NULL ){
+      if(t->is_Java_thread()) {
+        thread = (JavaThread*)t;
+      }
+      else if(t->is_VM_thread()){
+        vmthread = (VMThread *)t;
+      }
+    }
+  }
+
+  if (info != NULL && thread != NULL) {
+    // Handle ALL stack overflow variations here
+    if (sig == SIGSEGV || sig == SIGBUS) {
+      address addr = (address) info->si_addr;
+
+      // check if fault address is within thread stack
+      if (addr < thread->stack_base() &&
+          addr >= thread->stack_base() - thread->stack_size()) {
+        // stack overflow
+        if (thread->in_stack_yellow_zone(addr)) {
+          thread->disable_stack_yellow_zone();
+          ShouldNotCallThis();
+        }
+        else if (thread->in_stack_red_zone(addr)) {
+          thread->disable_stack_red_zone();
+          ShouldNotCallThis();
+        }
+#ifndef _ALLBSD_SOURCE
+        else {
+          // Accessing stack address below sp may cause SEGV if
+          // current thread has MAP_GROWSDOWN stack. This should
+          // only happen when current thread was created by user
+          // code with MAP_GROWSDOWN flag and then attached to VM.
+          // See notes in os_bsd.cpp.
+          if (thread->osthread()->expanding_stack() == 0) {
+            thread->osthread()->set_expanding_stack();
+            if (os::Bsd::manually_expand_stack(thread, addr)) {
+              thread->osthread()->clear_expanding_stack();
+              return true;
+            }
+            thread->osthread()->clear_expanding_stack();
+          }
+          else {
+            fatal("recursive segv. expanding stack.");
+          }
+        }
+#endif
+      }
+    }
+
+    /*if (thread->thread_state() == _thread_in_Java) {
+      ShouldNotCallThis();
+    }
+    else*/ if (thread->thread_state() == _thread_in_vm &&
+               sig == SIGBUS && thread->doing_unsafe_access()) {
+      ShouldNotCallThis();
+    }
+
+    // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC
+    // kicks in and the heap gets shrunk before the field access.
+    /*if (sig == SIGSEGV || sig == SIGBUS) {
+      address addr = JNI_FastGetField::find_slowcase_pc(pc);
+      if (addr != (address)-1) {
+        stub = addr;
+      }
+    }*/
+
+    // Check to see if we caught the safepoint code in the process
+    // of write protecting the memory serialization page.  It write
+    // enables the page immediately after protecting it so we can
+    // just return to retry the write.
+    if ((sig == SIGSEGV || sig == SIGBUS) &&
+        os::is_memory_serialize_page(thread, (address) info->si_addr)) {
+      // Block current thread until permission is restored.
+      os::block_on_serialize_page_trap();
+      return true;
+    }
+  }
+
+  // signal-chaining
+  if (os::Bsd::chained_handler(sig, info, ucVoid)) {
+     return true;
+  }
+
+  if (!abort_if_unrecognized) {
+    // caller wants another chance, so give it to him
+    return false;
+  }
+
+#ifndef PRODUCT
+  if (sig == SIGSEGV) {
+    fatal("\n#"
+          "\n#    /--------------------\\"
+          "\n#    | segmentation fault |"
+          "\n#    \\---\\ /--------------/"
+          "\n#        /"
+          "\n#    [-]        |\\_/|    "
+          "\n#    (+)=C      |o o|__  "
+          "\n#    | |        =-*-=__\\ "
+          "\n#    OOO        c_c_(___)");
+  }
+#endif // !PRODUCT
+
+  const char *fmt =
+      "caught unhandled signal " INT32_FORMAT " at address " PTR_FORMAT;
+  char buf[128];
+
+  sprintf(buf, fmt, sig, info->si_addr);
+  fatal(buf);
+}
+
+void os::Bsd::init_thread_fpu_state(void) {
+  // Nothing to do
+}
+
+#ifndef _ALLBSD_SOURCE
+int os::Bsd::get_fpu_control_word() {
+  ShouldNotCallThis();
+}
+
+void os::Bsd::set_fpu_control_word(int fpu) {
+  ShouldNotCallThis();
+}
+#endif
+
+bool os::is_allocatable(size_t bytes) {
+#ifdef _LP64
+  return true;
+#else
+  if (bytes < 2 * G) {
+    return true;
+  }
+
+  char* addr = reserve_memory(bytes, NULL);
+
+  if (addr != NULL) {
+    release_memory(addr, bytes);
+  }
+
+  return addr != NULL;
+#endif // _LP64
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// thread stack
+
+size_t os::Bsd::min_stack_allowed = 64 * K;
+
+bool os::Bsd::supports_variable_stack_size() {
+  return true;
+}
+
+size_t os::Bsd::default_stack_size(os::ThreadType thr_type) {
+#ifdef _LP64
+  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
+#else
+  size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K);
+#endif // _LP64
+  return s;
+}
+
+size_t os::Bsd::default_guard_size(os::ThreadType thr_type) {
+  // Only enable glibc guard pages for non-Java threads
+  // (Java threads have HotSpot guard pages)
+  return (thr_type == java_thread ? 0 : page_size());
+}
+
+static void current_stack_region(address *bottom, size_t *size) {
+  address stack_bottom;
+  address stack_top;
+  size_t stack_bytes;
+
+#ifdef __APPLE__
+  pthread_t self = pthread_self();
+  stack_top = (address) pthread_get_stackaddr_np(self);
+  stack_bytes = pthread_get_stacksize_np(self);
+  stack_bottom = stack_top - stack_bytes;
+#elif defined(__OpenBSD__)
+  stack_t ss;
+  int rslt = pthread_stackseg_np(pthread_self(), &ss);
+
+  if (rslt != 0)
+    fatal(err_msg("pthread_stackseg_np failed with err = " INT32_FORMAT,
+          rslt));
+
+  stack_top = (address) ss.ss_sp;
+  stack_bytes  = ss.ss_size;
+  stack_bottom = stack_top - stack_bytes;
+#elif defined(_ALLBSD_SOURCE)
+  pthread_attr_t attr;
+
+  int rslt = pthread_attr_init(&attr);
+
+  // JVM needs to know exact stack location, abort if it fails
+  if (rslt != 0)
+    fatal(err_msg("pthread_attr_init failed with err = " INT32_FORMAT, rslt));
+
+  rslt = pthread_attr_get_np(pthread_self(), &attr);
+
+  if (rslt != 0)
+    fatal(err_msg("pthread_attr_get_np failed with err = " INT32_FORMAT,
+          rslt));
+
+  if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 ||
+      pthread_attr_getstacksize(&attr, &stack_bytes) != 0) {
+    fatal("Can not locate current stack attributes!");
+  }
+
+  pthread_attr_destroy(&attr);
+
+  stack_top = stack_bottom + stack_bytes;
+#else /* Linux */
+  pthread_attr_t attr;
+  int res = pthread_getattr_np(pthread_self(), &attr);
+  if (res != 0) {
+    if (res == ENOMEM) {
+      vm_exit_out_of_memory(0, "pthread_getattr_np");
+    }
+    else {
+      fatal(err_msg("pthread_getattr_np failed with errno = " INT32_FORMAT,
+            res));
+    }
+  }
+
+  res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes);
+  if (res != 0) {
+    fatal(err_msg("pthread_attr_getstack failed with errno = " INT32_FORMAT,
+          res));
+  }
+  stack_top = stack_bottom + stack_bytes;
+
+  // The block of memory returned by pthread_attr_getstack() includes
+  // guard pages where present.  We need to trim these off.
+  size_t page_bytes = os::Bsd::page_size();
+  assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack");
+
+  size_t guard_bytes;
+  res = pthread_attr_getguardsize(&attr, &guard_bytes);
+  if (res != 0) {
+    fatal(err_msg(
+        "pthread_attr_getguardsize failed with errno = " INT32_FORMAT, res));
+  }
+  int guard_pages = align_size_up(guard_bytes, page_bytes) / page_bytes;
+  assert(guard_bytes == guard_pages * page_bytes, "unaligned guard");
+
+#ifdef IA64
+  // IA64 has two stacks sharing the same area of memory, a normal
+  // stack growing downwards and a register stack growing upwards.
+  // Guard pages, if present, are in the centre.  This code splits
+  // the stack in two even without guard pages, though in theory
+  // there's nothing to stop us allocating more to the normal stack
+  // or more to the register stack if one or the other were found
+  // to grow faster.
+  int total_pages = align_size_down(stack_bytes, page_bytes) / page_bytes;
+  stack_bottom += (total_pages - guard_pages) / 2 * page_bytes;
+#endif // IA64
+
+  stack_bottom += guard_bytes;
+
+  pthread_attr_destroy(&attr);
+
+  // The initial thread has a growable stack, and the size reported
+  // by pthread_attr_getstack is the maximum size it could possibly
+  // be given what currently mapped.  This can be huge, so we cap it.
+  if (os::Bsd::is_initial_thread()) {
+    stack_bytes = stack_top - stack_bottom;
+
+    if (stack_bytes > JavaThread::stack_size_at_create())
+      stack_bytes = JavaThread::stack_size_at_create();
+
+    stack_bottom = stack_top - stack_bytes;
+  }
+#endif
+
+  assert(os::current_stack_pointer() >= stack_bottom, "should do");
+  assert(os::current_stack_pointer() < stack_top, "should do");
+
+  *bottom = stack_bottom;
+  *size = stack_top - stack_bottom;
+}
+
+address os::current_stack_base() {
+  address bottom;
+  size_t size;
+  current_stack_region(&bottom, &size);
+  return bottom + size;
+}
+
+size_t os::current_stack_size() {
+  // stack size includes normal stack and HotSpot guard pages
+  address bottom;
+  size_t size;
+  current_stack_region(&bottom, &size);
+  return size;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// helper functions for fatal error handler
+
+void os::print_context(outputStream* st, void* context) {
+  ShouldNotCallThis();
+}
+
+void os::print_register_info(outputStream *st, void *context) {
+  ShouldNotCallThis();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Stubs for things that would be in bsd_zero.s if it existed.
+// You probably want to disassemble these monkeys to check they're ok.
+
+extern "C" {
+  int SpinPause() {
+  }
+
+  int SafeFetch32(int *adr, int errValue) {
+    int value = errValue;
+    value = *adr;
+    return value;
+  }
+  intptr_t SafeFetchN(intptr_t *adr, intptr_t errValue) {
+    intptr_t value = errValue;
+    value = *adr;
+    return value;
+  }
+
+  void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
+    if (from > to) {
+      jshort *end = from + count;
+      while (from < end)
+        *(to++) = *(from++);
+    }
+    else if (from < to) {
+      jshort *end = from;
+      from += count - 1;
+      to   += count - 1;
+      while (from >= end)
+        *(to--) = *(from--);
+    }
+  }
+  void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
+    if (from > to) {
+      jint *end = from + count;
+      while (from < end)
+        *(to++) = *(from++);
+    }
+    else if (from < to) {
+      jint *end = from;
+      from += count - 1;
+      to   += count - 1;
+      while (from >= end)
+        *(to--) = *(from--);
+    }
+  }
+  void _Copy_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
+    if (from > to) {
+      jlong *end = from + count;
+      while (from < end)
+        os::atomic_copy64(from++, to++);
+    }
+    else if (from < to) {
+      jlong *end = from;
+      from += count - 1;
+      to   += count - 1;
+      while (from >= end)
+        os::atomic_copy64(from--, to--);
+    }
+  }
+
+  void _Copy_arrayof_conjoint_bytes(HeapWord* from,
+                                    HeapWord* to,
+                                    size_t    count) {
+    memmove(to, from, count);
+  }
+  void _Copy_arrayof_conjoint_jshorts(HeapWord* from,
+                                      HeapWord* to,
+                                      size_t    count) {
+    memmove(to, from, count * 2);
+  }
+  void _Copy_arrayof_conjoint_jints(HeapWord* from,
+                                    HeapWord* to,
+                                    size_t    count) {
+    memmove(to, from, count * 4);
+  }
+  void _Copy_arrayof_conjoint_jlongs(HeapWord* from,
+                                     HeapWord* to,
+                                     size_t    count) {
+    memmove(to, from, count * 8);
+  }
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// Implementations of atomic operations not supported by processors.
+//  -- http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Atomic-Builtins.html
+
+#ifndef _LP64
+extern "C" {
+  long long unsigned int __sync_val_compare_and_swap_8(
+    volatile void *ptr,
+    long long unsigned int oldval,
+    long long unsigned int newval) {
+    ShouldNotCallThis();
+  }
+};
+#endif // !_LP64
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2010 Red Hat, Inc.
+ * 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 OS_CPU_BSD_ZERO_VM_OS_BSD_ZERO_HPP
+#define OS_CPU_BSD_ZERO_VM_OS_BSD_ZERO_HPP
+
+  static void setup_fpu() {}
+
+  static bool is_allocatable(size_t bytes);
+
+  // Used to register dynamic code cache area with the OS
+  // Note: Currently only used in 64 bit Windows implementations
+  static bool register_code_area(char *low, char *high) { return true; }
+
+  // Atomically copy 64 bits of data
+  static void atomic_copy64(volatile void *src, volatile void *dst) {
+#if defined(PPC) && !defined(_LP64)
+    double tmp;
+    asm volatile ("lfd  %0, 0(%1)\n"
+                  "stfd %0, 0(%2)\n"
+                  : "=f"(tmp)
+                  : "b"(src), "b"(dst));
+#elif defined(S390) && !defined(_LP64)
+    double tmp;
+    asm volatile ("ld  %0, 0(%1)\n"
+                  "std %0, 0(%2)\n"
+                  : "=r"(tmp)
+                  : "a"(src), "a"(dst));
+#else
+    *(jlong *) dst = *(jlong *) src;
+#endif
+  }
+
+#endif // OS_CPU_BSD_ZERO_VM_OS_BSD_ZERO_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/prefetch_bsd_zero.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008 Red Hat, Inc.
+ * 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 OS_CPU_BSD_ZERO_VM_PREFETCH_BSD_ZERO_INLINE_HPP
+#define OS_CPU_BSD_ZERO_VM_PREFETCH_BSD_ZERO_INLINE_HPP
+
+#include "runtime/prefetch.hpp"
+
+inline void Prefetch::read(void* loc, intx interval) {
+}
+
+inline void Prefetch::write(void* loc, intx interval) {
+}
+
+#endif // OS_CPU_BSD_ZERO_VM_PREFETCH_BSD_ZERO_INLINE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/threadLS_bsd_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007 Red Hat, Inc.
+ * 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 "runtime/threadLocalStorage.hpp"
+#include "thread_bsd.inline.hpp"
+
+void ThreadLocalStorage::generate_code_for_get_thread() {
+  // nothing to do
+}
+
+void ThreadLocalStorage::pd_init() {
+  // nothing to do
+}
+
+void ThreadLocalStorage::pd_set_thread(Thread* thread) {
+  os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/threadLS_bsd_zero.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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 OS_CPU_BSD_ZERO_VM_THREADLS_BSD_ZERO_HPP
+#define OS_CPU_BSD_ZERO_VM_THREADLS_BSD_ZERO_HPP
+
+// Processor dependent parts of ThreadLocalStorage
+
+ public:
+  static Thread* thread() {
+    return (Thread*) os::thread_local_storage_at(thread_index());
+  }
+
+#endif // OS_CPU_BSD_ZERO_VM_THREADLS_BSD_ZERO_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/thread_bsd_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2009, 2010 Red Hat, Inc.
+ * 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 "runtime/frame.inline.hpp"
+#include "thread_bsd.inline.hpp"
+
+void JavaThread::cache_global_variables() {
+  // nothing to do
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/thread_bsd_zero.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
+ * 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 OS_CPU_BSD_ZERO_VM_THREAD_BSD_ZERO_HPP
+#define OS_CPU_BSD_ZERO_VM_THREAD_BSD_ZERO_HPP
+
+ private:
+  ZeroStack  _zero_stack;
+  ZeroFrame* _top_zero_frame;
+
+  void pd_initialize() {
+    _top_zero_frame = NULL;
+  }
+
+ public:
+  ZeroStack *zero_stack() {
+    return &_zero_stack;
+  }
+
+ public:
+  ZeroFrame *top_zero_frame() {
+    return _top_zero_frame;
+  }
+  void push_zero_frame(ZeroFrame *frame) {
+    *(ZeroFrame **) frame = _top_zero_frame;
+    _top_zero_frame = frame;
+  }
+  void pop_zero_frame() {
+    zero_stack()->set_sp((intptr_t *) _top_zero_frame + 1);
+    _top_zero_frame = *(ZeroFrame **) _top_zero_frame;
+  }
+
+ public:
+  static ByteSize zero_stack_offset() {
+    return byte_offset_of(JavaThread, _zero_stack);
+  }
+  static ByteSize top_zero_frame_offset() {
+    return byte_offset_of(JavaThread, _top_zero_frame);
+  }
+
+ public:
+  void record_base_of_stack_pointer() {
+    assert(top_zero_frame() == NULL, "junk on stack prior to Java call");
+  }
+  void set_base_of_stack_pointer(intptr_t* base_sp) {
+    assert(base_sp == NULL, "should be");
+    assert(top_zero_frame() == NULL, "junk on stack after Java call");
+  }
+
+ public:
+  void set_last_Java_frame() {
+    set_last_Java_frame(top_zero_frame(), zero_stack()->sp());
+  }
+  void reset_last_Java_frame() {
+    frame_anchor()->zap();
+  }
+  void set_last_Java_frame(ZeroFrame* fp, intptr_t* sp) {
+    frame_anchor()->set(sp, NULL, fp);
+  }
+
+ public:
+  ZeroFrame* last_Java_fp() {
+    return frame_anchor()->last_Java_fp();
+  }
+
+ private:
+  frame pd_last_frame() {
+    assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
+    return frame(last_Java_fp(), last_Java_sp());
+  }
+
+ public:
+  static ByteSize last_Java_fp_offset() {
+    return byte_offset_of(JavaThread, _anchor) +
+      JavaFrameAnchor::last_Java_fp_offset();
+  }
+
+ public:
+  // Check for pending suspend requests and pending asynchronous
+  // exceptions.  There are separate accessors for these, but
+  // _suspend_flags is volatile so using them would be unsafe.
+  bool has_special_condition_for_native_trans() {
+    return _suspend_flags != 0;
+  }
+
+ public:
+  bool pd_get_top_frame_for_signal_handler(frame* fr_addr,
+                                           void* ucontext,
+                                           bool isInJava) {
+    ShouldNotCallThis();
+  }
+
+  // These routines are only used on cpu architectures that
+  // have separate register stacks (Itanium).
+  static bool register_stack_overflow() { return false; }
+  static void enable_register_stack_guard() {}
+  static void disable_register_stack_guard() {}
+
+#endif // OS_CPU_BSD_ZERO_VM_THREAD_BSD_ZERO_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/vmStructs_bsd_zero.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007 Red Hat, Inc.
+ * 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 OS_CPU_BSD_ZERO_VM_VMSTRUCTS_BSD_ZERO_HPP
+#define OS_CPU_BSD_ZERO_VM_VMSTRUCTS_BSD_ZERO_HPP
+
+// These are the OS and CPU-specific fields, types and integer
+// constants required by the Serviceability Agent. This file is
+// referenced by vmStructs.cpp.
+
+#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \
+  /* This must be the last entry, and must be present */                \
+  last_entry()
+
+
+#define VM_TYPES_OS_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type, last_entry) \
+  /* This must be the last entry, and must be present */                \
+  last_entry()
+
+#define VM_INT_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \
+  /* This must be the last entry, and must be present */                \
+  last_entry()
+
+#define VM_LONG_CONSTANTS_OS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant, last_entry) \
+  /* This must be the last entry, and must be present */                \
+  last_entry()
+
+#endif // OS_CPU_BSD_ZERO_VM_VMSTRUCTS_BSD_ZERO_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/os_cpu/bsd_zero/vm/vm_version_bsd_zero.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2009 Red Hat, Inc.
+ * 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 "runtime/os.hpp"
+#include "vm_version_zero.hpp"
+
+// This file is intentionally empty
--- a/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -38,7 +38,6 @@
 #else
 define_pd_global(intx,  VMThreadStackSize,       512);
 #endif // _LP64
-define_pd_global(intx,  SurvivorRatio,           8);
 define_pd_global(intx,  CompilerThreadStackSize, 0);
 define_pd_global(uintx, JVMInvokeMethodSlack,    8192);
 
--- a/hotspot/src/os_cpu/windows_x86/vm/copy_windows_x86.inline.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/os_cpu/windows_x86/vm/copy_windows_x86.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,13 +85,35 @@
 }
 
 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
-  // FIXME
-  (void)memmove(to, from, count << LogBytesPerShort);
+  if (from > to) {
+    while (count-- > 0) {
+      // Copy forwards
+      *to++ = *from++;
+    }
+  } else {
+    from += count - 1;
+    to   += count - 1;
+    while (count-- > 0) {
+      // Copy backwards
+      *to-- = *from--;
+    }
+  }
 }
 
 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
-  // FIXME
-  (void)memmove(to, from, count << LogBytesPerInt);
+  if (from > to) {
+    while (count-- > 0) {
+      // Copy forwards
+      *to++ = *from++;
+    }
+  } else {
+    from += count - 1;
+    to   += count - 1;
+    while (count-- > 0) {
+      // Copy backwards
+      *to-- = *from--;
+    }
+  }
 }
 
 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,8 @@
     private int receiver_count;
     private String reason;
     private List<CallSite> calls;
+    private int endNodes;
+    private double timeStamp;
 
     CallSite() {
     }
@@ -93,18 +95,22 @@
         emit(stream, indent);
         String m = getMethod().getHolder().replace('/', '.') + "::" + getMethod().getName();
         if (getReason() == null) {
-            stream.println("  @ " + getBci() + " " + m + " (" + getMethod().getBytes() + " bytes)");
+            stream.print("  @ " + getBci() + " " + m + " (" + getMethod().getBytes() + " bytes)");
 
         } else {
             if (isCompat()) {
-                stream.println("  @ " + getBci() + " " + m + " " + getReason());
+                stream.print("  @ " + getBci() + " " + m + " " + getReason());
             } else {
-                stream.println("- @ " + getBci() + " " + m +
+                stream.print("- @ " + getBci() + " " + m +
                         " (" + getMethod().getBytes() + " bytes) " + getReason());
             }
         }
+        if (getEndNodes() > 0) {
+          stream.printf(" (end time: %6.4f nodes: %d)", getTimeStamp(), getEndNodes());
+        }
+        stream.println("");
         if (getReceiver() != null) {
-            emit(stream, indent + 3);
+            emit(stream, indent + 4);
             //                 stream.println("type profile " + method.holder + " -> " + receiver + " (" +
             //                                receiver_count + "/" + count + "," + (receiver_count * 100 / count) + "%)");
             stream.println("type profile " + getMethod().getHolder() + " -> " + getReceiver() + " (" +
@@ -180,4 +186,21 @@
     public static void setCompat(boolean aCompat) {
         compat = aCompat;
     }
+
+    void setEndNodes(int n) {
+        endNodes = n;
+    }
+
+    public int getEndNodes() {
+        return endNodes;
+    }
+
+    void setTimeStamp(double time) {
+        timeStamp = time;
+    }
+
+    public double getTimeStamp() {
+        return timeStamp;
+    }
+
 }
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogCompilation.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -126,7 +126,6 @@
                 maxattempts = Math.max(maxattempts,c.getAttempts());
                 elapsed += c.getElapsedTime();
                 for (Phase phase : c.getPhases()) {
-                    out.printf("\t%s %6.4f\n", phase.getName(), phase.getElapsedTime());
                     Double v = phaseTime.get(phase.getName());
                     if (v == null) {
                         v = Double.valueOf(0.0);
@@ -138,6 +137,7 @@
                         v2 = Integer.valueOf(0);
                     }
                     phaseNodes.put(phase.getName(), Integer.valueOf(v2.intValue() + phase.getNodes()));
+                    out.printf("\t%s %6.4f %d %d\n", phase.getName(), phase.getElapsedTime(), phase.getStartNodes(), phase.getNodes());
                 }
             } else if (e instanceof MakeNotEntrantEvent) {
                 MakeNotEntrantEvent mne = (MakeNotEntrantEvent) e;
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -365,7 +365,7 @@
             if (currentTrap != null) {
                 currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci")));
             } else {
-                System.err.println("Missing uncommon_trap for jvms");
+                // Ignore <eliminate_allocation type='667'> and <eliminate_lock lock='1'>
             }
         } else if (qname.equals("nmethod")) {
             String id = makeId(atts);
@@ -391,6 +391,11 @@
                     throw new InternalError("call site and parse don't match");
                 }
             }
+        } else if (qname.equals("parse_done")) {
+            CallSite call = scopes.pop();
+            call.setEndNodes(Integer.parseInt(search(atts, "nodes")));
+            call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
+            scopes.push(call);
         }
     }
 
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Phase.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Phase.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
     }
 
     int getNodes() {
-        return getStartNodes();
+        return getEndNodes() - getStartNodes();
     }
 
     void setEndNodes(int n) {
--- a/hotspot/src/share/vm/adlc/adlc.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/adlc/adlc.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -67,9 +67,9 @@
 #endif
 #endif // _WIN32
 
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
   #include <inttypes.h>
-#endif // LINUX
+#endif // LINUX || _ALLBSD_SOURCE
 
 // Macros
 #define uint32 unsigned int
--- a/hotspot/src/share/vm/adlc/formssel.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/adlc/formssel.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1225,7 +1225,7 @@
   // Handle special constant table variables.
   if (strcmp(rep_var, "constanttablebase") == 0) {
     fprintf(fp, "char reg[128];  ra->dump_register(in(mach_constant_base_node_input()), reg);\n");
-    fprintf(fp, "st->print(\"%%s\");\n");
+    fprintf(fp, "    st->print(\"%%s\", reg);\n");
     return;
   }
   if (strcmp(rep_var, "constantoffset") == 0) {
--- a/hotspot/src/share/vm/c1/c1_Compilation.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -346,7 +346,6 @@
     implicit_exception_table(),
     compiler(),
     _env->comp_level(),
-    true,
     has_unsafe_access()
   );
 }
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -28,8 +28,10 @@
 #include "c1/c1_Compilation.hpp"
 #include "c1/c1_GraphBuilder.hpp"
 #include "c1/c1_InstructionPrinter.hpp"
+#include "ci/ciCallSite.hpp"
 #include "ci/ciField.hpp"
 #include "ci/ciKlass.hpp"
+#include "ci/ciMethodHandle.hpp"
 #include "compiler/compileBroker.hpp"
 #include "interpreter/bytecode.hpp"
 #include "runtime/sharedRuntime.hpp"
@@ -1163,11 +1165,11 @@
   Goto *x = new Goto(block_at(to_bci), to_bci <= from_bci);
   if (is_profiling()) {
     compilation()->set_would_profile(true);
-  }
-  if (profile_branches()) {
-    x->set_profiled_method(method());
     x->set_profiled_bci(bci());
-    x->set_should_profile(true);
+    if (profile_branches()) {
+      x->set_profiled_method(method());
+      x->set_should_profile(true);
+    }
   }
   append(x);
 }
@@ -1201,9 +1203,9 @@
     Goto *goto_node = i->as_Goto();
     if (goto_node != NULL) {
       compilation()->set_would_profile(true);
+      goto_node->set_profiled_bci(bci());
       if (profile_branches()) {
         goto_node->set_profiled_method(method());
-        goto_node->set_profiled_bci(bci());
         goto_node->set_should_profile(true);
         // Find out which successor is used.
         if (goto_node->default_sux() == tsux) {
@@ -1424,7 +1426,7 @@
     // See whether this is the first return; if so, store off some
     // of the state for later examination
     if (num_returns() == 0) {
-      set_inline_cleanup_info(_block, _last, state());
+      set_inline_cleanup_info();
     }
 
     // The current bci() is in the wrong scope, so use the bci() of
@@ -1582,6 +1584,8 @@
     code = Bytecodes::_invokespecial;
   }
 
+  bool is_invokedynamic = code == Bytecodes::_invokedynamic;
+
   // NEEDS_CLEANUP
   // I've added the target-is_loaded() test below but I don't really understand
   // how klass->is_loaded() can be true and yet target->is_loaded() is false.
@@ -1693,26 +1697,31 @@
       && target->will_link(klass, callee_holder, code)) {
     // callee is known => check if we have static binding
     assert(target->is_loaded(), "callee must be known");
-    if (code == Bytecodes::_invokestatic
-     || code == Bytecodes::_invokespecial
-     || code == Bytecodes::_invokevirtual && target->is_final_method()
-    ) {
-      // static binding => check if callee is ok
-      ciMethod* inline_target = (cha_monomorphic_target != NULL)
-                                  ? cha_monomorphic_target
-                                  : target;
-      bool res = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL));
+    if (code == Bytecodes::_invokestatic  ||
+        code == Bytecodes::_invokespecial ||
+        code == Bytecodes::_invokevirtual && target->is_final_method() ||
+        code == Bytecodes::_invokedynamic) {
+      ciMethod* inline_target = (cha_monomorphic_target != NULL) ? cha_monomorphic_target : target;
+      bool success = false;
+      if (target->is_method_handle_invoke()) {
+        // method handle invokes
+        success = !is_invokedynamic ? for_method_handle_inline(target) : for_invokedynamic_inline(target);
+      }
+      if (!success) {
+        // static binding => check if callee is ok
+        success = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL));
+      }
       CHECK_BAILOUT();
 
 #ifndef PRODUCT
       // printing
-      if (PrintInlining && !res) {
+      if (PrintInlining && !success) {
         // if it was successfully inlined, then it was already printed.
-        print_inline_result(inline_target, res);
+        print_inline_result(inline_target, success);
       }
 #endif
       clear_inline_bailout();
-      if (res) {
+      if (success) {
         // Register dependence if JVMTI has either breakpoint
         // setting or hotswapping of methods capabilities since they may
         // cause deoptimization.
@@ -1740,7 +1749,6 @@
     code == Bytecodes::_invokespecial   ||
     code == Bytecodes::_invokevirtual   ||
     code == Bytecodes::_invokeinterface;
-  bool is_invokedynamic = code == Bytecodes::_invokedynamic;
   ValueType* result_type = as_ValueType(target->return_type());
 
   // We require the debug info to be the "state before" because
@@ -3038,7 +3046,7 @@
     INLINE_BAILOUT("disallowed by CompilerOracle")
   } else if (!callee->can_be_compiled()) {
     // callee is not compilable (prob. has breakpoints)
-    INLINE_BAILOUT("not compilable")
+    INLINE_BAILOUT("not compilable (disabled)")
   } else if (callee->intrinsic_id() != vmIntrinsics::_none && try_inline_intrinsics(callee)) {
     // intrinsics can be native or not
     return true;
@@ -3397,7 +3405,7 @@
 }
 
 
-bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known) {
+bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, BlockBegin* cont_block) {
   assert(!callee->is_native(), "callee must not be native");
   if (CompilationPolicy::policy()->should_not_inline(compilation()->env(), callee)) {
     INLINE_BAILOUT("inlining prohibited by policy");
@@ -3430,7 +3438,7 @@
   } else {
     if (inline_level() > MaxInlineLevel                         ) INLINE_BAILOUT("too-deep inlining");
     if (recursive_inline_level(callee) > MaxRecursiveInlineLevel) INLINE_BAILOUT("too-deep recursive inlining");
-    if (callee->code_size() > max_inline_size()                 ) INLINE_BAILOUT("callee is too large");
+    if (callee->code_size_for_inlining() > max_inline_size()    ) INLINE_BAILOUT("callee is too large");
 
     // don't inline throwable methods unless the inlining tree is rooted in a throwable class
     if (callee->name() == ciSymbol::object_initializer_name() &&
@@ -3468,7 +3476,8 @@
 
   // Insert null check if necessary
   Value recv = NULL;
-  if (code() != Bytecodes::_invokestatic) {
+  if (code() != Bytecodes::_invokestatic &&
+      code() != Bytecodes::_invokedynamic) {
     // note: null check must happen even if first instruction of callee does
     //       an implicit null check since the callee is in a different scope
     //       and we must make sure exception handling does the right thing
@@ -3496,7 +3505,7 @@
   // fall-through of control flow, all return instructions of the
   // callee will need to be replaced by Goto's pointing to this
   // continuation point.
-  BlockBegin* cont = block_at(next_bci());
+  BlockBegin* cont = cont_block != NULL ? cont_block : block_at(next_bci());
   bool continuation_existed = true;
   if (cont == NULL) {
     cont = new BlockBegin(next_bci());
@@ -3608,27 +3617,29 @@
   // block merging. This allows load elimination and CSE to take place
   // across multiple callee scopes if they are relatively simple, and
   // is currently essential to making inlining profitable.
-  if (   num_returns() == 1
-      && block() == orig_block
-      && block() == inline_cleanup_block()) {
-    _last = inline_cleanup_return_prev();
-    _state = inline_cleanup_state();
-  } else if (continuation_preds == cont->number_of_preds()) {
-    // Inlining caused that the instructions after the invoke in the
-    // caller are not reachable any more. So skip filling this block
-    // with instructions!
-    assert (cont == continuation(), "");
-    assert(_last && _last->as_BlockEnd(), "");
-    _skip_block = true;
-  } else {
-    // Resume parsing in continuation block unless it was already parsed.
-    // Note that if we don't change _last here, iteration in
-    // iterate_bytecodes_for_block will stop when we return.
-    if (!continuation()->is_set(BlockBegin::was_visited_flag)) {
-      // add continuation to work list instead of parsing it immediately
+  if (cont_block == NULL) {
+    if (num_returns() == 1
+        && block() == orig_block
+        && block() == inline_cleanup_block()) {
+      _last  = inline_cleanup_return_prev();
+      _state = inline_cleanup_state();
+    } else if (continuation_preds == cont->number_of_preds()) {
+      // Inlining caused that the instructions after the invoke in the
+      // caller are not reachable any more. So skip filling this block
+      // with instructions!
+      assert(cont == continuation(), "");
       assert(_last && _last->as_BlockEnd(), "");
-      scope_data()->parent()->add_to_work_list(continuation());
       _skip_block = true;
+    } else {
+      // Resume parsing in continuation block unless it was already parsed.
+      // Note that if we don't change _last here, iteration in
+      // iterate_bytecodes_for_block will stop when we return.
+      if (!continuation()->is_set(BlockBegin::was_visited_flag)) {
+        // add continuation to work list instead of parsing it immediately
+        assert(_last && _last->as_BlockEnd(), "");
+        scope_data()->parent()->add_to_work_list(continuation());
+        _skip_block = true;
+      }
     }
   }
 
@@ -3645,6 +3656,114 @@
 }
 
 
+bool GraphBuilder::for_method_handle_inline(ciMethod* callee) {
+  assert(!callee->is_static(), "change next line");
+  int index = state()->stack_size() - (callee->arg_size_no_receiver() + 1);
+  Value receiver = state()->stack_at(index);
+
+  if (receiver->type()->is_constant()) {
+    ciMethodHandle* method_handle = receiver->type()->as_ObjectType()->constant_value()->as_method_handle();
+
+    // Set the callee to have access to the class and signature in
+    // the MethodHandleCompiler.
+    method_handle->set_callee(callee);
+    method_handle->set_caller(method());
+
+    // Get an adapter for the MethodHandle.
+    ciMethod* method_handle_adapter = method_handle->get_method_handle_adapter();
+    if (method_handle_adapter != NULL) {
+      return try_inline(method_handle_adapter, /*holder_known=*/ true);
+    }
+  } else if (receiver->as_CheckCast()) {
+    // Match MethodHandle.selectAlternative idiom
+    Phi* phi = receiver->as_CheckCast()->obj()->as_Phi();
+
+    if (phi != NULL && phi->operand_count() == 2) {
+      // Get the two MethodHandle inputs from the Phi.
+      Value op1 = phi->operand_at(0);
+      Value op2 = phi->operand_at(1);
+      ciMethodHandle* mh1 = op1->type()->as_ObjectType()->constant_value()->as_method_handle();
+      ciMethodHandle* mh2 = op2->type()->as_ObjectType()->constant_value()->as_method_handle();
+
+      // Set the callee to have access to the class and signature in
+      // the MethodHandleCompiler.
+      mh1->set_callee(callee);
+      mh1->set_caller(method());
+      mh2->set_callee(callee);
+      mh2->set_caller(method());
+
+      // Get adapters for the MethodHandles.
+      ciMethod* mh1_adapter = mh1->get_method_handle_adapter();
+      ciMethod* mh2_adapter = mh2->get_method_handle_adapter();
+
+      if (mh1_adapter != NULL && mh2_adapter != NULL) {
+        set_inline_cleanup_info();
+
+        // Build the If guard
+        BlockBegin* one = new BlockBegin(next_bci());
+        BlockBegin* two = new BlockBegin(next_bci());
+        BlockBegin* end = new BlockBegin(next_bci());
+        Instruction* iff = append(new If(phi, If::eql, false, op1, one, two, NULL, false));
+        block()->set_end(iff->as_BlockEnd());
+
+        // Connect up the states
+        one->merge(block()->end()->state());
+        two->merge(block()->end()->state());
+
+        // Save the state for the second inlinee
+        ValueStack* state_before = copy_state_before();
+
+        // Parse first adapter
+        _last = _block = one;
+        if (!try_inline_full(mh1_adapter, /*holder_known=*/ true, end)) {
+          restore_inline_cleanup_info();
+          block()->clear_end();  // remove appended iff
+          return false;
+        }
+
+        // Parse second adapter
+        _last = _block = two;
+        _state = state_before;
+        if (!try_inline_full(mh2_adapter, /*holder_known=*/ true, end)) {
+          restore_inline_cleanup_info();
+          block()->clear_end();  // remove appended iff
+          return false;
+        }
+
+        connect_to_end(end);
+        return true;
+      }
+    }
+  }
+  return false;
+}
+
+
+bool GraphBuilder::for_invokedynamic_inline(ciMethod* callee) {
+  // Get the MethodHandle from the CallSite.
+  ciCallSite*     call_site     = stream()->get_call_site();
+  ciMethodHandle* method_handle = call_site->get_target();
+
+  // Set the callee to have access to the class and signature in the
+  // MethodHandleCompiler.
+  method_handle->set_callee(callee);
+  method_handle->set_caller(method());
+
+  // Get an adapter for the MethodHandle.
+  ciMethod* method_handle_adapter = method_handle->get_invokedynamic_adapter();
+  if (method_handle_adapter != NULL) {
+    if (try_inline(method_handle_adapter, /*holder_known=*/ true)) {
+      // Add a dependence for invalidation of the optimization.
+      if (!call_site->is_constant_call_site()) {
+        dependency_recorder()->assert_call_site_target_value(call_site, method_handle);
+      }
+      return true;
+    }
+  }
+  return false;
+}
+
+
 void GraphBuilder::inline_bailout(const char* msg) {
   assert(msg != NULL, "inline bailout msg must exist");
   _inline_bailout_msg = msg;
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -315,9 +315,17 @@
                                ValueStack* return_state) { scope_data()->set_inline_cleanup_info(block,
                                                                                                   return_prev,
                                                                                                   return_state); }
+  void set_inline_cleanup_info() {
+    set_inline_cleanup_info(_block, _last, _state);
+  }
   BlockBegin*  inline_cleanup_block() const              { return scope_data()->inline_cleanup_block();  }
   Instruction* inline_cleanup_return_prev() const        { return scope_data()->inline_cleanup_return_prev(); }
   ValueStack*  inline_cleanup_state() const              { return scope_data()->inline_cleanup_state();  }
+  void restore_inline_cleanup_info() {
+    _block = inline_cleanup_block();
+    _last  = inline_cleanup_return_prev();
+    _state = inline_cleanup_state();
+  }
   void incr_num_returns()                                { scope_data()->incr_num_returns();             }
   int  num_returns() const                               { return scope_data()->num_returns();           }
   intx max_inline_size() const                           { return scope_data()->max_inline_size();       }
@@ -329,11 +337,15 @@
   void fill_sync_handler(Value lock, BlockBegin* sync_handler, bool default_handler = false);
 
   // inliners
-  bool try_inline(ciMethod* callee, bool holder_known);
+  bool try_inline(           ciMethod* callee, bool holder_known);
   bool try_inline_intrinsics(ciMethod* callee);
-  bool try_inline_full      (ciMethod* callee, bool holder_known);
+  bool try_inline_full(      ciMethod* callee, bool holder_known, BlockBegin* cont_block = NULL);
   bool try_inline_jsr(int jsr_dest_bci);
 
+  // JSR 292 support
+  bool for_method_handle_inline(ciMethod* callee);
+  bool for_invokedynamic_inline(ciMethod* callee);
+
   // helpers
   void inline_bailout(const char* msg);
   BlockBegin* header_block(BlockBegin* entry, BlockBegin::Flag f, ValueStack* state);
--- a/hotspot/src/share/vm/c1/c1_Instruction.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -514,28 +514,17 @@
 
 void BlockBegin::set_end(BlockEnd* end) {
   assert(end != NULL, "should not reset block end to NULL");
-  BlockEnd* old_end = _end;
-  if (end == old_end) {
+  if (end == _end) {
     return;
   }
-  // Must make the predecessors/successors match up with the
-  // BlockEnd's notion.
-  int i, n;
-  if (old_end != NULL) {
-    // disconnect from the old end
-    old_end->set_begin(NULL);
+  clear_end();
 
-    // disconnect this block from it's current successors
-    for (i = 0; i < _successors.length(); i++) {
-      _successors.at(i)->remove_predecessor(this);
-    }
-  }
+  // Set the new end
   _end = end;
 
   _successors.clear();
   // Now reset successors list based on BlockEnd
-  n = end->number_of_sux();
-  for (i = 0; i < n; i++) {
+  for (int i = 0; i < end->number_of_sux(); i++) {
     BlockBegin* sux = end->sux_at(i);
     _successors.append(sux);
     sux->_predecessors.append(this);
@@ -544,6 +533,22 @@
 }
 
 
+void BlockBegin::clear_end() {
+  // Must make the predecessors/successors match up with the
+  // BlockEnd's notion.
+  if (_end != NULL) {
+    // disconnect from the old end
+    _end->set_begin(NULL);
+
+    // disconnect this block from it's current successors
+    for (int i = 0; i < _successors.length(); i++) {
+      _successors.at(i)->remove_predecessor(this);
+    }
+    _end = NULL;
+  }
+}
+
+
 void BlockBegin::disconnect_edge(BlockBegin* from, BlockBegin* to) {
   // disconnect any edges between from and to
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/c1/c1_Instruction.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1601,6 +1601,7 @@
   void set_depth_first_number(int dfn)           { _depth_first_number = dfn; }
   void set_linear_scan_number(int lsn)           { _linear_scan_number = lsn; }
   void set_end(BlockEnd* end);
+  void clear_end();
   void disconnect_from_graph();
   static void disconnect_edge(BlockBegin* from, BlockBegin* to);
   BlockBegin* insert_block_between(BlockBegin* sux);
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -142,7 +142,8 @@
 #endif
 #ifdef ARM
   assert(disp() == 0 || index()->is_illegal(), "can't have both");
-  assert(-4096 < disp() && disp() < 4096, "architecture constraint");
+  // Note: offsets higher than 4096 must not be rejected here. They can
+  // be handled by the back-end or will be rejected if not.
 #endif
 #ifdef _LP64
   assert(base()->is_cpu_register(), "wrong base operand");
@@ -1393,8 +1394,15 @@
 }
 
 
-void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception) {
-  append(new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception));
+void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
+                           CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {
+  LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
+  if (profiled_method != NULL) {
+    c->set_profiled_method(profiled_method);
+    c->set_profiled_bci(profiled_bci);
+    c->set_should_profile(true);
+  }
+  append(c);
 }
 
 
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -2100,7 +2100,7 @@
   void fpop_raw()                                { append(new LIR_Op0(lir_fpop_raw)); }
 
   void instanceof(LIR_Opr result, LIR_Opr object, ciKlass* klass, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check, CodeEmitInfo* info_for_patch, ciMethod* profiled_method, int profiled_bci);
-  void store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception);
+  void store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci);
 
   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -121,7 +121,7 @@
 
 void LIR_Assembler::check_codespace() {
   CodeSection* cs = _masm->code_section();
-  if (cs->remaining() < (int)(1*K)) {
+  if (cs->remaining() < (int)(NOT_LP64(1*K)LP64_ONLY(2*K))) {
     BAILOUT("CodeBuffer overflow");
   }
 }
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -133,7 +133,6 @@
   static bool is_small_constant(LIR_Opr opr);
 
   static LIR_Opr receiverOpr();
-  static LIR_Opr incomingReceiverOpr();
   static LIR_Opr osrBufferPointer();
 
   // stubs
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -2493,7 +2493,7 @@
 
     // increment backedge counter if needed
     CodeEmitInfo* info = state_for(x, state);
-    increment_backedge_counter(info, info->stack()->bci());
+    increment_backedge_counter(info, x->profiled_bci());
     CodeEmitInfo* safepoint_info = state_for(x, state);
     __ safepoint(safepoint_poll_register(), safepoint_info);
   }
@@ -2970,8 +2970,8 @@
   // accessors are also always mature.
   if (!x->inlinee()->is_accessor()) {
     CodeEmitInfo* info = state_for(x, x->state(), true);
-    // Increment invocation counter, don't notify the runtime, because we don't inline loops,
-    increment_event_counter_impl(info, x->inlinee(), 0, InvocationEntryBci, false, false);
+    // Notify the runtime very infrequently only to take care of counter overflows
+    increment_event_counter_impl(info, x->inlinee(), (1 << Tier23InlineeNotifyFreqLog) - 1, InvocationEntryBci, false, true);
   }
 }
 
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -2404,7 +2404,7 @@
       assert(!is_call_site || assigned_reg >= nof_regs || !is_caller_save(assigned_reg), "interval is in a caller-save register at a call -> register will be overwritten");
 
       VMReg name = vm_reg_for_interval(interval);
-      map->set_oop(name);
+      set_oop(map, name);
 
       // Spill optimization: when the stack value is guaranteed to be always correct,
       // then it must be added to the oop map even if the interval is currently in a register
@@ -2415,7 +2415,7 @@
         assert(interval->canonical_spill_slot() >= LinearScan::nof_regs, "no spill slot assigned");
         assert(interval->assigned_reg() < LinearScan::nof_regs, "interval is on stack, so stack slot is registered twice");
 
-        map->set_oop(frame_map()->slot_regname(interval->canonical_spill_slot() - LinearScan::nof_regs));
+        set_oop(map, frame_map()->slot_regname(interval->canonical_spill_slot() - LinearScan::nof_regs));
       }
     }
   }
@@ -2424,7 +2424,7 @@
   assert(info->stack() != NULL, "CodeEmitInfo must always have a stack");
   int locks_count = info->stack()->total_locks_size();
   for (int i = 0; i < locks_count; i++) {
-    map->set_oop(frame_map()->monitor_object_regname(i));
+    set_oop(map, frame_map()->monitor_object_regname(i));
   }
 
   return map;
@@ -2619,6 +2619,24 @@
 
     Location::Type loc_type = float_saved_as_double ? Location::float_in_dbl : Location::normal;
     VMReg rname = frame_map()->fpu_regname(opr->fpu_regnr());
+#ifndef __SOFTFP__
+#ifndef VM_LITTLE_ENDIAN
+    if (! float_saved_as_double) {
+      // On big endian system, we may have an issue if float registers use only
+      // the low half of the (same) double registers.
+      // Both the float and the double could have the same regnr but would correspond
+      // to two different addresses once saved.
+
+      // get next safely (no assertion checks)
+      VMReg next = VMRegImpl::as_VMReg(1+rname->value());
+      if (next->is_reg() &&
+          (next->as_FloatRegister() == rname->as_FloatRegister())) {
+        // the back-end does use the same numbering for the double and the float
+        rname = next; // VMReg for the low bits, e.g. the real VMReg for the float
+      }
+    }
+#endif
+#endif
     LocationValue* sv = new LocationValue(Location::new_reg_loc(loc_type, rname));
 
     scope_values->append(sv);
--- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -352,6 +352,13 @@
 
   MonitorValue*  location_for_monitor_index(int monitor_index);
   LocationValue* location_for_name(int name, Location::Type loc_type);
+  void set_oop(OopMap* map, VMReg name) {
+    if (map->legal_vm_reg_name(name)) {
+      map->set_oop(name);
+    } else {
+      bailout("illegal oopMap register name");
+    }
+  }
 
   int append_scope_value_for_constant(LIR_Opr opr, GrowableArray<ScopeValue*>* scope_values);
   int append_scope_value_for_operand(LIR_Opr opr, GrowableArray<ScopeValue*>* scope_values);
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -375,14 +375,6 @@
 JRT_END
 
 
-JRT_ENTRY(void, Runtime1::post_jvmti_exception_throw(JavaThread* thread))
-  if (JvmtiExport::can_post_on_exceptions()) {
-    vframeStream vfst(thread, true);
-    address bcp = vfst.method()->bcp_from(vfst.bci());
-    JvmtiExport::post_exception_throw(thread, vfst.method(), bcp, thread->exception_oop());
-  }
-JRT_END
-
 // counter_overflow() is called from within C1-compiled methods. The enclosing method is the method
 // associated with the top activation record. The inlinee (that is possibly included in the enclosing
 // method) method oop is passed as an argument. In order to do that it is embedded in the code as
--- a/hotspot/src/share/vm/c1/c1_Runtime1.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -65,7 +65,6 @@
   stub(monitorexit_nofpu)              /* optimized version that does not preserve fpu registers */ \
   stub(access_field_patching)        \
   stub(load_klass_patching)          \
-  stub(jvmti_exception_throw)        \
   stub(g1_pre_barrier_slow)          \
   stub(g1_post_barrier_slow)         \
   stub(fpu2long_stub)                \
@@ -141,7 +140,6 @@
   static void unimplemented_entry   (JavaThread* thread, StubID id);
 
   static address exception_handler_for_pc(JavaThread* thread);
-  static void post_jvmti_exception_throw(JavaThread* thread);
 
   static void throw_range_check_exception(JavaThread* thread, int index);
   static void throw_index_exception(JavaThread* thread, int index);
--- a/hotspot/src/share/vm/c1/c1_globals.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/c1/c1_globals.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -47,6 +47,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "c1_globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "c1_globals_bsd.hpp"
+#endif
 
 //
 // Defines all global flags used by the client compiler.
@@ -278,7 +281,7 @@
   product(intx, CompilationRepeat, 0,                                       \
           "Number of times to recompile method before returning result")    \
                                                                             \
-  develop(intx, NMethodSizeLimit, (32*K)*wordSize,                          \
+  develop(intx, NMethodSizeLimit, (64*K)*wordSize,                          \
           "Maximum size of a compiled method.")                             \
                                                                             \
   develop(bool, TraceFPUStack, false,                                       \
--- a/hotspot/src/share/vm/ci/ciArrayKlass.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciArrayKlass.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 // This class, and its subclasses represent klassOops in the
 // HotSpot virtual machine whose Klass part is an arrayKlass.
 class ciArrayKlass : public ciKlass {
+  CI_PACKAGE_ACCESS
 private:
   jint _dimension;
 
--- a/hotspot/src/share/vm/ci/ciCallProfile.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciCallProfile.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -79,6 +79,17 @@
     assert(i < _limit, "out of Call Profile MorphismLimit");
     return _receiver[i];
   }
+
+  // Rescale the current profile based on the incoming scale
+  ciCallProfile rescale(double scale) {
+    assert(scale >= 0 && scale <= 1.0, "out of range");
+    ciCallProfile call = *this;
+    call._count = (int)(call._count * scale);
+    for (int i = 0; i < _morphism; i++) {
+      call._receiver_count[i] = (int)(call._receiver_count[i] * scale);
+    }
+    return call;
+  }
 };
 
 #endif // SHARE_VM_CI_CICALLPROFILE_HPP
--- a/hotspot/src/share/vm/ci/ciClassList.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciClassList.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -77,12 +77,14 @@
 
 // Everyone gives access to ciObjectFactory
 #define CI_PACKAGE_ACCESS \
-friend class ciObjectFactory;
+friend class ciObjectFactory; \
+friend class VMStructs;
 
 // These are the packages that have access to ciEnv
 // Any more access must be given explicitly.
 #define CI_PACKAGE_ACCESS_TO           \
 friend class ciObjectFactory;          \
+friend class VMStructs;                \
 friend class ciCallSite;               \
 friend class ciConstantPoolCache;      \
 friend class ciField;                  \
--- a/hotspot/src/share/vm/ci/ciConstant.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciConstant.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 //
 // This class represents a constant value.
 class ciConstant VALUE_OBJ_CLASS_SPEC {
+  friend class VMStructs;
 private:
   friend class ciEnv;
   friend class ciField;
@@ -46,9 +47,6 @@
     ciObject* _object;
   } _value;
 
-  // Implementation of the print method.
-  void print_impl(outputStream* st);
-
 public:
 
   ciConstant() {
--- a/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -473,6 +473,7 @@
   }
 
   if (require_local)  return NULL;
+
   // Not yet loaded into the VM, or not governed by loader constraints.
   // Make a CI representative for it.
   return get_unloaded_klass(accessing_klass, name);
@@ -498,7 +499,7 @@
                                         bool& is_accessible,
                                         ciInstanceKlass* accessor) {
   EXCEPTION_CONTEXT;
-  KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
+  KlassHandle klass(THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
   Symbol* klass_name = NULL;
   if (klass.is_null()) {
     // The klass has not been inserted into the constant pool.
@@ -785,17 +786,17 @@
   // Either the declared holder was not loaded, or the method could
   // not be found.  Create a dummy ciMethod to represent the failed
   // lookup.
-
-  return get_unloaded_method(declared_holder,
-                             get_symbol(name_sym),
-                             get_symbol(sig_sym));
+  ciSymbol* name      = get_symbol(name_sym);
+  ciSymbol* signature = get_symbol(sig_sym);
+  return get_unloaded_method(declared_holder, name, signature, accessor);
 }
 
 
 // ------------------------------------------------------------------
 // ciEnv::get_fake_invokedynamic_method_impl
 ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool,
-                                                    int index, Bytecodes::Code bc) {
+                                                    int index, Bytecodes::Code bc,
+                                                    ciInstanceKlass* accessor) {
   // Compare the following logic with InterpreterRuntime::resolve_invokedynamic.
   assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic");
 
@@ -807,9 +808,10 @@
   // Call site might not be resolved yet.  We could create a real invoker method from the
   // compiler, but it is simpler to stop the code path here with an unlinked method.
   if (!is_resolved) {
-    ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
-    ciSymbol*        sig_sym  = get_symbol(cpool->signature_ref_at(index));
-    return get_unloaded_method(mh_klass, ciSymbol::invokeExact_name(), sig_sym);
+    ciInstanceKlass* holder    = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
+    ciSymbol*        name      = ciSymbol::invokeExact_name();
+    ciSymbol*        signature = get_symbol(cpool->signature_ref_at(index));
+    return get_unloaded_method(holder, name, signature, accessor);
   }
 
   // Get the invoker methodOop from the constant pool.
@@ -850,9 +852,9 @@
                                      int index, Bytecodes::Code bc,
                                      ciInstanceKlass* accessor) {
   if (bc == Bytecodes::_invokedynamic) {
-    GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc);)
+    GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc, accessor);)
   } else {
-    GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);)
+    GUARDED_VM_ENTRY(return get_method_by_index_impl(          cpool, index, bc, accessor);)
   }
 }
 
@@ -884,42 +886,63 @@
 }
 
 // ------------------------------------------------------------------
-// ciEnv::check_for_system_dictionary_modification
-// Check for changes to the system dictionary during compilation
-// class loads, evolution, breakpoints
-void ciEnv::check_for_system_dictionary_modification(ciMethod* target) {
+// ciEnv::validate_compile_task_dependencies
+//
+// Check for changes during compilation (e.g. class loads, evolution,
+// breakpoints, call site invalidation).
+void ciEnv::validate_compile_task_dependencies(ciMethod* target) {
   if (failing())  return;  // no need for further checks
 
-  // Dependencies must be checked when the system dictionary changes.
-  // If logging is enabled all violated dependences will be recorded in
-  // the log.  In debug mode check dependencies even if the system
-  // dictionary hasn't changed to verify that no invalid dependencies
-  // were inserted.  Any violated dependences in this case are dumped to
-  // the tty.
-
-  bool counter_changed = system_dictionary_modification_counter_changed();
-  bool test_deps = counter_changed;
-  DEBUG_ONLY(test_deps = true);
-  if (!test_deps)  return;
-
-  bool print_failures = false;
-  DEBUG_ONLY(print_failures = !counter_changed);
-
-  bool keep_going = (print_failures || xtty != NULL);
-
-  int violated = 0;
-
+  // First, check non-klass dependencies as we might return early and
+  // not check klass dependencies if the system dictionary
+  // modification counter hasn't changed (see below).
   for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
+    if (deps.is_klass_type())  continue;  // skip klass dependencies
     klassOop witness = deps.check_dependency();
     if (witness != NULL) {
-      ++violated;
-      if (print_failures)  deps.print_dependency(witness, /*verbose=*/ true);
-      // If there's no log and we're not sanity-checking, we're done.
-      if (!keep_going)     break;
+      record_failure("invalid non-klass dependency");
+      return;
     }
   }
 
-  if (violated != 0) {
+  // Klass dependencies must be checked when the system dictionary
+  // changes.  If logging is enabled all violated dependences will be
+  // recorded in the log.  In debug mode check dependencies even if
+  // the system dictionary hasn't changed to verify that no invalid
+  // dependencies were inserted.  Any violated dependences in this
+  // case are dumped to the tty.
+  bool counter_changed = system_dictionary_modification_counter_changed();
+
+  bool verify_deps = trueInDebug;
+  if (!counter_changed && !verify_deps)  return;
+
+  int klass_violations = 0;
+  for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
+    if (!deps.is_klass_type())  continue;  // skip non-klass dependencies
+    klassOop witness = deps.check_dependency();
+    if (witness != NULL) {
+      klass_violations++;
+      if (!counter_changed) {
+        // Dependence failed but counter didn't change.  Log a message
+        // describing what failed and allow the assert at the end to
+        // trigger.
+        deps.print_dependency(witness);
+      } else if (xtty == NULL) {
+        // If we're not logging then a single violation is sufficient,
+        // otherwise we want to log all the dependences which were
+        // violated.
+        break;
+      }
+    }
+  }
+
+  if (klass_violations != 0) {
+#ifdef ASSERT
+    if (!counter_changed && !PrintCompilation) {
+      // Print out the compile task that failed
+      _task->print_line();
+    }
+#endif
     assert(counter_changed, "failed dependencies, but counter didn't change");
     record_failure("concurrent class loading");
   }
@@ -938,7 +961,6 @@
                             ImplicitExceptionTable* inc_table,
                             AbstractCompiler* compiler,
                             int comp_level,
-                            bool has_debug_info,
                             bool has_unsafe_access) {
   VM_ENTRY_MARK;
   nmethod* nm = NULL;
@@ -978,8 +1000,8 @@
       // Encode the dependencies now, so we can check them right away.
       dependencies()->encode_content_bytes();
 
-      // Check for {class loads, evolution, breakpoints} during compilation
-      check_for_system_dictionary_modification(target);
+      // Check for {class loads, evolution, breakpoints, ...} during compilation
+      validate_compile_task_dependencies(target);
     }
 
     methodHandle method(THREAD, target->get_methodOop());
@@ -1033,7 +1055,6 @@
         CompileBroker::handle_full_code_cache();
       }
     } else {
-      NOT_PRODUCT(nm->set_has_debug_info(has_debug_info); )
       nm->set_has_unsafe_access(has_unsafe_access);
 
       // Record successful registration.
--- a/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciEnv.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -153,7 +153,8 @@
                                       int method_index, Bytecodes::Code bc,
                                       ciInstanceKlass* loading_klass);
   ciMethod*  get_fake_invokedynamic_method_impl(constantPoolHandle cpool,
-                                                int index, Bytecodes::Code bc);
+                                                int index, Bytecodes::Code bc,
+                                                ciInstanceKlass* accessor);
 
   // Helper methods
   bool       check_klass_accessibility(ciKlass* accessing_klass,
@@ -192,13 +193,14 @@
   // the result.
   ciMethod* get_unloaded_method(ciInstanceKlass* holder,
                                 ciSymbol*        name,
-                                ciSymbol*        signature) {
-    return _factory->get_unloaded_method(holder, name, signature);
+                                ciSymbol*        signature,
+                                ciInstanceKlass* accessor) {
+    return _factory->get_unloaded_method(holder, name, signature, accessor);
   }
 
   // Get a ciKlass representing an unloaded klass.
   // Ensures uniqueness of the result.
-  ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
+  ciKlass* get_unloaded_klass(ciKlass*  accessing_klass,
                               ciSymbol* name) {
     return _factory->get_unloaded_klass(accessing_klass, name, true);
   }
@@ -224,7 +226,7 @@
 
   // See if we already have an unloaded klass for the given name
   // or return NULL if not.
-  ciKlass *check_get_unloaded_klass(ciKlass* accessing_klass, ciSymbol* name) {
+  ciKlass *check_get_unloaded_klass(ciKlass*  accessing_klass, ciSymbol* name) {
     return _factory->get_unloaded_klass(accessing_klass, name, false);
   }
 
@@ -247,9 +249,9 @@
   // Is this thread currently in the VM state?
   static bool is_in_vm();
 
-  // Helper routine for determining the validity of a compilation
-  // with respect to concurrent class loading.
-  void check_for_system_dictionary_modification(ciMethod* target);
+  // Helper routine for determining the validity of a compilation with
+  // respect to method dependencies (e.g. concurrent class loading).
+  void validate_compile_task_dependencies(ciMethod* target);
 
 public:
   enum {
@@ -317,8 +319,7 @@
                        ImplicitExceptionTable*   inc_table,
                        AbstractCompiler*         compiler,
                        int                       comp_level,
-                       bool                      has_debug_info = true,
-                       bool                      has_unsafe_access = false);
+                       bool                      has_unsafe_access);
 
 
   // Access to certain well known ciObjects.
--- a/hotspot/src/share/vm/ci/ciField.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciField.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -64,9 +64,6 @@
   // shared constructor code
   void initialize_from(fieldDescriptor* fd);
 
-  // The implementation of the print method.
-  void print_impl(outputStream* st);
-
 public:
   ciFlags flags() { return _flags; }
 
@@ -178,7 +175,12 @@
   bool is_volatile    () { return flags().is_volatile(); }
   bool is_transient   () { return flags().is_transient(); }
 
-  bool is_call_site_target() { return ((holder() == CURRENT_ENV->CallSite_klass()) && (name() == ciSymbol::target_name())); }
+  bool is_call_site_target() {
+    ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass();
+    if (callsite_klass == NULL)
+      return false;
+    return (holder()->is_subclass_of(callsite_klass) && (name() == ciSymbol::target_name()));
+  }
 
   // Debugging output
   void print();
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -31,6 +31,7 @@
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
 #include "oops/oop.inline.hpp"
+#include "oops/fieldStreams.hpp"
 #include "runtime/fieldDescriptor.hpp"
 
 // ciInstanceKlass
@@ -412,7 +413,7 @@
     VM_ENTRY_MARK;
     ciEnv* curEnv = ciEnv::current();
     instanceKlass* ik = get_instanceKlass();
-    int max_n_fields = ik->fields()->length()/instanceKlass::next_offset;
+    int max_n_fields = ik->java_fields_count();
 
     Arena* arena = curEnv->arena();
     _non_static_fields =
@@ -476,23 +477,6 @@
   // Now sort them by offset, ascending.
   // (In principle, they could mix with superclass fields.)
   fields->sort(sort_field_by_offset);
-#ifdef ASSERT
-  int last_offset = instanceOopDesc::base_offset_in_bytes();
-  for (int i = 0; i < fields->length(); i++) {
-    ciField* field = fields->at(i);
-    int offset = field->offset_in_bytes();
-    int size   = (field->_type == NULL) ? heapOopSize : field->size_in_bytes();
-    assert(last_offset <= offset, err_msg("no field overlap: %d <= %d", last_offset, offset));
-    if (last_offset > (int)sizeof(oopDesc))
-      assert((offset - last_offset) < BytesPerLong, "no big holes");
-    // Note:  Two consecutive T_BYTE fields will be separated by wordSize-1
-    // padding bytes if one of them is declared by a superclass.
-    // This is a minor inefficiency classFileParser.cpp.
-    last_offset = offset + size;
-  }
-  assert(last_offset <= (int)instanceOopDesc::base_offset_in_bytes() + fsize, "no overflow");
-#endif
-
   _nonstatic_fields = fields;
   return flen;
 }
@@ -505,33 +489,29 @@
   int flen = 0;
   GrowableArray<ciField*>* fields = NULL;
   instanceKlass* k = get_instanceKlass();
-  typeArrayOop fields_array = k->fields();
-  for (int pass = 0; pass <= 1; pass++) {
-    for (int i = 0, alen = fields_array->length(); i < alen; i += instanceKlass::next_offset) {
-      fieldDescriptor fd;
-      fd.initialize(k->as_klassOop(), i);
-      if (fd.is_static())  continue;
-      if (pass == 0) {
-        flen += 1;
-      } else {
-        ciField* field = new (arena) ciField(&fd);
-        fields->append(field);
-      }
-    }
+  for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
+    if (fs.access_flags().is_static())  continue;
+    flen += 1;
+  }
 
-    // Between passes, allocate the array:
-    if (pass == 0) {
-      if (flen == 0) {
-        return NULL;  // return nothing if none are locally declared
-      }
-      if (super_fields != NULL) {
-        flen += super_fields->length();
-      }
-      fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
-      if (super_fields != NULL) {
-        fields->appendAll(super_fields);
-      }
-    }
+  // allocate the array:
+  if (flen == 0) {
+    return NULL;  // return nothing if none are locally declared
+  }
+  if (super_fields != NULL) {
+    flen += super_fields->length();
+  }
+  fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
+  if (super_fields != NULL) {
+    fields->appendAll(super_fields);
+  }
+
+  for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
+    if (fs.access_flags().is_static())  continue;
+    fieldDescriptor fd;
+    fd.initialize(k->as_klassOop(), fs.index());
+    ciField* field = new (arena) ciField(&fd);
+    fields->append(field);
   }
   assert(fields->length() == flen, "sanity");
   return fields;
--- a/hotspot/src/share/vm/ci/ciMethod.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -148,21 +148,27 @@
 //
 // Unloaded method.
 ciMethod::ciMethod(ciInstanceKlass* holder,
-                   ciSymbol* name,
-                   ciSymbol* signature) : ciObject(ciMethodKlass::make()) {
-  // These fields are always filled in.
-  _name = name;
-  _holder = holder;
-  _signature = new (CURRENT_ENV->arena()) ciSignature(_holder, constantPoolHandle(), signature);
-  _intrinsic_id = vmIntrinsics::_none;
-  _liveness = NULL;
-  _can_be_statically_bound = false;
-  _method_blocks = NULL;
-  _method_data = NULL;
+                   ciSymbol*        name,
+                   ciSymbol*        signature,
+                   ciInstanceKlass* accessor) :
+  ciObject(ciMethodKlass::make()),
+  _name(                   name),
+  _holder(                 holder),
+  _intrinsic_id(           vmIntrinsics::_none),
+  _liveness(               NULL),
+  _can_be_statically_bound(false),
+  _method_blocks(          NULL),
+  _method_data(            NULL)
 #if defined(COMPILER2) || defined(SHARK)
-  _flow = NULL;
-  _bcea = NULL;
+  ,
+  _flow(                   NULL),
+  _bcea(                   NULL)
 #endif // COMPILER2 || SHARK
+{
+  // Usually holder and accessor are the same type but in some cases
+  // the holder has the wrong class loader (e.g. invokedynamic call
+  // sites) so we pass the accessor.
+  _signature = new (CURRENT_ENV->arena()) ciSignature(accessor, constantPoolHandle(), signature);
 }
 
 
@@ -1017,6 +1023,34 @@
 }
 
 // ------------------------------------------------------------------
+// ciMethod::code_size_for_inlining
+//
+// Code size for inlining decisions.
+//
+// Don't fully count method handle adapters against inlining budgets:
+// the metric we use here is the number of call sites in the adapter
+// as they are probably the instructions which generate some code.
+int ciMethod::code_size_for_inlining() {
+  check_is_loaded();
+
+  // Method handle adapters
+  if (is_method_handle_adapter()) {
+    // Count call sites
+    int call_site_count = 0;
+    ciBytecodeStream iter(this);
+    while (iter.next() != ciBytecodeStream::EOBC()) {
+      if (Bytecodes::is_invoke(iter.cur_bc())) {
+        call_site_count++;
+      }
+    }
+    return call_site_count;
+  }
+
+  // Normal method
+  return code_size();
+}
+
+// ------------------------------------------------------------------
 // ciMethod::instructions_size
 //
 // This is a rough metric for "fat" methods, compared before inlining
--- a/hotspot/src/share/vm/ci/ciMethod.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -88,7 +88,7 @@
 #endif
 
   ciMethod(methodHandle h_m);
-  ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature);
+  ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
 
   methodOop get_methodOop() const {
     methodOop m = (methodOop)get_oop();
@@ -157,6 +157,9 @@
   int interpreter_invocation_count() const       { check_is_loaded(); return _interpreter_invocation_count; }
   int interpreter_throwout_count() const         { check_is_loaded(); return _interpreter_throwout_count; }
 
+  // Code size for inlining decisions.
+  int code_size_for_inlining();
+
   int comp_level();
   int highest_osr_comp_level();
 
--- a/hotspot/src/share/vm/ci/ciMethodHandle.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciMethodHandle.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,7 +37,7 @@
 // ciMethodHandle::get_adapter
 //
 // Return an adapter for this MethodHandle.
-ciMethod* ciMethodHandle::get_adapter_impl(bool is_invokedynamic) const {
+ciMethod* ciMethodHandle::get_adapter_impl(bool is_invokedynamic) {
   VM_ENTRY_MARK;
   Handle h(get_oop());
   methodHandle callee(_callee->get_methodOop());
@@ -73,7 +73,7 @@
 // ciMethodHandle::get_adapter
 //
 // Return an adapter for this MethodHandle.
-ciMethod* ciMethodHandle::get_adapter(bool is_invokedynamic) const {
+ciMethod* ciMethodHandle::get_adapter(bool is_invokedynamic) {
   ciMethod* result = get_adapter_impl(is_invokedynamic);
   if (result) {
     // Fake up the MDO maturity.
@@ -86,11 +86,22 @@
 }
 
 
+#ifndef PRODUCT
 // ------------------------------------------------------------------
-// ciMethodHandle::print_impl
+// ciMethodHandle::print_chain_impl
 //
 // Implementation of the print method.
-void ciMethodHandle::print_impl(outputStream* st) {
-  st->print(" type=");
-  get_oop()->print();
+void ciMethodHandle::print_chain_impl(outputStream* st) {
+  ASSERT_IN_VM;
+  MethodHandleChain::print(get_oop());
 }
+
+
+// ------------------------------------------------------------------
+// ciMethodHandle::print_chain
+//
+// Implementation of the print_chain method.
+void ciMethodHandle::print_chain(outputStream* st) {
+  GUARDED_VM_ENTRY(print_chain_impl(st););
+}
+#endif
--- a/hotspot/src/share/vm/ci/ciMethodHandle.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciMethodHandle.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,19 +37,23 @@
   ciMethod*      _callee;
   ciMethod*      _caller;
   ciCallProfile  _profile;
+  ciMethod*      _method_handle_adapter;
+  ciMethod*      _invokedynamic_adapter;
 
   // Return an adapter for this MethodHandle.
-  ciMethod* get_adapter_impl(bool is_invokedynamic) const;
-  ciMethod* get_adapter(     bool is_invokedynamic) const;
+  ciMethod* get_adapter_impl(bool is_invokedynamic);
+  ciMethod* get_adapter(     bool is_invokedynamic);
 
 protected:
-  void print_impl(outputStream* st);
+  void print_chain_impl(outputStream* st) PRODUCT_RETURN;
 
 public:
   ciMethodHandle(instanceHandle h_i) :
     ciInstance(h_i),
     _callee(NULL),
-    _caller(NULL)
+    _caller(NULL),
+    _method_handle_adapter(NULL),
+    _invokedynamic_adapter(NULL)
   {}
 
   // What kind of ciObject is this?
@@ -60,10 +64,22 @@
   void set_call_profile(ciCallProfile profile)  { _profile = profile; }
 
   // Return an adapter for a MethodHandle call.
-  ciMethod* get_method_handle_adapter() const { return get_adapter(false); }
+  ciMethod* get_method_handle_adapter() {
+    if (_method_handle_adapter == NULL) {
+      _method_handle_adapter = get_adapter(false);
+    }
+    return _method_handle_adapter;
+  }
 
   // Return an adapter for an invokedynamic call.
-  ciMethod* get_invokedynamic_adapter() const { return get_adapter(true);  }
+  ciMethod* get_invokedynamic_adapter() {
+    if (_invokedynamic_adapter == NULL) {
+      _invokedynamic_adapter = get_adapter(true);
+    }
+    return _invokedynamic_adapter;
+  }
+
+  void print_chain(outputStream* st = tty) PRODUCT_RETURN;
 };
 
 #endif // SHARE_VM_CI_CIMETHODHANDLE_HPP
--- a/hotspot/src/share/vm/ci/ciObject.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciObject.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -194,16 +194,26 @@
 // ciObject::should_be_constant()
 bool ciObject::should_be_constant() {
   if (ScavengeRootsInCode >= 2)  return true;  // force everybody to be a constant
-  if (!JavaObjectsInPerm && !is_null_object()) {
+  if (is_null_object()) return true;
+
+  ciEnv* env = CURRENT_ENV;
+  if (!JavaObjectsInPerm) {
     // We want Strings and Classes to be embeddable by default since
     // they used to be in the perm world.  Not all Strings used to be
     // embeddable but there's no easy way to distinguish the interned
     // from the regulars ones so just treat them all that way.
-    ciEnv* env = CURRENT_ENV;
     if (klass() == env->String_klass() || klass() == env->Class_klass()) {
       return true;
     }
   }
+  if (EnableInvokeDynamic &&
+      (klass()->is_subclass_of(env->MethodHandle_klass()) ||
+       klass()->is_subclass_of(env->CallSite_klass()))) {
+    assert(ScavengeRootsInCode >= 1, "must be");
+    // We want to treat these aggressively.
+    return true;
+  }
+
   return handle() == NULL || is_perm();
 }
 
--- a/hotspot/src/share/vm/ci/ciObjectFactory.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciObjectFactory.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -374,20 +374,32 @@
 // unloaded method.  This may need to change.
 ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder,
                                                ciSymbol*        name,
-                                               ciSymbol*        signature) {
-  for (int i=0; i<_unloaded_methods->length(); i++) {
+                                               ciSymbol*        signature,
+                                               ciInstanceKlass* accessor) {
+  ciSignature* that = NULL;
+  for (int i = 0; i < _unloaded_methods->length(); i++) {
     ciMethod* entry = _unloaded_methods->at(i);
     if (entry->holder()->equals(holder) &&
         entry->name()->equals(name) &&
         entry->signature()->as_symbol()->equals(signature)) {
-      // We've found a match.
-      return entry;
+      // Short-circuit slow resolve.
+      if (entry->signature()->accessing_klass() == accessor) {
+        // We've found a match.
+        return entry;
+      } else {
+        // Lazily create ciSignature
+        if (that == NULL)  that = new (arena()) ciSignature(accessor, constantPoolHandle(), signature);
+        if (entry->signature()->equals(that)) {
+          // We've found a match.
+          return entry;
+        }
+      }
     }
   }
 
   // This is a new unloaded method.  Create it and stick it in
   // the cache.
-  ciMethod* new_method = new (arena()) ciMethod(holder, name, signature);
+  ciMethod* new_method = new (arena()) ciMethod(holder, name, signature, accessor);
 
   init_ident_of(new_method);
   _unloaded_methods->append(new_method);
--- a/hotspot/src/share/vm/ci/ciObjectFactory.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciObjectFactory.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,9 @@
 // which ensures that for each oop, at most one ciObject is created.
 // This invariant allows efficient implementation of ciObject.
 class ciObjectFactory : public ResourceObj {
+  friend class VMStructs;
+  friend class ciEnv;
+
 private:
   static volatile bool _initialized;
   static GrowableArray<ciObject*>* _shared_ci_objects;
@@ -105,7 +108,8 @@
   // Get the ciMethod representing an unloaded/unfound method.
   ciMethod* get_unloaded_method(ciInstanceKlass* holder,
                                 ciSymbol*        name,
-                                ciSymbol*        signature);
+                                ciSymbol*        signature,
+                                ciInstanceKlass* accessor);
 
   // Get a ciKlass representing an unloaded klass.
   ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
--- a/hotspot/src/share/vm/ci/ciSignature.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciSignature.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -80,7 +80,7 @@
 }
 
 // ------------------------------------------------------------------
-// ciSignature::return_ciType
+// ciSignature::return_type
 //
 // What is the return type of this signature?
 ciType* ciSignature::return_type() const {
@@ -88,7 +88,7 @@
 }
 
 // ------------------------------------------------------------------
-// ciSignature::ciType_at
+// ciSignature::type_at
 //
 // What is the type of the index'th element of this
 // signature?
@@ -99,6 +99,24 @@
 }
 
 // ------------------------------------------------------------------
+// ciSignature::equals
+//
+// Compare this signature to another one.  Signatures with different
+// accessing classes but with signature-types resolved to the same
+// types are defined to be equal.
+bool ciSignature::equals(ciSignature* that) {
+  // Compare signature
+  if (!this->as_symbol()->equals(that->as_symbol()))  return false;
+  // Compare all types of the arguments
+  for (int i = 0; i < _count; i++) {
+    if (this->type_at(i) != that->type_at(i))         return false;
+  }
+  // Compare the return type
+  if (this->return_type() != that->return_type())     return false;
+  return true;
+}
+
+// ------------------------------------------------------------------
 // ciSignature::print_signature
 void ciSignature::print_signature() {
   _symbol->print_symbol();
--- a/hotspot/src/share/vm/ci/ciSignature.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciSignature.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -43,6 +43,7 @@
   int _count;
 
   friend class ciMethod;
+  friend class ciObjectFactory;
 
   ciSignature(ciKlass* accessing_klass, constantPoolHandle cpool, ciSymbol* signature);
 
@@ -52,6 +53,7 @@
 
 public:
   ciSymbol* as_symbol() const                    { return _symbol; }
+  ciKlass*  accessing_klass() const              { return _accessing_klass; }
 
   ciType* return_type() const;
   ciType* type_at(int index) const;
@@ -59,6 +61,8 @@
   int       size() const                         { return _size; }
   int       count() const                        { return _count; }
 
+  bool equals(ciSignature* that);
+
   void print_signature();
   void print();
 };
--- a/hotspot/src/share/vm/ci/ciStreams.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/ci/ciStreams.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -129,7 +129,8 @@
   // Return current ByteCode and increment PC to next bytecode, skipping all
   // intermediate constants.  Returns EOBC at end.
   // Expected usage:
-  //     while( (bc = iter.next()) != EOBC() ) { ... }
+  //     ciBytecodeStream iter(m);
+  //     while (iter.next() != ciBytecodeStream::EOBC()) { ... }
   Bytecodes::Code next() {
     _bc_start = _pc;                        // Capture start of bc
     if( _pc >= _end ) return EOBC();        // End-Of-Bytecodes
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,7 @@
 #include "memory/oopFactory.hpp"
 #include "memory/universe.inline.hpp"
 #include "oops/constantPoolOop.hpp"
+#include "oops/fieldStreams.hpp"
 #include "oops/instanceKlass.hpp"
 #include "oops/instanceMirrorKlass.hpp"
 #include "oops/klass.inline.hpp"
@@ -991,42 +992,98 @@
   STATIC_BYTE,          // Boolean, Byte, char
   STATIC_SHORT,         // shorts
   STATIC_WORD,          // ints
-  STATIC_DOUBLE,        // long or double
-  STATIC_ALIGNED_DOUBLE,// aligned long or double
+  STATIC_DOUBLE,        // aligned long or double
   NONSTATIC_OOP,
   NONSTATIC_BYTE,
   NONSTATIC_SHORT,
   NONSTATIC_WORD,
   NONSTATIC_DOUBLE,
-  NONSTATIC_ALIGNED_DOUBLE
+  MAX_FIELD_ALLOCATION_TYPE,
+  BAD_ALLOCATION_TYPE = -1
 };
 
-
-struct FieldAllocationCount {
-  unsigned int static_oop_count;
-  unsigned int static_byte_count;
-  unsigned int static_short_count;
-  unsigned int static_word_count;
-  unsigned int static_double_count;
-  unsigned int nonstatic_oop_count;
-  unsigned int nonstatic_byte_count;
-  unsigned int nonstatic_short_count;
-  unsigned int nonstatic_word_count;
-  unsigned int nonstatic_double_count;
+static FieldAllocationType _basic_type_to_atype[2 * (T_CONFLICT + 1)] = {
+  BAD_ALLOCATION_TYPE, // 0
+  BAD_ALLOCATION_TYPE, // 1
+  BAD_ALLOCATION_TYPE, // 2
+  BAD_ALLOCATION_TYPE, // 3
+  NONSTATIC_BYTE ,     // T_BOOLEAN  =  4,
+  NONSTATIC_SHORT,     // T_CHAR     =  5,
+  NONSTATIC_WORD,      // T_FLOAT    =  6,
+  NONSTATIC_DOUBLE,    // T_DOUBLE   =  7,
+  NONSTATIC_BYTE,      // T_BYTE     =  8,
+  NONSTATIC_SHORT,     // T_SHORT    =  9,
+  NONSTATIC_WORD,      // T_INT      = 10,
+  NONSTATIC_DOUBLE,    // T_LONG     = 11,
+  NONSTATIC_OOP,       // T_OBJECT   = 12,
+  NONSTATIC_OOP,       // T_ARRAY    = 13,
+  BAD_ALLOCATION_TYPE, // T_VOID     = 14,
+  BAD_ALLOCATION_TYPE, // T_ADDRESS  = 15,
+  BAD_ALLOCATION_TYPE, // T_NARROWOOP= 16,
+  BAD_ALLOCATION_TYPE, // T_CONFLICT = 17,
+  BAD_ALLOCATION_TYPE, // 0
+  BAD_ALLOCATION_TYPE, // 1
+  BAD_ALLOCATION_TYPE, // 2
+  BAD_ALLOCATION_TYPE, // 3
+  STATIC_BYTE ,        // T_BOOLEAN  =  4,
+  STATIC_SHORT,        // T_CHAR     =  5,
+  STATIC_WORD,          // T_FLOAT    =  6,
+  STATIC_DOUBLE,       // T_DOUBLE   =  7,
+  STATIC_BYTE,         // T_BYTE     =  8,
+  STATIC_SHORT,        // T_SHORT    =  9,
+  STATIC_WORD,         // T_INT      = 10,
+  STATIC_DOUBLE,       // T_LONG     = 11,
+  STATIC_OOP,          // T_OBJECT   = 12,
+  STATIC_OOP,          // T_ARRAY    = 13,
+  BAD_ALLOCATION_TYPE, // T_VOID     = 14,
+  BAD_ALLOCATION_TYPE, // T_ADDRESS  = 15,
+  BAD_ALLOCATION_TYPE, // T_NARROWOOP= 16,
+  BAD_ALLOCATION_TYPE, // T_CONFLICT = 17,
 };
 
-typeArrayHandle ClassFileParser::parse_fields(constantPoolHandle cp, bool is_interface,
-                                              struct FieldAllocationCount *fac,
-                                              objArrayHandle* fields_annotations, TRAPS) {
+static FieldAllocationType basic_type_to_atype(bool is_static, BasicType type) {
+  assert(type >= T_BOOLEAN && type < T_VOID, "only allowable values");
+  FieldAllocationType result = _basic_type_to_atype[type + (is_static ? (T_CONFLICT + 1) : 0)];
+  assert(result != BAD_ALLOCATION_TYPE, "bad type");
+  return result;
+}
+
+class FieldAllocationCount: public ResourceObj {
+ public:
+  unsigned int count[MAX_FIELD_ALLOCATION_TYPE];
+
+  FieldAllocationCount() {
+    for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) {
+      count[i] = 0;
+    }
+  }
+
+  FieldAllocationType update(bool is_static, BasicType type) {
+    FieldAllocationType atype = basic_type_to_atype(is_static, type);
+    count[atype]++;
+    return atype;
+  }
+};
+
+
+typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name,
+                                              constantPoolHandle cp, bool is_interface,
+                                              FieldAllocationCount *fac,
+                                              objArrayHandle* fields_annotations,
+                                              int* java_fields_count_ptr, TRAPS) {
   ClassFileStream* cfs = stream();
   typeArrayHandle nullHandle;
   cfs->guarantee_more(2, CHECK_(nullHandle));  // length
   u2 length = cfs->get_u2_fast();
+  *java_fields_count_ptr = length;
+
+  int num_injected = 0;
+  InjectedField* injected = JavaClasses::get_injected(class_name, &num_injected);
+
   // Tuples of shorts [access, name index, sig index, initial value index, byte offset, generic signature index]
-  typeArrayOop new_fields = oopFactory::new_permanent_shortArray(length*instanceKlass::next_offset, CHECK_(nullHandle));
+  typeArrayOop new_fields = oopFactory::new_permanent_shortArray((length + num_injected) * FieldInfo::field_slots, CHECK_(nullHandle));
   typeArrayHandle fields(THREAD, new_fields);
 
-  int index = 0;
   typeArrayHandle field_annotations;
   for (int n = 0; n < length; n++) {
     cfs->guarantee_more(8, CHECK_(nullHandle));  // access_flags, name_index, descriptor_index, attributes_count
@@ -1077,93 +1134,77 @@
       }
     }
 
-    fields->short_at_put(index++, access_flags.as_short());
-    fields->short_at_put(index++, name_index);
-    fields->short_at_put(index++, signature_index);
-    fields->short_at_put(index++, constantvalue_index);
+    FieldInfo* field = FieldInfo::from_field_array(fields(), n);
+    field->initialize(access_flags.as_short(),
+                      name_index,
+                      signature_index,
+                      constantvalue_index,
+                      generic_signature_index,
+                      0);
+
+    BasicType type = cp->basic_type_for_signature_at(signature_index);
 
     // Remember how many oops we encountered and compute allocation type
-    BasicType type = cp->basic_type_for_signature_at(signature_index);
-    FieldAllocationType atype;
-    if ( is_static ) {
-      switch ( type ) {
-        case  T_BOOLEAN:
-        case  T_BYTE:
-          fac->static_byte_count++;
-          atype = STATIC_BYTE;
-          break;
-        case  T_LONG:
-        case  T_DOUBLE:
-          if (Universe::field_type_should_be_aligned(type)) {
-            atype = STATIC_ALIGNED_DOUBLE;
-          } else {
-            atype = STATIC_DOUBLE;
-          }
-          fac->static_double_count++;
-          break;
-        case  T_CHAR:
-        case  T_SHORT:
-          fac->static_short_count++;
-          atype = STATIC_SHORT;
-          break;
-        case  T_FLOAT:
-        case  T_INT:
-          fac->static_word_count++;
-          atype = STATIC_WORD;
-          break;
-        case  T_ARRAY:
-        case  T_OBJECT:
-          fac->static_oop_count++;
-          atype = STATIC_OOP;
-          break;
-        case  T_ADDRESS:
-        case  T_VOID:
-        default:
-          assert(0, "bad field type");
-      }
-    } else {
-      switch ( type ) {
-        case  T_BOOLEAN:
-        case  T_BYTE:
-          fac->nonstatic_byte_count++;
-          atype = NONSTATIC_BYTE;
-          break;
-        case  T_LONG:
-        case  T_DOUBLE:
-          if (Universe::field_type_should_be_aligned(type)) {
-            atype = NONSTATIC_ALIGNED_DOUBLE;
-          } else {
-            atype = NONSTATIC_DOUBLE;
-          }
-          fac->nonstatic_double_count++;
-          break;
-        case  T_CHAR:
-        case  T_SHORT:
-          fac->nonstatic_short_count++;
-          atype = NONSTATIC_SHORT;
-          break;
-        case  T_FLOAT:
-        case  T_INT:
-          fac->nonstatic_word_count++;
-          atype = NONSTATIC_WORD;
-          break;
-        case  T_ARRAY:
-        case  T_OBJECT:
-          fac->nonstatic_oop_count++;
-          atype = NONSTATIC_OOP;
-          break;
-        case  T_ADDRESS:
-        case  T_VOID:
-        default:
-          assert(0, "bad field type");
-      }
-    }
+    FieldAllocationType atype = fac->update(is_static, type);
 
     // The correct offset is computed later (all oop fields will be located together)
     // We temporarily store the allocation type in the offset field
-    fields->short_at_put(index++, atype);
-    fields->short_at_put(index++, 0);  // Clear out high word of byte offset
-    fields->short_at_put(index++, generic_signature_index);
+    field->set_offset(atype);
+  }
+
+  if (num_injected != 0) {
+    int index = length;
+    for (int n = 0; n < num_injected; n++) {
+      // Check for duplicates
+      if (injected[n].may_be_java) {
+        Symbol* name      = injected[n].name();
+        Symbol* signature = injected[n].signature();
+        bool duplicate = false;
+        for (int i = 0; i < length; i++) {
+          FieldInfo* f = FieldInfo::from_field_array(fields(), i);
+          if (name      == cp->symbol_at(f->name_index()) &&
+              signature == cp->symbol_at(f->signature_index())) {
+            // Symbol is desclared in Java so skip this one
+            duplicate = true;
+            break;
+          }
+        }
+        if (duplicate) {
+          // These will be removed from the field array at the end
+          continue;
+        }
+      }
+
+      // Injected field
+      FieldInfo* field = FieldInfo::from_field_array(fields(), index);
+      field->initialize(JVM_ACC_FIELD_INTERNAL,
+                        injected[n].name_index,
+                        injected[n].signature_index,
+                        0,
+                        0,
+                        0);
+
+      BasicType type = FieldType::basic_type(injected[n].signature());
+
+      // Remember how many oops we encountered and compute allocation type
+      FieldAllocationType atype = fac->update(false, type);
+
+      // The correct offset is computed later (all oop fields will be located together)
+      // We temporarily store the allocation type in the offset field
+      field->set_offset(atype);
+      index++;
+    }
+
+    if (index < length + num_injected) {
+      // sometimes injected fields already exist in the Java source so
+      // the fields array could be too long.  In that case trim the
+      // fields array.
+      new_fields = oopFactory::new_permanent_shortArray(index * FieldInfo::field_slots, CHECK_(nullHandle));
+      for (int i = 0; i < index * FieldInfo::field_slots; i++) {
+        new_fields->short_at_put(i, fields->short_at(i));
+      }
+      fields = new_fields;
+    }
   }
 
   if (_need_verify && length > 1) {
@@ -1175,11 +1216,9 @@
     bool dup = false;
     {
       debug_only(No_Safepoint_Verifier nsv;)
-      for (int i = 0; i < length*instanceKlass::next_offset; i += instanceKlass::next_offset) {
-        int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
-        Symbol* name = cp->symbol_at(name_index);
-        int sig_index = fields->ushort_at(i + instanceKlass::signature_index_offset);
-        Symbol* sig = cp->symbol_at(sig_index);
+      for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) {
+        Symbol* name = fs.name();
+        Symbol* sig = fs.signature();
         // If no duplicates, add name/signature in hashtable names_and_sigs.
         if (!put_after_lookup(name, sig, names_and_sigs)) {
           dup = true;
@@ -2592,227 +2631,6 @@
 }
 
 
-void ClassFileParser::java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
-  constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS) {
-  // This code is for compatibility with earlier jdk's that do not
-  // have the "discovered" field in java.lang.ref.Reference.  For 1.5
-  // the check for the "discovered" field should issue a warning if
-  // the field is not found.  For 1.6 this code should be issue a
-  // fatal error if the "discovered" field is not found.
-  //
-  // Increment fac.nonstatic_oop_count so that the start of the
-  // next type of non-static oops leaves room for the fake oop.
-  // Do not increment next_nonstatic_oop_offset so that the
-  // fake oop is place after the java.lang.ref.Reference oop
-  // fields.
-  //
-  // Check the fields in java.lang.ref.Reference for the "discovered"
-  // field.  If it is not present, artifically create a field for it.
-  // This allows this VM to run on early JDK where the field is not
-  // present.
-  int reference_sig_index = 0;
-  int reference_name_index = 0;
-  int reference_index = 0;
-  int extra = java_lang_ref_Reference::number_of_fake_oop_fields;
-  const int n = (*fields_ptr)()->length();
-  for (int i = 0; i < n; i += instanceKlass::next_offset ) {
-    int name_index =
-    (*fields_ptr)()->ushort_at(i + instanceKlass::name_index_offset);
-    int sig_index  =
-      (*fields_ptr)()->ushort_at(i + instanceKlass::signature_index_offset);
-    Symbol* f_name = cp->symbol_at(name_index);
-    Symbol* f_sig  = cp->symbol_at(sig_index);
-    if (f_sig == vmSymbols::reference_signature() && reference_index == 0) {
-      // Save the index for reference signature for later use.
-      // The fake discovered field does not entries in the
-      // constant pool so the index for its signature cannot
-      // be extracted from the constant pool.  It will need
-      // later, however.  It's signature is vmSymbols::reference_signature()
-      // so same an index for that signature.
-      reference_sig_index = sig_index;
-      reference_name_index = name_index;
-      reference_index = i;
-    }
-    if (f_name == vmSymbols::reference_discovered_name() &&
-      f_sig == vmSymbols::reference_signature()) {
-      // The values below are fake but will force extra
-      // non-static oop fields and a corresponding non-static
-      // oop map block to be allocated.
-      extra = 0;
-      break;
-    }
-  }
-  if (extra != 0) {
-    fac_ptr->nonstatic_oop_count += extra;
-    // Add the additional entry to "fields" so that the klass
-    // contains the "discoverd" field and the field will be initialized
-    // in instances of the object.
-    int fields_with_fix_length = (*fields_ptr)()->length() +
-      instanceKlass::next_offset;
-    typeArrayOop ff = oopFactory::new_permanent_shortArray(
-                                                fields_with_fix_length, CHECK);
-    typeArrayHandle fields_with_fix(THREAD, ff);
-
-    // Take everything from the original but the length.
-    for (int idx = 0; idx < (*fields_ptr)->length(); idx++) {
-      fields_with_fix->ushort_at_put(idx, (*fields_ptr)->ushort_at(idx));
-    }
-
-    // Add the fake field at the end.
-    int i = (*fields_ptr)->length();
-    // There is no name index for the fake "discovered" field nor
-    // signature but a signature is needed so that the field will
-    // be properly initialized.  Use one found for
-    // one of the other reference fields. Be sure the index for the
-    // name is 0.  In fieldDescriptor::initialize() the index of the
-    // name is checked.  That check is by passed for the last nonstatic
-    // oop field in a java.lang.ref.Reference which is assumed to be
-    // this artificial "discovered" field.  An assertion checks that
-    // the name index is 0.
-    assert(reference_index != 0, "Missing signature for reference");
-
-    int j;
-    for (j = 0; j < instanceKlass::next_offset; j++) {
-      fields_with_fix->ushort_at_put(i + j,
-        (*fields_ptr)->ushort_at(reference_index +j));
-    }
-    // Clear the public access flag and set the private access flag.
-    short flags;
-    flags =
-      fields_with_fix->ushort_at(i + instanceKlass::access_flags_offset);
-    assert(!(flags & JVM_RECOGNIZED_FIELD_MODIFIERS), "Unexpected access flags set");
-    flags = flags & (~JVM_ACC_PUBLIC);
-    flags = flags | JVM_ACC_PRIVATE;
-    AccessFlags access_flags;
-    access_flags.set_flags(flags);
-    assert(!access_flags.is_public(), "Failed to clear public flag");
-    assert(access_flags.is_private(), "Failed to set private flag");
-    fields_with_fix->ushort_at_put(i + instanceKlass::access_flags_offset,
-      flags);
-
-    assert(fields_with_fix->ushort_at(i + instanceKlass::name_index_offset)
-      == reference_name_index, "The fake reference name is incorrect");
-    assert(fields_with_fix->ushort_at(i + instanceKlass::signature_index_offset)
-      == reference_sig_index, "The fake reference signature is incorrect");
-    // The type of the field is stored in the low_offset entry during
-    // parsing.
-    assert(fields_with_fix->ushort_at(i + instanceKlass::low_offset) ==
-      NONSTATIC_OOP, "The fake reference type is incorrect");
-
-    // "fields" is allocated in the permanent generation.  Disgard
-    // it and let it be collected.
-    (*fields_ptr) = fields_with_fix;
-  }
-  return;
-}
-
-
-void ClassFileParser::java_lang_Class_fix_pre(int* nonstatic_field_size,
-                                              FieldAllocationCount *fac_ptr) {
-  // Add fake fields for java.lang.Class instances
-  //
-  // This is not particularly nice. We should consider adding a
-  // private transient object field at the Java level to
-  // java.lang.Class. Alternatively we could add a subclass of
-  // instanceKlass which provides an accessor and size computer for
-  // this field, but that appears to be more code than this hack.
-  //
-  // NOTE that we wedge these in at the beginning rather than the
-  // end of the object because the Class layout changed between JDK
-  // 1.3 and JDK 1.4 with the new reflection implementation; some
-  // nonstatic oop fields were added at the Java level. The offsets
-  // of these fake fields can't change between these two JDK
-  // versions because when the offsets are computed at bootstrap
-  // time we don't know yet which version of the JDK we're running in.
-
-  // The values below are fake but will force three non-static oop fields and
-  // a corresponding non-static oop map block to be allocated.
-  const int extra = java_lang_Class::number_of_fake_oop_fields;
-  fac_ptr->nonstatic_oop_count += extra;
-
-  // Reserve some leading space for fake ints
-  *nonstatic_field_size += align_size_up(java_lang_Class::hc_number_of_fake_int_fields * BytesPerInt, heapOopSize) / heapOopSize;
-}
-
-
-void ClassFileParser::java_lang_Class_fix_post(int* next_nonstatic_oop_offset_ptr) {
-  // Cause the extra fake fields in java.lang.Class to show up before
-  // the Java fields for layout compatibility between 1.3 and 1.4
-  // Incrementing next_nonstatic_oop_offset here advances the
-  // location where the real java fields are placed.
-  const int extra = java_lang_Class::number_of_fake_oop_fields;
-  (*next_nonstatic_oop_offset_ptr) += (extra * heapOopSize);
-}
-
-
-// Force MethodHandle.vmentry to be an unmanaged pointer.
-// There is no way for a classfile to express this, so we must help it.
-void ClassFileParser::java_lang_invoke_MethodHandle_fix_pre(constantPoolHandle cp,
-                                                    typeArrayHandle fields,
-                                                    FieldAllocationCount *fac_ptr,
-                                                    TRAPS) {
-  // Add fake fields for java.lang.invoke.MethodHandle instances
-  //
-  // This is not particularly nice, but since there is no way to express
-  // a native wordSize field in Java, we must do it at this level.
-
-  if (!EnableInvokeDynamic)  return;
-
-  int word_sig_index = 0;
-  const int cp_size = cp->length();
-  for (int index = 1; index < cp_size; index++) {
-    if (cp->tag_at(index).is_utf8() &&
-        cp->symbol_at(index) == vmSymbols::machine_word_signature()) {
-      word_sig_index = index;
-      break;
-    }
-  }
-
-  if (word_sig_index == 0)
-    THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
-              "missing I or J signature (for vmentry) in java.lang.invoke.MethodHandle");
-
-  // Find vmentry field and change the signature.
-  bool found_vmentry = false;
-  for (int i = 0; i < fields->length(); i += instanceKlass::next_offset) {
-    int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
-    int sig_index  = fields->ushort_at(i + instanceKlass::signature_index_offset);
-    int acc_flags  = fields->ushort_at(i + instanceKlass::access_flags_offset);
-    Symbol* f_name = cp->symbol_at(name_index);
-    Symbol* f_sig  = cp->symbol_at(sig_index);
-    if (f_name == vmSymbols::vmentry_name() && (acc_flags & JVM_ACC_STATIC) == 0) {
-      if (f_sig == vmSymbols::machine_word_signature()) {
-        // If the signature of vmentry is already changed, we're done.
-        found_vmentry = true;
-        break;
-      }
-      else if (f_sig == vmSymbols::byte_signature()) {
-        // Adjust the field type from byte to an unmanaged pointer.
-        assert(fac_ptr->nonstatic_byte_count > 0, "");
-        fac_ptr->nonstatic_byte_count -= 1;
-
-        fields->ushort_at_put(i + instanceKlass::signature_index_offset, word_sig_index);
-        assert(wordSize == longSize || wordSize == jintSize, "ILP32 or LP64");
-        if (wordSize == longSize)  fac_ptr->nonstatic_double_count += 1;
-        else                       fac_ptr->nonstatic_word_count   += 1;
-
-        FieldAllocationType atype = (FieldAllocationType) fields->ushort_at(i + instanceKlass::low_offset);
-        assert(atype == NONSTATIC_BYTE, "");
-        FieldAllocationType new_atype = (wordSize == longSize) ? NONSTATIC_DOUBLE : NONSTATIC_WORD;
-        fields->ushort_at_put(i + instanceKlass::low_offset, new_atype);
-
-        found_vmentry = true;
-        break;
-      }
-    }
-  }
-
-  if (!found_vmentry)
-    THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
-              "missing vmentry byte field in java.lang.invoke.MethodHandle");
-}
-
-
 instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
                                                     Handle class_loader,
                                                     Handle protection_domain,
@@ -3025,10 +2843,13 @@
       local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle));
     }
 
+    int java_fields_count = 0;
     // Fields (offsets are filled in later)
-    struct FieldAllocationCount fac = {0,0,0,0,0,0,0,0,0,0};
+    FieldAllocationCount fac;
     objArrayHandle fields_annotations;
-    typeArrayHandle fields = parse_fields(cp, access_flags.is_interface(), &fac, &fields_annotations, CHECK_(nullHandle));
+    typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
+                                          &java_fields_count,
+                                          CHECK_(nullHandle));
     // Methods
     bool has_final_method = false;
     AccessFlags promoted_flags;
@@ -3146,51 +2967,33 @@
     // Calculate the starting byte offsets
     next_static_oop_offset      = instanceMirrorKlass::offset_of_static_fields();
     next_static_double_offset   = next_static_oop_offset +
-                                  (fac.static_oop_count * heapOopSize);
-    if ( fac.static_double_count &&
+                                  (fac.count[STATIC_OOP] * heapOopSize);
+    if ( fac.count[STATIC_DOUBLE] &&
          (Universe::field_type_should_be_aligned(T_DOUBLE) ||
           Universe::field_type_should_be_aligned(T_LONG)) ) {
       next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong);
     }
 
     next_static_word_offset     = next_static_double_offset +
-                                  (fac.static_double_count * BytesPerLong);
+                                  (fac.count[STATIC_DOUBLE] * BytesPerLong);
     next_static_short_offset    = next_static_word_offset +
-                                  (fac.static_word_count * BytesPerInt);
+                                  (fac.count[STATIC_WORD] * BytesPerInt);
     next_static_byte_offset     = next_static_short_offset +
-                                  (fac.static_short_count * BytesPerShort);
+                                  (fac.count[STATIC_SHORT] * BytesPerShort);
     next_static_type_offset     = align_size_up((next_static_byte_offset +
-                                  fac.static_byte_count ), wordSize );
+                                  fac.count[STATIC_BYTE] ), wordSize );
     static_field_size           = (next_static_type_offset -
                                   next_static_oop_offset) / wordSize;
 
-    // Add fake fields for java.lang.Class instances (also see below)
-    if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
-      java_lang_Class_fix_pre(&nonstatic_field_size, &fac);
-    }
-
     first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
                                    nonstatic_field_size * heapOopSize;
     next_nonstatic_field_offset = first_nonstatic_field_offset;
 
-    // adjust the vmentry field declaration in java.lang.invoke.MethodHandle
-    if (EnableInvokeDynamic && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) {
-      java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
-    }
-
-    // Add a fake "discovered" field if it is not present
-    // for compatibility with earlier jdk's.
-    if (class_name == vmSymbols::java_lang_ref_Reference()
-      && class_loader.is_null()) {
-      java_lang_ref_Reference_fix_pre(&fields, cp, &fac, CHECK_(nullHandle));
-    }
-    // end of "discovered" field compactibility fix
-
-    unsigned int nonstatic_double_count = fac.nonstatic_double_count;
-    unsigned int nonstatic_word_count   = fac.nonstatic_word_count;
-    unsigned int nonstatic_short_count  = fac.nonstatic_short_count;
-    unsigned int nonstatic_byte_count   = fac.nonstatic_byte_count;
-    unsigned int nonstatic_oop_count    = fac.nonstatic_oop_count;
+    unsigned int nonstatic_double_count = fac.count[NONSTATIC_DOUBLE];
+    unsigned int nonstatic_word_count   = fac.count[NONSTATIC_WORD];
+    unsigned int nonstatic_short_count  = fac.count[NONSTATIC_SHORT];
+    unsigned int nonstatic_byte_count   = fac.count[NONSTATIC_BYTE];
+    unsigned int nonstatic_oop_count    = fac.count[NONSTATIC_OOP];
 
     bool super_has_nonstatic_fields =
             (super_klass() != NULL && super_klass->has_nonstatic_fields());
@@ -3210,20 +3013,7 @@
     nonstatic_oop_counts  = NEW_RESOURCE_ARRAY_IN_THREAD(
               THREAD, unsigned int, nonstatic_oop_count + 1);
 
-    // Add fake fields for java.lang.Class instances (also see above).
-    // FieldsAllocationStyle and CompactFields values will be reset to default.
-    if(class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
-      java_lang_Class_fix_post(&next_nonstatic_field_offset);
-      nonstatic_oop_offsets[0] = first_nonstatic_field_offset;
-      const uint fake_oop_count = (next_nonstatic_field_offset -
-                                   first_nonstatic_field_offset) / heapOopSize;
-      nonstatic_oop_counts[0] = fake_oop_count;
-      nonstatic_oop_map_count = 1;
-      nonstatic_oop_count -= fake_oop_count;
-      first_nonstatic_oop_offset = first_nonstatic_field_offset;
-    } else {
-      first_nonstatic_oop_offset = 0; // will be set for first oop field
-    }
+    first_nonstatic_oop_offset = 0; // will be set for first oop field
 
 #ifndef PRODUCT
     if( PrintCompactFieldsSavings ) {
@@ -3378,10 +3168,9 @@
     // Iterate over fields again and compute correct offsets.
     // The field allocation type was temporarily stored in the offset slot.
     // oop fields are located before non-oop fields (static and non-static).
-    int len = fields->length();
-    for (int i = 0; i < len; i += instanceKlass::next_offset) {
+    for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) {
       int real_offset;
-      FieldAllocationType atype = (FieldAllocationType) fields->ushort_at(i + instanceKlass::low_offset);
+      FieldAllocationType atype = (FieldAllocationType) fs.offset();
       switch (atype) {
         case STATIC_OOP:
           real_offset = next_static_oop_offset;
@@ -3399,7 +3188,6 @@
           real_offset = next_static_word_offset;
           next_static_word_offset += BytesPerInt;
           break;
-        case STATIC_ALIGNED_DOUBLE:
         case STATIC_DOUBLE:
           real_offset = next_static_double_offset;
           next_static_double_offset += BytesPerLong;
@@ -3461,7 +3249,6 @@
             next_nonstatic_word_offset += BytesPerInt;
           }
           break;
-        case NONSTATIC_ALIGNED_DOUBLE:
         case NONSTATIC_DOUBLE:
           real_offset = next_nonstatic_double_offset;
           next_nonstatic_double_offset += BytesPerLong;
@@ -3469,8 +3256,7 @@
         default:
           ShouldNotReachHere();
       }
-      fields->short_at_put(i + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
-      fields->short_at_put(i + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
+      fs.set_offset(real_offset);
     }
 
     // Size of instances
@@ -3517,12 +3303,12 @@
     this_klass->set_class_loader(class_loader());
     this_klass->set_nonstatic_field_size(nonstatic_field_size);
     this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
-    this_klass->set_static_oop_field_count(fac.static_oop_count);
+    this_klass->set_static_oop_field_count(fac.count[STATIC_OOP]);
     cp->set_pool_holder(this_klass());
     error_handler.set_in_error(false);   // turn off error handler for cp
     this_klass->set_constants(cp());
     this_klass->set_local_interfaces(local_interfaces());
-    this_klass->set_fields(fields());
+    this_klass->set_fields(fields(), java_fields_count);
     this_klass->set_methods(methods());
     if (has_final_method) {
       this_klass->set_has_final_method();
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -33,6 +33,9 @@
 #include "utilities/accessFlags.hpp"
 
 class TempNewSymbol;
+class FieldAllocationCount;
+
+
 // Parser for for .class files
 //
 // The bytes describing the class file structure is read from a Stream object
@@ -84,9 +87,11 @@
                               bool* is_synthetic_addr,
                               u2* generic_signature_index_addr,
                               typeArrayHandle* field_annotations, TRAPS);
-  typeArrayHandle parse_fields(constantPoolHandle cp, bool is_interface,
-                               struct FieldAllocationCount *fac,
-                               objArrayHandle* fields_annotations, TRAPS);
+  typeArrayHandle parse_fields(Symbol* class_name,
+                               constantPoolHandle cp, bool is_interface,
+                               FieldAllocationCount *fac,
+                               objArrayHandle* fields_annotations,
+                               int* java_fields_count_ptr, TRAPS);
 
   // Method parsing
   methodHandle parse_method(constantPoolHandle cp, bool is_interface,
@@ -150,25 +155,6 @@
   objArrayHandle compute_transitive_interfaces(instanceKlassHandle super,
                                                objArrayHandle local_ifs, TRAPS);
 
-  // Special handling for certain classes.
-  // Add the "discovered" field to java.lang.ref.Reference if
-  // it does not exist.
-  void java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
-                                       constantPoolHandle cp,
-                                       FieldAllocationCount *fac_ptr, TRAPS);
-  // Adjust the field allocation counts for java.lang.Class to add
-  // fake fields.
-  void java_lang_Class_fix_pre(int* nonstatic_field_size,
-                               FieldAllocationCount *fac_ptr);
-  // Adjust the next_nonstatic_oop_offset to place the fake fields
-  // before any Java fields.
-  void java_lang_Class_fix_post(int* next_nonstatic_oop_offset);
-  // Adjust the field allocation counts for java.lang.invoke.MethodHandle to add
-  // a fake address (void*) field.
-  void java_lang_invoke_MethodHandle_fix_pre(constantPoolHandle cp,
-                                     typeArrayHandle fields,
-                                     FieldAllocationCount *fac_ptr, TRAPS);
-
   // Format checker methods
   void classfile_parse_error(const char* msg, TRAPS);
   void classfile_parse_error(const char* msg, int index, TRAPS);
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -68,6 +68,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 // Entry points in zip.dll for loading zip/jar file entries
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -28,10 +28,12 @@
 #include "classfile/vmSymbols.hpp"
 #include "code/debugInfo.hpp"
 #include "code/pcDesc.hpp"
+#include "compiler/compilerOracle.hpp"
 #include "interpreter/interpreter.hpp"
 #include "memory/oopFactory.hpp"
 #include "memory/resourceArea.hpp"
 #include "memory/universe.inline.hpp"
+#include "oops/fieldStreams.hpp"
 #include "oops/instanceKlass.hpp"
 #include "oops/instanceMirrorKlass.hpp"
 #include "oops/klass.hpp"
@@ -56,6 +58,52 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
+
+#define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
+  klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
+
+#define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
+  { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
+
+InjectedField JavaClasses::_injected_fields[] = {
+  ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
+};
+
+int JavaClasses::compute_injected_offset(InjectedFieldID id) {
+  return _injected_fields[id].compute_offset();
+}
+
+
+InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
+  *field_count = 0;
+
+  vmSymbols::SID sid = vmSymbols::find_sid(class_name);
+  if (sid == vmSymbols::NO_SID) {
+    // Only well known classes can inject fields
+    return NULL;
+  }
+
+  int count = 0;
+  int start = -1;
+
+#define LOOKUP_INJECTED_FIELD(klass, name, signature, may_be_java) \
+  if (sid == vmSymbols::VM_SYMBOL_ENUM_NAME(klass)) {              \
+    count++;                                                       \
+    if (start == -1) start = klass##_##name##_enum;                \
+  }
+  ALL_INJECTED_FIELDS(LOOKUP_INJECTED_FIELD);
+#undef LOOKUP_INJECTED_FIELD
+
+  if (start != -1) {
+    *field_count = count;
+    return _injected_fields + start;
+  }
+  return NULL;
+}
+
 
 static bool find_field(instanceKlass* ik,
                        Symbol* name_symbol, Symbol* signature_symbol,
@@ -427,24 +475,19 @@
 }
 
 
-// During bootstrap, java.lang.Class wasn't loaded so static field
-// offsets were computed without the size added it.  Go back and
-// update all the static field offsets to included the size.
-static void fixup_static_field(fieldDescriptor* fd, TRAPS) {
-  if (fd->is_static()) {
-    int real_offset = fd->offset() + instanceMirrorKlass::offset_of_static_fields();
-    typeArrayOop fields = instanceKlass::cast(fd->field_holder())->fields();
-    fields->short_at_put(fd->index() + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
-    fields->short_at_put(fd->index() + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
-  }
-}
-
 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
   assert(instanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
 
   if (k->oop_is_instance()) {
-    // Fixup the offsets
-    instanceKlass::cast(k())->do_local_static_fields(&fixup_static_field, CHECK);
+    // During bootstrap, java.lang.Class wasn't loaded so static field
+    // offsets were computed without the size added it.  Go back and
+    // update all the static field offsets to included the size.
+    for (JavaFieldStream fs(instanceKlass::cast(k())); !fs.done(); fs.next()) {
+      if (fs.access_flags().is_static()) {
+        int real_offset = fs.offset() + instanceMirrorKlass::offset_of_static_fields();
+        fs.set_offset(real_offset);
+      }
+    }
   }
   create_mirror(k, CHECK);
 }
@@ -460,12 +503,8 @@
   if (SystemDictionary::Class_klass_loaded() && (k->oop_is_instance() || k->oop_is_javaArray())) {
     // Allocate mirror (java.lang.Class instance)
     Handle mirror = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0);
-    // Setup indirections
-    mirror->obj_field_put(klass_offset,  k());
-    k->set_java_mirror(mirror());
 
     instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass());
-    java_lang_Class::set_oop_size(mirror(), mk->instance_size(k));
     java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
 
     // It might also have a component mirror.  This mirror must already exist.
@@ -503,25 +542,22 @@
 
 
 int  java_lang_Class::oop_size(oop java_class) {
-  assert(oop_size_offset != 0, "must be set");
-  return java_class->int_field(oop_size_offset);
+  assert(_oop_size_offset != 0, "must be set");
+  return java_class->int_field(_oop_size_offset);
 }
 void java_lang_Class::set_oop_size(oop java_class, int size) {
-  assert(oop_size_offset != 0, "must be set");
-  java_class->int_field_put(oop_size_offset, size);
+  assert(_oop_size_offset != 0, "must be set");
+  java_class->int_field_put(_oop_size_offset, size);
 }
 int  java_lang_Class::static_oop_field_count(oop java_class) {
-  assert(static_oop_field_count_offset != 0, "must be set");
-  return java_class->int_field(static_oop_field_count_offset);
+  assert(_static_oop_field_count_offset != 0, "must be set");
+  return java_class->int_field(_static_oop_field_count_offset);
 }
 void java_lang_Class::set_static_oop_field_count(oop java_class, int size) {
-  assert(static_oop_field_count_offset != 0, "must be set");
-  java_class->int_field_put(static_oop_field_count_offset, size);
+  assert(_static_oop_field_count_offset != 0, "must be set");
+  java_class->int_field_put(_static_oop_field_count_offset, size);
 }
 
-
-
-
 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
   // This should be improved by adding a field at the Java level or by
   // introducing a new VM klass (see comment in ClassFileParser)
@@ -531,9 +567,10 @@
     assert(aklass != NULL, "correct bootstrap");
     set_array_klass(java_class, aklass);
   }
+#ifdef ASSERT
   instanceMirrorKlass* mk = instanceMirrorKlass::cast(SystemDictionary::Class_klass());
-  java_lang_Class::set_oop_size(java_class, mk->instance_size(oop(NULL)));
-  java_lang_Class::set_static_oop_field_count(java_class, 0);
+  assert(java_lang_Class::static_oop_field_count(java_class) == 0, "should have been zeroed by allocation");
+#endif
   return java_class;
 }
 
@@ -541,12 +578,18 @@
 klassOop java_lang_Class::as_klassOop(oop java_class) {
   //%note memory_2
   assert(java_lang_Class::is_instance(java_class), "must be a Class object");
-  klassOop k = klassOop(java_class->obj_field(klass_offset));
+  klassOop k = klassOop(java_class->obj_field(_klass_offset));
   assert(k == NULL || k->is_klass(), "type check");
   return k;
 }
 
 
+void java_lang_Class::set_klass(oop java_class, klassOop klass) {
+  assert(java_lang_Class::is_instance(java_class), "must be a Class object");
+  java_class->obj_field_put(_klass_offset, klass);
+}
+
+
 void java_lang_Class::print_signature(oop java_class, outputStream* st) {
   assert(java_lang_Class::is_instance(java_class), "must be a Class object");
   Symbol* name = NULL;
@@ -597,7 +640,7 @@
 
 
 klassOop java_lang_Class::array_klass(oop java_class) {
-  klassOop k = klassOop(java_class->obj_field(array_klass_offset));
+  klassOop k = klassOop(java_class->obj_field(_array_klass_offset));
   assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_javaArray(), "should be array klass");
   return k;
 }
@@ -605,12 +648,12 @@
 
 void java_lang_Class::set_array_klass(oop java_class, klassOop klass) {
   assert(klass->is_klass() && Klass::cast(klass)->oop_is_javaArray(), "should be array klass");
-  java_class->obj_field_put(array_klass_offset, klass);
+  java_class->obj_field_put(_array_klass_offset, klass);
 }
 
 
 methodOop java_lang_Class::resolved_constructor(oop java_class) {
-  oop constructor = java_class->obj_field(resolved_constructor_offset);
+  oop constructor = java_class->obj_field(_resolved_constructor_offset);
   assert(constructor == NULL || constructor->is_method(), "should be method");
   return methodOop(constructor);
 }
@@ -618,21 +661,21 @@
 
 void java_lang_Class::set_resolved_constructor(oop java_class, methodOop constructor) {
   assert(constructor->is_method(), "should be method");
-  java_class->obj_field_put(resolved_constructor_offset, constructor);
+  java_class->obj_field_put(_resolved_constructor_offset, constructor);
 }
 
 
 bool java_lang_Class::is_primitive(oop java_class) {
   // should assert:
   //assert(java_lang_Class::is_instance(java_class), "must be a Class object");
-  klassOop k = klassOop(java_class->obj_field(klass_offset));
+  klassOop k = klassOop(java_class->obj_field(_klass_offset));
   return k == NULL;
 }
 
 
 BasicType java_lang_Class::primitive_type(oop java_class) {
   assert(java_lang_Class::is_primitive(java_class), "just checking");
-  klassOop ak = klassOop(java_class->obj_field(array_klass_offset));
+  klassOop ak = klassOop(java_class->obj_field(_array_klass_offset));
   BasicType type = T_VOID;
   if (ak != NULL) {
     // Note: create_basic_type_mirror above initializes ak to a non-null value.
@@ -667,34 +710,18 @@
 
 bool java_lang_Class::offsets_computed = false;
 int  java_lang_Class::classRedefinedCount_offset = -1;
-int  java_lang_Class::parallelCapable_offset = -1;
 
 void java_lang_Class::compute_offsets() {
   assert(!offsets_computed, "offsets should be initialized only once");
   offsets_computed = true;
 
-  klassOop k = SystemDictionary::Class_klass();
+  klassOop klass_oop = SystemDictionary::Class_klass();
   // The classRedefinedCount field is only present starting in 1.5,
   // so don't go fatal.
   compute_optional_offset(classRedefinedCount_offset,
-    k, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
-
-  // The field indicating parallelCapable (parallelLockMap) is only present starting in 7,
-  klassOop k1 = SystemDictionary::ClassLoader_klass();
-  compute_optional_offset(parallelCapable_offset,
-    k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature());
-}
-
-// For class loader classes, parallelCapable defined
-// based on non-null field
-// Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it
-bool java_lang_Class::parallelCapable(oop class_loader) {
-  if (!JDK_Version::is_gte_jdk17x_version()
-     || parallelCapable_offset == -1) {
-     // Default for backward compatibility is false
-     return false;
-  }
-  return (class_loader->obj_field(parallelCapable_offset) != NULL);
+                          klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
+
+  CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
 }
 
 int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
@@ -1124,7 +1151,7 @@
     }
     nmethod* nm = method->code();
     if (WizardMode && nm != NULL) {
-      sprintf(buf + (int)strlen(buf), "(nmethod " PTR_FORMAT ")", (intptr_t)nm);
+      sprintf(buf + (int)strlen(buf), "(nmethod " INTPTR_FORMAT ")", (intptr_t)nm);
     }
   }
 
@@ -2307,7 +2334,6 @@
 int java_lang_invoke_MethodHandle::_type_offset;
 int java_lang_invoke_MethodHandle::_vmtarget_offset;
 int java_lang_invoke_MethodHandle::_vmentry_offset;
-int java_lang_invoke_MethodHandle::_vmslots_offset;
 
 int java_lang_invoke_MemberName::_clazz_offset;
 int java_lang_invoke_MemberName::_name_offset;
@@ -2323,36 +2349,33 @@
 
 int java_lang_invoke_AdapterMethodHandle::_conversion_offset;
 
+int java_lang_invoke_CountingMethodHandle::_vmcount_offset;
+
 void java_lang_invoke_MethodHandle::compute_offsets() {
-  klassOop k = SystemDictionary::MethodHandle_klass();
-  if (k != NULL && EnableInvokeDynamic) {
+  klassOop klass_oop = SystemDictionary::MethodHandle_klass();
+  if (klass_oop != NULL && EnableInvokeDynamic) {
     bool allow_super = false;
-    compute_offset(_type_offset,      k, vmSymbols::type_name(),      vmSymbols::java_lang_invoke_MethodType_signature(), allow_super);
-    compute_offset(_vmtarget_offset,  k, vmSymbols::vmtarget_name(),  vmSymbols::object_signature(),                      allow_super);
-    compute_offset(_vmentry_offset,   k, vmSymbols::vmentry_name(),   vmSymbols::machine_word_signature(),                allow_super);
-
-    // Note:  MH.vmslots (if it is present) is a hoisted copy of MH.type.form.vmslots.
-    // It is optional pending experiments to keep or toss.
-    compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), allow_super);
+    compute_offset(_type_offset,      klass_oop, vmSymbols::type_name(),      vmSymbols::java_lang_invoke_MethodType_signature(), allow_super);
+    METHODHANDLE_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
   }
 }
 
 void java_lang_invoke_MemberName::compute_offsets() {
-  klassOop k = SystemDictionary::MemberName_klass();
-  if (k != NULL && EnableInvokeDynamic) {
-    compute_offset(_clazz_offset,     k, vmSymbols::clazz_name(),     vmSymbols::class_signature());
-    compute_offset(_name_offset,      k, vmSymbols::name_name(),      vmSymbols::string_signature());
-    compute_offset(_type_offset,      k, vmSymbols::type_name(),      vmSymbols::object_signature());
-    compute_offset(_flags_offset,     k, vmSymbols::flags_name(),     vmSymbols::int_signature());
-    compute_offset(_vmtarget_offset,  k, vmSymbols::vmtarget_name(),  vmSymbols::object_signature());
-    compute_offset(_vmindex_offset,   k, vmSymbols::vmindex_name(),   vmSymbols::int_signature());
+  klassOop klass_oop = SystemDictionary::MemberName_klass();
+  if (klass_oop != NULL && EnableInvokeDynamic) {
+    compute_offset(_clazz_offset,     klass_oop, vmSymbols::clazz_name(),     vmSymbols::class_signature());
+    compute_offset(_name_offset,      klass_oop, vmSymbols::name_name(),      vmSymbols::string_signature());
+    compute_offset(_type_offset,      klass_oop, vmSymbols::type_name(),      vmSymbols::object_signature());
+    compute_offset(_flags_offset,     klass_oop, vmSymbols::flags_name(),     vmSymbols::int_signature());
+    compute_offset(_vmindex_offset,   klass_oop, vmSymbols::vmindex_name(),   vmSymbols::int_signature());
+    MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
   }
 }
 
 void java_lang_invoke_DirectMethodHandle::compute_offsets() {
   klassOop k = SystemDictionary::DirectMethodHandle_klass();
   if (k != NULL && EnableInvokeDynamic) {
-    compute_offset(_vmindex_offset,   k, vmSymbols::vmindex_name(),   vmSymbols::int_signature(),    true);
+    DIRECTMETHODHANDLE_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
   }
 }
 
@@ -2371,6 +2394,23 @@
   }
 }
 
+void java_lang_invoke_CountingMethodHandle::compute_offsets() {
+  klassOop k = SystemDictionary::CountingMethodHandle_klass();
+  if (k != NULL && EnableInvokeDynamic) {
+    compute_offset(_vmcount_offset, k, vmSymbols::vmcount_name(), vmSymbols::int_signature(), true);
+  }
+}
+
+int java_lang_invoke_CountingMethodHandle::vmcount(oop mh) {
+  assert(is_instance(mh), "CMH only");
+  return mh->int_field(_vmcount_offset);
+}
+
+void java_lang_invoke_CountingMethodHandle::set_vmcount(oop mh, int count) {
+  assert(is_instance(mh), "CMH only");
+  mh->int_field_put(_vmcount_offset, count);
+}
+
 oop java_lang_invoke_MethodHandle::type(oop mh) {
   return mh->obj_field(_type_offset);
 }
@@ -2379,31 +2419,9 @@
   mh->obj_field_put(_type_offset, mtype);
 }
 
-int java_lang_invoke_MethodHandle::vmslots(oop mh) {
-  int vmslots_offset = _vmslots_offset;
-  if (vmslots_offset != 0) {
-#ifdef ASSERT
-    int x = mh->int_field(vmslots_offset);
-    int y = compute_vmslots(mh);
-    assert(x == y, "correct hoisted value");
-#endif
-    return mh->int_field(vmslots_offset);
-  } else {
-    return compute_vmslots(mh);
-  }
-}
-
-// if MH.vmslots exists, hoist into it the value of type.form.vmslots
-void java_lang_invoke_MethodHandle::init_vmslots(oop mh) {
-  int vmslots_offset = _vmslots_offset;
-  if (vmslots_offset != 0) {
-    mh->int_field_put(vmslots_offset, compute_vmslots(mh));
-  }
-}
-
 // fetch type.form.vmslots, which is the number of JVM stack slots
 // required to carry the arguments of this MH
-int java_lang_invoke_MethodHandle::compute_vmslots(oop mh) {
+int java_lang_invoke_MethodHandle::vmslots(oop mh) {
   oop mtype = type(mh);
   if (mtype == NULL)  return 0;  // Java code would get NPE
   oop form = java_lang_invoke_MethodType::form(mtype);
@@ -2623,6 +2641,7 @@
     compute_optional_offset(_erasedType_offset, k, vmSymbols::erasedType_name(), vmSymbols::java_lang_invoke_MethodType_signature(), true);
     compute_optional_offset(_genericInvoker_offset, k, vmSymbols::genericInvoker_name(), vmSymbols::java_lang_invoke_MethodHandle_signature(), true);
     if (_genericInvoker_offset == 0)  _genericInvoker_offset = -1;  // set to explicit "empty" value
+    METHODTYPEFORM_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
   }
 }
 
@@ -2674,14 +2693,17 @@
   if (k != NULL) {
     compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_lang_invoke_MethodHandle_signature());
   }
-}
-
-oop java_lang_invoke_CallSite::target(oop site) {
-  return site->obj_field(_target_offset);
-}
-
-void java_lang_invoke_CallSite::set_target(oop site, oop target) {
-  site->obj_field_put(_target_offset, target);
+
+  // Disallow compilation of CallSite.setTargetNormal and CallSite.setTargetVolatile
+  // (For C2:  keep this until we have throttling logic for uncommon traps.)
+  if (k != NULL) {
+    instanceKlass* ik = instanceKlass::cast(k);
+    methodOop m_normal   = ik->lookup_method(vmSymbols::setTargetNormal_name(),   vmSymbols::setTarget_signature());
+    methodOop m_volatile = ik->lookup_method(vmSymbols::setTargetVolatile_name(), vmSymbols::setTarget_signature());
+    guarantee(m_normal != NULL && m_volatile != NULL, "must exist");
+    m_normal->set_not_compilable_quietly();
+    m_volatile->set_not_compilable_quietly();
+  }
 }
 
 
@@ -2728,6 +2750,18 @@
 
 
 // Support for java_lang_ClassLoader
+bool java_lang_ClassLoader::offsets_computed = false;
+int  java_lang_ClassLoader::parallelCapable_offset = -1;
+
+void java_lang_ClassLoader::compute_offsets() {
+  assert(!offsets_computed, "offsets should be initialized only once");
+  offsets_computed = true;
+
+  // The field indicating parallelCapable (parallelLockMap) is only present starting in 7,
+  klassOop k1 = SystemDictionary::ClassLoader_klass();
+  compute_optional_offset(parallelCapable_offset,
+    k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature());
+}
 
 oop java_lang_ClassLoader::parent(oop loader) {
   assert(loader->is_oop(), "loader must be oop");
@@ -2735,6 +2769,18 @@
 }
 
 
+// For class loader classes, parallelCapable defined
+// based on non-null field
+// Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it
+bool java_lang_ClassLoader::parallelCapable(oop class_loader) {
+  if (!JDK_Version::is_gte_jdk17x_version()
+     || parallelCapable_offset == -1) {
+     // Default for backward compatibility is false
+     return false;
+  }
+  return (class_loader->obj_field(parallelCapable_offset) != NULL);
+}
+
 bool java_lang_ClassLoader::is_trusted_loader(oop loader) {
   // Fix for 4474172; see evaluation for more details
   loader = non_reflection_class_loader(loader);
@@ -2784,12 +2830,11 @@
 int java_lang_String::offset_offset;
 int java_lang_String::count_offset;
 int java_lang_String::hash_offset;
-int java_lang_Class::klass_offset;
-int java_lang_Class::array_klass_offset;
-int java_lang_Class::resolved_constructor_offset;
-int java_lang_Class::number_of_fake_oop_fields;
-int java_lang_Class::oop_size_offset;
-int java_lang_Class::static_oop_field_count_offset;
+int java_lang_Class::_klass_offset;
+int java_lang_Class::_array_klass_offset;
+int java_lang_Class::_resolved_constructor_offset;
+int java_lang_Class::_oop_size_offset;
+int java_lang_Class::_static_oop_field_count_offset;
 int java_lang_Throwable::backtrace_offset;
 int java_lang_Throwable::detailMessage_offset;
 int java_lang_Throwable::cause_offset;
@@ -2902,20 +2947,20 @@
 
 
 void java_nio_Buffer::compute_offsets() {
-  klassOop k = SystemDictionary::java_nio_Buffer_klass();
+  klassOop k = SystemDictionary::nio_Buffer_klass();
   assert(k != NULL, "must be loaded in 1.4+");
   compute_offset(_limit_offset, k, vmSymbols::limit_name(), vmSymbols::int_signature());
 }
 
 // Support for intrinsification of sun.misc.AtomicLongCSImpl.attemptUpdate
 int sun_misc_AtomicLongCSImpl::value_offset() {
-  assert(SystemDictionary::sun_misc_AtomicLongCSImpl_klass() != NULL, "can't call this");
+  assert(SystemDictionary::AtomicLongCSImpl_klass() != NULL, "can't call this");
   return _value_offset;
 }
 
 
 void sun_misc_AtomicLongCSImpl::compute_offsets() {
-  klassOop k = SystemDictionary::sun_misc_AtomicLongCSImpl_klass();
+  klassOop k = SystemDictionary::AtomicLongCSImpl_klass();
   // If this class is not present, its value field offset won't be referenced.
   if (k != NULL) {
     compute_offset(_value_offset, k, vmSymbols::value_name(), vmSymbols::long_signature());
@@ -2950,23 +2995,6 @@
   java_lang_String::count_offset  = java_lang_String::offset_offset + sizeof (jint);
   java_lang_String::hash_offset   = java_lang_String::count_offset + sizeof (jint);
 
-  {
-    // Do the Class Class
-    int offset = header;
-    java_lang_Class::oop_size_offset = header;
-    offset += BytesPerInt;
-    java_lang_Class::static_oop_field_count_offset = offset;
-    offset = align_size_up(offset + BytesPerInt, x);
-    java_lang_Class::klass_offset = offset;
-    offset += x;
-    java_lang_Class::array_klass_offset = offset;
-    offset += x;
-    java_lang_Class::resolved_constructor_offset = offset;
-  }
-
-  // This is NOT an offset
-  java_lang_Class::number_of_fake_oop_fields = java_lang_Class::hc_number_of_fake_oop_fields;
-
   // Throwable Class
   java_lang_Throwable::backtrace_offset  = java_lang_Throwable::hc_backtrace_offset  * x + header;
   java_lang_Throwable::detailMessage_offset = java_lang_Throwable::hc_detailMessage_offset * x + header;
@@ -3018,8 +3046,8 @@
 
 // Compute non-hard-coded field offsets of all the classes in this file
 void JavaClasses::compute_offsets() {
-
-  java_lang_Class::compute_offsets();
+  // java_lang_Class::compute_offsets was called earlier in bootstrap
+  java_lang_ClassLoader::compute_offsets();
   java_lang_Thread::compute_offsets();
   java_lang_ThreadGroup::compute_offsets();
   if (EnableInvokeDynamic) {
@@ -3031,6 +3059,7 @@
     java_lang_invoke_MethodType::compute_offsets();
     java_lang_invoke_MethodTypeForm::compute_offsets();
     java_lang_invoke_CallSite::compute_offsets();
+    java_lang_invoke_CountingMethodHandle::compute_offsets();
   }
   java_security_AccessControlContext::compute_offsets();
   // Initialize reflection classes. The layouts of these classes
@@ -3243,6 +3272,23 @@
 
 #endif // PRODUCT
 
+int InjectedField::compute_offset() {
+  klassOop klass_oop = klass();
+  for (AllFieldStream fs(instanceKlass::cast(klass_oop)); !fs.done(); fs.next()) {
+    if (!may_be_java && !fs.access_flags().is_internal()) {
+      // Only look at injected fields
+      continue;
+    }
+    if (fs.name() == name() && fs.signature() == signature()) {
+      return fs.offset();
+    }
+  }
+  ResourceMark rm;
+  tty->print_cr("Invalid layout of %s at %s", instanceKlass::cast(klass_oop)->external_name(), name()->as_C_string());
+  fatal("Invalid layout of preloaded class");
+  return -1;
+}
+
 void javaClasses_init() {
   JavaClasses::compute_offsets();
   JavaClasses::check_offsets();
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -156,36 +156,39 @@
 
 // Interface to java.lang.Class objects
 
+#define CLASS_INJECTED_FIELDS(macro)                                       \
+  macro(java_lang_Class, klass,                  object_signature,  false) \
+  macro(java_lang_Class, resolved_constructor,   object_signature,  false) \
+  macro(java_lang_Class, array_klass,            object_signature,  false) \
+  macro(java_lang_Class, oop_size,               int_signature,     false) \
+  macro(java_lang_Class, static_oop_field_count, int_signature,     false)
+
 class java_lang_Class : AllStatic {
-   friend class VMStructs;
+  friend class VMStructs;
+
  private:
   // The fake offsets are added by the class loader when java.lang.Class is loaded
 
-  enum {
-    hc_number_of_fake_oop_fields   = 3,
-    hc_number_of_fake_int_fields   = 2
-  };
+  static int _klass_offset;
+  static int _resolved_constructor_offset;
+  static int _array_klass_offset;
 
-  static int klass_offset;
-  static int resolved_constructor_offset;
-  static int array_klass_offset;
-  static int number_of_fake_oop_fields;
+  static int _oop_size_offset;
+  static int _static_oop_field_count_offset;
 
-  static int oop_size_offset;
-  static int static_oop_field_count_offset;
-
-  static void compute_offsets();
   static bool offsets_computed;
   static int classRedefinedCount_offset;
-  static int parallelCapable_offset;
 
  public:
+  static void compute_offsets();
+
   // Instance creation
   static oop  create_mirror(KlassHandle k, TRAPS);
   static void fixup_mirror(KlassHandle k, TRAPS);
   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
   // Conversion
   static klassOop as_klassOop(oop java_class);
+  static void set_klass(oop java_class, klassOop klass);
   static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL);
   static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) {
     klassOop refk_oop = NULL;
@@ -209,14 +212,12 @@
   static klassOop array_klass(oop java_class);
   static void set_array_klass(oop java_class, klassOop klass);
   // compiler support for class operations
-  static int klass_offset_in_bytes() { return klass_offset; }
-  static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; }
-  static int array_klass_offset_in_bytes() { return array_klass_offset; }
+  static int klass_offset_in_bytes()                { return _klass_offset; }
+  static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; }
+  static int array_klass_offset_in_bytes()          { return _array_klass_offset; }
   // Support for classRedefinedCount field
   static int classRedefinedCount(oop the_class_mirror);
   static void set_classRedefinedCount(oop the_class_mirror, int value);
-  // Support for parallelCapable field
-  static bool parallelCapable(oop the_class_mirror);
 
   static int oop_size(oop java_class);
   static void set_oop_size(oop java_class, int size);
@@ -771,7 +772,7 @@
     ref->obj_field_put(referent_offset, value);
   }
   static void set_referent_raw(oop ref, oop value) {
-    ref->obj_field_raw_put(referent_offset, value);
+    ref->obj_field_put_raw(referent_offset, value);
   }
   static HeapWord* referent_addr(oop ref) {
     return ref->obj_field_addr<HeapWord>(referent_offset);
@@ -783,7 +784,7 @@
     ref->obj_field_put(next_offset, value);
   }
   static void set_next_raw(oop ref, oop value) {
-    ref->obj_field_raw_put(next_offset, value);
+    ref->obj_field_put_raw(next_offset, value);
   }
   static HeapWord* next_addr(oop ref) {
     return ref->obj_field_addr<HeapWord>(next_offset);
@@ -795,7 +796,7 @@
     ref->obj_field_put(discovered_offset, value);
   }
   static void set_discovered_raw(oop ref, oop value) {
-    ref->obj_field_raw_put(discovered_offset, value);
+    ref->obj_field_put_raw(discovered_offset, value);
   }
   static HeapWord* discovered_addr(oop ref) {
     return ref->obj_field_addr<HeapWord>(discovered_offset);
@@ -834,16 +835,19 @@
 
 // Interface to java.lang.invoke.MethodHandle objects
 
+#define METHODHANDLE_INJECTED_FIELDS(macro)                               \
+  macro(java_lang_invoke_MethodHandle, vmentry,  intptr_signature, false) \
+  macro(java_lang_invoke_MethodHandle, vmtarget, object_signature, true)
+
 class MethodHandleEntry;
 
 class java_lang_invoke_MethodHandle: AllStatic {
   friend class JavaClasses;
 
  private:
-  static int _vmentry_offset;           // assembly code trampoline for MH
-  static int _vmtarget_offset;          // class-specific target reference
+  static int _vmentry_offset;            // assembly code trampoline for MH
+  static int _vmtarget_offset;           // class-specific target reference
   static int _type_offset;              // the MethodType of this MH
-  static int _vmslots_offset;           // OPTIONAL hoisted type.form.vmslots
 
   static void compute_offsets();
 
@@ -859,8 +863,6 @@
   static void       set_vmentry(oop mh, MethodHandleEntry* data);
 
   static int            vmslots(oop mh);
-  static void      init_vmslots(oop mh);
-  static int    compute_vmslots(oop mh);
 
   // Testers
   static bool is_subclass(klassOop klass) {
@@ -874,14 +876,15 @@
   static int type_offset_in_bytes()             { return _type_offset; }
   static int vmtarget_offset_in_bytes()         { return _vmtarget_offset; }
   static int vmentry_offset_in_bytes()          { return _vmentry_offset; }
-  static int vmslots_offset_in_bytes()          { return _vmslots_offset; }
 };
 
+#define DIRECTMETHODHANDLE_INJECTED_FIELDS(macro)                          \
+  macro(java_lang_invoke_DirectMethodHandle, vmindex, int_signature, true)
+
 class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle {
   friend class JavaClasses;
 
  private:
-  //         _vmtarget_offset;          // method   or class      or interface
   static int _vmindex_offset;           // negative or vtable idx or itable idx
   static void compute_offsets();
 
@@ -981,9 +984,40 @@
 };
 
 
+// A simple class that maintains an invocation count
+class java_lang_invoke_CountingMethodHandle: public java_lang_invoke_MethodHandle {
+  friend class JavaClasses;
+
+ private:
+  static int _vmcount_offset;
+  static void compute_offsets();
+
+ public:
+  // Accessors
+  static int            vmcount(oop mh);
+  static void       set_vmcount(oop mh, int count);
+
+  // Testers
+  static bool is_subclass(klassOop klass) {
+    return SystemDictionary::CountingMethodHandle_klass() != NULL &&
+      Klass::cast(klass)->is_subclass_of(SystemDictionary::CountingMethodHandle_klass());
+  }
+  static bool is_instance(oop obj) {
+    return obj != NULL && is_subclass(obj->klass());
+  }
+
+  // Accessors for code generation:
+  static int vmcount_offset_in_bytes()          { return _vmcount_offset; }
+};
+
+
+
 // Interface to java.lang.invoke.MemberName objects
 // (These are a private interface for Java code to query the class hierarchy.)
 
+#define MEMBERNAME_INJECTED_FIELDS(macro)                              \
+  macro(java_lang_invoke_MemberName, vmtarget, object_signature, true)
+
 class java_lang_invoke_MemberName: AllStatic {
   friend class JavaClasses;
 
@@ -1093,6 +1127,10 @@
   static int form_offset_in_bytes()             { return _form_offset; }
 };
 
+#define METHODTYPEFORM_INJECTED_FIELDS(macro)                              \
+  macro(java_lang_invoke_MethodTypeForm, vmslots,  int_signature,    true) \
+  macro(java_lang_invoke_MethodTypeForm, vmlayout, object_signature, true)
+
 class java_lang_invoke_MethodTypeForm: AllStatic {
   friend class JavaClasses;
 
@@ -1107,6 +1145,8 @@
  public:
   // Accessors
   static int            vmslots(oop mtform);
+  static void       set_vmslots(oop mtform, int vmslots);
+
   static oop            erasedType(oop mtform);
   static oop            genericInvoker(oop mtform);
 
@@ -1128,21 +1168,16 @@
 
 private:
   static int _target_offset;
-  static int _caller_method_offset;
-  static int _caller_bci_offset;
 
   static void compute_offsets();
 
 public:
   // Accessors
-  static oop            target(oop site);
-  static void       set_target(oop site, oop target);
+  static oop              target(         oop site)             { return site->obj_field(             _target_offset);         }
+  static void         set_target(         oop site, oop target) {        site->obj_field_put(         _target_offset, target); }
 
-  static oop            caller_method(oop site);
-  static void       set_caller_method(oop site, oop ref);
-
-  static jint           caller_bci(oop site);
-  static void       set_caller_bci(oop site, jint bci);
+  static volatile oop     target_volatile(oop site)             { return site->obj_field_volatile(    _target_offset);         }
+  static void         set_target_volatile(oop site, oop target) {        site->obj_field_put_volatile(_target_offset, target); }
 
   // Testers
   static bool is_subclass(klassOop klass) {
@@ -1154,8 +1189,6 @@
 
   // Accessors for code generation:
   static int target_offset_in_bytes()           { return _target_offset; }
-  static int caller_method_offset_in_bytes()    { return _caller_method_offset; }
-  static int caller_bci_offset_in_bytes()       { return _caller_bci_offset; }
 };
 
 
@@ -1186,11 +1219,18 @@
    hc_parent_offset = 0
   };
 
+  static bool offsets_computed;
   static int parent_offset;
+  static int parallelCapable_offset;
+
+  static void compute_offsets();
 
  public:
   static oop parent(oop loader);
 
+  // Support for parallelCapable field
+  static bool parallelCapable(oop the_class_mirror);
+
   static bool is_trusted_loader(oop loader);
 
   // Fix for 4474172
@@ -1312,17 +1352,71 @@
   static oop  get_owner_threadObj(oop obj);
 };
 
+// Use to declare fields that need to be injected into Java classes
+// for the JVM to use.  The name_index and signature_index are
+// declared in vmSymbols.  The may_be_java flag is used to declare
+// fields that might already exist in Java but should be injected if
+// they don't.  Otherwise the field is unconditionally injected and
+// the JVM uses the injected one.  This is to ensure that name
+// collisions don't occur.  In general may_be_java should be false
+// unless there's a good reason.
+
+class InjectedField {
+ public:
+  const SystemDictionary::WKID klass_id;
+  const vmSymbols::SID name_index;
+  const vmSymbols::SID signature_index;
+  const bool           may_be_java;
+
+
+  klassOop klass() const    { return SystemDictionary::well_known_klass(klass_id); }
+  Symbol* name() const      { return lookup_symbol(name_index); }
+  Symbol* signature() const { return lookup_symbol(signature_index); }
+
+  int compute_offset();
+
+  // Find the Symbol for this index
+  static Symbol* lookup_symbol(int symbol_index) {
+    return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
+  }
+};
+
+#define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \
+  klass##_##name##_enum,
+
+#define ALL_INJECTED_FIELDS(macro)          \
+  CLASS_INJECTED_FIELDS(macro)              \
+  METHODHANDLE_INJECTED_FIELDS(macro)       \
+  DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \
+  MEMBERNAME_INJECTED_FIELDS(macro)         \
+  METHODTYPEFORM_INJECTED_FIELDS(macro)
+
 // Interface to hard-coded offset checking
 
 class JavaClasses : AllStatic {
  private:
+
+  static InjectedField _injected_fields[];
+
   static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
   static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
   static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
+
  public:
+  enum InjectedFieldID {
+    ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM)
+    MAX_enum
+  };
+
+  static int compute_injected_offset(InjectedFieldID id);
+
   static void compute_hard_coded_offsets();
   static void compute_offsets();
   static void check_offsets() PRODUCT_RETURN;
+
+  static InjectedField* get_injected(Symbol* class_name, int* field_count);
 };
 
+#undef DECLARE_INJECTED_FIELD_ENUM
+
 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -125,13 +125,13 @@
 bool SystemDictionary::is_parallelCapable(Handle class_loader) {
   if (UnsyncloadClass || class_loader.is_null()) return true;
   if (AlwaysLockClassLoader) return false;
-  return java_lang_Class::parallelCapable(class_loader());
+  return java_lang_ClassLoader::parallelCapable(class_loader());
 }
 // ----------------------------------------------------------------------------
 // ParallelDefineClass flag does not apply to bootclass loader
 bool SystemDictionary::is_parallelDefine(Handle class_loader) {
    if (class_loader.is_null()) return false;
-   if (AllowParallelDefineClass && java_lang_Class::parallelCapable(class_loader())) {
+   if (AllowParallelDefineClass && java_lang_ClassLoader::parallelCapable(class_loader())) {
      return true;
    }
    return false;
@@ -1290,7 +1290,7 @@
                                                     Symbol* class_name,
                                                     TRAPS) {
 
-  klassOop dlm = SystemDictionary::sun_jkernel_DownloadManager_klass();
+  klassOop dlm = SystemDictionary::DownloadManager_klass();
   instanceKlassHandle nk;
 
   // If download manager class isn't loaded just return.
@@ -1953,7 +1953,7 @@
   // first do Object, String, Class
   initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
 
-  debug_only(instanceKlass::verify_class_klass_nonstatic_oop_maps(WK_KLASS(Class_klass)));
+  java_lang_Class::compute_offsets();
 
   // Fixup mirrors for classes loaded before java.lang.Class.
   // These calls iterate over the objects currently in the perm gen
@@ -2001,7 +2001,7 @@
   //_box_klasses[T_ARRAY]   = WK_KLASS(object_klass);
 
 #ifdef KERNEL
-  if (sun_jkernel_DownloadManager_klass() == NULL) {
+  if (DownloadManager_klass() == NULL) {
     warning("Cannot find sun/jkernel/DownloadManager");
   }
 #endif // KERNEL
@@ -2736,7 +2736,7 @@
       class_size += ik->local_interfaces()->size();
       class_size += ik->transitive_interfaces()->size();
       // We do not have to count implementors, since we only store one!
-      class_size += ik->fields()->size();
+      class_size += ik->all_fields_count() * FieldInfo::field_slots;
     }
   }
 
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -133,15 +133,15 @@
   template(reflect_Method_klass,         java_lang_reflect_Method,       Pre) \
   template(reflect_Constructor_klass,    java_lang_reflect_Constructor,  Pre) \
                                                                               \
-  /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
-  /* Universe::is_gte_jdk14x_version() is not set up by this point. */        \
-  /* It's okay if this turns out to be NULL in non-1.4 JDKs. */               \
-  template(reflect_MagicAccessorImpl_klass,          sun_reflect_MagicAccessorImpl,  Opt) \
-  template(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \
-  template(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \
-  template(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt) \
-  template(reflect_ConstantPool_klass,  sun_reflect_ConstantPool,       Opt_Only_JDK15) \
-  template(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15) \
+  /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */                              \
+  /* Universe::is_gte_jdk14x_version() is not set up by this point. */                                                   \
+  /* It's okay if this turns out to be NULL in non-1.4 JDKs. */                                                          \
+  template(reflect_MagicAccessorImpl_klass,             sun_reflect_MagicAccessorImpl,             Opt)                  \
+  template(reflect_MethodAccessorImpl_klass,            sun_reflect_MethodAccessorImpl,            Opt_Only_JDK14NewRef) \
+  template(reflect_ConstructorAccessorImpl_klass,       sun_reflect_ConstructorAccessorImpl,       Opt_Only_JDK14NewRef) \
+  template(reflect_DelegatingClassLoader_klass,         sun_reflect_DelegatingClassLoader,         Opt)                  \
+  template(reflect_ConstantPool_klass,                  sun_reflect_ConstantPool,                  Opt_Only_JDK15)       \
+  template(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15)       \
                                                                               \
   /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
   template(MethodHandle_klass,             java_lang_invoke_MethodHandle,             Pre_JSR292) \
@@ -155,6 +155,7 @@
   template(BootstrapMethodError_klass,     java_lang_BootstrapMethodError,            Pre_JSR292) \
   template(WrongMethodTypeException_klass, java_lang_invoke_WrongMethodTypeException, Pre_JSR292) \
   template(CallSite_klass,                 java_lang_invoke_CallSite,                 Pre_JSR292) \
+  template(CountingMethodHandle_klass,     java_lang_invoke_CountingMethodHandle,     Opt)        \
   template(ConstantCallSite_klass,         java_lang_invoke_ConstantCallSite,         Pre_JSR292) \
   template(MutableCallSite_klass,          java_lang_invoke_MutableCallSite,          Pre_JSR292) \
   template(VolatileCallSite_klass,         java_lang_invoke_VolatileCallSite,         Pre_JSR292) \
@@ -167,14 +168,14 @@
   template(StackTraceElement_klass,      java_lang_StackTraceElement,    Opt) \
   /* Universe::is_gte_jdk14x_version() is not set up by this point. */        \
   /* It's okay if this turns out to be NULL in non-1.4 JDKs. */               \
-  template(java_nio_Buffer_klass,        java_nio_Buffer,                Opt) \
+  template(nio_Buffer_klass,             java_nio_Buffer,                Opt) \
                                                                               \
   /* If this class isn't present, it won't be referenced. */                  \
-  template(sun_misc_AtomicLongCSImpl_klass, sun_misc_AtomicLongCSImpl,   Opt) \
+  template(AtomicLongCSImpl_klass,       sun_misc_AtomicLongCSImpl,   Opt)    \
                                                                               \
-  template(sun_jkernel_DownloadManager_klass, sun_jkernel_DownloadManager, Opt_Kernel) \
+  template(DownloadManager_klass,        sun_jkernel_DownloadManager, Opt_Kernel) \
                                                                               \
-  template(sun_misc_PostVMInitHook_klass, sun_misc_PostVMInitHook, Opt)       \
+  template(PostVMInitHook_klass,         sun_misc_PostVMInitHook, Opt)        \
                                                                               \
   /* Preload boxing klasses */                                                \
   template(Boolean_klass,                java_lang_Boolean,              Pre) \
@@ -198,7 +199,7 @@
   enum WKID {
     NO_WKID = 0,
 
-    #define WK_KLASS_ENUM(name, ignore_s, ignore_o) WK_KLASS_ENUM_NAME(name),
+    #define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
     WK_KLASSES_DO(WK_KLASS_ENUM)
     #undef WK_KLASS_ENUM
 
@@ -425,11 +426,16 @@
   }
 
 public:
-  #define WK_KLASS_DECLARE(name, ignore_symbol, option) \
+  #define WK_KLASS_DECLARE(name, symbol, option) \
     static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); }
   WK_KLASSES_DO(WK_KLASS_DECLARE);
   #undef WK_KLASS_DECLARE
 
+  static klassOop well_known_klass(WKID id) {
+    assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
+    return _well_known_klasses[id];
+  }
+
   // Local definition for direct access to the private array:
   #define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
 
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -218,6 +218,7 @@
   template(returnType_name,                           "returnType")                               \
   template(signature_name,                            "signature")                                \
   template(slot_name,                                 "slot")                                     \
+  template(selectAlternative_name,                    "selectAlternative")                        \
                                                                                                   \
   /* Support for annotations (JDK 1.5 and above) */                                               \
                                                                                                   \
@@ -246,9 +247,11 @@
   template(java_lang_invoke_MethodTypeForm_signature, "Ljava/lang/invoke/MethodTypeForm;")        \
   template(java_lang_invoke_MemberName,               "java/lang/invoke/MemberName")              \
   template(java_lang_invoke_MethodHandleNatives,      "java/lang/invoke/MethodHandleNatives")     \
+  template(java_lang_invoke_MethodHandleImpl,         "java/lang/invoke/MethodHandleImpl")        \
   template(java_lang_invoke_AdapterMethodHandle,      "java/lang/invoke/AdapterMethodHandle")     \
   template(java_lang_invoke_BoundMethodHandle,        "java/lang/invoke/BoundMethodHandle")       \
   template(java_lang_invoke_DirectMethodHandle,       "java/lang/invoke/DirectMethodHandle")      \
+  template(java_lang_invoke_CountingMethodHandle,     "java/lang/invoke/CountingMethodHandle")    \
   /* internal up-calls made only by the JVM, via class sun.invoke.MethodHandleNatives: */         \
   template(findMethodHandleType_name,                 "findMethodHandleType")                     \
   template(findMethodHandleType_signature,       "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/invoke/MethodType;") \
@@ -258,8 +261,12 @@
   template(linkMethodHandleConstant_signature, "(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/invoke/MethodHandle;") \
   template(makeDynamicCallSite_name,                  "makeDynamicCallSite")                      \
   template(makeDynamicCallSite_signature, "(Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Object;Ljava/lang/invoke/MemberName;I)Ljava/lang/invoke/CallSite;") \
-  NOT_LP64(  do_alias(machine_word_signature,         int_signature)  )                           \
-  LP64_ONLY( do_alias(machine_word_signature,         long_signature) )                           \
+  template(setTargetNormal_name,                      "setTargetNormal")                          \
+  template(setTargetVolatile_name,                    "setTargetVolatile")                        \
+  template(setTarget_signature,                       "(Ljava/lang/invoke/MethodHandle;)V")       \
+  NOT_LP64(  do_alias(intptr_signature,               int_signature)  )                           \
+  LP64_ONLY( do_alias(intptr_signature,               long_signature) )                           \
+  template(selectAlternative_signature, "(ZLjava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodHandle;)Ljava/lang/invoke/MethodHandle;") \
                                                                                                   \
   /* common method and field names */                                                             \
   template(object_initializer_name,                   "<init>")                                   \
@@ -344,6 +351,7 @@
   template(vmmethod_name,                             "vmmethod")                                 \
   template(vmtarget_name,                             "vmtarget")                                 \
   template(vmentry_name,                              "vmentry")                                  \
+  template(vmcount_name,                              "vmcount")                                  \
   template(vmslots_name,                              "vmslots")                                  \
   template(vmlayout_name,                             "vmlayout")                                 \
   template(vmindex_name,                              "vmindex")                                  \
@@ -357,6 +365,11 @@
   template(erasedType_name,                           "erasedType")                               \
   template(genericInvoker_name,                       "genericInvoker")                           \
   template(append_name,                               "append")                                   \
+  template(klass_name,                                "klass")                                    \
+  template(resolved_constructor_name,                 "resolved_constructor")                     \
+  template(array_klass_name,                          "array_klass")                              \
+  template(oop_size_name,                             "oop_size")                                 \
+  template(static_oop_field_count_name,               "static_oop_field_count")                   \
                                                                                                   \
   /* non-intrinsic name/signature pairs: */                                                       \
   template(register_method_name,                      "register")                                 \
@@ -907,6 +920,8 @@
   do_intrinsic(_invokeVarargs,            java_lang_invoke_MethodHandle, invokeVarargs_name, object_array_object_signature, F_R)  \
   do_intrinsic(_invokeDynamic,            java_lang_invoke_InvokeDynamic, star_name,         object_array_object_signature, F_SN) \
                                                                                                                         \
+  do_intrinsic(_selectAlternative,        java_lang_invoke_MethodHandleImpl, selectAlternative_name, selectAlternative_signature, F_S)  \
+                                                                                                                        \
   /* unboxing methods: */                                                                                               \
   do_intrinsic(_booleanValue,             java_lang_Boolean,      booleanValue_name, void_boolean_signature, F_R)       \
    do_name(     booleanValue_name,       "booleanValue")                                                                \
@@ -952,7 +967,8 @@
 // Class vmSymbols
 
 class vmSymbols: AllStatic {
- friend class vmIntrinsics;
+  friend class vmIntrinsics;
+  friend class VMStructs;
  public:
   // enum for figuring positions and size of array holding Symbol*s
   enum SID {
--- a/hotspot/src/share/vm/code/dependencies.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/code/dependencies.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -113,9 +113,9 @@
   assert_common_1(no_finalizable_subclasses, ctxk);
 }
 
-void Dependencies::assert_call_site_target_value(ciKlass* ctxk, ciCallSite* call_site, ciMethodHandle* method_handle) {
-  check_ctxk(ctxk);
-  assert_common_3(call_site_target_value, ctxk, call_site, method_handle);
+void Dependencies::assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle) {
+  check_ctxk(call_site->klass());
+  assert_common_2(call_site_target_value, call_site, method_handle);
 }
 
 // Helper function.  If we are adding a new dep. under ctxk2,
@@ -135,7 +135,7 @@
   }
 }
 
-void Dependencies::assert_common_1(Dependencies::DepType dept, ciObject* x) {
+void Dependencies::assert_common_1(DepType dept, ciObject* x) {
   assert(dep_args(dept) == 1, "sanity");
   log_dependency(dept, x);
   GrowableArray<ciObject*>* deps = _deps[dept];
@@ -148,21 +148,37 @@
   }
 }
 
-void Dependencies::assert_common_2(Dependencies::DepType dept,
-                                   ciKlass* ctxk, ciObject* x) {
-  assert(dep_context_arg(dept) == 0, "sanity");
+void Dependencies::assert_common_2(DepType dept,
+                                   ciObject* x0, ciObject* x1) {
   assert(dep_args(dept) == 2, "sanity");
-  log_dependency(dept, ctxk, x);
+  log_dependency(dept, x0, x1);
   GrowableArray<ciObject*>* deps = _deps[dept];
 
   // see if the same (or a similar) dep is already recorded
-  if (note_dep_seen(dept, x)) {
-    // look in this bucket for redundant assertions
-    const int stride = 2;
-    for (int i = deps->length(); (i -= stride) >= 0; ) {
-      ciObject* x1 = deps->at(i+1);
-      if (x == x1) {  // same subject; check the context
-        if (maybe_merge_ctxk(deps, i+0, ctxk)) {
+  bool has_ctxk = has_explicit_context_arg(dept);
+  if (has_ctxk) {
+    assert(dep_context_arg(dept) == 0, "sanity");
+    if (note_dep_seen(dept, x1)) {
+      // look in this bucket for redundant assertions
+      const int stride = 2;
+      for (int i = deps->length(); (i -= stride) >= 0; ) {
+        ciObject* y1 = deps->at(i+1);
+        if (x1 == y1) {  // same subject; check the context
+          if (maybe_merge_ctxk(deps, i+0, x0->as_klass())) {
+            return;
+          }
+        }
+      }
+    }
+  } else {
+    assert(dep_implicit_context_arg(dept) == 0, "sanity");
+    if (note_dep_seen(dept, x0) && note_dep_seen(dept, x1)) {
+      // look in this bucket for redundant assertions
+      const int stride = 2;
+      for (int i = deps->length(); (i -= stride) >= 0; ) {
+        ciObject* y0 = deps->at(i+0);
+        ciObject* y1 = deps->at(i+1);
+        if (x0 == y0 && x1 == y1) {
           return;
         }
       }
@@ -170,11 +186,11 @@
   }
 
   // append the assertion in the correct bucket:
-  deps->append(ctxk);
-  deps->append(x);
+  deps->append(x0);
+  deps->append(x1);
 }
 
-void Dependencies::assert_common_3(Dependencies::DepType dept,
+void Dependencies::assert_common_3(DepType dept,
                                    ciKlass* ctxk, ciObject* x, ciObject* x2) {
   assert(dep_context_arg(dept) == 0, "sanity");
   assert(dep_args(dept) == 3, "sanity");
@@ -361,7 +377,7 @@
   3, // unique_concrete_subtypes_2 ctxk, k1, k2
   3, // unique_concrete_methods_2 ctxk, m1, m2
   1, // no_finalizable_subclasses ctxk
-  3  // call_site_target_value ctxk, call_site, method_handle
+  2  // call_site_target_value call_site, method_handle
 };
 
 const char* Dependencies::dep_name(Dependencies::DepType dept) {
@@ -375,10 +391,7 @@
 }
 
 void Dependencies::check_valid_dependency_type(DepType dept) {
-  for (int deptv = (int) FIRST_TYPE; deptv < (int) TYPE_LIMIT; deptv++) {
-    if (dept == ((DepType) deptv))  return;
-  }
-  ShouldNotReachHere();
+  guarantee(FIRST_TYPE <= dept && dept < TYPE_LIMIT, err_msg("invalid dependency type: %d", (int) dept));
 }
 
 // for the sake of the compiler log, print out current dependencies:
@@ -586,8 +599,7 @@
     code_byte -= ctxk_bit;
     DepType dept = (DepType)code_byte;
     _type = dept;
-    guarantee((dept - FIRST_TYPE) < (TYPE_LIMIT - FIRST_TYPE),
-              "bad dependency type tag");
+    Dependencies::check_valid_dependency_type(dept);
     int stride = _dep_args[dept];
     assert(stride == dep_args(dept), "sanity");
     int skipj = -1;
@@ -615,18 +627,35 @@
 
 klassOop Dependencies::DepStream::context_type() {
   assert(must_be_in_vm(), "raw oops here");
-  int ctxkj = dep_context_arg(_type);  // -1 if no context arg
-  if (ctxkj < 0) {
-    return NULL;           // for example, evol_method
-  } else {
-    oop k = recorded_oop_at(_xi[ctxkj]);
-    if (k != NULL) {       // context type was not compressed away
+
+  // Most dependencies have an explicit context type argument.
+  {
+    int ctxkj = dep_context_arg(_type);  // -1 if no explicit context arg
+    if (ctxkj >= 0) {
+      oop k = argument(ctxkj);
+      if (k != NULL) {       // context type was not compressed away
+        assert(k->is_klass(), "type check");
+        return (klassOop) k;
+      }
+      // recompute "default" context type
+      return ctxk_encoded_as_null(_type, argument(ctxkj+1));
+    }
+  }
+
+  // Some dependencies are using the klass of the first object
+  // argument as implicit context type (e.g. call_site_target_value).
+  {
+    int ctxkj = dep_implicit_context_arg(_type);
+    if (ctxkj >= 0) {
+      oop k = argument(ctxkj)->klass();
       assert(k->is_klass(), "type check");
       return (klassOop) k;
-    } else {               // recompute "default" context type
-      return ctxk_encoded_as_null(_type, recorded_oop_at(_xi[ctxkj+1]));
     }
   }
+
+  // And some dependencies don't have a context type at all,
+  // e.g. evol_method.
+  return NULL;
 }
 
 /// Checking dependencies:
@@ -1409,21 +1438,20 @@
 }
 
 
-klassOop Dependencies::check_call_site_target_value(klassOop ctxk, oop call_site, oop method_handle, CallSiteDepChange* changes) {
+klassOop Dependencies::check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes) {
   assert(call_site    ->is_a(SystemDictionary::CallSite_klass()),     "sanity");
   assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "sanity");
   if (changes == NULL) {
     // Validate all CallSites
     if (java_lang_invoke_CallSite::target(call_site) != method_handle)
-      return ctxk;  // assertion failed
+      return call_site->klass();  // assertion failed
   } else {
     // Validate the given CallSite
     if (call_site == changes->call_site() && java_lang_invoke_CallSite::target(call_site) != changes->method_handle()) {
       assert(method_handle != changes->method_handle(), "must be");
-      return ctxk;  // assertion failed
+      return call_site->klass();  // assertion failed
     }
   }
-  assert(java_lang_invoke_CallSite::target(call_site) == method_handle, "should still be valid");
   return NULL;  // assertion still valid
 }
 
@@ -1488,7 +1516,7 @@
   klassOop witness = NULL;
   switch (type()) {
   case call_site_target_value:
-    witness = check_call_site_target_value(context_type(), argument(1), argument(2), changes);
+    witness = check_call_site_target_value(argument(0), argument(1), changes);
     break;
   default:
     witness = NULL;
--- a/hotspot/src/share/vm/code/dependencies.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/code/dependencies.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -166,9 +166,14 @@
     LG2_TYPE_LIMIT = 4,  // assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT))
 
     // handy categorizations of dependency types:
-    all_types      = ((1<<TYPE_LIMIT)-1) & ((-1)<<FIRST_TYPE),
-    non_ctxk_types = (1<<evol_method),
-    ctxk_types     = all_types & ~non_ctxk_types,
+    all_types           = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
+
+    non_klass_types     = (1 << call_site_target_value),
+    klass_types         = all_types & ~non_klass_types,
+
+    non_ctxk_types      = (1 << evol_method),
+    implicit_ctxk_types = (1 << call_site_target_value),
+    explicit_ctxk_types = all_types & ~(non_ctxk_types | implicit_ctxk_types),
 
     max_arg_count = 3,   // current maximum number of arguments (incl. ctxk)
 
@@ -184,9 +189,15 @@
 
   static const char* dep_name(DepType dept);
   static int         dep_args(DepType dept);
-  static int  dep_context_arg(DepType dept) {
-    return dept_in_mask(dept, ctxk_types)? 0: -1;
-  }
+
+  static bool is_klass_type(           DepType dept) { return dept_in_mask(dept, klass_types        ); }
+
+  static bool has_explicit_context_arg(DepType dept) { return dept_in_mask(dept, explicit_ctxk_types); }
+  static bool has_implicit_context_arg(DepType dept) { return dept_in_mask(dept, implicit_ctxk_types); }
+
+  static int           dep_context_arg(DepType dept) { return has_explicit_context_arg(dept) ? 0 : -1; }
+  static int  dep_implicit_context_arg(DepType dept) { return has_implicit_context_arg(dept) ? 0 : -1; }
+
   static void check_valid_dependency_type(DepType dept);
 
  private:
@@ -250,8 +261,8 @@
   }
 
   void assert_common_1(DepType dept, ciObject* x);
-  void assert_common_2(DepType dept, ciKlass* ctxk, ciObject* x);
-  void assert_common_3(DepType dept, ciKlass* ctxk, ciObject* x, ciObject* x2);
+  void assert_common_2(DepType dept, ciObject* x0, ciObject* x1);
+  void assert_common_3(DepType dept, ciKlass* ctxk, ciObject* x1, ciObject* x2);
 
  public:
   // Adding assertions to a new dependency set at compile time:
@@ -264,7 +275,7 @@
   void assert_abstract_with_exclusive_concrete_subtypes(ciKlass* ctxk, ciKlass* k1, ciKlass* k2);
   void assert_exclusive_concrete_methods(ciKlass* ctxk, ciMethod* m1, ciMethod* m2);
   void assert_has_no_finalizable_subclasses(ciKlass* ctxk);
-  void assert_call_site_target_value(ciKlass* ctxk, ciCallSite* call_site, ciMethodHandle* method_handle);
+  void assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle);
 
   // Define whether a given method or type is concrete.
   // These methods define the term "concrete" as used in this module.
@@ -318,7 +329,7 @@
   static klassOop check_exclusive_concrete_methods(klassOop ctxk, methodOop m1, methodOop m2,
                                                    KlassDepChange* changes = NULL);
   static klassOop check_has_no_finalizable_subclasses(klassOop ctxk, KlassDepChange* changes = NULL);
-  static klassOop check_call_site_target_value(klassOop ctxk, oop call_site, oop method_handle, CallSiteDepChange* changes = NULL);
+  static klassOop check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes = NULL);
   // A returned klassOop is NULL if the dependency assertion is still
   // valid.  A non-NULL klassOop is a 'witness' to the assertion
   // failure, a point in the class hierarchy where the assertion has
@@ -455,6 +466,8 @@
     oop argument(int i);         // => recorded_oop_at(argument_index(i))
     klassOop context_type();
 
+    bool is_klass_type()         { return Dependencies::is_klass_type(type()); }
+
     methodOop method_argument(int i) {
       oop x = argument(i);
       assert(x->is_method(), "type");
--- a/hotspot/src/share/vm/code/nmethod.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -50,6 +50,7 @@
 
 // Only bother with this argument setup if dtrace is available
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL8(hotspot, compiled__method__load,
   const char*, int, const char*, int, const char*, int, void*, size_t);
 
@@ -69,6 +70,21 @@
         signature->bytes(), signature->utf8_length());                    \
     }                                                                     \
   }
+#else /* USDT2 */
+#define DTRACE_METHOD_UNLOAD_PROBE(method)                                \
+  {                                                                       \
+    methodOop m = (method);                                               \
+    if (m != NULL) {                                                      \
+      Symbol* klass_name = m->klass_name();                               \
+      Symbol* name = m->name();                                           \
+      Symbol* signature = m->signature();                                 \
+      HOTSPOT_COMPILED_METHOD_UNLOAD(                                     \
+        (char *) klass_name->bytes(), klass_name->utf8_length(),                   \
+        (char *) name->bytes(), name->utf8_length(),                               \
+        (char *) signature->bytes(), signature->utf8_length());                    \
+    }                                                                     \
+  }
+#endif /* USDT2 */
 
 #else //  ndef DTRACE_ENABLED
 
@@ -451,7 +467,6 @@
   _stack_traversal_mark       = 0;
   _unload_reported            = false;           // jvmti state
 
-  NOT_PRODUCT(_has_debug_info = false);
 #ifdef ASSERT
   _oops_are_stale             = false;
 #endif
@@ -1474,6 +1489,7 @@
 void nmethod::post_compiled_method_load_event() {
 
   methodOop moop = method();
+#ifndef USDT2
   HS_DTRACE_PROBE8(hotspot, compiled__method__load,
       moop->klass_name()->bytes(),
       moop->klass_name()->utf8_length(),
@@ -1482,6 +1498,16 @@
       moop->signature()->bytes(),
       moop->signature()->utf8_length(),
       insts_begin(), insts_size());
+#else /* USDT2 */
+  HOTSPOT_COMPILED_METHOD_LOAD(
+      (char *) moop->klass_name()->bytes(),
+      moop->klass_name()->utf8_length(),
+      (char *) moop->name()->bytes(),
+      moop->name()->utf8_length(),
+      (char *) moop->signature()->bytes(),
+      moop->signature()->utf8_length(),
+      insts_begin(), insts_size());
+#endif /* USDT2 */
 
   if (JvmtiExport::should_post_compiled_method_load() ||
       JvmtiExport::should_post_compiled_method_unload()) {
--- a/hotspot/src/share/vm/code/nmethod.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/code/nmethod.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -191,8 +191,6 @@
 
   jbyte _scavenge_root_state;
 
-  NOT_PRODUCT(bool _has_debug_info; )
-
   // Nmethod Flushing lock. If non-zero, then the nmethod is not removed
   // and is not made into a zombie. However, once the nmethod is made into
   // a zombie, it will be locked one final time if CompiledMethodUnload
@@ -329,11 +327,6 @@
   methodOop method() const                        { return _method; }
   AbstractCompiler* compiler() const              { return _compiler; }
 
-#ifndef PRODUCT
-  bool has_debug_info() const                     { return _has_debug_info; }
-  void set_has_debug_info(bool f)                 { _has_debug_info = false; }
-#endif // NOT PRODUCT
-
   // type info
   bool is_nmethod() const                         { return true; }
   bool is_java_method() const                     { return !method()->is_native(); }
--- a/hotspot/src/share/vm/code/pcDesc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/code/pcDesc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -30,11 +30,10 @@
 #include "memory/resourceArea.hpp"
 
 PcDesc::PcDesc(int pc_offset, int scope_decode_offset, int obj_decode_offset) {
-  assert(sizeof(PcDescFlags) <= 4, "occupies more than a word");
   _pc_offset           = pc_offset;
   _scope_decode_offset = scope_decode_offset;
   _obj_decode_offset   = obj_decode_offset;
-  _flags.word          = 0;
+  _flags               = 0;
 }
 
 address PcDesc::real_pc(const nmethod* code) const {
@@ -44,7 +43,7 @@
 void PcDesc::print(nmethod* code) {
 #ifndef PRODUCT
   ResourceMark rm;
-  tty->print_cr("PcDesc(pc=0x%lx offset=%x bits=%x):", real_pc(code), pc_offset(), _flags.bits);
+  tty->print_cr("PcDesc(pc=0x%lx offset=%x bits=%x):", real_pc(code), pc_offset(), _flags);
 
   if (scope_decode_offset() == DebugInformationRecorder::serialized_null) {
     return;
--- a/hotspot/src/share/vm/code/pcDesc.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/code/pcDesc.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -39,15 +39,17 @@
   int _scope_decode_offset; // offset for scope in nmethod
   int _obj_decode_offset;
 
-  union PcDescFlags {
-    int word;
-    struct {
-      unsigned int reexecute: 1;
-      unsigned int is_method_handle_invoke: 1;
-      unsigned int return_oop: 1;
-    } bits;
-    bool operator ==(const PcDescFlags& other) { return word == other.word; }
-  } _flags;
+  enum {
+    PCDESC_reexecute               = 1 << 0,
+    PCDESC_is_method_handle_invoke = 1 << 1,
+    PCDESC_return_oop              = 1 << 2
+  };
+
+  int _flags;
+
+  void set_flag(int mask, bool z) {
+    _flags = z ? (_flags | mask) : (_flags & ~mask);
+  }
 
  public:
   int pc_offset() const           { return _pc_offset;   }
@@ -69,8 +71,8 @@
   };
 
   // Flags
-  bool     should_reexecute()              const { return _flags.bits.reexecute; }
-  void set_should_reexecute(bool z)              { _flags.bits.reexecute = z;    }
+  bool     should_reexecute()              const { return (_flags & PCDESC_reexecute) != 0; }
+  void set_should_reexecute(bool z)              { set_flag(PCDESC_reexecute, z); }
 
   // Does pd refer to the same information as pd?
   bool is_same_info(const PcDesc* pd) {
@@ -79,11 +81,11 @@
       _flags == pd->_flags;
   }
 
-  bool     is_method_handle_invoke()       const { return _flags.bits.is_method_handle_invoke;     }
-  void set_is_method_handle_invoke(bool z)       {        _flags.bits.is_method_handle_invoke = z; }
+  bool     is_method_handle_invoke()       const { return (_flags & PCDESC_is_method_handle_invoke) != 0;     }
+  void set_is_method_handle_invoke(bool z)       { set_flag(PCDESC_is_method_handle_invoke, z); }
 
-  bool     return_oop()                    const { return _flags.bits.return_oop;     }
-  void set_return_oop(bool z)                    {        _flags.bits.return_oop = z; }
+  bool     return_oop()                    const { return (_flags & PCDESC_return_oop) != 0;     }
+  void set_return_oop(bool z)                    { set_flag(PCDESC_return_oop, z); }
 
   // Returns the real pc
   address real_pc(const nmethod* code) const;
--- a/hotspot/src/share/vm/code/stubs.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/code/stubs.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // The classes in this file provide a simple framework for the
 // management of little pieces of machine code - or stubs -
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -58,6 +58,7 @@
 
 // Only bother with this argument setup if dtrace is available
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin,
   char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t);
 HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end,
@@ -89,6 +90,35 @@
       signature->bytes(), signature->utf8_length(), (success));          \
   }
 
+#else /* USDT2 */
+
+#define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method)              \
+  {                                                                      \
+    char* comp_name = (char*)(compiler)->name();                         \
+    Symbol* klass_name = (method)->klass_name();                         \
+    Symbol* name = (method)->name();                                     \
+    Symbol* signature = (method)->signature();                           \
+    HOTSPOT_METHOD_COMPILE_BEGIN(                                       \
+      comp_name, strlen(comp_name),                                      \
+      (char *) klass_name->bytes(), klass_name->utf8_length(),          \
+      (char *) name->bytes(), name->utf8_length(),                       \
+      (char *) signature->bytes(), signature->utf8_length());            \
+  }
+
+#define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success)       \
+  {                                                                      \
+    char* comp_name = (char*)(compiler)->name();                         \
+    Symbol* klass_name = (method)->klass_name();                         \
+    Symbol* name = (method)->name();                                     \
+    Symbol* signature = (method)->signature();                           \
+    HOTSPOT_METHOD_COMPILE_END(                                          \
+      comp_name, strlen(comp_name),                                      \
+      (char *) klass_name->bytes(), klass_name->utf8_length(),           \
+      (char *) name->bytes(), name->utf8_length(),                       \
+      (char *) signature->bytes(), signature->utf8_length(), (success)); \
+  }
+#endif /* USDT2 */
+
 #else //  ndef DTRACE_ENABLED
 
 #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method)
--- a/hotspot/src/share/vm/compiler/compileBroker.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/compiler/compileBroker.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,8 @@
 // An entry in the compile queue.  It represents a pending or current
 // compilation.
 class CompileTask : public CHeapObj {
+  friend class VMStructs;
+
  private:
   Monitor*     _lock;
   uint         _compile_id;
--- a/hotspot/src/share/vm/compiler/disassembler.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/compiler/disassembler.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 class decode_env;
 
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 elapsedTimer CMSAdaptiveSizePolicy::_concurrent_timer;
 elapsedTimer CMSAdaptiveSizePolicy::_STW_timer;
 
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -50,6 +50,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //
 // ConcurrentMarkSweepPolicy methods
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -2004,7 +2004,7 @@
   ReferenceProcessorMTDiscoveryMutator rp_mut_discovery(ref_processor(), false);
 
   ref_processor()->set_enqueuing_is_done(false);
-  ref_processor()->enable_discovery();
+  ref_processor()->enable_discovery(false /*verify_disabled*/, false /*check_no_refs*/);
   ref_processor()->setup_policy(clear_all_soft_refs);
   // If an asynchronous collection finishes, the _modUnionTable is
   // all clear.  If we are assuming the collection from an asynchronous
@@ -3490,8 +3490,8 @@
     MutexLockerEx x(bitMapLock(),
                     Mutex::_no_safepoint_check_flag);
     checkpointRootsInitialWork(asynch);
-    rp->verify_no_references_recorded();
-    rp->enable_discovery(); // enable ("weak") refs discovery
+    // 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
@@ -3503,7 +3503,8 @@
            "ref discovery for this generation kind");
     // already have locks
     checkpointRootsInitialWork(asynch);
-    rp->enable_discovery(); // now enable ("weak") refs discovery
+    // now enable ("weak") refs discovery
+    rp->enable_discovery(true /*verify_disabled*/, false /*verify_no_refs*/);
     _collectorState = Marking;
   }
   SpecializationStats::print();
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 class ConcurrentMarkSweepGeneration;
 class CMSCollector;
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeBlockDictionary.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeBlockDictionary.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -33,6 +33,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifndef PRODUCT
 Mutex* FreeBlockDictionary::par_lock() const {
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -30,11 +30,15 @@
 #include "memory/gcLocker.inline.hpp"
 #include "runtime/interfaceSupport.hpp"
 #include "utilities/dtrace.hpp"
+
+
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL(hs_private, cms__initmark__begin);
 HS_DTRACE_PROBE_DECL(hs_private, cms__initmark__end);
 
 HS_DTRACE_PROBE_DECL(hs_private, cms__remark__begin);
 HS_DTRACE_PROBE_DECL(hs_private, cms__remark__end);
+#endif /* !USDT2 */
 
 //////////////////////////////////////////////////////////
 // Methods in abstract class VM_CMS_Operation
@@ -129,7 +133,12 @@
     // Nothing to do.
     return;
   }
+#ifndef USDT2
   HS_DTRACE_PROBE(hs_private, cms__initmark__begin);
+#else /* USDT2 */
+  HS_PRIVATE_CMS_INITMARK_BEGIN(
+                                );
+#endif /* USDT2 */
 
   GenCollectedHeap* gch = GenCollectedHeap::heap();
   GCCauseSetter gccs(gch, GCCause::_cms_initial_mark);
@@ -140,7 +149,12 @@
   _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsInitial);
 
   VM_CMS_Operation::verify_after_gc();
+#ifndef USDT2
   HS_DTRACE_PROBE(hs_private, cms__initmark__end);
+#else /* USDT2 */
+  HS_PRIVATE_CMS_INITMARK_END(
+                                );
+#endif /* USDT2 */
 }
 
 //////////////////////////////////////////////////////////
@@ -151,7 +165,12 @@
     // Nothing to do.
     return;
   }
+#ifndef USDT2
   HS_DTRACE_PROBE(hs_private, cms__remark__begin);
+#else /* USDT2 */
+  HS_PRIVATE_CMS_REMARK_BEGIN(
+                                );
+#endif /* USDT2 */
 
   GenCollectedHeap* gch = GenCollectedHeap::heap();
   GCCauseSetter gccs(gch, GCCause::_cms_final_remark);
@@ -162,7 +181,12 @@
   _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsFinal);
 
   VM_CMS_Operation::verify_after_gc();
+#ifndef USDT2
   HS_DTRACE_PROBE(hs_private, cms__remark__end);
+#else /* USDT2 */
+  HS_PRIVATE_CMS_REMARK_END(
+                                );
+#endif /* USDT2 */
 }
 
 // VM operation to invoke a concurrent collection of a
--- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 #include "gc_implementation/g1/collectionSetChooser.hpp"
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
+#include "gc_implementation/g1/g1ErgoVerbose.hpp"
 #include "memory/space.inline.hpp"
 
 CSetChooserCache::CSetChooserCache() {
@@ -117,30 +118,6 @@
   }
 }
 
-// this is a bit expensive... but we expect that it should not be called
-// to often.
-void CSetChooserCache::remove(HeapRegion *hr) {
-  assert(_occupancy > 0, "cache should not be empty");
-  assert(hr->sort_index() < -1, "should already be in the cache");
-  int index = get_index(hr->sort_index());
-  assert(_cache[index] == hr, "index should be correct");
-  int next_index = trim_index(index + 1);
-  int last_index = trim_index(_first + _occupancy - 1);
-  while (index != last_index) {
-    assert(_cache[next_index] != NULL, "should not be null");
-    _cache[index] = _cache[next_index];
-    _cache[index]->set_sort_index(get_sort_index(index));
-
-    index = next_index;
-    next_index = trim_index(next_index+1);
-  }
-  assert(index == last_index, "should have reached the last one");
-  _cache[index] = NULL;
-  hr->set_sort_index(-1);
-  --_occupancy;
-  assert(verify(), "cache should be consistent");
-}
-
 static inline int orderRegions(HeapRegion* hr1, HeapRegion* hr2) {
   if (hr1 == NULL) {
     if (hr2 == NULL) return 0;
@@ -196,43 +173,34 @@
   HeapRegion *prev = NULL;
   while (index < _numMarkedRegions) {
     HeapRegion *curr = _markedRegions.at(index++);
-    if (curr != NULL) {
-      int si = curr->sort_index();
-      guarantee(!curr->is_young(), "should not be young!");
-      guarantee(si > -1 && si == (index-1), "sort index invariant");
-      if (prev != NULL) {
-        guarantee(orderRegions(prev, curr) != 1, "regions should be sorted");
-      }
-      prev = curr;
+    guarantee(curr != NULL, "Regions in _markedRegions array cannot be NULL");
+    int si = curr->sort_index();
+    guarantee(!curr->is_young(), "should not be young!");
+    guarantee(si > -1 && si == (index-1), "sort index invariant");
+    if (prev != NULL) {
+      guarantee(orderRegions(prev, curr) != 1, "regions should be sorted");
     }
+    prev = curr;
   }
   return _cache.verify();
 }
 #endif
 
-bool
-CollectionSetChooser::addRegionToCache() {
-  assert(!_cache.is_full(), "cache should not be full");
-
-  HeapRegion *hr = NULL;
-  while (hr == NULL && _curMarkedIndex < _numMarkedRegions) {
-    hr = _markedRegions.at(_curMarkedIndex++);
-  }
-  if (hr == NULL)
-    return false;
-  assert(!hr->is_young(), "should not be young!");
-  assert(hr->sort_index() == _curMarkedIndex-1, "sort_index invariant");
-  _markedRegions.at_put(hr->sort_index(), NULL);
-  _cache.insert(hr);
-  assert(!_cache.is_empty(), "cache should not be empty");
-  assert(verify(), "cache should be consistent");
-  return false;
-}
-
 void
 CollectionSetChooser::fillCache() {
-  while (!_cache.is_full() && addRegionToCache()) {
+  while (!_cache.is_full() && (_curMarkedIndex < _numMarkedRegions)) {
+    HeapRegion* hr = _markedRegions.at(_curMarkedIndex);
+    assert(hr != NULL,
+           err_msg("Unexpected NULL hr in _markedRegions at index %d",
+                   _curMarkedIndex));
+    _curMarkedIndex += 1;
+    assert(!hr->is_young(), "should not be young!");
+    assert(hr->sort_index() == _curMarkedIndex-1, "sort_index invariant");
+    _markedRegions.at_put(hr->sort_index(), NULL);
+    _cache.insert(hr);
+    assert(!_cache.is_empty(), "cache should not be empty");
   }
+  assert(verify(), "cache should be consistent");
 }
 
 void
@@ -333,20 +301,6 @@
   clearMarkedHeapRegions();
 }
 
-void CollectionSetChooser::removeRegion(HeapRegion *hr) {
-  int si = hr->sort_index();
-  assert(si == -1 || hr->is_marked(), "Sort index not valid.");
-  if (si > -1) {
-    assert(_markedRegions.at(si) == hr, "Sort index not valid." );
-    _markedRegions.at_put(si, NULL);
-  } else if (si < -1) {
-    assert(_cache.region_in_cache(hr), "should be in the cache");
-    _cache.remove(hr);
-    assert(hr->sort_index() == -1, "sort index invariant");
-  }
-  hr->set_sort_index(-1);
-}
-
 // if time_remaining < 0.0, then this method should try to return
 // a region, whether it fits within the remaining time or not
 HeapRegion*
@@ -358,6 +312,9 @@
   if (_cache.is_empty()) {
     assert(_curMarkedIndex == _numMarkedRegions,
            "if cache is empty, list should also be empty");
+    ergo_verbose0(ErgoCSetConstruction,
+                  "stop adding old regions to CSet",
+                  ergo_format_reason("cache is empty"));
     return NULL;
   }
 
@@ -368,10 +325,23 @@
   if (g1p->adaptive_young_list_length()) {
     if (time_remaining - predicted_time < 0.0) {
       g1h->check_if_region_is_too_expensive(predicted_time);
+      ergo_verbose2(ErgoCSetConstruction,
+                    "stop adding old regions to CSet",
+                    ergo_format_reason("predicted old region time higher than remaining time")
+                    ergo_format_ms("predicted old region time")
+                    ergo_format_ms("remaining time"),
+                    predicted_time, time_remaining);
       return NULL;
     }
   } else {
-    if (predicted_time > 2.0 * avg_prediction) {
+    double threshold = 2.0 * avg_prediction;
+    if (predicted_time > threshold) {
+      ergo_verbose2(ErgoCSetConstruction,
+                    "stop adding old regions to CSet",
+                    ergo_format_reason("predicted old region time higher than threshold")
+                    ergo_format_ms("predicted old region time")
+                    ergo_format_ms("threshold"),
+                    predicted_time, threshold);
       return NULL;
     }
   }
--- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,26 @@
 #include "utilities/growableArray.hpp"
 
 // We need to sort heap regions by collection desirability.
+// This sorting is currently done in two "stages". An initial sort is
+// done following a cleanup pause as soon as all of the marked but
+// non-empty regions have been identified and the completely empty
+// ones reclaimed.
+// This gives us a global sort on a GC efficiency metric
+// based on predictive data available at that time. However,
+// any of these regions that are collected will only be collected
+// during a future GC pause, by which time it is possible that newer
+// data might allow us to revise and/or refine the earlier
+// pause predictions, leading to changes in expected gc efficiency
+// order. To somewhat mitigate this obsolescence, more so in the
+// case of regions towards the end of the list, which will be
+// picked later, these pre-sorted regions from the _markedRegions
+// array are not used as is, but a small prefix thereof is
+// insertion-sorted again into a small cache, based on more
+// recent remembered set information. Regions are then drawn
+// from this cache to construct the collection set at each
+// incremental GC.
+// This scheme and/or its implementation may be subject to
+// revision in the future.
 
 class CSetChooserCache VALUE_OBJ_CLASS_SPEC {
 private:
@@ -37,8 +57,8 @@
   } PrivateConstants;
 
   HeapRegion*  _cache[CacheLength];
-  int          _occupancy; // number of region in cache
-  int          _first; // "first" region in the cache
+  int          _occupancy; // number of regions in cache
+  int          _first;     // (index of) "first" region in the cache
 
   // adding CacheLength to deal with negative values
   inline int trim_index(int index) {
@@ -62,7 +82,6 @@
   void clear(void);
   void insert(HeapRegion *hr);
   HeapRegion *remove_first(void);
-  void remove (HeapRegion *hr);
   inline HeapRegion *get_first(void) {
     return _cache[_first];
   }
@@ -102,7 +121,6 @@
 
   void sortMarkedHeapRegions();
   void fillCache();
-  bool addRegionToCache(void);
   void addMarkedHeapRegion(HeapRegion *hr);
 
   // Must be called before calls to getParMarkedHeapRegionChunk.
@@ -122,9 +140,6 @@
 
   void updateAfterFullCollection();
 
-  // Ensure that "hr" is not a member of the marked region array or the cache
-  void removeRegion(HeapRegion* hr);
-
   bool unmarked_age_1_returned_as_new() { return _unmarked_age_1_returned_as_new; }
 
   // Returns true if the used portion of "_markedRegions" is properly
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -91,7 +91,7 @@
       }
     }
 
-    g1p->check_prediction_validity();
+    g1p->revise_young_list_target_length_if_necessary();
   }
 }
 
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -28,6 +28,7 @@
 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
+#include "gc_implementation/g1/g1ErgoVerbose.hpp"
 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
 #include "gc_implementation/g1/g1RemSet.hpp"
 #include "gc_implementation/g1/heapRegionRemSet.hpp"
@@ -817,10 +818,10 @@
   NoteStartOfMarkHRClosure startcl;
   g1h->heap_region_iterate(&startcl);
 
-  // Start weak-reference discovery.
-  ReferenceProcessor* rp = g1h->ref_processor();
-  rp->verify_no_references_recorded();
-  rp->enable_discovery(); // enable ("weak") refs discovery
+  // Start Concurrent Marking weak-reference discovery.
+  ReferenceProcessor* rp = g1h->ref_processor_cm();
+  // enable ("weak") refs discovery
+  rp->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
   rp->setup_policy(false); // snapshot the soft ref policy to be used in this cycle
 
   SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
@@ -1132,6 +1133,7 @@
   // world is stopped at this checkpoint
   assert(SafepointSynchronize::is_at_safepoint(),
          "world should be stopped");
+
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
   // If a full collection has happened, we shouldn't do this.
@@ -1727,18 +1729,21 @@
 
   size_t known_garbage_bytes =
     g1_par_count_task.used_bytes() - g1_par_count_task.live_bytes();
-#if 0
-  gclog_or_tty->print_cr("used %1.2lf, live %1.2lf, garbage %1.2lf",
-                         (double) g1_par_count_task.used_bytes() / (double) (1024 * 1024),
-                         (double) g1_par_count_task.live_bytes() / (double) (1024 * 1024),
-                         (double) known_garbage_bytes / (double) (1024 * 1024));
-#endif // 0
   g1p->set_known_garbage_bytes(known_garbage_bytes);
 
   size_t start_used_bytes = g1h->used();
   _at_least_one_mark_complete = true;
   g1h->set_marking_complete();
 
+  ergo_verbose4(ErgoConcCycles,
+           "finish cleanup",
+           ergo_format_byte("occupancy")
+           ergo_format_byte("capacity")
+           ergo_format_byte_perc("known garbage"),
+           start_used_bytes, g1h->capacity(),
+           known_garbage_bytes,
+           ((double) known_garbage_bytes / (double) g1h->capacity()) * 100.0);
+
   double count_end = os::elapsedTime();
   double this_final_counting_time = (count_end - start);
   if (G1PrintParCleanupStats) {
@@ -1811,9 +1816,7 @@
 
   // this will also free any regions totally full of garbage objects,
   // and sort the regions.
-  g1h->g1_policy()->record_concurrent_mark_cleanup_end(
-                        g1_par_note_end_task.freed_bytes(),
-                        g1_par_note_end_task.max_live_bytes());
+  g1h->g1_policy()->record_concurrent_mark_cleanup_end();
 
   // Statistics.
   double end = os::elapsedTime();
@@ -1833,6 +1836,10 @@
   size_t cleaned_up_bytes = start_used_bytes - g1h->used();
   g1p->decrease_known_garbage_bytes(cleaned_up_bytes);
 
+  // Clean up will have freed any regions completely full of garbage.
+  // Update the soft reference policy with the new heap occupancy.
+  Universe::update_heap_info_at_gc();
+
   // We need to make this be a "collection" so any collection pause that
   // races with it goes around and waits for completeCleanup to finish.
   g1h->increment_total_collections();
@@ -2068,8 +2075,10 @@
   }
 };
 
-// Implementation of AbstractRefProcTaskExecutor for G1
-class G1RefProcTaskExecutor: public AbstractRefProcTaskExecutor {
+// Implementation of AbstractRefProcTaskExecutor for parallel
+// reference processing at the end of G1 concurrent marking
+
+class G1CMRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
 private:
   G1CollectedHeap* _g1h;
   ConcurrentMark*  _cm;
@@ -2078,7 +2087,7 @@
   int              _active_workers;
 
 public:
-  G1RefProcTaskExecutor(G1CollectedHeap* g1h,
+  G1CMRefProcTaskExecutor(G1CollectedHeap* g1h,
                         ConcurrentMark* cm,
                         CMBitMap* bitmap,
                         WorkGang* workers,
@@ -2092,7 +2101,7 @@
   virtual void execute(EnqueueTask& task);
 };
 
-class G1RefProcTaskProxy: public AbstractGangTask {
+class G1CMRefProcTaskProxy: public AbstractGangTask {
   typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
   ProcessTask&     _proc_task;
   G1CollectedHeap* _g1h;
@@ -2100,7 +2109,7 @@
   CMBitMap*        _bitmap;
 
 public:
-  G1RefProcTaskProxy(ProcessTask& proc_task,
+  G1CMRefProcTaskProxy(ProcessTask& proc_task,
                      G1CollectedHeap* g1h,
                      ConcurrentMark* cm,
                      CMBitMap* bitmap) :
@@ -2118,10 +2127,10 @@
   }
 };
 
-void G1RefProcTaskExecutor::execute(ProcessTask& proc_task) {
+void G1CMRefProcTaskExecutor::execute(ProcessTask& proc_task) {
   assert(_workers != NULL, "Need parallel worker threads.");
 
-  G1RefProcTaskProxy proc_task_proxy(proc_task, _g1h, _cm, _bitmap);
+  G1CMRefProcTaskProxy proc_task_proxy(proc_task, _g1h, _cm, _bitmap);
 
   // We need to reset the phase for each task execution so that
   // the termination protocol of CMTask::do_marking_step works.
@@ -2131,12 +2140,12 @@
   _g1h->set_par_threads(0);
 }
 
-class G1RefEnqueueTaskProxy: public AbstractGangTask {
+class G1CMRefEnqueueTaskProxy: public AbstractGangTask {
   typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
   EnqueueTask& _enq_task;
 
 public:
-  G1RefEnqueueTaskProxy(EnqueueTask& enq_task) :
+  G1CMRefEnqueueTaskProxy(EnqueueTask& enq_task) :
     AbstractGangTask("Enqueue reference objects in parallel"),
     _enq_task(enq_task)
   { }
@@ -2146,10 +2155,10 @@
   }
 };
 
-void G1RefProcTaskExecutor::execute(EnqueueTask& enq_task) {
+void G1CMRefProcTaskExecutor::execute(EnqueueTask& enq_task) {
   assert(_workers != NULL, "Need parallel worker threads.");
 
-  G1RefEnqueueTaskProxy enq_task_proxy(enq_task);
+  G1CMRefEnqueueTaskProxy enq_task_proxy(enq_task);
 
   _g1h->set_par_threads(_active_workers);
   _workers->run_task(&enq_task_proxy);
@@ -2159,71 +2168,84 @@
 void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) {
   ResourceMark rm;
   HandleMark   hm;
-  G1CollectedHeap* g1h   = G1CollectedHeap::heap();
-  ReferenceProcessor* rp = g1h->ref_processor();
-
-  // See the comment in G1CollectedHeap::ref_processing_init()
-  // about how reference processing currently works in G1.
-
-  // Process weak references.
-  rp->setup_policy(clear_all_soft_refs);
-  assert(_markStack.isEmpty(), "mark stack should be empty");
-
-  G1CMIsAliveClosure   g1_is_alive(g1h);
-  G1CMKeepAliveClosure g1_keep_alive(g1h, this, nextMarkBitMap());
-  G1CMDrainMarkingStackClosure
-    g1_drain_mark_stack(nextMarkBitMap(), &_markStack, &g1_keep_alive);
-  // We use the work gang from the G1CollectedHeap and we utilize all
-  // the worker threads.
-  int active_workers = g1h->workers() ? g1h->workers()->total_workers() : 1;
-  active_workers = MAX2(MIN2(active_workers, (int)_max_task_num), 1);
-
-  G1RefProcTaskExecutor par_task_executor(g1h, this, nextMarkBitMap(),
-                                          g1h->workers(), active_workers);
-
-
-  if (rp->processing_is_mt()) {
-    // Set the degree of MT here.  If the discovery is done MT, there
-    // may have been a different number of threads doing the discovery
-    // and a different number of discovered lists may have Ref objects.
-    // That is OK as long as the Reference lists are balanced (see
-    // balance_all_queues() and balance_queues()).
-    rp->set_active_mt_degree(active_workers);
-
-    rp->process_discovered_references(&g1_is_alive,
+
+  G1CollectedHeap* g1h = G1CollectedHeap::heap();
+
+  // Is alive closure.
+  G1CMIsAliveClosure g1_is_alive(g1h);
+
+  // Inner scope to exclude the cleaning of the string and symbol
+  // tables from the displayed time.
+  {
+    bool verbose = PrintGC && PrintGCDetails;
+    if (verbose) {
+      gclog_or_tty->put(' ');
+    }
+    TraceTime t("GC ref-proc", verbose, false, gclog_or_tty);
+
+    ReferenceProcessor* rp = g1h->ref_processor_cm();
+
+    // See the comment in G1CollectedHeap::ref_processing_init()
+    // about how reference processing currently works in G1.
+
+    // Process weak references.
+    rp->setup_policy(clear_all_soft_refs);
+    assert(_markStack.isEmpty(), "mark stack should be empty");
+
+    G1CMKeepAliveClosure g1_keep_alive(g1h, this, nextMarkBitMap());
+    G1CMDrainMarkingStackClosure
+      g1_drain_mark_stack(nextMarkBitMap(), &_markStack, &g1_keep_alive);
+
+    // We use the work gang from the G1CollectedHeap and we utilize all
+    // the worker threads.
+    int active_workers = g1h->workers() ? g1h->workers()->total_workers() : 1;
+    active_workers = MAX2(MIN2(active_workers, (int)_max_task_num), 1);
+
+    G1CMRefProcTaskExecutor par_task_executor(g1h, this, nextMarkBitMap(),
+                                              g1h->workers(), active_workers);
+
+    if (rp->processing_is_mt()) {
+      // Set the degree of MT here.  If the discovery is done MT, there
+      // may have been a different number of threads doing the discovery
+      // and a different number of discovered lists may have Ref objects.
+      // That is OK as long as the Reference lists are balanced (see
+      // balance_all_queues() and balance_queues()).
+      rp->set_active_mt_degree(active_workers);
+
+      rp->process_discovered_references(&g1_is_alive,
                                       &g1_keep_alive,
                                       &g1_drain_mark_stack,
                                       &par_task_executor);
 
-    // The work routines of the parallel keep_alive and drain_marking_stack
-    // will set the has_overflown flag if we overflow the global marking
-    // stack.
-  } else {
-    rp->process_discovered_references(&g1_is_alive,
-                                      &g1_keep_alive,
-                                      &g1_drain_mark_stack,
-                                      NULL);
-
+      // The work routines of the parallel keep_alive and drain_marking_stack
+      // will set the has_overflown flag if we overflow the global marking
+      // stack.
+    } else {
+      rp->process_discovered_references(&g1_is_alive,
+                                        &g1_keep_alive,
+                                        &g1_drain_mark_stack,
+                                        NULL);
+    }
+
+    assert(_markStack.overflow() || _markStack.isEmpty(),
+            "mark stack should be empty (unless it overflowed)");
+    if (_markStack.overflow()) {
+      // Should have been done already when we tried to push an
+      // entry on to the global mark stack. But let's do it again.
+      set_has_overflown();
+    }
+
+    if (rp->processing_is_mt()) {
+      assert(rp->num_q() == active_workers, "why not");
+      rp->enqueue_discovered_references(&par_task_executor);
+    } else {
+      rp->enqueue_discovered_references();
+    }
+
+    rp->verify_no_references_recorded();
+    assert(!rp->discovery_enabled(), "Post condition");
   }
 
-  assert(_markStack.overflow() || _markStack.isEmpty(),
-      "mark stack should be empty (unless it overflowed)");
-  if (_markStack.overflow()) {
-    // Should have been done already when we tried to push an
-    // entry on to the global mark stack. But let's do it again.
-    set_has_overflown();
-  }
-
-  if (rp->processing_is_mt()) {
-    assert(rp->num_q() == active_workers, "why not");
-    rp->enqueue_discovered_references(&par_task_executor);
-  } else {
-    rp->enqueue_discovered_references();
-  }
-
-  rp->verify_no_references_recorded();
-  assert(!rp->discovery_enabled(), "should have been disabled");
-
   // Now clean up stale oops in StringTable
   StringTable::unlink(&g1_is_alive);
   // Clean up unreferenced symbols in symbol table.
@@ -3325,7 +3347,7 @@
   assert(_ref_processor == NULL, "should be initialized to NULL");
 
   if (G1UseConcMarkReferenceProcessing) {
-    _ref_processor = g1h->ref_processor();
+    _ref_processor = g1h->ref_processor_cm();
     assert(_ref_processor != NULL, "should not be NULL");
   }
 }
@@ -4560,6 +4582,15 @@
                  G1PPRL_DOUBLE_H_FORMAT,
                  "type", "address-range",
                  "used", "prev-live", "next-live", "gc-eff");
+  _out->print_cr(G1PPRL_LINE_PREFIX
+                 G1PPRL_TYPE_H_FORMAT
+                 G1PPRL_ADDR_BASE_H_FORMAT
+                 G1PPRL_BYTE_H_FORMAT
+                 G1PPRL_BYTE_H_FORMAT
+                 G1PPRL_BYTE_H_FORMAT
+                 G1PPRL_DOUBLE_H_FORMAT,
+                 "", "",
+                 "(bytes)", "(bytes)", "(bytes)", "(bytes/ms)");
 }
 
 // It takes as a parameter a reference to one of the _hum_* fields, it
@@ -4571,7 +4602,7 @@
   // The > 0 check is to deal with the prev and next live bytes which
   // could be 0.
   if (*hum_bytes > 0) {
-    bytes = MIN2((size_t) HeapRegion::GrainBytes, *hum_bytes);
+    bytes = MIN2(HeapRegion::GrainBytes, *hum_bytes);
     *hum_bytes -= bytes;
   }
   return bytes;
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -366,8 +366,8 @@
   friend class CMConcurrentMarkingTask;
   friend class G1ParNoteEndTask;
   friend class CalcLiveObjectsClosure;
-  friend class G1RefProcTaskProxy;
-  friend class G1RefProcTaskExecutor;
+  friend class G1CMRefProcTaskProxy;
+  friend class G1CMRefProcTaskExecutor;
   friend class G1CMParKeepAliveAndDrainClosure;
   friend class G1CMParDrainMarkingStackClosure;
 
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -215,20 +215,20 @@
           gclog_or_tty->print_cr("[GC concurrent-cleanup-start]");
         }
 
-        // Now do the remainder of the cleanup operation.
+        // Now do the concurrent cleanup operation.
         _cm->completeCleanup();
+
         // Notify anyone who's waiting that there are no more free
-        // regions coming. We have to do this before we join the STS,
-        // otherwise we might deadlock: a GC worker could be blocked
-        // waiting for the notification whereas this thread will be
-        // blocked for the pause to finish while it's trying to join
-        // the STS, which is conditional on the GC workers finishing.
+        // regions coming. We have to do this before we join the STS
+        // (in fact, we should not attempt to join the STS in the
+        // interval between finishing the cleanup pause and clearing
+        // the free_regions_coming flag) otherwise we might deadlock:
+        // a GC worker could be blocked waiting for the notification
+        // whereas this thread will be blocked for the pause to finish
+        // while it's trying to join the STS, which is conditional on
+        // the GC workers finishing.
         g1h->reset_free_regions_coming();
 
-        _sts.join();
-        g1_policy->record_concurrent_mark_cleanup_completed();
-        _sts.leave();
-
         double cleanup_end_sec = os::elapsedTime();
         if (PrintGC) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
@@ -240,6 +240,36 @@
       guarantee(cm()->cleanup_list_is_empty(),
                 "at this point there should be no regions on the cleanup list");
 
+      // There is a tricky race before recording that the concurrent
+      // cleanup has completed and a potential Full GC starting around
+      // the same time. We want to make sure that the Full GC calls
+      // abort() on concurrent mark after
+      // record_concurrent_mark_cleanup_completed(), since abort() is
+      // the method that will reset the concurrent mark state. If we
+      // end up calling record_concurrent_mark_cleanup_completed()
+      // after abort() then we might incorrectly undo some of the work
+      // abort() did. Checking the has_aborted() flag after joining
+      // the STS allows the correct ordering of the two methods. There
+      // are two scenarios:
+      //
+      // a) If we reach here before the Full GC, the fact that we have
+      // joined the STS means that the Full GC cannot start until we
+      // leave the STS, so record_concurrent_mark_cleanup_completed()
+      // will complete before abort() is called.
+      //
+      // b) If we reach here during the Full GC, we'll be held up from
+      // joining the STS until the Full GC is done, which means that
+      // abort() will have completed and has_aborted() will return
+      // true to prevent us from calling
+      // record_concurrent_mark_cleanup_completed() (and, in fact, it's
+      // not needed any more as the concurrent mark state has been
+      // already reset).
+      _sts.join();
+      if (!cm()->has_aborted()) {
+        g1_policy->record_concurrent_mark_cleanup_completed();
+      }
+      _sts.leave();
+
       if (cm()->has_aborted()) {
         if (PrintGC) {
           gclog_or_tty->date_stamp(PrintGCDateStamps);
@@ -248,7 +278,7 @@
         }
       }
 
-      // we now want to allow clearing of the marking bitmap to be
+      // We now want to allow clearing of the marking bitmap to be
       // suspended by a collection pause.
       _sts.join();
       _cm->clearNextBitmap();
--- a/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -39,6 +39,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 bool DirtyCardQueue::apply_closure(CardTableEntryClosure* cl,
                                    bool consume,
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -31,6 +31,7 @@
 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
+#include "gc_implementation/g1/g1ErgoVerbose.hpp"
 #include "gc_implementation/g1/g1MarkSweep.hpp"
 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
 #include "gc_implementation/g1/g1RemSet.inline.hpp"
@@ -41,6 +42,7 @@
 #include "memory/gcLocker.inline.hpp"
 #include "memory/genOopClosures.inline.hpp"
 #include "memory/generationSpec.hpp"
+#include "memory/referenceProcessor.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/oop.pcgc.inline.hpp"
 #include "runtime/aprofiler.hpp"
@@ -550,8 +552,7 @@
 }
 
 HeapRegion* G1CollectedHeap::new_region(size_t word_size, bool do_expand) {
-  assert(!isHumongous(word_size) ||
-                                  word_size <= (size_t) HeapRegion::GrainWords,
+  assert(!isHumongous(word_size) || word_size <= HeapRegion::GrainWords,
          "the only time we use this to allocate a humongous region is "
          "when we are allocating a single humongous region");
 
@@ -577,6 +578,11 @@
     res = new_region_try_secondary_free_list();
   }
   if (res == NULL && do_expand) {
+    ergo_verbose1(ErgoHeapSizing,
+                  "attempt heap expansion",
+                  ergo_format_reason("region allocation request failed")
+                  ergo_format_byte("allocation request"),
+                  word_size * HeapWordSize);
     if (expand(word_size * HeapWordSize)) {
       // Even though the heap was expanded, it might not have reached
       // the desired size. So, we cannot assume that the allocation
@@ -790,6 +796,11 @@
       // room available.
       assert(num_regions > fs, "earlier allocation should have succeeded");
 
+      ergo_verbose1(ErgoHeapSizing,
+                    "attempt heap expansion",
+                    ergo_format_reason("humongous allocation request failed")
+                    ergo_format_byte("allocation request"),
+                    word_size * HeapWordSize);
       if (expand((num_regions - fs) * HeapRegion::GrainBytes)) {
         // Even though the heap was expanded, it might not have
         // reached the desired size. So, we cannot assume that the
@@ -804,6 +815,11 @@
     result =
       humongous_obj_allocate_initialize_regions(first, num_regions, word_size);
     assert(result != NULL, "it should always return a valid result");
+
+    // A successful humongous object allocation changes the used space
+    // information of the old generation so we need to recalculate the
+    // sizes and update the jstat counters here.
+    g1mm()->update_sizes();
   }
 
   verify_region_sets_optional();
@@ -906,6 +922,8 @@
 
       if (GC_locker::is_active_and_needs_gc()) {
         if (g1_policy()->can_expand_young_list()) {
+          // No need for an ergo verbose message here,
+          // can_expand_young_list() does this when it returns true.
           result = _mutator_alloc_region.attempt_allocation_force(word_size,
                                                       false /* bot_updates */);
           if (result != NULL) {
@@ -1151,7 +1169,7 @@
       if (!hr->isHumongous()) {
         _hr_printer->post_compaction(hr, G1HRPrinter::Old);
       } else if (hr->startsHumongous()) {
-        if (hr->capacity() == (size_t) HeapRegion::GrainBytes) {
+        if (hr->capacity() == HeapRegion::GrainBytes) {
           // single humongous region
           _hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous);
         } else {
@@ -1231,15 +1249,11 @@
 
     COMPILER2_PRESENT(DerivedPointerTable::clear());
 
-    // We want to discover references, but not process them yet.
-    // This mode is disabled in
-    // instanceRefKlass::process_discovered_references if the
-    // generation does some collection work, or
-    // instanceRefKlass::enqueue_discovered_references if the
-    // generation returns without doing any work.
-    ref_processor()->disable_discovery();
-    ref_processor()->abandon_partial_discovery();
-    ref_processor()->verify_no_references_recorded();
+    // Disable discovery and empty the discovered lists
+    // for the CM ref processor.
+    ref_processor_cm()->disable_discovery();
+    ref_processor_cm()->abandon_partial_discovery();
+    ref_processor_cm()->verify_no_references_recorded();
 
     // Abandon current iterations of concurrent marking and concurrent
     // refinement, if any are in progress.
@@ -1267,31 +1281,33 @@
     empty_young_list();
     g1_policy()->set_full_young_gcs(true);
 
-    // See the comment in G1CollectedHeap::ref_processing_init() about
+    // See the comments in g1CollectedHeap.hpp and
+    // G1CollectedHeap::ref_processing_init() about
     // how reference processing currently works in G1.
 
-    // Temporarily make reference _discovery_ single threaded (non-MT).
-    ReferenceProcessorMTDiscoveryMutator rp_disc_ser(ref_processor(), false);
-
-    // Temporarily make refs discovery atomic
-    ReferenceProcessorAtomicMutator rp_disc_atomic(ref_processor(), true);
-
-    // Temporarily clear _is_alive_non_header
-    ReferenceProcessorIsAliveMutator rp_is_alive_null(ref_processor(), NULL);
-
-    ref_processor()->enable_discovery();
-    ref_processor()->setup_policy(do_clear_all_soft_refs);
+    // Temporarily make discovery by the STW ref processor single threaded (non-MT).
+    ReferenceProcessorMTDiscoveryMutator stw_rp_disc_ser(ref_processor_stw(), false);
+
+    // Temporarily clear the STW ref processor's _is_alive_non_header field.
+    ReferenceProcessorIsAliveMutator stw_rp_is_alive_null(ref_processor_stw(), NULL);
+
+    ref_processor_stw()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
+    ref_processor_stw()->setup_policy(do_clear_all_soft_refs);
+
     // Do collection work
     {
       HandleMark hm;  // Discard invalid handles created during gc
-      G1MarkSweep::invoke_at_safepoint(ref_processor(), do_clear_all_soft_refs);
+      G1MarkSweep::invoke_at_safepoint(ref_processor_stw(), do_clear_all_soft_refs);
     }
+
     assert(free_regions() == 0, "we should not have added any free regions");
     rebuild_region_lists();
 
     _summary_bytes_used = recalculate_used();
 
-    ref_processor()->enqueue_discovered_references();
+    // Enqueue any discovered reference objects that have
+    // not been removed from the discovered lists.
+    ref_processor_stw()->enqueue_discovered_references();
 
     COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
 
@@ -1306,7 +1322,16 @@
                        /* option      */ VerifyOption_G1UsePrevMarking);
 
     }
-    NOT_PRODUCT(ref_processor()->verify_no_references_recorded());
+
+    assert(!ref_processor_stw()->discovery_enabled(), "Postcondition");
+    ref_processor_stw()->verify_no_references_recorded();
+
+    // Note: since we've just done a full GC, concurrent
+    // marking is no longer active. Therefore we need not
+    // re-enable reference discovery for the CM ref processor.
+    // That will be done at the start of the next marking cycle.
+    assert(!ref_processor_cm()->discovery_enabled(), "Postcondition");
+    ref_processor_cm()->verify_no_references_recorded();
 
     reset_gc_time_stamp();
     // Since everything potentially moved, we will clear all remembered
@@ -1401,7 +1426,7 @@
   if (PrintHeapAtGC) {
     Universe::print_heap_after_gc();
   }
-  g1mm()->update_counters();
+  g1mm()->update_sizes();
   post_full_gc_dump();
 
   return true;
@@ -1477,63 +1502,34 @@
   // we'll try to make the capacity smaller than it, not greater).
   maximum_desired_capacity =  MAX2(maximum_desired_capacity, min_heap_size);
 
-  if (PrintGC && Verbose) {
-    const double free_percentage =
-      (double) free_after_gc / (double) capacity_after_gc;
-    gclog_or_tty->print_cr("Computing new size after full GC ");
-    gclog_or_tty->print_cr("  "
-                           "  minimum_free_percentage: %6.2f",
-                           minimum_free_percentage);
-    gclog_or_tty->print_cr("  "
-                           "  maximum_free_percentage: %6.2f",
-                           maximum_free_percentage);
-    gclog_or_tty->print_cr("  "
-                           "  capacity: %6.1fK"
-                           "  minimum_desired_capacity: %6.1fK"
-                           "  maximum_desired_capacity: %6.1fK",
-                           (double) capacity_after_gc / (double) K,
-                           (double) minimum_desired_capacity / (double) K,
-                           (double) maximum_desired_capacity / (double) K);
-    gclog_or_tty->print_cr("  "
-                           "  free_after_gc: %6.1fK"
-                           "  used_after_gc: %6.1fK",
-                           (double) free_after_gc / (double) K,
-                           (double) used_after_gc / (double) K);
-    gclog_or_tty->print_cr("  "
-                           "   free_percentage: %6.2f",
-                           free_percentage);
-  }
   if (capacity_after_gc < minimum_desired_capacity) {
     // Don't expand unless it's significant
     size_t expand_bytes = minimum_desired_capacity - capacity_after_gc;
-    if (expand(expand_bytes)) {
-      if (PrintGC && Verbose) {
-        gclog_or_tty->print_cr("  "
-                               "  expanding:"
-                               "  max_heap_size: %6.1fK"
-                               "  minimum_desired_capacity: %6.1fK"
-                               "  expand_bytes: %6.1fK",
-                               (double) max_heap_size / (double) K,
-                               (double) minimum_desired_capacity / (double) K,
-                               (double) expand_bytes / (double) K);
-      }
-    }
+    ergo_verbose4(ErgoHeapSizing,
+                  "attempt heap expansion",
+                  ergo_format_reason("capacity lower than "
+                                     "min desired capacity after Full GC")
+                  ergo_format_byte("capacity")
+                  ergo_format_byte("occupancy")
+                  ergo_format_byte_perc("min desired capacity"),
+                  capacity_after_gc, used_after_gc,
+                  minimum_desired_capacity, (double) MinHeapFreeRatio);
+    expand(expand_bytes);
 
     // No expansion, now see if we want to shrink
   } else if (capacity_after_gc > maximum_desired_capacity) {
     // Capacity too large, compute shrinking size
     size_t shrink_bytes = capacity_after_gc - maximum_desired_capacity;
+    ergo_verbose4(ErgoHeapSizing,
+                  "attempt heap shrinking",
+                  ergo_format_reason("capacity higher than "
+                                     "max desired capacity after Full GC")
+                  ergo_format_byte("capacity")
+                  ergo_format_byte("occupancy")
+                  ergo_format_byte_perc("max desired capacity"),
+                  capacity_after_gc, used_after_gc,
+                  maximum_desired_capacity, (double) MaxHeapFreeRatio);
     shrink(shrink_bytes);
-    if (PrintGC && Verbose) {
-      gclog_or_tty->print_cr("  "
-                             "  shrinking:"
-                             "  min_heap_size: %6.1fK"
-                             "  maximum_desired_capacity: %6.1fK"
-                             "  shrink_bytes: %6.1fK",
-                             (double) min_heap_size / (double) K,
-                             (double) maximum_desired_capacity / (double) K,
-                             (double) shrink_bytes / (double) K);
-    }
   }
 }
 
@@ -1619,6 +1615,11 @@
   verify_region_sets_optional();
 
   size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes);
+  ergo_verbose1(ErgoHeapSizing,
+                "attempt heap expansion",
+                ergo_format_reason("allocation request failed")
+                ergo_format_byte("allocation request"),
+                word_size * HeapWordSize);
   if (expand(expand_bytes)) {
     _hrs.verify_optional();
     verify_region_sets_optional();
@@ -1646,11 +1647,11 @@
   size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
   aligned_expand_bytes = align_size_up(aligned_expand_bytes,
                                        HeapRegion::GrainBytes);
-
-  if (Verbose && PrintGC) {
-    gclog_or_tty->print("Expanding garbage-first heap from %ldK by %ldK",
-                           old_mem_size/K, aligned_expand_bytes/K);
-  }
+  ergo_verbose2(ErgoHeapSizing,
+                "expand the heap",
+                ergo_format_byte("requested expansion amount")
+                ergo_format_byte("attempted expansion amount"),
+                expand_bytes, aligned_expand_bytes);
 
   // First commit the memory.
   HeapWord* old_end = (HeapWord*) _g1_storage.high();
@@ -1693,7 +1694,11 @@
       }
       assert(curr == mr.end(), "post-condition");
     }
+    g1_policy()->record_new_heap_size(n_regions());
   } else {
+    ergo_verbose0(ErgoHeapSizing,
+                  "did not expand the heap",
+                  ergo_format_reason("heap expansion operation failed"));
     // The expansion of the virtual storage space was unsuccessful.
     // Let's see if it was because we ran out of swap.
     if (G1ExitOnExpansionFailure &&
@@ -1702,13 +1707,6 @@
       vm_exit_out_of_memory(aligned_expand_bytes, "G1 heap expansion");
     }
   }
-
-  if (Verbose && PrintGC) {
-    size_t new_mem_size = _g1_storage.committed_size();
-    gclog_or_tty->print_cr("...%s, expanded to %ldK",
-                           (successful ? "Successful" : "Failed"),
-                           new_mem_size/K);
-  }
   return successful;
 }
 
@@ -1722,6 +1720,13 @@
   MemRegion mr = _hrs.shrink_by(aligned_shrink_bytes, &num_regions_deleted);
   HeapWord* old_end = (HeapWord*) _g1_storage.high();
   assert(mr.end() == old_end, "post-condition");
+
+  ergo_verbose3(ErgoHeapSizing,
+                "shrink the heap",
+                ergo_format_byte("requested shrinking amount")
+                ergo_format_byte("aligned shrinking amount")
+                ergo_format_byte("attempted shrinking amount"),
+                shrink_bytes, aligned_shrink_bytes, mr.byte_size());
   if (mr.byte_size() > 0) {
     if (_hr_printer.is_active()) {
       HeapWord* curr = mr.end();
@@ -1740,13 +1745,11 @@
     _expansion_regions += num_regions_deleted;
     update_committed_space(old_end, new_end);
     HeapRegionRemSet::shrink_heap(n_regions());
-
-    if (Verbose && PrintGC) {
-      size_t new_mem_size = _g1_storage.committed_size();
-      gclog_or_tty->print_cr("Shrinking garbage-first heap from %ldK by %ldK to %ldK",
-                             old_mem_size/K, aligned_shrink_bytes/K,
-                             new_mem_size/K);
-    }
+    g1_policy()->record_new_heap_size(n_regions());
+  } else {
+    ergo_verbose0(ErgoHeapSizing,
+                  "did not shrink the heap",
+                  ergo_format_reason("heap shrinking operation failed"));
   }
 }
 
@@ -1781,14 +1784,17 @@
   _g1_policy(policy_),
   _dirty_card_queue_set(false),
   _into_cset_dirty_card_queue_set(false),
-  _is_alive_closure(this),
-  _ref_processor(NULL),
+  _is_alive_closure_cm(this),
+  _is_alive_closure_stw(this),
+  _ref_processor_cm(NULL),
+  _ref_processor_stw(NULL),
   _process_strong_tasks(new SubTasksDone(G1H_PS_NumElements)),
   _bot_shared(NULL),
   _objs_with_preserved_marks(NULL), _preserved_marks_of_objs(NULL),
   _evac_failure_scan_stack(NULL) ,
   _mark_in_progress(false),
   _cg1r(NULL), _summary_bytes_used(0),
+  _g1mm(NULL),
   _refine_cte_cl(NULL),
   _full_collection(false),
   _free_list("Master Free List"),
@@ -1964,7 +1970,7 @@
 
   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
   guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
-  guarantee((size_t) HeapRegion::CardsPerRegion < max_cards_per_region,
+  guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
             "too many cards per region");
 
   HeapRegionSet::set_unrealistically_long_length(max_regions() + 1);
@@ -2005,8 +2011,6 @@
   // Perform any initialization actions delegated to the policy.
   g1_policy()->init();
 
-  g1_policy()->note_start_of_mark_thread();
-
   _refine_cte_cl =
     new RefineCardTableEntryClosure(ConcurrentG1RefineThread::sts(),
                                     g1_rem_set(),
@@ -2068,7 +2072,7 @@
 
   // Do create of the monitoring and management support so that
   // values in the heap have been properly initialized.
-  _g1mm = new G1MonitoringSupport(this, &_g1_storage);
+  _g1mm = new G1MonitoringSupport(this);
 
   return JNI_OK;
 }
@@ -2076,34 +2080,81 @@
 void G1CollectedHeap::ref_processing_init() {
   // Reference processing in G1 currently works as follows:
   //
-  // * There is only one reference processor instance that
-  //   'spans' the entire heap. It is created by the code
-  //   below.
-  // * Reference discovery is not enabled during an incremental
-  //   pause (see 6484982).
-  // * Discoverered refs are not enqueued nor are they processed
-  //   during an incremental pause (see 6484982).
-  // * Reference discovery is enabled at initial marking.
-  // * Reference discovery is disabled and the discovered
-  //   references processed etc during remarking.
-  // * Reference discovery is MT (see below).
-  // * Reference discovery requires a barrier (see below).
-  // * Reference processing is currently not MT (see 6608385).
-  // * A full GC enables (non-MT) reference discovery and
-  //   processes any discovered references.
+  // * There are two reference processor instances. One is
+  //   used to record and process discovered references
+  //   during concurrent marking; the other is used to
+  //   record and process references during STW pauses
+  //   (both full and incremental).
+  // * Both ref processors need to 'span' the entire heap as
+  //   the regions in the collection set may be dotted around.
+  //
+  // * For the concurrent marking ref processor:
+  //   * Reference discovery is enabled at initial marking.
+  //   * Reference discovery is disabled and the discovered
+  //     references processed etc during remarking.
+  //   * Reference discovery is MT (see below).
+  //   * Reference discovery requires a barrier (see below).
+  //   * Reference processing may or may not be MT
+  //     (depending on the value of ParallelRefProcEnabled
+  //     and ParallelGCThreads).
+  //   * A full GC disables reference discovery by the CM
+  //     ref processor and abandons any entries on it's
+  //     discovered lists.
+  //
+  // * For the STW processor:
+  //   * Non MT discovery is enabled at the start of a full GC.
+  //   * Processing and enqueueing during a full GC is non-MT.
+  //   * During a full GC, references are processed after marking.
+  //
+  //   * Discovery (may or may not be MT) is enabled at the start
+  //     of an incremental evacuation pause.
+  //   * References are processed near the end of a STW evacuation pause.
+  //   * For both types of GC:
+  //     * Discovery is atomic - i.e. not concurrent.
+  //     * Reference discovery will not need a barrier.
 
   SharedHeap::ref_processing_init();
   MemRegion mr = reserved_region();
-  _ref_processor =
+
+  // Concurrent Mark ref processor
+  _ref_processor_cm =
     new ReferenceProcessor(mr,    // span
-                           ParallelRefProcEnabled && (ParallelGCThreads > 1),    // mt processing
-                           (int) ParallelGCThreads,   // degree of mt processing
-                           ParallelGCThreads > 1 || ConcGCThreads > 1,  // mt discovery
-                           (int) MAX2(ParallelGCThreads, ConcGCThreads), // degree of mt discovery
-                           false,                     // Reference discovery is not atomic
-                           &_is_alive_closure,        // is alive closure for efficiency
-                           true);                     // Setting next fields of discovered
-                                                      // lists requires a barrier.
+                           ParallelRefProcEnabled && (ParallelGCThreads > 1),
+                                // mt processing
+                           (int) ParallelGCThreads,
+                                // degree of mt processing
+                           (ParallelGCThreads > 1) || (ConcGCThreads > 1),
+                                // mt discovery
+                           (int) MAX2(ParallelGCThreads, ConcGCThreads),
+                                // degree of mt discovery
+                           false,
+                                // Reference discovery is not atomic
+                           &_is_alive_closure_cm,
+                                // is alive closure
+                                // (for efficiency/performance)
+                           true);
+                                // Setting next fields of discovered
+                                // lists requires a barrier.
+
+  // STW ref processor
+  _ref_processor_stw =
+    new ReferenceProcessor(mr,    // span
+                           ParallelRefProcEnabled && (ParallelGCThreads > 1),
+                                // mt processing
+                           MAX2((int)ParallelGCThreads, 1),
+                                // degree of mt processing
+                           (ParallelGCThreads > 1),
+                                // mt discovery
+                           MAX2((int)ParallelGCThreads, 1),
+                                // degree of mt discovery
+                           true,
+                                // Reference discovery is atomic
+                           &_is_alive_closure_stw,
+                                // is alive closure
+                                // (for efficiency/performance)
+                           false);
+                                // Setting next fields of discovered
+                                // lists requires a barrier.
 }
 
 size_t G1CollectedHeap::capacity() const {
@@ -2997,8 +3048,7 @@
             _g1_storage.high(),
             _g1_storage.high_boundary());
   st->cr();
-  st->print("  region size " SIZE_FORMAT "K, ",
-            HeapRegion::GrainBytes/K);
+  st->print("  region size " SIZE_FORMAT "K, ", HeapRegion::GrainBytes / K);
   size_t young_regions = _young_list->length();
   st->print(SIZE_FORMAT " young (" SIZE_FORMAT "K), ",
             young_regions, young_regions * HeapRegion::GrainBytes / K);
@@ -3126,6 +3176,10 @@
   COMPILER2_PRESENT(assert(DerivedPointerTable::is_empty(),
                         "derived pointer present"));
   // always_do_update_barrier = true;
+
+  // We have just completed a GC. Update the soft reference
+  // policy with the new heap occupancy
+  Universe::update_heap_info_at_gc();
 }
 
 HeapWord* G1CollectedHeap::do_collection_pause(size_t word_size,
@@ -3307,6 +3361,14 @@
     // for the duration of this pause.
     g1_policy()->decide_on_conc_mark_initiation();
 
+    // We do not allow initial-mark to be piggy-backed on a
+    // partially-young GC.
+    assert(!g1_policy()->during_initial_mark_pause() ||
+            g1_policy()->full_young_gcs(), "sanity");
+
+    // We also do not allow partially-young GCs during marking.
+    assert(!mark_in_progress() || g1_policy()->full_young_gcs(), "sanity");
+
     char verbose_str[128];
     sprintf(verbose_str, "GC pause ");
     if (g1_policy()->full_young_gcs()) {
@@ -3363,222 +3425,248 @@
 
       COMPILER2_PRESENT(DerivedPointerTable::clear());
 
-      // Please see comment in G1CollectedHeap::ref_processing_init()
-      // to see how reference processing currently works in G1.
-      //
-      // We want to turn off ref discovery, if necessary, and turn it back on
-      // on again later if we do. XXX Dubious: why is discovery disabled?
-      bool was_enabled = ref_processor()->discovery_enabled();
-      if (was_enabled) ref_processor()->disable_discovery();
-
-      // Forget the current alloc region (we might even choose it to be part
-      // of the collection set!).
-      release_mutator_alloc_region();
-
-      // We should call this after we retire the mutator alloc
-      // region(s) so that all the ALLOC / RETIRE events are generated
-      // before the start GC event.
-      _hr_printer.start_gc(false /* full */, (size_t) total_collections());
-
-      // The elapsed time induced by the start time below deliberately elides
-      // the possible verification above.
-      double start_time_sec = os::elapsedTime();
-      size_t start_used_bytes = used();
+      // Please see comment in g1CollectedHeap.hpp and
+      // G1CollectedHeap::ref_processing_init() to see how
+      // reference processing currently works in G1.
+
+      // Enable discovery in the STW reference processor
+      ref_processor_stw()->enable_discovery(true /*verify_disabled*/,
+                                            true /*verify_no_refs*/);
+
+      {
+        // We want to temporarily turn off discovery by the
+        // CM ref processor, if necessary, and turn it back on
+        // on again later if we do. Using a scoped
+        // NoRefDiscovery object will do this.
+        NoRefDiscovery no_cm_discovery(ref_processor_cm());
+
+        // Forget the current alloc region (we might even choose it to be part
+        // of the collection set!).
+        release_mutator_alloc_region();
+
+        // We should call this after we retire the mutator alloc
+        // region(s) so that all the ALLOC / RETIRE events are generated
+        // before the start GC event.
+        _hr_printer.start_gc(false /* full */, (size_t) total_collections());
+
+        // The elapsed time induced by the start time below deliberately elides
+        // the possible verification above.
+        double start_time_sec = os::elapsedTime();
+        size_t start_used_bytes = used();
 
 #if YOUNG_LIST_VERBOSE
-      gclog_or_tty->print_cr("\nBefore recording pause start.\nYoung_list:");
-      _young_list->print();
-      g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
+        gclog_or_tty->print_cr("\nBefore recording pause start.\nYoung_list:");
+        _young_list->print();
+        g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
 #endif // YOUNG_LIST_VERBOSE
 
-      g1_policy()->record_collection_pause_start(start_time_sec,
-                                                 start_used_bytes);
+        g1_policy()->record_collection_pause_start(start_time_sec,
+                                                   start_used_bytes);
 
 #if YOUNG_LIST_VERBOSE
-      gclog_or_tty->print_cr("\nAfter recording pause start.\nYoung_list:");
-      _young_list->print();
+        gclog_or_tty->print_cr("\nAfter recording pause start.\nYoung_list:");
+        _young_list->print();
 #endif // YOUNG_LIST_VERBOSE
 
-      if (g1_policy()->during_initial_mark_pause()) {
-        concurrent_mark()->checkpointRootsInitialPre();
-      }
-      perm_gen()->save_marks();
-
-      // We must do this before any possible evacuation that should propagate
-      // marks.
-      if (mark_in_progress()) {
-        double start_time_sec = os::elapsedTime();
-
-        _cm->drainAllSATBBuffers();
-        double finish_mark_ms = (os::elapsedTime() - start_time_sec) * 1000.0;
-        g1_policy()->record_satb_drain_time(finish_mark_ms);
-      }
-      // Record the number of elements currently on the mark stack, so we
-      // only iterate over these.  (Since evacuation may add to the mark
-      // stack, doing more exposes race conditions.)  If no mark is in
-      // progress, this will be zero.
-      _cm->set_oops_do_bound();
-
-      if (mark_in_progress()) {
-        concurrent_mark()->newCSet();
-      }
+        if (g1_policy()->during_initial_mark_pause()) {
+          concurrent_mark()->checkpointRootsInitialPre();
+        }
+        perm_gen()->save_marks();
+
+        // We must do this before any possible evacuation that should propagate
+        // marks.
+        if (mark_in_progress()) {
+          double start_time_sec = os::elapsedTime();
+
+          _cm->drainAllSATBBuffers();
+          double finish_mark_ms = (os::elapsedTime() - start_time_sec) * 1000.0;
+          g1_policy()->record_satb_drain_time(finish_mark_ms);
+        }
+        // Record the number of elements currently on the mark stack, so we
+        // only iterate over these.  (Since evacuation may add to the mark
+        // stack, doing more exposes race conditions.)  If no mark is in
+        // progress, this will be zero.
+        _cm->set_oops_do_bound();
+
+        if (mark_in_progress()) {
+          concurrent_mark()->newCSet();
+        }
 
 #if YOUNG_LIST_VERBOSE
-      gclog_or_tty->print_cr("\nBefore choosing collection set.\nYoung_list:");
-      _young_list->print();
-      g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
+        gclog_or_tty->print_cr("\nBefore choosing collection set.\nYoung_list:");
+        _young_list->print();
+        g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
 #endif // YOUNG_LIST_VERBOSE
 
-      g1_policy()->choose_collection_set(target_pause_time_ms);
-
-      if (_hr_printer.is_active()) {
-        HeapRegion* hr = g1_policy()->collection_set();
-        while (hr != NULL) {
-          G1HRPrinter::RegionType type;
-          if (!hr->is_young()) {
-            type = G1HRPrinter::Old;
-          } else if (hr->is_survivor()) {
-            type = G1HRPrinter::Survivor;
-          } else {
-            type = G1HRPrinter::Eden;
+        g1_policy()->choose_collection_set(target_pause_time_ms);
+
+        if (_hr_printer.is_active()) {
+          HeapRegion* hr = g1_policy()->collection_set();
+          while (hr != NULL) {
+            G1HRPrinter::RegionType type;
+            if (!hr->is_young()) {
+              type = G1HRPrinter::Old;
+            } else if (hr->is_survivor()) {
+              type = G1HRPrinter::Survivor;
+            } else {
+              type = G1HRPrinter::Eden;
+            }
+            _hr_printer.cset(hr);
+            hr = hr->next_in_collection_set();
           }
-          _hr_printer.cset(hr);
-          hr = hr->next_in_collection_set();
         }
-      }
-
-      // We have chosen the complete collection set. If marking is
-      // active then, we clear the region fields of any of the
-      // concurrent marking tasks whose region fields point into
-      // the collection set as these values will become stale. This
-      // will cause the owning marking threads to claim a new region
-      // when marking restarts.
-      if (mark_in_progress()) {
-        concurrent_mark()->reset_active_task_region_fields_in_cset();
-      }
+
+        // We have chosen the complete collection set. If marking is
+        // active then, we clear the region fields of any of the
+        // concurrent marking tasks whose region fields point into
+        // the collection set as these values will become stale. This
+        // will cause the owning marking threads to claim a new region
+        // when marking restarts.
+        if (mark_in_progress()) {
+          concurrent_mark()->reset_active_task_region_fields_in_cset();
+        }
 
 #ifdef ASSERT
-      VerifyCSetClosure cl;
-      collection_set_iterate(&cl);
+        VerifyCSetClosure cl;
+        collection_set_iterate(&cl);
 #endif // ASSERT
 
-      setup_surviving_young_words();
-
-      // Initialize the GC alloc regions.
-      init_gc_alloc_regions();
-
-      // Actually do the work...
-      evacuate_collection_set();
-
-      free_collection_set(g1_policy()->collection_set());
-      g1_policy()->clear_collection_set();
-
-      cleanup_surviving_young_words();
-
-      // Start a new incremental collection set for the next pause.
-      g1_policy()->start_incremental_cset_building();
-
-      // Clear the _cset_fast_test bitmap in anticipation of adding
-      // regions to the incremental collection set for the next
-      // evacuation pause.
-      clear_cset_fast_test();
-
-      _young_list->reset_sampled_info();
-
-      // Don't check the whole heap at this point as the
-      // GC alloc regions from this pause have been tagged
-      // as survivors and moved on to the survivor list.
-      // Survivor regions will fail the !is_young() check.
-      assert(check_young_list_empty(false /* check_heap */),
-        "young list should be empty");
+        setup_surviving_young_words();
+
+        // Initialize the GC alloc regions.
+        init_gc_alloc_regions();
+
+        // Actually do the work...
+        evacuate_collection_set();
+
+        free_collection_set(g1_policy()->collection_set());
+        g1_policy()->clear_collection_set();
+
+        cleanup_surviving_young_words();
+
+        // Start a new incremental collection set for the next pause.
+        g1_policy()->start_incremental_cset_building();
+
+        // Clear the _cset_fast_test bitmap in anticipation of adding
+        // regions to the incremental collection set for the next
+        // evacuation pause.
+        clear_cset_fast_test();
+
+        _young_list->reset_sampled_info();
+
+        // Don't check the whole heap at this point as the
+        // GC alloc regions from this pause have been tagged
+        // as survivors and moved on to the survivor list.
+        // Survivor regions will fail the !is_young() check.
+        assert(check_young_list_empty(false /* check_heap */),
+          "young list should be empty");
 
 #if YOUNG_LIST_VERBOSE
-      gclog_or_tty->print_cr("Before recording survivors.\nYoung List:");
-      _young_list->print();
+        gclog_or_tty->print_cr("Before recording survivors.\nYoung List:");
+        _young_list->print();
 #endif // YOUNG_LIST_VERBOSE
 
-      g1_policy()->record_survivor_regions(_young_list->survivor_length(),
-        _young_list->first_survivor_region(),
-        _young_list->last_survivor_region());
-
-      _young_list->reset_auxilary_lists();
-
-      if (evacuation_failed()) {
-        _summary_bytes_used = recalculate_used();
-      } else {
-        // The "used" of the the collection set have already been subtracted
-        // when they were freed.  Add in the bytes evacuated.
-        _summary_bytes_used += g1_policy()->bytes_copied_during_gc();
-      }
-
-      if (g1_policy()->during_initial_mark_pause()) {
-        concurrent_mark()->checkpointRootsInitialPost();
-        set_marking_started();
-        // CAUTION: after the doConcurrentMark() call below,
-        // the concurrent marking thread(s) could be running
-        // concurrently with us. Make sure that anything after
-        // this point does not assume that we are the only GC thread
-        // running. Note: of course, the actual marking work will
-        // not start until the safepoint itself is released in
-        // ConcurrentGCThread::safepoint_desynchronize().
-        doConcurrentMark();
-      }
-
-      allocate_dummy_regions();
+        g1_policy()->record_survivor_regions(_young_list->survivor_length(),
+                                            _young_list->first_survivor_region(),
+                                            _young_list->last_survivor_region());
+
+        _young_list->reset_auxilary_lists();
+
+        if (evacuation_failed()) {
+          _summary_bytes_used = recalculate_used();
+        } else {
+          // The "used" of the the collection set have already been subtracted
+          // when they were freed.  Add in the bytes evacuated.
+          _summary_bytes_used += g1_policy()->bytes_copied_during_gc();
+        }
+
+        if (g1_policy()->during_initial_mark_pause()) {
+          concurrent_mark()->checkpointRootsInitialPost();
+          set_marking_started();
+          // CAUTION: after the doConcurrentMark() call below,
+          // the concurrent marking thread(s) could be running
+          // concurrently with us. Make sure that anything after
+          // this point does not assume that we are the only GC thread
+          // running. Note: of course, the actual marking work will
+          // not start until the safepoint itself is released in
+          // ConcurrentGCThread::safepoint_desynchronize().
+          doConcurrentMark();
+        }
+
+        allocate_dummy_regions();
 
 #if YOUNG_LIST_VERBOSE
-      gclog_or_tty->print_cr("\nEnd of the pause.\nYoung_list:");
-      _young_list->print();
-      g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
+        gclog_or_tty->print_cr("\nEnd of the pause.\nYoung_list:");
+        _young_list->print();
+        g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty);
 #endif // YOUNG_LIST_VERBOSE
 
-      init_mutator_alloc_region();
-
-      double end_time_sec = os::elapsedTime();
-      double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS;
-      g1_policy()->record_pause_time_ms(pause_time_ms);
-      g1_policy()->record_collection_pause_end();
-
-      MemoryService::track_memory_usage();
-
-      // In prepare_for_verify() below we'll need to scan the deferred
-      // update buffers to bring the RSets up-to-date if
-      // G1HRRSFlushLogBuffersOnVerify has been set. While scanning
-      // the update buffers we'll probably need to scan cards on the
-      // regions we just allocated to (i.e., the GC alloc
-      // regions). However, during the last GC we called
-      // set_saved_mark() on all the GC alloc regions, so card
-      // scanning might skip the [saved_mark_word()...top()] area of
-      // those regions (i.e., the area we allocated objects into
-      // during the last GC). But it shouldn't. Given that
-      // saved_mark_word() is conditional on whether the GC time stamp
-      // on the region is current or not, by incrementing the GC time
-      // stamp here we invalidate all the GC time stamps on all the
-      // regions and saved_mark_word() will simply return top() for
-      // all the regions. This is a nicer way of ensuring this rather
-      // than iterating over the regions and fixing them. In fact, the
-      // GC time stamp increment here also ensures that
-      // saved_mark_word() will return top() between pauses, i.e.,
-      // during concurrent refinement. So we don't need the
-      // is_gc_active() check to decided which top to use when
-      // scanning cards (see CR 7039627).
-      increment_gc_time_stamp();
-
-      if (VerifyAfterGC && total_collections() >= VerifyGCStartAt) {
-        HandleMark hm;  // Discard invalid handles created during verification
-        gclog_or_tty->print(" VerifyAfterGC:");
-        prepare_for_verify();
-        Universe::verify(/* allow dirty */ true,
-                         /* silent      */ false,
-                         /* option      */ VerifyOption_G1UsePrevMarking);
+        init_mutator_alloc_region();
+
+        {
+          size_t expand_bytes = g1_policy()->expansion_amount();
+          if (expand_bytes > 0) {
+            size_t bytes_before = capacity();
+            if (!expand(expand_bytes)) {
+              // We failed to expand the heap so let's verify that
+              // committed/uncommitted amount match the backing store
+              assert(capacity() == _g1_storage.committed_size(), "committed size mismatch");
+              assert(max_capacity() == _g1_storage.reserved_size(), "reserved size mismatch");
+            }
+          }
+        }
+
+        double end_time_sec = os::elapsedTime();
+        double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS;
+        g1_policy()->record_pause_time_ms(pause_time_ms);
+        g1_policy()->record_collection_pause_end();
+
+        MemoryService::track_memory_usage();
+
+        // In prepare_for_verify() below we'll need to scan the deferred
+        // update buffers to bring the RSets up-to-date if
+        // G1HRRSFlushLogBuffersOnVerify has been set. While scanning
+        // the update buffers we'll probably need to scan cards on the
+        // regions we just allocated to (i.e., the GC alloc
+        // regions). However, during the last GC we called
+        // set_saved_mark() on all the GC alloc regions, so card
+        // scanning might skip the [saved_mark_word()...top()] area of
+        // those regions (i.e., the area we allocated objects into
+        // during the last GC). But it shouldn't. Given that
+        // saved_mark_word() is conditional on whether the GC time stamp
+        // on the region is current or not, by incrementing the GC time
+        // stamp here we invalidate all the GC time stamps on all the
+        // regions and saved_mark_word() will simply return top() for
+        // all the regions. This is a nicer way of ensuring this rather
+        // than iterating over the regions and fixing them. In fact, the
+        // GC time stamp increment here also ensures that
+        // saved_mark_word() will return top() between pauses, i.e.,
+        // during concurrent refinement. So we don't need the
+        // is_gc_active() check to decided which top to use when
+        // scanning cards (see CR 7039627).
+        increment_gc_time_stamp();
+
+        if (VerifyAfterGC && total_collections() >= VerifyGCStartAt) {
+          HandleMark hm;  // Discard invalid handles created during verification
+          gclog_or_tty->print(" VerifyAfterGC:");
+          prepare_for_verify();
+          Universe::verify(/* allow dirty */ true,
+                           /* silent      */ false,
+                           /* option      */ VerifyOption_G1UsePrevMarking);
+        }
+
+        assert(!ref_processor_stw()->discovery_enabled(), "Postcondition");
+        ref_processor_stw()->verify_no_references_recorded();
+
+        // CM reference discovery will be re-enabled if necessary.
       }
 
-      if (was_enabled) ref_processor()->enable_discovery();
-
       {
         size_t expand_bytes = g1_policy()->expansion_amount();
         if (expand_bytes > 0) {
           size_t bytes_before = capacity();
+          // No need for an ergo verbose message here,
+          // expansion_amount() does this when it returns a value > 0.
           if (!expand(expand_bytes)) {
             // We failed to expand the heap so let's verify that
             // committed/uncommitted amount match the backing store
@@ -3624,7 +3712,7 @@
   if (PrintHeapAtGC) {
     Universe::print_heap_after_gc();
   }
-  g1mm()->update_counters();
+  g1mm()->update_sizes();
 
   if (G1SummarizeRSetStats &&
       (G1SummarizeRSetStatsPeriod > 0) &&
@@ -3722,52 +3810,6 @@
   _evac_failure_scan_stack = NULL;
 }
 
-// *** Sequential G1 Evacuation
-
-class G1IsAliveClosure: public BoolObjectClosure {
-  G1CollectedHeap* _g1;
-public:
-  G1IsAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
-  void do_object(oop p) { assert(false, "Do not call."); }
-  bool do_object_b(oop p) {
-    // It is reachable if it is outside the collection set, or is inside
-    // and forwarded.
-
-#ifdef G1_DEBUG
-    gclog_or_tty->print_cr("is alive "PTR_FORMAT" in CS %d forwarded %d overall %d",
-                           (void*) p, _g1->obj_in_cs(p), p->is_forwarded(),
-                           !_g1->obj_in_cs(p) || p->is_forwarded());
-#endif // G1_DEBUG
-
-    return !_g1->obj_in_cs(p) || p->is_forwarded();
-  }
-};
-
-class G1KeepAliveClosure: public OopClosure {
-  G1CollectedHeap* _g1;
-public:
-  G1KeepAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
-  void do_oop(narrowOop* p) { guarantee(false, "Not needed"); }
-  void do_oop(      oop* p) {
-    oop obj = *p;
-#ifdef G1_DEBUG
-    if (PrintGC && Verbose) {
-      gclog_or_tty->print_cr("keep alive *"PTR_FORMAT" = "PTR_FORMAT" "PTR_FORMAT,
-                             p, (void*) obj, (void*) *p);
-    }
-#endif // G1_DEBUG
-
-    if (_g1->obj_in_cs(obj)) {
-      assert( obj->is_forwarded(), "invariant" );
-      *p = obj->forwardee();
-#ifdef G1_DEBUG
-      gclog_or_tty->print_cr("     in CSet: moved "PTR_FORMAT" -> "PTR_FORMAT,
-                             (void*) obj, (void*) *p);
-#endif // G1_DEBUG
-    }
-  }
-};
-
 class UpdateRSetDeferred : public OopsInHeapRegionClosure {
 private:
   G1CollectedHeap* _g1;
@@ -3916,9 +3958,6 @@
         // _next_top_at_mark_start == top, _next_marked_bytes == 0
         // _next_marked_bytes == next_marked_bytes.
       }
-
-      // Now make sure the region has the right index in the sorted array.
-      g1_policy()->note_change_in_marked_bytes(cur);
     }
     cur = cur->next_in_collection_set();
   }
@@ -3958,7 +3997,8 @@
 
 oop
 G1CollectedHeap::handle_evacuation_failure_par(OopsInHeapRegionClosure* cl,
-                                               oop old) {
+                                               oop old,
+                                               bool should_mark_root) {
   assert(obj_in_cs(old),
          err_msg("obj: "PTR_FORMAT" should still be in the CSet",
                  (HeapWord*) old));
@@ -3966,6 +4006,16 @@
   oop forward_ptr = old->forward_to_atomic(old);
   if (forward_ptr == NULL) {
     // Forward-to-self succeeded.
+
+    // should_mark_root will be true when this routine is called
+    // from a root scanning closure during an initial mark pause.
+    // In this case the thread that succeeds in self-forwarding the
+    // object is also responsible for marking the object.
+    if (should_mark_root) {
+      assert(!oopDesc::is_null(old), "shouldn't be");
+      _cm->grayRoot(old);
+    }
+
     if (_evac_failure_closure != cl) {
       MutexLockerEx x(EvacFailureStack_lock, Mutex::_no_safepoint_check_flag);
       assert(!_drain_in_progress,
@@ -4069,6 +4119,23 @@
 }
 #endif // PRODUCT
 
+G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) :
+  ParGCAllocBuffer(gclab_word_size),
+  _should_mark_objects(false),
+  _bitmap(G1CollectedHeap::heap()->reserved_region().start(), gclab_word_size),
+  _retired(false)
+{
+  //_should_mark_objects is set to true when G1ParCopyHelper needs to
+  // mark the forwarded location of an evacuated object.
+  // We set _should_mark_objects to true if marking is active, i.e. when we
+  // need to propagate a mark, or during an initial mark pause, i.e. when we
+  // need to mark objects immediately reachable by the roots.
+  if (G1CollectedHeap::heap()->mark_in_progress() ||
+      G1CollectedHeap::heap()->g1_policy()->during_initial_mark_pause()) {
+    _should_mark_objects = true;
+  }
+}
+
 G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, int queue_num)
   : _g1h(g1h),
     _refs(g1h->task_queue(queue_num)),
@@ -4170,12 +4237,17 @@
 #endif // ASSERT
 
 void G1ParScanThreadState::trim_queue() {
+  assert(_evac_cl != NULL, "not set");
+  assert(_evac_failure_cl != NULL, "not set");
+  assert(_partial_scan_cl != NULL, "not set");
+
   StarTask ref;
   do {
     // Drain the overflow stack first, so other threads can steal.
     while (refs()->pop_overflow(ref)) {
       deal_with_reference(ref);
     }
+
     while (refs()->pop_local(ref)) {
       deal_with_reference(ref);
     }
@@ -4184,12 +4256,14 @@
 
 G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
   _g1(g1), _g1_rem(_g1->g1_rem_set()), _cm(_g1->concurrent_mark()),
-  _par_scan_state(par_scan_state) { }
-
-template <class T> void G1ParCopyHelper::mark_forwardee(T* p) {
-  // This is called _after_ do_oop_work has been called, hence after
-  // the object has been relocated to its new location and *p points
-  // to its new location.
+  _par_scan_state(par_scan_state),
+  _during_initial_mark(_g1->g1_policy()->during_initial_mark_pause()),
+  _mark_in_progress(_g1->mark_in_progress()) { }
+
+template <class T> void G1ParCopyHelper::mark_object(T* p) {
+  // This is called from do_oop_work for objects that are not
+  // in the collection set. Objects in the collection set
+  // are marked after they have been evacuated.
 
   T heap_oop = oopDesc::load_heap_oop(p);
   if (!oopDesc::is_null(heap_oop)) {
@@ -4201,7 +4275,8 @@
   }
 }
 
-oop G1ParCopyHelper::copy_to_survivor_space(oop old) {
+oop G1ParCopyHelper::copy_to_survivor_space(oop old, bool should_mark_root,
+                                                     bool should_mark_copy) {
   size_t    word_sz = old->size();
   HeapRegion* from_region = _g1->heap_region_containing_raw(old);
   // +1 to make the -1 indexes valid...
@@ -4221,7 +4296,7 @@
     // This will either forward-to-self, or detect that someone else has
     // installed a forwarding pointer.
     OopsInHeapRegionClosure* cl = _par_scan_state->evac_failure_closure();
-    return _g1->handle_evacuation_failure_par(cl, old);
+    return _g1->handle_evacuation_failure_par(cl, old, should_mark_root);
   }
 
   // We're going to allocate linearly, so might as well prefetch ahead.
@@ -4257,8 +4332,8 @@
       obj->set_mark(m);
     }
 
-    // preserve "next" mark bit
-    if (_g1->mark_in_progress() && !_g1->is_obj_ill(old)) {
+    // Mark the evacuated object or propagate "next" mark bit
+    if (should_mark_copy) {
       if (!use_local_bitmaps ||
           !_par_scan_state->alloc_buffer(alloc_purpose)->mark(obj_ptr)) {
         // if we couldn't mark it on the local bitmap (this happens when
@@ -4266,11 +4341,12 @@
         // the bullet and do the standard parallel mark
         _cm->markAndGrayObjectIfNecessary(obj);
       }
-#if 1
+
       if (_g1->isMarkedNext(old)) {
+        // Unmark the object's old location so that marking
+        // doesn't think the old object is alive.
         _cm->nextMarkBitMap()->parClear((HeapWord*)old);
       }
-#endif
     }
 
     size_t* surv_young_words = _par_scan_state->surviving_young_words();
@@ -4293,26 +4369,78 @@
   return obj;
 }
 
-template <bool do_gen_barrier, G1Barrier barrier, bool do_mark_forwardee>
+template <bool do_gen_barrier, G1Barrier barrier, bool do_mark_object>
 template <class T>
-void G1ParCopyClosure <do_gen_barrier, barrier, do_mark_forwardee>
+void G1ParCopyClosure<do_gen_barrier, barrier, do_mark_object>
 ::do_oop_work(T* p) {
   oop obj = oopDesc::load_decode_heap_oop(p);
   assert(barrier != G1BarrierRS || obj != NULL,
          "Precondition: G1BarrierRS implies obj is nonNull");
 
+  // Marking:
+  // If the object is in the collection set, then the thread
+  // that copies the object should mark, or propagate the
+  // mark to, the evacuated object.
+  // If the object is not in the collection set then we
+  // should call the mark_object() method depending on the
+  // value of the template parameter do_mark_object (which will
+  // be true for root scanning closures during an initial mark
+  // pause).
+  // The mark_object() method first checks whether the object
+  // is marked and, if not, attempts to mark the object.
+
   // here the null check is implicit in the cset_fast_test() test
   if (_g1->in_cset_fast_test(obj)) {
     if (obj->is_forwarded()) {
       oopDesc::encode_store_heap_oop(p, obj->forwardee());
+      // If we are a root scanning closure during an initial
+      // mark pause (i.e. do_mark_object will be true) then
+      // we also need to handle marking of roots in the
+      // event of an evacuation failure. In the event of an
+      // evacuation failure, the object is forwarded to itself
+      // and not copied. For root-scanning closures, the
+      // object would be marked after a successful self-forward
+      // but an object could be pointed to by both a root and non
+      // root location and be self-forwarded by a non-root-scanning
+      // closure. Therefore we also have to attempt to mark the
+      // self-forwarded root object here.
+      if (do_mark_object && obj->forwardee() == obj) {
+        mark_object(p);
+      }
     } else {
-      oop copy_oop = copy_to_survivor_space(obj);
+      // During an initial mark pause, objects that are pointed to
+      // by the roots need to be marked - even in the event of an
+      // evacuation failure. We pass the template parameter
+      // do_mark_object (which is true for root scanning closures
+      // during an initial mark pause) to copy_to_survivor_space
+      // which will pass it on to the evacuation failure handling
+      // code. The thread that successfully self-forwards a root
+      // object to itself is responsible for marking the object.
+      bool should_mark_root = do_mark_object;
+
+      // We need to mark the copied object if we're a root scanning
+      // closure during an initial mark pause (i.e. do_mark_object
+      // will be true), or the object is already marked and we need
+      // to propagate the mark to the evacuated copy.
+      bool should_mark_copy = do_mark_object ||
+                              _during_initial_mark ||
+                              (_mark_in_progress && !_g1->is_obj_ill(obj));
+
+      oop copy_oop = copy_to_survivor_space(obj, should_mark_root,
+                                                 should_mark_copy);
       oopDesc::encode_store_heap_oop(p, copy_oop);
     }
     // When scanning the RS, we only care about objs in CS.
     if (barrier == G1BarrierRS) {
       _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num());
     }
+  } else {
+    // The object is not in collection set. If we're a root scanning
+    // closure during an initial mark pause (i.e. do_mark_object will
+    // be true) then attempt to mark the object.
+    if (do_mark_object) {
+      mark_object(p);
+    }
   }
 
   if (barrier == G1BarrierEvac && obj != NULL) {
@@ -4457,35 +4585,34 @@
     ResourceMark rm;
     HandleMark   hm;
 
+    ReferenceProcessor*             rp = _g1h->ref_processor_stw();
+
     G1ParScanThreadState            pss(_g1h, i);
-    G1ParScanHeapEvacClosure        scan_evac_cl(_g1h, &pss);
-    G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss);
-    G1ParScanPartialArrayClosure    partial_scan_cl(_g1h, &pss);
+    G1ParScanHeapEvacClosure        scan_evac_cl(_g1h, &pss, rp);
+    G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, rp);
+    G1ParScanPartialArrayClosure    partial_scan_cl(_g1h, &pss, rp);
 
     pss.set_evac_closure(&scan_evac_cl);
     pss.set_evac_failure_closure(&evac_failure_cl);
     pss.set_partial_scan_closure(&partial_scan_cl);
 
-    G1ParScanExtRootClosure         only_scan_root_cl(_g1h, &pss);
-    G1ParScanPermClosure            only_scan_perm_cl(_g1h, &pss);
-    G1ParScanHeapRSClosure          only_scan_heap_rs_cl(_g1h, &pss);
-    G1ParPushHeapRSClosure          push_heap_rs_cl(_g1h, &pss);
-
-    G1ParScanAndMarkExtRootClosure  scan_mark_root_cl(_g1h, &pss);
-    G1ParScanAndMarkPermClosure     scan_mark_perm_cl(_g1h, &pss);
-    G1ParScanAndMarkHeapRSClosure   scan_mark_heap_rs_cl(_g1h, &pss);
-
-    OopsInHeapRegionClosure        *scan_root_cl;
-    OopsInHeapRegionClosure        *scan_perm_cl;
+    G1ParScanExtRootClosure        only_scan_root_cl(_g1h, &pss, rp);
+    G1ParScanPermClosure           only_scan_perm_cl(_g1h, &pss, rp);
+
+    G1ParScanAndMarkExtRootClosure scan_mark_root_cl(_g1h, &pss, rp);
+    G1ParScanAndMarkPermClosure    scan_mark_perm_cl(_g1h, &pss, rp);
+
+    OopClosure*                    scan_root_cl = &only_scan_root_cl;
+    OopsInHeapRegionClosure*       scan_perm_cl = &only_scan_perm_cl;
 
     if (_g1h->g1_policy()->during_initial_mark_pause()) {
+      // We also need to mark copied objects.
       scan_root_cl = &scan_mark_root_cl;
       scan_perm_cl = &scan_mark_perm_cl;
-    } else {
-      scan_root_cl = &only_scan_root_cl;
-      scan_perm_cl = &only_scan_perm_cl;
     }
 
+    G1ParPushHeapRSClosure          push_heap_rs_cl(_g1h, &pss);
+
     pss.start_strong_roots();
     _g1h->g1_process_strong_roots(/* not collecting perm */ false,
                                   SharedHeap::SO_AllClasses,
@@ -4533,6 +4660,7 @@
                         OopsInHeapRegionClosure* scan_rs,
                         OopsInGenClosure* scan_perm,
                         int worker_i) {
+
   // First scan the strong roots, including the perm gen.
   double ext_roots_start = os::elapsedTime();
   double closure_app_time_sec = 0.0;
@@ -4551,13 +4679,13 @@
                        &eager_scan_code_roots,
                        &buf_scan_perm);
 
-  // Now the ref_processor roots.
+  // Now the CM ref_processor roots.
   if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) {
-    // We need to treat the discovered reference lists as roots and
-    // keep entries (which are added by the marking threads) on them
-    // live until they can be processed at the end of marking.
-    ref_processor()->weak_oops_do(&buf_scan_non_heap_roots);
-    ref_processor()->oops_do(&buf_scan_non_heap_roots);
+    // We need to treat the discovered reference lists of the
+    // concurrent mark ref processor as roots and keep entries
+    // (which are added by the marking threads) on them live
+    // until they can be processed at the end of marking.
+    ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots);
   }
 
   // Finish up any enqueued closure apps (attributed as object copy time).
@@ -4598,6 +4726,524 @@
   SharedHeap::process_weak_roots(root_closure, &roots_in_blobs, non_root_closure);
 }
 
+// Weak Reference Processing support
+
+// An always "is_alive" closure that is used to preserve referents.
+// If the object is non-null then it's alive.  Used in the preservation
+// of referent objects that are pointed to by reference objects
+// discovered by the CM ref processor.
+class G1AlwaysAliveClosure: public BoolObjectClosure {
+  G1CollectedHeap* _g1;
+public:
+  G1AlwaysAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
+  void do_object(oop p) { assert(false, "Do not call."); }
+  bool do_object_b(oop p) {
+    if (p != NULL) {
+      return true;
+    }
+    return false;
+  }
+};
+
+bool G1STWIsAliveClosure::do_object_b(oop p) {
+  // An object is reachable if it is outside the collection set,
+  // or is inside and copied.
+  return !_g1->obj_in_cs(p) || p->is_forwarded();
+}
+
+// Non Copying Keep Alive closure
+class G1KeepAliveClosure: public OopClosure {
+  G1CollectedHeap* _g1;
+public:
+  G1KeepAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
+  void do_oop(narrowOop* p) { guarantee(false, "Not needed"); }
+  void do_oop(      oop* p) {
+    oop obj = *p;
+
+    if (_g1->obj_in_cs(obj)) {
+      assert( obj->is_forwarded(), "invariant" );
+      *p = obj->forwardee();
+    }
+  }
+};
+
+// Copying Keep Alive closure - can be called from both
+// serial and parallel code as long as different worker
+// threads utilize different G1ParScanThreadState instances
+// and different queues.
+
+class G1CopyingKeepAliveClosure: public OopClosure {
+  G1CollectedHeap*         _g1h;
+  OopClosure*              _copy_non_heap_obj_cl;
+  OopsInHeapRegionClosure* _copy_perm_obj_cl;
+  G1ParScanThreadState*    _par_scan_state;
+
+public:
+  G1CopyingKeepAliveClosure(G1CollectedHeap* g1h,
+                            OopClosure* non_heap_obj_cl,
+                            OopsInHeapRegionClosure* perm_obj_cl,
+                            G1ParScanThreadState* pss):
+    _g1h(g1h),
+    _copy_non_heap_obj_cl(non_heap_obj_cl),
+    _copy_perm_obj_cl(perm_obj_cl),
+    _par_scan_state(pss)
+  {}
+
+  virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+  virtual void do_oop(      oop* p) { do_oop_work(p); }
+
+  template <class T> void do_oop_work(T* p) {
+    oop obj = oopDesc::load_decode_heap_oop(p);
+
+    if (_g1h->obj_in_cs(obj)) {
+      // If the referent object has been forwarded (either copied
+      // to a new location or to itself in the event of an
+      // evacuation failure) then we need to update the reference
+      // field and, if both reference and referent are in the G1
+      // heap, update the RSet for the referent.
+      //
+      // If the referent has not been forwarded then we have to keep
+      // it alive by policy. Therefore we have copy the referent.
+      //
+      // If the reference field is in the G1 heap then we can push
+      // on the PSS queue. When the queue is drained (after each
+      // phase of reference processing) the object and it's followers
+      // will be copied, the reference field set to point to the
+      // new location, and the RSet updated. Otherwise we need to
+      // use the the non-heap or perm closures directly to copy
+      // the refernt object and update the pointer, while avoiding
+      // updating the RSet.
+
+      if (_g1h->is_in_g1_reserved(p)) {
+        _par_scan_state->push_on_queue(p);
+      } else {
+        // The reference field is not in the G1 heap.
+        if (_g1h->perm_gen()->is_in(p)) {
+          _copy_perm_obj_cl->do_oop(p);
+        } else {
+          _copy_non_heap_obj_cl->do_oop(p);
+        }
+      }
+    }
+  }
+};
+
+// Serial drain queue closure. Called as the 'complete_gc'
+// closure for each discovered list in some of the
+// reference processing phases.
+
+class G1STWDrainQueueClosure: public VoidClosure {
+protected:
+  G1CollectedHeap* _g1h;
+  G1ParScanThreadState* _par_scan_state;
+
+  G1ParScanThreadState*   par_scan_state() { return _par_scan_state; }
+
+public:
+  G1STWDrainQueueClosure(G1CollectedHeap* g1h, G1ParScanThreadState* pss) :
+    _g1h(g1h),
+    _par_scan_state(pss)
+  { }
+
+  void do_void() {
+    G1ParScanThreadState* const pss = par_scan_state();
+    pss->trim_queue();
+  }
+};
+
+// Parallel Reference Processing closures
+
+// Implementation of AbstractRefProcTaskExecutor for parallel reference
+// processing during G1 evacuation pauses.
+
+class G1STWRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
+private:
+  G1CollectedHeap*   _g1h;
+  RefToScanQueueSet* _queues;
+  WorkGang*          _workers;
+  int                _active_workers;
+
+public:
+  G1STWRefProcTaskExecutor(G1CollectedHeap* g1h,
+                        WorkGang* workers,
+                        RefToScanQueueSet *task_queues,
+                        int n_workers) :
+    _g1h(g1h),
+    _queues(task_queues),
+    _workers(workers),
+    _active_workers(n_workers)
+  {
+    assert(n_workers > 0, "shouldn't call this otherwise");
+  }
+
+  // Executes the given task using concurrent marking worker threads.
+  virtual void execute(ProcessTask& task);
+  virtual void execute(EnqueueTask& task);
+};
+
+// Gang task for possibly parallel reference processing
+
+class G1STWRefProcTaskProxy: public AbstractGangTask {
+  typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
+  ProcessTask&     _proc_task;
+  G1CollectedHeap* _g1h;
+  RefToScanQueueSet *_task_queues;
+  ParallelTaskTerminator* _terminator;
+
+public:
+  G1STWRefProcTaskProxy(ProcessTask& proc_task,
+                     G1CollectedHeap* g1h,
+                     RefToScanQueueSet *task_queues,
+                     ParallelTaskTerminator* terminator) :
+    AbstractGangTask("Process reference objects in parallel"),
+    _proc_task(proc_task),
+    _g1h(g1h),
+    _task_queues(task_queues),
+    _terminator(terminator)
+  {}
+
+  virtual void work(int i) {
+    // The reference processing task executed by a single worker.
+    ResourceMark rm;
+    HandleMark   hm;
+
+    G1STWIsAliveClosure is_alive(_g1h);
+
+    G1ParScanThreadState pss(_g1h, i);
+
+    G1ParScanHeapEvacClosure        scan_evac_cl(_g1h, &pss, NULL);
+    G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, NULL);
+    G1ParScanPartialArrayClosure    partial_scan_cl(_g1h, &pss, NULL);
+
+    pss.set_evac_closure(&scan_evac_cl);
+    pss.set_evac_failure_closure(&evac_failure_cl);
+    pss.set_partial_scan_closure(&partial_scan_cl);
+
+    G1ParScanExtRootClosure        only_copy_non_heap_cl(_g1h, &pss, NULL);
+    G1ParScanPermClosure           only_copy_perm_cl(_g1h, &pss, NULL);
+
+    G1ParScanAndMarkExtRootClosure copy_mark_non_heap_cl(_g1h, &pss, NULL);
+    G1ParScanAndMarkPermClosure    copy_mark_perm_cl(_g1h, &pss, NULL);
+
+    OopClosure*                    copy_non_heap_cl = &only_copy_non_heap_cl;
+    OopsInHeapRegionClosure*       copy_perm_cl = &only_copy_perm_cl;
+
+    if (_g1h->g1_policy()->during_initial_mark_pause()) {
+      // We also need to mark copied objects.
+      copy_non_heap_cl = &copy_mark_non_heap_cl;
+      copy_perm_cl = &copy_mark_perm_cl;
+    }
+
+    // Keep alive closure.
+    G1CopyingKeepAliveClosure keep_alive(_g1h, copy_non_heap_cl, copy_perm_cl, &pss);
+
+    // Complete GC closure
+    G1ParEvacuateFollowersClosure drain_queue(_g1h, &pss, _task_queues, _terminator);
+
+    // Call the reference processing task's work routine.
+    _proc_task.work(i, is_alive, keep_alive, drain_queue);
+
+    // Note we cannot assert that the refs array is empty here as not all
+    // of the processing tasks (specifically phase2 - pp2_work) execute
+    // the complete_gc closure (which ordinarily would drain the queue) so
+    // the queue may not be empty.
+  }
+};
+
+// Driver routine for parallel reference processing.
+// Creates an instance of the ref processing gang
+// task and has the worker threads execute it.
+void G1STWRefProcTaskExecutor::execute(ProcessTask& proc_task) {
+  assert(_workers != NULL, "Need parallel worker threads.");
+
+  ParallelTaskTerminator terminator(_active_workers, _queues);
+  G1STWRefProcTaskProxy proc_task_proxy(proc_task, _g1h, _queues, &terminator);
+
+  _g1h->set_par_threads(_active_workers);
+  _workers->run_task(&proc_task_proxy);
+  _g1h->set_par_threads(0);
+}
+
+// Gang task for parallel reference enqueueing.
+
+class G1STWRefEnqueueTaskProxy: public AbstractGangTask {
+  typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
+  EnqueueTask& _enq_task;
+
+public:
+  G1STWRefEnqueueTaskProxy(EnqueueTask& enq_task) :
+    AbstractGangTask("Enqueue reference objects in parallel"),
+    _enq_task(enq_task)
+  { }
+
+  virtual void work(int i) {
+    _enq_task.work(i);
+  }
+};
+
+// Driver routine for parallel reference enqueing.
+// Creates an instance of the ref enqueueing gang
+// task and has the worker threads execute it.
+
+void G1STWRefProcTaskExecutor::execute(EnqueueTask& enq_task) {
+  assert(_workers != NULL, "Need parallel worker threads.");
+
+  G1STWRefEnqueueTaskProxy enq_task_proxy(enq_task);
+
+  _g1h->set_par_threads(_active_workers);
+  _workers->run_task(&enq_task_proxy);
+  _g1h->set_par_threads(0);
+}
+
+// End of weak reference support closures
+
+// Abstract task used to preserve (i.e. copy) any referent objects
+// that are in the collection set and are pointed to by reference
+// objects discovered by the CM ref processor.
+
+class G1ParPreserveCMReferentsTask: public AbstractGangTask {
+protected:
+  G1CollectedHeap* _g1h;
+  RefToScanQueueSet      *_queues;
+  ParallelTaskTerminator _terminator;
+  int _n_workers;
+
+public:
+  G1ParPreserveCMReferentsTask(G1CollectedHeap* g1h,int workers, RefToScanQueueSet *task_queues) :
+    AbstractGangTask("ParPreserveCMReferents"),
+    _g1h(g1h),
+    _queues(task_queues),
+    _terminator(workers, _queues),
+    _n_workers(workers)
+  { }
+
+  void work(int i) {
+    ResourceMark rm;
+    HandleMark   hm;
+
+    G1ParScanThreadState            pss(_g1h, i);
+    G1ParScanHeapEvacClosure        scan_evac_cl(_g1h, &pss, NULL);
+    G1ParScanHeapEvacFailureClosure evac_failure_cl(_g1h, &pss, NULL);
+    G1ParScanPartialArrayClosure    partial_scan_cl(_g1h, &pss, NULL);
+
+    pss.set_evac_closure(&scan_evac_cl);
+    pss.set_evac_failure_closure(&evac_failure_cl);
+    pss.set_partial_scan_closure(&partial_scan_cl);
+
+    assert(pss.refs()->is_empty(), "both queue and overflow should be empty");
+
+
+    G1ParScanExtRootClosure        only_copy_non_heap_cl(_g1h, &pss, NULL);
+    G1ParScanPermClosure           only_copy_perm_cl(_g1h, &pss, NULL);
+
+    G1ParScanAndMarkExtRootClosure copy_mark_non_heap_cl(_g1h, &pss, NULL);
+    G1ParScanAndMarkPermClosure    copy_mark_perm_cl(_g1h, &pss, NULL);
+
+    OopClosure*                    copy_non_heap_cl = &only_copy_non_heap_cl;
+    OopsInHeapRegionClosure*       copy_perm_cl = &only_copy_perm_cl;
+
+    if (_g1h->g1_policy()->during_initial_mark_pause()) {
+      // We also need to mark copied objects.
+      copy_non_heap_cl = &copy_mark_non_heap_cl;
+      copy_perm_cl = &copy_mark_perm_cl;
+    }
+
+    // Is alive closure
+    G1AlwaysAliveClosure always_alive(_g1h);
+
+    // Copying keep alive closure. Applied to referent objects that need
+    // to be copied.
+    G1CopyingKeepAliveClosure keep_alive(_g1h, copy_non_heap_cl, copy_perm_cl, &pss);
+
+    ReferenceProcessor* rp = _g1h->ref_processor_cm();
+
+    int limit = ReferenceProcessor::number_of_subclasses_of_ref() * rp->max_num_q();
+    int stride = MIN2(MAX2(_n_workers, 1), limit);
+
+    // limit is set using max_num_q() - which was set using ParallelGCThreads.
+    // So this must be true - but assert just in case someone decides to
+    // change the worker ids.
+    assert(0 <= i && i < limit, "sanity");
+    assert(!rp->discovery_is_atomic(), "check this code");
+
+    // Select discovered lists [i, i+stride, i+2*stride,...,limit)
+    for (int idx = i; idx < limit; idx += stride) {
+      DiscoveredList& ref_list = rp->discovered_refs()[idx];
+
+      DiscoveredListIterator iter(ref_list, &keep_alive, &always_alive);
+      while (iter.has_next()) {
+        // Since discovery is not atomic for the CM ref processor, we
+        // can see some null referent objects.
+        iter.load_ptrs(DEBUG_ONLY(true));
+        oop ref = iter.obj();
+
+        // This will filter nulls.
+        if (iter.is_referent_alive()) {
+          iter.make_referent_alive();
+        }
+        iter.move_to_next();
+      }
+    }
+
+    // Drain the queue - which may cause stealing
+    G1ParEvacuateFollowersClosure drain_queue(_g1h, &pss, _queues, &_terminator);
+    drain_queue.do_void();
+    // Allocation buffers were retired at the end of G1ParEvacuateFollowersClosure
+    assert(pss.refs()->is_empty(), "should be");
+  }
+};
+
+// Weak Reference processing during an evacuation pause (part 1).
+void G1CollectedHeap::process_discovered_references() {
+  double ref_proc_start = os::elapsedTime();
+
+  ReferenceProcessor* rp = _ref_processor_stw;
+  assert(rp->discovery_enabled(), "should have been enabled");
+
+  // Any reference objects, in the collection set, that were 'discovered'
+  // by the CM ref processor should have already been copied (either by
+  // applying the external root copy closure to the discovered lists, or
+  // by following an RSet entry).
+  //
+  // But some of the referents, that are in the collection set, that these
+  // reference objects point to may not have been copied: the STW ref
+  // processor would have seen that the reference object had already
+  // been 'discovered' and would have skipped discovering the reference,
+  // but would not have treated the reference object as a regular oop.
+  // As a reult the copy closure would not have been applied to the
+  // referent object.
+  //
+  // We need to explicitly copy these referent objects - the references
+  // will be processed at the end of remarking.
+  //
+  // We also need to do this copying before we process the reference
+  // objects discovered by the STW ref processor in case one of these
+  // referents points to another object which is also referenced by an
+  // object discovered by the STW ref processor.
+
+  int n_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
+                        workers()->total_workers() : 1);
+
+  set_par_threads(n_workers);
+  G1ParPreserveCMReferentsTask keep_cm_referents(this, n_workers, _task_queues);
+
+  if (G1CollectedHeap::use_parallel_gc_threads()) {
+    workers()->run_task(&keep_cm_referents);
+  } else {
+    keep_cm_referents.work(0);
+  }
+
+  set_par_threads(0);
+
+  // Closure to test whether a referent is alive.
+  G1STWIsAliveClosure is_alive(this);
+
+  // Even when parallel reference processing is enabled, the processing
+  // of JNI refs is serial and performed serially by the current thread
+  // rather than by a worker. The following PSS will be used for processing
+  // JNI refs.
+
+  // Use only a single queue for this PSS.
+  G1ParScanThreadState pss(this, 0);
+
+  // We do not embed a reference processor in the copying/scanning
+  // closures while we're actually processing the discovered
+  // reference objects.
+  G1ParScanHeapEvacClosure        scan_evac_cl(this, &pss, NULL);
+  G1ParScanHeapEvacFailureClosure evac_failure_cl(this, &pss, NULL);
+  G1ParScanPartialArrayClosure    partial_scan_cl(this, &pss, NULL);
+
+  pss.set_evac_closure(&scan_evac_cl);
+  pss.set_evac_failure_closure(&evac_failure_cl);
+  pss.set_partial_scan_closure(&partial_scan_cl);
+
+  assert(pss.refs()->is_empty(), "pre-condition");
+
+  G1ParScanExtRootClosure        only_copy_non_heap_cl(this, &pss, NULL);
+  G1ParScanPermClosure           only_copy_perm_cl(this, &pss, NULL);
+
+  G1ParScanAndMarkExtRootClosure copy_mark_non_heap_cl(this, &pss, NULL);
+  G1ParScanAndMarkPermClosure    copy_mark_perm_cl(this, &pss, NULL);
+
+  OopClosure*                    copy_non_heap_cl = &only_copy_non_heap_cl;
+  OopsInHeapRegionClosure*       copy_perm_cl = &only_copy_perm_cl;
+
+  if (_g1h->g1_policy()->during_initial_mark_pause()) {
+    // We also need to mark copied objects.
+    copy_non_heap_cl = &copy_mark_non_heap_cl;
+    copy_perm_cl = &copy_mark_perm_cl;
+  }
+
+  // Keep alive closure.
+  G1CopyingKeepAliveClosure keep_alive(this, copy_non_heap_cl, copy_perm_cl, &pss);
+
+  // Serial Complete GC closure
+  G1STWDrainQueueClosure drain_queue(this, &pss);
+
+  // Setup the soft refs policy...
+  rp->setup_policy(false);
+
+  if (!rp->processing_is_mt()) {
+    // Serial reference processing...
+    rp->process_discovered_references(&is_alive,
+                                      &keep_alive,
+                                      &drain_queue,
+                                      NULL);
+  } else {
+    // Parallel reference processing
+    int active_workers = (ParallelGCThreads > 0 ? workers()->total_workers() : 1);
+    assert(rp->num_q() == active_workers, "sanity");
+    assert(active_workers <= rp->max_num_q(), "sanity");
+
+    G1STWRefProcTaskExecutor par_task_executor(this, workers(), _task_queues, active_workers);
+    rp->process_discovered_references(&is_alive, &keep_alive, &drain_queue, &par_task_executor);
+  }
+
+  // We have completed copying any necessary live referent objects
+  // (that were not copied during the actual pause) so we can
+  // retire any active alloc buffers
+  pss.retire_alloc_buffers();
+  assert(pss.refs()->is_empty(), "both queue and overflow should be empty");
+
+  double ref_proc_time = os::elapsedTime() - ref_proc_start;
+  g1_policy()->record_ref_proc_time(ref_proc_time * 1000.0);
+}
+
+// Weak Reference processing during an evacuation pause (part 2).
+void G1CollectedHeap::enqueue_discovered_references() {
+  double ref_enq_start = os::elapsedTime();
+
+  ReferenceProcessor* rp = _ref_processor_stw;
+  assert(!rp->discovery_enabled(), "should have been disabled as part of processing");
+
+  // Now enqueue any remaining on the discovered lists on to
+  // the pending list.
+  if (!rp->processing_is_mt()) {
+    // Serial reference processing...
+    rp->enqueue_discovered_references();
+  } else {
+    // Parallel reference enqueuing
+
+    int active_workers = (ParallelGCThreads > 0 ? workers()->total_workers() : 1);
+    assert(rp->num_q() == active_workers, "sanity");
+    assert(active_workers <= rp->max_num_q(), "sanity");
+
+    G1STWRefProcTaskExecutor par_task_executor(this, workers(), _task_queues, active_workers);
+    rp->enqueue_discovered_references(&par_task_executor);
+  }
+
+  rp->verify_no_references_recorded();
+  assert(!rp->discovery_enabled(), "should have been disabled");
+
+  // FIXME
+  // CM's reference processing also cleans up the string and symbol tables.
+  // Should we do that here also? We could, but it is a serial operation
+  // and could signicantly increase the pause time.
+
+  double ref_enq_time = os::elapsedTime() - ref_enq_start;
+  g1_policy()->record_ref_enq_time(ref_enq_time * 1000.0);
+}
+
 void G1CollectedHeap::evacuate_collection_set() {
   set_evacuation_failed(false);
 
@@ -4615,6 +5261,7 @@
 
   assert(dirty_card_queue_set().completed_buffers_num() == 0, "Should be empty");
   double start_par = os::elapsedTime();
+
   if (G1CollectedHeap::use_parallel_gc_threads()) {
     // The individual threads will set their evac-failure closures.
     StrongRootsScope srs(this);
@@ -4629,15 +5276,23 @@
   g1_policy()->record_par_time(par_time);
   set_par_threads(0);
 
+  // Process any discovered reference objects - we have
+  // to do this _before_ we retire the GC alloc regions
+  // as we may have to copy some 'reachable' referent
+  // objects (and their reachable sub-graphs) that were
+  // not copied during the pause.
+  process_discovered_references();
+
   // Weak root processing.
   // Note: when JSR 292 is enabled and code blobs can contain
   // non-perm oops then we will need to process the code blobs
   // here too.
   {
-    G1IsAliveClosure is_alive(this);
+    G1STWIsAliveClosure is_alive(this);
     G1KeepAliveClosure keep_alive(this);
     JNIHandles::weak_oops_do(&is_alive, &keep_alive);
   }
+
   release_gc_alloc_regions();
   g1_rem_set()->cleanup_after_oops_into_collection_set_do();
 
@@ -4659,6 +5314,15 @@
     }
   }
 
+  // Enqueue any remaining references remaining on the STW
+  // reference processor's discovered lists. We need to do
+  // this after the card table is cleaned (and verified) as
+  // the act of enqueuing entries on to the pending list
+  // will log these updates (and dirty their associated
+  // cards). We need these updates logged to update any
+  // RSets.
+  enqueue_discovered_references();
+
   if (G1DeferredRSUpdate) {
     RedirtyLoggedCardTableEntryFastClosure redirty;
     dirty_card_queue_set().set_closure(&redirty);
@@ -4859,7 +5523,7 @@
   }
 
   double elapsed = os::elapsedTime() - start;
-  g1_policy()->record_clear_ct_time( elapsed * 1000.0);
+  g1_policy()->record_clear_ct_time(elapsed * 1000.0);
 #ifndef PRODUCT
   if (G1VerifyCTCleanup || VerifyAfterGC) {
     G1VerifyCardTableCleanup cleanup_verifier(this, ct_bs);
@@ -5150,7 +5814,6 @@
       g1_policy()->update_region_num(true /* next_is_young */);
       set_region_short_lived_locked(new_alloc_region);
       _hr_printer.alloc(new_alloc_region, G1HRPrinter::Eden, young_list_full);
-      g1mm()->update_eden_counters();
       return new_alloc_region;
     }
   }
@@ -5165,6 +5828,10 @@
   g1_policy()->add_region_to_incremental_cset_lhs(alloc_region);
   _summary_bytes_used += allocated_bytes;
   _hr_printer.retire(alloc_region);
+  // We update the eden sizes here, when the region is retired,
+  // instead of when it's allocated, since this is the point that its
+  // used space has been recored in _summary_bytes_used.
+  g1mm()->update_eden_size();
 }
 
 HeapRegion* MutatorAllocRegion::allocate_new_region(size_t word_size,
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -155,6 +155,19 @@
     : G1AllocRegion("Mutator Alloc Region", false /* bot_updates */) { }
 };
 
+// The G1 STW is alive closure.
+// An instance is embedded into the G1CH and used as the
+// (optional) _is_alive_non_header closure in the STW
+// reference processor. It is also extensively used during
+// refence processing during STW evacuation pauses.
+class G1STWIsAliveClosure: public BoolObjectClosure {
+  G1CollectedHeap* _g1;
+public:
+  G1STWIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
+  void do_object(oop p) { assert(false, "Do not call."); }
+  bool do_object_b(oop p);
+};
+
 class SurvivorGCAllocRegion : public G1AllocRegion {
 protected:
   virtual HeapRegion* allocate_new_region(size_t word_size, bool force);
@@ -174,6 +187,7 @@
 };
 
 class RefineCardTableEntryClosure;
+
 class G1CollectedHeap : public SharedHeap {
   friend class VM_G1CollectForAllocation;
   friend class VM_GenCollectForPermanentAllocation;
@@ -573,9 +587,20 @@
   // allocated block, or else "NULL".
   HeapWord* expand_and_allocate(size_t word_size);
 
+  // Process any reference objects discovered during
+  // an incremental evacuation pause.
+  void process_discovered_references();
+
+  // Enqueue any remaining discovered references
+  // after processing.
+  void enqueue_discovered_references();
+
 public:
 
-  G1MonitoringSupport* g1mm() { return _g1mm; }
+  G1MonitoringSupport* g1mm() {
+    assert(_g1mm != NULL, "should have been initialized");
+    return _g1mm;
+  }
 
   // Expand the garbage-first heap by at least the given size (in bytes!).
   // Returns true if the heap was expanded by the requested amount;
@@ -822,17 +847,87 @@
   void finalize_for_evac_failure();
 
   // An attempt to evacuate "obj" has failed; take necessary steps.
-  oop handle_evacuation_failure_par(OopsInHeapRegionClosure* cl, oop obj);
+  oop handle_evacuation_failure_par(OopsInHeapRegionClosure* cl, oop obj,
+                                    bool should_mark_root);
   void handle_evacuation_failure_common(oop obj, markOop m);
 
+  // ("Weak") Reference processing support.
+  //
+  // G1 has 2 instances of the referece processor class. One
+  // (_ref_processor_cm) handles reference object discovery
+  // and subsequent processing during concurrent marking cycles.
+  //
+  // The other (_ref_processor_stw) handles reference object
+  // discovery and processing during full GCs and incremental
+  // evacuation pauses.
+  //
+  // During an incremental pause, reference discovery will be
+  // temporarily disabled for _ref_processor_cm and will be
+  // enabled for _ref_processor_stw. At the end of the evacuation
+  // pause references discovered by _ref_processor_stw will be
+  // processed and discovery will be disabled. The previous
+  // setting for reference object discovery for _ref_processor_cm
+  // will be re-instated.
+  //
+  // At the start of marking:
+  //  * Discovery by the CM ref processor is verified to be inactive
+  //    and it's discovered lists are empty.
+  //  * Discovery by the CM ref processor is then enabled.
+  //
+  // At the end of marking:
+  //  * Any references on the CM ref processor's discovered
+  //    lists are processed (possibly MT).
+  //
+  // At the start of full GC we:
+  //  * Disable discovery by the CM ref processor and
+  //    empty CM ref processor's discovered lists
+  //    (without processing any entries).
+  //  * Verify that the STW ref processor is inactive and it's
+  //    discovered lists are empty.
+  //  * Temporarily set STW ref processor discovery as single threaded.
+  //  * Temporarily clear the STW ref processor's _is_alive_non_header
+  //    field.
+  //  * Finally enable discovery by the STW ref processor.
+  //
+  // The STW ref processor is used to record any discovered
+  // references during the full GC.
+  //
+  // At the end of a full GC we:
+  //  * Enqueue any reference objects discovered by the STW ref processor
+  //    that have non-live referents. This has the side-effect of
+  //    making the STW ref processor inactive by disabling discovery.
+  //  * Verify that the CM ref processor is still inactive
+  //    and no references have been placed on it's discovered
+  //    lists (also checked as a precondition during initial marking).
+
+  // The (stw) reference processor...
+  ReferenceProcessor* _ref_processor_stw;
+
+  // During reference object discovery, the _is_alive_non_header
+  // closure (if non-null) is applied to the referent object to
+  // determine whether the referent is live. If so then the
+  // reference object does not need to be 'discovered' and can
+  // be treated as a regular oop. This has the benefit of reducing
+  // the number of 'discovered' reference objects that need to
+  // be processed.
+  //
+  // Instance of the is_alive closure for embedding into the
+  // STW reference processor as the _is_alive_non_header field.
+  // Supplying a value for the _is_alive_non_header field is
+  // optional but doing so prevents unnecessary additions to
+  // the discovered lists during reference discovery.
+  G1STWIsAliveClosure _is_alive_closure_stw;
+
+  // The (concurrent marking) reference processor...
+  ReferenceProcessor* _ref_processor_cm;
+
   // Instance of the concurrent mark is_alive closure for embedding
-  // into the reference processor as the is_alive_non_header. This
-  // prevents unnecessary additions to the discovered lists during
-  // concurrent discovery.
-  G1CMIsAliveClosure _is_alive_closure;
-
-  // ("Weak") Reference processing support
-  ReferenceProcessor* _ref_processor;
+  // into the Concurrent Marking reference processor as the
+  // _is_alive_non_header field. Supplying a value for the
+  // _is_alive_non_header field is optional but doing so prevents
+  // unnecessary additions to the discovered lists during reference
+  // discovery.
+  G1CMIsAliveClosure _is_alive_closure_cm;
 
   enum G1H_process_strong_roots_tasks {
     G1H_PS_mark_stack_oops_do,
@@ -873,6 +968,7 @@
   // specified by the policy object.
   jint initialize();
 
+  // Initialize weak reference processing.
   virtual void ref_processing_init();
 
   void set_par_threads(int t) {
@@ -924,8 +1020,13 @@
   // The shared block offset table array.
   G1BlockOffsetSharedArray* bot_shared() const { return _bot_shared; }
 
-  // Reference Processing accessor
-  ReferenceProcessor* ref_processor() { return _ref_processor; }
+  // Reference Processing accessors
+
+  // The STW reference processor....
+  ReferenceProcessor* ref_processor_stw() const { return _ref_processor_stw; }
+
+  // The Concurent Marking reference processor...
+  ReferenceProcessor* ref_processor_cm() const { return _ref_processor_cm; }
 
   virtual size_t capacity() const;
   virtual size_t used() const;
@@ -1236,12 +1337,7 @@
   // storage in the heap comes from a young region or not.
   // See ReduceInitialCardMarks.
   virtual bool can_elide_tlab_store_barriers() const {
-    // 6920090: Temporarily disabled, because of lingering
-    // instabilities related to RICM with G1. In the
-    // interim, the option ReduceInitialCardMarksForG1
-    // below is left solely as a debugging device at least
-    // until 6920109 fixes the instabilities.
-    return ReduceInitialCardMarksForG1;
+    return true;
   }
 
   virtual bool card_mark_must_follow_store() const {
@@ -1265,8 +1361,6 @@
   // update logging post-barrier, we don't maintain remembered set
   // information for young gen objects.
   virtual bool can_elide_initializing_store_barrier(oop new_obj) {
-    // Re 6920090, 6920109 above.
-    assert(ReduceInitialCardMarksForG1, "Else cannot be here");
     return is_in_young(new_obj);
   }
 
@@ -1715,26 +1809,22 @@
 class G1ParGCAllocBuffer: public ParGCAllocBuffer {
 private:
   bool        _retired;
-  bool        _during_marking;
+  bool        _should_mark_objects;
   GCLabBitMap _bitmap;
 
 public:
-  G1ParGCAllocBuffer(size_t gclab_word_size) :
-    ParGCAllocBuffer(gclab_word_size),
-    _during_marking(G1CollectedHeap::heap()->mark_in_progress()),
-    _bitmap(G1CollectedHeap::heap()->reserved_region().start(), gclab_word_size),
-    _retired(false)
-  { }
+  G1ParGCAllocBuffer(size_t gclab_word_size);
 
   inline bool mark(HeapWord* addr) {
     guarantee(use_local_bitmaps, "invariant");
-    assert(_during_marking, "invariant");
+    assert(_should_mark_objects, "invariant");
     return _bitmap.mark(addr);
   }
 
   inline void set_buf(HeapWord* buf) {
-    if (use_local_bitmaps && _during_marking)
+    if (use_local_bitmaps && _should_mark_objects) {
       _bitmap.set_buffer(buf);
+    }
     ParGCAllocBuffer::set_buf(buf);
     _retired = false;
   }
@@ -1742,7 +1832,7 @@
   inline void retire(bool end_of_gc, bool retain) {
     if (_retired)
       return;
-    if (use_local_bitmaps && _during_marking) {
+    if (use_local_bitmaps && _should_mark_objects) {
       _bitmap.retire();
     }
     ParGCAllocBuffer::retire(end_of_gc, retain);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -28,6 +28,7 @@
 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
+#include "gc_implementation/g1/g1ErgoVerbose.hpp"
 #include "gc_implementation/g1/heapRegionRemSet.hpp"
 #include "gc_implementation/shared/gcPolicyCounters.hpp"
 #include "runtime/arguments.hpp"
@@ -145,13 +146,18 @@
   _stop_world_start(0.0),
   _all_stop_world_times_ms(new NumberSeq()),
   _all_yield_times_ms(new NumberSeq()),
+  _using_new_ratio_calculations(false),
 
   _all_mod_union_times_ms(new NumberSeq()),
 
   _summary(new Summary()),
 
+  _cur_clear_ct_time_ms(0.0),
+
+  _cur_ref_proc_time_ms(0.0),
+  _cur_ref_enq_time_ms(0.0),
+
 #ifndef PRODUCT
-  _cur_clear_ct_time_ms(0.0),
   _min_clear_cc_time_ms(-1.0),
   _max_clear_cc_time_ms(-1.0),
   _cur_clear_cc_time_ms(0.0),
@@ -219,16 +225,12 @@
   _recent_CS_bytes_surviving(new TruncatedSeq(NumPrevPausesForHeuristics)),
 
   _recent_avg_pause_time_ratio(0.0),
-  _num_markings(0),
-  _n_marks(0),
-  _n_pauses_at_mark_end(0),
 
   _all_full_gc_times_ms(new NumberSeq()),
 
   // G1PausesBtwnConcMark defaults to -1
   // so the hack is to do the cast  QQQ FIXME
   _pauses_btwn_concurrent_mark((size_t)G1PausesBtwnConcMark),
-  _n_marks_since_last_pause(0),
   _initiate_conc_mark_if_possible(false),
   _during_initial_mark_pause(false),
   _should_revert_to_full_young_gcs(false),
@@ -271,20 +273,31 @@
   _recorded_survivor_tail(NULL),
   _survivors_age_table(true),
 
-  _gc_overhead_perc(0.0)
-
-{
+  _gc_overhead_perc(0.0) {
+
   // Set up the region size and associated fields. Given that the
   // policy is created before the heap, we have to set this up here,
   // so it's done as soon as possible.
   HeapRegion::setup_heap_region_size(Arguments::min_heap_size());
   HeapRegionRemSet::setup_remset_size();
 
+  G1ErgoVerbose::initialize();
+  if (PrintAdaptiveSizePolicy) {
+    // Currently, we only use a single switch for all the heuristics.
+    G1ErgoVerbose::set_enabled(true);
+    // Given that we don't currently have a verboseness level
+    // parameter, we'll hardcode this to high. This can be easily
+    // changed in the future.
+    G1ErgoVerbose::set_level(ErgoHigh);
+  } else {
+    G1ErgoVerbose::set_enabled(false);
+  }
+
   // Verify PLAB sizes
-  const uint region_size = HeapRegion::GrainWords;
+  const size_t region_size = HeapRegion::GrainWords;
   if (YoungPLABSize > region_size || OldPLABSize > region_size) {
     char buffer[128];
-    jio_snprintf(buffer, sizeof(buffer), "%sPLABSize should be at most %u",
+    jio_snprintf(buffer, sizeof(buffer), "%sPLABSize should be at most "SIZE_FORMAT,
                  OldPLABSize > region_size ? "Old" : "Young", region_size);
     vm_exit_during_initialization(buffer);
   }
@@ -402,7 +415,7 @@
   _concurrent_mark_cleanup_times_ms->add(0.20);
   _tenuring_threshold = MaxTenuringThreshold;
   // _max_survivor_regions will be calculated by
-  // calculate_young_list_target_length() during initialization.
+  // update_young_list_target_length() during initialization.
   _max_survivor_regions = 0;
 
   assert(GCTimeRatio > 0,
@@ -410,7 +423,20 @@
          "if a user set it to 0");
   _gc_overhead_perc = 100.0 * (1.0 / (1.0 + GCTimeRatio));
 
+  uintx reserve_perc = G1ReservePercent;
+  // Put an artificial ceiling on this so that it's not set to a silly value.
+  if (reserve_perc > 50) {
+    reserve_perc = 50;
+    warning("G1ReservePercent is set to a value that is too large, "
+            "it's been updated to %u", reserve_perc);
+  }
+  _reserve_factor = (double) reserve_perc / 100.0;
+  // This will be set when the heap is expanded
+  // for the first time during initialization.
+  _reserve_regions = 0;
+
   initialize_all();
+  _collectionSetChooser = new CollectionSetChooser();
 }
 
 // Increment "i", mod "len"
@@ -434,6 +460,7 @@
 // ParallelScavengeHeap::initialize()). We might change this in the
 // future, but it's a good start.
 class G1YoungGenSizer : public TwoGenerationCollectorPolicy {
+private:
   size_t size_to_region_num(size_t byte_size) {
     return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes);
   }
@@ -443,7 +470,6 @@
     initialize_flags();
     initialize_size_info();
   }
-
   size_t min_young_region_num() {
     return size_to_region_num(_min_gen0_size);
   }
@@ -455,6 +481,13 @@
   }
 };
 
+void G1CollectorPolicy::update_young_list_size_using_newratio(size_t number_of_heap_regions) {
+  assert(number_of_heap_regions > 0, "Heap must be initialized");
+  size_t young_size = number_of_heap_regions / (NewRatio + 1);
+  _min_desired_young_length = young_size;
+  _max_desired_young_length = young_size;
+}
+
 void G1CollectorPolicy::init() {
   // Set aside an initial future to_space.
   _g1 = G1CollectedHeap::heap();
@@ -465,18 +498,34 @@
 
   G1YoungGenSizer sizer;
   size_t initial_region_num = sizer.initial_young_region_num();
-
-  if (UseAdaptiveSizePolicy) {
-    set_adaptive_young_list_length(true);
+  _min_desired_young_length = sizer.min_young_region_num();
+  _max_desired_young_length = sizer.max_young_region_num();
+
+  if (FLAG_IS_CMDLINE(NewRatio)) {
+    if (FLAG_IS_CMDLINE(NewSize) || FLAG_IS_CMDLINE(MaxNewSize)) {
+      warning("-XX:NewSize and -XX:MaxNewSize override -XX:NewRatio");
+    } else {
+      // Treat NewRatio as a fixed size that is only recalculated when the heap size changes
+      update_young_list_size_using_newratio(_g1->n_regions());
+      _using_new_ratio_calculations = true;
+    }
+  }
+
+  // GenCollectorPolicy guarantees that min <= initial <= max.
+  // Asserting here just to state that we rely on this property.
+  assert(_min_desired_young_length <= _max_desired_young_length, "Invalid min/max young gen size values");
+  assert(initial_region_num <= _max_desired_young_length, "Initial young gen size too large");
+  assert(_min_desired_young_length <= initial_region_num, "Initial young gen size too small");
+
+  set_adaptive_young_list_length(_min_desired_young_length < _max_desired_young_length);
+  if (adaptive_young_list_length()) {
     _young_list_fixed_length = 0;
   } else {
-    set_adaptive_young_list_length(false);
     _young_list_fixed_length = initial_region_num;
   }
   _free_regions_at_end_of_collection = _g1->free_regions();
-  calculate_young_list_min_length();
-  guarantee( _young_list_min_length == 0, "invariant, not enough info" );
-  calculate_young_list_target_length();
+  update_young_list_target_length();
+  _prev_eden_capacity = _young_list_target_length * HeapRegion::GrainBytes;
 
   // We may immediately start allocating regions and placing them on the
   // collection set list. Initialize the per-collection set info
@@ -484,238 +533,261 @@
 }
 
 // Create the jstat counters for the policy.
-void G1CollectorPolicy::initialize_gc_policy_counters()
-{
+void G1CollectorPolicy::initialize_gc_policy_counters() {
   _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3);
 }
 
-void G1CollectorPolicy::calculate_young_list_min_length() {
-  _young_list_min_length = 0;
-
-  if (!adaptive_young_list_length())
-    return;
-
-  if (_alloc_rate_ms_seq->num() > 3) {
-    double now_sec = os::elapsedTime();
-    double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0;
-    double alloc_rate_ms = predict_alloc_rate_ms();
-    size_t min_regions = (size_t) ceil(alloc_rate_ms * when_ms);
-    size_t current_region_num = _g1->young_list()->length();
-    _young_list_min_length = min_regions + current_region_num;
-  }
-}
-
-void G1CollectorPolicy::calculate_young_list_target_length() {
-  if (adaptive_young_list_length()) {
-    size_t rs_lengths = (size_t) get_new_prediction(_rs_lengths_seq);
-    calculate_young_list_target_length(rs_lengths);
-  } else {
-    if (full_young_gcs())
-      _young_list_target_length = _young_list_fixed_length;
-    else
-      _young_list_target_length = _young_list_fixed_length / 2;
-  }
-
-  // Make sure we allow the application to allocate at least one
-  // region before we need to do a collection again.
-  size_t min_length = _g1->young_list()->length() + 1;
-  _young_list_target_length = MAX2(_young_list_target_length, min_length);
-  calculate_max_gc_locker_expansion();
-  calculate_survivors_policy();
-}
-
-void G1CollectorPolicy::calculate_young_list_target_length(size_t rs_lengths) {
-  guarantee( adaptive_young_list_length(), "pre-condition" );
-  guarantee( !_in_marking_window || !_last_full_young_gc, "invariant" );
-
-  double start_time_sec = os::elapsedTime();
-  size_t min_reserve_perc = MAX2((size_t)2, (size_t)G1ReservePercent);
-  min_reserve_perc = MIN2((size_t) 50, min_reserve_perc);
-  size_t reserve_regions =
-    (size_t) ((double) min_reserve_perc * (double) _g1->n_regions() / 100.0);
-
-  if (full_young_gcs() && _free_regions_at_end_of_collection > 0) {
-    // we are in fully-young mode and there are free regions in the heap
-
-    double survivor_regions_evac_time =
-        predict_survivor_regions_evac_time();
-
-    double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0;
-    size_t pending_cards = (size_t) get_new_prediction(_pending_cards_seq);
-    size_t adj_rs_lengths = rs_lengths + predict_rs_length_diff();
-    size_t scanned_cards = predict_young_card_num(adj_rs_lengths);
-    double base_time_ms = predict_base_elapsed_time_ms(pending_cards, scanned_cards)
-                          + survivor_regions_evac_time;
-
-    // the result
-    size_t final_young_length = 0;
-
-    size_t init_free_regions =
-      MAX2((size_t)0, _free_regions_at_end_of_collection - reserve_regions);
-
-    // if we're still under the pause target...
-    if (base_time_ms <= target_pause_time_ms) {
-      // We make sure that the shortest young length that makes sense
-      // fits within the target pause time.
-      size_t min_young_length = 1;
-
-      if (predict_will_fit(min_young_length, base_time_ms,
-                                     init_free_regions, target_pause_time_ms)) {
-        // The shortest young length will fit within the target pause time;
-        // we'll now check whether the absolute maximum number of young
-        // regions will fit in the target pause time. If not, we'll do
-        // a binary search between min_young_length and max_young_length
-        size_t abs_max_young_length = _free_regions_at_end_of_collection - 1;
-        size_t max_young_length = abs_max_young_length;
-
-        if (max_young_length > min_young_length) {
-          // Let's check if the initial max young length will fit within the
-          // target pause. If so then there is no need to search for a maximal
-          // young length - we'll return the initial maximum
-
-          if (predict_will_fit(max_young_length, base_time_ms,
-                                init_free_regions, target_pause_time_ms)) {
-            // The maximum young length will satisfy the target pause time.
-            // We are done so set min young length to this maximum length.
-            // The code after the loop will then set final_young_length using
-            // the value cached in the minimum length.
-            min_young_length = max_young_length;
-          } else {
-            // The maximum possible number of young regions will not fit within
-            // the target pause time so let's search....
-
-            size_t diff = (max_young_length - min_young_length) / 2;
-            max_young_length = min_young_length + diff;
-
-            while (max_young_length > min_young_length) {
-              if (predict_will_fit(max_young_length, base_time_ms,
-                                        init_free_regions, target_pause_time_ms)) {
-
-                // The current max young length will fit within the target
-                // pause time. Note we do not exit the loop here. By setting
-                // min = max, and then increasing the max below means that
-                // we will continue searching for an upper bound in the
-                // range [max..max+diff]
-                min_young_length = max_young_length;
-              }
-              diff = (max_young_length - min_young_length) / 2;
-              max_young_length = min_young_length + diff;
-            }
-            // the above loop found a maximal young length that will fit
-            // within the target pause time.
-          }
-          assert(min_young_length <= abs_max_young_length, "just checking");
-        }
-        final_young_length = min_young_length;
-      }
-    }
-    // and we're done!
-
-    // we should have at least one region in the target young length
-    _young_list_target_length =
-                              final_young_length + _recorded_survivor_regions;
-
-    // let's keep an eye of how long we spend on this calculation
-    // right now, I assume that we'll print it when we need it; we
-    // should really adde it to the breakdown of a pause
-    double end_time_sec = os::elapsedTime();
-    double elapsed_time_ms = (end_time_sec - start_time_sec) * 1000.0;
-
-#ifdef TRACE_CALC_YOUNG_LENGTH
-    // leave this in for debugging, just in case
-    gclog_or_tty->print_cr("target = %1.1lf ms, young = " SIZE_FORMAT ", "
-                           "elapsed %1.2lf ms, (%s%s) " SIZE_FORMAT SIZE_FORMAT,
-                           target_pause_time_ms,
-                           _young_list_target_length
-                           elapsed_time_ms,
-                           full_young_gcs() ? "full" : "partial",
-                           during_initial_mark_pause() ? " i-m" : "",
-                           _in_marking_window,
-                           _in_marking_window_im);
-#endif // TRACE_CALC_YOUNG_LENGTH
-
-    if (_young_list_target_length < _young_list_min_length) {
-      // bummer; this means that, if we do a pause when the maximal
-      // length dictates, we'll violate the pause spacing target (the
-      // min length was calculate based on the application's current
-      // alloc rate);
-
-      // so, we have to bite the bullet, and allocate the minimum
-      // number. We'll violate our target, but we just can't meet it.
-
-#ifdef TRACE_CALC_YOUNG_LENGTH
-      // leave this in for debugging, just in case
-      gclog_or_tty->print_cr("adjusted target length from "
-                             SIZE_FORMAT " to " SIZE_FORMAT,
-                             _young_list_target_length, _young_list_min_length);
-#endif // TRACE_CALC_YOUNG_LENGTH
-
-      _young_list_target_length = _young_list_min_length;
-    }
-  } else {
-    // we are in a partially-young mode or we've run out of regions (due
-    // to evacuation failure)
-
-#ifdef TRACE_CALC_YOUNG_LENGTH
-    // leave this in for debugging, just in case
-    gclog_or_tty->print_cr("(partial) setting target to " SIZE_FORMAT
-                           _young_list_min_length);
-#endif // TRACE_CALC_YOUNG_LENGTH
-    // we'll do the pause as soon as possible by choosing the minimum
-    _young_list_target_length = _young_list_min_length;
-  }
-
-  _rs_lengths_prediction = rs_lengths;
-}
-
-// This is used by: calculate_young_list_target_length(rs_length). It
-// returns true iff:
-//   the predicted pause time for the given young list will not overflow
-//   the target pause time
-// and:
-//   the predicted amount of surviving data will not overflow the
-//   the amount of free space available for survivor regions.
-//
-bool
-G1CollectorPolicy::predict_will_fit(size_t young_length,
-                                    double base_time_ms,
-                                    size_t init_free_regions,
-                                    double target_pause_time_ms) {
-
-  if (young_length >= init_free_regions)
+bool G1CollectorPolicy::predict_will_fit(size_t young_length,
+                                         double base_time_ms,
+                                         size_t base_free_regions,
+                                         double target_pause_time_ms) {
+  if (young_length >= base_free_regions) {
     // end condition 1: not enough space for the young regions
     return false;
-
-  double accum_surv_rate_adj = 0.0;
-  double accum_surv_rate =
-    accum_yg_surv_rate_pred((int)(young_length - 1)) - accum_surv_rate_adj;
-
+  }
+
+  double accum_surv_rate = accum_yg_surv_rate_pred((int)(young_length - 1));
   size_t bytes_to_copy =
-    (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes);
-
+               (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes);
   double copy_time_ms = predict_object_copy_time_ms(bytes_to_copy);
-
-  double young_other_time_ms =
-                       predict_young_other_time_ms(young_length);
-
-  double pause_time_ms =
-                   base_time_ms + copy_time_ms + young_other_time_ms;
-
-  if (pause_time_ms > target_pause_time_ms)
-    // end condition 2: over the target pause time
+  double young_other_time_ms = predict_young_other_time_ms(young_length);
+  double pause_time_ms = base_time_ms + copy_time_ms + young_other_time_ms;
+  if (pause_time_ms > target_pause_time_ms) {
+    // end condition 2: prediction is over the target pause time
     return false;
+  }
 
   size_t free_bytes =
-                 (init_free_regions - young_length) * HeapRegion::GrainBytes;
-
-  if ((2.0 + sigma()) * (double) bytes_to_copy > (double) free_bytes)
-    // end condition 3: out of to-space (conservatively)
+                  (base_free_regions - young_length) * HeapRegion::GrainBytes;
+  if ((2.0 * sigma()) * (double) bytes_to_copy > (double) free_bytes) {
+    // end condition 3: out-of-space (conservatively!)
     return false;
+  }
 
   // success!
   return true;
 }
 
+void G1CollectorPolicy::record_new_heap_size(size_t new_number_of_regions) {
+  // re-calculate the necessary reserve
+  double reserve_regions_d = (double) new_number_of_regions * _reserve_factor;
+  // We use ceiling so that if reserve_regions_d is > 0.0 (but
+  // smaller than 1.0) we'll get 1.
+  _reserve_regions = (size_t) ceil(reserve_regions_d);
+
+  if (_using_new_ratio_calculations) {
+    // -XX:NewRatio was specified so we need to update the
+    // young gen length when the heap size has changed.
+    update_young_list_size_using_newratio(new_number_of_regions);
+  }
+}
+
+size_t G1CollectorPolicy::calculate_young_list_desired_min_length(
+                                                     size_t base_min_length) {
+  size_t desired_min_length = 0;
+  if (adaptive_young_list_length()) {
+    if (_alloc_rate_ms_seq->num() > 3) {
+      double now_sec = os::elapsedTime();
+      double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0;
+      double alloc_rate_ms = predict_alloc_rate_ms();
+      desired_min_length = (size_t) ceil(alloc_rate_ms * when_ms);
+    } else {
+      // otherwise we don't have enough info to make the prediction
+    }
+  }
+  desired_min_length += base_min_length;
+  // make sure we don't go below any user-defined minimum bound
+  return MAX2(_min_desired_young_length, desired_min_length);
+}
+
+size_t G1CollectorPolicy::calculate_young_list_desired_max_length() {
+  // Here, we might want to also take into account any additional
+  // constraints (i.e., user-defined minimum bound). Currently, we
+  // effectively don't set this bound.
+  return _max_desired_young_length;
+}
+
+void G1CollectorPolicy::update_young_list_target_length(size_t rs_lengths) {
+  if (rs_lengths == (size_t) -1) {
+    // if it's set to the default value (-1), we should predict it;
+    // otherwise, use the given value.
+    rs_lengths = (size_t) get_new_prediction(_rs_lengths_seq);
+  }
+
+  // Calculate the absolute and desired min bounds.
+
+  // This is how many young regions we already have (currently: the survivors).
+  size_t base_min_length = recorded_survivor_regions();
+  // This is the absolute minimum young length, which ensures that we
+  // can allocate one eden region in the worst-case.
+  size_t absolute_min_length = base_min_length + 1;
+  size_t desired_min_length =
+                     calculate_young_list_desired_min_length(base_min_length);
+  if (desired_min_length < absolute_min_length) {
+    desired_min_length = absolute_min_length;
+  }
+
+  // Calculate the absolute and desired max bounds.
+
+  // We will try our best not to "eat" into the reserve.
+  size_t absolute_max_length = 0;
+  if (_free_regions_at_end_of_collection > _reserve_regions) {
+    absolute_max_length = _free_regions_at_end_of_collection - _reserve_regions;
+  }
+  size_t desired_max_length = calculate_young_list_desired_max_length();
+  if (desired_max_length > absolute_max_length) {
+    desired_max_length = absolute_max_length;
+  }
+
+  size_t young_list_target_length = 0;
+  if (adaptive_young_list_length()) {
+    if (full_young_gcs()) {
+      young_list_target_length =
+                        calculate_young_list_target_length(rs_lengths,
+                                                           base_min_length,
+                                                           desired_min_length,
+                                                           desired_max_length);
+      _rs_lengths_prediction = rs_lengths;
+    } else {
+      // Don't calculate anything and let the code below bound it to
+      // the desired_min_length, i.e., do the next GC as soon as
+      // possible to maximize how many old regions we can add to it.
+    }
+  } else {
+    if (full_young_gcs()) {
+      young_list_target_length = _young_list_fixed_length;
+    } else {
+      // A bit arbitrary: during partially-young GCs we allocate half
+      // the young regions to try to add old regions to the CSet.
+      young_list_target_length = _young_list_fixed_length / 2;
+      // We choose to accept that we might go under the desired min
+      // length given that we intentionally ask for a smaller young gen.
+      desired_min_length = absolute_min_length;
+    }
+  }
+
+  // Make sure we don't go over the desired max length, nor under the
+  // desired min length. In case they clash, desired_min_length wins
+  // which is why that test is second.
+  if (young_list_target_length > desired_max_length) {
+    young_list_target_length = desired_max_length;
+  }
+  if (young_list_target_length < desired_min_length) {
+    young_list_target_length = desired_min_length;
+  }
+
+  assert(young_list_target_length > recorded_survivor_regions(),
+         "we should be able to allocate at least one eden region");
+  assert(young_list_target_length >= absolute_min_length, "post-condition");
+  _young_list_target_length = young_list_target_length;
+
+  update_max_gc_locker_expansion();
+}
+
+size_t
+G1CollectorPolicy::calculate_young_list_target_length(size_t rs_lengths,
+                                                   size_t base_min_length,
+                                                   size_t desired_min_length,
+                                                   size_t desired_max_length) {
+  assert(adaptive_young_list_length(), "pre-condition");
+  assert(full_young_gcs(), "only call this for fully-young GCs");
+
+  // In case some edge-condition makes the desired max length too small...
+  if (desired_max_length <= desired_min_length) {
+    return desired_min_length;
+  }
+
+  // We'll adjust min_young_length and max_young_length not to include
+  // the already allocated young regions (i.e., so they reflect the
+  // min and max eden regions we'll allocate). The base_min_length
+  // will be reflected in the predictions by the
+  // survivor_regions_evac_time prediction.
+  assert(desired_min_length > base_min_length, "invariant");
+  size_t min_young_length = desired_min_length - base_min_length;
+  assert(desired_max_length > base_min_length, "invariant");
+  size_t max_young_length = desired_max_length - base_min_length;
+
+  double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0;
+  double survivor_regions_evac_time = predict_survivor_regions_evac_time();
+  size_t pending_cards = (size_t) get_new_prediction(_pending_cards_seq);
+  size_t adj_rs_lengths = rs_lengths + predict_rs_length_diff();
+  size_t scanned_cards = predict_young_card_num(adj_rs_lengths);
+  double base_time_ms =
+    predict_base_elapsed_time_ms(pending_cards, scanned_cards) +
+    survivor_regions_evac_time;
+  size_t available_free_regions = _free_regions_at_end_of_collection;
+  size_t base_free_regions = 0;
+  if (available_free_regions > _reserve_regions) {
+    base_free_regions = available_free_regions - _reserve_regions;
+  }
+
+  // Here, we will make sure that the shortest young length that
+  // makes sense fits within the target pause time.
+
+  if (predict_will_fit(min_young_length, base_time_ms,
+                       base_free_regions, target_pause_time_ms)) {
+    // The shortest young length will fit into the target pause time;
+    // we'll now check whether the absolute maximum number of young
+    // regions will fit in the target pause time. If not, we'll do
+    // a binary search between min_young_length and max_young_length.
+    if (predict_will_fit(max_young_length, base_time_ms,
+                         base_free_regions, target_pause_time_ms)) {
+      // The maximum young length will fit into the target pause time.
+      // We are done so set min young length to the maximum length (as
+      // the result is assumed to be returned in min_young_length).
+      min_young_length = max_young_length;
+    } else {
+      // The maximum possible number of young regions will not fit within
+      // the target pause time so we'll search for the optimal
+      // length. The loop invariants are:
+      //
+      // min_young_length < max_young_length
+      // min_young_length is known to fit into the target pause time
+      // max_young_length is known not to fit into the target pause time
+      //
+      // Going into the loop we know the above hold as we've just
+      // checked them. Every time around the loop we check whether
+      // the middle value between min_young_length and
+      // max_young_length fits into the target pause time. If it
+      // does, it becomes the new min. If it doesn't, it becomes
+      // the new max. This way we maintain the loop invariants.
+
+      assert(min_young_length < max_young_length, "invariant");
+      size_t diff = (max_young_length - min_young_length) / 2;
+      while (diff > 0) {
+        size_t young_length = min_young_length + diff;
+        if (predict_will_fit(young_length, base_time_ms,
+                             base_free_regions, target_pause_time_ms)) {
+          min_young_length = young_length;
+        } else {
+          max_young_length = young_length;
+        }
+        assert(min_young_length <  max_young_length, "invariant");
+        diff = (max_young_length - min_young_length) / 2;
+      }
+      // The results is min_young_length which, according to the
+      // loop invariants, should fit within the target pause time.
+
+      // These are the post-conditions of the binary search above:
+      assert(min_young_length < max_young_length,
+             "otherwise we should have discovered that max_young_length "
+             "fits into the pause target and not done the binary search");
+      assert(predict_will_fit(min_young_length, base_time_ms,
+                              base_free_regions, target_pause_time_ms),
+             "min_young_length, the result of the binary search, should "
+             "fit into the pause target");
+      assert(!predict_will_fit(min_young_length + 1, base_time_ms,
+                               base_free_regions, target_pause_time_ms),
+             "min_young_length, the result of the binary search, should be "
+             "optimal, so no larger length should fit into the pause target");
+    }
+  } else {
+    // Even the minimum length doesn't fit into the pause time
+    // target, return it as the result nevertheless.
+  }
+  return base_min_length + min_young_length;
+}
+
 double G1CollectorPolicy::predict_survivor_regions_evac_time() {
   double survivor_regions_evac_time = 0.0;
   for (HeapRegion * r = _recorded_survivor_head;
@@ -726,17 +798,19 @@
   return survivor_regions_evac_time;
 }
 
-void G1CollectorPolicy::check_prediction_validity() {
+void G1CollectorPolicy::revise_young_list_target_length_if_necessary() {
   guarantee( adaptive_young_list_length(), "should not call this otherwise" );
 
   size_t rs_lengths = _g1->young_list()->sampled_rs_lengths();
   if (rs_lengths > _rs_lengths_prediction) {
     // add 10% to avoid having to recalculate often
     size_t rs_lengths_prediction = rs_lengths * 1100 / 1000;
-    calculate_young_list_target_length(rs_lengths_prediction);
+    update_young_list_target_length(rs_lengths_prediction);
   }
 }
 
+
+
 HeapWord* G1CollectorPolicy::mem_allocate_work(size_t size,
                                                bool is_tlab,
                                                bool* gc_overhead_limit_was_exceeded) {
@@ -843,8 +917,8 @@
   _free_regions_at_end_of_collection = _g1->free_regions();
   // Reset survivors SurvRateGroup.
   _survivor_surv_rate_group->reset();
-  calculate_young_list_min_length();
-  calculate_young_list_target_length();
+  update_young_list_target_length();
+  _collectionSetChooser->updateAfterFullCollection();
 }
 
 void G1CollectorPolicy::record_stop_world_start() {
@@ -859,6 +933,11 @@
     gclog_or_tty->print(" (%s)", full_young_gcs() ? "young" : "partial");
   }
 
+  // We only need to do this here as the policy will only be applied
+  // to the GC we're about to start. so, no point is calculating this
+  // every time we calculate / recalculate the target young length.
+  update_survivors_policy();
+
   assert(_g1->used() == _g1->recalculate_used(),
          err_msg("sanity, used: "SIZE_FORMAT" recalculate_used: "SIZE_FORMAT,
                  _g1->used(), _g1->recalculate_used()));
@@ -948,54 +1027,10 @@
   _mark_cleanup_start_sec = os::elapsedTime();
 }
 
-void
-G1CollectorPolicy::record_concurrent_mark_cleanup_end(size_t freed_bytes,
-                                                      size_t max_live_bytes) {
-  record_concurrent_mark_cleanup_end_work1(freed_bytes, max_live_bytes);
-  record_concurrent_mark_cleanup_end_work2();
-}
-
-void
-G1CollectorPolicy::
-record_concurrent_mark_cleanup_end_work1(size_t freed_bytes,
-                                         size_t max_live_bytes) {
-  if (_n_marks < 2) _n_marks++;
-  if (G1PolicyVerbose > 0)
-    gclog_or_tty->print_cr("At end of marking, max_live is " SIZE_FORMAT " MB "
-                           " (of " SIZE_FORMAT " MB heap).",
-                           max_live_bytes/M, _g1->capacity()/M);
-}
-
-// The important thing about this is that it includes "os::elapsedTime".
-void G1CollectorPolicy::record_concurrent_mark_cleanup_end_work2() {
-  double end_time_sec = os::elapsedTime();
-  double elapsed_time_ms = (end_time_sec - _mark_cleanup_start_sec)*1000.0;
-  _concurrent_mark_cleanup_times_ms->add(elapsed_time_ms);
-  _cur_mark_stop_world_time_ms += elapsed_time_ms;
-  _prev_collection_pause_end_ms += elapsed_time_ms;
-
-  _mmu_tracker->add_pause(_mark_cleanup_start_sec, end_time_sec, true);
-
-  _num_markings++;
-
-  // We did a marking, so reset the "since_last_mark" variables.
-  double considerConcMarkCost = 1.0;
-  // If there are available processors, concurrent activity is free...
-  if (Threads::number_of_non_daemon_threads() * 2 <
-      os::active_processor_count()) {
-    considerConcMarkCost = 0.0;
-  }
-  _n_pauses_at_mark_end = _n_pauses;
-  _n_marks_since_last_pause++;
-}
-
-void
-G1CollectorPolicy::record_concurrent_mark_cleanup_completed() {
+void G1CollectorPolicy::record_concurrent_mark_cleanup_completed() {
   _should_revert_to_full_young_gcs = false;
   _last_full_young_gc = true;
   _in_marking_window = false;
-  if (adaptive_young_list_length())
-    calculate_young_list_target_length();
 }
 
 void G1CollectorPolicy::record_concurrent_pause() {
@@ -1148,20 +1183,37 @@
   if (last_pause_included_initial_mark)
     record_concurrent_mark_init_end(0.0);
 
-  size_t min_used_targ =
+  size_t marking_initiating_used_threshold =
     (_g1->capacity() / 100) * InitiatingHeapOccupancyPercent;
 
-
   if (!_g1->mark_in_progress() && !_last_full_young_gc) {
     assert(!last_pause_included_initial_mark, "invariant");
-    if (cur_used_bytes > min_used_targ &&
-      cur_used_bytes > _prev_collection_pause_used_at_end_bytes) {
+    if (cur_used_bytes > marking_initiating_used_threshold) {
+      if (cur_used_bytes > _prev_collection_pause_used_at_end_bytes) {
         assert(!during_initial_mark_pause(), "we should not see this here");
 
+        ergo_verbose3(ErgoConcCycles,
+                      "request concurrent cycle initiation",
+                      ergo_format_reason("occupancy higher than threshold")
+                      ergo_format_byte("occupancy")
+                      ergo_format_byte_perc("threshold"),
+                      cur_used_bytes,
+                      marking_initiating_used_threshold,
+                      (double) InitiatingHeapOccupancyPercent);
+
         // Note: this might have already been set, if during the last
         // pause we decided to start a cycle but at the beginning of
         // this pause we decided to postpone it. That's OK.
         set_initiate_conc_mark_if_possible();
+      } else {
+        ergo_verbose2(ErgoConcCycles,
+                  "do not request concurrent cycle initiation",
+                  ergo_format_reason("occupancy lower than previous occupancy")
+                  ergo_format_byte("occupancy")
+                  ergo_format_byte("previous occupancy"),
+                  cur_used_bytes,
+                  _prev_collection_pause_used_at_end_bytes);
+      }
     }
   }
 
@@ -1397,6 +1449,8 @@
 #endif
     print_stats(1, "Other", other_time_ms);
     print_stats(2, "Choose CSet", _recorded_young_cset_choice_time_ms);
+    print_stats(2, "Ref Proc", _cur_ref_proc_time_ms);
+    print_stats(2, "Ref Enq", _cur_ref_enq_time_ms);
 
     for (int i = 0; i < _aux_num; ++i) {
       if (_cur_aux_times_set[i]) {
@@ -1413,11 +1467,9 @@
     summary->record_other_time_ms(other_time_ms);
   }
   for (int i = 0; i < _aux_num; ++i)
-    if (_cur_aux_times_set[i])
+    if (_cur_aux_times_set[i]) {
       _all_aux_times_ms[i].add(_cur_aux_times_ms[i]);
-
-  // Reset marks-between-pauses counter.
-  _n_marks_since_last_pause = 0;
+    }
 
   // Update the efficiency-since-mark vars.
   double proc_ms = elapsed_ms * (double) _parallel_gc_threads;
@@ -1437,16 +1489,51 @@
   }
 
   if (_last_full_young_gc) {
-    set_full_young_gcs(false);
+    if (!last_pause_included_initial_mark) {
+      ergo_verbose2(ErgoPartiallyYoungGCs,
+                    "start partially-young GCs",
+                    ergo_format_byte_perc("known garbage"),
+                    _known_garbage_bytes, _known_garbage_ratio * 100.0);
+      set_full_young_gcs(false);
+    } else {
+      ergo_verbose0(ErgoPartiallyYoungGCs,
+                    "do not start partially-young GCs",
+                    ergo_format_reason("concurrent cycle is about to start"));
+    }
     _last_full_young_gc = false;
   }
 
   if ( !_last_young_gc_full ) {
-    if ( _should_revert_to_full_young_gcs ||
-      _known_garbage_ratio < 0.05 ||
-      (adaptive_young_list_length() &&
-      (get_gc_eff_factor() * cur_efficiency < predict_young_gc_eff())) ) {
-        set_full_young_gcs(true);
+    if (_should_revert_to_full_young_gcs) {
+      ergo_verbose2(ErgoPartiallyYoungGCs,
+                    "end partially-young GCs",
+                    ergo_format_reason("partially-young GCs end requested")
+                    ergo_format_byte_perc("known garbage"),
+                    _known_garbage_bytes, _known_garbage_ratio * 100.0);
+      set_full_young_gcs(true);
+    } else if (_known_garbage_ratio < 0.05) {
+      ergo_verbose3(ErgoPartiallyYoungGCs,
+               "end partially-young GCs",
+               ergo_format_reason("known garbage percent lower than threshold")
+               ergo_format_byte_perc("known garbage")
+               ergo_format_perc("threshold"),
+               _known_garbage_bytes, _known_garbage_ratio * 100.0,
+               0.05 * 100.0);
+      set_full_young_gcs(true);
+    } else if (adaptive_young_list_length() &&
+              (get_gc_eff_factor() * cur_efficiency < predict_young_gc_eff())) {
+      ergo_verbose5(ErgoPartiallyYoungGCs,
+                    "end partially-young GCs",
+                    ergo_format_reason("current GC efficiency lower than "
+                                       "predicted fully-young GC efficiency")
+                    ergo_format_double("GC efficiency factor")
+                    ergo_format_double("current GC efficiency")
+                    ergo_format_double("predicted fully-young GC efficiency")
+                    ergo_format_byte_perc("known garbage"),
+                    get_gc_eff_factor(), cur_efficiency,
+                    predict_young_gc_eff(),
+                    _known_garbage_bytes, _known_garbage_ratio * 100.0);
+      set_full_young_gcs(true);
     }
   }
   _should_revert_to_full_young_gcs = false;
@@ -1600,13 +1687,14 @@
   _in_marking_window = new_in_marking_window;
   _in_marking_window_im = new_in_marking_window_im;
   _free_regions_at_end_of_collection = _g1->free_regions();
-  calculate_young_list_min_length();
-  calculate_young_list_target_length();
+  update_young_list_target_length();
 
   // Note that _mmu_tracker->max_gc_time() returns the time in seconds.
   double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
   adjust_concurrent_refinement(update_rs_time, update_rs_processed_buffers, update_rs_time_goal_ms);
   // </NEW PREDICTION>
+
+  assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end.");
 }
 
 #define EXT_SIZE_FORMAT "%d%s"
@@ -1622,20 +1710,26 @@
     size_t used_before_gc = _cur_collection_pause_used_at_start_bytes;
     size_t used = _g1->used();
     size_t capacity = _g1->capacity();
+    size_t eden_capacity =
+      (_young_list_target_length * HeapRegion::GrainBytes) - survivor_bytes;
 
     gclog_or_tty->print_cr(
-         "   [Eden: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
-             "Survivors: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
-             "Heap: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"
-                     EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")]",
-             EXT_SIZE_PARAMS(_eden_bytes_before_gc),
-               EXT_SIZE_PARAMS(eden_bytes),
-             EXT_SIZE_PARAMS(_survivor_bytes_before_gc),
-               EXT_SIZE_PARAMS(survivor_bytes),
-             EXT_SIZE_PARAMS(used_before_gc),
-             EXT_SIZE_PARAMS(_capacity_before_gc),
-               EXT_SIZE_PARAMS(used),
-               EXT_SIZE_PARAMS(capacity));
+      "   [Eden: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT") "
+      "Survivors: "EXT_SIZE_FORMAT"->"EXT_SIZE_FORMAT" "
+      "Heap: "EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")->"
+      EXT_SIZE_FORMAT"("EXT_SIZE_FORMAT")]",
+      EXT_SIZE_PARAMS(_eden_bytes_before_gc),
+      EXT_SIZE_PARAMS(_prev_eden_capacity),
+      EXT_SIZE_PARAMS(eden_bytes),
+      EXT_SIZE_PARAMS(eden_capacity),
+      EXT_SIZE_PARAMS(_survivor_bytes_before_gc),
+      EXT_SIZE_PARAMS(survivor_bytes),
+      EXT_SIZE_PARAMS(used_before_gc),
+      EXT_SIZE_PARAMS(_capacity_before_gc),
+      EXT_SIZE_PARAMS(used),
+      EXT_SIZE_PARAMS(capacity));
+
+    _prev_eden_capacity = eden_capacity;
   } else if (PrintGC) {
     _g1->print_size_transition(gclog_or_tty,
                                _cur_collection_pause_used_at_start_bytes,
@@ -1877,6 +1971,12 @@
   // I don't think we need to do this when in young GC mode since
   // marking will be initiated next time we hit the soft limit anyway...
   if (predicted_time_ms > _expensive_region_limit_ms) {
+    ergo_verbose2(ErgoPartiallyYoungGCs,
+              "request partially-young GCs end",
+              ergo_format_reason("predicted region time higher than threshold")
+              ergo_format_ms("predicted region time")
+              ergo_format_ms("threshold"),
+              predicted_time_ms, _expensive_region_limit_ms);
     // no point in doing another partial one
     _should_revert_to_full_young_gcs = true;
   }
@@ -1986,7 +2086,9 @@
 }
 
 size_t G1CollectorPolicy::expansion_amount() {
-  if ((recent_avg_pause_time_ratio() * 100.0) > _gc_overhead_perc) {
+  double recent_gc_overhead = recent_avg_pause_time_ratio() * 100.0;
+  double threshold = _gc_overhead_perc;
+  if (recent_gc_overhead > threshold) {
     // We will double the existing space, or take
     // G1ExpandByPercentOfAvailable % of the available expansion
     // space, whichever is smaller, bounded below by a minimum
@@ -2001,30 +2103,25 @@
     expand_bytes = MIN2(expand_bytes_via_pct, committed_bytes);
     expand_bytes = MAX2(expand_bytes, min_expand_bytes);
     expand_bytes = MIN2(expand_bytes, uncommitted_bytes);
-    if (G1PolicyVerbose > 1) {
-      gclog_or_tty->print("Decided to expand: ratio = %5.2f, "
-                 "committed = %d%s, uncommited = %d%s, via pct = %d%s.\n"
-                 "                   Answer = %d.\n",
-                 recent_avg_pause_time_ratio(),
-                 byte_size_in_proper_unit(committed_bytes),
-                 proper_unit_for_byte_size(committed_bytes),
-                 byte_size_in_proper_unit(uncommitted_bytes),
-                 proper_unit_for_byte_size(uncommitted_bytes),
-                 byte_size_in_proper_unit(expand_bytes_via_pct),
-                 proper_unit_for_byte_size(expand_bytes_via_pct),
-                 byte_size_in_proper_unit(expand_bytes),
-                 proper_unit_for_byte_size(expand_bytes));
-    }
+
+    ergo_verbose5(ErgoHeapSizing,
+                  "attempt heap expansion",
+                  ergo_format_reason("recent GC overhead higher than "
+                                     "threshold after GC")
+                  ergo_format_perc("recent GC overhead")
+                  ergo_format_perc("threshold")
+                  ergo_format_byte("uncommitted")
+                  ergo_format_byte_perc("calculated expansion amount"),
+                  recent_gc_overhead, threshold,
+                  uncommitted_bytes,
+                  expand_bytes_via_pct, (double) G1ExpandByPercentOfAvailable);
+
     return expand_bytes;
   } else {
     return 0;
   }
 }
 
-void G1CollectorPolicy::note_start_of_mark_thread() {
-  _mark_thread_startup_sec = os::elapsedTime();
-}
-
 class CountCSClosure: public HeapRegionClosure {
   G1CollectorPolicy* _g1_policy;
 public:
@@ -2237,8 +2334,7 @@
 #endif // PRODUCT
 }
 
-void
-G1CollectorPolicy::update_region_num(bool young) {
+void G1CollectorPolicy::update_region_num(bool young) {
   if (young) {
     ++_region_num_young;
   } else {
@@ -2270,7 +2366,7 @@
   };
 }
 
-void G1CollectorPolicy::calculate_max_gc_locker_expansion() {
+void G1CollectorPolicy::update_max_gc_locker_expansion() {
   size_t expansion_region_num = 0;
   if (GCLockerEdenExpansionPercent > 0) {
     double perc = (double) GCLockerEdenExpansionPercent / 100.0;
@@ -2286,9 +2382,13 @@
 }
 
 // Calculates survivor space parameters.
-void G1CollectorPolicy::calculate_survivors_policy()
-{
-  _max_survivor_regions = _young_list_target_length / SurvivorRatio;
+void G1CollectorPolicy::update_survivors_policy() {
+  double max_survivor_regions_d =
+                 (double) _young_list_target_length / (double) SurvivorRatio;
+  // We use ceiling so that if max_survivor_regions_d is > 0.0 (but
+  // smaller than 1.0) we'll get 1.
+  _max_survivor_regions = (size_t) ceil(max_survivor_regions_d);
+
   _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(
         HeapRegion::GrainWords * _max_survivor_regions);
 }
@@ -2308,20 +2408,30 @@
   }
 };
 
-bool G1CollectorPolicy_BestRegionsFirst::assertMarkedBytesDataOK() {
+bool G1CollectorPolicy::assertMarkedBytesDataOK() {
   HRSortIndexIsOKClosure cl(_collectionSetChooser);
   _g1->heap_region_iterate(&cl);
   return true;
 }
 #endif
 
-bool
-G1CollectorPolicy::force_initial_mark_if_outside_cycle() {
+bool G1CollectorPolicy::force_initial_mark_if_outside_cycle(
+                                                     GCCause::Cause gc_cause) {
   bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
   if (!during_cycle) {
+    ergo_verbose1(ErgoConcCycles,
+                  "request concurrent cycle initiation",
+                  ergo_format_reason("requested by GC cause")
+                  ergo_format_str("GC cause"),
+                  GCCause::to_string(gc_cause));
     set_initiate_conc_mark_if_possible();
     return true;
   } else {
+    ergo_verbose1(ErgoConcCycles,
+                  "do not request concurrent cycle initiation",
+                  ergo_format_reason("concurrent cycle already in progress")
+                  ergo_format_str("GC cause"),
+                  GCCause::to_string(gc_cause));
     return false;
   }
 }
@@ -2349,10 +2459,21 @@
       // initiate a new cycle.
 
       set_during_initial_mark_pause();
+      // We do not allow non-full young GCs during marking.
+      if (!full_young_gcs()) {
+        set_full_young_gcs(true);
+        ergo_verbose0(ErgoPartiallyYoungGCs,
+                      "end partially-young GCs",
+                      ergo_format_reason("concurrent cycle is about to start"));
+      }
 
       // And we can now clear initiate_conc_mark_if_possible() as
       // we've already acted on it.
       clear_initiate_conc_mark_if_possible();
+
+      ergo_verbose0(ErgoConcCycles,
+                  "initiate concurrent cycle",
+                  ergo_format_reason("concurrent cycle initiation requested"));
     } else {
       // The concurrent marking thread is still finishing up the
       // previous cycle. If we start one right now the two cycles
@@ -2366,16 +2487,13 @@
       // and, if it's in a yield point, it's waiting for us to
       // finish. So, at this point we will not start a cycle and we'll
       // let the concurrent marking thread complete the last one.
+      ergo_verbose0(ErgoConcCycles,
+                    "do not initiate concurrent cycle",
+                    ergo_format_reason("concurrent cycle already in progress"));
     }
   }
 }
 
-void
-G1CollectorPolicy_BestRegionsFirst::
-record_collection_pause_start(double start_time_sec, size_t start_used) {
-  G1CollectorPolicy::record_collection_pause_start(start_time_sec, start_used);
-}
-
 class KnownGarbageClosure: public HeapRegionClosure {
   CollectionSetChooser* _hrSorted;
 
@@ -2483,20 +2601,20 @@
 };
 
 void
-G1CollectorPolicy_BestRegionsFirst::
-record_concurrent_mark_cleanup_end(size_t freed_bytes,
-                                   size_t max_live_bytes) {
-  double start;
-  if (G1PrintParCleanupStats) start = os::elapsedTime();
-  record_concurrent_mark_cleanup_end_work1(freed_bytes, max_live_bytes);
+G1CollectorPolicy::record_concurrent_mark_cleanup_end() {
+  double start_sec;
+  if (G1PrintParCleanupStats) {
+    start_sec = os::elapsedTime();
+  }
 
   _collectionSetChooser->clearMarkedHeapRegions();
-  double clear_marked_end;
+  double clear_marked_end_sec;
   if (G1PrintParCleanupStats) {
-    clear_marked_end = os::elapsedTime();
-    gclog_or_tty->print_cr("  clear marked regions + work1: %8.3f ms.",
-                  (clear_marked_end - start)*1000.0);
+    clear_marked_end_sec = os::elapsedTime();
+    gclog_or_tty->print_cr("  clear marked regions: %8.3f ms.",
+                           (clear_marked_end_sec - start_sec) * 1000.0);
   }
+
   if (G1CollectedHeap::use_parallel_gc_threads()) {
     const size_t OverpartitionFactor = 4;
     const size_t MinWorkUnit = 8;
@@ -2515,27 +2633,25 @@
     KnownGarbageClosure knownGarbagecl(_collectionSetChooser);
     _g1->heap_region_iterate(&knownGarbagecl);
   }
-  double known_garbage_end;
+  double known_garbage_end_sec;
   if (G1PrintParCleanupStats) {
-    known_garbage_end = os::elapsedTime();
+    known_garbage_end_sec = os::elapsedTime();
     gclog_or_tty->print_cr("  compute known garbage: %8.3f ms.",
-                  (known_garbage_end - clear_marked_end)*1000.0);
+                      (known_garbage_end_sec - clear_marked_end_sec) * 1000.0);
   }
+
   _collectionSetChooser->sortMarkedHeapRegions();
-  double sort_end;
+  double end_sec = os::elapsedTime();
   if (G1PrintParCleanupStats) {
-    sort_end = os::elapsedTime();
     gclog_or_tty->print_cr("  sorting: %8.3f ms.",
-                  (sort_end - known_garbage_end)*1000.0);
+                           (end_sec - known_garbage_end_sec) * 1000.0);
   }
 
-  record_concurrent_mark_cleanup_end_work2();
-  double work2_end;
-  if (G1PrintParCleanupStats) {
-    work2_end = os::elapsedTime();
-    gclog_or_tty->print_cr("  work2: %8.3f ms.",
-                  (work2_end - sort_end)*1000.0);
-  }
+  double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0;
+  _concurrent_mark_cleanup_times_ms->add(elapsed_time_ms);
+  _cur_mark_stop_world_time_ms += elapsed_time_ms;
+  _prev_collection_pause_end_ms += elapsed_time_ms;
+  _mmu_tracker->add_pause(_mark_cleanup_start_sec, end_sec, true);
 }
 
 // Add the heap region at the head of the non-incremental collection set
@@ -2750,12 +2866,12 @@
 }
 #endif // !PRODUCT
 
-void
-G1CollectorPolicy_BestRegionsFirst::choose_collection_set(
-                                                  double target_pause_time_ms) {
+void G1CollectorPolicy::choose_collection_set(double target_pause_time_ms) {
   // Set this here - in case we're not doing young collections.
   double non_young_start_time_sec = os::elapsedTime();
 
+  YoungList* young_list = _g1->young_list();
+
   start_recording_regions();
 
   guarantee(target_pause_time_ms > 0.0,
@@ -2768,61 +2884,62 @@
 
   double time_remaining_ms = target_pause_time_ms - base_time_ms;
 
+  ergo_verbose3(ErgoCSetConstruction | ErgoHigh,
+                "start choosing CSet",
+                ergo_format_ms("predicted base time")
+                ergo_format_ms("remaining time")
+                ergo_format_ms("target pause time"),
+                base_time_ms, time_remaining_ms, target_pause_time_ms);
+
   // the 10% and 50% values are arbitrary...
-  if (time_remaining_ms < 0.10 * target_pause_time_ms) {
+  double threshold = 0.10 * target_pause_time_ms;
+  if (time_remaining_ms < threshold) {
+    double prev_time_remaining_ms = time_remaining_ms;
     time_remaining_ms = 0.50 * target_pause_time_ms;
     _within_target = false;
+    ergo_verbose3(ErgoCSetConstruction,
+                  "adjust remaining time",
+                  ergo_format_reason("remaining time lower than threshold")
+                  ergo_format_ms("remaining time")
+                  ergo_format_ms("threshold")
+                  ergo_format_ms("adjusted remaining time"),
+                  prev_time_remaining_ms, threshold, time_remaining_ms);
   } else {
     _within_target = true;
   }
 
-  // We figure out the number of bytes available for future to-space.
-  // For new regions without marking information, we must assume the
-  // worst-case of complete survival.  If we have marking information for a
-  // region, we can bound the amount of live data.  We can add a number of
-  // such regions, as long as the sum of the live data bounds does not
-  // exceed the available evacuation space.
-  size_t max_live_bytes = _g1->free_regions() * HeapRegion::GrainBytes;
-
-  size_t expansion_bytes =
-    _g1->expansion_regions() * HeapRegion::GrainBytes;
+  size_t expansion_bytes = _g1->expansion_regions() * HeapRegion::GrainBytes;
+
+  HeapRegion* hr;
+  double young_start_time_sec = os::elapsedTime();
 
   _collection_set_bytes_used_before = 0;
   _collection_set_size = 0;
-
-  // Adjust for expansion and slop.
-  max_live_bytes = max_live_bytes + expansion_bytes;
-
-  HeapRegion* hr;
-  double young_start_time_sec = os::elapsedTime();
-
-  if (G1PolicyVerbose > 0) {
-    gclog_or_tty->print_cr("Adding %d young regions to the CSet",
-      _g1->young_list()->length());
-  }
-
   _young_cset_length  = 0;
   _last_young_gc_full = full_young_gcs() ? true : false;
 
-  if (_last_young_gc_full)
+  if (_last_young_gc_full) {
     ++_full_young_pause_num;
-  else
+  } else {
     ++_partial_young_pause_num;
+  }
 
   // The young list is laid with the survivor regions from the previous
   // pause are appended to the RHS of the young list, i.e.
   //   [Newly Young Regions ++ Survivors from last pause].
 
-  hr = _g1->young_list()->first_survivor_region();
+  size_t survivor_region_num = young_list->survivor_length();
+  size_t eden_region_num = young_list->length() - survivor_region_num;
+  size_t old_region_num = 0;
+  hr = young_list->first_survivor_region();
   while (hr != NULL) {
     assert(hr->is_survivor(), "badly formed young list");
     hr->set_young();
     hr = hr->get_next_young_region();
   }
 
-  // Clear the fields that point to the survivor list - they are
-  // all young now.
-  _g1->young_list()->clear_survivors();
+  // Clear the fields that point to the survivor list - they are all young now.
+  young_list->clear_survivors();
 
   if (_g1->mark_in_progress())
     _g1->concurrent_mark()->register_collection_set_finger(_inc_cset_max_finger);
@@ -2831,14 +2948,17 @@
   _collection_set = _inc_cset_head;
   _collection_set_size = _inc_cset_size;
   _collection_set_bytes_used_before = _inc_cset_bytes_used_before;
-
-  // For young regions in the collection set, we assume the worst
-  // case of complete survival
-  max_live_bytes -= _inc_cset_size * HeapRegion::GrainBytes;
-
   time_remaining_ms -= _inc_cset_predicted_elapsed_time_ms;
   predicted_pause_time_ms += _inc_cset_predicted_elapsed_time_ms;
 
+  ergo_verbose3(ErgoCSetConstruction | ErgoHigh,
+                "add young regions to CSet",
+                ergo_format_region("eden")
+                ergo_format_region("survivors")
+                ergo_format_ms("predicted young region time"),
+                eden_region_num, survivor_region_num,
+                _inc_cset_predicted_elapsed_time_ms);
+
   // The number of recorded young regions is the incremental
   // collection set's current size
   set_recorded_young_regions(_inc_cset_size);
@@ -2848,14 +2968,7 @@
   set_predicted_bytes_to_copy(_inc_cset_predicted_bytes_to_copy);
 #endif // PREDICTIONS_VERBOSE
 
-  if (G1PolicyVerbose > 0) {
-    gclog_or_tty->print_cr("  Added " PTR_FORMAT " Young Regions to CS.",
-      _inc_cset_size);
-    gclog_or_tty->print_cr("    (" SIZE_FORMAT " KB left in heap.)",
-      max_live_bytes/K);
-  }
-
-  assert(_inc_cset_size == _g1->young_list()->length(), "Invariant");
+  assert(_inc_cset_size == young_list->length(), "Invariant");
 
   double young_end_time_sec = os::elapsedTime();
   _recorded_young_cset_choice_time_ms =
@@ -2869,6 +2982,8 @@
     NumberSeq seq;
     double avg_prediction = 100000000000000000.0; // something very large
 
+    size_t prev_collection_set_size = _collection_set_size;
+    double prev_predicted_pause_time_ms = predicted_pause_time_ms;
     do {
       hr = _collectionSetChooser->getNextMarkedRegion(time_remaining_ms,
                                                       avg_prediction);
@@ -2878,23 +2993,58 @@
         predicted_pause_time_ms += predicted_time_ms;
         add_to_collection_set(hr);
         record_non_young_cset_region(hr);
-        max_live_bytes -= MIN2(hr->max_live_bytes(), max_live_bytes);
-        if (G1PolicyVerbose > 0) {
-          gclog_or_tty->print_cr("    (" SIZE_FORMAT " KB left in heap.)",
-                        max_live_bytes/K);
-        }
         seq.add(predicted_time_ms);
         avg_prediction = seq.avg() + seq.sd();
       }
-      should_continue =
-        ( hr != NULL) &&
-        ( (adaptive_young_list_length()) ? time_remaining_ms > 0.0
-          : _collection_set_size < _young_list_fixed_length );
+
+      should_continue = true;
+      if (hr == NULL) {
+        // No need for an ergo verbose message here,
+        // getNextMarkRegion() does this when it returns NULL.
+        should_continue = false;
+      } else {
+        if (adaptive_young_list_length()) {
+          if (time_remaining_ms < 0.0) {
+            ergo_verbose1(ErgoCSetConstruction,
+                          "stop adding old regions to CSet",
+                          ergo_format_reason("remaining time is lower than 0")
+                          ergo_format_ms("remaining time"),
+                          time_remaining_ms);
+            should_continue = false;
+          }
+        } else {
+          if (_collection_set_size >= _young_list_fixed_length) {
+            ergo_verbose2(ErgoCSetConstruction,
+                          "stop adding old regions to CSet",
+                          ergo_format_reason("CSet length reached target")
+                          ergo_format_region("CSet")
+                          ergo_format_region("young target"),
+                          _collection_set_size, _young_list_fixed_length);
+            should_continue = false;
+          }
+        }
+      }
     } while (should_continue);
 
     if (!adaptive_young_list_length() &&
-        _collection_set_size < _young_list_fixed_length)
+        _collection_set_size < _young_list_fixed_length) {
+      ergo_verbose2(ErgoCSetConstruction,
+                    "request partially-young GCs end",
+                    ergo_format_reason("CSet length lower than target")
+                    ergo_format_region("CSet")
+                    ergo_format_region("young target"),
+                    _collection_set_size, _young_list_fixed_length);
       _should_revert_to_full_young_gcs  = true;
+    }
+
+    old_region_num = _collection_set_size - prev_collection_set_size;
+
+    ergo_verbose2(ErgoCSetConstruction | ErgoHigh,
+                  "add old regions to CSet",
+                  ergo_format_region("old")
+                  ergo_format_ms("predicted old region time"),
+                  old_region_num,
+                  predicted_pause_time_ms - prev_predicted_pause_time_ms);
   }
 
   stop_incremental_cset_building();
@@ -2903,24 +3053,17 @@
 
   end_recording_regions();
 
+  ergo_verbose5(ErgoCSetConstruction,
+                "finish choosing CSet",
+                ergo_format_region("eden")
+                ergo_format_region("survivors")
+                ergo_format_region("old")
+                ergo_format_ms("predicted pause time")
+                ergo_format_ms("target pause time"),
+                eden_region_num, survivor_region_num, old_region_num,
+                predicted_pause_time_ms, target_pause_time_ms);
+
   double non_young_end_time_sec = os::elapsedTime();
   _recorded_non_young_cset_choice_time_ms =
     (non_young_end_time_sec - non_young_start_time_sec) * 1000.0;
 }
-
-void G1CollectorPolicy_BestRegionsFirst::record_full_collection_end() {
-  G1CollectorPolicy::record_full_collection_end();
-  _collectionSetChooser->updateAfterFullCollection();
-}
-
-void G1CollectorPolicy_BestRegionsFirst::
-expand_if_possible(size_t numRegions) {
-  size_t expansion_bytes = numRegions * HeapRegion::GrainBytes;
-  _g1->expand(expansion_bytes);
-}
-
-void G1CollectorPolicy_BestRegionsFirst::
-record_collection_pause_end() {
-  G1CollectorPolicy::record_collection_pause_end();
-  assert(assertMarkedBytesDataOK(), "Marked regions not OK at pause end.");
-}
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -84,7 +84,7 @@
 };
 
 class G1CollectorPolicy: public CollectorPolicy {
-protected:
+private:
   // The number of pauses during the execution.
   long _n_pauses;
 
@@ -106,10 +106,7 @@
     initialize_perm_generation(PermGen::MarkSweepCompact);
   }
 
-  virtual size_t default_init_heap_size() {
-    // Pick some reasonable default.
-    return 8*M;
-  }
+  CollectionSetChooser* _collectionSetChooser;
 
   double _cur_collection_start_sec;
   size_t _cur_collection_pause_used_at_start_bytes;
@@ -119,6 +116,8 @@
   double _cur_satb_drain_time_ms;
   double _cur_clear_ct_time_ms;
   bool   _satb_drain_time_set;
+  double _cur_ref_proc_time_ms;
+  double _cur_ref_enq_time_ms;
 
 #ifndef PRODUCT
   // Card Table Count Cache stats
@@ -183,9 +182,9 @@
   // if true, then it tries to dynamically adjust the length of the
   // young list
   bool _adaptive_young_list_length;
-  size_t _young_list_min_length;
   size_t _young_list_target_length;
   size_t _young_list_fixed_length;
+  size_t _prev_eden_capacity; // used for logging
 
   // The max number of regions we can extend the eden by while the GC
   // locker is active. This should be >= _young_list_target_length;
@@ -207,6 +206,9 @@
 
   double                _gc_overhead_perc;
 
+  double _reserve_factor;
+  size_t _reserve_regions;
+
   bool during_marking() {
     return _during_marking;
   }
@@ -243,6 +245,10 @@
 
   TruncatedSeq* _max_conc_overhead_seq;
 
+  bool   _using_new_ratio_calculations;
+  size_t _min_desired_young_length; // as set on the command line or default calculations
+  size_t _max_desired_young_length; // as set on the command line or default calculations
+
   size_t _recorded_young_regions;
   size_t _recorded_non_young_regions;
   size_t _recorded_region_num;
@@ -307,7 +313,6 @@
                                     double update_rs_processed_buffers,
                                     double goal_ms);
 
-protected:
   double _pause_time_target_ms;
   double _recorded_young_cset_choice_time_ms;
   double _recorded_non_young_cset_choice_time_ms;
@@ -456,12 +461,6 @@
   size_t predict_bytes_to_copy(HeapRegion* hr);
   double predict_region_elapsed_time_ms(HeapRegion* hr, bool young);
 
-    // for use by: calculate_young_list_target_length(rs_length)
-  bool predict_will_fit(size_t young_region_num,
-                        double base_time_ms,
-                        size_t init_free_regions,
-                        double target_pause_time_ms);
-
   void start_recording_regions();
   void record_cset_region_info(HeapRegion* hr, bool young);
   void record_non_young_cset_region(HeapRegion* hr);
@@ -493,7 +492,6 @@
 
   // </NEW PREDICTION>
 
-public:
   void cset_regions_freed() {
     bool propagate = _last_young_gc_full && !_in_marking_window;
     _short_lived_surv_rate_group->all_surviving_words_recorded(propagate);
@@ -552,7 +550,7 @@
     return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
   }
 
-protected:
+private:
   void print_stats(int level, const char* str, double value);
   void print_stats(int level, const char* str, int value);
 
@@ -586,10 +584,6 @@
   // Statistics kept per GC stoppage, pause or full.
   TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
 
-  // We track markings.
-  int _num_markings;
-  double _mark_thread_startup_sec;       // Time at startup of marking thread
-
   // Add a new GC of the given duration and end time to the record.
   void update_recent_gc_times(double end_time_sec, double elapsed_ms);
 
@@ -662,12 +656,6 @@
   // young list/collection set).
   size_t _inc_cset_predicted_bytes_to_copy;
 
-  // Info about marking.
-  int _n_marks; // Sticky at 2, so we know when we've done at least 2.
-
-  // The number of collection pauses at the end of the last mark.
-  size_t _n_pauses_at_mark_end;
-
   // Stash a pointer to the g1 heap.
   G1CollectedHeap* _g1;
 
@@ -735,8 +723,6 @@
   // Number of pauses between concurrent marking.
   size_t _pauses_btwn_concurrent_mark;
 
-  size_t _n_marks_since_last_pause;
-
   // At the end of a pause we check the heap occupancy and we decide
   // whether we will start a marking cycle during the next pause. If
   // we decide that we want to do that, we will set this parameter to
@@ -772,9 +758,46 @@
   double _mark_cleanup_start_sec;
   double _mark_closure_time_ms;
 
-  void   calculate_young_list_min_length();
-  void   calculate_young_list_target_length();
-  void   calculate_young_list_target_length(size_t rs_lengths);
+  // Update the young list target length either by setting it to the
+  // desired fixed value or by calculating it using G1's pause
+  // prediction model. If no rs_lengths parameter is passed, predict
+  // the RS lengths using the prediction model, otherwise use the
+  // given rs_lengths as the prediction.
+  void update_young_list_target_length(size_t rs_lengths = (size_t) -1);
+
+  // Calculate and return the minimum desired young list target
+  // length. This is the minimum desired young list length according
+  // to the user's inputs.
+  size_t calculate_young_list_desired_min_length(size_t base_min_length);
+
+  // Calculate and return the maximum desired young list target
+  // length. This is the maximum desired young list length according
+  // to the user's inputs.
+  size_t calculate_young_list_desired_max_length();
+
+  // Calculate and return the maximum young list target length that
+  // can fit into the pause time goal. The parameters are: rs_lengths
+  // represent the prediction of how large the young RSet lengths will
+  // be, base_min_length is the alreay existing number of regions in
+  // the young list, min_length and max_length are the desired min and
+  // max young list length according to the user's inputs.
+  size_t calculate_young_list_target_length(size_t rs_lengths,
+                                            size_t base_min_length,
+                                            size_t desired_min_length,
+                                            size_t desired_max_length);
+
+  // Check whether a given young length (young_length) fits into the
+  // given target pause time and whether the prediction for the amount
+  // of objects to be copied for the given length will fit into the
+  // given free space (expressed by base_free_regions).  It is used by
+  // calculate_young_list_target_length().
+  bool predict_will_fit(size_t young_length, double base_time_ms,
+                        size_t base_free_regions, double target_pause_time_ms);
+
+  // Count the number of bytes used in the CS.
+  void count_CS_bytes_used();
+
+  void update_young_list_size_using_newratio(size_t number_of_heap_regions);
 
 public:
 
@@ -786,7 +809,10 @@
     return CollectorPolicy::G1CollectorPolicyKind;
   }
 
-  void check_prediction_validity();
+  // Check the current value of the young list RSet lengths and
+  // compare it against the last prediction. If the current value is
+  // higher, recalculate the young list target length prediction.
+  void revise_young_list_target_length_if_necessary();
 
   size_t bytes_in_collection_set() {
     return _bytes_in_collection_set_before_gc;
@@ -796,20 +822,12 @@
     return _all_pause_times_ms->num() + 1;
   }
 
-protected:
-
-  // Count the number of bytes used in the CS.
-  void count_CS_bytes_used();
-
-  // Together these do the base cleanup-recording work.  Subclasses might
-  // want to put something between them.
-  void record_concurrent_mark_cleanup_end_work1(size_t freed_bytes,
-                                                size_t max_live_bytes);
-  void record_concurrent_mark_cleanup_end_work2();
+  // This should be called after the heap is resized.
+  void record_new_heap_size(size_t new_number_of_regions);
 
 public:
 
-  virtual void init();
+  void init();
 
   // Create jstat counters for the policy.
   virtual void initialize_gc_policy_counters();
@@ -834,10 +852,9 @@
   // start time, where the given number of bytes were used at the start.
   // This may involve changing the desired size of a collection set.
 
-  virtual void record_stop_world_start();
+  void record_stop_world_start();
 
-  virtual void record_collection_pause_start(double start_time_sec,
-                                             size_t start_used);
+  void record_collection_pause_start(double start_time_sec, size_t start_used);
 
   // Must currently be called while the world is stopped.
   void record_concurrent_mark_init_end(double
@@ -845,23 +862,22 @@
 
   void record_mark_closure_time(double mark_closure_time_ms);
 
-  virtual void record_concurrent_mark_remark_start();
-  virtual void record_concurrent_mark_remark_end();
+  void record_concurrent_mark_remark_start();
+  void record_concurrent_mark_remark_end();
 
-  virtual void record_concurrent_mark_cleanup_start();
-  virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes,
-                                                  size_t max_live_bytes);
-  virtual void record_concurrent_mark_cleanup_completed();
+  void record_concurrent_mark_cleanup_start();
+  void record_concurrent_mark_cleanup_end();
+  void record_concurrent_mark_cleanup_completed();
 
-  virtual void record_concurrent_pause();
-  virtual void record_concurrent_pause_end();
+  void record_concurrent_pause();
+  void record_concurrent_pause_end();
 
-  virtual void record_collection_pause_end();
+  void record_collection_pause_end();
   void print_heap_transition();
 
   // Record the fact that a full collection occurred.
-  virtual void record_full_collection_start();
-  virtual void record_full_collection_end();
+  void record_full_collection_start();
+  void record_full_collection_end();
 
   void record_gc_worker_start_time(int worker_i, double ms) {
     _par_last_gc_worker_start_times_ms[worker_i] = ms;
@@ -946,6 +962,14 @@
     _cur_aux_times_ms[i] += ms;
   }
 
+  void record_ref_proc_time(double ms) {
+    _cur_ref_proc_time_ms = ms;
+  }
+
+  void record_ref_enq_time(double ms) {
+    _cur_ref_enq_time_ms = ms;
+  }
+
 #ifndef PRODUCT
   void record_cc_clear_time(double ms) {
     if (_min_clear_cc_time_ms < 0.0 || ms <= _min_clear_cc_time_ms)
@@ -972,7 +996,7 @@
   // Choose a new collection set.  Marks the chosen regions as being
   // "in_collection_set", and links them together.  The head and number of
   // the collection set are available via access methods.
-  virtual void choose_collection_set(double target_pause_time_ms) = 0;
+  void choose_collection_set(double target_pause_time_ms);
 
   // The head of the list (via "next_in_collection_set()") representing the
   // current collection set.
@@ -1045,7 +1069,7 @@
   // new cycle, as long as we are not already in one. It's best if it
   // is called during a safepoint when the test whether a cycle is in
   // progress or not is stable.
-  bool force_initial_mark_if_outside_cycle();
+  bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause);
 
   // This is called at the very beginning of an evacuation pause (it
   // has to be the first thing that the pause does). If
@@ -1057,19 +1081,12 @@
 
   // If an expansion would be appropriate, because recent GC overhead had
   // exceeded the desired limit, return an amount to expand by.
-  virtual size_t expansion_amount();
-
-  // note start of mark thread
-  void note_start_of_mark_thread();
-
-  // The marked bytes of the "r" has changed; reclassify it's desirability
-  // for marking.  Also asserts that "r" is eligible for a CS.
-  virtual void note_change_in_marked_bytes(HeapRegion* r) = 0;
+  size_t expansion_amount();
 
 #ifndef PRODUCT
   // Check any appropriate marked bytes info, asserting false if
   // something's wrong, else returning "true".
-  virtual bool assertMarkedBytesDataOK() = 0;
+  bool assertMarkedBytesDataOK();
 #endif
 
   // Print tracing information.
@@ -1099,6 +1116,10 @@
     return young_list_length < young_list_max_length;
   }
 
+  size_t young_list_max_length() {
+    return _young_list_max_length;
+  }
+
   void update_region_num(bool young);
 
   bool full_young_gcs() {
@@ -1128,10 +1149,10 @@
     return ret;
   }
 
+private:
   //
   // Survivor regions policy.
   //
-protected:
 
   // Current tenuring threshold, set to 0 if the collector reaches the
   // maximum amount of suvivors regions.
@@ -1204,58 +1225,11 @@
     _survivors_age_table.merge_par(age_table);
   }
 
-  void calculate_max_gc_locker_expansion();
+  void update_max_gc_locker_expansion();
 
   // Calculates survivor space parameters.
-  void calculate_survivors_policy();
-
-};
-
-// This encapsulates a particular strategy for a g1 Collector.
-//
-//      Start a concurrent mark when our heap size is n bytes
-//            greater then our heap size was at the last concurrent
-//            mark.  Where n is a function of the CMSTriggerRatio
-//            and the MinHeapFreeRatio.
-//
-//      Start a g1 collection pause when we have allocated the
-//            average number of bytes currently being freed in
-//            a collection, but only if it is at least one region
-//            full
-//
-//      Resize Heap based on desired
-//      allocation space, where desired allocation space is
-//      a function of survival rate and desired future to size.
-//
-//      Choose collection set by first picking all older regions
-//      which have a survival rate which beats our projected young
-//      survival rate.  Then fill out the number of needed regions
-//      with young regions.
+  void update_survivors_policy();
 
-class G1CollectorPolicy_BestRegionsFirst: public G1CollectorPolicy {
-  CollectionSetChooser* _collectionSetChooser;
-  // If the estimated is less then desirable, resize if possible.
-  void expand_if_possible(size_t numRegions);
-
-  virtual void choose_collection_set(double target_pause_time_ms);
-  virtual void record_collection_pause_start(double start_time_sec,
-                                             size_t start_used);
-  virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes,
-                                                  size_t max_live_bytes);
-  virtual void record_full_collection_end();
-
-public:
-  G1CollectorPolicy_BestRegionsFirst() {
-    _collectionSetChooser = new CollectionSetChooser();
-  }
-  void record_collection_pause_end();
-  // This is not needed any more, after the CSet choosing code was
-  // changed to use the pause prediction work. But let's leave the
-  // hook in just in case.
-  void note_change_in_marked_bytes(HeapRegion* r) { }
-#ifndef PRODUCT
-  bool assertMarkedBytesDataOK();
-#endif
 };
 
 // This should move to some place more general...
@@ -1269,8 +1243,4 @@
   return (sum_of_squares - 2.0 * avg * sum + n_d * avg * avg) / n_d;
 }
 
-// Local Variables: ***
-// c-indentation-style: gnu ***
-// End: ***
-
 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1ErgoVerbose.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "gc_implementation/g1/g1ErgoVerbose.hpp"
+#include "utilities/ostream.hpp"
+
+ErgoLevel G1ErgoVerbose::_level;
+bool G1ErgoVerbose::_enabled[ErgoHeuristicNum];
+
+void G1ErgoVerbose::initialize() {
+  set_level(ErgoLow);
+  set_enabled(false);
+}
+
+void G1ErgoVerbose::set_level(ErgoLevel level) {
+  _level = level;
+}
+
+void G1ErgoVerbose::set_enabled(ErgoHeuristic n, bool enabled) {
+  assert(0 <= n && n < ErgoHeuristicNum, "pre-condition");
+  _enabled[n] = enabled;
+}
+
+void G1ErgoVerbose::set_enabled(bool enabled) {
+  for (int n = 0; n < ErgoHeuristicNum; n += 1) {
+    set_enabled((ErgoHeuristic) n, enabled);
+  }
+}
+
+const char* G1ErgoVerbose::to_string(int tag) {
+  ErgoHeuristic n = extract_heuristic(tag);
+  switch (n) {
+  case ErgoHeapSizing:            return "Heap Sizing";
+  case ErgoCSetConstruction:      return "CSet Construction";
+  case ErgoConcCycles:            return "Concurrent Cycles";
+  case ErgoPartiallyYoungGCs:     return "Partially-Young GCs";
+  default:
+    ShouldNotReachHere();
+    // Keep the Windows compiler happy
+    return NULL;
+  }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1ErgoVerbose.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP
+#define SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP
+
+#include "memory/allocation.hpp"
+#include "utilities/debug.hpp"
+
+// The log of G1's heuristic decisions comprises of a series of
+// records which have a similar format in order to maintain
+// consistency across records and ultimately easier parsing of the
+// output, if we ever choose to do that. Each record consists of:
+// * A time stamp to be able to easily correlate each record with
+// other events.
+// * A unique string to allow us to easily identify such records.
+// * The name of the heuristic the record corresponds to.
+// * An action string which describes the action that G1 did or is
+// about to do.
+// * An optional reason string which describes the reason for the
+// action.
+// * An optional number of name/value pairs which contributed to the
+// decision to take the action described in the record.
+//
+// Each record is associated with a "tag" which is the combination of
+// the heuristic the record corresponds to, as well as the min level
+// of verboseness at which the record should be printed. The tag is
+// checked against the current settings to determine whether the record
+// should be printed or not.
+
+// The available verboseness levels.
+typedef enum {
+  // Determine which part of the tag is occupied by the level.
+  ErgoLevelShift = 8,
+  ErgoLevelMask = ~((1 << ErgoLevelShift) - 1),
+
+  // ErgoLow is 0 so that we don't have to explicitly or a heuristic
+  // id with ErgoLow to keep its use simpler.
+  ErgoLow = 0,
+  ErgoHigh = 1 << ErgoLevelShift
+} ErgoLevel;
+
+// The available heuristics.
+typedef enum {
+  // Determines which part of the tag is occupied by the heuristic id.
+  ErgoHeuristicMask = ~ErgoLevelMask,
+
+  ErgoHeapSizing = 0,
+  ErgoCSetConstruction,
+  ErgoConcCycles,
+  ErgoPartiallyYoungGCs,
+
+  ErgoHeuristicNum
+} ErgoHeuristic;
+
+class G1ErgoVerbose : AllStatic {
+private:
+  // Determines the minimum verboseness level at which records will be
+  // printed.
+  static ErgoLevel _level;
+  // Determines which heuristics are currently enabled.
+  static bool _enabled[ErgoHeuristicNum];
+
+  static ErgoLevel extract_level(int tag) {
+    return (ErgoLevel) (tag & ErgoLevelMask);
+  }
+
+  static ErgoHeuristic extract_heuristic(int tag) {
+    return (ErgoHeuristic) (tag & ErgoHeuristicMask);
+  }
+
+public:
+  // Needs to be explicitly called at GC initialization.
+  static void initialize();
+
+  static void set_level(ErgoLevel level);
+  static void set_enabled(ErgoHeuristic h, bool enabled);
+  // It is applied to all heuristics.
+  static void set_enabled(bool enabled);
+
+  static bool enabled(int tag) {
+    ErgoLevel level = extract_level(tag);
+    ErgoHeuristic n = extract_heuristic(tag);
+    return level <= _level && _enabled[n];
+  }
+
+  // Extract the heuristic id from the tag and return a string with
+  // its name.
+  static const char* to_string(int tag);
+};
+
+// The macros below generate the format string for values of different
+// types and/or metrics.
+
+// The reason for the action is optional and is handled specially: the
+// reason string is concatenated here so it's not necessary to pass it
+// as a parameter.
+#define ergo_format_reason(_reason_) ", reason: " _reason_
+
+// Single parameter format strings
+#define ergo_format_str(_name_)      ", " _name_ ": %s"
+#define ergo_format_region(_name_)   ", " _name_ ": "SIZE_FORMAT" regions"
+#define ergo_format_byte(_name_)     ", " _name_ ": "SIZE_FORMAT" bytes"
+#define ergo_format_double(_name_)   ", " _name_ ": %1.2f"
+#define ergo_format_perc(_name_)     ", " _name_ ": %1.2f %%"
+#define ergo_format_ms(_name_)       ", " _name_ ": %1.2f ms"
+
+// Double parameter format strings
+#define ergo_format_byte_perc(_name_)                                   \
+                             ", " _name_ ": "SIZE_FORMAT" bytes (%1.2f %%)"
+
+// Generates the format string
+#define ergo_format(_action_, _extra_format_)                   \
+  " %1.3f: [G1Ergonomics (%s) " _action_ _extra_format_ "]"
+
+// Conditionally, prints an ergonomic decision record. _extra_format_
+// is the format string for the optional items we'd like to print
+// (i.e., the decision's reason and any associated values). This
+// string should be built up using the ergo_*_format macros (see
+// above) to ensure consistency.
+//
+// Since we cannot rely on the compiler supporting variable argument
+// macros, this macro accepts a fixed number of arguments and passes
+// them to the print method. For convenience, we have wrapper macros
+// below which take a specific number of arguments and set the rest to
+// a default value.
+#define ergo_verbose_common(_tag_, _action_, _extra_format_,            \
+                            _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \
+  do {                                                                  \
+    if (G1ErgoVerbose::enabled((_tag_))) {                              \
+      gclog_or_tty->print_cr(ergo_format(_action_, _extra_format_),     \
+                             os::elapsedTime(),                         \
+                             G1ErgoVerbose::to_string((_tag_)),         \
+                             (_arg0_), (_arg1_), (_arg2_),              \
+                             (_arg3_), (_arg4_), (_arg5_));             \
+    }                                                                   \
+  } while (0)
+
+
+#define ergo_verbose(_tag_, _action_)                           \
+  ergo_verbose_common(_tag_, _action_, "", 0, 0, 0, 0, 0, 0)
+
+#define ergo_verbose0(_tag_, _action_, _extra_format_)                  \
+  ergo_verbose_common(_tag_, _action_, _extra_format_, 0, 0, 0, 0, 0, 0)
+
+#define ergo_verbose1(_tag_, _action_, _extra_format_,                  \
+                      _arg0_)                                           \
+  ergo_verbose_common(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, 0, 0, 0, 0, 0)
+
+#define ergo_verbose2(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_)                                   \
+  ergo_verbose_common(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, 0, 0, 0, 0)
+
+#define ergo_verbose3(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, _arg2_)                           \
+  ergo_verbose_common(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, _arg2_, 0, 0, 0)
+
+#define ergo_verbose4(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, _arg2_, _arg3_)                   \
+  ergo_verbose_common(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, _arg2_, _arg3_, 0, 0)
+
+#define ergo_verbose5(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, _arg2_, _arg3_, _arg4_)           \
+  ergo_verbose_common(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, 0)
+
+#define ergo_verbose6(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_)   \
+  ergo_verbose_common(_tag_, _action_, _extra_format_,                  \
+                      _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_)
+
+#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ERGOVERBOSE_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MMUTracker.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MMUTracker.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -97,10 +97,6 @@
     // or performance (we are GC'ing most of the time anyway!),
     // simply overwrite the oldest entry in the tracker.
 
-    if (G1PolicyVerbose > 1) {
-      warning("MMU Tracker Queue overflow. Replacing earliest entry.");
-    }
-
     _head_index = trim_index(_head_index + 1);
     assert(_head_index == _tail_index, "Because we have a full circular buffer");
     _tail_index = trim_index(_tail_index + 1);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -62,6 +62,8 @@
   // hook up weak ref data so it can be used during Mark-Sweep
   assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
   assert(rp != NULL, "should be non-NULL");
+  assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Precondition");
+
   GenMarkSweep::_ref_processor = rp;
   rp->setup_policy(clear_all_softrefs);
 
@@ -139,6 +141,8 @@
 
   // Process reference objects found during marking
   ReferenceProcessor* rp = GenMarkSweep::ref_processor();
+  assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Sanity");
+
   rp->setup_policy(clear_all_softrefs);
   rp->process_discovered_references(&GenMarkSweep::is_alive,
                                     &GenMarkSweep::keep_alive,
@@ -166,7 +170,6 @@
   GenMarkSweep::follow_mdo_weak_refs();
   assert(GenMarkSweep::_marking_stack.is_empty(), "just drained");
 
-
   // Visit interned string tables and delete unmarked oops
   StringTable::unlink(&GenMarkSweep::is_alive);
   // Clean up unreferenced symbols in symbol table.
@@ -346,7 +349,8 @@
                            NULL,  // do not touch code cache here
                            &GenMarkSweep::adjust_pointer_closure);
 
-  g1h->ref_processor()->weak_oops_do(&GenMarkSweep::adjust_root_pointer_closure);
+  assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
+  g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_root_pointer_closure);
 
   // Now adjust pointers in remaining weak roots.  (All of which should
   // have been cleared if they pointed to non-surviving objects.)
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -27,19 +27,69 @@
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
 
-G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h,
-                                         VirtualSpace* g1_storage_addr) :
+G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm,
+                                           const char* name,
+                                           int ordinal, int spaces,
+                                           size_t min_capacity,
+                                           size_t max_capacity,
+                                           size_t curr_capacity)
+  : GenerationCounters(name, ordinal, spaces, min_capacity,
+                       max_capacity, curr_capacity), _g1mm(g1mm) { }
+
+// We pad the capacity three times given that the young generation
+// contains three spaces (eden and two survivors).
+G1YoungGenerationCounters::G1YoungGenerationCounters(G1MonitoringSupport* g1mm,
+                                                     const char* name)
+  : G1GenerationCounters(g1mm, name, 0 /* ordinal */, 3 /* spaces */,
+               G1MonitoringSupport::pad_capacity(0, 3) /* min_capacity */,
+               G1MonitoringSupport::pad_capacity(g1mm->young_gen_max(), 3),
+               G1MonitoringSupport::pad_capacity(0, 3) /* curr_capacity */) {
+  update_all();
+}
+
+G1OldGenerationCounters::G1OldGenerationCounters(G1MonitoringSupport* g1mm,
+                                                 const char* name)
+  : G1GenerationCounters(g1mm, name, 1 /* ordinal */, 1 /* spaces */,
+               G1MonitoringSupport::pad_capacity(0) /* min_capacity */,
+               G1MonitoringSupport::pad_capacity(g1mm->old_gen_max()),
+               G1MonitoringSupport::pad_capacity(0) /* curr_capacity */) {
+  update_all();
+}
+
+void G1YoungGenerationCounters::update_all() {
+  size_t committed =
+            G1MonitoringSupport::pad_capacity(_g1mm->young_gen_committed(), 3);
+  _current_size->set_value(committed);
+}
+
+void G1OldGenerationCounters::update_all() {
+  size_t committed =
+            G1MonitoringSupport::pad_capacity(_g1mm->old_gen_committed());
+  _current_size->set_value(committed);
+}
+
+G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
   _g1h(g1h),
   _incremental_collection_counters(NULL),
   _full_collection_counters(NULL),
-  _non_young_collection_counters(NULL),
+  _old_collection_counters(NULL),
   _old_space_counters(NULL),
   _young_collection_counters(NULL),
   _eden_counters(NULL),
   _from_counters(NULL),
   _to_counters(NULL),
-  _g1_storage_addr(g1_storage_addr)
-{
+
+  _overall_reserved(0),
+  _overall_committed(0),    _overall_used(0),
+  _young_region_num(0),
+  _young_gen_committed(0),
+  _eden_committed(0),       _eden_used(0),
+  _survivor_committed(0),   _survivor_used(0),
+  _old_committed(0),        _old_used(0) {
+
+  _overall_reserved = g1h->max_capacity();
+  recalculate_sizes();
+
   // Counters for GC collections
   //
   //  name "collector.0".  In a generational collector this would be the
@@ -69,110 +119,147 @@
   // generational GC terms.  The "1, 1" parameters are for
   // the n-th generation (=1) with 1 space.
   // Counters are created from minCapacity, maxCapacity, and capacity
-  _non_young_collection_counters =
-    new GenerationCounters("whole heap", 1, 1, _g1_storage_addr);
+  _old_collection_counters = new G1OldGenerationCounters(this, "old");
 
   //  name  "generation.1.space.0"
   // Counters are created from maxCapacity, capacity, initCapacity,
   // and used.
-  _old_space_counters = new HSpaceCounters("space", 0,
-    _g1h->max_capacity(), _g1h->capacity(), _non_young_collection_counters);
+  _old_space_counters = new HSpaceCounters("space", 0 /* ordinal */,
+    pad_capacity(overall_reserved()) /* max_capacity */,
+    pad_capacity(old_space_committed()) /* init_capacity */,
+   _old_collection_counters);
 
   //   Young collection set
   //  name "generation.0".  This is logically the young generation.
   //  The "0, 3" are paremeters for the n-th genertaion (=0) with 3 spaces.
-  // See  _non_young_collection_counters for additional counters
-  _young_collection_counters = new GenerationCounters("young", 0, 3, NULL);
+  // See  _old_collection_counters for additional counters
+  _young_collection_counters = new G1YoungGenerationCounters(this, "young");
 
-  // Replace "max_heap_byte_size() with maximum young gen size for
-  // g1Collectedheap
   //  name "generation.0.space.0"
   // See _old_space_counters for additional counters
-  _eden_counters = new HSpaceCounters("eden", 0,
-    _g1h->max_capacity(), eden_space_committed(),
+  _eden_counters = new HSpaceCounters("eden", 0 /* ordinal */,
+    pad_capacity(overall_reserved()) /* max_capacity */,
+    pad_capacity(eden_space_committed()) /* init_capacity */,
     _young_collection_counters);
 
   //  name "generation.0.space.1"
   // See _old_space_counters for additional counters
   // Set the arguments to indicate that this survivor space is not used.
-  _from_counters = new HSpaceCounters("s0", 1, (long) 0, (long) 0,
+  _from_counters = new HSpaceCounters("s0", 1 /* ordinal */,
+    pad_capacity(0) /* max_capacity */,
+    pad_capacity(0) /* init_capacity */,
     _young_collection_counters);
+  // Given that this survivor space is not used, we update it here
+  // once to reflect that its used space is 0 so that we don't have to
+  // worry about updating it again later.
+  _from_counters->update_used(0);
 
   //  name "generation.0.space.2"
   // See _old_space_counters for additional counters
-  _to_counters = new HSpaceCounters("s1", 2,
-    _g1h->max_capacity(),
-    survivor_space_committed(),
+  _to_counters = new HSpaceCounters("s1", 2 /* ordinal */,
+    pad_capacity(overall_reserved()) /* max_capacity */,
+    pad_capacity(survivor_space_committed()) /* init_capacity */,
     _young_collection_counters);
 }
 
-size_t G1MonitoringSupport::overall_committed() {
-  return g1h()->capacity();
-}
+void G1MonitoringSupport::recalculate_sizes() {
+  G1CollectedHeap* g1 = g1h();
+
+  // Recalculate all the sizes from scratch. We assume that this is
+  // called at a point where no concurrent updates to the various
+  // values we read here are possible (i.e., at a STW phase at the end
+  // of a GC).
 
-size_t G1MonitoringSupport::overall_used() {
-  return g1h()->used_unlocked();
-}
+  size_t young_list_length = g1->young_list()->length();
+  size_t survivor_list_length = g1->g1_policy()->recorded_survivor_regions();
+  assert(young_list_length >= survivor_list_length, "invariant");
+  size_t eden_list_length = young_list_length - survivor_list_length;
+  // Max length includes any potential extensions to the young gen
+  // we'll do when the GC locker is active.
+  size_t young_list_max_length = g1->g1_policy()->young_list_max_length();
+  assert(young_list_max_length >= survivor_list_length, "invariant");
+  size_t eden_list_max_length = young_list_max_length - survivor_list_length;
 
-size_t G1MonitoringSupport::eden_space_committed() {
-  return MAX2(eden_space_used(), (size_t) HeapRegion::GrainBytes);
-}
+  _overall_used = g1->used_unlocked();
+  _eden_used = eden_list_length * HeapRegion::GrainBytes;
+  _survivor_used = survivor_list_length * HeapRegion::GrainBytes;
+  _young_region_num = young_list_length;
+  _old_used = subtract_up_to_zero(_overall_used, _eden_used + _survivor_used);
+
+  // First calculate the committed sizes that can be calculated independently.
+  _survivor_committed = _survivor_used;
+  _old_committed = HeapRegion::align_up_to_region_byte_size(_old_used);
 
-size_t G1MonitoringSupport::eden_space_used() {
-  size_t young_list_length = g1h()->young_list()->length();
-  size_t eden_used = young_list_length * HeapRegion::GrainBytes;
-  size_t survivor_used = survivor_space_used();
-  eden_used = subtract_up_to_zero(eden_used, survivor_used);
-  return eden_used;
-}
+  // Next, start with the overall committed size.
+  _overall_committed = g1->capacity();
+  size_t committed = _overall_committed;
+
+  // Remove the committed size we have calculated so far (for the
+  // survivor and old space).
+  assert(committed >= (_survivor_committed + _old_committed), "sanity");
+  committed -= _survivor_committed + _old_committed;
+
+  // Next, calculate and remove the committed size for the eden.
+  _eden_committed = eden_list_max_length * HeapRegion::GrainBytes;
+  // Somewhat defensive: be robust in case there are inaccuracies in
+  // the calculations
+  _eden_committed = MIN2(_eden_committed, committed);
+  committed -= _eden_committed;
 
-size_t G1MonitoringSupport::survivor_space_committed() {
-  return MAX2(survivor_space_used(),
-              (size_t) HeapRegion::GrainBytes);
-}
+  // Finally, give the rest to the old space...
+  _old_committed += committed;
+  // ..and calculate the young gen committed.
+  _young_gen_committed = _eden_committed + _survivor_committed;
 
-size_t G1MonitoringSupport::survivor_space_used() {
-  size_t survivor_num = g1h()->g1_policy()->recorded_survivor_regions();
-  size_t survivor_used = survivor_num * HeapRegion::GrainBytes;
-  return survivor_used;
+  assert(_overall_committed ==
+         (_eden_committed + _survivor_committed + _old_committed),
+         "the committed sizes should add up");
+  // Somewhat defensive: cap the eden used size to make sure it
+  // never exceeds the committed size.
+  _eden_used = MIN2(_eden_used, _eden_committed);
+  // _survivor_committed and _old_committed are calculated in terms of
+  // the corresponding _*_used value, so the next two conditions
+  // should hold.
+  assert(_survivor_used <= _survivor_committed, "post-condition");
+  assert(_old_used <= _old_committed, "post-condition");
 }
 
-size_t G1MonitoringSupport::old_space_committed() {
-  size_t committed = overall_committed();
-  size_t eden_committed = eden_space_committed();
-  size_t survivor_committed = survivor_space_committed();
-  committed = subtract_up_to_zero(committed, eden_committed);
-  committed = subtract_up_to_zero(committed, survivor_committed);
-  committed = MAX2(committed, (size_t) HeapRegion::GrainBytes);
-  return committed;
-}
+void G1MonitoringSupport::recalculate_eden_size() {
+  G1CollectedHeap* g1 = g1h();
+
+  // When a new eden region is allocated, only the eden_used size is
+  // affected (since we have recalculated everything else at the last GC).
 
-// See the comment near the top of g1MonitoringSupport.hpp for
-// an explanation of these calculations for "used" and "capacity".
-size_t G1MonitoringSupport::old_space_used() {
-  size_t used = overall_used();
-  size_t eden_used = eden_space_used();
-  size_t survivor_used = survivor_space_used();
-  used = subtract_up_to_zero(used, eden_used);
-  used = subtract_up_to_zero(used, survivor_used);
-  return used;
-}
-
-void G1MonitoringSupport::update_counters() {
-  if (UsePerfData) {
-    eden_counters()->update_capacity(eden_space_committed());
-    eden_counters()->update_used(eden_space_used());
-    to_counters()->update_capacity(survivor_space_committed());
-    to_counters()->update_used(survivor_space_used());
-    old_space_counters()->update_capacity(old_space_committed());
-    old_space_counters()->update_used(old_space_used());
-    non_young_collection_counters()->update_all();
+  size_t young_region_num = g1h()->young_list()->length();
+  if (young_region_num > _young_region_num) {
+    size_t diff = young_region_num - _young_region_num;
+    _eden_used += diff * HeapRegion::GrainBytes;
+    // Somewhat defensive: cap the eden used size to make sure it
+    // never exceeds the committed size.
+    _eden_used = MIN2(_eden_used, _eden_committed);
+    _young_region_num = young_region_num;
   }
 }
 
-void G1MonitoringSupport::update_eden_counters() {
+void G1MonitoringSupport::update_sizes() {
+  recalculate_sizes();
   if (UsePerfData) {
-    eden_counters()->update_capacity(eden_space_committed());
+    eden_counters()->update_capacity(pad_capacity(eden_space_committed()));
+    eden_counters()->update_used(eden_space_used());
+    // only the to survivor space (s1) is active, so we don't need to
+    // update the counteres for the from survivor space (s0)
+    to_counters()->update_capacity(pad_capacity(survivor_space_committed()));
+    to_counters()->update_used(survivor_space_used());
+    old_space_counters()->update_capacity(pad_capacity(old_space_committed()));
+    old_space_counters()->update_used(old_space_used());
+    old_collection_counters()->update_all();
+    young_collection_counters()->update_all();
+  }
+}
+
+void G1MonitoringSupport::update_eden_size() {
+  recalculate_eden_size();
+  if (UsePerfData) {
     eden_counters()->update_used(eden_space_used());
   }
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MonitoringSupport.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -28,101 +28,95 @@
 #include "gc_implementation/shared/hSpaceCounters.hpp"
 
 class G1CollectedHeap;
-class G1SpaceMonitoringSupport;
 
-// Class for monitoring logical spaces in G1.
-// G1 defines a set of regions as a young
-// collection (analogous to a young generation).
-// The young collection is a logical generation
-// with no fixed chunk (see space.hpp) reflecting
-// the address space for the generation.  In addition
-// to the young collection there is its complement
-// the non-young collection that is simply the regions
-// not in the young collection.  The non-young collection
-// is treated here as a logical old generation only
-// because the monitoring tools expect a generational
-// heap.  The monitoring tools expect that a Space
-// (see space.hpp) exists that describe the
-// address space of young collection and non-young
-// collection and such a view is provided here.
+// Class for monitoring logical spaces in G1. It provides data for
+// both G1's jstat counters as well as G1's memory pools.
+//
+// G1 splits the heap into heap regions and each heap region belongs
+// to one of the following categories:
+//
+// * eden      : regions that have been allocated since the last GC
+// * survivors : regions with objects that survived the last few GCs
+// * old       : long-lived non-humongous regions
+// * humongous : humongous regions
+// * free      : free regions
+//
+// The combination of eden and survivor regions form the equivalent of
+// the young generation in the other GCs. The combination of old and
+// humongous regions form the equivalent of the old generation in the
+// other GCs. Free regions do not have a good equivalent in the other
+// GCs given that they can be allocated as any of the other region types.
 //
-// This class provides interfaces to access
-// the value of variables for the young collection
-// that include the "capacity" and "used" of the
-// young collection along with constant values
-// for the minimum and maximum capacities for
-// the logical spaces.  Similarly for the non-young
-// collection.
-//
-// Also provided are counters for G1 concurrent collections
-// and stop-the-world full heap collecitons.
+// The monitoring tools expect the heap to contain a number of
+// generations (young, old, perm) and each generation to contain a
+// number of spaces (young: eden, survivors, old). Given that G1 does
+// not maintain those spaces physically (e.g., the set of
+// non-contiguous eden regions can be considered as a "logical"
+// space), we'll provide the illusion that those generations and
+// spaces exist. In reality, each generation and space refers to a set
+// of heap regions that are potentially non-contiguous.
 //
-// Below is a description of how "used" and "capactiy"
-// (or committed) is calculated for the logical spaces.
+// This class provides interfaces to access the min, current, and max
+// capacity and current occupancy for each of G1's logical spaces and
+// generations we expose to the monitoring tools. Also provided are
+// counters for G1 concurrent collections and stop-the-world full heap
+// collections.
 //
-// 1) The used space calculation for a pool is not necessarily
-// independent of the others. We can easily get from G1 the overall
-// used space in the entire heap, the number of regions in the young
-// generation (includes both eden and survivors), and the number of
-// survivor regions. So, from that we calculate:
+// Below is a description of how the various sizes are calculated.
 //
-//  survivor_used = survivor_num * region_size
-//  eden_used     = young_region_num * region_size - survivor_used
-//  old_gen_used  = overall_used - eden_used - survivor_used
+// * Current Capacity
 //
-// Note that survivor_used and eden_used are upper bounds. To get the
-// actual value we would have to iterate over the regions and add up
-// ->used(). But that'd be expensive. So, we'll accept some lack of
-// accuracy for those two. But, we have to be careful when calculating
-// old_gen_used, in case we subtract from overall_used more then the
-// actual number and our result goes negative.
+//    - heap_capacity = current heap capacity (e.g., current committed size)
+//    - young_gen_capacity = current max young gen target capacity
+//          (i.e., young gen target capacity + max allowed expansion capacity)
+//    - survivor_capacity = current survivor region capacity
+//    - eden_capacity = young_gen_capacity - survivor_capacity
+//    - old_capacity = heap_capacity - young_gen_capacity
+//
+//    What we do in the above is to distribute the free regions among
+//    eden_capacity and old_capacity.
 //
-// 2) Calculating the used space is straightforward, as described
-// above. However, how do we calculate the committed space, given that
-// we allocate space for the eden, survivor, and old gen out of the
-// same pool of regions? One way to do this is to use the used value
-// as also the committed value for the eden and survivor spaces and
-// then calculate the old gen committed space as follows:
+// * Occupancy
 //
-//  old_gen_committed = overall_committed - eden_committed - survivor_committed
+//    - young_gen_used = current young region capacity
+//    - survivor_used = survivor_capacity
+//    - eden_used = young_gen_used - survivor_used
+//    - old_used = overall_used - young_gen_used
 //
-// Maybe a better way to do that would be to calculate used for eden
-// and survivor as a sum of ->used() over their regions and then
-// calculate committed as region_num * region_size (i.e., what we use
-// to calculate the used space now). This is something to consider
-// in the future.
+//    Unfortunately, we currently only keep track of the number of
+//    currently allocated young and survivor regions + the overall used
+//    bytes in the heap, so the above can be a little inaccurate.
+//
+// * Min Capacity
 //
-// 3) Another decision that is again not straightforward is what is
-// the max size that each memory pool can grow to. One way to do this
-// would be to use the committed size for the max for the eden and
-// survivors and calculate the old gen max as follows (basically, it's
-// a similar pattern to what we use for the committed space, as
-// described above):
+//    We set this to 0 for all spaces. We could consider setting the old
+//    min capacity to the min capacity of the heap (see 7078465).
+//
+// * Max Capacity
 //
-//  old_gen_max = overall_max - eden_max - survivor_max
+//    For jstat, we set the max capacity of all spaces to heap_capacity,
+//    given that we don't always have a reasonably upper bound on how big
+//    each space can grow. For the memory pools, we actually make the max
+//    capacity undefined. We could consider setting the old max capacity
+//    to the max capacity of the heap (see 7078465).
 //
-// Unfortunately, the above makes the max of each pool fluctuate over
-// time and, even though this is allowed according to the spec, it
-// broke several assumptions in the M&M framework (there were cases
-// where used would reach a value greater than max). So, for max we
-// use -1, which means "undefined" according to the spec.
+// If we had more accurate occupancy / capacity information per
+// region set the above calculations would be greatly simplified and
+// be made more accurate.
 //
-// 4) Now, there is a very subtle issue with all the above. The
-// framework will call get_memory_usage() on the three pools
-// asynchronously. As a result, each call might get a different value
-// for, say, survivor_num which will yield inconsistent values for
-// eden_used, survivor_used, and old_gen_used (as survivor_num is used
-// in the calculation of all three). This would normally be
-// ok. However, it's possible that this might cause the sum of
-// eden_used, survivor_used, and old_gen_used to go over the max heap
-// size and this seems to sometimes cause JConsole (and maybe other
-// clients) to get confused. There's not a really an easy / clean
-// solution to this problem, due to the asynchrounous nature of the
-// framework.
+// We update all the above synchronously and we store the results in
+// fields so that we just read said fields when needed. A subtle point
+// is that all the above sizes need to be recalculated when the old
+// gen changes capacity (after a GC or after a humongous allocation)
+// but only the eden occupancy changes when a new eden region is
+// allocated. So, in the latter case we have minimal recalcuation to
+// do which is important as we want to keep the eden region allocation
+// path as low-overhead as possible.
 
 class G1MonitoringSupport : public CHeapObj {
+  friend class VMStructs;
+
   G1CollectedHeap* _g1h;
-  VirtualSpace* _g1_storage_addr;
 
   // jstat performance counters
   //  incremental collections both fully and partially young
@@ -133,9 +127,9 @@
   // _from_counters, and _to_counters are associated with
   // this "generational" counter.
   GenerationCounters*  _young_collection_counters;
-  //  non-young collection set counters. The _old_space_counters
+  //  old collection set counters. The _old_space_counters
   // below are associated with this "generational" counter.
-  GenerationCounters*  _non_young_collection_counters;
+  GenerationCounters*  _old_collection_counters;
   // Counters for the capacity and used for
   //   the whole heap
   HSpaceCounters*      _old_space_counters;
@@ -145,6 +139,27 @@
   HSpaceCounters*      _from_counters;
   HSpaceCounters*      _to_counters;
 
+  // When it's appropriate to recalculate the various sizes (at the
+  // end of a GC, when a new eden region is allocated, etc.) we store
+  // them here so that we can easily report them when needed and not
+  // have to recalculate them every time.
+
+  size_t _overall_reserved;
+  size_t _overall_committed;
+  size_t _overall_used;
+
+  size_t _young_region_num;
+  size_t _young_gen_committed;
+  size_t _eden_committed;
+  size_t _eden_used;
+  size_t _survivor_committed;
+  size_t _survivor_used;
+
+  size_t _old_committed;
+  size_t _old_used;
+
+  G1CollectedHeap* g1h() { return _g1h; }
+
   // It returns x - y if x > y, 0 otherwise.
   // As described in the comment above, some of the inputs to the
   // calculations we have to do are obtained concurrently and hence
@@ -160,15 +175,35 @@
     }
   }
 
+  // Recalculate all the sizes.
+  void recalculate_sizes();
+  // Recalculate only what's necessary when a new eden region is allocated.
+  void recalculate_eden_size();
+
  public:
-  G1MonitoringSupport(G1CollectedHeap* g1h, VirtualSpace* g1_storage_addr);
+  G1MonitoringSupport(G1CollectedHeap* g1h);
 
-  G1CollectedHeap* g1h() { return _g1h; }
-  VirtualSpace* g1_storage_addr() { return _g1_storage_addr; }
+  // Unfortunately, the jstat tool assumes that no space has 0
+  // capacity. In our case, given that each space is logical, it's
+  // possible that no regions will be allocated to it, hence to have 0
+  // capacity (e.g., if there are no survivor regions, the survivor
+  // space has 0 capacity). The way we deal with this is to always pad
+  // each capacity value we report to jstat by a very small amount to
+  // make sure that it's never zero. Given that we sometimes have to
+  // report a capacity of a generation that contains several spaces
+  // (e.g., young gen includes one eden, two survivor spaces), the
+  // mult parameter is provided in order to adding the appropriate
+  // padding multiple times so that the capacities add up correctly.
+  static size_t pad_capacity(size_t size_bytes, size_t mult = 1) {
+    return size_bytes + MinObjAlignmentInBytes * mult;
+  }
 
-  // Performance Counter accessors
-  void update_counters();
-  void update_eden_counters();
+  // Recalculate all the sizes from scratch and update all the jstat
+  // counters accordingly.
+  void update_sizes();
+  // Recalculate only what's necessary when a new eden region is
+  // allocated and update any jstat counters that need to be updated.
+  void update_eden_size();
 
   CollectorCounters* incremental_collection_counters() {
     return _incremental_collection_counters;
@@ -176,8 +211,11 @@
   CollectorCounters* full_collection_counters() {
     return _full_collection_counters;
   }
-  GenerationCounters* non_young_collection_counters() {
-    return _non_young_collection_counters;
+  GenerationCounters* young_collection_counters() {
+    return _young_collection_counters;
+  }
+  GenerationCounters* old_collection_counters() {
+    return _old_collection_counters;
   }
   HSpaceCounters*      old_space_counters() { return _old_space_counters; }
   HSpaceCounters*      eden_counters() { return _eden_counters; }
@@ -187,17 +225,45 @@
   // Monitoring support used by
   //   MemoryService
   //   jstat counters
-  size_t overall_committed();
-  size_t overall_used();
+
+  size_t overall_reserved()           { return _overall_reserved;     }
+  size_t overall_committed()          { return _overall_committed;    }
+  size_t overall_used()               { return _overall_used;         }
 
-  size_t eden_space_committed();
-  size_t eden_space_used();
+  size_t young_gen_committed()        { return _young_gen_committed;  }
+  size_t young_gen_max()              { return overall_reserved();    }
+  size_t eden_space_committed()       { return _eden_committed;       }
+  size_t eden_space_used()            { return _eden_used;            }
+  size_t survivor_space_committed()   { return _survivor_committed;   }
+  size_t survivor_space_used()        { return _survivor_used;        }
+
+  size_t old_gen_committed()          { return old_space_committed(); }
+  size_t old_gen_max()                { return overall_reserved();    }
+  size_t old_space_committed()        { return _old_committed;        }
+  size_t old_space_used()             { return _old_used;             }
+};
 
-  size_t survivor_space_committed();
-  size_t survivor_space_used();
+class G1GenerationCounters: public GenerationCounters {
+protected:
+  G1MonitoringSupport* _g1mm;
+
+public:
+  G1GenerationCounters(G1MonitoringSupport* g1mm,
+                       const char* name, int ordinal, int spaces,
+                       size_t min_capacity, size_t max_capacity,
+                       size_t curr_capacity);
+};
 
-  size_t old_space_committed();
-  size_t old_space_used();
+class G1YoungGenerationCounters: public G1GenerationCounters {
+public:
+  G1YoungGenerationCounters(G1MonitoringSupport* g1mm, const char* name);
+  virtual void update_all();
+};
+
+class G1OldGenerationCounters: public G1GenerationCounters {
+public:
+  G1OldGenerationCounters(G1MonitoringSupport* g1mm, const char* name);
+  virtual void update_all();
 };
 
 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1MONITORINGSUPPORT_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -34,6 +34,7 @@
 class CMMarkStack;
 class G1ParScanThreadState;
 class CMTask;
+class ReferenceProcessor;
 
 // A class that scans oops in a given heap region (much as OopsInGenClosure
 // scans oops in a generation.)
@@ -50,6 +51,8 @@
   G1RemSet* _g1_rem;
   ConcurrentMark* _cm;
   G1ParScanThreadState* _par_scan_state;
+  bool _during_initial_mark;
+  bool _mark_in_progress;
 public:
   G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
   bool apply_to_weak_ref_discovered_field() { return true; }
@@ -57,8 +60,10 @@
 
 class G1ParPushHeapRSClosure : public G1ParClosureSuper {
 public:
-  G1ParPushHeapRSClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
+  G1ParPushHeapRSClosure(G1CollectedHeap* g1,
+                         G1ParScanThreadState* par_scan_state):
     G1ParClosureSuper(g1, par_scan_state) { }
+
   template <class T> void do_oop_nv(T* p);
   virtual void do_oop(oop* p)          { do_oop_nv(p); }
   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
@@ -66,8 +71,13 @@
 
 class G1ParScanClosure : public G1ParClosureSuper {
 public:
-  G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
-    G1ParClosureSuper(g1, par_scan_state) { }
+  G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) :
+    G1ParClosureSuper(g1, par_scan_state)
+  {
+    assert(_ref_processor == NULL, "sanity");
+    _ref_processor = rp;
+  }
+
   template <class T> void do_oop_nv(T* p);
   virtual void do_oop(oop* p)          { do_oop_nv(p); }
   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
@@ -90,9 +100,18 @@
 
 class G1ParScanPartialArrayClosure : public G1ParClosureSuper {
   G1ParScanClosure _scanner;
+
 public:
-  G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
-    G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state) { }
+  G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) :
+    G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state, rp)
+  {
+    assert(_ref_processor == NULL, "sanity");
+  }
+
+  G1ParScanClosure* scanner() {
+    return &_scanner;
+  }
+
   template <class T> void do_oop_nv(T* p);
   virtual void do_oop(oop* p)       { do_oop_nv(p); }
   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
@@ -102,8 +121,9 @@
 class G1ParCopyHelper : public G1ParClosureSuper {
   G1ParScanClosure *_scanner;
 protected:
-  template <class T> void mark_forwardee(T* p);
-  oop copy_to_survivor_space(oop obj);
+  template <class T> void mark_object(T* p);
+  oop copy_to_survivor_space(oop obj, bool should_mark_root,
+                                      bool should_mark_copy);
 public:
   G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
                   G1ParScanClosure *scanner) :
@@ -111,17 +131,25 @@
 };
 
 template<bool do_gen_barrier, G1Barrier barrier,
-         bool do_mark_forwardee>
+         bool do_mark_object>
 class G1ParCopyClosure : public G1ParCopyHelper {
   G1ParScanClosure _scanner;
+
   template <class T> void do_oop_work(T* p);
+
 public:
-  G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
-    _scanner(g1, par_scan_state), G1ParCopyHelper(g1, par_scan_state, &_scanner) { }
+  G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
+                   ReferenceProcessor* rp) :
+    _scanner(g1, par_scan_state, rp),
+    G1ParCopyHelper(g1, par_scan_state, &_scanner)
+  {
+    assert(_ref_processor == NULL, "sanity");
+  }
+
+  G1ParScanClosure* scanner() { return &_scanner; }
+
   template <class T> void do_oop_nv(T* p) {
     do_oop_work(p);
-    if (do_mark_forwardee)
-      mark_forwardee(p);
   }
   virtual void do_oop(oop* p)       { do_oop_nv(p); }
   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
@@ -129,21 +157,25 @@
 
 typedef G1ParCopyClosure<false, G1BarrierNone, false> G1ParScanExtRootClosure;
 typedef G1ParCopyClosure<true,  G1BarrierNone, false> G1ParScanPermClosure;
-typedef G1ParCopyClosure<false, G1BarrierRS,   false> G1ParScanHeapRSClosure;
+
 typedef G1ParCopyClosure<false, G1BarrierNone, true> G1ParScanAndMarkExtRootClosure;
 typedef G1ParCopyClosure<true,  G1BarrierNone, true> G1ParScanAndMarkPermClosure;
-typedef G1ParCopyClosure<false, G1BarrierRS,   true> G1ParScanAndMarkHeapRSClosure;
+
+// The following closure types are no longer used but are retained
+// for historical reasons:
+// typedef G1ParCopyClosure<false, G1BarrierRS,   false> G1ParScanHeapRSClosure;
+// typedef G1ParCopyClosure<false, G1BarrierRS,   true> G1ParScanAndMarkHeapRSClosure;
 
-// This is the only case when we set skip_cset_test. Basically, this
-// closure is (should?) only be called directly while we're draining
-// the overflow and task queues. In that case we know that the
-// reference in question points into the collection set, otherwise we
-// would not have pushed it on the queue. The following is defined in
-// g1_specialized_oop_closures.hpp.
-// typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure;
-// We need a separate closure to handle references during evacuation
-// failure processing, as we cannot asume that the reference already
-// points into the collection set (like G1ParScanHeapEvacClosure does).
+// The following closure type is defined in g1_specialized_oop_closures.hpp:
+//
+// typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacClosure;
+
+// We use a separate closure to handle references during evacuation
+// failure processing.
+// We could have used another instance of G1ParScanHeapEvacClosure
+// (since that closure no longer assumes that the references it
+// handles point into the collection set).
+
 typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure;
 
 class FilterIntoCSClosure: public OopClosure {
@@ -152,9 +184,10 @@
   DirtyCardToOopClosure* _dcto_cl;
 public:
   FilterIntoCSClosure(  DirtyCardToOopClosure* dcto_cl,
-                        G1CollectedHeap* g1, OopClosure* oc) :
-    _dcto_cl(dcto_cl), _g1(g1), _oc(oc)
-  {}
+                        G1CollectedHeap* g1,
+                        OopClosure* oc) :
+    _dcto_cl(dcto_cl), _g1(g1), _oc(oc) { }
+
   template <class T> void do_oop_nv(T* p);
   virtual void do_oop(oop* p)        { do_oop_nv(p); }
   virtual void do_oop(narrowOop* p)  { do_oop_nv(p); }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -234,6 +234,7 @@
   HeapRegion *startRegion = calculateStartRegion(worker_i);
 
   ScanRSClosure scanRScl(oc, worker_i);
+
   _g1->collection_set_iterate_from(startRegion, &scanRScl);
   scanRScl.set_try_claimed();
   _g1->collection_set_iterate_from(startRegion, &scanRScl);
@@ -283,6 +284,7 @@
   double start = os::elapsedTime();
   // Apply the given closure to all remaining log entries.
   RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq);
+
   _g1->iterate_dirty_card_closure(&into_cset_update_rs_cl, into_cset_dcq, false, worker_i);
 
   // Now there should be no dirty cards.
--- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(MemRegion whole_heap,
                                                  int max_covered_regions) :
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -124,9 +124,6 @@
   develop(bool, G1RSBarrierNullFilter, true,                                \
           "If true, generate null-pointer filtering code in RS barrier")    \
                                                                             \
-  develop(bool, G1PrintCTFilterStats, false,                                \
-          "If true, print stats on RS filtering effectiveness")             \
-                                                                            \
   develop(bool, G1DeferredRSUpdate, true,                                   \
           "If true, use deferred RS updates")                               \
                                                                             \
@@ -137,9 +134,9 @@
   develop(bool, G1RSCountHisto, false,                                      \
           "If true, print a histogram of RS occupancies after each pause")  \
                                                                             \
-  product(bool, G1PrintRegionLivenessInfo, false,                           \
-          "Prints the liveness information for all regions in the heap "    \
-          "at the end of a marking cycle.")                                 \
+  diagnostic(bool, G1PrintRegionLivenessInfo, false,                        \
+            "Prints the liveness information for all regions in the heap "  \
+            "at the end of a marking cycle.")                               \
                                                                             \
   develop(bool, G1PrintParCleanupStats, false,                              \
           "When true, print extra stats about parallel cleanup.")           \
@@ -231,7 +228,7 @@
           "the number of regions for which we'll print a surv rate "        \
           "summary.")                                                       \
                                                                             \
-  product(intx, G1ReservePercent, 10,                                       \
+  product(uintx, G1ReservePercent, 10,                                      \
           "It determines the minimum reserve we should have in the heap "   \
           "to minimize the probability of promotion failure.")              \
                                                                             \
@@ -293,10 +290,6 @@
           "each evacuation pause in order to artificially fill up the "     \
           "heap and stress the marking implementation.")                    \
                                                                             \
-  develop(bool, ReduceInitialCardMarksForG1, false,                         \
-          "When ReduceInitialCardMarks is true, this flag setting "         \
-          " controls whether G1 allows the RICM optimization")              \
-                                                                            \
   develop(bool, G1ExitOnExpansionFailure, false,                            \
           "Raise a fatal VM exit out of memory failure in the event "       \
           " that heap expansion fails due to running out of swap.")         \
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,7 +36,7 @@
 };
 
 template<bool do_gen_barrier, G1Barrier barrier,
-         bool do_mark_forwardee>
+         bool do_mark_object>
 class G1ParCopyClosure;
 class G1ParScanClosure;
 class G1ParPushHeapRSClosure;
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -33,11 +33,11 @@
 #include "memory/iterator.hpp"
 #include "oops/oop.inline.hpp"
 
-int HeapRegion::LogOfHRGrainBytes = 0;
-int HeapRegion::LogOfHRGrainWords = 0;
-int HeapRegion::GrainBytes        = 0;
-int HeapRegion::GrainWords        = 0;
-int HeapRegion::CardsPerRegion    = 0;
+int    HeapRegion::LogOfHRGrainBytes = 0;
+int    HeapRegion::LogOfHRGrainWords = 0;
+size_t HeapRegion::GrainBytes        = 0;
+size_t HeapRegion::GrainWords        = 0;
+size_t HeapRegion::CardsPerRegion    = 0;
 
 HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
                                  HeapRegion* hr, OopClosure* cl,
@@ -45,7 +45,7 @@
                                  FilterKind fk) :
   ContiguousSpaceDCTOC(hr, cl, precision, NULL),
   _hr(hr), _fk(fk), _g1(g1)
-{}
+{ }
 
 FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
                                                    OopClosure* oc) :
@@ -210,15 +210,17 @@
                                               HeapWord* top,
                                               OopClosure* cl) {
   G1CollectedHeap* g1h = _g1;
+  int oop_size;
+  OopClosure* cl2 = NULL;
 
-  int oop_size;
-
-  OopClosure* cl2 = cl;
   FilterIntoCSClosure intoCSFilt(this, g1h, cl);
   FilterOutOfRegionClosure outOfRegionFilt(_hr, cl);
+
   switch (_fk) {
+  case NoFilterKind:          cl2 = cl; break;
   case IntoCSFilterKind:      cl2 = &intoCSFilt; break;
   case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break;
+  default:                    ShouldNotReachHere();
   }
 
   // Start filtering what we add to the remembered set. If the object is
@@ -239,16 +241,19 @@
     case NoFilterKind:
       bottom = walk_mem_region_loop(cl, g1h, _hr, bottom, top);
       break;
+
     case IntoCSFilterKind: {
       FilterIntoCSClosure filt(this, g1h, cl);
       bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
       break;
     }
+
     case OutOfRegionFilterKind: {
       FilterOutOfRegionClosure filt(_hr, cl);
       bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
       break;
     }
+
     default:
       ShouldNotReachHere();
     }
@@ -317,11 +322,11 @@
   guarantee(GrainBytes == 0, "we should only set it once");
   // The cast to int is safe, given that we've bounded region_size by
   // MIN_REGION_SIZE and MAX_REGION_SIZE.
-  GrainBytes = (int) region_size;
+  GrainBytes = (size_t)region_size;
 
   guarantee(GrainWords == 0, "we should only set it once");
   GrainWords = GrainBytes >> LogHeapWordSize;
-  guarantee(1 << LogOfHRGrainWords == GrainWords, "sanity");
+  guarantee((size_t)(1 << LogOfHRGrainWords) == GrainWords, "sanity");
 
   guarantee(CardsPerRegion == 0, "we should only set it once");
   CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
@@ -374,8 +379,7 @@
 
 void HeapRegion::par_clear() {
   assert(used() == 0, "the region should have been already cleared");
-  assert(capacity() == (size_t) HeapRegion::GrainBytes,
-         "should be back to normal");
+  assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
   HeapRegionRemSet* hrrs = rem_set();
   hrrs->clear();
   CardTableModRefBS* ct_bs =
@@ -431,7 +435,7 @@
     assert(end() == _orig_end, "sanity");
   }
 
-  assert(capacity() == (size_t) HeapRegion::GrainBytes, "pre-condition");
+  assert(capacity() == HeapRegion::GrainBytes, "pre-condition");
   _humongous_type = NotHumongous;
   _humongous_start_region = NULL;
 }
@@ -483,12 +487,13 @@
 HeapRegion(size_t hrs_index, G1BlockOffsetSharedArray* sharedOffsetArray,
            MemRegion mr, bool is_zeroed)
   : G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed),
-    _next_fk(HeapRegionDCTOC::NoFilterKind), _hrs_index(hrs_index),
+    _hrs_index(hrs_index),
     _humongous_type(NotHumongous), _humongous_start_region(NULL),
     _in_collection_set(false),
     _next_in_special_set(NULL), _orig_end(NULL),
     _claimed(InitialClaimValue), _evacuation_failed(false),
     _prev_marked_bytes(0), _next_marked_bytes(0), _sort_index(-1),
+    _gc_efficiency(0.0),
     _young_type(NotYoung), _next_young_region(NULL),
     _next_dirty_cards_region(NULL), _next(NULL), _pending_removal(false),
 #ifdef ASSERT
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -118,7 +118,6 @@
                   FilterKind fk);
 };
 
-
 // The complicating factor is that BlockOffsetTable diverged
 // significantly, and we need functionality that is only in the G1 version.
 // So I copied that code, which led to an alternate G1 version of
@@ -223,10 +222,6 @@
     ContinuesHumongous
   };
 
-  // The next filter kind that should be used for a "new_dcto_cl" call with
-  // the "traditional" signature.
-  HeapRegionDCTOC::FilterKind _next_fk;
-
   // Requires that the region "mr" be dense with objects, and begin and end
   // with an object.
   void oops_in_mr_iterate(MemRegion mr, OopClosure* cl);
@@ -351,16 +346,17 @@
              G1BlockOffsetSharedArray* sharedOffsetArray,
              MemRegion mr, bool is_zeroed);
 
-  static int LogOfHRGrainBytes;
-  static int LogOfHRGrainWords;
-  // The normal type of these should be size_t. However, they used to
-  // be members of an enum before and they are assumed by the
-  // compilers to be ints. To avoid going and fixing all their uses,
-  // I'm declaring them as ints. I'm not anticipating heap region
-  // sizes to reach anywhere near 2g, so using an int here is safe.
-  static int GrainBytes;
-  static int GrainWords;
-  static int CardsPerRegion;
+  static int    LogOfHRGrainBytes;
+  static int    LogOfHRGrainWords;
+
+  static size_t GrainBytes;
+  static size_t GrainWords;
+  static size_t CardsPerRegion;
+
+  static size_t align_up_to_region_byte_size(size_t sz) {
+    return (sz + (size_t) GrainBytes - 1) &
+                                      ~((1 << (size_t) LogOfHRGrainBytes) - 1);
+  }
 
   // It sets up the heap region size (GrainBytes / GrainWords), as
   // well as other related fields that are based on the heap region
@@ -573,40 +569,14 @@
   // allocated in the current region before the last call to "save_mark".
   void oop_before_save_marks_iterate(OopClosure* cl);
 
-  // This call determines the "filter kind" argument that will be used for
-  // the next call to "new_dcto_cl" on this region with the "traditional"
-  // signature (i.e., the call below.)  The default, in the absence of a
-  // preceding call to this method, is "NoFilterKind", and a call to this
-  // method is necessary for each such call, or else it reverts to the
-  // default.
-  // (This is really ugly, but all other methods I could think of changed a
-  // lot of main-line code for G1.)
-  void set_next_filter_kind(HeapRegionDCTOC::FilterKind nfk) {
-    _next_fk = nfk;
-  }
-
   DirtyCardToOopClosure*
   new_dcto_closure(OopClosure* cl,
                    CardTableModRefBS::PrecisionStyle precision,
                    HeapRegionDCTOC::FilterKind fk);
 
-#if WHASSUP
-  DirtyCardToOopClosure*
-  new_dcto_closure(OopClosure* cl,
-                   CardTableModRefBS::PrecisionStyle precision,
-                   HeapWord* boundary) {
-    assert(boundary == NULL, "This arg doesn't make sense here.");
-    DirtyCardToOopClosure* res = new_dcto_closure(cl, precision, _next_fk);
-    _next_fk = HeapRegionDCTOC::NoFilterKind;
-    return res;
-  }
-#endif
-
-  //
   // Note the start or end of marking. This tells the heap region
   // that the collector is about to start or has finished (concurrently)
   // marking the heap.
-  //
 
   // Note the start of a marking phase. Record the
   // start of the unmarked area of the region here.
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -148,7 +148,7 @@
       CardIdx_t from_card = (CardIdx_t)
           hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize);
 
-      assert(0 <= from_card && from_card < HeapRegion::CardsPerRegion,
+      assert(0 <= from_card && (size_t)from_card < HeapRegion::CardsPerRegion,
              "Must be in range.");
       add_card_work(from_card, par);
     }
@@ -639,7 +639,7 @@
         uintptr_t(from_hr->bottom())
           >> CardTableModRefBS::card_shift;
       CardIdx_t card_index = from_card - from_hr_bot_card_index;
-      assert(0 <= card_index && card_index < HeapRegion::CardsPerRegion,
+      assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
              "Must be in range.");
       if (G1HRRSUseSparseTable &&
           _sparse_table.add_card(from_hrs_ind, card_index)) {
@@ -1066,7 +1066,7 @@
       uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift;
     assert(from_card >= hr_bot_card_index, "Inv");
     CardIdx_t card_index = from_card - hr_bot_card_index;
-    assert(0 <= card_index && card_index < HeapRegion::CardsPerRegion,
+    assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
            "Must be in range.");
     return _sparse_table.contains_card(hr_ind, card_index);
   }
@@ -1191,7 +1191,7 @@
   _is = Sparse;
   // Set these values so that we increment to the first region.
   _coarse_cur_region_index = -1;
-  _coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);;
+  _coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);
 
   _cur_region_cur_card = 0;
 
@@ -1270,7 +1270,7 @@
 bool HeapRegionRemSetIterator::fine_has_next() {
   return
     _fine_cur_prt != NULL &&
-    _cur_region_cur_card < (size_t) HeapRegion::CardsPerRegion;
+    _cur_region_cur_card < HeapRegion::CardsPerRegion;
 }
 
 bool HeapRegionRemSetIterator::has_next(size_t& card_index) {
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -395,8 +395,8 @@
   // Coarse table iteration fields:
 
   // Current region index;
-  int _coarse_cur_region_index;
-  int _coarse_cur_region_cur_card;
+  int    _coarse_cur_region_index;
+  size_t _coarse_cur_region_cur_card;
 
   bool coarse_has_next(size_t& card_index);
 
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -56,6 +56,7 @@
 // and maintain that: _length <= _allocated_length <= _max_length
 
 class HeapRegionSeq: public CHeapObj {
+  friend class VMStructs;
 
   // The array that holds the HeapRegions.
   HeapRegion** _regions;
--- a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 PtrQueue::PtrQueue(PtrQueueSet* qset, bool perm, bool active) :
   _qset(qset), _buf(NULL), _index(0), _active(active),
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -29,6 +29,7 @@
 #include "memory/sharedHeap.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/thread.hpp"
+#include "runtime/vmThread.hpp"
 
 // This method removes entries from an SATB buffer that will not be
 // useful to the concurrent marking threads. An entry is removed if it
@@ -252,9 +253,18 @@
       t->satb_mark_queue().apply_closure(_par_closures[worker]);
     }
   }
-  // We'll have worker 0 do this one.
-  if (worker == 0) {
-    shared_satb_queue()->apply_closure(_par_closures[0]);
+
+  // We also need to claim the VMThread so that its parity is updated
+  // otherwise the next call to Thread::possibly_parallel_oops_do inside
+  // a StrongRootsScope might skip the VMThread because it has a stale
+  // parity that matches the parity set by the StrongRootsScope
+  //
+  // Whichever worker succeeds in claiming the VMThread gets to do
+  // the shared queue.
+
+  VMThread* vmt = VMThread::vm_thread();
+  if (vmt->claim_oops_do(true, parity)) {
+    shared_satb_queue()->apply_closure(_par_closures[worker]);
   }
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
+#define SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
+
+#include "gc_implementation/g1/heapRegion.hpp"
+#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
+#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
+
+#define VM_STRUCTS_G1(nonstatic_field, static_field)                          \
+                                                                              \
+  static_field(HeapRegion, GrainBytes, size_t)                                \
+                                                                              \
+  nonstatic_field(HeapRegionSeq,   _regions, HeapRegion**)                    \
+  nonstatic_field(HeapRegionSeq,   _length,  size_t)                          \
+                                                                              \
+  nonstatic_field(G1CollectedHeap, _hrs,                HeapRegionSeq)        \
+  nonstatic_field(G1CollectedHeap, _g1_committed,       MemRegion)            \
+  nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t)               \
+  nonstatic_field(G1CollectedHeap, _g1mm,               G1MonitoringSupport*) \
+                                                                              \
+  nonstatic_field(G1MonitoringSupport, _eden_committed,     size_t)           \
+  nonstatic_field(G1MonitoringSupport, _eden_used,          size_t)           \
+  nonstatic_field(G1MonitoringSupport, _survivor_committed, size_t)           \
+  nonstatic_field(G1MonitoringSupport, _survivor_used,      size_t)           \
+  nonstatic_field(G1MonitoringSupport, _old_committed,      size_t)           \
+  nonstatic_field(G1MonitoringSupport, _old_used,           size_t)           \
+
+
+#define VM_TYPES_G1(declare_type, declare_toplevel_type)                      \
+                                                                              \
+  declare_type(G1CollectedHeap, SharedHeap)                                   \
+                                                                              \
+  declare_type(HeapRegion, ContiguousSpace)                                   \
+  declare_toplevel_type(HeapRegionSeq)                                        \
+  declare_toplevel_type(G1MonitoringSupport)                                  \
+                                                                              \
+  declare_toplevel_type(G1CollectedHeap*)                                     \
+  declare_toplevel_type(HeapRegion*)                                          \
+  declare_toplevel_type(G1MonitoringSupport*)                                 \
+
+
+#endif // SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -98,7 +98,7 @@
 
     // At this point we are supposed to start a concurrent cycle. We
     // will do so if one is not already in progress.
-    bool res = g1h->g1_policy()->force_initial_mark_if_outside_cycle();
+    bool res = g1h->g1_policy()->force_initial_mark_if_outside_cycle(_gc_cause);
 
     // The above routine returns true if we were able to force the
     // next GC pause to be an initial mark; it returns false if a
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -38,6 +38,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 bool
 ParMarkBitMap::initialize(MemRegion covered_region)
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -909,10 +909,6 @@
     }
     young_gen()->verify(allow_dirty);
   }
-  if (!silent) {
-    gclog_or_tty->print("ref_proc ");
-  }
-  ReferenceProcessor::verify();
 }
 
 void ParallelScavengeHeap::print_heap_change(size_t prev_used) {
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -80,10 +80,6 @@
       Universe::oops_do(&mark_and_push_closure);
       break;
 
-    case reference_processing:
-      ReferenceProcessor::oops_do(&mark_and_push_closure);
-      break;
-
     case jni_handles:
       JNIHandles::oops_do(&mark_and_push_closure);
       break;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -98,8 +98,7 @@
     management            = 6,
     jvmti                 = 7,
     system_dictionary     = 8,
-    reference_processing  = 9,
-    code_cache            = 10
+    code_cache            = 9
   };
  private:
   RootType _root_type;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -198,10 +198,9 @@
 
     allocate_stacks();
 
-    NOT_PRODUCT(ref_processor()->verify_no_references_recorded());
     COMPILER2_PRESENT(DerivedPointerTable::clear());
 
-    ref_processor()->enable_discovery();
+    ref_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
     ref_processor()->setup_policy(clear_all_softrefs);
 
     mark_sweep_phase1(clear_all_softrefs);
@@ -516,7 +515,6 @@
   {
     ParallelScavengeHeap::ParStrongRootsScope psrs;
     Universe::oops_do(mark_and_push_closure());
-    ReferenceProcessor::oops_do(mark_and_push_closure());
     JNIHandles::oops_do(mark_and_push_closure());   // Global (strong) JNI handles
     CodeBlobToOopClosure each_active_code_blob(mark_and_push_closure(), /*do_marking=*/ true);
     Threads::oops_do(mark_and_push_closure(), &each_active_code_blob);
@@ -623,7 +621,6 @@
 
   // General strong roots.
   Universe::oops_do(adjust_root_pointer_closure());
-  ReferenceProcessor::oops_do(adjust_root_pointer_closure());
   JNIHandles::oops_do(adjust_root_pointer_closure());   // Global (strong) JNI handles
   Threads::oops_do(adjust_root_pointer_closure(), NULL);
   ObjectSynchronizer::oops_do(adjust_root_pointer_closure());
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -2069,10 +2069,9 @@
     CodeCache::gc_prologue();
     Threads::gc_prologue();
 
-    NOT_PRODUCT(ref_processor()->verify_no_references_recorded());
     COMPILER2_PRESENT(DerivedPointerTable::clear());
 
-    ref_processor()->enable_discovery();
+    ref_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
     ref_processor()->setup_policy(maximum_heap_compaction);
 
     bool marked_for_unloading = false;
@@ -2445,7 +2444,6 @@
 
   // General strong roots.
   Universe::oops_do(adjust_root_pointer_closure());
-  ReferenceProcessor::oops_do(adjust_root_pointer_closure());
   JNIHandles::oops_do(adjust_root_pointer_closure());   // Global (strong) JNI handles
   Threads::oops_do(adjust_root_pointer_closure(), NULL);
   ObjectSynchronizer::oops_do(adjust_root_pointer_closure());
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -102,17 +102,15 @@
   _state = flushed;
 }
 
-bool PSPromotionLAB::unallocate_object(oop obj) {
+bool PSPromotionLAB::unallocate_object(HeapWord* obj, size_t obj_size) {
   assert(Universe::heap()->is_in(obj), "Object outside heap");
 
   if (contains(obj)) {
-    HeapWord* object_end = (HeapWord*)obj + obj->size();
-    assert(object_end <= top(), "Object crosses promotion LAB boundary");
+    HeapWord* object_end = obj + obj_size;
+    assert(object_end == top(), "Not matching last allocation");
 
-    if (object_end == top()) {
-      set_top((HeapWord*)obj);
-      return true;
-    }
+    set_top(obj);
+    return true;
   }
 
   return false;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -73,7 +73,7 @@
 
   bool is_flushed()                  { return _state == flushed; }
 
-  bool unallocate_object(oop obj);
+  bool unallocate_object(HeapWord* obj, size_t obj_size);
 
   // Returns a subregion containing all objects in this space.
   MemRegion used_region()            { return MemRegion(bottom(), top()); }
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -380,10 +380,10 @@
       // deallocate it, so we have to test.  If the deallocation fails,
       // overwrite with a filler object.
       if (new_obj_is_tenured) {
-        if (!_old_lab.unallocate_object(new_obj)) {
+        if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
           CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
         }
-      } else if (!_young_lab.unallocate_object(new_obj)) {
+      } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
         CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
       }
 
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -350,10 +350,9 @@
     }
     save_to_space_top_before_gc();
 
-    NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
     COMPILER2_PRESENT(DerivedPointerTable::clear());
 
-    reference_processor()->enable_discovery();
+    reference_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
     reference_processor()->setup_policy(false);
 
     // We track how much was promoted to the next generation for
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -55,7 +55,6 @@
   switch (_root_type) {
     case universe:
       Universe::oops_do(&roots_closure);
-      ReferenceProcessor::oops_do(&roots_closure);
       break;
 
     case jni_handles:
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // PSVirtualSpace
 
--- a/hotspot/src/share/vm/gc_implementation/shared/generationCounters.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/generationCounters.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -26,14 +26,10 @@
 #include "gc_implementation/shared/generationCounters.hpp"
 #include "memory/resourceArea.hpp"
 
-
-GenerationCounters::GenerationCounters(const char* name,
-                                       int ordinal, int spaces,
-                                       VirtualSpace* v):
-                    _virtual_space(v) {
-
+void GenerationCounters::initialize(const char* name, int ordinal, int spaces,
+                                    size_t min_capacity, size_t max_capacity,
+                                    size_t curr_capacity) {
   if (UsePerfData) {
-
     EXCEPTION_MARK;
     ResourceMark rm;
 
@@ -51,18 +47,37 @@
 
     cname = PerfDataManager::counter_name(_name_space, "minCapacity");
     PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
-                                     _virtual_space == NULL ? 0 :
-                                     _virtual_space->committed_size(), CHECK);
+                                     min_capacity, CHECK);
 
     cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
     PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
-                                     _virtual_space == NULL ? 0 :
-                                     _virtual_space->reserved_size(), CHECK);
+                                     max_capacity, CHECK);
 
     cname = PerfDataManager::counter_name(_name_space, "capacity");
-    _current_size = PerfDataManager::create_variable(SUN_GC, cname,
-                                     PerfData::U_Bytes,
-                                     _virtual_space == NULL ? 0 :
-                                     _virtual_space->committed_size(), CHECK);
+    _current_size =
+      PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
+                                       curr_capacity, CHECK);
   }
 }
+
+GenerationCounters::GenerationCounters(const char* name,
+                                       int ordinal, int spaces,
+                                       VirtualSpace* v)
+  : _virtual_space(v) {
+  assert(v != NULL, "don't call this constructor if v == NULL");
+  initialize(name, ordinal, spaces,
+             v->committed_size(), v->reserved_size(), v->committed_size());
+}
+
+GenerationCounters::GenerationCounters(const char* name,
+                                       int ordinal, int spaces,
+                                       size_t min_capacity, size_t max_capacity,
+                                       size_t curr_capacity)
+  : _virtual_space(NULL) {
+  initialize(name, ordinal, spaces, min_capacity, max_capacity, curr_capacity);
+}
+
+void GenerationCounters::update_all() {
+  assert(_virtual_space != NULL, "otherwise, override this method");
+  _current_size->set_value(_virtual_space->committed_size());
+}
--- a/hotspot/src/share/vm/gc_implementation/shared/generationCounters.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/generationCounters.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -34,6 +34,11 @@
 class GenerationCounters: public CHeapObj {
   friend class VMStructs;
 
+private:
+  void initialize(const char* name, int ordinal, int spaces,
+                  size_t min_capacity, size_t max_capacity,
+                  size_t curr_capacity);
+
  protected:
   PerfVariable*      _current_size;
   VirtualSpace*      _virtual_space;
@@ -48,11 +53,18 @@
   char*              _name_space;
 
   // This constructor is only meant for use with the PSGenerationCounters
-  // constructor.  The need for such an constructor should be eliminated
+  // constructor. The need for such an constructor should be eliminated
   // when VirtualSpace and PSVirtualSpace are unified.
-  GenerationCounters() : _name_space(NULL), _current_size(NULL), _virtual_space(NULL) {}
+  GenerationCounters()
+             : _name_space(NULL), _current_size(NULL), _virtual_space(NULL) {}
+
+  // This constructor is used for subclasses that do not have a space
+  // associated with them (e.g, in G1).
+  GenerationCounters(const char* name, int ordinal, int spaces,
+                     size_t min_capacity, size_t max_capacity,
+                     size_t curr_capacity);
+
  public:
-
   GenerationCounters(const char* name, int ordinal, int spaces,
                      VirtualSpace* v);
 
@@ -60,10 +72,7 @@
     if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
   }
 
-  virtual void update_all() {
-    _current_size->set_value(_virtual_space == NULL ? 0 :
-                             _virtual_space->committed_size());
-  }
+  virtual void update_all();
 
   const char* name_space() const        { return _name_space; }
 
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 MutableNUMASpace::MutableNUMASpace(size_t alignment) : MutableSpace(alignment) {
--- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -40,20 +40,32 @@
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #endif
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL1(hotspot, gc__begin, bool);
 HS_DTRACE_PROBE_DECL(hotspot, gc__end);
+#endif /* !USDT2 */
 
 // The same dtrace probe can't be inserted in two different files, so we
 // have to call it here, so it's only in one file.  Can't create new probes
 // for the other file anymore.   The dtrace probes have to remain stable.
 void VM_GC_Operation::notify_gc_begin(bool full) {
+#ifndef USDT2
   HS_DTRACE_PROBE1(hotspot, gc__begin, full);
   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
+#else /* USDT2 */
+  HOTSPOT_GC_BEGIN(
+                   full);
+#endif /* USDT2 */
 }
 
 void VM_GC_Operation::notify_gc_end() {
+#ifndef USDT2
   HS_DTRACE_PROBE(hotspot, gc__end);
   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
+#else /* USDT2 */
+  HOTSPOT_GC_END(
+);
+#endif /* USDT2 */
 }
 
 void VM_GC_Operation::acquire_pending_list_lock() {
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -28,6 +28,7 @@
 #include "gc_interface/collectedHeap.hpp"
 #include "gc_interface/collectedHeap.inline.hpp"
 #include "oops/oop.inline.hpp"
+#include "oops/instanceMirrorKlass.hpp"
 #include "runtime/init.hpp"
 #include "services/heapDumper.hpp"
 #ifdef TARGET_OS_FAMILY_linux
@@ -39,6 +40,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 #ifdef ASSERT
@@ -157,8 +161,14 @@
     // ..and clear it.
     Copy::zero_to_words(obj, new_tlab_size);
   } else {
-    // ...and clear just the allocated object.
-    Copy::zero_to_words(obj, size);
+    // ...and zap just allocated object.
+#ifdef ASSERT
+    // Skip mangling the space corresponding to the object header to
+    // ensure that the returned space is not considered parsable by
+    // any concurrent GC thread.
+    size_t hdr_size = oopDesc::header_size();
+    Copy::fill_to_words(obj + hdr_size, new_tlab_size - hdr_size, badHeapWordVal);
+#endif // ASSERT
   }
   thread->tlab().fill(obj, obj + size, new_tlab_size);
   return obj;
@@ -427,3 +437,37 @@
     inspector.doit();
   }
 }
+
+oop CollectedHeap::Class_obj_allocate(KlassHandle klass, int size, KlassHandle real_klass, TRAPS) {
+  debug_only(check_for_valid_allocation_state());
+  assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
+  assert(size >= 0, "int won't convert to size_t");
+  HeapWord* obj;
+  if (JavaObjectsInPerm) {
+    obj = common_permanent_mem_allocate_init(size, CHECK_NULL);
+  } else {
+    assert(ScavengeRootsInCode > 0, "must be");
+    obj = common_mem_allocate_init(size, CHECK_NULL);
+  }
+  post_allocation_setup_common(klass, obj, size);
+  assert(Universe::is_bootstrapping() ||
+         !((oop)obj)->blueprint()->oop_is_array(), "must not be an array");
+  NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
+  oop mirror = (oop)obj;
+
+  java_lang_Class::set_oop_size(mirror, size);
+
+  // Setup indirections
+  if (!real_klass.is_null()) {
+    java_lang_Class::set_klass(mirror, real_klass());
+    real_klass->set_java_mirror(mirror);
+  }
+
+  instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass());
+  assert(size == mk->instance_size(real_klass), "should have been set");
+
+  // notify jvmti and dtrace
+  post_allocation_notify(klass, (oop)obj);
+
+  return mirror;
+}
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -319,9 +319,13 @@
   // VM (then terminate).
   virtual void preload_and_dump(TRAPS) { ShouldNotReachHere(); }
 
+  // Allocate and initialize instances of Class
+  static oop Class_obj_allocate(KlassHandle klass, int size, KlassHandle real_klass, TRAPS);
+
   // General obj/array allocation facilities.
   inline static oop obj_allocate(KlassHandle klass, int size, TRAPS);
   inline static oop array_allocate(KlassHandle klass, int size, int length, TRAPS);
+  inline static oop array_allocate_nozero(KlassHandle klass, int size, int length, TRAPS);
 
   // Special obj/array allocation facilities.
   // Some heaps may want to manage "permanent" data uniquely. These default
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -43,6 +43,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Inline allocation implementations.
 
@@ -271,6 +274,23 @@
   return (oop)obj;
 }
 
+oop CollectedHeap::array_allocate_nozero(KlassHandle klass,
+                                         int size,
+                                         int length,
+                                         TRAPS) {
+  debug_only(check_for_valid_allocation_state());
+  assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
+  assert(size >= 0, "int won't convert to size_t");
+  HeapWord* obj = common_mem_allocate_noinit(size, CHECK_NULL);
+  ((oop)obj)->set_klass_gap(0);
+  post_allocation_setup_array(klass, obj, size, length);
+#ifndef PRODUCT
+  const size_t hs = oopDesc::header_size()+1;
+  Universe::heap()->check_for_non_bad_heap_word_value(obj+hs, size-hs);
+#endif
+  return (oop)obj;
+}
+
 oop CollectedHeap::permanent_obj_allocate(KlassHandle klass, int size, TRAPS) {
   oop obj = permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL);
   post_allocation_install_obj_klass(klass, obj, size);
@@ -287,7 +307,10 @@
   assert(size >= 0, "int won't convert to size_t");
   HeapWord* obj = common_permanent_mem_allocate_init(size, CHECK_NULL);
   post_allocation_setup_no_klass_install(klass, obj, size);
-  NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
+#ifndef PRODUCT
+  const size_t hs = oopDesc::header_size();
+  Universe::heap()->check_for_bad_heap_word_value(obj+hs, size-hs);
+#endif
   return (oop)obj;
 }
 
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -56,6 +56,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // This file contains the platform-independent parts
 // of the abstract interpreter and the abstract interpreter generator.
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -65,6 +65,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "orderAccess_linux_ppc.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "orderAccess_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "orderAccess_bsd_zero.inline.hpp"
+#endif
 
 
 // no precompiled headers
--- a/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -92,7 +92,7 @@
       // the incoming method.  We could lose a line of trace output.
       // This is acceptable in a debug-only feature.
       st->cr();
-      st->print("[%d] ", (int) Thread::current()->osthread()->thread_id());
+      st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
       method->print_name(st);
       st->cr();
       _current_method = method();
@@ -106,7 +106,7 @@
     }
     _code = code;
      int bci = bcp - method->code_base();
-    st->print("[%d] ", (int) Thread::current()->osthread()->thread_id());
+    st->print("[%ld] ", (long) Thread::current()->osthread()->thread_id());
     if (Verbose) {
       st->print("%8d  %4d  " INTPTR_FORMAT " " INTPTR_FORMAT " %s",
            BytecodeCounter::counter_value(), bci, tos, tos2, Bytecodes::name(code));
--- a/hotspot/src/share/vm/interpreter/bytecodes.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodes.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -419,6 +419,8 @@
 
   static bool        is_zero_const  (Code code)    { return (code == _aconst_null || code == _iconst_0
                                                            || code == _fconst_0 || code == _dconst_0); }
+  static bool        is_invoke      (Code code)    { return (_invokevirtual <= code && code <= _invokedynamic); }
+
   static int         compute_flags  (const char* format, int more_flags = 0);  // compute the flags
   static int         flags          (int code, bool is_wide) {
     assert(code == (u_char)code, "must be a byte");
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -555,7 +555,7 @@
     assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "must be");
 
     {
-      // Walk all nmethods depending on CallSite
+      // Walk all nmethods depending on this call site.
       MutexLocker mu(Compile_lock, thread);
       Universe::flush_dependents_on(call_site, method_handle);
     }
@@ -984,11 +984,8 @@
   // check the access_flags for the field in the klass
 
   instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1()));
-  typeArrayOop fields = ik->fields();
   int index = cp_entry->field_index();
-  assert(index < fields->length(), "holders field index is out of range");
-  // bail out if field accesses are not watched
-  if ((fields->ushort_at(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return;
+  if ((ik->field_access_flags(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return;
 
   switch(cp_entry->flag_state()) {
     case btos:    // fall through
@@ -1021,11 +1018,9 @@
 
   // check the access_flags for the field in the klass
   instanceKlass* ik = instanceKlass::cast(k);
-  typeArrayOop fields = ik->fields();
   int index = cp_entry->field_index();
-  assert(index < fields->length(), "holders field index is out of range");
   // bail out if field modifications are not watched
-  if ((fields->ushort_at(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return;
+  if ((ik->field_access_flags(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return;
 
   char sig_type = '\0';
 
@@ -1244,7 +1239,7 @@
   // preparing the same method will be sure to see non-null entry & mirror.
 IRT_END
 
-#if defined(IA32) || defined(AMD64)
+#if defined(IA32) || defined(AMD64) || defined(ARM)
 IRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address))
   if (src_address == dest_address) {
     return;
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -41,6 +41,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // The InterpreterRuntime is called by the interpreter for everything
 // that cannot/should not be dealt with in assembly and needs C support.
@@ -141,8 +144,8 @@
                                         methodOopDesc* method,
                                         intptr_t* from, intptr_t* to);
 
-#if defined(IA32) || defined(AMD64)
-  // Popframe support (only needed on x86 and AMD64)
+#if defined(IA32) || defined(AMD64) || defined(ARM)
+  // Popframe support (only needed on x86, AMD64 and ARM)
   static void popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address);
 #endif
 
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -52,6 +52,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //------------------------------------------------------------------------------------------------------------------------
 // Implementation of FieldAccessInfo
--- a/hotspot/src/share/vm/memory/allocation.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/allocation.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -39,6 +39,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 void* CHeapObj::operator new(size_t size){
   return (void *) AllocateHeap(size, "CHeapObj-new");
--- a/hotspot/src/share/vm/memory/allocation.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/allocation.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -151,6 +151,8 @@
 //------------------------------Chunk------------------------------------------
 // Linked list of raw memory chunks
 class Chunk: public CHeapObj {
+  friend class VMStructs;
+
  protected:
   Chunk*       _next;     // Next Chunk in list
   const size_t _len;      // Size of this Chunk
@@ -200,6 +202,8 @@
   friend class ResourceMark;
   friend class HandleMark;
   friend class NoHandleMark;
+  friend class VMStructs;
+
   Chunk *_first;                // First chunk
   Chunk *_chunk;                // current chunk
   char *_hwm, *_max;            // High water mark and max in current chunk
--- a/hotspot/src/share/vm/memory/collectorPolicy.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -47,6 +47,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
 #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp"
--- a/hotspot/src/share/vm/memory/defNewGeneration.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -48,6 +48,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //
 // DefNewGeneration functions.
--- a/hotspot/src/share/vm/memory/gcLocker.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/gcLocker.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -41,6 +41,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 // The direct lock/unlock calls do not force a collection if an unlock
 // decrements the count to zero. Avoid calling these if at all possible.
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -599,8 +599,7 @@
           // atomic wrt other collectors in this configuration, we
           // are guaranteed to have empty discovered ref lists.
           if (rp->discovery_is_atomic()) {
-            rp->verify_no_references_recorded();
-            rp->enable_discovery();
+            rp->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
             rp->setup_policy(do_clear_all_soft_refs);
           } else {
             // collect() below will enable discovery as appropriate
@@ -1269,10 +1268,6 @@
     gclog_or_tty->print("remset ");
   }
   rem_set()->verify();
-  if (!silent) {
-     gclog_or_tty->print("ref_proc ");
-  }
-  ReferenceProcessor::verify();
 }
 
 void GenCollectedHeap::print() const { print_on(tty); }
--- a/hotspot/src/share/vm/memory/genMarkSweep.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -55,6 +55,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 void GenMarkSweep::invoke_at_safepoint(int level, ReferenceProcessor* rp,
   bool clear_all_softrefs) {
--- a/hotspot/src/share/vm/memory/oopFactory.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/oopFactory.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -77,7 +77,14 @@
 typeArrayOop oopFactory::new_typeArray(BasicType type, int length, TRAPS) {
   klassOop type_asKlassOop = Universe::typeArrayKlassObj(type);
   typeArrayKlass* type_asArrayKlass = typeArrayKlass::cast(type_asKlassOop);
-  typeArrayOop result = type_asArrayKlass->allocate(length, THREAD);
+  typeArrayOop result = type_asArrayKlass->allocate_common(length, true, THREAD);
+  return result;
+}
+
+typeArrayOop oopFactory::new_typeArray_nozero(BasicType type, int length, TRAPS) {
+  klassOop type_asKlassOop = Universe::typeArrayKlassObj(type);
+  typeArrayKlass* type_asArrayKlass = typeArrayKlass::cast(type_asKlassOop);
+  typeArrayOop result = type_asArrayKlass->allocate_common(length, false, THREAD);
   return result;
 }
 
--- a/hotspot/src/share/vm/memory/oopFactory.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/oopFactory.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -63,6 +63,7 @@
   static typeArrayOop    new_permanent_intArray  (int length, TRAPS);  // used for class file structures
 
   static typeArrayOop    new_typeArray(BasicType type, int length, TRAPS);
+  static typeArrayOop    new_typeArray_nozero(BasicType type, int length, TRAPS);
 
   // Constant pools
   static constantPoolOop      new_constantPool     (int length,
--- a/hotspot/src/share/vm/memory/referencePolicy.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/referencePolicy.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,8 +41,9 @@
 
 // The oop passed in is the SoftReference object, and not
 // the object the SoftReference points to.
-bool LRUCurrentHeapPolicy::should_clear_reference(oop p) {
-  jlong interval = java_lang_ref_SoftReference::clock() - java_lang_ref_SoftReference::timestamp(p);
+bool LRUCurrentHeapPolicy::should_clear_reference(oop p,
+                                                  jlong timestamp_clock) {
+  jlong interval = timestamp_clock - java_lang_ref_SoftReference::timestamp(p);
   assert(interval >= 0, "Sanity check");
 
   // The interval will be zero if the ref was accessed since the last scavenge/gc.
@@ -71,8 +72,9 @@
 
 // The oop passed in is the SoftReference object, and not
 // the object the SoftReference points to.
-bool LRUMaxHeapPolicy::should_clear_reference(oop p) {
-  jlong interval = java_lang_ref_SoftReference::clock() - java_lang_ref_SoftReference::timestamp(p);
+bool LRUMaxHeapPolicy::should_clear_reference(oop p,
+                                             jlong timestamp_clock) {
+  jlong interval = timestamp_clock - java_lang_ref_SoftReference::timestamp(p);
   assert(interval >= 0, "Sanity check");
 
   // The interval will be zero if the ref was accessed since the last scavenge/gc.
--- a/hotspot/src/share/vm/memory/referencePolicy.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/referencePolicy.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,19 +31,27 @@
 
 class ReferencePolicy : public CHeapObj {
  public:
-  virtual bool should_clear_reference(oop p)       { ShouldNotReachHere(); return true; }
+  virtual bool should_clear_reference(oop p, jlong timestamp_clock) {
+    ShouldNotReachHere();
+    return true;
+  }
+
   // Capture state (of-the-VM) information needed to evaluate the policy
   virtual void setup() { /* do nothing */ }
 };
 
 class NeverClearPolicy : public ReferencePolicy {
  public:
-  bool should_clear_reference(oop p) { return false; }
+  virtual bool should_clear_reference(oop p, jlong timestamp_clock) {
+    return false;
+  }
 };
 
 class AlwaysClearPolicy : public ReferencePolicy {
  public:
-  bool should_clear_reference(oop p) { return true; }
+  virtual bool should_clear_reference(oop p, jlong timestamp_clock) {
+    return true;
+  }
 };
 
 class LRUCurrentHeapPolicy : public ReferencePolicy {
@@ -55,7 +63,7 @@
 
   // Capture state (of-the-VM) information needed to evaluate the policy
   void setup();
-  bool should_clear_reference(oop p);
+  virtual bool should_clear_reference(oop p, jlong timestamp_clock);
 };
 
 class LRUMaxHeapPolicy : public ReferencePolicy {
@@ -67,7 +75,7 @@
 
   // Capture state (of-the-VM) information needed to evaluate the policy
   void setup();
-  bool should_clear_reference(oop p);
+  virtual bool should_clear_reference(oop p, jlong timestamp_clock);
 };
 
 #endif // SHARE_VM_MEMORY_REFERENCEPOLICY_HPP
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,62 +35,21 @@
 
 ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
 ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy      = NULL;
-oop              ReferenceProcessor::_sentinelRef = NULL;
-const int        subclasses_of_ref                = REF_PHANTOM - REF_OTHER;
-
-// List of discovered references.
-class DiscoveredList {
-public:
-  DiscoveredList() : _len(0), _compressed_head(0), _oop_head(NULL) { }
-  oop head() const     {
-     return UseCompressedOops ?  oopDesc::decode_heap_oop_not_null(_compressed_head) :
-                                _oop_head;
-  }
-  HeapWord* adr_head() {
-    return UseCompressedOops ? (HeapWord*)&_compressed_head :
-                               (HeapWord*)&_oop_head;
-  }
-  void   set_head(oop o) {
-    if (UseCompressedOops) {
-      // Must compress the head ptr.
-      _compressed_head = oopDesc::encode_heap_oop_not_null(o);
-    } else {
-      _oop_head = o;
-    }
-  }
-  bool   empty() const          { return head() == ReferenceProcessor::sentinel_ref(); }
-  size_t length()               { return _len; }
-  void   set_length(size_t len) { _len = len;  }
-  void   inc_length(size_t inc) { _len += inc; assert(_len > 0, "Error"); }
-  void   dec_length(size_t dec) { _len -= dec; }
-private:
-  // Set value depending on UseCompressedOops. This could be a template class
-  // but then we have to fix all the instantiations and declarations that use this class.
-  oop       _oop_head;
-  narrowOop _compressed_head;
-  size_t _len;
-};
+bool             ReferenceProcessor::_pending_list_uses_discovered_field = false;
+jlong            ReferenceProcessor::_soft_ref_timestamp_clock = 0;
 
 void referenceProcessor_init() {
   ReferenceProcessor::init_statics();
 }
 
 void ReferenceProcessor::init_statics() {
-  assert(_sentinelRef == NULL, "should be initialized precisely once");
-  EXCEPTION_MARK;
-  _sentinelRef = instanceKlass::cast(
-                    SystemDictionary::Reference_klass())->
-                      allocate_permanent_instance(THREAD);
+  jlong now = os::javaTimeMillis();
 
-  // Initialize the master soft ref clock.
-  java_lang_ref_SoftReference::set_clock(os::javaTimeMillis());
+  // Initialize the soft ref timestamp clock.
+  _soft_ref_timestamp_clock = now;
+  // Also update the soft ref clock in j.l.r.SoftReference
+  java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock);
 
-  if (HAS_PENDING_EXCEPTION) {
-      Handle ex(THREAD, PENDING_EXCEPTION);
-      vm_exit_during_initialization(ex);
-  }
-  assert(_sentinelRef != NULL && _sentinelRef->is_oop(),
-         "Just constructed it!");
   _always_clear_soft_ref_policy = new AlwaysClearPolicy();
   _default_soft_ref_policy      = new COMPILER2_PRESENT(LRUMaxHeapPolicy())
                                       NOT_COMPILER2(LRUCurrentHeapPolicy());
@@ -100,6 +59,29 @@
   guarantee(RefDiscoveryPolicy == ReferenceBasedDiscovery ||
             RefDiscoveryPolicy == ReferentBasedDiscovery,
             "Unrecongnized RefDiscoveryPolicy");
+  _pending_list_uses_discovered_field = JDK_Version::current().pending_list_uses_discovered_field();
+}
+
+void ReferenceProcessor::enable_discovery(bool verify_disabled, bool check_no_refs) {
+#ifdef ASSERT
+  // Verify that we're not currently discovering refs
+  assert(!verify_disabled || !_discovering_refs, "nested call?");
+
+  if (check_no_refs) {
+    // Verify that the discovered lists are empty
+    verify_no_references_recorded();
+  }
+#endif // ASSERT
+
+  // Someone could have modified the value of the static
+  // field in the j.l.r.SoftReference class that holds the
+  // soft reference timestamp clock using reflection or
+  // Unsafe between GCs. Unconditionally update the static
+  // field in ReferenceProcessor here so that we use the new
+  // value during reference discovery.
+
+  _soft_ref_timestamp_clock = java_lang_ref_SoftReference::clock();
+  _discovering_refs = true;
 }
 
 ReferenceProcessor::ReferenceProcessor(MemRegion span,
@@ -123,20 +105,23 @@
   _discovery_is_mt     = mt_discovery;
   _num_q               = MAX2(1, mt_processing_degree);
   _max_num_q           = MAX2(_num_q, mt_discovery_degree);
-  _discoveredSoftRefs  = NEW_C_HEAP_ARRAY(DiscoveredList, _max_num_q * subclasses_of_ref);
-  if (_discoveredSoftRefs == NULL) {
+  _discovered_refs     = NEW_C_HEAP_ARRAY(DiscoveredList,
+                                          _max_num_q * number_of_subclasses_of_ref());
+  if (_discovered_refs == NULL) {
     vm_exit_during_initialization("Could not allocated RefProc Array");
   }
+  _discoveredSoftRefs    = &_discovered_refs[0];
   _discoveredWeakRefs    = &_discoveredSoftRefs[_max_num_q];
   _discoveredFinalRefs   = &_discoveredWeakRefs[_max_num_q];
   _discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q];
-  assert(sentinel_ref() != NULL, "_sentinelRef is NULL");
-  // Initialized all entries to _sentinelRef
-  for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
-        _discoveredSoftRefs[i].set_head(sentinel_ref());
-    _discoveredSoftRefs[i].set_length(0);
+
+  // Initialize all entries to NULL
+  for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+    _discovered_refs[i].set_head(NULL);
+    _discovered_refs[i].set_length(0);
   }
-  // If we do barreirs, cache a copy of the barrier set.
+
+  // If we do barriers, cache a copy of the barrier set.
   if (discovered_list_needs_barrier) {
     _bs = Universe::heap()->barrier_set();
   }
@@ -146,46 +131,42 @@
 #ifndef PRODUCT
 void ReferenceProcessor::verify_no_references_recorded() {
   guarantee(!_discovering_refs, "Discovering refs?");
-  for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
-    guarantee(_discoveredSoftRefs[i].empty(),
+  for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+    guarantee(_discovered_refs[i].is_empty(),
               "Found non-empty discovered list");
   }
 }
 #endif
 
 void ReferenceProcessor::weak_oops_do(OopClosure* f) {
-  // Should this instead be
-  // for (int i = 0; i < subclasses_of_ref; i++_ {
-  //   for (int j = 0; j < _num_q; j++) {
-  //     int index = i * _max_num_q + j;
-  for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
+  for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
     if (UseCompressedOops) {
-      f->do_oop((narrowOop*)_discoveredSoftRefs[i].adr_head());
+      f->do_oop((narrowOop*)_discovered_refs[i].adr_head());
     } else {
-      f->do_oop((oop*)_discoveredSoftRefs[i].adr_head());
+      f->do_oop((oop*)_discovered_refs[i].adr_head());
     }
   }
 }
 
-void ReferenceProcessor::oops_do(OopClosure* f) {
-  f->do_oop(adr_sentinel_ref());
-}
-
 void ReferenceProcessor::update_soft_ref_master_clock() {
   // Update (advance) the soft ref master clock field. This must be done
   // after processing the soft ref list.
   jlong now = os::javaTimeMillis();
-  jlong clock = java_lang_ref_SoftReference::clock();
+  jlong soft_ref_clock = java_lang_ref_SoftReference::clock();
+  assert(soft_ref_clock == _soft_ref_timestamp_clock, "soft ref clocks out of sync");
+
   NOT_PRODUCT(
-  if (now < clock) {
-    warning("time warp: %d to %d", clock, now);
+  if (now < _soft_ref_timestamp_clock) {
+    warning("time warp: "INT64_FORMAT" to "INT64_FORMAT,
+            _soft_ref_timestamp_clock, now);
   }
   )
   // In product mode, protect ourselves from system time being adjusted
   // externally and going backward; see note in the implementation of
   // GenCollectedHeap::time_since_last_gc() for the right way to fix
   // this uniformly throughout the VM; see bug-id 4741166. XXX
-  if (now > clock) {
+  if (now > _soft_ref_timestamp_clock) {
+    _soft_ref_timestamp_clock = now;
     java_lang_ref_SoftReference::set_clock(now);
   }
   // Else leave clock stalled at its old value until time progresses
@@ -203,6 +184,16 @@
   // Stop treating discovered references specially.
   disable_discovery();
 
+  // If discovery was concurrent, someone could have modified
+  // the value of the static field in the j.l.r.SoftReference
+  // class that holds the soft reference timestamp clock using
+  // reflection or Unsafe between when discovery was enabled and
+  // now. Unconditionally update the static field in ReferenceProcessor
+  // here so that we use the new value during processing of the
+  // discovered soft refs.
+
+  _soft_ref_timestamp_clock = java_lang_ref_SoftReference::clock();
+
   bool trace_time = PrintGCDetails && PrintReferenceGC;
   // Soft references
   {
@@ -283,8 +274,6 @@
   }
 #endif
   JNIHandles::weak_oops_do(is_alive, keep_alive);
-  // Finally remember to keep sentinel around
-  keep_alive->do_oop(adr_sentinel_ref());
   complete_gc->do_void();
 }
 
@@ -327,46 +316,77 @@
 void ReferenceProcessor::enqueue_discovered_reflist(DiscoveredList& refs_list,
                                                     HeapWord* pending_list_addr) {
   // Given a list of refs linked through the "discovered" field
-  // (java.lang.ref.Reference.discovered) chain them through the
-  // "next" field (java.lang.ref.Reference.next) and prepend
-  // to the pending list.
+  // (java.lang.ref.Reference.discovered), self-loop their "next" field
+  // thus distinguishing them from active References, then
+  // prepend them to the pending list.
+  // BKWRD COMPATIBILITY NOTE: For older JDKs (prior to the fix for 4956777),
+  // the "next" field is used to chain the pending list, not the discovered
+  // field.
+
   if (TraceReferenceGC && PrintGCDetails) {
     gclog_or_tty->print_cr("ReferenceProcessor::enqueue_discovered_reflist list "
                            INTPTR_FORMAT, (address)refs_list.head());
   }
-  oop obj = refs_list.head();
-  // Walk down the list, copying the discovered field into
-  // the next field and clearing it (except for the last
-  // non-sentinel object which is treated specially to avoid
-  // confusion with an active reference).
-  while (obj != sentinel_ref()) {
-    assert(obj->is_instanceRef(), "should be reference object");
-    oop next = java_lang_ref_Reference::discovered(obj);
-    if (TraceReferenceGC && PrintGCDetails) {
-      gclog_or_tty->print_cr("        obj " INTPTR_FORMAT "/next " INTPTR_FORMAT,
-                             obj, next);
+
+  oop obj = NULL;
+  oop next_d = refs_list.head();
+  if (pending_list_uses_discovered_field()) { // New behaviour
+    // Walk down the list, self-looping the next field
+    // so that the References are not considered active.
+    while (obj != next_d) {
+      obj = next_d;
+      assert(obj->is_instanceRef(), "should be reference object");
+      next_d = java_lang_ref_Reference::discovered(obj);
+      if (TraceReferenceGC && PrintGCDetails) {
+        gclog_or_tty->print_cr("        obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT,
+                               obj, next_d);
+      }
+      assert(java_lang_ref_Reference::next(obj) == NULL,
+             "Reference not active; should not be discovered");
+      // Self-loop next, so as to make Ref not active.
+      java_lang_ref_Reference::set_next(obj, obj);
+      if (next_d == obj) {  // obj is last
+        // Swap refs_list into pendling_list_addr and
+        // set obj's discovered to what we read from pending_list_addr.
+        oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr);
+        // Need oop_check on pending_list_addr above;
+        // see special oop-check code at the end of
+        // enqueue_discovered_reflists() further below.
+        java_lang_ref_Reference::set_discovered(obj, old); // old may be NULL
+      }
     }
-    assert(java_lang_ref_Reference::next(obj) == NULL,
-           "The reference should not be enqueued");
-    if (next == sentinel_ref()) {  // obj is last
-      // Swap refs_list into pendling_list_addr and
-      // set obj's next to what we read from pending_list_addr.
-      oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr);
-      // Need oop_check on pending_list_addr above;
-      // see special oop-check code at the end of
-      // enqueue_discovered_reflists() further below.
-      if (old == NULL) {
-        // obj should be made to point to itself, since
-        // pending list was empty.
-        java_lang_ref_Reference::set_next(obj, obj);
+  } else { // Old behaviour
+    // Walk down the list, copying the discovered field into
+    // the next field and clearing the discovered field.
+    while (obj != next_d) {
+      obj = next_d;
+      assert(obj->is_instanceRef(), "should be reference object");
+      next_d = java_lang_ref_Reference::discovered(obj);
+      if (TraceReferenceGC && PrintGCDetails) {
+        gclog_or_tty->print_cr("        obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT,
+                               obj, next_d);
+      }
+      assert(java_lang_ref_Reference::next(obj) == NULL,
+             "The reference should not be enqueued");
+      if (next_d == obj) {  // obj is last
+        // Swap refs_list into pendling_list_addr and
+        // set obj's next to what we read from pending_list_addr.
+        oop old = oopDesc::atomic_exchange_oop(refs_list.head(), pending_list_addr);
+        // Need oop_check on pending_list_addr above;
+        // see special oop-check code at the end of
+        // enqueue_discovered_reflists() further below.
+        if (old == NULL) {
+          // obj should be made to point to itself, since
+          // pending list was empty.
+          java_lang_ref_Reference::set_next(obj, obj);
+        } else {
+          java_lang_ref_Reference::set_next(obj, old);
+        }
       } else {
-        java_lang_ref_Reference::set_next(obj, old);
+        java_lang_ref_Reference::set_next(obj, next_d);
       }
-    } else {
-      java_lang_ref_Reference::set_next(obj, next);
+      java_lang_ref_Reference::set_discovered(obj, (oop) NULL);
     }
-    java_lang_ref_Reference::set_discovered(obj, (oop) NULL);
-    obj = next;
   }
 }
 
@@ -376,10 +396,9 @@
   RefProcEnqueueTask(ReferenceProcessor& ref_processor,
                      DiscoveredList      discovered_refs[],
                      HeapWord*           pending_list_addr,
-                     oop                 sentinel_ref,
                      int                 n_queues)
     : EnqueueTask(ref_processor, discovered_refs,
-                  pending_list_addr, sentinel_ref, n_queues)
+                  pending_list_addr, n_queues)
   { }
 
   virtual void work(unsigned int work_id) {
@@ -392,11 +411,11 @@
     // allocated and are indexed into.
     assert(_n_queues == (int) _ref_processor.max_num_q(), "Different number not expected");
     for (int j = 0;
-         j < subclasses_of_ref;
+         j < ReferenceProcessor::number_of_subclasses_of_ref();
          j++, index += _n_queues) {
       _ref_processor.enqueue_discovered_reflist(
         _refs_lists[index], _pending_list_addr);
-      _refs_lists[index].set_head(_sentinel_ref);
+      _refs_lists[index].set_head(NULL);
       _refs_lists[index].set_length(0);
     }
   }
@@ -407,126 +426,20 @@
   AbstractRefProcTaskExecutor* task_executor) {
   if (_processing_is_mt && task_executor != NULL) {
     // Parallel code
-    RefProcEnqueueTask tsk(*this, _discoveredSoftRefs,
-                           pending_list_addr, sentinel_ref(), _max_num_q);
+    RefProcEnqueueTask tsk(*this, _discovered_refs,
+                           pending_list_addr, _max_num_q);
     task_executor->execute(tsk);
   } else {
     // Serial code: call the parent class's implementation
-    for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
-      enqueue_discovered_reflist(_discoveredSoftRefs[i], pending_list_addr);
-      _discoveredSoftRefs[i].set_head(sentinel_ref());
-      _discoveredSoftRefs[i].set_length(0);
+    for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+      enqueue_discovered_reflist(_discovered_refs[i], pending_list_addr);
+      _discovered_refs[i].set_head(NULL);
+      _discovered_refs[i].set_length(0);
     }
   }
 }
 
-// Iterator for the list of discovered references.
-class DiscoveredListIterator {
-public:
-  inline DiscoveredListIterator(DiscoveredList&    refs_list,
-                                OopClosure*        keep_alive,
-                                BoolObjectClosure* is_alive);
-
-  // End Of List.
-  inline bool has_next() const { return _next != ReferenceProcessor::sentinel_ref(); }
-
-  // Get oop to the Reference object.
-  inline oop obj() const { return _ref; }
-
-  // Get oop to the referent object.
-  inline oop referent() const { return _referent; }
-
-  // Returns true if referent is alive.
-  inline bool is_referent_alive() const;
-
-  // Loads data for the current reference.
-  // The "allow_null_referent" argument tells us to allow for the possibility
-  // of a NULL referent in the discovered Reference object. This typically
-  // happens in the case of concurrent collectors that may have done the
-  // discovery concurrently, or interleaved, with mutator execution.
-  inline void load_ptrs(DEBUG_ONLY(bool allow_null_referent));
-
-  // Move to the next discovered reference.
-  inline void next();
-
-  // Remove the current reference from the list
-  inline void remove();
-
-  // Make the Reference object active again.
-  inline void make_active() { java_lang_ref_Reference::set_next(_ref, NULL); }
-
-  // Make the referent alive.
-  inline void make_referent_alive() {
-    if (UseCompressedOops) {
-      _keep_alive->do_oop((narrowOop*)_referent_addr);
-    } else {
-      _keep_alive->do_oop((oop*)_referent_addr);
-    }
-  }
-
-  // Update the discovered field.
-  inline void update_discovered() {
-    // First _prev_next ref actually points into DiscoveredList (gross).
-    if (UseCompressedOops) {
-      _keep_alive->do_oop((narrowOop*)_prev_next);
-    } else {
-      _keep_alive->do_oop((oop*)_prev_next);
-    }
-  }
-
-  // NULL out referent pointer.
-  inline void clear_referent() { oop_store_raw(_referent_addr, NULL); }
-
-  // Statistics
-  NOT_PRODUCT(
-  inline size_t processed() const { return _processed; }
-  inline size_t removed() const   { return _removed; }
-  )
-
-  inline void move_to_next();
-
-private:
-  DiscoveredList&    _refs_list;
-  HeapWord*          _prev_next;
-  oop                _ref;
-  HeapWord*          _discovered_addr;
-  oop                _next;
-  HeapWord*          _referent_addr;
-  oop                _referent;
-  OopClosure*        _keep_alive;
-  BoolObjectClosure* _is_alive;
-  DEBUG_ONLY(
-  oop                _first_seen; // cyclic linked list check
-  )
-  NOT_PRODUCT(
-  size_t             _processed;
-  size_t             _removed;
-  )
-};
-
-inline DiscoveredListIterator::DiscoveredListIterator(DiscoveredList&    refs_list,
-                                                      OopClosure*        keep_alive,
-                                                      BoolObjectClosure* is_alive)
-  : _refs_list(refs_list),
-    _prev_next(refs_list.adr_head()),
-    _ref(refs_list.head()),
-#ifdef ASSERT
-    _first_seen(refs_list.head()),
-#endif
-#ifndef PRODUCT
-    _processed(0),
-    _removed(0),
-#endif
-    _next(refs_list.head()),
-    _keep_alive(keep_alive),
-    _is_alive(is_alive)
-{ }
-
-inline bool DiscoveredListIterator::is_referent_alive() const {
-  return _is_alive->do_object_b(_referent);
-}
-
-inline void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
+void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
   _discovered_addr = java_lang_ref_Reference::discovered_addr(_ref);
   oop discovered = java_lang_ref_Reference::discovered(_ref);
   assert(_discovered_addr && discovered->is_oop_or_null(),
@@ -542,30 +455,55 @@
          "bad referent");
 }
 
-inline void DiscoveredListIterator::next() {
-  _prev_next = _discovered_addr;
-  move_to_next();
-}
-
-inline void DiscoveredListIterator::remove() {
+void DiscoveredListIterator::remove() {
   assert(_ref->is_oop(), "Dropping a bad reference");
   oop_store_raw(_discovered_addr, NULL);
+
   // First _prev_next ref actually points into DiscoveredList (gross).
+  oop new_next;
+  if (_next == _ref) {
+    // At the end of the list, we should make _prev point to itself.
+    // If _ref is the first ref, then _prev_next will be in the DiscoveredList,
+    // and _prev will be NULL.
+    new_next = _prev;
+  } else {
+    new_next = _next;
+  }
+
   if (UseCompressedOops) {
     // Remove Reference object from list.
-    oopDesc::encode_store_heap_oop_not_null((narrowOop*)_prev_next, _next);
+    oopDesc::encode_store_heap_oop((narrowOop*)_prev_next, new_next);
   } else {
     // Remove Reference object from list.
-    oopDesc::store_heap_oop((oop*)_prev_next, _next);
+    oopDesc::store_heap_oop((oop*)_prev_next, new_next);
   }
   NOT_PRODUCT(_removed++);
   _refs_list.dec_length(1);
 }
 
-inline void DiscoveredListIterator::move_to_next() {
-  _ref = _next;
-  assert(_ref != _first_seen, "cyclic ref_list found");
-  NOT_PRODUCT(_processed++);
+// Make the Reference object active again.
+void DiscoveredListIterator::make_active() {
+  // For G1 we don't want to use set_next - it
+  // will dirty the card for the next field of
+  // the reference object and will fail
+  // CT verification.
+  if (UseG1GC) {
+    BarrierSet* bs = oopDesc::bs();
+    HeapWord* next_addr = java_lang_ref_Reference::next_addr(_ref);
+
+    if (UseCompressedOops) {
+      bs->write_ref_field_pre((narrowOop*)next_addr, NULL);
+    } else {
+      bs->write_ref_field_pre((oop*)next_addr, NULL);
+    }
+    java_lang_ref_Reference::set_next_raw(_ref, NULL);
+  } else {
+    java_lang_ref_Reference::set_next(_ref, NULL);
+  }
+}
+
+void DiscoveredListIterator::clear_referent() {
+  oop_store_raw(_referent_addr, NULL);
 }
 
 // NOTE: process_phase*() are largely similar, and at a high level
@@ -592,7 +530,8 @@
   while (iter.has_next()) {
     iter.load_ptrs(DEBUG_ONLY(!discovery_is_atomic() /* allow_null_referent */));
     bool referent_is_dead = (iter.referent() != NULL) && !iter.is_referent_alive();
-    if (referent_is_dead && !policy->should_clear_reference(iter.obj())) {
+    if (referent_is_dead &&
+        !policy->should_clear_reference(iter.obj(), _soft_ref_timestamp_clock)) {
       if (TraceReferenceGC) {
         gclog_or_tty->print_cr("Dropping reference (" INTPTR_FORMAT ": %s"  ") by policy",
                                iter.obj(), iter.obj()->blueprint()->internal_name());
@@ -613,7 +552,7 @@
   NOT_PRODUCT(
     if (PrintGCDetails && TraceReferenceGC) {
       gclog_or_tty->print_cr(" Dropped %d dead Refs out of %d "
-        "discovered Refs by policy  list " INTPTR_FORMAT,
+        "discovered Refs by policy, from list " INTPTR_FORMAT,
         iter.removed(), iter.processed(), (address)refs_list.head());
     }
   )
@@ -725,32 +664,37 @@
     assert(iter.obj()->is_oop(UseConcMarkSweepGC), "Adding a bad reference");
     iter.next();
   }
-  // Remember to keep sentinel pointer around
+  // Remember to update the next pointer of the last ref.
   iter.update_discovered();
   // Close the reachable set
   complete_gc->do_void();
 }
 
 void
-ReferenceProcessor::abandon_partial_discovered_list(DiscoveredList& refs_list) {
-  oop obj = refs_list.head();
-  while (obj != sentinel_ref()) {
-    oop discovered = java_lang_ref_Reference::discovered(obj);
+ReferenceProcessor::clear_discovered_references(DiscoveredList& refs_list) {
+  oop obj = NULL;
+  oop next = refs_list.head();
+  while (next != obj) {
+    obj = next;
+    next = java_lang_ref_Reference::discovered(obj);
     java_lang_ref_Reference::set_discovered_raw(obj, NULL);
-    obj = discovered;
   }
-  refs_list.set_head(sentinel_ref());
+  refs_list.set_head(NULL);
   refs_list.set_length(0);
 }
 
+void
+ReferenceProcessor::abandon_partial_discovered_list(DiscoveredList& refs_list) {
+  clear_discovered_references(refs_list);
+}
+
 void ReferenceProcessor::abandon_partial_discovery() {
   // loop over the lists
-  for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
+  for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
     if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) {
-      gclog_or_tty->print_cr("\nAbandoning %s discovered list",
-                             list_name(i));
+      gclog_or_tty->print_cr("\nAbandoning %s discovered list", list_name(i));
     }
-    abandon_partial_discovered_list(_discoveredSoftRefs[i]);
+    abandon_partial_discovered_list(_discovered_refs[i]);
   }
 }
 
@@ -817,6 +761,14 @@
   bool _clear_referent;
 };
 
+void ReferenceProcessor::set_discovered(oop ref, oop value) {
+  if (_discovered_list_needs_barrier) {
+    java_lang_ref_Reference::set_discovered(ref, value);
+  } else {
+    java_lang_ref_Reference::set_discovered_raw(ref, value);
+  }
+}
+
 // Balances reference queues.
 // Move entries from all queues[0, 1, ..., _max_num_q-1] to
 // queues[0, 1, ..., _num_q-1] because only the first _num_q
@@ -859,6 +811,9 @@
           refs_to_move = MIN2(ref_lists[from_idx].length() - avg_refs,
                               avg_refs - ref_lists[to_idx].length());
         }
+
+        assert(refs_to_move > 0, "otherwise the code below will fail");
+
         oop move_head = ref_lists[from_idx].head();
         oop move_tail = move_head;
         oop new_head  = move_head;
@@ -867,10 +822,24 @@
           move_tail = new_head;
           new_head = java_lang_ref_Reference::discovered(new_head);
         }
-        java_lang_ref_Reference::set_discovered(move_tail, ref_lists[to_idx].head());
+
+        // Add the chain to the to list.
+        if (ref_lists[to_idx].head() == NULL) {
+          // to list is empty. Make a loop at the end.
+          set_discovered(move_tail, move_tail);
+        } else {
+          set_discovered(move_tail, ref_lists[to_idx].head());
+        }
         ref_lists[to_idx].set_head(move_head);
         ref_lists[to_idx].inc_length(refs_to_move);
-        ref_lists[from_idx].set_head(new_head);
+
+        // Remove the chain from the from list.
+        if (move_tail == new_head) {
+          // We found the end of the from list.
+          ref_lists[from_idx].set_head(NULL);
+        } else {
+          ref_lists[from_idx].set_head(new_head);
+        }
         ref_lists[from_idx].dec_length(refs_to_move);
         if (ref_lists[from_idx].length() == 0) {
           break;
@@ -980,17 +949,13 @@
 
 void ReferenceProcessor::clean_up_discovered_references() {
   // loop over the lists
-  // Should this instead be
-  // for (int i = 0; i < subclasses_of_ref; i++_ {
-  //   for (int j = 0; j < _num_q; j++) {
-  //     int index = i * _max_num_q + j;
-  for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
+  for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
     if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) {
       gclog_or_tty->print_cr(
         "\nScrubbing %s discovered list of Null referents",
         list_name(i));
     }
-    clean_up_discovered_reflist(_discoveredSoftRefs[i]);
+    clean_up_discovered_reflist(_discovered_refs[i]);
   }
 }
 
@@ -1082,42 +1047,40 @@
   // First we must make sure this object is only enqueued once. CAS in a non null
   // discovered_addr.
   oop current_head = refs_list.head();
+  // The last ref must have its discovered field pointing to itself.
+  oop next_discovered = (current_head != NULL) ? current_head : obj;
 
   // Note: In the case of G1, this specific pre-barrier is strictly
   // not necessary because the only case we are interested in
   // here is when *discovered_addr is NULL (see the CAS further below),
   // so this will expand to nothing. As a result, we have manually
   // elided this out for G1, but left in the test for some future
-  // collector that might have need for a pre-barrier here.
-  if (_discovered_list_needs_barrier && !UseG1GC) {
-    if (UseCompressedOops) {
-      _bs->write_ref_field_pre((narrowOop*)discovered_addr, current_head);
-    } else {
-      _bs->write_ref_field_pre((oop*)discovered_addr, current_head);
-    }
-    guarantee(false, "Need to check non-G1 collector");
-  }
-  oop retest = oopDesc::atomic_compare_exchange_oop(current_head, discovered_addr,
+  // collector that might have need for a pre-barrier here, e.g.:-
+  // _bs->write_ref_field_pre((oop* or narrowOop*)discovered_addr, next_discovered);
+  assert(!_discovered_list_needs_barrier || UseG1GC,
+         "Need to check non-G1 collector: "
+         "may need a pre-write-barrier for CAS from NULL below");
+  oop retest = oopDesc::atomic_compare_exchange_oop(next_discovered, discovered_addr,
                                                     NULL);
   if (retest == NULL) {
     // This thread just won the right to enqueue the object.
-    // We have separate lists for enqueueing so no synchronization
+    // We have separate lists for enqueueing, so no synchronization
     // is necessary.
     refs_list.set_head(obj);
     refs_list.inc_length(1);
     if (_discovered_list_needs_barrier) {
-      _bs->write_ref_field((void*)discovered_addr, current_head);
+      _bs->write_ref_field((void*)discovered_addr, next_discovered);
     }
 
     if (TraceReferenceGC) {
-      gclog_or_tty->print_cr("Enqueued reference (mt) (" INTPTR_FORMAT ": %s)",
+      gclog_or_tty->print_cr("Discovered reference (mt) (" INTPTR_FORMAT ": %s)",
                              obj, obj->blueprint()->internal_name());
     }
   } else {
     // If retest was non NULL, another thread beat us to it:
     // The reference has already been discovered...
     if (TraceReferenceGC) {
-      gclog_or_tty->print_cr("Already enqueued reference (" INTPTR_FORMAT ": %s)",
+      gclog_or_tty->print_cr("Already discovered reference (" INTPTR_FORMAT ": %s)",
                              obj, obj->blueprint()->internal_name());
     }
   }
@@ -1142,7 +1105,7 @@
 //     (or part of the heap being collected, indicated by our "span"
 //     we don't treat it specially (i.e. we scan it as we would
 //     a normal oop, treating its references as strong references).
-//     This means that references can't be enqueued unless their
+//     This means that references can't be discovered unless their
 //     referent is also in the same span. This is the simplest,
 //     most "local" and most conservative approach, albeit one
 //     that may cause weak references to be enqueued least promptly.
@@ -1164,14 +1127,13 @@
 //     and complexity in processing these references.
 //     We call this choice the "RefeferentBasedDiscovery" policy.
 bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
-  // We enqueue references only if we are discovering refs
-  // (rather than processing discovered refs).
+  // Make sure we are discovering refs (rather than processing discovered refs).
   if (!_discovering_refs || !RegisterReferences) {
     return false;
   }
-  // We only enqueue active references.
+  // We only discover active references.
   oop next = java_lang_ref_Reference::next(obj);
-  if (next != NULL) {
+  if (next != NULL) {   // Ref is no longer active
     return false;
   }
 
@@ -1184,8 +1146,8 @@
     return false;
   }
 
-  // We only enqueue references whose referents are not (yet) strongly
-  // reachable.
+  // We only discover references whose referents are not (yet)
+  // known to be strongly reachable.
   if (is_alive_non_header() != NULL) {
     verify_referent(obj);
     if (is_alive_non_header()->do_object_b(java_lang_ref_Reference::referent(obj))) {
@@ -1200,18 +1162,20 @@
     // time-stamp policies advance the soft-ref clock only
     // at a major collection cycle, this is always currently
     // accurate.
-    if (!_current_soft_ref_policy->should_clear_reference(obj)) {
+    if (!_current_soft_ref_policy->should_clear_reference(obj, _soft_ref_timestamp_clock)) {
       return false;
     }
   }
 
+  ResourceMark rm;      // Needed for tracing.
+
   HeapWord* const discovered_addr = java_lang_ref_Reference::discovered_addr(obj);
   const oop  discovered = java_lang_ref_Reference::discovered(obj);
   assert(discovered->is_oop_or_null(), "bad discovered field");
   if (discovered != NULL) {
     // The reference has already been discovered...
     if (TraceReferenceGC) {
-      gclog_or_tty->print_cr("Already enqueued reference (" INTPTR_FORMAT ": %s)",
+      gclog_or_tty->print_cr("Already discovered reference (" INTPTR_FORMAT ": %s)",
                              obj, obj->blueprint()->internal_name());
     }
     if (RefDiscoveryPolicy == ReferentBasedDiscovery) {
@@ -1233,9 +1197,9 @@
 
   if (RefDiscoveryPolicy == ReferentBasedDiscovery) {
     verify_referent(obj);
-    // enqueue if and only if either:
-    // reference is in our span or
-    // we are an atomic collector and referent is in our span
+    // Discover if and only if EITHER:
+    // .. reference is in our span, OR
+    // .. we are an atomic collector and referent is in our span
     if (_span.contains(obj_addr) ||
         (discovery_is_atomic() &&
          _span.contains(java_lang_ref_Reference::referent(obj)))) {
@@ -1262,30 +1226,28 @@
     // here: the field will be visited later when processing the discovered
     // references.
     oop current_head = list->head();
+    // The last ref must have its discovered field pointing to itself.
+    oop next_discovered = (current_head != NULL) ? current_head : obj;
+
     // As in the case further above, since we are over-writing a NULL
     // pre-value, we can safely elide the pre-barrier here for the case of G1.
+    // e.g.:- _bs->write_ref_field_pre((oop* or narrowOop*)discovered_addr, next_discovered);
     assert(discovered == NULL, "control point invariant");
-    if (_discovered_list_needs_barrier && !UseG1GC) { // safe to elide for G1
-      if (UseCompressedOops) {
-        _bs->write_ref_field_pre((narrowOop*)discovered_addr, current_head);
-      } else {
-        _bs->write_ref_field_pre((oop*)discovered_addr, current_head);
-      }
-      guarantee(false, "Need to check non-G1 collector");
-    }
-    oop_store_raw(discovered_addr, current_head);
+    assert(!_discovered_list_needs_barrier || UseG1GC,
+           "For non-G1 collector, may need a pre-write-barrier for CAS from NULL below");
+    oop_store_raw(discovered_addr, next_discovered);
     if (_discovered_list_needs_barrier) {
-      _bs->write_ref_field((void*)discovered_addr, current_head);
+      _bs->write_ref_field((void*)discovered_addr, next_discovered);
     }
     list->set_head(obj);
     list->inc_length(1);
 
     if (TraceReferenceGC) {
-      gclog_or_tty->print_cr("Enqueued reference (" INTPTR_FORMAT ": %s)",
+      gclog_or_tty->print_cr("Discovered reference (" INTPTR_FORMAT ": %s)",
                                 obj, obj->blueprint()->internal_name());
     }
   }
-  assert(obj->is_oop(), "Enqueued a bad reference");
+  assert(obj->is_oop(), "Discovered a bad reference");
   verify_referent(obj);
   return true;
 }
@@ -1419,7 +1381,9 @@
 }
 
 const char* ReferenceProcessor::list_name(int i) {
-   assert(i >= 0 && i <= _max_num_q * subclasses_of_ref, "Out of bounds index");
+   assert(i >= 0 && i <= _max_num_q * number_of_subclasses_of_ref(),
+          "Out of bounds index");
+
    int j = i / _max_num_q;
    switch (j) {
      case 0: return "SoftRef";
@@ -1437,22 +1401,12 @@
 }
 #endif
 
-void ReferenceProcessor::verify() {
-  guarantee(sentinel_ref() != NULL && sentinel_ref()->is_oop(), "Lost _sentinelRef");
-}
-
 #ifndef PRODUCT
 void ReferenceProcessor::clear_discovered_references() {
   guarantee(!_discovering_refs, "Discovering refs?");
-  for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
-    oop obj = _discoveredSoftRefs[i].head();
-    while (obj != sentinel_ref()) {
-      oop next = java_lang_ref_Reference::discovered(obj);
-      java_lang_ref_Reference::set_discovered(obj, (oop) NULL);
-      obj = next;
-    }
-    _discoveredSoftRefs[i].set_head(sentinel_ref());
-    _discoveredSoftRefs[i].set_length(0);
+  for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
+    clear_discovered_references(_discovered_refs[i]);
   }
 }
+
 #endif // PRODUCT
--- a/hotspot/src/share/vm/memory/referenceProcessor.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -48,18 +48,177 @@
 // forward references
 class ReferencePolicy;
 class AbstractRefProcTaskExecutor;
-class DiscoveredList;
+
+// List of discovered references.
+class DiscoveredList {
+public:
+  DiscoveredList() : _len(0), _compressed_head(0), _oop_head(NULL) { }
+  oop head() const     {
+     return UseCompressedOops ?  oopDesc::decode_heap_oop(_compressed_head) :
+                                _oop_head;
+  }
+  HeapWord* adr_head() {
+    return UseCompressedOops ? (HeapWord*)&_compressed_head :
+                               (HeapWord*)&_oop_head;
+  }
+  void set_head(oop o) {
+    if (UseCompressedOops) {
+      // Must compress the head ptr.
+      _compressed_head = oopDesc::encode_heap_oop(o);
+    } else {
+      _oop_head = o;
+    }
+  }
+  bool   is_empty() const       { return head() == NULL; }
+  size_t length()               { return _len; }
+  void   set_length(size_t len) { _len = len;  }
+  void   inc_length(size_t inc) { _len += inc; assert(_len > 0, "Error"); }
+  void   dec_length(size_t dec) { _len -= dec; }
+private:
+  // Set value depending on UseCompressedOops. This could be a template class
+  // but then we have to fix all the instantiations and declarations that use this class.
+  oop       _oop_head;
+  narrowOop _compressed_head;
+  size_t _len;
+};
+
+// Iterator for the list of discovered references.
+class DiscoveredListIterator {
+private:
+  DiscoveredList&    _refs_list;
+  HeapWord*          _prev_next;
+  oop                _prev;
+  oop                _ref;
+  HeapWord*          _discovered_addr;
+  oop                _next;
+  HeapWord*          _referent_addr;
+  oop                _referent;
+  OopClosure*        _keep_alive;
+  BoolObjectClosure* _is_alive;
+
+  DEBUG_ONLY(
+  oop                _first_seen; // cyclic linked list check
+  )
+
+  NOT_PRODUCT(
+  size_t             _processed;
+  size_t             _removed;
+  )
+
+public:
+  inline DiscoveredListIterator(DiscoveredList&    refs_list,
+                                OopClosure*        keep_alive,
+                                BoolObjectClosure* is_alive):
+    _refs_list(refs_list),
+    _prev_next(refs_list.adr_head()),
+    _prev(NULL),
+    _ref(refs_list.head()),
+#ifdef ASSERT
+    _first_seen(refs_list.head()),
+#endif
+#ifndef PRODUCT
+    _processed(0),
+    _removed(0),
+#endif
+    _next(NULL),
+    _keep_alive(keep_alive),
+    _is_alive(is_alive)
+{ }
+
+  // End Of List.
+  inline bool has_next() const { return _ref != NULL; }
+
+  // Get oop to the Reference object.
+  inline oop obj() const { return _ref; }
+
+  // Get oop to the referent object.
+  inline oop referent() const { return _referent; }
+
+  // Returns true if referent is alive.
+  inline bool is_referent_alive() const {
+    return _is_alive->do_object_b(_referent);
+  }
+
+  // Loads data for the current reference.
+  // The "allow_null_referent" argument tells us to allow for the possibility
+  // of a NULL referent in the discovered Reference object. This typically
+  // happens in the case of concurrent collectors that may have done the
+  // discovery concurrently, or interleaved, with mutator execution.
+  void load_ptrs(DEBUG_ONLY(bool allow_null_referent));
+
+  // Move to the next discovered reference.
+  inline void next() {
+    _prev_next = _discovered_addr;
+    _prev = _ref;
+    move_to_next();
+  }
+
+  // Remove the current reference from the list
+  void remove();
+
+  // Make the Reference object active again.
+  void make_active();
+
+  // Make the referent alive.
+  inline void make_referent_alive() {
+    if (UseCompressedOops) {
+      _keep_alive->do_oop((narrowOop*)_referent_addr);
+    } else {
+      _keep_alive->do_oop((oop*)_referent_addr);
+    }
+  }
+
+  // Update the discovered field.
+  inline void update_discovered() {
+    // First _prev_next ref actually points into DiscoveredList (gross).
+    if (UseCompressedOops) {
+      if (!oopDesc::is_null(*(narrowOop*)_prev_next)) {
+        _keep_alive->do_oop((narrowOop*)_prev_next);
+      }
+    } else {
+      if (!oopDesc::is_null(*(oop*)_prev_next)) {
+        _keep_alive->do_oop((oop*)_prev_next);
+      }
+    }
+  }
+
+  // NULL out referent pointer.
+  void clear_referent();
+
+  // Statistics
+  NOT_PRODUCT(
+  inline size_t processed() const { return _processed; }
+  inline size_t removed() const   { return _removed; }
+  )
+
+  inline void move_to_next() {
+    if (_ref == _next) {
+      // End of the list.
+      _ref = NULL;
+    } else {
+      _ref = _next;
+    }
+    assert(_ref != _first_seen, "cyclic ref_list found");
+    NOT_PRODUCT(_processed++);
+  }
+};
 
 class ReferenceProcessor : public CHeapObj {
  protected:
-  // End of list marker
-  static oop  _sentinelRef;
-  MemRegion   _span; // (right-open) interval of heap
-                     // subject to wkref discovery
-  bool        _discovering_refs;      // true when discovery enabled
-  bool        _discovery_is_atomic;   // if discovery is atomic wrt
-                                      // other collectors in configuration
-  bool        _discovery_is_mt;       // true if reference discovery is MT.
+  // Compatibility with pre-4965777 JDK's
+  static bool _pending_list_uses_discovered_field;
+
+  // The SoftReference master timestamp clock
+  static jlong _soft_ref_timestamp_clock;
+
+  MemRegion   _span;                    // (right-open) interval of heap
+                                        // subject to wkref discovery
+
+  bool        _discovering_refs;        // true when discovery enabled
+  bool        _discovery_is_atomic;     // if discovery is atomic wrt
+                                        // other collectors in configuration
+  bool        _discovery_is_mt;         // true if reference discovery is MT.
+
   // If true, setting "next" field of a discovered refs list requires
   // write barrier(s).  (Must be true if used in a collector in which
   // elements of a discovered list may be moved during discovery: for
@@ -67,18 +226,19 @@
   // long-term concurrent marking phase that does weak reference
   // discovery.)
   bool        _discovered_list_needs_barrier;
-  BarrierSet* _bs;                    // Cached copy of BarrierSet.
-  bool        _enqueuing_is_done;     // true if all weak references enqueued
-  bool        _processing_is_mt;      // true during phases when
-                                      // reference processing is MT.
-  int         _next_id;               // round-robin mod _num_q counter in
-                                      // support of work distribution
 
-  // For collectors that do not keep GC marking information
+  BarrierSet* _bs;                      // Cached copy of BarrierSet.
+  bool        _enqueuing_is_done;       // true if all weak references enqueued
+  bool        _processing_is_mt;        // true during phases when
+                                        // reference processing is MT.
+  int         _next_id;                 // round-robin mod _num_q counter in
+                                        // support of work distribution
+
+  // For collectors that do not keep GC liveness information
   // in the object header, this field holds a closure that
   // helps the reference processor determine the reachability
-  // of an oop (the field is currently initialized to NULL for
-  // all collectors but the CMS collector).
+  // of an oop. It is currently initialized to NULL for all
+  // collectors except for CMS and G1.
   BoolObjectClosure* _is_alive_non_header;
 
   // Soft ref clearing policies
@@ -95,19 +255,25 @@
   int             _num_q;
   // The maximum MT'ness degree of the queues below
   int             _max_num_q;
-  // Arrays of lists of oops, one per thread
+
+  // Master array of discovered oops
+  DiscoveredList* _discovered_refs;
+
+  // Arrays of lists of oops, one per thread (pointers into master array above)
   DiscoveredList* _discoveredSoftRefs;
   DiscoveredList* _discoveredWeakRefs;
   DiscoveredList* _discoveredFinalRefs;
   DiscoveredList* _discoveredPhantomRefs;
 
  public:
-  int num_q()                            { return _num_q; }
-  int max_num_q()                        { return _max_num_q; }
-  void set_active_mt_degree(int v)       { _num_q = v; }
-  DiscoveredList* discovered_soft_refs() { return _discoveredSoftRefs; }
-  static oop  sentinel_ref()             { return _sentinelRef; }
-  static oop* adr_sentinel_ref()         { return &_sentinelRef; }
+  static int number_of_subclasses_of_ref() { return (REF_PHANTOM - REF_OTHER); }
+
+  int num_q()                              { return _num_q; }
+  int max_num_q()                          { return _max_num_q; }
+  void set_active_mt_degree(int v)         { _num_q = v; }
+
+  DiscoveredList* discovered_refs()        { return _discovered_refs; }
+
   ReferencePolicy* setup_policy(bool always_clear) {
     _current_soft_ref_policy = always_clear ?
       _always_clear_soft_ref_policy : _default_soft_ref_policy;
@@ -115,7 +281,6 @@
     return _current_soft_ref_policy;
   }
 
- public:
   // Process references with a certain reachability level.
   void process_discovered_reflist(DiscoveredList               refs_lists[],
                                   ReferencePolicy*             policy,
@@ -208,6 +373,11 @@
   void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor);
 
  protected:
+  // Set the 'discovered' field of the given reference to
+  // the given value - emitting barriers depending upon
+  // the value of _discovered_list_needs_barrier.
+  void set_discovered(oop ref, oop value);
+
   // "Preclean" the given discovered reference list
   // by removing references with strongly reachable referents.
   // Currently used in support of CMS only.
@@ -230,6 +400,7 @@
                                         HeapWord* discovered_addr);
   void verify_ok_to_handle_reflists() PRODUCT_RETURN;
 
+  void clear_discovered_references(DiscoveredList& refs_list);
   void abandon_partial_discovered_list(DiscoveredList& refs_list);
 
   // Calculate the number of jni handles.
@@ -245,6 +416,7 @@
   // constructor
   ReferenceProcessor():
     _span((HeapWord*)NULL, (HeapWord*)NULL),
+    _discovered_refs(NULL),
     _discoveredSoftRefs(NULL),  _discoveredWeakRefs(NULL),
     _discoveredFinalRefs(NULL), _discoveredPhantomRefs(NULL),
     _discovering_refs(false),
@@ -292,7 +464,7 @@
   void      set_span(MemRegion span) { _span = span; }
 
   // start and stop weak ref discovery
-  void enable_discovery()   { _discovering_refs = true;  }
+  void enable_discovery(bool verify_disabled, bool check_no_refs);
   void disable_discovery()  { _discovering_refs = false; }
   bool discovery_enabled()  { return _discovering_refs;  }
 
@@ -300,6 +472,13 @@
   bool discovery_is_atomic() const { return _discovery_is_atomic; }
   void set_atomic_discovery(bool atomic) { _discovery_is_atomic = atomic; }
 
+  // whether the JDK in which we are embedded is a pre-4965777 JDK,
+  // and thus whether or not it uses the discovered field to chain
+  // the entries in the pending list.
+  static bool pending_list_uses_discovered_field() {
+    return _pending_list_uses_discovered_field;
+  }
+
   // whether discovery is done by multiple threads same-old-timeously
   bool discovery_is_mt() const { return _discovery_is_mt; }
   void set_mt_discovery(bool mt) { _discovery_is_mt = mt; }
@@ -314,7 +493,6 @@
 
   // iterate over oops
   void weak_oops_do(OopClosure* f);       // weak roots
-  static void oops_do(OopClosure* f);     // strong root(s)
 
   // Balance each of the discovered lists.
   void balance_all_queues();
@@ -340,7 +518,6 @@
   // debugging
   void verify_no_references_recorded() PRODUCT_RETURN;
   void verify_referent(oop obj)        PRODUCT_RETURN;
-  static void verify();
 
   // clear the discovered lists (unlinking each entry).
   void clear_discovered_references() PRODUCT_RETURN;
@@ -362,7 +539,7 @@
 
   ~NoRefDiscovery() {
     if (_was_discovering_refs) {
-      _rp->enable_discovery();
+      _rp->enable_discovery(true /*verify_disabled*/, false /*check_no_refs*/);
     }
   }
 };
@@ -524,12 +701,10 @@
   EnqueueTask(ReferenceProcessor& ref_processor,
               DiscoveredList      refs_lists[],
               HeapWord*           pending_list_addr,
-              oop                 sentinel_ref,
               int                 n_queues)
     : _ref_processor(ref_processor),
       _refs_lists(refs_lists),
       _pending_list_addr(pending_list_addr),
-      _sentinel_ref(sentinel_ref),
       _n_queues(n_queues)
   { }
 
@@ -540,7 +715,6 @@
   ReferenceProcessor& _ref_processor;
   DiscoveredList*     _refs_lists;
   HeapWord*           _pending_list_addr;
-  oop                 _sentinel_ref;
   int                 _n_queues;
 };
 
--- a/hotspot/src/share/vm/memory/resourceArea.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/resourceArea.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //------------------------------ResourceMark-----------------------------------
 debug_only(int ResourceArea::_warned;)      // to suppress multiple warnings
--- a/hotspot/src/share/vm/memory/resourceArea.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/resourceArea.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // The resource area holds temporary data structures in the VM.
 // The actual allocation areas are thread local. Typical usage:
@@ -52,6 +55,7 @@
 class ResourceArea: public Arena {
   friend class ResourceMark;
   friend class DeoptResourceMark;
+  friend class VMStructs;
   debug_only(int _nesting;)             // current # of nested ResourceMarks
   debug_only(static int _warned;)       // to suppress multiple warnings
 
--- a/hotspot/src/share/vm/memory/sharedHeap.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/sharedHeap.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -146,7 +146,6 @@
   assert(_strong_roots_parity != 0, "must have called prologue code");
   if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) {
     Universe::oops_do(roots);
-    ReferenceProcessor::oops_do(roots);
     // Consider perm-gen discovered lists to be strong.
     perm_gen()->ref_processor()->weak_oops_do(roots);
   }
--- a/hotspot/src/share/vm/memory/space.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/space.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -44,6 +44,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // A space is an abstraction for the "storage units" backing
 // up the generation abstraction. It includes specific
--- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -38,6 +38,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Thread-Local Edens support
 
--- a/hotspot/src/share/vm/memory/universe.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/memory/universe.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -89,6 +89,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
 #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp"
@@ -890,7 +893,7 @@
 
   } else if (UseG1GC) {
 #ifndef SERIALGC
-    G1CollectorPolicy* g1p = new G1CollectorPolicy_BestRegionsFirst();
+    G1CollectorPolicy* g1p = new G1CollectorPolicy();
     G1CollectedHeap* g1h = new G1CollectedHeap(g1p);
     Universe::_collectedHeap = g1h;
 #else  // SERIALGC
@@ -1203,12 +1206,12 @@
   // Compute the dependent nmethods that have a reference to a
   // CallSite object.  We use instanceKlass::mark_dependent_nmethod
   // directly instead of CodeCache::mark_for_deoptimization because we
-  // want dependents on the class CallSite only not all classes in the
-  // ContextStream.
+  // want dependents on the call site class only not all classes in
+  // the ContextStream.
   int marked = 0;
   {
     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
-    instanceKlass* call_site_klass = instanceKlass::cast(SystemDictionary::CallSite_klass());
+    instanceKlass* call_site_klass = instanceKlass::cast(call_site->klass());
     marked = call_site_klass->mark_dependent_nmethods(changes);
   }
   if (marked > 0) {
--- a/hotspot/src/share/vm/oops/constMethodKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/constMethodKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -172,11 +172,6 @@
 int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
   assert(obj->is_constMethod(), "should be constMethod");
   constMethodOop cm_oop = constMethodOop(obj);
-#if 0
-  PSParallelCompact::adjust_pointer(cm_oop->adr_method());
-  PSParallelCompact::adjust_pointer(cm_oop->adr_exception_table());
-  PSParallelCompact::adjust_pointer(cm_oop->adr_stackmap_data());
-#endif
   oop* const beg_oop = cm_oop->oop_block_beg();
   oop* const end_oop = cm_oop->oop_block_end();
   for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
--- a/hotspot/src/share/vm/oops/constantPoolKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/constantPoolKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -44,6 +44,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
--- a/hotspot/src/share/vm/oops/constantPoolOop.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/constantPoolOop.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1355,7 +1355,7 @@
       }
       case JVM_CONSTANT_Long: {
         u8 val = Bytes::get_Java_u8(bytes);
-        printf("long         "INT64_FORMAT, *(jlong *) &val);
+        printf("long         "INT64_FORMAT, (int64_t) *(jlong *) &val);
         ent_size = 8;
         idx++; // Long takes two cpool slots
         break;
--- a/hotspot/src/share/vm/oops/cpCacheKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/cpCacheKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -63,8 +63,10 @@
   //   CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
 
   oop obj = CollectedHeap::permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL);
-  NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value((HeapWord*) obj,
-                                                              size));
+#ifndef PRODUCT
+  const size_t hs = oopDesc::header_size();
+  Universe::heap()->check_for_bad_heap_word_value(((HeapWord*) obj)+hs, size-hs);
+#endif
   constantPoolCacheOop cache = (constantPoolCacheOop) obj;
   assert(!UseConcMarkSweepGC || obj->klass_or_null() == NULL,
          "klass should be NULL here when using CMS");
--- a/hotspot/src/share/vm/oops/cpCacheOop.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/cpCacheOop.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -128,17 +128,13 @@
 void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
                                        Bytecodes::Code put_code,
                                        KlassHandle field_holder,
-                                       int orig_field_index,
+                                       int field_index,
                                        int field_offset,
                                        TosState field_type,
                                        bool is_final,
                                        bool is_volatile) {
   set_f1(field_holder()->java_mirror());
   set_f2(field_offset);
-  // The field index is used by jvm/ti and is the index into fields() array
-  // in holder instanceKlass.  This is scaled by instanceKlass::next_offset.
-  assert((orig_field_index % instanceKlass::next_offset) == 0, "wierd index");
-  const int field_index = orig_field_index / instanceKlass::next_offset;
   assert(field_index <= field_index_mask,
          "field index does not fit in low flag bits");
   set_flags(as_flags(field_type, is_final, false, is_volatile, false, false) |
@@ -149,7 +145,7 @@
 }
 
 int  ConstantPoolCacheEntry::field_index() const {
-  return (_flags & field_index_mask) * instanceKlass::next_offset;
+  return (_flags & field_index_mask);
 }
 
 void ConstantPoolCacheEntry::set_method(Bytecodes::Code invoke_code,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/oops/fieldInfo.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_OOPS_FIELDINFO_HPP
+#define SHARE_VM_OOPS_FIELDINFO_HPP
+
+#include "oops/typeArrayOop.hpp"
+#include "classfile/vmSymbols.hpp"
+
+// This class represents the field information contained in the fields
+// array of an instanceKlass.  Currently it's laid on top an array of
+// Java shorts but in the future it could simply be used as a real
+// array type.  FieldInfo generally shouldn't be used directly.
+// Fields should be queried either through instanceKlass or through
+// the various FieldStreams.
+class FieldInfo VALUE_OBJ_CLASS_SPEC {
+  friend class fieldDescriptor;
+  friend class JavaFieldStream;
+  friend class ClassFileParser;
+
+ public:
+  // fields
+  // Field info extracted from the class file and stored
+  // as an array of 7 shorts
+  enum FieldOffset {
+    access_flags_offset      = 0,
+    name_index_offset        = 1,
+    signature_index_offset   = 2,
+    initval_index_offset     = 3,
+    low_offset               = 4,
+    high_offset              = 5,
+    generic_signature_offset = 6,
+    field_slots              = 7
+  };
+
+ private:
+  u2 _shorts[field_slots];
+
+  void set_name_index(u2 val)                    { _shorts[name_index_offset] = val;         }
+  void set_signature_index(u2 val)               { _shorts[signature_index_offset] = val;    }
+  void set_initval_index(u2 val)                 { _shorts[initval_index_offset] = val;      }
+  void set_generic_signature_index(u2 val)       { _shorts[generic_signature_offset] = val;  }
+
+  u2 name_index() const                          { return _shorts[name_index_offset];        }
+  u2 signature_index() const                     { return _shorts[signature_index_offset];   }
+  u2 initval_index() const                       { return _shorts[initval_index_offset];     }
+  u2 generic_signature_index() const             { return _shorts[generic_signature_offset]; }
+
+ public:
+  static FieldInfo* from_field_array(typeArrayOop fields, int index) {
+    return ((FieldInfo*)fields->short_at_addr(index * field_slots));
+  }
+
+  void initialize(u2 access_flags,
+                  u2 name_index,
+                  u2 signature_index,
+                  u2 initval_index,
+                  u2 generic_signature_index,
+                  u4 offset) {
+    _shorts[access_flags_offset] = access_flags;
+    _shorts[name_index_offset] = name_index;
+    _shorts[signature_index_offset] = signature_index;
+    _shorts[initval_index_offset] = initval_index;
+    _shorts[generic_signature_offset] = generic_signature_index;
+    set_offset(offset);
+  }
+
+  u2 access_flags() const                        { return _shorts[access_flags_offset];            }
+  u4 offset() const                              { return build_int_from_shorts(_shorts[low_offset], _shorts[high_offset]); }
+
+  Symbol* name(constantPoolHandle cp) const {
+    int index = name_index();
+    if (is_internal()) {
+      return lookup_symbol(index);
+    }
+    return cp->symbol_at(index);
+  }
+
+  Symbol* signature(constantPoolHandle cp) const {
+    int index = signature_index();
+    if (is_internal()) {
+      return lookup_symbol(index);
+    }
+    return cp->symbol_at(index);
+  }
+
+  Symbol* generic_signature(constantPoolHandle cp) const {
+    int index = generic_signature_index();
+    if (index == 0) {
+      return NULL;
+    }
+    return cp->symbol_at(index);
+  }
+
+  void set_access_flags(u2 val)                  { _shorts[access_flags_offset] = val;             }
+  void set_offset(u4 val)                        {
+    _shorts[low_offset] = extract_low_short_from_int(val);
+    _shorts[high_offset] = extract_high_short_from_int(val);
+  }
+
+  bool is_internal() const {
+    return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0;
+  }
+
+  Symbol* lookup_symbol(int symbol_index) const {
+    assert(is_internal(), "only internal fields");
+    return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
+  }
+};
+
+#endif // SHARE_VM_OOPS_FIELDINFO_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/oops/fieldStreams.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_OOPS_FIELDSTREAMS_HPP
+#define SHARE_VM_OOPS_FIELDSTREAMS_HPP
+
+#include "oops/instanceKlass.hpp"
+#include "oops/fieldInfo.hpp"
+
+// The is the base class for iteration over the fields array
+// describing the declared fields in the class.  Several subclasses
+// are provided depending on the kind of iteration required.  The
+// JavaFieldStream is for iterating over regular Java fields and it
+// generally the preferred iterator.  InternalFieldStream only
+// iterates over fields that have been injected by the JVM.
+// AllFieldStream exposes all fields and should only be used in rare
+// cases.
+class FieldStreamBase : public StackObj {
+ protected:
+  typeArrayHandle     _fields;
+  constantPoolHandle  _constants;
+  int                 _index;
+  int                 _limit;
+
+  FieldInfo* field() const { return FieldInfo::from_field_array(_fields(), _index); }
+
+  FieldStreamBase(typeArrayHandle fields, constantPoolHandle constants, int start, int limit) {
+    _fields = fields;
+    _constants = constants;
+    _index = start;
+    _limit = limit;
+  }
+
+  FieldStreamBase(typeArrayHandle fields, constantPoolHandle constants) {
+    _fields = fields;
+    _constants = constants;
+    _index = 0;
+    _limit = fields->length() / FieldInfo::field_slots;
+  }
+
+ public:
+  FieldStreamBase(instanceKlass* klass) {
+    _fields = klass->fields();
+    _constants = klass->constants();
+    _index = 0;
+    _limit = klass->java_fields_count();
+  }
+  FieldStreamBase(instanceKlassHandle klass) {
+    _fields = klass->fields();
+    _constants = klass->constants();
+    _index = 0;
+    _limit = klass->java_fields_count();
+  }
+
+  // accessors
+  int index() const                 { return _index; }
+
+  void next() { _index += 1; }
+  bool done() const { return _index >= _limit; }
+
+  // Accessors for current field
+  AccessFlags access_flags() const {
+    AccessFlags flags;
+    flags.set_flags(field()->access_flags());
+    return flags;
+  }
+
+  void set_access_flags(u2 flags) const {
+    field()->set_access_flags(flags);
+  }
+
+  void set_access_flags(AccessFlags flags) const {
+    set_access_flags(flags.as_short());
+  }
+
+  Symbol* name() const {
+    return field()->name(_constants);
+  }
+
+  Symbol* signature() const {
+    return field()->signature(_constants);
+  }
+
+  Symbol* generic_signature() const {
+    return field()->generic_signature(_constants);
+  }
+
+  int offset() const {
+    return field()->offset();
+  }
+
+  void set_offset(int offset) {
+    field()->set_offset(offset);
+  }
+};
+
+// Iterate over only the internal fields
+class JavaFieldStream : public FieldStreamBase {
+ public:
+  JavaFieldStream(instanceKlass* k):      FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {}
+  JavaFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {}
+
+  int name_index() const {
+    assert(!field()->is_internal(), "regular only");
+    return field()->name_index();
+  }
+  void set_name_index(int index) {
+    assert(!field()->is_internal(), "regular only");
+    field()->set_name_index(index);
+  }
+  int signature_index() const {
+    assert(!field()->is_internal(), "regular only");
+    return field()->signature_index();
+  }
+  void set_signature_index(int index) {
+    assert(!field()->is_internal(), "regular only");
+    field()->set_signature_index(index);
+  }
+  int generic_signature_index() const {
+    assert(!field()->is_internal(), "regular only");
+    return field()->generic_signature_index();
+  }
+  void set_generic_signature_index(int index) {
+    assert(!field()->is_internal(), "regular only");
+    field()->set_generic_signature_index(index);
+  }
+  int initval_index() const {
+    assert(!field()->is_internal(), "regular only");
+    return field()->initval_index();
+  }
+  void set_initval_index(int index) {
+    assert(!field()->is_internal(), "regular only");
+    return field()->set_initval_index(index);
+  }
+};
+
+
+// Iterate over only the internal fields
+class InternalFieldStream : public FieldStreamBase {
+ public:
+  InternalFieldStream(instanceKlass* k):      FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), k->all_fields_count()) {}
+  InternalFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), k->all_fields_count()) {}
+};
+
+
+class AllFieldStream : public FieldStreamBase {
+ public:
+  AllFieldStream(typeArrayHandle fields, constantPoolHandle constants): FieldStreamBase(fields, constants) {}
+  AllFieldStream(instanceKlass* k):      FieldStreamBase(k->fields(), k->constants()) {}
+  AllFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants()) {}
+};
+
+#endif // SHARE_VM_OOPS_FIELDSTREAMS_HPP
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,7 @@
 #include "memory/genOopClosures.inline.hpp"
 #include "memory/oopFactory.hpp"
 #include "memory/permGen.hpp"
+#include "oops/fieldStreams.hpp"
 #include "oops/instanceKlass.hpp"
 #include "oops/instanceMirrorKlass.hpp"
 #include "oops/instanceOop.hpp"
@@ -60,6 +61,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
@@ -76,6 +80,8 @@
 
 #ifdef DTRACE_ENABLED
 
+#ifndef USDT2
+
 HS_DTRACE_PROBE_DECL4(hotspot, class__initialization__required,
   char*, intptr_t, oop, intptr_t);
 HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__recursive,
@@ -118,6 +124,42 @@
     HS_DTRACE_PROBE5(hotspot, class__initialization__##type,     \
       data, len, (clss)->class_loader(), thread_type, wait);     \
   }
+#else /* USDT2 */
+
+#define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED
+#define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE
+#define HOTSPOT_CLASS_INITIALIZATION_concurrent HOTSPOT_CLASS_INITIALIZATION_CONCURRENT
+#define HOTSPOT_CLASS_INITIALIZATION_erroneous HOTSPOT_CLASS_INITIALIZATION_ERRONEOUS
+#define HOTSPOT_CLASS_INITIALIZATION_super__failed HOTSPOT_CLASS_INITIALIZATION_SUPER_FAILED
+#define HOTSPOT_CLASS_INITIALIZATION_clinit HOTSPOT_CLASS_INITIALIZATION_CLINIT
+#define HOTSPOT_CLASS_INITIALIZATION_error HOTSPOT_CLASS_INITIALIZATION_ERROR
+#define HOTSPOT_CLASS_INITIALIZATION_end HOTSPOT_CLASS_INITIALIZATION_END
+#define DTRACE_CLASSINIT_PROBE(type, clss, thread_type)          \
+  {                                                              \
+    char* data = NULL;                                           \
+    int len = 0;                                                 \
+    Symbol* name = (clss)->name();                               \
+    if (name != NULL) {                                          \
+      data = (char*)name->bytes();                               \
+      len = name->utf8_length();                                 \
+    }                                                            \
+    HOTSPOT_CLASS_INITIALIZATION_##type(                         \
+      data, len, (clss)->class_loader(), thread_type);           \
+  }
+
+#define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) \
+  {                                                              \
+    char* data = NULL;                                           \
+    int len = 0;                                                 \
+    Symbol* name = (clss)->name();                               \
+    if (name != NULL) {                                          \
+      data = (char*)name->bytes();                               \
+      len = name->utf8_length();                                 \
+    }                                                            \
+    HOTSPOT_CLASS_INITIALIZATION_##type(                         \
+      data, len, (clss)->class_loader(), thread_type, wait);     \
+  }
+#endif /* USDT2 */
 
 #else //  ndef DTRACE_ENABLED
 
@@ -782,14 +824,11 @@
 
 
 bool instanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
-  const int n = fields()->length();
-  for (int i = 0; i < n; i += next_offset ) {
-    int name_index = fields()->ushort_at(i + name_index_offset);
-    int sig_index  = fields()->ushort_at(i + signature_index_offset);
-    Symbol* f_name = constants()->symbol_at(name_index);
-    Symbol* f_sig  = constants()->symbol_at(sig_index);
+  for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) {
+    Symbol* f_name = fs.name();
+    Symbol* f_sig  = fs.signature();
     if (f_name == name && f_sig == sig) {
-      fd->initialize(as_klassOop(), i);
+      fd->initialize(as_klassOop(), fs.index());
       return true;
     }
   }
@@ -803,11 +842,10 @@
   closure->do_symbol(&_source_file_name);
   closure->do_symbol(&_source_debug_extension);
 
-  const int n = fields()->length();
-  for (int i = 0; i < n; i += next_offset ) {
-    int name_index = fields()->ushort_at(i + name_index_offset);
+  for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
+    int name_index = fs.name_index();
     closure->do_symbol(constants()->symbol_at_addr(name_index));
-    int sig_index  = fields()->ushort_at(i + signature_index_offset);
+    int sig_index  = fs.signature_index();
     closure->do_symbol(constants()->symbol_at_addr(sig_index));
   }
 }
@@ -872,10 +910,9 @@
 
 
 bool instanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const {
-  int length = fields()->length();
-  for (int i = 0; i < length; i += next_offset) {
-    if (offset_from_fields( i ) == offset) {
-      fd->initialize(as_klassOop(), i);
+  for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) {
+    if (fs.offset() == offset) {
+      fd->initialize(as_klassOop(), fs.index());
       if (fd->is_static() == is_static) return true;
     }
   }
@@ -906,11 +943,12 @@
 
 
 void instanceKlass::do_local_static_fields(FieldClosure* cl) {
-  fieldDescriptor fd;
-  int length = fields()->length();
-  for (int i = 0; i < length; i += next_offset) {
-    fd.initialize(as_klassOop(), i);
-    if (fd.is_static()) cl->do_field(&fd);
+  for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
+    if (fs.access_flags().is_static()) {
+      fieldDescriptor fd;
+      fd.initialize(as_klassOop(), fs.index());
+      cl->do_field(&fd);
+    }
   }
 }
 
@@ -922,11 +960,12 @@
 
 
 void instanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) {
-  fieldDescriptor fd;
-  int length = this_oop->fields()->length();
-  for (int i = 0; i < length; i += next_offset) {
-    fd.initialize(this_oop(), i);
-    if (fd.is_static()) { f(&fd, CHECK); } // Do NOT remove {}! (CHECK macro expands into several statements)
+  for (JavaFieldStream fs(this_oop()); !fs.done(); fs.next()) {
+    if (fs.access_flags().is_static()) {
+      fieldDescriptor fd;
+      fd.initialize(this_oop(), fs.index());
+      f(&fd, CHECK);
+    }
   }
 }
 
@@ -941,11 +980,11 @@
     super->do_nonstatic_fields(cl);
   }
   fieldDescriptor fd;
-  int length = fields()->length();
+  int length = java_fields_count();
   // In DebugInfo nonstatic fields are sorted by offset.
   int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1));
   int j = 0;
-  for (int i = 0; i < length; i += next_offset) {
+  for (int i = 0; i < length; i += 1) {
     fd.initialize(as_klassOop(), i);
     if (!fd.is_static()) {
       fields_sorted[j + 0] = fd.offset();
@@ -1374,37 +1413,6 @@
 
 
 //
-// nmethodBucket is used to record dependent nmethods for
-// deoptimization.  nmethod dependencies are actually <klass, method>
-// pairs but we really only care about the klass part for purposes of
-// finding nmethods which might need to be deoptimized.  Instead of
-// recording the method, a count of how many times a particular nmethod
-// was recorded is kept.  This ensures that any recording errors are
-// noticed since an nmethod should be removed as many times are it's
-// added.
-//
-class nmethodBucket {
- private:
-  nmethod*       _nmethod;
-  int            _count;
-  nmethodBucket* _next;
-
- public:
-  nmethodBucket(nmethod* nmethod, nmethodBucket* next) {
-    _nmethod = nmethod;
-    _next = next;
-    _count = 1;
-  }
-  int count()                             { return _count; }
-  int increment()                         { _count += 1; return _count; }
-  int decrement()                         { _count -= 1; assert(_count >= 0, "don't underflow"); return _count; }
-  nmethodBucket* next()                   { return _next; }
-  void set_next(nmethodBucket* b)         { _next = b; }
-  nmethod* get_nmethod()                  { return _nmethod; }
-};
-
-
-//
 // Walk the list of dependent nmethods searching for nmethods which
 // are dependent on the changes that were passed in and mark them for
 // deoptimization.  Returns the number of nmethods found.
@@ -2411,43 +2419,6 @@
   oop_oop_iterate(obj, &blk);
 }
 
-#ifndef PRODUCT
-
-void instanceKlass::verify_class_klass_nonstatic_oop_maps(klassOop k) {
-  // This verification code is disabled.  JDK_Version::is_gte_jdk14x_version()
-  // cannot be called since this function is called before the VM is
-  // able to determine what JDK version is running with.
-  // The check below always is false since 1.4.
-  return;
-
-  // This verification code temporarily disabled for the 1.4
-  // reflection implementation since java.lang.Class now has
-  // Java-level instance fields. Should rewrite this to handle this
-  // case.
-  if (!(JDK_Version::is_gte_jdk14x_version() && UseNewReflection)) {
-    // Verify that java.lang.Class instances have a fake oop field added.
-    instanceKlass* ik = instanceKlass::cast(k);
-
-    // Check that we have the right class
-    static bool first_time = true;
-    guarantee(k == SystemDictionary::Class_klass() && first_time, "Invalid verify of maps");
-    first_time = false;
-    const int extra = java_lang_Class::number_of_fake_oop_fields;
-    guarantee(ik->nonstatic_field_size() == extra, "just checking");
-    guarantee(ik->nonstatic_oop_map_count() == 1, "just checking");
-    guarantee(ik->size_helper() == align_object_size(instanceOopDesc::header_size() + extra), "just checking");
-
-    // Check that the map is (2,extra)
-    int offset = java_lang_Class::klass_offset;
-
-    OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
-    guarantee(map->offset() == offset && map->count() == (unsigned int) extra,
-              "sanity");
-  }
-}
-
-#endif // ndef PRODUCT
-
 // JNIid class for jfieldIDs only
 // Note to reviewers:
 // These JNI functions are just moved over to column 1 and not changed
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -27,6 +27,7 @@
 
 #include "oops/constMethodOop.hpp"
 #include "oops/constantPoolOop.hpp"
+#include "oops/fieldInfo.hpp"
 #include "oops/instanceOop.hpp"
 #include "oops/klassOop.hpp"
 #include "oops/klassVtable.hpp"
@@ -228,6 +229,7 @@
   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
   int             _static_oop_field_count;// number of static oop fields in this klass
   int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
+  int             _java_fields_count;    // The number of declared Java fields
   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization
   bool            _rewritten;            // methods rewritten.
   bool            _has_nonstatic_fields; // for sizing with UseCompressedOops
@@ -307,28 +309,29 @@
   objArrayOop transitive_interfaces() const     { return _transitive_interfaces; }
   void set_transitive_interfaces(objArrayOop a) { oop_store_without_check((oop*) &_transitive_interfaces, (oop) a); }
 
-  // fields
-  // Field info extracted from the class file and stored
-  // as an array of 7 shorts
-  enum FieldOffset {
-    access_flags_offset    = 0,
-    name_index_offset      = 1,
-    signature_index_offset = 2,
-    initval_index_offset   = 3,
-    low_offset             = 4,
-    high_offset            = 5,
-    generic_signature_offset = 6,
-    next_offset            = 7
-  };
+ private:
+  friend class fieldDescriptor;
+  FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }
+
+ public:
+  int     field_offset      (int index) const { return field(index)->offset(); }
+  int     field_access_flags(int index) const { return field(index)->access_flags(); }
+  Symbol* field_name        (int index) const { return field(index)->name(constants()); }
+  Symbol* field_signature   (int index) const { return field(index)->signature(constants()); }
+
+  // Number of Java declared fields
+  int java_fields_count() const           { return _java_fields_count; }
+
+  // Number of fields including any injected fields
+  int all_fields_count() const            { return _fields->length() / sizeof(FieldInfo::field_slots); }
 
   typeArrayOop fields() const              { return _fields; }
-  int offset_from_fields( int index ) const {
-    return build_int_from_shorts( fields()->ushort_at(index + low_offset),
-                                  fields()->ushort_at(index + high_offset) );
+
+  void set_fields(typeArrayOop f, int java_fields_count) {
+    oop_store_without_check((oop*) &_fields, (oop) f);
+    _java_fields_count = java_fields_count;
   }
 
-  void set_fields(typeArrayOop f)          { oop_store_without_check((oop*) &_fields, (oop) f); }
-
   // inner classes
   typeArrayOop inner_classes() const       { return _inner_classes; }
   void set_inner_classes(typeArrayOop f)   { oop_store_without_check((oop*) &_inner_classes, (oop) f); }
@@ -842,10 +845,6 @@
   // Verification
   const char* internal_name() const;
   void oop_verify_on(oop obj, outputStream* st);
-
-#ifndef PRODUCT
-  static void verify_class_klass_nonstatic_oop_maps(klassOop k) PRODUCT_RETURN;
-#endif
 };
 
 inline methodOop instanceKlass::method_at_vtable(int index)  {
@@ -1013,4 +1012,36 @@
   PreviousVersionInfo* next_previous_version();
 };
 
+
+//
+// nmethodBucket is used to record dependent nmethods for
+// deoptimization.  nmethod dependencies are actually <klass, method>
+// pairs but we really only care about the klass part for purposes of
+// finding nmethods which might need to be deoptimized.  Instead of
+// recording the method, a count of how many times a particular nmethod
+// was recorded is kept.  This ensures that any recording errors are
+// noticed since an nmethod should be removed as many times are it's
+// added.
+//
+class nmethodBucket: public CHeapObj {
+  friend class VMStructs;
+ private:
+  nmethod*       _nmethod;
+  int            _count;
+  nmethodBucket* _next;
+
+ public:
+  nmethodBucket(nmethod* nmethod, nmethodBucket* next) {
+    _nmethod = nmethod;
+    _next = next;
+    _count = 1;
+  }
+  int count()                             { return _count; }
+  int increment()                         { _count += 1; return _count; }
+  int decrement()                         { _count -= 1; assert(_count >= 0, "don't underflow"); return _count; }
+  nmethodBucket* next()                   { return _next; }
+  void set_next(nmethodBucket* b)         { _next = b; }
+  nmethod* get_nmethod()                  { return _nmethod; }
+};
+
 #endif // SHARE_VM_OOPS_INSTANCEKLASS_HPP
--- a/hotspot/src/share/vm/oops/instanceKlassKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlassKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -386,7 +386,7 @@
     ik->set_local_interfaces(NULL);
     ik->set_transitive_interfaces(NULL);
     ik->init_implementor();
-    ik->set_fields(NULL);
+    ik->set_fields(NULL, 0);
     ik->set_constants(NULL);
     ik->set_class_loader(NULL);
     ik->set_protection_domain(NULL);
--- a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -288,15 +288,7 @@
   // Query before forming handle.
   int size = instance_size(k);
   KlassHandle h_k(THREAD, as_klassOop());
-  instanceOop i;
-
-  if (JavaObjectsInPerm) {
-    i = (instanceOop) CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
-  } else {
-    assert(ScavengeRootsInCode > 0, "must be");
-    i = (instanceOop) CollectedHeap::obj_allocate(h_k, size, CHECK_NULL);
-  }
-
+  instanceOop i = (instanceOop) CollectedHeap::Class_obj_allocate(h_k, size, k, CHECK_NULL);
   return i;
 }
 
--- a/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/instanceRefKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -45,7 +45,7 @@
 #endif
 
 template <class T>
-static void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
+void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
   T heap_oop = oopDesc::load_heap_oop(referent_addr);
   debug_only(
@@ -56,9 +56,8 @@
   if (!oopDesc::is_null(heap_oop)) {
     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
     if (!referent->is_gc_marked() &&
-        MarkSweep::ref_processor()->
-          discover_reference(obj, ref->reference_type())) {
-      // reference already enqueued, referent will be traversed later
+        MarkSweep::ref_processor()->discover_reference(obj, ref->reference_type())) {
+      // reference was discovered, referent will be traversed later
       ref->instanceKlass::oop_follow_contents(obj);
       debug_only(
         if(TraceReferenceGC && PrintGCDetails) {
@@ -76,8 +75,34 @@
       MarkSweep::mark_and_push(referent_addr);
     }
   }
-  // treat next as normal oop.  next is a link in the pending list.
   T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
+  if (ReferenceProcessor::pending_list_uses_discovered_field()) {
+    // Treat discovered as normal oop, if ref is not "active",
+    // i.e. if next is non-NULL.
+    T  next_oop = oopDesc::load_heap_oop(next_addr);
+    if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
+      T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
+      debug_only(
+        if(TraceReferenceGC && PrintGCDetails) {
+          gclog_or_tty->print_cr("   Process discovered as normal "
+                                 INTPTR_FORMAT, discovered_addr);
+        }
+      )
+      MarkSweep::mark_and_push(discovered_addr);
+    }
+  } else {
+#ifdef ASSERT
+    // In the case of older JDKs which do not use the discovered
+    // field for the pending list, an inactive ref (next != NULL)
+    // must always have a NULL discovered field.
+    oop next = oopDesc::load_decode_heap_oop(next_addr);
+    oop discovered = java_lang_ref_Reference::discovered(obj);
+    assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
+           err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
+                   (oopDesc*)obj));
+#endif
+  }
+  // treat next as normal oop.  next is a link in the reference queue.
   debug_only(
     if(TraceReferenceGC && PrintGCDetails) {
       gclog_or_tty->print_cr("   Process next as normal " INTPTR_FORMAT, next_addr);
@@ -130,13 +155,33 @@
       PSParallelCompact::mark_and_push(cm, referent_addr);
     }
   }
-  // treat next as normal oop.  next is a link in the pending list.
   T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
-  debug_only(
-    if(TraceReferenceGC && PrintGCDetails) {
-      gclog_or_tty->print_cr("   Process next as normal " INTPTR_FORMAT, next_addr);
+  if (ReferenceProcessor::pending_list_uses_discovered_field()) {
+    // Treat discovered as normal oop, if ref is not "active",
+    // i.e. if next is non-NULL.
+    T  next_oop = oopDesc::load_heap_oop(next_addr);
+    if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
+      T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
+      debug_only(
+        if(TraceReferenceGC && PrintGCDetails) {
+          gclog_or_tty->print_cr("   Process discovered as normal "
+                                 INTPTR_FORMAT, discovered_addr);
+        }
+      )
+      PSParallelCompact::mark_and_push(cm, discovered_addr);
     }
-  )
+  } else {
+#ifdef ASSERT
+    // In the case of older JDKs which do not use the discovered
+    // field for the pending list, an inactive ref (next != NULL)
+    // must always have a NULL discovered field.
+    T next = oopDesc::load_heap_oop(next_addr);
+    oop discovered = java_lang_ref_Reference::discovered(obj);
+    assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
+           err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
+                   (oopDesc*)obj));
+#endif
+  }
   PSParallelCompact::mark_and_push(cm, next_addr);
   ref->instanceKlass::oop_follow_contents(cm, obj);
 }
@@ -197,27 +242,53 @@
 }
 
 #define InstanceRefKlass_SPECIALIZED_OOP_ITERATE(T, nv_suffix, contains)        \
+  T* disc_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);             \
   if (closure->apply_to_weak_ref_discovered_field()) {                          \
-    T* disc_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);           \
     closure->do_oop##nv_suffix(disc_addr);                                      \
   }                                                                             \
                                                                                 \
   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);           \
   T heap_oop = oopDesc::load_heap_oop(referent_addr);                           \
-  if (!oopDesc::is_null(heap_oop) && contains(referent_addr)) {                 \
-    ReferenceProcessor* rp = closure->_ref_processor;                           \
+  ReferenceProcessor* rp = closure->_ref_processor;                             \
+  if (!oopDesc::is_null(heap_oop)) {                                            \
     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);                 \
     if (!referent->is_gc_marked() && (rp != NULL) &&                            \
         rp->discover_reference(obj, reference_type())) {                        \
       return size;                                                              \
-    } else {                                                                    \
+    } else if (contains(referent_addr)) {                                       \
       /* treat referent as normal oop */                                        \
       SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
       closure->do_oop##nv_suffix(referent_addr);                                \
     }                                                                           \
   }                                                                             \
+  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);                   \
+  if (ReferenceProcessor::pending_list_uses_discovered_field()) {               \
+    T next_oop  = oopDesc::load_heap_oop(next_addr);                            \
+    /* Treat discovered as normal oop, if ref is not "active" (next non-NULL) */\
+    if (!oopDesc::is_null(next_oop) && contains(disc_addr)) {                   \
+        /* i.e. ref is not "active" */                                          \
+      debug_only(                                                               \
+        if(TraceReferenceGC && PrintGCDetails) {                                \
+          gclog_or_tty->print_cr("   Process discovered as normal "             \
+                                 INTPTR_FORMAT, disc_addr);                     \
+        }                                                                       \
+      )                                                                         \
+      SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
+      closure->do_oop##nv_suffix(disc_addr);                                    \
+    }                                                                           \
+  } else {                                                                      \
+    /* In the case of older JDKs which do not use the discovered field for  */  \
+    /* the pending list, an inactive ref (next != NULL) must always have a  */  \
+    /* NULL discovered field. */                                                \
+    debug_only(                                                                 \
+      T next_oop = oopDesc::load_heap_oop(next_addr);                           \
+      T disc_oop = oopDesc::load_heap_oop(disc_addr);                           \
+      assert(oopDesc::is_null(next_oop) || oopDesc::is_null(disc_oop),          \
+           err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL" \
+                   "discovered field", (oopDesc*)obj));                                   \
+    )                                                                           \
+  }                                                                             \
   /* treat next as normal oop */                                                \
-  T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);                   \
   if (contains(next_addr)) {                                                    \
     SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \
     closure->do_oop##nv_suffix(next_addr);                                      \
@@ -306,8 +377,37 @@
       pm->claim_or_forward_depth(referent_addr);
     }
   }
-  // treat next as normal oop
+  // Treat discovered as normal oop, if ref is not "active",
+  // i.e. if next is non-NULL.
   T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
+  if (ReferenceProcessor::pending_list_uses_discovered_field()) {
+    T  next_oop = oopDesc::load_heap_oop(next_addr);
+    if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
+      T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
+      debug_only(
+        if(TraceReferenceGC && PrintGCDetails) {
+          gclog_or_tty->print_cr("   Process discovered as normal "
+                                 INTPTR_FORMAT, discovered_addr);
+        }
+      )
+      if (PSScavenge::should_scavenge(discovered_addr)) {
+        pm->claim_or_forward_depth(discovered_addr);
+      }
+    }
+  } else {
+#ifdef ASSERT
+    // In the case of older JDKs which do not use the discovered
+    // field for the pending list, an inactive ref (next != NULL)
+    // must always have a NULL discovered field.
+    oop next = oopDesc::load_decode_heap_oop(next_addr);
+    oop discovered = java_lang_ref_Reference::discovered(obj);
+    assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
+           err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
+                   (oopDesc*)obj));
+#endif
+  }
+
+  // Treat next as normal oop;  next is a link in the reference queue.
   if (PSScavenge::should_scavenge(next_addr)) {
     pm->claim_or_forward_depth(next_addr);
   }
--- a/hotspot/src/share/vm/oops/klassOop.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/klassOop.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -53,8 +53,10 @@
  private:
   // These have no implementation since klassOop should never be accessed in this fashion
   oop obj_field(int offset) const;
+  volatile oop obj_field_volatile(int offset) const;
   void obj_field_put(int offset, oop value);
-  void obj_field_raw_put(int offset, oop value);
+  void obj_field_put_raw(int offset, oop value);
+  void obj_field_put_volatile(int offset, oop value);
 
   jbyte byte_field(int offset) const;
   void byte_field_put(int offset, jbyte contents);
--- a/hotspot/src/share/vm/oops/markOop.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/markOop.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -33,6 +33,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 void markOopDesc::print_on(outputStream* st) const {
--- a/hotspot/src/share/vm/oops/methodDataOop.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/methodDataOop.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -600,6 +600,11 @@
   uint taken() {
     return uint_at(taken_off_set);
   }
+
+  void set_taken(uint cnt) {
+    set_uint_at(taken_off_set, cnt);
+  }
+
   // Saturating counter
   uint inc_taken() {
     uint cnt = taken() + 1;
@@ -926,6 +931,10 @@
     return uint_at(not_taken_off_set);
   }
 
+  void set_not_taken(uint cnt) {
+    set_uint_at(not_taken_off_set, cnt);
+  }
+
   uint inc_not_taken() {
     uint cnt = not_taken() + 1;
     // Did we wrap? Will compiler screw us??
--- a/hotspot/src/share/vm/oops/methodOop.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/methodOop.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -914,6 +914,7 @@
                                                Symbol* name,
                                                Symbol* signature,
                                                Handle method_type, TRAPS) {
+  ResourceMark rm;
   methodHandle empty;
 
   assert(holder() == SystemDictionary::MethodHandle_klass(),
@@ -1267,12 +1268,19 @@
 
 // Comparer for sorting an object array containing
 // methodOops.
-template <class T>
-static int method_comparator(T a, T b) {
+// Used non-template method_comparator methods since
+// Visual Studio 2003 compiler generates incorrect
+// optimized code for it.
+static int method_comparator_narrowOop(narrowOop a, narrowOop b) {
   methodOop m = (methodOop)oopDesc::decode_heap_oop_not_null(a);
   methodOop n = (methodOop)oopDesc::decode_heap_oop_not_null(b);
   return m->name()->fast_compare(n->name());
 }
+static int method_comparator_oop(oop a, oop b) {
+  methodOop m = (methodOop)a;
+  methodOop n = (methodOop)b;
+  return m->name()->fast_compare(n->name());
+}
 
 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
 void methodOopDesc::sort_methods(objArrayOop methods,
@@ -1298,9 +1306,9 @@
     {
       No_Safepoint_Verifier nsv;
       if (UseCompressedOops) {
-        QuickSort::sort<narrowOop>((narrowOop*)(methods->base()), length, method_comparator<narrowOop>, idempotent);
+        QuickSort::sort<narrowOop>((narrowOop*)(methods->base()), length, method_comparator_narrowOop, idempotent);
       } else {
-        QuickSort::sort<oop>((oop*)(methods->base()), length, method_comparator<oop>, idempotent);
+        QuickSort::sort<oop>((oop*)(methods->base()), length, method_comparator_oop, idempotent);
       }
       if (UseConcMarkSweepGC) {
         // For CMS we need to dirty the cards for the array
--- a/hotspot/src/share/vm/oops/oop.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/oop.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 bool always_do_update_barrier = false;
 
--- a/hotspot/src/share/vm/oops/oop.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/oop.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -214,8 +214,10 @@
 
   // Access to fields in a instanceOop through these methods.
   oop obj_field(int offset) const;
+  volatile oop obj_field_volatile(int offset) const;
   void obj_field_put(int offset, oop value);
-  void obj_field_raw_put(int offset, oop value);
+  void obj_field_put_raw(int offset, oop value);
+  void obj_field_put_volatile(int offset, oop value);
 
   jbyte byte_field(int offset) const;
   void byte_field_put(int offset, jbyte contents);
--- a/hotspot/src/share/vm/oops/oop.inline.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -321,15 +321,25 @@
     load_decode_heap_oop(obj_field_addr<narrowOop>(offset)) :
     load_decode_heap_oop(obj_field_addr<oop>(offset));
 }
+inline volatile oop oopDesc::obj_field_volatile(int offset) const {
+  volatile oop value = obj_field(offset);
+  OrderAccess::acquire();
+  return value;
+}
 inline void oopDesc::obj_field_put(int offset, oop value) {
   UseCompressedOops ? oop_store(obj_field_addr<narrowOop>(offset), value) :
                       oop_store(obj_field_addr<oop>(offset),       value);
 }
-inline void oopDesc::obj_field_raw_put(int offset, oop value) {
+inline void oopDesc::obj_field_put_raw(int offset, oop value) {
   UseCompressedOops ?
     encode_store_heap_oop(obj_field_addr<narrowOop>(offset), value) :
     encode_store_heap_oop(obj_field_addr<oop>(offset),       value);
 }
+inline void oopDesc::obj_field_put_volatile(int offset, oop value) {
+  OrderAccess::release();
+  obj_field_put(offset, value);
+  OrderAccess::fence();
+}
 
 inline jbyte oopDesc::byte_field(int offset) const                  { return (jbyte) *byte_field_addr(offset);    }
 inline void oopDesc::byte_field_put(int offset, jbyte contents)     { *byte_field_addr(offset) = (jint) contents; }
--- a/hotspot/src/share/vm/oops/oopsHierarchy.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/oopsHierarchy.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifdef CHECK_UNHANDLED_OOPS
 
--- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -76,7 +76,7 @@
   return k();
 }
 
-typeArrayOop typeArrayKlass::allocate(int length, TRAPS) {
+typeArrayOop typeArrayKlass::allocate_common(int length, bool do_zero, TRAPS) {
   assert(log2_element_size() >= 0, "bad scale");
   if (length >= 0) {
     if (length <= max_length()) {
@@ -84,7 +84,11 @@
       KlassHandle h_k(THREAD, as_klassOop());
       typeArrayOop t;
       CollectedHeap* ch = Universe::heap();
-      t = (typeArrayOop)CollectedHeap::array_allocate(h_k, (int)size, length, CHECK_NULL);
+      if (do_zero) {
+        t = (typeArrayOop)CollectedHeap::array_allocate(h_k, (int)size, length, CHECK_NULL);
+      } else {
+        t = (typeArrayOop)CollectedHeap::array_allocate_nozero(h_k, (int)size, length, CHECK_NULL);
+      }
       assert(t->is_parsable(), "Don't publish unless parsable");
       return t;
     } else {
--- a/hotspot/src/share/vm/oops/typeArrayKlass.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/typeArrayKlass.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -56,7 +56,8 @@
   bool compute_is_subtype_of(klassOop k);
 
   // Allocation
-  typeArrayOop allocate(int length, TRAPS);
+  typeArrayOop allocate_common(int length, bool do_zero, TRAPS);
+  typeArrayOop allocate(int length, TRAPS) { return allocate_common(length, true, THREAD); }
   typeArrayOop allocate_permanent(int length, TRAPS);  // used for class file structures
   oop multi_allocate(int rank, jint* sizes, TRAPS);
 
--- a/hotspot/src/share/vm/oops/typeArrayOop.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/oops/typeArrayOop.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -51,6 +51,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "orderAccess_linux_ppc.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "orderAccess_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "orderAccess_bsd_zero.inline.hpp"
+#endif
 
 // A typeArrayOop is an array containing basic types (non oop elements).
 // It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs}
--- a/hotspot/src/share/vm/opto/block.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/block.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1107,7 +1107,7 @@
 
 //------------------------------trace_frequency_order--------------------------
 // Comparison function for edges
-static int trace_frequency_order(const void *p0, const void *p1) {
+extern "C" int trace_frequency_order(const void *p0, const void *p1) {
   Trace *tr0 = *(Trace **) p0;
   Trace *tr1 = *(Trace **) p1;
   Block *b0 = tr0->first_block();
--- a/hotspot/src/share/vm/opto/block.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/block.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,7 @@
 // Note that the constructor just zeros things, and since I use Arena
 // allocation I do not need a destructor to reclaim storage.
 class Block_Array : public ResourceObj {
+  friend class VMStructs;
   uint _size;                   // allocated size, as opposed to formal limit
   debug_only(uint _limit;)      // limit to formal domain
 protected:
@@ -72,6 +73,7 @@
 
 
 class Block_List : public Block_Array {
+  friend class VMStructs;
 public:
   uint _cnt;
   Block_List() : Block_Array(Thread::current()->resource_area()), _cnt(0) {}
@@ -87,6 +89,7 @@
 
 
 class CFGElement : public ResourceObj {
+  friend class VMStructs;
  public:
   float _freq; // Execution frequency (estimate)
 
@@ -102,6 +105,7 @@
 // Basic blocks are used during the output routines, and are not used during
 // any optimization pass.  They are created late in the game.
 class Block : public CFGElement {
+  friend class VMStructs;
  public:
   // Nodes in this block, in order
   Node_List _nodes;
@@ -341,6 +345,7 @@
 //------------------------------PhaseCFG---------------------------------------
 // Build an array of Basic Block pointers, one per Node.
 class PhaseCFG : public Phase {
+  friend class VMStructs;
  private:
   // Build a proper looking cfg.  Return count of basic blocks
   uint build_cfg();
@@ -515,6 +520,7 @@
 
 //------------------------------CFGLoop-------------------------------------------
 class CFGLoop : public CFGElement {
+  friend class VMStructs;
   int _id;
   int _depth;
   CFGLoop *_parent;      // root of loop tree is the method level "pseudo" loop, it's parent is null
@@ -566,6 +572,7 @@
 // A edge between two basic blocks that will be embodied by a branch or a
 // fall-through.
 class CFGEdge : public ResourceObj {
+  friend class VMStructs;
  private:
   Block * _from;        // Source basic block
   Block * _to;          // Destination basic block
@@ -702,6 +709,7 @@
 //------------------------------PhaseBlockLayout-------------------------------
 // Rearrange blocks into some canonical order, based on edges and their frequencies
 class PhaseBlockLayout : public Phase {
+  friend class VMStructs;
   PhaseCFG &_cfg;               // Control flow graph
 
   GrowableArray<CFGEdge *> *edges;
--- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -45,7 +45,7 @@
   _method(callee),
   _site_invoke_ratio(site_invoke_ratio),
   _max_inline_level(max_inline_level),
-  _count_inline_bcs(method()->code_size())
+  _count_inline_bcs(method()->code_size_for_inlining())
 {
   NOT_PRODUCT(_count_inlines = 0;)
   if (_caller_jvms != NULL) {
@@ -107,7 +107,7 @@
 
   // positive filter: should send be inlined?  returns NULL (--> yes)
   // or rejection msg
-  int size = callee_method->code_size();
+  int size = callee_method->code_size_for_inlining();
 
   // Check for too many throws (and not too huge)
   if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
@@ -141,7 +141,21 @@
     assert(mha_profile, "must exist");
     CounterData* cd = mha_profile->as_CounterData();
     invoke_count = cd->count();
-    call_site_count = invoke_count;  // use the same value
+    if (invoke_count == 0) {
+      return "method handle not reached";
+    }
+
+    if (_caller_jvms != NULL && _caller_jvms->method() != NULL &&
+        _caller_jvms->method()->method_data() != NULL &&
+        !_caller_jvms->method()->method_data()->is_empty()) {
+      ciMethodData* mdo = _caller_jvms->method()->method_data();
+      ciProfileData* mha_profile = mdo->bci_to_data(_caller_jvms->bci());
+      assert(mha_profile, "must exist");
+      CounterData* cd = mha_profile->as_CounterData();
+      call_site_count = cd->count();
+    } else {
+      call_site_count = invoke_count;  // use the same value
+    }
   }
 
   assert(invoke_count != 0, "require invocation count greater than zero");
@@ -244,7 +258,7 @@
   }
 
   // use frequency-based objections only for non-trivial methods
-  if (callee_method->code_size() <= MaxTrivialSize) return NULL;
+  if (callee_method->code_size_for_inlining() <= MaxTrivialSize) return NULL;
 
   // don't use counts with -Xcomp or CTW
   if (UseInterpreter && !CompileTheWorld) {
@@ -305,7 +319,7 @@
   }
 
   // suppress a few checks for accessors and trivial methods
-  if (callee_method->code_size() > MaxTrivialSize) {
+  if (callee_method->code_size_for_inlining() > MaxTrivialSize) {
 
     // don't inline into giant methods
     if (C->unique() > (uint)NodeCountInliningCutoff) {
@@ -349,7 +363,7 @@
     }
   }
 
-  int size = callee_method->code_size();
+  int size = callee_method->code_size_for_inlining();
 
   if (UseOldInlining && ClipInlining
       && (int)count_inline_bcs() + size >= DesiredMethodLimit) {
@@ -394,6 +408,16 @@
   return true;
 }
 
+//------------------------------check_can_parse--------------------------------
+const char* InlineTree::check_can_parse(ciMethod* callee) {
+  // Certain methods cannot be parsed at all:
+  if ( callee->is_native())                     return "native method";
+  if (!callee->can_be_compiled())               return "not compilable (disabled)";
+  if (!callee->has_balanced_monitors())         return "not compilable (unbalanced monitors)";
+  if ( callee->get_flow_analysis()->failing())  return "not compilable (flow analysis failed)";
+  return NULL;
+}
+
 //------------------------------print_inlining---------------------------------
 // Really, the failure_msg can be a success message also.
 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, const char* failure_msg) const {
@@ -423,14 +447,22 @@
   int         caller_bci    = jvms->bci();
   ciMethod   *caller_method = jvms->method();
 
-  if( !pass_initial_checks(caller_method, caller_bci, callee_method)) {
-    if( PrintInlining ) {
+  // Do some initial checks.
+  if (!pass_initial_checks(caller_method, caller_bci, callee_method)) {
+    if (PrintInlining) {
       failure_msg = "failed_initial_checks";
-      print_inlining( callee_method, caller_bci, failure_msg);
+      print_inlining(callee_method, caller_bci, failure_msg);
     }
     return NULL;
   }
 
+  // Do some parse checks.
+  failure_msg = check_can_parse(callee_method);
+  if (failure_msg != NULL) {
+    if (PrintInlining)  print_inlining(callee_method, caller_bci, failure_msg);
+    return NULL;
+  }
+
   // Check if inlining policy says no.
   WarmCallInfo wci = *(initial_wci);
   failure_msg = try_to_inline(callee_method, caller_method, caller_bci, profile, &wci);
@@ -471,7 +503,7 @@
     if (failure_msg == NULL)  failure_msg = "inline (hot)";
 
     // Inline!
-    if( PrintInlining ) print_inlining( callee_method, caller_bci, failure_msg);
+    if (PrintInlining)  print_inlining(callee_method, caller_bci, failure_msg);
     if (UseOldInlining)
       build_inline_tree_for_callee(callee_method, jvms, caller_bci);
     if (InlineWarmCalls && !wci.is_hot())
@@ -481,7 +513,7 @@
 
   // Do not inline
   if (failure_msg == NULL)  failure_msg = "too cold to inline";
-  if( PrintInlining ) print_inlining( callee_method, caller_bci, failure_msg);
+  if (PrintInlining)  print_inlining(callee_method, caller_bci, failure_msg);
   return NULL;
 }
 
@@ -578,3 +610,22 @@
   }
   return iltp;
 }
+
+
+
+#ifndef PRODUCT
+void InlineTree::print_impl(outputStream* st, int indent) const {
+  for (int i = 0; i < indent; i++) st->print(" ");
+  st->print(" @ %d ", caller_bci());
+  method()->print_short_name(st);
+  st->cr();
+
+  for (int i = 0 ; i < _subtrees.length(); i++) {
+    _subtrees.at(i)->print_impl(st, indent + 2);
+  }
+}
+
+void InlineTree::print_value_on(outputStream* st) const {
+  print_impl(st, 2);
+}
+#endif
--- a/hotspot/src/share/vm/opto/c2_globals.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/c2_globals.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -44,6 +44,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "c2_globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "c2_globals_bsd.hpp"
+#endif
 
 //
 // Defines all globals flags used by the server compiler.
--- a/hotspot/src/share/vm/opto/callGenerator.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/callGenerator.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -61,12 +61,9 @@
   {
     _is_osr        = is_osr;
     _expected_uses = expected_uses;
-    assert(can_parse(method, is_osr), "parse must be possible");
+    assert(InlineTree::check_can_parse(method) == NULL, "parse must be possible");
   }
 
-  // Can we build either an OSR or a regular parser for this method?
-  static bool can_parse(ciMethod* method, int is_osr = false);
-
   virtual bool      is_parse() const           { return true; }
   virtual JVMState* generate(JVMState* jvms);
   int is_osr() { return _is_osr; }
@@ -152,7 +149,6 @@
     call->set_optimized_virtual(true);
     if (method()->is_method_handle_invoke()) {
       call->set_method_handle_invoke(true);
-      kit.C->set_has_method_handle_invokes(true);
     }
   }
   kit.set_arguments_for_java_call(call);
@@ -210,7 +206,6 @@
   call->set_optimized_virtual(true);
   // Take extra care (in the presence of argument motion) not to trash the SP:
   call->set_method_handle_invoke(true);
-  kit.C->set_has_method_handle_invokes(true);
 
   // Pass the target MethodHandle as first argument and shift the
   // other arguments.
@@ -303,20 +298,8 @@
   return kit.transfer_exceptions_into_jvms();
 }
 
-bool ParseGenerator::can_parse(ciMethod* m, int entry_bci) {
-  // Certain methods cannot be parsed at all:
-  if (!m->can_be_compiled())              return false;
-  if (!m->has_balanced_monitors())        return false;
-  if (m->get_flow_analysis()->failing())  return false;
-
-  // (Methods may bail out for other reasons, after the parser is run.
-  // We try to avoid this, but if forced, we must return (Node*)NULL.
-  // The user of the CallGenerator must check for this condition.)
-  return true;
-}
-
 CallGenerator* CallGenerator::for_inline(ciMethod* m, float expected_uses) {
-  if (!ParseGenerator::can_parse(m))  return NULL;
+  if (InlineTree::check_can_parse(m) != NULL)  return NULL;
   return new ParseGenerator(m, expected_uses);
 }
 
@@ -324,7 +307,7 @@
 // for the method execution already in progress, not just the JVMS
 // of the caller.  Thus, this CallGenerator cannot be mixed with others!
 CallGenerator* CallGenerator::for_osr(ciMethod* m, int osr_bci) {
-  if (!ParseGenerator::can_parse(m, true))  return NULL;
+  if (InlineTree::check_can_parse(m) != NULL)  return NULL;
   float past_uses = m->interpreter_invocation_count();
   float expected_uses = past_uses;
   return new ParseGenerator(m, expected_uses, true);
@@ -336,7 +319,7 @@
 }
 
 CallGenerator* CallGenerator::for_dynamic_call(ciMethod* m) {
-  assert(m->is_method_handle_invoke(), "for_dynamic_call mismatch");
+  assert(m->is_method_handle_invoke() || m->is_method_handle_adapter(), "for_dynamic_call mismatch");
   return new DynamicCallGenerator(m);
 }
 
@@ -715,24 +698,36 @@
     // Get an adapter for the MethodHandle.
     ciMethod* target_method = method_handle->get_method_handle_adapter();
     if (target_method != NULL) {
-      CallGenerator* hit_cg = Compile::current()->call_generator(target_method, -1, false, jvms, true, 1);
-      if (hit_cg != NULL && hit_cg->is_inline())
-        return hit_cg;
+      CallGenerator* cg = Compile::current()->call_generator(target_method, -1, false, jvms, true, PROB_ALWAYS);
+      if (cg != NULL && cg->is_inline())
+        return cg;
     }
   } else if (method_handle->Opcode() == Op_Phi && method_handle->req() == 3 &&
              method_handle->in(1)->Opcode() == Op_ConP && method_handle->in(2)->Opcode() == Op_ConP) {
+    float prob = PROB_FAIR;
+    Node* meth_region = method_handle->in(0);
+    if (meth_region->is_Region() &&
+        meth_region->in(1)->is_Proj() && meth_region->in(2)->is_Proj() &&
+        meth_region->in(1)->in(0) == meth_region->in(2)->in(0) &&
+        meth_region->in(1)->in(0)->is_If()) {
+      // If diamond, so grab the probability of the test to drive the inlining below
+      prob = meth_region->in(1)->in(0)->as_If()->_prob;
+      if (meth_region->in(1)->is_IfTrue()) {
+        prob = 1 - prob;
+      }
+    }
+
     // selectAlternative idiom merging two constant MethodHandles.
     // Generate a guard so that each can be inlined.  We might want to
     // do more inputs at later point but this gets the most common
     // case.
-    const TypeOopPtr* oop_ptr = method_handle->in(1)->bottom_type()->is_oopptr();
-    ciObject* const_oop = oop_ptr->const_oop();
-    ciMethodHandle* mh = const_oop->as_method_handle();
-
-    CallGenerator* cg1 = for_method_handle_inline(method_handle->in(1), jvms, caller, callee, profile);
-    CallGenerator* cg2 = for_method_handle_inline(method_handle->in(2), jvms, caller, callee, profile);
+    CallGenerator* cg1 = for_method_handle_inline(method_handle->in(1), jvms, caller, callee, profile.rescale(1.0 - prob));
+    CallGenerator* cg2 = for_method_handle_inline(method_handle->in(2), jvms, caller, callee, profile.rescale(prob));
     if (cg1 != NULL && cg2 != NULL) {
-      return new PredictedDynamicCallGenerator(mh, cg2, cg1, PROB_FAIR);
+      const TypeOopPtr* oop_ptr = method_handle->in(1)->bottom_type()->is_oopptr();
+      ciObject* const_oop = oop_ptr->const_oop();
+      ciMethodHandle* mh = const_oop->as_method_handle();
+      return new PredictedDynamicCallGenerator(mh, cg2, cg1, prob);
     }
   }
   return NULL;
@@ -741,7 +736,6 @@
 
 CallGenerator* CallGenerator::for_invokedynamic_inline(ciCallSite* call_site, JVMState* jvms,
                                                        ciMethod* caller, ciMethod* callee, ciCallProfile profile) {
-  assert(call_site->is_constant_call_site() || call_site->is_mutable_call_site(), "must be");
   ciMethodHandle* method_handle = call_site->get_target();
 
   // Set the callee to have access to the class and signature in the
@@ -754,13 +748,13 @@
   ciMethod* target_method = method_handle->get_invokedynamic_adapter();
   if (target_method != NULL) {
     Compile *C = Compile::current();
-    CallGenerator* hit_cg = C->call_generator(target_method, -1, false, jvms, true, PROB_ALWAYS);
-    if (hit_cg != NULL && hit_cg->is_inline()) {
+    CallGenerator* cg = C->call_generator(target_method, -1, false, jvms, true, PROB_ALWAYS);
+    if (cg != NULL && cg->is_inline()) {
       // Add a dependence for invalidation of the optimization.
-      if (call_site->is_mutable_call_site()) {
-        C->dependencies()->assert_call_site_target_value(C->env()->CallSite_klass(), call_site, method_handle);
+      if (!call_site->is_constant_call_site()) {
+        C->dependencies()->assert_call_site_target_value(call_site, method_handle);
       }
-      return hit_cg;
+      return cg;
     }
   }
   return NULL;
--- a/hotspot/src/share/vm/opto/callnode.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/callnode.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -187,6 +187,7 @@
 // This provides a way to map the optimized program back into the interpreter,
 // or to let the GC mark the stack.
 class JVMState : public ResourceObj {
+  friend class VMStructs;
 public:
   typedef enum {
     Reexecute_Undefined = -1, // not defined -- will be translated into false later
@@ -500,6 +501,7 @@
 // Call nodes now subsume the function of debug nodes at callsites, so they
 // contain the functionality of a full scope chain of debug nodes.
 class CallNode : public SafePointNode {
+  friend class VMStructs;
 public:
   const TypeFunc *_tf;        // Function type
   address      _entry_point;  // Address of method being called
@@ -565,6 +567,7 @@
 // convention.  (The "Java" calling convention is the compiler's calling
 // convention, as opposed to the interpreter's or that of native C.)
 class CallJavaNode : public CallNode {
+  friend class VMStructs;
 protected:
   virtual uint cmp( const Node &n ) const;
   virtual uint size_of() const; // Size is bigger
--- a/hotspot/src/share/vm/opto/chaitin.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/chaitin.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,7 @@
 //------------------------------LRG--------------------------------------------
 // Live-RanGe structure.
 class LRG : public ResourceObj {
+  friend class VMStructs;
 public:
   enum { SPILL_REG=29999 };     // Register number of a spilled LRG
 
@@ -181,6 +182,7 @@
 // Map Node indices to Live RanGe indices.
 // Array lookup in the optimized case.
 class LRG_List : public ResourceObj {
+  friend class VMStructs;
   uint _cnt, _max;
   uint* _lidxs;
   ReallocMark _nesting;         // assertion check for reallocations
@@ -211,6 +213,7 @@
 // abstract!  It needs abstraction so I can fiddle with the implementation to
 // get even more speed.
 class PhaseIFG : public Phase {
+  friend class VMStructs;
   // Current implementation: a triangular adjacency list.
 
   // Array of adjacency-lists, indexed by live-range number
@@ -294,6 +297,7 @@
 //------------------------------Chaitin----------------------------------------
 // Briggs-Chaitin style allocation, mostly.
 class PhaseChaitin : public PhaseRegAlloc {
+  friend class VMStructs;
 
   int _trip_cnt;
   int _alternate;
@@ -482,6 +486,7 @@
   }
 
   int yank_if_dead( Node *old, Block *current_block, Node_List *value, Node_List *regnd );
+  int yank( Node *old, Block *current_block, Node_List *value, Node_List *regnd );
   int elide_copy( Node *n, int k, Block *current_block, Node_List &value, Node_List &regnd, bool can_change_regs );
   int use_prior_register( Node *copy, uint idx, Node *def, Block *current_block, Node_List &value, Node_List &regnd );
   bool may_be_copy_of_callee( Node *def ) const;
--- a/hotspot/src/share/vm/opto/compile.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/compile.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -817,7 +817,6 @@
                            &_handler_table, &_inc_table,
                            compiler,
                            env()->comp_level(),
-                           true, /*has_debug_info*/
                            has_unsafe_access()
                            );
   }
--- a/hotspot/src/share/vm/opto/compile.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/compile.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -80,6 +80,8 @@
 // This class defines a top-level Compiler invocation.
 
 class Compile : public Phase {
+  friend class VMStructs;
+
  public:
   // Fixed alias indexes.  (See also MergeMemNode.)
   enum {
--- a/hotspot/src/share/vm/opto/connode.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/connode.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -721,12 +721,7 @@
   if( t == Type::TOP ) return Type::TOP;
   if( t == Type::FLOAT ) return Type::DOUBLE;
   const TypeF *tf = t->is_float_constant();
-#ifndef IA64
   return TypeD::make( (double)tf->getf() );
-#else
-  float x = tf->getf();
-  return TypeD::make( (x == 0.0f) ? (double)x : (double)x + ia64_double_zero );
-#endif
 }
 
 //=============================================================================
--- a/hotspot/src/share/vm/opto/connode.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/connode.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -496,14 +496,6 @@
   virtual bool depends_only_on_test() const { return false; }
 };
 
-//------------------------------MemMoveNode------------------------------------
-// Memory to memory move.  Inserted very late, after allocation.
-class MemMoveNode : public Node {
-public:
-  MemMoveNode( Node *dst, Node *src ) : Node(0,dst,src) {}
-  virtual int Opcode() const;
-};
-
 //------------------------------ThreadLocalNode--------------------------------
 // Ideal Node which returns the base of ThreadLocalStorage.
 class ThreadLocalNode : public Node {
--- a/hotspot/src/share/vm/opto/doCall.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/doCall.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -136,15 +136,9 @@
       str.force_bci(jvms->bci());  // Set the stream to the invokedynamic bci.
       ciCallSite* call_site = str.get_call_site();
 
-      // Inline constant and mutable call sites.  We don't inline
-      // volatile call sites optimistically since they are specified
-      // to change their value often and that would result in a lot of
-      // deoptimizations and recompiles.
-      if (call_site->is_constant_call_site() || call_site->is_mutable_call_site()) {
-        CallGenerator* cg = CallGenerator::for_invokedynamic_inline(call_site, jvms, caller, call_method, profile);
-        if (cg != NULL) {
-          return cg;
-        }
+      CallGenerator* cg = CallGenerator::for_invokedynamic_inline(call_site, jvms, caller, call_method, profile);
+      if (cg != NULL) {
+        return cg;
       }
       // If something failed, generate a normal dynamic call.
       return CallGenerator::for_dynamic_call(call_method);
--- a/hotspot/src/share/vm/opto/idealGraphPrinter.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/idealGraphPrinter.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -375,9 +375,9 @@
   return (intptr_t)(n);
 }
 
-void IdealGraphPrinter::visit_node(Node *n, void *param) {
+void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {
 
-  if(param) {
+  if (edges) {
 
     // Output edge
     intptr_t dest_id = get_node_id(n);
@@ -599,16 +599,11 @@
 
 #ifdef ASSERT
     if (node->debug_orig() != NULL) {
+      temp_set->Clear();
       stringStream dorigStream;
       Node* dorig = node->debug_orig();
-      if (dorig) {
+      while (dorig && temp_set->test_set(dorig->_idx)) {
         dorigStream.print("%d ", dorig->_idx);
-        Node* first = dorig;
-        dorig = first->debug_orig();
-        while (dorig && dorig != first) {
-          dorigStream.print("%d ", dorig->_idx);
-          dorig = dorig->debug_orig();
-        }
       }
       print_prop("debug_orig", dorigStream.as_string());
     }
@@ -629,7 +624,7 @@
   }
 }
 
-void IdealGraphPrinter::walk_nodes(Node *start, void *param) {
+void IdealGraphPrinter::walk_nodes(Node *start, bool edges, VectorSet* temp_set) {
 
 
   VectorSet visited(Thread::current()->resource_area());
@@ -650,7 +645,7 @@
   while(nodeStack.length() > 0) {
 
     Node *n = nodeStack.pop();
-    visit_node(n, param);
+    visit_node(n, edges, temp_set);
 
     if (_traverse_outs) {
       for (DUIterator i = n->outs(); n->has_out(i); i++) {
@@ -689,12 +684,14 @@
   print_attr(GRAPH_NAME_PROPERTY, (const char *)name);
   end_head();
 
+  VectorSet temp_set(Thread::current()->resource_area());
+
   head(NODES_ELEMENT);
-  walk_nodes(node, NULL);
+  walk_nodes(node, false, &temp_set);
   tail(NODES_ELEMENT);
 
   head(EDGES_ELEMENT);
-  walk_nodes(node, (void *)1);
+  walk_nodes(node, true, &temp_set);
   tail(EDGES_ELEMENT);
   if (C->cfg() != NULL) {
     head(CONTROL_FLOW_ELEMENT);
--- a/hotspot/src/share/vm/opto/idealGraphPrinter.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/idealGraphPrinter.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -104,8 +104,8 @@
   void print_indent();
   void print_method(ciMethod *method, int bci, InlineTree *tree);
   void print_inline_tree(InlineTree *tree);
-  void visit_node(Node *n, void *param);
-  void walk_nodes(Node *start, void *param);
+  void visit_node(Node *n, bool edges, VectorSet* temp_set);
+  void walk_nodes(Node *start, bool edges, VectorSet* temp_set);
   void begin_elem(const char *s);
   void end_elem();
   void begin_head(const char *s);
--- a/hotspot/src/share/vm/opto/library_call.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -4658,6 +4658,7 @@
     // "You break it, you buy it."
     InitializeNode* init = alloc->initialization();
     assert(init->is_complete(), "we just did this");
+    init->set_complete_with_arraycopy();
     assert(dest->is_CheckCastPP(), "sanity");
     assert(dest->in(0)->in(0) == init, "dest pinned");
     adr_type = TypeRawPtr::BOTTOM;  // all initializations are into raw memory
--- a/hotspot/src/share/vm/opto/loopTransform.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -709,10 +709,13 @@
 
   // Adjust body_size to determine if we unroll or not
   uint body_size = _body.size();
+  // Key test to unroll loop in CRC32 java code
+  int xors_in_loop = 0;
   // Also count ModL, DivL and MulL which expand mightly
   for (uint k = 0; k < _body.size(); k++) {
     Node* n = _body.at(k);
     switch (n->Opcode()) {
+      case Op_XorI: xors_in_loop++; break; // CRC32 java code
       case Op_ModL: body_size += 30; break;
       case Op_DivL: body_size += 30; break;
       case Op_MulL: body_size += 10; break;
@@ -729,7 +732,8 @@
 
   // Check for being too big
   if (body_size > (uint)LoopUnrollLimit) {
-     // Normal case: loop too big
+    if (xors_in_loop >= 4 && body_size < (uint)LoopUnrollLimit*4) return true;
+    // Normal case: loop too big
     return false;
   }
 
--- a/hotspot/src/share/vm/opto/loopnode.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/loopnode.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -582,20 +582,25 @@
 
   // Build a canonical trip test.
   // Clone code, as old values may be in use.
-  Node* nphi = PhiNode::make(x, init_trip, TypeInt::INT);
-  nphi = _igvn.register_new_node_with_optimizer(nphi);
-  set_ctrl(nphi, get_ctrl(phi));
-
   incr = incr->clone();
-  incr->set_req(1,nphi);
+  incr->set_req(1,phi);
   incr->set_req(2,stride);
   incr = _igvn.register_new_node_with_optimizer(incr);
   set_early_ctrl( incr );
-
-  nphi->set_req(LoopNode::LoopBackControl, incr);
-  _igvn.replace_node(phi, nphi);
-  phi = nphi->as_Phi();
-
+  _igvn.hash_delete(phi);
+  phi->set_req_X( LoopNode::LoopBackControl, incr, &_igvn );
+
+  // If phi type is more restrictive than Int, raise to
+  // Int to prevent (almost) infinite recursion in igvn
+  // which can only handle integer types for constants or minint..maxint.
+  if (!TypeInt::INT->higher_equal(phi->bottom_type())) {
+    Node* nphi = PhiNode::make(phi->in(0), phi->in(LoopNode::EntryControl), TypeInt::INT);
+    nphi->set_req(LoopNode::LoopBackControl, phi->in(LoopNode::LoopBackControl));
+    nphi = _igvn.register_new_node_with_optimizer(nphi);
+    set_ctrl(nphi, get_ctrl(phi));
+    _igvn.replace_node(phi, nphi);
+    phi = nphi->as_Phi();
+  }
   cmp = cmp->clone();
   cmp->set_req(1,incr);
   cmp->set_req(2,limit);
@@ -1618,8 +1623,6 @@
   Node *phi  = cl->phi();
   int stride_con = cl->stride_con();
 
-  PhaseGVN *gvn = &_igvn;
-
   // Visit all children, looking for Phis
   for (DUIterator i = cl->outs(); cl->has_out(i); i++) {
     Node *out = cl->out(i);
@@ -1655,25 +1658,31 @@
     int ratio_con = stride_con2/stride_con;
 
     if ((ratio_con * stride_con) == stride_con2) { // Check for exact
+#ifndef PRODUCT
+      if (TraceLoopOpts) {
+        tty->print("Parallel IV: %d ", phi2->_idx);
+        loop->dump_head();
+      }
+#endif
       // Convert to using the trip counter.  The parallel induction
       // variable differs from the trip counter by a loop-invariant
       // amount, the difference between their respective initial values.
       // It is scaled by the 'ratio_con'.
-      // Perform local Ideal transformation since in most cases ratio == 1.
       Node* ratio = _igvn.intcon(ratio_con);
       set_ctrl(ratio, C->root());
-      Node* hook = new (C, 3) Node(3);
-      Node* ratio_init = gvn->transform(new (C, 3) MulINode(init, ratio));
-      hook->init_req(0, ratio_init);
-      Node* diff = gvn->transform(new (C, 3) SubINode(init2, ratio_init));
-      hook->init_req(1, diff);
-      Node* ratio_idx = gvn->transform(new (C, 3) MulINode(phi, ratio));
-      hook->init_req(2, ratio_idx);
-      Node* add  = gvn->transform(new (C, 3) AddINode(ratio_idx, diff));
-      set_subtree_ctrl(add);
+      Node* ratio_init = new (C, 3) MulINode(init, ratio);
+      _igvn.register_new_node_with_optimizer(ratio_init, init);
+      set_early_ctrl(ratio_init);
+      Node* diff = new (C, 3) SubINode(init2, ratio_init);
+      _igvn.register_new_node_with_optimizer(diff, init2);
+      set_early_ctrl(diff);
+      Node* ratio_idx = new (C, 3) MulINode(phi, ratio);
+      _igvn.register_new_node_with_optimizer(ratio_idx, phi);
+      set_ctrl(ratio_idx, cl);
+      Node* add = new (C, 3) AddINode(ratio_idx, diff);
+      _igvn.register_new_node_with_optimizer(add);
+      set_ctrl(add, cl);
       _igvn.replace_node( phi2, add );
-      // Free up intermediate goo
-      _igvn.remove_dead_node(hook);
       // Sometimes an induction variable is unused
       if (add->outcnt() == 0) {
         _igvn.remove_dead_node(add);
--- a/hotspot/src/share/vm/opto/macro.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/macro.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1685,9 +1685,21 @@
 
 void PhaseMacroExpand::expand_allocate_array(AllocateArrayNode *alloc) {
   Node* length = alloc->in(AllocateNode::ALength);
+  InitializeNode* init = alloc->initialization();
+  Node* klass_node = alloc->in(AllocateNode::KlassNode);
+  ciKlass* k = _igvn.type(klass_node)->is_klassptr()->klass();
+  address slow_call_address;  // Address of slow call
+  if (init != NULL && init->is_complete_with_arraycopy() &&
+      k->is_type_array_klass()) {
+    // Don't zero type array during slow allocation in VM since
+    // it will be initialized later by arraycopy in compiled code.
+    slow_call_address = OptoRuntime::new_array_nozero_Java();
+  } else {
+    slow_call_address = OptoRuntime::new_array_Java();
+  }
   expand_allocate_common(alloc, length,
                          OptoRuntime::new_array_Type(),
-                         OptoRuntime::new_array_Java());
+                         slow_call_address);
 }
 
 //-----------------------mark_eliminated_locking_nodes-----------------------
--- a/hotspot/src/share/vm/opto/matcher.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/matcher.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -501,6 +501,12 @@
      idealreg2spillmask[Op_RegP]->OR(*idealreg2regmask[Op_RegD]);
 #else
      idealreg2spillmask[Op_RegP]->OR(*idealreg2regmask[Op_RegF]);
+#ifdef ARM
+     // ARM has support for moving 64bit values between a pair of
+     // integer registers and a double register
+     idealreg2spillmask[Op_RegL]->OR(*idealreg2regmask[Op_RegD]);
+     idealreg2spillmask[Op_RegD]->OR(*idealreg2regmask[Op_RegL]);
+#endif
 #endif
    }
 
@@ -1106,6 +1112,9 @@
       mcall_java->_optimized_virtual = call_java->is_optimized_virtual();
       is_method_handle_invoke = call_java->is_method_handle_invoke();
       mcall_java->_method_handle_invoke = is_method_handle_invoke;
+      if (is_method_handle_invoke) {
+        C->set_has_method_handle_invokes(true);
+      }
       if( mcall_java->is_MachCallStaticJava() )
         mcall_java->as_MachCallStaticJava()->_name =
          call_java->as_CallStaticJava()->_name;
--- a/hotspot/src/share/vm/opto/memnode.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/memnode.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1493,6 +1493,7 @@
   if (tp == NULL || tp->empty())  return Type::TOP;
   int off = tp->offset();
   assert(off != Type::OffsetTop, "case covered by TypePtr::empty");
+  Compile* C = phase->C;
 
   // Try to guess loaded type from pointer type
   if (tp->base() == Type::AryPtr) {
@@ -1536,7 +1537,7 @@
           Node* base = adr->in(AddPNode::Base);
           if (base != NULL &&
               !phase->type(base)->higher_equal(TypePtr::NULL_PTR)) {
-            Compile::AliasType* atp = phase->C->alias_type(base->adr_type());
+            Compile::AliasType* atp = C->alias_type(base->adr_type());
             if (is_autobox_cache(atp)) {
               return jt->join(TypePtr::NOTNULL)->is_ptr();
             }
@@ -1546,22 +1547,23 @@
       }
     }
   } else if (tp->base() == Type::InstPtr) {
+    ciEnv* env = C->env();
     const TypeInstPtr* tinst = tp->is_instptr();
     ciKlass* klass = tinst->klass();
     assert( off != Type::OffsetBot ||
             // arrays can be cast to Objects
             tp->is_oopptr()->klass()->is_java_lang_Object() ||
             // unsafe field access may not have a constant offset
-            phase->C->has_unsafe_access(),
+            C->has_unsafe_access(),
             "Field accesses must be precise" );
     // For oop loads, we expect the _type to be precise
-    if (klass == phase->C->env()->String_klass() &&
+    if (klass == env->String_klass() &&
         adr->is_AddP() && off != Type::OffsetBot) {
       // For constant Strings treat the final fields as compile time constants.
       Node* base = adr->in(AddPNode::Base);
       const TypeOopPtr* t = phase->type(base)->isa_oopptr();
       if (t != NULL && t->singleton()) {
-        ciField* field = phase->C->env()->String_klass()->get_field_by_offset(off, false);
+        ciField* field = env->String_klass()->get_field_by_offset(off, false);
         if (field != NULL && field->is_final()) {
           ciObject* string = t->const_oop();
           ciConstant constant = string->as_instance()->field_value(field);
@@ -1577,6 +1579,32 @@
         }
       }
     }
+    // Optimizations for constant objects
+    ciObject* const_oop = tinst->const_oop();
+    if (const_oop != NULL) {
+      // For constant CallSites treat the target field as a compile time constant.
+      if (const_oop->is_call_site()) {
+        ciCallSite* call_site = const_oop->as_call_site();
+        ciField* field = call_site->klass()->as_instance_klass()->get_field_by_offset(off, /*is_static=*/ false);
+        if (field != NULL && field->is_call_site_target()) {
+          ciMethodHandle* target = call_site->get_target();
+          if (target != NULL) {  // just in case
+            ciConstant constant(T_OBJECT, target);
+            const Type* t;
+            if (adr->bottom_type()->is_ptr_to_narrowoop()) {
+              t = TypeNarrowOop::make_from_constant(constant.as_object(), true);
+            } else {
+              t = TypeOopPtr::make_from_constant(constant.as_object(), true);
+            }
+            // Add a dependence for invalidation of the optimization.
+            if (!call_site->is_constant_call_site()) {
+              C->dependencies()->assert_call_site_target_value(call_site, target);
+            }
+            return t;
+          }
+        }
+      }
+    }
   } else if (tp->base() == Type::KlassPtr) {
     assert( off != Type::OffsetBot ||
             // arrays can be cast to Objects
@@ -2819,7 +2847,7 @@
 
 //---------------------------InitializeNode------------------------------------
 InitializeNode::InitializeNode(Compile* C, int adr_type, Node* rawoop)
-  : _is_complete(false),
+  : _is_complete(Incomplete),
     MemBarNode(C, adr_type, rawoop)
 {
   init_class_id(Class_Initialize);
@@ -2857,7 +2885,7 @@
 
 void InitializeNode::set_complete(PhaseGVN* phase) {
   assert(!is_complete(), "caller responsibility");
-  _is_complete = true;
+  _is_complete = Complete;
 
   // After this node is complete, it contains a bunch of
   // raw-memory initializations.  There is no need for
--- a/hotspot/src/share/vm/opto/memnode.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/memnode.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -942,7 +942,12 @@
 class InitializeNode: public MemBarNode {
   friend class AllocateNode;
 
-  bool _is_complete;
+  enum {
+    Incomplete    = 0,
+    Complete      = 1,
+    WithArraycopy = 2
+  };
+  int _is_complete;
 
 public:
   enum {
@@ -976,10 +981,12 @@
   // An InitializeNode must completed before macro expansion is done.
   // Completion requires that the AllocateNode must be followed by
   // initialization of the new memory to zero, then to any initializers.
-  bool is_complete() { return _is_complete; }
+  bool is_complete() { return _is_complete != Incomplete; }
+  bool is_complete_with_arraycopy() { return (_is_complete & WithArraycopy) != 0; }
 
   // Mark complete.  (Must not yet be complete.)
   void set_complete(PhaseGVN* phase);
+  void set_complete_with_arraycopy() { _is_complete = Complete | WithArraycopy; }
 
 #ifdef ASSERT
   // ensure all non-degenerate stores are ordered and non-overlapping
--- a/hotspot/src/share/vm/opto/node.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/node.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -184,6 +184,8 @@
 // whenever I have phase-specific information.
 
 class Node {
+  friend class VMStructs;
+
   // Lots of restrictions on cloning Nodes
   Node(const Node&);            // not defined; linker error to use these
   Node &operator=(const Node &rhs);
@@ -1286,6 +1288,7 @@
 // Note that the constructor just zeros things, and since I use Arena
 // allocation I do not need a destructor to reclaim storage.
 class Node_Array : public ResourceObj {
+  friend class VMStructs;
 protected:
   Arena *_a;                    // Arena to allocate in
   uint   _max;
@@ -1316,6 +1319,7 @@
 };
 
 class Node_List : public Node_Array {
+  friend class VMStructs;
   uint _cnt;
 public:
   Node_List() : Node_Array(Thread::current()->resource_area()), _cnt(0) {}
@@ -1339,6 +1343,7 @@
 
 //------------------------------Unique_Node_List-------------------------------
 class Unique_Node_List : public Node_List {
+  friend class VMStructs;
   VectorSet _in_worklist;
   uint _clock_index;            // Index in list where to pop from next
 public:
@@ -1389,6 +1394,7 @@
 
 //------------------------------Node_Stack-------------------------------------
 class Node_Stack {
+  friend class VMStructs;
 protected:
   struct INode {
     Node *node; // Processed node
@@ -1461,6 +1467,7 @@
 // Debugging or profiling annotations loosely and sparsely associated
 // with some nodes.  See Compile::node_notes_at for the accessor.
 class Node_Notes VALUE_OBJ_CLASS_SPEC {
+  friend class VMStructs;
   JVMState* _jvms;
 
 public:
--- a/hotspot/src/share/vm/opto/optoreg.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/optoreg.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -172,6 +172,7 @@
 // and converting that will return OptoReg::Bad losing the identity of the OptoReg.
 
 class OptoRegPair {
+  friend class VMStructs;
 private:
   short _second;
   short _first;
--- a/hotspot/src/share/vm/opto/parse.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/parse.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -41,6 +41,8 @@
 
 //------------------------------InlineTree-------------------------------------
 class InlineTree : public ResourceObj {
+  friend class VMStructs;
+
   Compile*    C;                  // cache
   JVMState*   _caller_jvms;       // state of caller
   ciMethod*   _method;            // method being called by the caller_jvms
@@ -54,7 +56,8 @@
   float compute_callee_frequency( int caller_bci ) const;
 
   GrowableArray<InlineTree*> _subtrees;
-  friend class Compile;
+
+  void print_impl(outputStream* stj, int indent) const PRODUCT_RETURN;
 
 protected:
   InlineTree(Compile* C,
@@ -78,6 +81,8 @@
   int         stack_depth()       const { return _caller_jvms ? _caller_jvms->depth() : 0; }
 
 public:
+  static const char* check_can_parse(ciMethod* callee);
+
   static InlineTree* build_inline_tree_root();
   static InlineTree* find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee, bool create_if_not_found = false);
 
@@ -119,6 +124,8 @@
   uint        count_inlines()     const { return _count_inlines; };
 #endif
   GrowableArray<InlineTree*> subtrees() { return _subtrees; }
+
+  void print_value_on(outputStream* st) const PRODUCT_RETURN;
 };
 
 
--- a/hotspot/src/share/vm/opto/parse2.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/parse2.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -752,20 +752,12 @@
 // Handle ret bytecode
 void Parse::do_ret() {
   // Find to whom we return.
-#if 0 // %%%% MAKE THIS WORK
-  Node* con = local();
-  const TypePtr* tp = con->bottom_type()->isa_ptr();
-  assert(tp && tp->singleton(), "");
-  int return_bci = (int) tp->get_con();
-  merge(return_bci);
-#else
   assert(block()->num_successors() == 1, "a ret can only go one place now");
   Block* target = block()->successor_at(0);
   assert(!target->is_ready(), "our arrival must be expected");
   profile_ret(target->flow()->start());
   int pnum = target->next_path_num();
   merge_common(target, pnum);
-#endif
 }
 
 //--------------------------dynamic_branch_prediction--------------------------
--- a/hotspot/src/share/vm/opto/parse3.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/parse3.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -100,11 +100,11 @@
     }
   }
 
-  // Deoptimize on putfield writes to CallSite.target
+  // Deoptimize on putfield writes to call site target field.
   if (!is_get && field->is_call_site_target()) {
     uncommon_trap(Deoptimization::Reason_unhandled,
                   Deoptimization::Action_reinterpret,
-                  NULL, "put to CallSite.target field");
+                  NULL, "put to call site target field");
     return;
   }
 
@@ -147,19 +147,21 @@
 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
   // Does this field have a constant value?  If so, just push the value.
   if (field->is_constant()) {
+    // final field
     if (field->is_static()) {
       // final static field
       if (push_constant(field->constant_value()))
         return;
     }
     else {
-      // final non-static field of a trusted class (classes in
-      // java.lang.invoke and sun.invoke packages and subpackages).
+      // final non-static field
+      // Treat final non-static fields of trusted classes (classes in
+      // java.lang.invoke and sun.invoke packages and subpackages) as
+      // compile time constants.
       if (obj->is_Con()) {
         const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
         ciObject* constant_oop = oop_ptr->const_oop();
         ciConstant constant = field->constant_value_of(constant_oop);
-
         if (push_constant(constant, true))
           return;
       }
--- a/hotspot/src/share/vm/opto/phaseX.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/phaseX.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -864,6 +864,10 @@
   // Pull from worklist; transform node;
   // If node has changed: update edge info and put uses on worklist.
   while( _worklist.size() ) {
+    if (C->check_node_count(NodeLimitFudgeFactor * 2,
+                            "out of nodes optimizing method")) {
+      return;
+    }
     Node *n  = _worklist.pop();
     if (++loop_count >= K * C->unique()) {
       debug_only(n->dump(4);)
--- a/hotspot/src/share/vm/opto/postaloc.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/postaloc.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -72,7 +72,22 @@
   return i == limit;
 }
 
-
+//------------------------------yank-----------------------------------
+// Helper function for yank_if_dead
+int PhaseChaitin::yank( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) {
+  int blk_adjust=0;
+  Block *oldb = _cfg._bbs[old->_idx];
+  oldb->find_remove(old);
+  // Count 1 if deleting an instruction from the current block
+  if( oldb == current_block ) blk_adjust++;
+  _cfg._bbs.map(old->_idx,NULL);
+  OptoReg::Name old_reg = lrgs(n2lidx(old)).reg();
+  if( regnd && (*regnd)[old_reg]==old ) { // Instruction is currently available?
+    value->map(old_reg,NULL);  // Yank from value/regnd maps
+    regnd->map(old_reg,NULL);  // This register's value is now unknown
+  }
+  return blk_adjust;
+}
 
 //------------------------------yank_if_dead-----------------------------------
 // Removed an edge from 'old'.  Yank if dead.  Return adjustment counts to
@@ -80,18 +95,23 @@
 int PhaseChaitin::yank_if_dead( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) {
   int blk_adjust=0;
   while (old->outcnt() == 0 && old != C->top()) {
-    Block *oldb = _cfg._bbs[old->_idx];
-    oldb->find_remove(old);
-    // Count 1 if deleting an instruction from the current block
-    if( oldb == current_block ) blk_adjust++;
-    _cfg._bbs.map(old->_idx,NULL);
-    OptoReg::Name old_reg = lrgs(n2lidx(old)).reg();
-    if( regnd && (*regnd)[old_reg]==old ) { // Instruction is currently available?
-      value->map(old_reg,NULL);  // Yank from value/regnd maps
-      regnd->map(old_reg,NULL);  // This register's value is now unknown
+    blk_adjust += yank(old, current_block, value, regnd);
+
+    Node *tmp = NULL;
+    for (uint i = 1; i < old->req(); i++) {
+      if (old->in(i)->is_MachTemp()) {
+        // handle TEMP inputs
+        Node* machtmp = old->in(i);
+        if (machtmp->outcnt() == 1) {
+          assert(machtmp->unique_out() == old, "sanity");
+          blk_adjust += yank(machtmp, current_block, value, regnd);
+          machtmp->disconnect_inputs(NULL);
+        }
+      } else {
+        assert(tmp == NULL, "can't handle more non MachTemp inputs");
+        tmp = old->in(i);
+      }
     }
-    assert(old->req() <= 2, "can't handle more inputs");
-    Node *tmp = old->req() > 1 ? old->in(1) : NULL;
     old->disconnect_inputs(NULL);
     if( !tmp ) break;
     old = tmp;
--- a/hotspot/src/share/vm/opto/regalloc.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/regalloc.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,7 @@
 //------------------------------PhaseRegAlloc------------------------------------
 // Abstract register allocator
 class PhaseRegAlloc : public Phase {
+  friend class VMStructs;
   static void (*_alloc_statistics[MAX_REG_ALLOCATORS])();
   static int _num_allocators;
 
--- a/hotspot/src/share/vm/opto/runtime.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/runtime.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -102,6 +102,7 @@
 // Compiled code entry points
 address OptoRuntime::_new_instance_Java                           = NULL;
 address OptoRuntime::_new_array_Java                              = NULL;
+address OptoRuntime::_new_array_nozero_Java                       = NULL;
 address OptoRuntime::_multianewarray2_Java                        = NULL;
 address OptoRuntime::_multianewarray3_Java                        = NULL;
 address OptoRuntime::_multianewarray4_Java                        = NULL;
@@ -151,6 +152,7 @@
   // -------------------------------------------------------------------------------------------------------------------------------
   gen(env, _new_instance_Java              , new_instance_Type            , new_instance_C                  ,    0 , true , false, false);
   gen(env, _new_array_Java                 , new_array_Type               , new_array_C                     ,    0 , true , false, false);
+  gen(env, _new_array_nozero_Java          , new_array_Type               , new_array_nozero_C              ,    0 , true , false, false);
   gen(env, _multianewarray2_Java           , multianewarray2_Type         , multianewarray2_C               ,    0 , true , false, false);
   gen(env, _multianewarray3_Java           , multianewarray3_Type         , multianewarray3_C               ,    0 , true , false, false);
   gen(env, _multianewarray4_Java           , multianewarray4_Type         , multianewarray4_C               ,    0 , true , false, false);
@@ -308,6 +310,36 @@
   }
 JRT_END
 
+// array allocation without zeroing
+JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(klassOopDesc* array_type, int len, JavaThread *thread))
+  JRT_BLOCK;
+#ifndef PRODUCT
+  SharedRuntime::_new_array_ctr++;            // new array requires GC
+#endif
+  assert(check_compiled_frame(thread), "incorrect caller");
+
+  // Scavenge and allocate an instance.
+  oop result;
+
+  assert(Klass::cast(array_type)->oop_is_typeArray(), "should be called only for type array");
+  // The oopFactory likes to work with the element type.
+  BasicType elem_type = typeArrayKlass::cast(array_type)->element_type();
+  result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
+
+  // Pass oops back through thread local storage.  Our apparent type to Java
+  // is that we return an oop, but we can block on exit from this routine and
+  // a GC can trash the oop in C's return register.  The generated stub will
+  // fetch the oop from TLS after any possible GC.
+  deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
+  thread->set_vm_result(result);
+  JRT_BLOCK_END;
+
+  if (GraphKit::use_ReduceInitialCardMarks()) {
+    // inform GC that we won't do card marks for initializing writes.
+    new_store_pre_barrier(thread);
+  }
+JRT_END
+
 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
 
 // multianewarray for 2 dimensions
@@ -965,10 +997,13 @@
         force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
 
       if (handler_address == NULL) {
+        Handle original_exception(thread, exception());
         handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true);
         assert (handler_address != NULL, "must have compiled handler");
-        // Update the exception cache only when the unwind was not forced.
-        if (!force_unwind) {
+        // Update the exception cache only when the unwind was not forced
+        // and there didn't happen another exception during the computation of the
+        // compiled exception handler.
+        if (!force_unwind && original_exception() == exception()) {
           nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
         }
       } else {
@@ -978,7 +1013,6 @@
 
     thread->set_exception_pc(pc);
     thread->set_exception_handler_pc(handler_address);
-    thread->set_exception_stack_size(0);
 
     // Check if the exception PC is a MethodHandle call site.
     thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
--- a/hotspot/src/share/vm/opto/runtime.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/runtime.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -114,6 +114,7 @@
   // References to generated stubs
   static address _new_instance_Java;
   static address _new_array_Java;
+  static address _new_array_nozero_Java;
   static address _multianewarray2_Java;
   static address _multianewarray3_Java;
   static address _multianewarray4_Java;
@@ -143,6 +144,7 @@
 
   // Allocate storage for a objArray or typeArray
   static void new_array_C(klassOopDesc* array_klass, int len, JavaThread *thread);
+  static void new_array_nozero_C(klassOopDesc* array_klass, int len, JavaThread *thread);
 
   // Post-slow-path-allocation, pre-initializing-stores step for
   // implementing ReduceInitialCardMarks
@@ -208,6 +210,7 @@
   // access to runtime stubs entry points for java code
   static address new_instance_Java()                     { return _new_instance_Java; }
   static address new_array_Java()                        { return _new_array_Java; }
+  static address new_array_nozero_Java()                 { return _new_array_nozero_Java; }
   static address multianewarray2_Java()                  { return _multianewarray2_Java; }
   static address multianewarray3_Java()                  { return _multianewarray3_Java; }
   static address multianewarray4_Java()                  { return _multianewarray4_Java; }
--- a/hotspot/src/share/vm/opto/split_if.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/split_if.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -500,19 +500,14 @@
   region_cache.lru_insert( new_false, new_false );
   region_cache.lru_insert( new_true , new_true  );
   // Now handle all uses of the splitting block
-  for (DUIterator_Last kmin, k = region->last_outs(kmin); k >= kmin; --k) {
-    Node* phi = region->last_out(k);
-    if( !phi->in(0) ) {         // Dead phi?  Remove it
+  for (DUIterator k = region->outs(); region->has_out(k); k++) {
+    Node* phi = region->out(k);
+    if (!phi->in(0)) {         // Dead phi?  Remove it
       _igvn.remove_dead_node(phi);
-      continue;
-    }
-    assert( phi->in(0) == region, "" );
-    if( phi == region ) {       // Found the self-reference
-      phi->set_req(0, NULL);
-      continue;                 // Break the self-cycle
-    }
-    // Expected common case: Phi hanging off of Region
-    if( phi->is_Phi() ) {
+    } else if (phi == region) { // Found the self-reference
+      continue;                 // No roll-back of DUIterator
+    } else if (phi->is_Phi()) { // Expected common case: Phi hanging off of Region
+      assert(phi->in(0) == region, "Inconsistent graph");
       // Need a per-def cache.  Phi represents a def, so make a cache
       small_cache phi_cache;
 
@@ -524,22 +519,24 @@
         // collection of PHI's merging values from different paths.  The Phis
         // inserted depend only on the location of the USE.  We use a
         // 2-element cache to handle multiple uses from the same block.
-        handle_use( use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true );
+        handle_use(use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true);
       } // End of while phi has uses
-
-      // Because handle_use might relocate region->_out,
-      // we must refresh the iterator.
-      k = region->last_outs(kmin);
-
       // Remove the dead Phi
       _igvn.remove_dead_node( phi );
-
     } else {
+      assert(phi->in(0) == region, "Inconsistent graph");
       // Random memory op guarded by Region.  Compute new DEF for USE.
-      handle_use( phi, region, &region_cache, region_dom, new_false, new_true, old_false, old_true );
+      handle_use(phi, region, &region_cache, region_dom, new_false, new_true, old_false, old_true);
     }
+    // Every path above deletes a use of the region, except for the region
+    // self-cycle (which is needed by handle_use calling find_use_block
+    // calling get_ctrl calling get_ctrl_no_update looking for dead
+    // regions).  So roll back the DUIterator innards.
+    --k;
+  } // End of while merge point has phis
 
-  } // End of while merge point has phis
+  assert(region->outcnt() == 1, "Only self reference should remain"); // Just Self on the Region
+  region->set_req(0, NULL);       // Break the self-cycle
 
   // Any leftover bits in the splitting block must not have depended on local
   // Phi inputs (these have already been split-up).  Hence it's safe to hoist
--- a/hotspot/src/share/vm/opto/type.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/opto/type.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -64,6 +64,8 @@
 // different kind of Type exists.  Types are never modified after creation, so
 // all their interesting fields are constant.
 class Type {
+  friend class VMStructs;
+
 public:
   enum TYPES {
     Bad=0,                      // Type check
--- a/hotspot/src/share/vm/precompiled.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/precompiled.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -206,7 +206,6 @@
 # include "runtime/perfMemory.hpp"
 # include "runtime/prefetch.hpp"
 # include "runtime/reflection.hpp"
-# include "runtime/reflectionCompat.hpp"
 # include "runtime/reflectionUtils.hpp"
 # include "runtime/registerMap.hpp"
 # include "runtime/safepoint.hpp"
--- a/hotspot/src/share/vm/prims/forte.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/forte.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -522,25 +522,6 @@
 extern "C" {
 JNIEXPORT
 void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
-
-// This is if'd out because we no longer use thread suspension.
-// However if someone wanted to backport this to a 5.0 jvm then this
-// code would be important.
-#if 0
-  if (SafepointSynchronize::is_synchronizing()) {
-    // The safepoint mechanism is trying to synchronize all the threads.
-    // Since this can involve thread suspension, it is not safe for us
-    // to be here. We can reduce the deadlock risk window by quickly
-    // returning to the SIGPROF handler. However, it is still possible
-    // for VMThread to catch us here or in the SIGPROF handler. If we
-    // are suspended while holding a resource and another thread blocks
-    // on that resource in the SIGPROF handler, then we will have a
-    // three-thread deadlock (VMThread, this thread, the other thread).
-    trace->num_frames = ticks_safepoint; // -10
-    return;
-  }
-#endif
-
   JavaThread* thread;
 
   if (trace->env_id == NULL ||
@@ -640,6 +621,11 @@
 // Method to let libcollector know about a dynamically loaded function.
 // Because it is weakly bound, the calls become NOP's when the library
 // isn't present.
+#ifdef __APPLE__
+// XXXDARWIN: Link errors occur even when __attribute__((weak_import))
+// is added
+#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) (0)
+#else
 void    collector_func_load(char* name,
                             void* null_argument_1,
                             void* null_argument_2,
@@ -650,6 +636,7 @@
 #pragma weak collector_func_load
 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
         ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 )
+#endif // __APPLE__
 #endif // !_WINDOWS
 
 } // end extern "C"
--- a/hotspot/src/share/vm/prims/jni.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jni.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -82,6 +82,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 static jint CurrentVersion = JNI_VERSION_1_6;
 
@@ -106,6 +110,7 @@
 //   return_value = 5;
 //   return return_value;
 // JNI_END
+#ifndef USDT2
 #define DT_RETURN_MARK_DECL(name, type)                                    \
   HS_DTRACE_PROBE_DECL1(hotspot_jni, name##__return, type);                \
   DTRACE_ONLY(                                                             \
@@ -130,6 +135,30 @@
     }                                                                      \
   )
 
+#else /* USDT2 */
+
+#define DT_RETURN_MARK_DECL(name, type, probe)                             \
+  DTRACE_ONLY(                                                             \
+    class DTraceReturnProbeMark_##name {                                   \
+     public:                                                               \
+      const type& _ret_ref;                                                \
+      DTraceReturnProbeMark_##name(const type& v) : _ret_ref(v) {}         \
+      ~DTraceReturnProbeMark_##name() {                                    \
+        probe;                                                             \
+      }                                                                    \
+    }                                                                      \
+  )
+// Void functions are simpler since there's no return value
+#define DT_VOID_RETURN_MARK_DECL(name, probe)                              \
+  DTRACE_ONLY(                                                             \
+    class DTraceReturnProbeMark_##name {                                   \
+     public:                                                               \
+      ~DTraceReturnProbeMark_##name() {                                    \
+        probe;                                                             \
+      }                                                                    \
+    }                                                                      \
+  )
+#endif /* USDT2 */
 
 // Place these macros in the function to mark the return.  Non-void
 // functions need the type and address of the return value.
@@ -158,9 +187,15 @@
 
 // Choose DT_RETURN_MARK macros  based on the type: float/double -> void
 // (dtrace doesn't do FP yet)
+#ifndef USDT2
 #define DT_RETURN_MARK_DECL_FOR(TypeName, name, type) \
   FP_SELECT(TypeName, \
     DT_RETURN_MARK_DECL(name, type), DT_VOID_RETURN_MARK_DECL(name) )
+#else /* USDT2 */
+#define DT_RETURN_MARK_DECL_FOR(TypeName, name, type, probe)    \
+  FP_SELECT(TypeName, \
+    DT_RETURN_MARK_DECL(name, type, probe), DT_VOID_RETURN_MARK_DECL(name, probe) )
+#endif /* USDT2 */
 #define DT_RETURN_MARK_FOR(TypeName, name, type, ref) \
   FP_SELECT(TypeName, \
     DT_RETURN_MARK(name, type, ref), DT_VOID_RETURN_MARK(name) )
@@ -319,14 +354,24 @@
 
 // Implementation of JNI entries
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(DefineClass, jclass);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(DefineClass, jclass
+                    , HOTSPOT_JNI_DEFINECLASS_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderRef,
                                   const jbyte *buf, jsize bufLen))
   JNIWrapper("DefineClass");
 
+#ifndef USDT2
   DTRACE_PROBE5(hotspot_jni, DefineClass__entry,
     env, name, loaderRef, buf, bufLen);
+#else /* USDT2 */
+  HOTSPOT_JNI_DEFINECLASS_ENTRY(
+    env, (char*) name, loaderRef, (char*) buf, bufLen);
+#endif /* USDT2 */
   jclass cls = NULL;
   DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls);
 
@@ -372,11 +417,21 @@
 
 static bool first_time_FindClass = true;
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(FindClass, jclass);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(FindClass, jclass
+                    , HOTSPOT_JNI_FINDCLASS_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name))
   JNIWrapper("FindClass");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, FindClass__entry, env, name);
+#else /* USDT2 */
+  HOTSPOT_JNI_FINDCLASS_ENTRY(
+                              env, (char *)name);
+#endif /* USDT2 */
 
   jclass result = NULL;
   DT_RETURN_MARK(FindClass, jclass, (const jclass&)result);
@@ -440,11 +495,21 @@
   return result;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID
+                    , HOTSPOT_JNI_FROMREFLECTEDMETHOD_RETURN((uintptr_t)_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method))
   JNIWrapper("FromReflectedMethod");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, FromReflectedMethod__entry, env, method);
+#else /* USDT2 */
+  HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY(
+                                        env, method);
+#endif /* USDT2 */
   jmethodID ret = NULL;
   DT_RETURN_MARK(FromReflectedMethod, jmethodID, (const jmethodID&)ret);
 
@@ -471,11 +536,21 @@
   return ret;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(FromReflectedField, jfieldID);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(FromReflectedField, jfieldID
+                    , HOTSPOT_JNI_FROMREFLECTEDFIELD_RETURN((uintptr_t)_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field))
   JNIWrapper("FromReflectedField");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, FromReflectedField__entry, env, field);
+#else /* USDT2 */
+  HOTSPOT_JNI_FROMREFLECTEDFIELD_ENTRY(
+                                       env, field);
+#endif /* USDT2 */
   jfieldID ret = NULL;
   DT_RETURN_MARK(FromReflectedField, jfieldID, (const jfieldID&)ret);
 
@@ -492,7 +567,7 @@
 
   // First check if this is a static field
   if (modifiers & JVM_ACC_STATIC) {
-    intptr_t offset = instanceKlass::cast(k1())->offset_from_fields( slot );
+    intptr_t offset = instanceKlass::cast(k1())->field_offset( slot );
     JNIid* id = instanceKlass::cast(k1())->jni_id_for(offset);
     assert(id != NULL, "corrupt Field object");
     debug_only(id->set_is_static_field_id();)
@@ -504,17 +579,27 @@
   // The slot is the index of the field description in the field-array
   // The jfieldID is the offset of the field within the object
   // It may also have hash bits for k, if VerifyJNIFields is turned on.
-  intptr_t offset = instanceKlass::cast(k1())->offset_from_fields( slot );
+  intptr_t offset = instanceKlass::cast(k1())->field_offset( slot );
   assert(instanceKlass::cast(k1())->contains_field_offset(offset), "stay within object");
   ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset);
   return ret;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(ToReflectedMethod, jobject);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(ToReflectedMethod, jobject
+                    , HOTSPOT_JNI_TOREFLECTEDMETHOD_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID method_id, jboolean isStatic))
   JNIWrapper("ToReflectedMethod");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, ToReflectedMethod__entry, env, cls, method_id, isStatic);
+#else /* USDT2 */
+  HOTSPOT_JNI_TOREFLECTEDMETHOD_ENTRY(
+                                      env, cls, (uintptr_t) method_id, isStatic);
+#endif /* USDT2 */
   jobject ret = NULL;
   DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret);
 
@@ -530,11 +615,21 @@
   return ret;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(GetSuperclass, jclass);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(GetSuperclass, jclass
+                    , HOTSPOT_JNI_GETSUPERCLASS_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub))
   JNIWrapper("GetSuperclass");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetSuperclass__entry, env, sub);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSUPERCLASS_ENTRY(
+                                  env, sub);
+#endif /* USDT2 */
   jclass obj = NULL;
   DT_RETURN_MARK(GetSuperclass, jclass, (const jclass&)obj);
 
@@ -563,13 +658,23 @@
 
 JNI_QUICK_ENTRY(jboolean, jni_IsAssignableFrom(JNIEnv *env, jclass sub, jclass super))
   JNIWrapper("IsSubclassOf");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, IsAssignableFrom__entry, env, sub, super);
+#else /* USDT2 */
+  HOTSPOT_JNI_ISASSIGNABLEFROM_ENTRY(
+                                     env, sub, super);
+#endif /* USDT2 */
   oop sub_mirror   = JNIHandles::resolve_non_null(sub);
   oop super_mirror = JNIHandles::resolve_non_null(super);
   if (java_lang_Class::is_primitive(sub_mirror) ||
       java_lang_Class::is_primitive(super_mirror)) {
     jboolean ret = (sub_mirror == super_mirror);
+#ifndef USDT2
     DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret);
+#else /* USDT2 */
+    HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN(
+                                        ret);
+#endif /* USDT2 */
     return ret;
   }
   klassOop sub_klass   = java_lang_Class::as_klassOop(sub_mirror);
@@ -577,15 +682,30 @@
   assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom");
   jboolean ret = Klass::cast(sub_klass)->is_subtype_of(super_klass) ?
                    JNI_TRUE : JNI_FALSE;
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN(
+                                      ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(Throw, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(Throw, jint
+                    , HOTSPOT_JNI_THROW_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jint, jni_Throw(JNIEnv *env, jthrowable obj))
   JNIWrapper("Throw");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, Throw__entry, env, obj);
+#else /* USDT2 */
+  HOTSPOT_JNI_THROW_ENTRY(
+ env, obj);
+#endif /* USDT2 */
   jint ret = JNI_OK;
   DT_RETURN_MARK(Throw, jint, (const jint&)ret);
 
@@ -593,11 +713,21 @@
   ShouldNotReachHere();
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(ThrowNew, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(ThrowNew, jint
+                    , HOTSPOT_JNI_THROWNEW_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jint, jni_ThrowNew(JNIEnv *env, jclass clazz, const char *message))
   JNIWrapper("ThrowNew");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, ThrowNew__entry, env, clazz, message);
+#else /* USDT2 */
+  HOTSPOT_JNI_THROWNEW_ENTRY(
+                             env, clazz, (char *) message);
+#endif /* USDT2 */
   jint ret = JNI_OK;
   DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret);
 
@@ -626,18 +756,33 @@
 
 JNI_ENTRY_NO_PRESERVE(jthrowable, jni_ExceptionOccurred(JNIEnv *env))
   JNIWrapper("ExceptionOccurred");
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__entry, env);
+#else /* USDT2 */
+  HOTSPOT_JNI_EXCEPTIONOCCURRED_ENTRY(
+                                      env);
+#endif /* USDT2 */
   jni_check_async_exceptions(thread);
   oop exception = thread->pending_exception();
   jthrowable ret = (jthrowable) JNIHandles::make_local(env, exception);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_EXCEPTIONOCCURRED_RETURN(
+                                       ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 
 JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env))
   JNIWrapper("ExceptionDescribe");
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, ExceptionDescribe__entry, env);
+#else /* USDT2 */
+  HOTSPOT_JNI_EXCEPTIONDESCRIBE_ENTRY(
+                                      env);
+#endif /* USDT2 */
   if (thread->has_pending_exception()) {
     Handle ex(thread, thread->pending_exception());
     thread->clear_pending_exception();
@@ -673,13 +818,23 @@
       }
     }
   }
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, ExceptionDescribe__return);
+#else /* USDT2 */
+  HOTSPOT_JNI_EXCEPTIONDESCRIBE_RETURN(
+                                       );
+#endif /* USDT2 */
 JNI_END
 
 
 JNI_QUICK_ENTRY(void, jni_ExceptionClear(JNIEnv *env))
   JNIWrapper("ExceptionClear");
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, ExceptionClear__entry, env);
+#else /* USDT2 */
+  HOTSPOT_JNI_EXCEPTIONCLEAR_ENTRY(
+                                   env);
+#endif /* USDT2 */
 
   // The jni code might be using this API to clear java thrown exception.
   // So just mark jvmti thread exception state as exception caught.
@@ -688,13 +843,23 @@
     state->set_exception_caught();
   }
   thread->clear_pending_exception();
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, ExceptionClear__return);
+#else /* USDT2 */
+  HOTSPOT_JNI_EXCEPTIONCLEAR_RETURN(
+                                    );
+#endif /* USDT2 */
 JNI_END
 
 
 JNI_ENTRY(void, jni_FatalError(JNIEnv *env, const char *msg))
   JNIWrapper("FatalError");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, FatalError__entry, env, msg);
+#else /* USDT2 */
+  HOTSPOT_JNI_FATALERROR_ENTRY(
+                               env, (char *) msg);
+#endif /* USDT2 */
   tty->print_cr("FATAL ERROR in native method: %s", msg);
   thread->print_stack();
   os::abort(); // Dump core and abort
@@ -703,10 +868,20 @@
 
 JNI_ENTRY(jint, jni_PushLocalFrame(JNIEnv *env, jint capacity))
   JNIWrapper("PushLocalFrame");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, PushLocalFrame__entry, env, capacity);
+#else /* USDT2 */
+  HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY(
+                                   env, capacity);
+#endif /* USDT2 */
   //%note jni_11
   if (capacity < 0 && capacity > MAX_REASONABLE_LOCAL_CAPACITY) {
+#ifndef USDT2
     DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR);
+#else /* USDT2 */
+    HOTSPOT_JNI_PUSHLOCALFRAME_RETURN(
+                                      (uint32_t)JNI_ERR);
+#endif /* USDT2 */
     return JNI_ERR;
   }
   JNIHandleBlock* old_handles = thread->active_handles();
@@ -715,14 +890,24 @@
   new_handles->set_pop_frame_link(old_handles);
   thread->set_active_handles(new_handles);
   jint ret = JNI_OK;
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_PUSHLOCALFRAME_RETURN(
+                                    ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 
 JNI_ENTRY(jobject, jni_PopLocalFrame(JNIEnv *env, jobject result))
   JNIWrapper("PopLocalFrame");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, PopLocalFrame__entry, env, result);
+#else /* USDT2 */
+  HOTSPOT_JNI_POPLOCALFRAME_ENTRY(
+                                  env, result);
+#endif /* USDT2 */
   //%note jni_11
   Handle result_handle(thread, JNIHandles::resolve(result));
   JNIHandleBlock* old_handles = thread->active_handles();
@@ -737,71 +922,141 @@
     JNIHandleBlock::release_block(old_handles, thread); // may block
     result = JNIHandles::make_local(thread, result_handle());
   }
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, PopLocalFrame__return, result);
+#else /* USDT2 */
+  HOTSPOT_JNI_POPLOCALFRAME_RETURN(
+                                   result);
+#endif /* USDT2 */
   return result;
 JNI_END
 
 
 JNI_ENTRY(jobject, jni_NewGlobalRef(JNIEnv *env, jobject ref))
   JNIWrapper("NewGlobalRef");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, NewGlobalRef__entry, env, ref);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWGLOBALREF_ENTRY(
+                                 env, ref);
+#endif /* USDT2 */
   Handle ref_handle(thread, JNIHandles::resolve(ref));
   jobject ret = JNIHandles::make_global(ref_handle);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, NewGlobalRef__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWGLOBALREF_RETURN(
+                                  ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 // Must be JNI_ENTRY (with HandleMark)
 JNI_ENTRY_NO_PRESERVE(void, jni_DeleteGlobalRef(JNIEnv *env, jobject ref))
   JNIWrapper("DeleteGlobalRef");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, DeleteGlobalRef__entry, env, ref);
+#else /* USDT2 */
+  HOTSPOT_JNI_DELETEGLOBALREF_ENTRY(
+                                    env, ref);
+#endif /* USDT2 */
   JNIHandles::destroy_global(ref);
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, DeleteGlobalRef__return);
+#else /* USDT2 */
+  HOTSPOT_JNI_DELETEGLOBALREF_RETURN(
+                                     );
+#endif /* USDT2 */
 JNI_END
 
 JNI_QUICK_ENTRY(void, jni_DeleteLocalRef(JNIEnv *env, jobject obj))
   JNIWrapper("DeleteLocalRef");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, DeleteLocalRef__entry, env, obj);
+#else /* USDT2 */
+  HOTSPOT_JNI_DELETELOCALREF_ENTRY(
+                                   env, obj);
+#endif /* USDT2 */
   JNIHandles::destroy_local(obj);
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, DeleteLocalRef__return);
+#else /* USDT2 */
+  HOTSPOT_JNI_DELETELOCALREF_RETURN(
+                                    );
+#endif /* USDT2 */
 JNI_END
 
 JNI_QUICK_ENTRY(jboolean, jni_IsSameObject(JNIEnv *env, jobject r1, jobject r2))
   JNIWrapper("IsSameObject");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, IsSameObject__entry, env, r1, r2);
+#else /* USDT2 */
+  HOTSPOT_JNI_ISSAMEOBJECT_ENTRY(
+                                 env, r1, r2);
+#endif /* USDT2 */
   oop a = JNIHandles::resolve(r1);
   oop b = JNIHandles::resolve(r2);
   jboolean ret = (a == b) ? JNI_TRUE : JNI_FALSE;
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, IsSameObject__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_ISSAMEOBJECT_RETURN(
+                                  ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 
 JNI_ENTRY(jobject, jni_NewLocalRef(JNIEnv *env, jobject ref))
   JNIWrapper("NewLocalRef");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, NewLocalRef__entry, env, ref);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWLOCALREF_ENTRY(
+                                env, ref);
+#endif /* USDT2 */
   jobject ret = JNIHandles::make_local(env, JNIHandles::resolve(ref));
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, NewLocalRef__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWLOCALREF_RETURN(
+                                 ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 JNI_LEAF(jint, jni_EnsureLocalCapacity(JNIEnv *env, jint capacity))
   JNIWrapper("EnsureLocalCapacity");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, EnsureLocalCapacity__entry, env, capacity);
+#else /* USDT2 */
+  HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY(
+                                        env, capacity);
+#endif /* USDT2 */
   jint ret;
   if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) {
     ret = JNI_OK;
   } else {
     ret = JNI_ERR;
   }
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, EnsureLocalCapacity__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_ENSURELOCALCAPACITY_RETURN(
+                                         ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 // Return the Handle Type
 JNI_LEAF(jobjectRefType, jni_GetObjectRefType(JNIEnv *env, jobject obj))
   JNIWrapper("GetObjectRefType");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetObjectRefType__entry, env, obj);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETOBJECTREFTYPE_ENTRY(
+                                     env, obj);
+#endif /* USDT2 */
   jobjectRefType ret;
   if (JNIHandles::is_local_handle(thread, obj) ||
       JNIHandles::is_frame_handle(thread, obj))
@@ -812,7 +1067,12 @@
     ret = JNIWeakGlobalRefType;
   else
     ret = JNIInvalidRefType;
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetObjectRefType__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETOBJECTREFTYPE_RETURN(
+                                      (void *) ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
@@ -1163,12 +1423,22 @@
   return ih;
 }
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(AllocObject, jobject);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(AllocObject, jobject
+                    , HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz))
   JNIWrapper("AllocObject");
 
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, AllocObject__entry, env, clazz);
+#else /* USDT2 */
+  HOTSPOT_JNI_ALLOCOBJECT_ENTRY(
+                                env, clazz);
+#endif /* USDT2 */
   jobject ret = NULL;
   DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret);
 
@@ -1177,11 +1447,21 @@
   return ret;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(NewObjectA, jobject);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(NewObjectA, jobject
+                    , HOTSPOT_JNI_NEWOBJECTA_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args))
   JNIWrapper("NewObjectA");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, NewObjectA__entry, env, clazz, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWOBJECTA_ENTRY(
+                               env, clazz, (uintptr_t) methodID);
+#endif /* USDT2 */
   jobject obj = NULL;
   DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj);
 
@@ -1193,11 +1473,21 @@
   return obj;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(NewObjectV, jobject);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(NewObjectV, jobject
+                    , HOTSPOT_JNI_NEWOBJECTV_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args))
   JNIWrapper("NewObjectV");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, NewObjectV__entry, env, clazz, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWOBJECTV_ENTRY(
+                               env, clazz, (uintptr_t) methodID);
+#endif /* USDT2 */
   jobject obj = NULL;
   DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj);
 
@@ -1209,11 +1499,21 @@
   return obj;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(NewObject, jobject);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(NewObject, jobject
+                    , HOTSPOT_JNI_NEWOBJECT_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...))
   JNIWrapper("NewObject");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, NewObject__entry, env, clazz, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWOBJECT_ENTRY(
+                              env, clazz, (uintptr_t) methodID);
+#endif /* USDT2 */
   jobject obj = NULL;
   DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj);
 
@@ -1231,17 +1531,32 @@
 
 JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj))
   JNIWrapper("GetObjectClass");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetObjectClass__entry, env, obj);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETOBJECTCLASS_ENTRY(
+                                   env, obj);
+#endif /* USDT2 */
   klassOop k = JNIHandles::resolve_non_null(obj)->klass();
   jclass ret =
     (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETOBJECTCLASS_RETURN(
+                                    ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 JNI_QUICK_ENTRY(jboolean, jni_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz))
   JNIWrapper("IsInstanceOf");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, IsInstanceOf__entry, env, obj, clazz);
+#else /* USDT2 */
+  HOTSPOT_JNI_ISINSTANCEOF_ENTRY(
+                                 env, obj, clazz);
+#endif /* USDT2 */
   jboolean ret = JNI_TRUE;
   if (obj != NULL) {
     ret = JNI_FALSE;
@@ -1251,7 +1566,12 @@
       ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE;
     }
   }
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, IsInstanceOf__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_ISINSTANCEOF_RETURN(
+                                  ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
@@ -1313,9 +1633,19 @@
 JNI_ENTRY(jmethodID, jni_GetMethodID(JNIEnv *env, jclass clazz,
           const char *name, const char *sig))
   JNIWrapper("GetMethodID");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, GetMethodID__entry, env, clazz, name, sig);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETMETHODID_ENTRY(
+                                env, clazz, (char *) name, (char *) sig);
+#endif /* USDT2 */
   jmethodID ret = get_method_id(env, clazz, name, sig, false, thread);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetMethodID__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETMETHODID_RETURN(
+                                 (uintptr_t) ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
@@ -1323,9 +1653,19 @@
 JNI_ENTRY(jmethodID, jni_GetStaticMethodID(JNIEnv *env, jclass clazz,
           const char *name, const char *sig))
   JNIWrapper("GetStaticMethodID");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, GetStaticMethodID__entry, env, clazz, name, sig);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTATICMETHODID_ENTRY(
+                                      env, (char *) clazz, (char *) name, (char *)sig);
+#endif /* USDT2 */
   jmethodID ret = get_method_id(env, clazz, name, sig, true, thread);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetStaticMethodID__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTATICMETHODID_RETURN(
+                                       (uintptr_t) ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
@@ -1335,7 +1675,7 @@
 // Calling Methods
 //
 
-
+#ifndef USDT2
 #define DEFINE_CALLMETHOD(ResultType, Result, Tag) \
 \
   DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType);\
@@ -1346,7 +1686,7 @@
           jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \
   JNIWrapper("Call" XSTR(Result) "Method"); \
 \
-  DTRACE_PROBE3(hotspot_jni, Call##Result##Method__entry, env, obj, methodID);\
+  DTRACE_PROBE3(hotspot_jni, Call##Result##Method__entry, env, obj, methodID); \
   ResultType ret = 0;\
   DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \
                      (const ResultType&)ret);\
@@ -1366,7 +1706,7 @@
           jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \
   JNIWrapper("Call" XSTR(Result) "MethodV"); \
 \
-  DTRACE_PROBE3(hotspot_jni, Call##Result##MethodV__entry, env, obj, methodID);\
+  DTRACE_PROBE3(hotspot_jni, Call##Result##MethodV__entry, env, obj, methodID); \
   ResultType ret = 0;\
   DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \
                      (const ResultType&)ret);\
@@ -1382,7 +1722,7 @@
 JNI_ENTRY(ResultType, \
           jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \
   JNIWrapper("Call" XSTR(Result) "MethodA"); \
-  DTRACE_PROBE3(hotspot_jni, Call##Result##MethodA__entry, env, obj, methodID);\
+  DTRACE_PROBE3(hotspot_jni, Call##Result##MethodA__entry, env, obj, methodID); \
   ResultType ret = 0;\
   DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \
                      (const ResultType&)ret);\
@@ -1410,9 +1750,183 @@
 DT_VOID_RETURN_MARK_DECL(CallVoidMethodV);
 DT_VOID_RETURN_MARK_DECL(CallVoidMethodA);
 
+#else /* USDT2 */
+
+#define DEFINE_CALLMETHOD(ResultType, Result, Tag \
+                          , EntryProbe, ReturnProbe)    \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType \
+                          , ReturnProbe);                          \
+\
+JNI_ENTRY(ResultType, \
+          jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \
+  JNIWrapper("Call" XSTR(Result) "Method"); \
+\
+  EntryProbe; \
+  ResultType ret = 0;\
+  DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \
+                     (const ResultType&)ret);\
+\
+  va_list args; \
+  va_start(args, methodID); \
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherVaArg ap(methodID, args); \
+  jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \
+  va_end(args); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLMETHOD(jboolean, Boolean, T_BOOLEAN
+                  , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHOD(jbyte,    Byte,    T_BYTE
+                  , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHOD(jchar,    Char,    T_CHAR
+                  , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHOD(jshort,   Short,   T_SHORT
+                  , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref))
+
+DEFINE_CALLMETHOD(jobject,  Object,  T_OBJECT
+                  , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHOD(jint,     Int,     T_INT,
+                  HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHOD(jlong,    Long,    T_LONG
+                  , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref))
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_CALLMETHOD(jfloat,   Float,   T_FLOAT
+                  , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLFLOATMETHOD_RETURN())
+DEFINE_CALLMETHOD(jdouble,  Double,  T_DOUBLE
+                  , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN())
+
+#define DEFINE_CALLMETHODV(ResultType, Result, Tag \
+                          , EntryProbe, ReturnProbe)    \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodV, ResultType \
+                          , ReturnProbe);                          \
+\
+JNI_ENTRY(ResultType, \
+          jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \
+  JNIWrapper("Call" XSTR(Result) "MethodV"); \
+\
+  EntryProbe;\
+  ResultType ret = 0;\
+  DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \
+                     (const ResultType&)ret);\
+\
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherVaArg ap(methodID, args); \
+  jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLMETHODV(jboolean, Boolean, T_BOOLEAN
+                  , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODV(jbyte,    Byte,    T_BYTE
+                  , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODV(jchar,    Char,    T_CHAR
+                  , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODV(jshort,   Short,   T_SHORT
+                  , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref))
+
+DEFINE_CALLMETHODV(jobject,  Object,  T_OBJECT
+                  , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODV(jint,     Int,     T_INT,
+                  HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODV(jlong,    Long,    T_LONG
+                  , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref))
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_CALLMETHODV(jfloat,   Float,   T_FLOAT
+                  , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLFLOATMETHOD_RETURN())
+DEFINE_CALLMETHODV(jdouble,  Double,  T_DOUBLE
+                  , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN())
+
+#define DEFINE_CALLMETHODA(ResultType, Result, Tag \
+                          , EntryProbe, ReturnProbe)    \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodA, ResultType \
+                          , ReturnProbe);                          \
+\
+JNI_ENTRY(ResultType, \
+          jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \
+  JNIWrapper("Call" XSTR(Result) "MethodA"); \
+  EntryProbe; \
+  ResultType ret = 0;\
+  DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \
+                     (const ResultType&)ret);\
+\
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherArray ap(methodID, args); \
+  jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLMETHODA(jboolean, Boolean, T_BOOLEAN
+                  , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODA(jbyte,    Byte,    T_BYTE
+                  , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODA(jchar,    Char,    T_CHAR
+                  , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODA(jshort,   Short,   T_SHORT
+                  , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref))
+
+DEFINE_CALLMETHODA(jobject,  Object,  T_OBJECT
+                  , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODA(jint,     Int,     T_INT,
+                  HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref))
+DEFINE_CALLMETHODA(jlong,    Long,    T_LONG
+                  , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref))
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_CALLMETHODA(jfloat,   Float,   T_FLOAT
+                  , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLFLOATMETHOD_RETURN())
+DEFINE_CALLMETHODA(jdouble,  Double,  T_DOUBLE
+                  , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID),
+                  HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN())
+
+DT_VOID_RETURN_MARK_DECL(CallVoidMethod, HOTSPOT_JNI_CALLVOIDMETHOD_RETURN());
+DT_VOID_RETURN_MARK_DECL(CallVoidMethodV, HOTSPOT_JNI_CALLVOIDMETHODV_RETURN());
+DT_VOID_RETURN_MARK_DECL(CallVoidMethodA, HOTSPOT_JNI_CALLVOIDMETHODA_RETURN());
+
+#endif /* USDT2 */
+
 JNI_ENTRY(void, jni_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...))
   JNIWrapper("CallVoidMethod");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, CallVoidMethod__entry, env, obj, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLVOIDMETHOD_ENTRY(
+                                   env, obj, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallVoidMethod);
 
   va_list args;
@@ -1426,7 +1940,12 @@
 
 JNI_ENTRY(void, jni_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args))
   JNIWrapper("CallVoidMethodV");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, CallVoidMethodV__entry, env, obj, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLVOIDMETHODV_ENTRY(
+                                    env, obj, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallVoidMethodV);
 
   JavaValue jvalue(T_VOID);
@@ -1437,7 +1956,12 @@
 
 JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args))
   JNIWrapper("CallVoidMethodA");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, CallVoidMethodA__entry, env, obj, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLVOIDMETHODA_ENTRY(
+                                    env, obj, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallVoidMethodA);
 
   JavaValue jvalue(T_VOID);
@@ -1446,6 +1970,7 @@
 JNI_END
 
 
+#ifndef USDT2
 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \
 \
   DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType);\
@@ -1518,11 +2043,188 @@
 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV);
 DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA);
 
+#else /* USDT2 */
+
+#define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag \
+                                    , EntryProbe, ReturnProbe)      \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType \
+                          , ReturnProbe);\
+\
+JNI_ENTRY(ResultType, \
+          jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \
+  JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \
+\
+  EntryProbe;\
+  ResultType ret;\
+  DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##Method, ResultType, \
+                     (const ResultType&)ret);\
+\
+  va_list args; \
+  va_start(args, methodID); \
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherVaArg ap(methodID, args); \
+  jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \
+  va_end(args); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLNONVIRTUALMETHOD(jboolean, Boolean, T_BOOLEAN
+                            , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHOD(jbyte,    Byte,    T_BYTE
+                            , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHOD(jchar,    Char,    T_CHAR
+                            , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHOD(jshort,   Short,   T_SHORT
+                            , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_RETURN(_ret_ref))
+
+DEFINE_CALLNONVIRTUALMETHOD(jobject,  Object,  T_OBJECT
+                            , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHOD(jint,     Int,     T_INT
+                            , HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHOD(jlong,    Long,    T_LONG
+                            , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+// Float and double probes don't return value because dtrace doesn't currently support it
+                            HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHOD(jfloat,   Float,   T_FLOAT
+                            , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_RETURN())
+DEFINE_CALLNONVIRTUALMETHOD(jdouble,  Double,  T_DOUBLE
+                            , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_RETURN())
+
+#define DEFINE_CALLNONVIRTUALMETHODV(ResultType, Result, Tag \
+                                    , EntryProbe, ReturnProbe)      \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType \
+                          , ReturnProbe);\
+\
+JNI_ENTRY(ResultType, \
+          jni_CallNonvirtual##Result##MethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) \
+  JNIWrapper("CallNonvitual" XSTR(Result) "MethodV"); \
+\
+  EntryProbe;\
+  ResultType ret;\
+  DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \
+                     (const ResultType&)ret);\
+\
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherVaArg ap(methodID, args); \
+  jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLNONVIRTUALMETHODV(jboolean, Boolean, T_BOOLEAN
+                            , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODV(jbyte,    Byte,    T_BYTE
+                            , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODV(jchar,    Char,    T_CHAR
+                            , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODV(jshort,   Short,   T_SHORT
+                            , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_RETURN(_ret_ref))
+
+DEFINE_CALLNONVIRTUALMETHODV(jobject,  Object,  T_OBJECT
+                            , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODV(jint,     Int,     T_INT
+                            , HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODV(jlong,    Long,    T_LONG
+                            , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+// Float and double probes don't return value because dtrace doesn't currently support it
+                            HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODV(jfloat,   Float,   T_FLOAT
+                            , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_RETURN())
+DEFINE_CALLNONVIRTUALMETHODV(jdouble,  Double,  T_DOUBLE
+                            , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_RETURN())
+
+#define DEFINE_CALLNONVIRTUALMETHODA(ResultType, Result, Tag \
+                                    , EntryProbe, ReturnProbe)      \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType \
+                          , ReturnProbe);\
+\
+JNI_ENTRY(ResultType, \
+          jni_CallNonvirtual##Result##MethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) \
+  JNIWrapper("CallNonvitual" XSTR(Result) "MethodA"); \
+\
+  EntryProbe;\
+  ResultType ret;\
+  DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \
+                     (const ResultType&)ret);\
+\
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherArray ap(methodID, args); \
+  jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLNONVIRTUALMETHODA(jboolean, Boolean, T_BOOLEAN
+                            , HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODA(jbyte,    Byte,    T_BYTE
+                            , HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODA(jchar,    Char,    T_CHAR
+                            , HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODA(jshort,   Short,   T_SHORT
+                            , HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_RETURN(_ret_ref))
+
+DEFINE_CALLNONVIRTUALMETHODA(jobject,  Object,  T_OBJECT
+                            , HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODA(jint,     Int,     T_INT
+                            , HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODA(jlong,    Long,    T_LONG
+                            , HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+// Float and double probes don't return value because dtrace doesn't currently support it
+                            HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_RETURN(_ret_ref))
+DEFINE_CALLNONVIRTUALMETHODA(jfloat,   Float,   T_FLOAT
+                            , HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_RETURN())
+DEFINE_CALLNONVIRTUALMETHODA(jdouble,  Double,  T_DOUBLE
+                            , HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_ENTRY(env, obj, cls, (uintptr_t)methodID),
+                            HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_RETURN())
+
+DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod
+                         , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_RETURN());
+DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV
+                         , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_RETURN());
+DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA
+                         , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_RETURN());
+#endif /* USDT2 */
+
 JNI_ENTRY(void, jni_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...))
   JNIWrapper("CallNonvirtualVoidMethod");
 
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethod__entry,
                env, obj, cls, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_ENTRY(
+               env, obj, cls, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallNonvirtualVoidMethod);
 
   va_list args;
@@ -1537,8 +2239,13 @@
 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args))
   JNIWrapper("CallNonvirtualVoidMethodV");
 
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodV__entry,
                env, obj, cls, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_ENTRY(
+               env, obj, cls, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV);
 
   JavaValue jvalue(T_VOID);
@@ -1549,8 +2256,13 @@
 
 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args))
   JNIWrapper("CallNonvirtualVoidMethodA");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodA__entry,
                 env, obj, cls, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_ENTRY(
+                env, obj, cls, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA);
   JavaValue jvalue(T_VOID);
   JNI_ArgumentPusherArray ap(methodID, args);
@@ -1558,6 +2270,7 @@
 JNI_END
 
 
+#ifndef USDT2
 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag) \
 \
   DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType);\
@@ -1630,9 +2343,190 @@
 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV);
 DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA);
 
+#else /* USDT2 */
+
+#define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag \
+                                , EntryProbe, ResultProbe) \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType \
+                          , ResultProbe);                               \
+\
+JNI_ENTRY(ResultType, \
+          jni_CallStatic##Result##Method(JNIEnv *env, jclass cls, jmethodID methodID, ...)) \
+  JNIWrapper("CallStatic" XSTR(Result) "Method"); \
+\
+  EntryProbe; \
+  ResultType ret = 0;\
+  DT_RETURN_MARK_FOR(Result, CallStatic##Result##Method, ResultType, \
+                     (const ResultType&)ret);\
+\
+  va_list args; \
+  va_start(args, methodID); \
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherVaArg ap(methodID, args); \
+  jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \
+  va_end(args); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLSTATICMETHOD(jboolean, Boolean, T_BOOLEAN
+                        , HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHOD(jbyte,    Byte,    T_BYTE
+                        , HOTSPOT_JNI_CALLSTATICBYTEMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICBYTEMETHOD_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHOD(jchar,    Char,    T_CHAR
+                        , HOTSPOT_JNI_CALLSTATICCHARMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICCHARMETHOD_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHOD(jshort,   Short,   T_SHORT
+                        , HOTSPOT_JNI_CALLSTATICSHORTMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICSHORTMETHOD_RETURN(_ret_ref));
+
+DEFINE_CALLSTATICMETHOD(jobject,  Object,  T_OBJECT
+                        , HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHOD(jint,     Int,     T_INT
+                        , HOTSPOT_JNI_CALLSTATICINTMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICINTMETHOD_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHOD(jlong,    Long,    T_LONG
+                        , HOTSPOT_JNI_CALLSTATICLONGMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICLONGMETHOD_RETURN(_ret_ref));
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_CALLSTATICMETHOD(jfloat,   Float,   T_FLOAT
+                        , HOTSPOT_JNI_CALLSTATICFLOATMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICFLOATMETHOD_RETURN());
+DEFINE_CALLSTATICMETHOD(jdouble,  Double,  T_DOUBLE
+                        , HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_RETURN());
+
+#define DEFINE_CALLSTATICMETHODV(ResultType, Result, Tag \
+                                , EntryProbe, ResultProbe) \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodV, ResultType \
+                          , ResultProbe);                               \
+\
+JNI_ENTRY(ResultType, \
+          jni_CallStatic##Result##MethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) \
+  JNIWrapper("CallStatic" XSTR(Result) "MethodV"); \
+\
+  EntryProbe; \
+  ResultType ret = 0;\
+  DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \
+                     (const ResultType&)ret);\
+\
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherVaArg ap(methodID, args); \
+  /* Make sure class is initialized before trying to invoke its method */ \
+  KlassHandle k(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls))); \
+  Klass::cast(k())->initialize(CHECK_0); \
+  jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \
+  va_end(args); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLSTATICMETHODV(jboolean, Boolean, T_BOOLEAN
+                        , HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODV(jbyte,    Byte,    T_BYTE
+                        , HOTSPOT_JNI_CALLSTATICBYTEMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICBYTEMETHODV_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODV(jchar,    Char,    T_CHAR
+                        , HOTSPOT_JNI_CALLSTATICCHARMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICCHARMETHODV_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODV(jshort,   Short,   T_SHORT
+                        , HOTSPOT_JNI_CALLSTATICSHORTMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICSHORTMETHODV_RETURN(_ret_ref));
+
+DEFINE_CALLSTATICMETHODV(jobject,  Object,  T_OBJECT
+                        , HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODV(jint,     Int,     T_INT
+                        , HOTSPOT_JNI_CALLSTATICINTMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICINTMETHODV_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODV(jlong,    Long,    T_LONG
+                        , HOTSPOT_JNI_CALLSTATICLONGMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICLONGMETHODV_RETURN(_ret_ref));
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_CALLSTATICMETHODV(jfloat,   Float,   T_FLOAT
+                        , HOTSPOT_JNI_CALLSTATICFLOATMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICFLOATMETHODV_RETURN());
+DEFINE_CALLSTATICMETHODV(jdouble,  Double,  T_DOUBLE
+                        , HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_RETURN());
+
+#define DEFINE_CALLSTATICMETHODA(ResultType, Result, Tag \
+                                , EntryProbe, ResultProbe) \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodA, ResultType \
+                          , ResultProbe);                               \
+\
+JNI_ENTRY(ResultType, \
+          jni_CallStatic##Result##MethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) \
+  JNIWrapper("CallStatic" XSTR(Result) "MethodA"); \
+\
+  EntryProbe; \
+  ResultType ret = 0;\
+  DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \
+                     (const ResultType&)ret);\
+\
+  JavaValue jvalue(Tag); \
+  JNI_ArgumentPusherArray ap(methodID, args); \
+  jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \
+  ret = jvalue.get_##ResultType(); \
+  return ret;\
+JNI_END
+
+// the runtime type of subword integral basic types is integer
+DEFINE_CALLSTATICMETHODA(jboolean, Boolean, T_BOOLEAN
+                        , HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODA(jbyte,    Byte,    T_BYTE
+                        , HOTSPOT_JNI_CALLSTATICBYTEMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICBYTEMETHODA_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODA(jchar,    Char,    T_CHAR
+                        , HOTSPOT_JNI_CALLSTATICCHARMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICCHARMETHODA_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODA(jshort,   Short,   T_SHORT
+                        , HOTSPOT_JNI_CALLSTATICSHORTMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICSHORTMETHODA_RETURN(_ret_ref));
+
+DEFINE_CALLSTATICMETHODA(jobject,  Object,  T_OBJECT
+                        , HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODA(jint,     Int,     T_INT
+                        , HOTSPOT_JNI_CALLSTATICINTMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICINTMETHODA_RETURN(_ret_ref));
+DEFINE_CALLSTATICMETHODA(jlong,    Long,    T_LONG
+                        , HOTSPOT_JNI_CALLSTATICLONGMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICLONGMETHODA_RETURN(_ret_ref));
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_CALLSTATICMETHODA(jfloat,   Float,   T_FLOAT
+                        , HOTSPOT_JNI_CALLSTATICFLOATMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICFLOATMETHODA_RETURN());
+DEFINE_CALLSTATICMETHODA(jdouble,  Double,  T_DOUBLE
+                        , HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_ENTRY(env, cls, (uintptr_t)methodID),
+                        HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_RETURN());
+
+DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod
+                         , HOTSPOT_JNI_CALLSTATICVOIDMETHOD_RETURN());
+DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV
+                         , HOTSPOT_JNI_CALLSTATICVOIDMETHODV_RETURN());
+DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA
+                         , HOTSPOT_JNI_CALLSTATICVOIDMETHODA_RETURN());
+#endif /* USDT2 */
+
 JNI_ENTRY(void, jni_CallStaticVoidMethod(JNIEnv *env, jclass cls, jmethodID methodID, ...))
   JNIWrapper("CallStaticVoidMethod");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethod__entry, env, cls, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLSTATICVOIDMETHOD_ENTRY(
+                                         env, cls, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallStaticVoidMethod);
 
   va_list args;
@@ -1646,7 +2540,12 @@
 
 JNI_ENTRY(void, jni_CallStaticVoidMethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args))
   JNIWrapper("CallStaticVoidMethodV");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodV__entry, env, cls, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLSTATICVOIDMETHODV_ENTRY(
+                                          env, cls, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallStaticVoidMethodV);
 
   JavaValue jvalue(T_VOID);
@@ -1657,7 +2556,12 @@
 
 JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args))
   JNIWrapper("CallStaticVoidMethodA");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodA__entry, env, cls, methodID);
+#else /* USDT2 */
+  HOTSPOT_JNI_CALLSTATICVOIDMETHODA_ENTRY(
+                                          env, cls, (uintptr_t) methodID);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(CallStaticVoidMethodA);
 
   JavaValue jvalue(T_VOID);
@@ -1671,12 +2575,22 @@
 //
 
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(GetFieldID, jfieldID);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(GetFieldID, jfieldID
+                    , HOTSPOT_JNI_GETFIELDID_RETURN((uintptr_t)_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz,
           const char *name, const char *sig))
   JNIWrapper("GetFieldID");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, GetFieldID__entry, env, clazz, name, sig);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETFIELDID_ENTRY(
+                               env, clazz, (char *) name, (char *) sig);
+#endif /* USDT2 */
   jfieldID ret = 0;
   DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret);
 
@@ -1708,7 +2622,12 @@
 
 JNI_ENTRY(jobject, jni_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID))
   JNIWrapper("GetObjectField");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, GetObjectField__entry, env, obj, fieldID);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETOBJECTFIELD_ENTRY(
+                                   env, obj, (uintptr_t) fieldID);
+#endif /* USDT2 */
   oop o = JNIHandles::resolve_non_null(obj);
   klassOop k = o->klass();
   int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID);
@@ -1738,11 +2657,17 @@
     }
   }
 #endif // SERIALGC
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret);
+#else /* USDT2 */
+HOTSPOT_JNI_GETOBJECTFIELD_RETURN(
+                                  ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 
+#ifndef USDT2
 #define DEFINE_GETFIELD(Return,Fieldname,Result) \
 \
   DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return);\
@@ -1776,6 +2701,61 @@
 DEFINE_GETFIELD(jfloat,   float,  Float)
 DEFINE_GETFIELD(jdouble,  double, Double)
 
+#else /* USDT2 */
+
+#define DEFINE_GETFIELD(Return,Fieldname,Result \
+  , EntryProbe, ReturnProbe) \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return \
+  , ReturnProbe); \
+\
+JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \
+  JNIWrapper("Get" XSTR(Result) "Field"); \
+\
+  EntryProbe; \
+  Return ret = 0;\
+  DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\
+\
+  oop o = JNIHandles::resolve_non_null(obj); \
+  klassOop k = o->klass(); \
+  int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID);  \
+  /* Keep JVMTI addition small and only check enabled flag here.       */ \
+  /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \
+  /* and creates a ResetNoHandleMark.                                   */ \
+  if (JvmtiExport::should_post_field_access()) { \
+    o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \
+  } \
+  ret = o->Fieldname##_field(offset); \
+  return ret; \
+JNI_END
+
+DEFINE_GETFIELD(jboolean, bool,   Boolean
+                , HOTSPOT_JNI_GETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_GETBOOLEANFIELD_RETURN(_ret_ref))
+DEFINE_GETFIELD(jbyte,    byte,   Byte
+                , HOTSPOT_JNI_GETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_GETBYTEFIELD_RETURN(_ret_ref))
+DEFINE_GETFIELD(jchar,    char,   Char
+                , HOTSPOT_JNI_GETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_GETCHARFIELD_RETURN(_ret_ref))
+DEFINE_GETFIELD(jshort,   short,  Short
+                , HOTSPOT_JNI_GETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_GETSHORTFIELD_RETURN(_ret_ref))
+DEFINE_GETFIELD(jint,     int,    Int
+                , HOTSPOT_JNI_GETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_GETINTFIELD_RETURN(_ret_ref))
+DEFINE_GETFIELD(jlong,    long,   Long
+                , HOTSPOT_JNI_GETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_GETLONGFIELD_RETURN(_ret_ref))
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_GETFIELD(jfloat,   float,  Float
+                , HOTSPOT_JNI_GETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_GETFLOATFIELD_RETURN())
+DEFINE_GETFIELD(jdouble,  double, Double
+                , HOTSPOT_JNI_GETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_GETDOUBLEFIELD_RETURN())
+#endif /* USDT2 */
+
 address jni_GetBooleanField_addr() {
   return (address)jni_GetBooleanField;
 }
@@ -1803,7 +2783,12 @@
 
 JNI_QUICK_ENTRY(void, jni_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, jobject value))
   JNIWrapper("SetObjectField");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, SetObjectField__entry, env, obj, fieldID, value);
+#else /* USDT2 */
+  HOTSPOT_JNI_SETOBJECTFIELD_ENTRY(
+                                   env, obj, (uintptr_t) fieldID, value);
+#endif /* USDT2 */
   oop o = JNIHandles::resolve_non_null(obj);
   klassOop k = o->klass();
   int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID);
@@ -1816,9 +2801,15 @@
     o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, 'L', (jvalue *)&field_value);
   }
   o->obj_field_put(offset, JNIHandles::resolve(value));
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, SetObjectField__return);
+#else /* USDT2 */
+  HOTSPOT_JNI_SETOBJECTFIELD_RETURN(
+);
+#endif /* USDT2 */
 JNI_END
 
+#ifndef USDT2
 #define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType) \
 \
 JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \
@@ -1853,12 +2844,74 @@
 DEFINE_SETFIELD(jfloat,   float,  Float,   'F', f)
 DEFINE_SETFIELD(jdouble,  double, Double,  'D', d)
 
+#else /* USDT2 */
+
+#define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType \
+                        , EntryProbe, ReturnProbe) \
+\
+JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \
+  JNIWrapper("Set" XSTR(Result) "Field"); \
+\
+  EntryProbe; \
+\
+  oop o = JNIHandles::resolve_non_null(obj); \
+  klassOop k = o->klass(); \
+  int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID);  \
+  /* Keep JVMTI addition small and only check enabled flag here.       */ \
+  /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \
+  /* and creates a ResetNoHandleMark.                                   */ \
+  if (JvmtiExport::should_post_field_modification()) { \
+    jvalue field_value; \
+    field_value.unionType = value; \
+    o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \
+  } \
+  o->Fieldname##_field_put(offset, value); \
+  ReturnProbe; \
+JNI_END
+
+DEFINE_SETFIELD(jboolean, bool,   Boolean, 'Z', z
+                , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
+                HOTSPOT_JNI_SETBOOLEANFIELD_RETURN())
+DEFINE_SETFIELD(jbyte,    byte,   Byte,    'B', b
+                , HOTSPOT_JNI_SETBYTEFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
+                HOTSPOT_JNI_SETBYTEFIELD_RETURN())
+DEFINE_SETFIELD(jchar,    char,   Char,    'C', c
+                , HOTSPOT_JNI_SETCHARFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
+                HOTSPOT_JNI_SETCHARFIELD_RETURN())
+DEFINE_SETFIELD(jshort,   short,  Short,   'S', s
+                , HOTSPOT_JNI_SETSHORTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
+                HOTSPOT_JNI_SETSHORTFIELD_RETURN())
+DEFINE_SETFIELD(jint,     int,    Int,     'I', i
+                , HOTSPOT_JNI_SETINTFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
+                HOTSPOT_JNI_SETINTFIELD_RETURN())
+DEFINE_SETFIELD(jlong,    long,   Long,    'J', j
+                , HOTSPOT_JNI_SETLONGFIELD_ENTRY(env, obj, (uintptr_t)fieldID, value),
+                HOTSPOT_JNI_SETLONGFIELD_RETURN())
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_SETFIELD(jfloat,   float,  Float,   'F', f
+                , HOTSPOT_JNI_SETFLOATFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_SETFLOATFIELD_RETURN())
+DEFINE_SETFIELD(jdouble,  double, Double,  'D', d
+                , HOTSPOT_JNI_SETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID),
+                HOTSPOT_JNI_SETDOUBLEFIELD_RETURN())
+#endif /* USDT2 */
+
+#ifndef USDT2
 DT_RETURN_MARK_DECL(ToReflectedField, jobject);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(ToReflectedField, jobject
+                    , HOTSPOT_JNI_TOREFLECTEDFIELD_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic))
   JNIWrapper("ToReflectedField");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, ToReflectedField__entry,
                 env, cls, fieldID, isStatic);
+#else /* USDT2 */
+  HOTSPOT_JNI_TOREFLECTEDFIELD_ENTRY(
+                env, cls, (uintptr_t) fieldID, isStatic);
+#endif /* USDT2 */
   jobject ret = NULL;
   DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret);
 
@@ -1888,12 +2941,22 @@
 //
 // Accessing Static Fields
 //
+#ifndef USDT2
 DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID
+                    , HOTSPOT_JNI_GETSTATICFIELDID_RETURN((uintptr_t)_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz,
           const char *name, const char *sig))
   JNIWrapper("GetStaticFieldID");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, GetStaticFieldID__entry, env, clazz, name, sig);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTATICFIELDID_ENTRY(
+                                     env, clazz, (char *) name, (char *) sig);
+#endif /* USDT2 */
   jfieldID ret = NULL;
   DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret);
 
@@ -1929,7 +2992,12 @@
 
 JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID))
   JNIWrapper("GetStaticObjectField");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, GetStaticObjectField__entry, env, clazz, fieldID);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY(
+                                         env, clazz, (uintptr_t) fieldID);
+#endif /* USDT2 */
 #ifndef JNICHECK_KERNEL
   DEBUG_ONLY(klassOop param_k = jniCheck::validate_class(thread, clazz);)
 #endif // JNICHECK_KERNEL
@@ -1941,10 +3009,16 @@
     JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true);
   }
   jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset()));
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTATICOBJECTFIELD_RETURN(
+                                          ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
+#ifndef USDT2
 #define DEFINE_GETSTATICFIELD(Return,Fieldname,Result) \
 \
   DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return);\
@@ -1975,10 +3049,58 @@
 DEFINE_GETSTATICFIELD(jfloat,   float,  Float)
 DEFINE_GETSTATICFIELD(jdouble,  double, Double)
 
+#else /* USDT2 */
+
+#define DEFINE_GETSTATICFIELD(Return,Fieldname,Result \
+                              , EntryProbe, ReturnProbe) \
+\
+  DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return \
+                          , ReturnProbe);                                          \
+\
+JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID)) \
+  JNIWrapper("GetStatic" XSTR(Result) "Field"); \
+  EntryProbe; \
+  Return ret = 0;\
+  DT_RETURN_MARK_FOR(Result, GetStatic##Result##Field, Return, \
+                     (const Return&)ret);\
+  JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \
+  assert(id->is_static_field_id(), "invalid static field id"); \
+  /* Keep JVMTI addition small and only check enabled flag here. */ \
+  /* jni_GetField_probe() assumes that is okay to create handles. */ \
+  if (JvmtiExport::should_post_field_access()) { \
+    JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \
+  } \
+  ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \
+  return ret;\
+JNI_END
+
+DEFINE_GETSTATICFIELD(jboolean, bool,   Boolean
+                      , HOTSPOT_JNI_GETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICBOOLEANFIELD_RETURN(_ret_ref))
+DEFINE_GETSTATICFIELD(jbyte,    byte,   Byte
+                      , HOTSPOT_JNI_GETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),    HOTSPOT_JNI_GETSTATICBYTEFIELD_RETURN(_ret_ref)   )
+DEFINE_GETSTATICFIELD(jchar,    char,   Char
+                      , HOTSPOT_JNI_GETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),    HOTSPOT_JNI_GETSTATICCHARFIELD_RETURN(_ret_ref)   )
+DEFINE_GETSTATICFIELD(jshort,   short,  Short
+                      , HOTSPOT_JNI_GETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),   HOTSPOT_JNI_GETSTATICSHORTFIELD_RETURN(_ret_ref)  )
+DEFINE_GETSTATICFIELD(jint,     int,    Int
+                      , HOTSPOT_JNI_GETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),     HOTSPOT_JNI_GETSTATICINTFIELD_RETURN(_ret_ref)    )
+DEFINE_GETSTATICFIELD(jlong,    long,   Long
+                      , HOTSPOT_JNI_GETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),    HOTSPOT_JNI_GETSTATICLONGFIELD_RETURN(_ret_ref)   )
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_GETSTATICFIELD(jfloat,   float,  Float
+                      , HOTSPOT_JNI_GETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),   HOTSPOT_JNI_GETSTATICFLOATFIELD_RETURN()          )
+DEFINE_GETSTATICFIELD(jdouble,  double, Double
+                      , HOTSPOT_JNI_GETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),  HOTSPOT_JNI_GETSTATICDOUBLEFIELD_RETURN()         )
+#endif /* USDT2 */
 
 JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value))
   JNIWrapper("SetStaticObjectField");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, SetStaticObjectField__entry, env, clazz, fieldID, value);
+#else /* USDT2 */
+ HOTSPOT_JNI_SETSTATICOBJECTFIELD_ENTRY(
+                                        env, clazz, (uintptr_t) fieldID, value);
+#endif /* USDT2 */
   JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID);
   assert(id->is_static_field_id(), "invalid static field id");
   // Keep JVMTI addition small and only check enabled flag here.
@@ -1989,10 +3111,16 @@
     JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value);
   }
   id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value));
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return);
+#else /* USDT2 */
+  HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN(
+                                          );
+#endif /* USDT2 */
 JNI_END
 
 
+#ifndef USDT2
 #define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType) \
 \
 JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \
@@ -2024,6 +3152,54 @@
 DEFINE_SETSTATICFIELD(jfloat,   float,  Float,   'F', f)
 DEFINE_SETSTATICFIELD(jdouble,  double, Double,  'D', d)
 
+#else /* USDT2 */
+
+#define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType \
+                              , EntryProbe, ReturnProbe) \
+\
+JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \
+  JNIWrapper("SetStatic" XSTR(Result) "Field"); \
+  EntryProbe; \
+\
+  JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \
+  assert(id->is_static_field_id(), "invalid static field id"); \
+  /* Keep JVMTI addition small and only check enabled flag here. */ \
+  /* jni_SetField_probe() assumes that is okay to create handles. */ \
+  if (JvmtiExport::should_post_field_modification()) { \
+    jvalue field_value; \
+    field_value.unionType = value; \
+    JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \
+  } \
+  id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \
+  ReturnProbe;\
+JNI_END
+
+DEFINE_SETSTATICFIELD(jboolean, bool,   Boolean, 'Z', z
+                      , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value),
+                      HOTSPOT_JNI_SETBOOLEANFIELD_RETURN())
+DEFINE_SETSTATICFIELD(jbyte,    byte,   Byte,    'B', b
+                      , HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
+                      HOTSPOT_JNI_SETSTATICBYTEFIELD_RETURN())
+DEFINE_SETSTATICFIELD(jchar,    char,   Char,    'C', c
+                      , HOTSPOT_JNI_SETSTATICCHARFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
+                      HOTSPOT_JNI_SETSTATICCHARFIELD_RETURN())
+DEFINE_SETSTATICFIELD(jshort,   short,  Short,   'S', s
+                      , HOTSPOT_JNI_SETSTATICSHORTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
+                      HOTSPOT_JNI_SETSTATICSHORTFIELD_RETURN())
+DEFINE_SETSTATICFIELD(jint,     int,    Int,     'I', i
+                      , HOTSPOT_JNI_SETSTATICINTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
+                      HOTSPOT_JNI_SETSTATICINTFIELD_RETURN())
+DEFINE_SETSTATICFIELD(jlong,    long,   Long,    'J', j
+                      , HOTSPOT_JNI_SETSTATICLONGFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
+                      HOTSPOT_JNI_SETSTATICLONGFIELD_RETURN())
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_SETSTATICFIELD(jfloat,   float,  Float,   'F', f
+                      , HOTSPOT_JNI_SETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),
+                      HOTSPOT_JNI_SETSTATICFLOATFIELD_RETURN())
+DEFINE_SETSTATICFIELD(jdouble,  double, Double,  'D', d
+                      , HOTSPOT_JNI_SETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID),
+                      HOTSPOT_JNI_SETSTATICDOUBLEFIELD_RETURN())
+#endif /* USDT2 */
 
 //
 // String Operations
@@ -2031,11 +3207,21 @@
 
 // Unicode Interface
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(NewString, jstring);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(NewString, jstring
+                    , HOTSPOT_JNI_NEWSTRING_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jstring, jni_NewString(JNIEnv *env, const jchar *unicodeChars, jsize len))
   JNIWrapper("NewString");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, NewString__entry, env, unicodeChars, len);
+#else /* USDT2 */
+ HOTSPOT_JNI_NEWSTRING_ENTRY(
+                             env, (uint16_t *) unicodeChars, len);
+#endif /* USDT2 */
   jstring ret = NULL;
   DT_RETURN_MARK(NewString, jstring, (const jstring&)ret);
   oop string=java_lang_String::create_oop_from_unicode((jchar*) unicodeChars, len, CHECK_NULL);
@@ -2046,9 +3232,19 @@
 
 JNI_QUICK_ENTRY(jsize, jni_GetStringLength(JNIEnv *env, jstring string))
   JNIWrapper("GetStringLength");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetStringLength__entry, env, string);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTRINGLENGTH_ENTRY(
+                                    env, string);
+#endif /* USDT2 */
   jsize ret = java_lang_String::length(JNIHandles::resolve_non_null(string));
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetStringLength__return, ret);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETSTRINGLENGTH_RETURN(
+                                    ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
@@ -2056,7 +3252,12 @@
 JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars(
   JNIEnv *env, jstring string, jboolean *isCopy))
   JNIWrapper("GetStringChars");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, GetStringChars__entry, env, string, isCopy);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETSTRINGCHARS_ENTRY(
+                                  env, string, (uintptr_t *) isCopy);
+#endif /* USDT2 */
   //%note jni_5
   if (isCopy != NULL) {
     *isCopy = JNI_TRUE;
@@ -2070,31 +3271,56 @@
     memcpy(buf, s_value->char_at_addr(s_offset), sizeof(jchar)*s_len);
   }
   buf[s_len] = 0;
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetStringChars__return, buf);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTRINGCHARS_RETURN(
+                                    buf);
+#endif /* USDT2 */
   return buf;
 JNI_END
 
 
 JNI_QUICK_ENTRY(void, jni_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars))
   JNIWrapper("ReleaseStringChars");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, ReleaseStringChars__entry, env, str, chars);
+#else /* USDT2 */
+  HOTSPOT_JNI_RELEASESTRINGCHARS_ENTRY(
+                                       env, str, (uint16_t *) chars);
+#endif /* USDT2 */
   //%note jni_6
   if (chars != NULL) {
     // Since String objects are supposed to be immutable, don't copy any
     // new data back.  A bad user will have to go after the char array.
     FreeHeap((void*) chars);
   }
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, ReleaseStringChars__return);
+#else /* USDT2 */
+  HOTSPOT_JNI_RELEASESTRINGCHARS_RETURN(
+);
+#endif /* USDT2 */
 JNI_END
 
 
 // UTF Interface
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(NewStringUTF, jstring);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(NewStringUTF, jstring
+                    , HOTSPOT_JNI_NEWSTRINGUTF_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jstring, jni_NewStringUTF(JNIEnv *env, const char *bytes))
   JNIWrapper("NewStringUTF");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, NewStringUTF__entry, env, bytes);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWSTRINGUTF_ENTRY(
+                                 env, (char *) bytes);
+#endif /* USDT2 */
   jstring ret;
   DT_RETURN_MARK(NewStringUTF, jstring, (const jstring&)ret);
 
@@ -2106,43 +3332,83 @@
 
 JNI_ENTRY(jsize, jni_GetStringUTFLength(JNIEnv *env, jstring string))
   JNIWrapper("GetStringUTFLength");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetStringUTFLength__entry, env, string);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETSTRINGUTFLENGTH_ENTRY(
+                                      env, string);
+#endif /* USDT2 */
   jsize ret = java_lang_String::utf8_length(JNIHandles::resolve_non_null(string));
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetStringUTFLength__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTRINGUTFLENGTH_RETURN(
+                                        ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 
 JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy))
   JNIWrapper("GetStringUTFChars");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, GetStringUTFChars__entry, env, string, isCopy);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY(
+                                     env, string, (uintptr_t *) isCopy);
+#endif /* USDT2 */
   oop java_string = JNIHandles::resolve_non_null(string);
   size_t length = java_lang_String::utf8_length(java_string);
   char* result = AllocateHeap(length + 1, "GetStringUTFChars");
   java_lang_String::as_utf8_string(java_string, result, (int) length + 1);
   if (isCopy != NULL) *isCopy = JNI_TRUE;
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN(
+                                      result);
+#endif /* USDT2 */
   return result;
 JNI_END
 
 
 JNI_LEAF(void, jni_ReleaseStringUTFChars(JNIEnv *env, jstring str, const char *chars))
   JNIWrapper("ReleaseStringUTFChars");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, ReleaseStringUTFChars__entry, env, str, chars);
+#else /* USDT2 */
+ HOTSPOT_JNI_RELEASESTRINGUTFCHARS_ENTRY(
+                                         env, str, (char *) chars);
+#endif /* USDT2 */
   if (chars != NULL) {
     FreeHeap((char*) chars);
   }
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, ReleaseStringUTFChars__return);
+#else /* USDT2 */
+HOTSPOT_JNI_RELEASESTRINGUTFCHARS_RETURN(
+);
+#endif /* USDT2 */
 JNI_END
 
 
 JNI_QUICK_ENTRY(jsize, jni_GetArrayLength(JNIEnv *env, jarray array))
   JNIWrapper("GetArrayLength");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetArrayLength__entry, env, array);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETARRAYLENGTH_ENTRY(
+                                  env, array);
+#endif /* USDT2 */
   arrayOop a = arrayOop(JNIHandles::resolve_non_null(array));
   assert(a->is_array(), "must be array");
   jsize ret = a->length();
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetArrayLength__return, ret);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETARRAYLENGTH_RETURN(
+                                   ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
@@ -2151,11 +3417,21 @@
 // Object Array Operations
 //
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray
+                    , HOTSPOT_JNI_NEWOBJECTARRAY_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement))
   JNIWrapper("NewObjectArray");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, NewObjectArray__entry, env, length, elementClass, initialElement);
+#else /* USDT2 */
+ HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY(
+                                  env, length, elementClass, initialElement);
+#endif /* USDT2 */
   jobjectArray ret = NULL;
   DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret);
   KlassHandle ek(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(elementClass)));
@@ -2173,11 +3449,21 @@
   return ret;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject
+                    , HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index))
   JNIWrapper("GetObjectArrayElement");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, GetObjectArrayElement__entry, env, array, index);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY(
+                                         env, array, index);
+#endif /* USDT2 */
   jobject ret = NULL;
   DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret);
   objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array));
@@ -2191,11 +3477,21 @@
   }
 JNI_END
 
+#ifndef USDT2
 DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement);
+#else /* USDT2 */
+DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement
+                         , HOTSPOT_JNI_SETOBJECTARRAYELEMENT_RETURN());
+#endif /* USDT2 */
 
 JNI_ENTRY(void, jni_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject value))
   JNIWrapper("SetObjectArrayElement");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, SetObjectArrayElement__entry, env, array, index, value);
+#else /* USDT2 */
+ HOTSPOT_JNI_SETOBJECTARRAYELEMENT_ENTRY(
+                                         env, array, index, value);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(SetObjectArrayElement);
 
   objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array));
@@ -2214,9 +3510,10 @@
 JNI_END
 
 
+#ifndef USDT2
 #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result) \
 \
-  DT_RETURN_MARK_DECL(New##Result##Array, Return);\
+  DT_RETURN_MARK_DECL(New##Result##Array, Return); \
 \
 JNI_ENTRY(Return, \
           jni_New##Result##Array(JNIEnv *env, jsize len)) \
@@ -2239,6 +3536,51 @@
 DEFINE_NEWSCALARARRAY(jfloatArray,   new_singleArray, Float)
 DEFINE_NEWSCALARARRAY(jdoubleArray,  new_doubleArray, Double)
 
+#else /* USDT2 */
+
+#define DEFINE_NEWSCALARARRAY(Return,Allocator,Result \
+                              ,EntryProbe,ReturnProbe)  \
+\
+  DT_RETURN_MARK_DECL(New##Result##Array, Return \
+                      , ReturnProbe); \
+\
+JNI_ENTRY(Return, \
+          jni_New##Result##Array(JNIEnv *env, jsize len)) \
+  JNIWrapper("New" XSTR(Result) "Array"); \
+  EntryProbe; \
+  Return ret = NULL;\
+  DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\
+\
+  oop obj= oopFactory::Allocator(len, CHECK_0); \
+  ret = (Return) JNIHandles::make_local(env, obj); \
+  return ret;\
+JNI_END
+
+DEFINE_NEWSCALARARRAY(jbooleanArray, new_boolArray,   Boolean,
+                      HOTSPOT_JNI_NEWBOOLEANARRAY_ENTRY(env, len),
+                      HOTSPOT_JNI_NEWBOOLEANARRAY_RETURN(_ret_ref))
+DEFINE_NEWSCALARARRAY(jbyteArray,    new_byteArray,   Byte,
+                      HOTSPOT_JNI_NEWBYTEARRAY_ENTRY(env, len),
+                      HOTSPOT_JNI_NEWBYTEARRAY_RETURN(_ret_ref))
+DEFINE_NEWSCALARARRAY(jshortArray,   new_shortArray,  Short,
+                      HOTSPOT_JNI_NEWSHORTARRAY_ENTRY(env, len),
+                      HOTSPOT_JNI_NEWSHORTARRAY_RETURN(_ret_ref))
+DEFINE_NEWSCALARARRAY(jcharArray,    new_charArray,   Char,
+                      HOTSPOT_JNI_NEWCHARARRAY_ENTRY(env, len),
+                      HOTSPOT_JNI_NEWCHARARRAY_RETURN(_ret_ref))
+DEFINE_NEWSCALARARRAY(jintArray,     new_intArray,    Int,
+                      HOTSPOT_JNI_NEWINTARRAY_ENTRY(env, len),
+                      HOTSPOT_JNI_NEWINTARRAY_RETURN(_ret_ref))
+DEFINE_NEWSCALARARRAY(jlongArray,    new_longArray,   Long,
+                      HOTSPOT_JNI_NEWLONGARRAY_ENTRY(env, len),
+                      HOTSPOT_JNI_NEWLONGARRAY_RETURN(_ret_ref))
+DEFINE_NEWSCALARARRAY(jfloatArray,   new_singleArray, Float,
+                      HOTSPOT_JNI_NEWFLOATARRAY_ENTRY(env, len),
+                      HOTSPOT_JNI_NEWFLOATARRAY_RETURN(_ret_ref))
+DEFINE_NEWSCALARARRAY(jdoubleArray,  new_doubleArray, Double,
+                      HOTSPOT_JNI_NEWDOUBLEARRAY_ENTRY(env, len),
+                      HOTSPOT_JNI_NEWDOUBLEARRAY_RETURN(_ret_ref))
+#endif /* USDT2 */
 
 // Return an address which will fault if the caller writes to it.
 
@@ -2256,6 +3598,7 @@
 }
 
 
+#ifndef USDT2
 #define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag) \
 \
 JNI_QUICK_ENTRY(ElementType*, \
@@ -2290,7 +3633,62 @@
 DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT,   jfloat,   Float,   float)
 DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE,  jdouble,  Double,  double)
 
-
+#else /* USDT2 */
+
+#define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag \
+                                      , EntryProbe, ReturnProbe) \
+\
+JNI_QUICK_ENTRY(ElementType*, \
+          jni_Get##Result##ArrayElements(JNIEnv *env, ElementType##Array array, jboolean *isCopy)) \
+  JNIWrapper("Get" XSTR(Result) "ArrayElements"); \
+  EntryProbe; \
+  /* allocate an chunk of memory in c land */ \
+  typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \
+  ElementType* result; \
+  int len = a->length(); \
+  if (len == 0) { \
+    /* Empty array: legal but useless, can't return NULL. \
+     * Return a pointer to something useless. \
+     * Avoid asserts in typeArrayOop. */ \
+    result = (ElementType*)get_bad_address(); \
+  } else { \
+    result = NEW_C_HEAP_ARRAY(ElementType, len); \
+    /* copy the array to the c chunk */ \
+    memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \
+  } \
+  if (isCopy) *isCopy = JNI_TRUE; \
+  ReturnProbe; \
+  return result; \
+JNI_END
+
+DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool
+                              , HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy),
+                              HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_RETURN((uintptr_t*)result))
+DEFINE_GETSCALARARRAYELEMENTS(T_BYTE,    jbyte,    Byte,    byte
+                              , HOTSPOT_JNI_GETBYTEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy),
+                              HOTSPOT_JNI_GETBYTEARRAYELEMENTS_RETURN((char*)result))
+DEFINE_GETSCALARARRAYELEMENTS(T_SHORT,   jshort,   Short,   short
+                              , HOTSPOT_JNI_GETSHORTARRAYELEMENTS_ENTRY(env, (uint16_t*) array, (uintptr_t *) isCopy),
+                              HOTSPOT_JNI_GETSHORTARRAYELEMENTS_RETURN((uint16_t*)result))
+DEFINE_GETSCALARARRAYELEMENTS(T_CHAR,    jchar,    Char,    char
+                              , HOTSPOT_JNI_GETCHARARRAYELEMENTS_ENTRY(env, (uint16_t*) array, (uintptr_t *) isCopy),
+                              HOTSPOT_JNI_GETCHARARRAYELEMENTS_RETURN(result))
+DEFINE_GETSCALARARRAYELEMENTS(T_INT,     jint,     Int,     int
+                              , HOTSPOT_JNI_GETINTARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy),
+                              HOTSPOT_JNI_GETINTARRAYELEMENTS_RETURN((uint32_t*)result))
+DEFINE_GETSCALARARRAYELEMENTS(T_LONG,    jlong,    Long,    long
+                              , HOTSPOT_JNI_GETLONGARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy),
+                              HOTSPOT_JNI_GETLONGARRAYELEMENTS_RETURN(((uintptr_t*)result)))
+// Float and double probes don't return value because dtrace doesn't currently support it
+DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT,   jfloat,   Float,   float
+                              , HOTSPOT_JNI_GETFLOATARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy),
+                              HOTSPOT_JNI_GETFLOATARRAYELEMENTS_RETURN(result))
+DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE,  jdouble,  Double,  double
+                              , HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy),
+                              HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_RETURN(result))
+#endif /* USDT2 */
+
+#ifndef USDT2
 #define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag) \
 \
 JNI_QUICK_ENTRY(void, \
@@ -2320,6 +3718,56 @@
 DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT,   jfloat,   Float,   float)
 DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE,  jdouble,  Double,  double)
 
+#else /* USDT2 */
+
+#define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag \
+                                          , EntryProbe, ReturnProbe);\
+\
+JNI_QUICK_ENTRY(void, \
+          jni_Release##Result##ArrayElements(JNIEnv *env, ElementType##Array array, \
+                                             ElementType *buf, jint mode)) \
+  JNIWrapper("Release" XSTR(Result) "ArrayElements"); \
+  EntryProbe; \
+  typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \
+  int len = a->length(); \
+  if (len != 0) {   /* Empty array:  nothing to free or copy. */  \
+    if ((mode == 0) || (mode == JNI_COMMIT)) { \
+      memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \
+    } \
+    if ((mode == 0) || (mode == JNI_ABORT)) { \
+      FreeHeap(buf); \
+    } \
+  } \
+  ReturnProbe; \
+JNI_END
+
+DEFINE_RELEASESCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool
+                                  , HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) buf, mode),
+                                  HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_RETURN())
+DEFINE_RELEASESCALARARRAYELEMENTS(T_BYTE,    jbyte,    Byte,    byte
+                                  , HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_ENTRY(env, array, (char *) buf, mode),
+                                  HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_RETURN())
+DEFINE_RELEASESCALARARRAYELEMENTS(T_SHORT,   jshort,   Short,   short
+                                  ,  HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_ENTRY(env, array, (uint16_t *) buf, mode),
+                                  HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_RETURN())
+DEFINE_RELEASESCALARARRAYELEMENTS(T_CHAR,    jchar,    Char,    char
+                                  ,  HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_ENTRY(env, array, (uint16_t *) buf, mode),
+                                  HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_RETURN())
+DEFINE_RELEASESCALARARRAYELEMENTS(T_INT,     jint,     Int,     int
+                                  , HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_ENTRY(env, array, (uint32_t *) buf, mode),
+                                  HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_RETURN())
+DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG,    jlong,    Long,    long
+                                  , HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) buf, mode),
+                                  HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_RETURN())
+DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT,   jfloat,   Float,   float
+                                  , HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_ENTRY(env, array, (float *) buf, mode),
+                                  HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_RETURN())
+DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE,  jdouble,  Double,  double
+                                  , HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_ENTRY(env, array, (double *) buf, mode),
+                                  HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_RETURN())
+#endif /* USDT2 */
+
+#ifndef USDT2
 #define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \
   DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion);\
 \
@@ -2351,6 +3799,59 @@
 DEFINE_GETSCALARARRAYREGION(T_FLOAT,   jfloat,  Float,   float)
 DEFINE_GETSCALARARRAYREGION(T_DOUBLE,  jdouble, Double,  double)
 
+#else /* USDT2 */
+
+#define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \
+                                    , EntryProbe, ReturnProbe); \
+  DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion \
+                           , ReturnProbe); \
+\
+JNI_ENTRY(void, \
+jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \
+             jsize len, ElementType *buf)) \
+  JNIWrapper("Get" XSTR(Result) "ArrayRegion"); \
+  EntryProbe; \
+  DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \
+  typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \
+  if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \
+    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \
+  } else { \
+    if (len > 0) { \
+      int sc = typeArrayKlass::cast(src->klass())->log2_element_size(); \
+      memcpy((u_char*) buf, \
+             (u_char*) src->Tag##_at_addr(start), \
+             len << sc);                          \
+    } \
+  } \
+JNI_END
+
+DEFINE_GETSCALARARRAYREGION(T_BOOLEAN, jboolean,Boolean, bool
+                            , HOTSPOT_JNI_GETBOOLEANARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf),
+                            HOTSPOT_JNI_GETBOOLEANARRAYREGION_RETURN());
+DEFINE_GETSCALARARRAYREGION(T_BYTE,    jbyte,   Byte,    byte
+                            ,  HOTSPOT_JNI_GETBYTEARRAYREGION_ENTRY(env, array, start, len, (char *) buf),
+                            HOTSPOT_JNI_GETBYTEARRAYREGION_RETURN());
+DEFINE_GETSCALARARRAYREGION(T_SHORT,   jshort,  Short,   short
+                            , HOTSPOT_JNI_GETSHORTARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf),
+                            HOTSPOT_JNI_GETSHORTARRAYREGION_RETURN());
+DEFINE_GETSCALARARRAYREGION(T_CHAR,    jchar,   Char,    char
+                            ,  HOTSPOT_JNI_GETCHARARRAYREGION_ENTRY(env, array, start, len, (uint16_t*) buf),
+                            HOTSPOT_JNI_GETCHARARRAYREGION_RETURN());
+DEFINE_GETSCALARARRAYREGION(T_INT,     jint,    Int,     int
+                            , HOTSPOT_JNI_GETINTARRAYREGION_ENTRY(env, array, start, len, (uint32_t*) buf),
+                            HOTSPOT_JNI_GETINTARRAYREGION_RETURN());
+DEFINE_GETSCALARARRAYREGION(T_LONG,    jlong,   Long,    long
+                            ,  HOTSPOT_JNI_GETLONGARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf),
+                            HOTSPOT_JNI_GETLONGARRAYREGION_RETURN());
+DEFINE_GETSCALARARRAYREGION(T_FLOAT,   jfloat,  Float,   float
+                            , HOTSPOT_JNI_GETFLOATARRAYREGION_ENTRY(env, array, start, len, (float *) buf),
+                            HOTSPOT_JNI_GETFLOATARRAYREGION_RETURN());
+DEFINE_GETSCALARARRAYREGION(T_DOUBLE,  jdouble, Double,  double
+                            , HOTSPOT_JNI_GETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf),
+                            HOTSPOT_JNI_GETDOUBLEARRAYREGION_RETURN());
+#endif /* USDT2 */
+
+#ifndef USDT2
 #define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \
   DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion);\
 \
@@ -2382,6 +3883,58 @@
 DEFINE_SETSCALARARRAYREGION(T_FLOAT,   jfloat,   Float,   float)
 DEFINE_SETSCALARARRAYREGION(T_DOUBLE,  jdouble,  Double,  double)
 
+#else /* USDT2 */
+
+#define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \
+                                    , EntryProbe, ReturnProbe); \
+  DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion \
+                           ,ReturnProbe);           \
+\
+JNI_ENTRY(void, \
+jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \
+             jsize len, const ElementType *buf)) \
+  JNIWrapper("Set" XSTR(Result) "ArrayRegion"); \
+  EntryProbe; \
+  DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \
+  typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \
+  if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \
+    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \
+  } else { \
+    if (len > 0) { \
+      int sc = typeArrayKlass::cast(dst->klass())->log2_element_size(); \
+      memcpy((u_char*) dst->Tag##_at_addr(start), \
+             (u_char*) buf, \
+             len << sc);    \
+    } \
+  } \
+JNI_END
+
+DEFINE_SETSCALARARRAYREGION(T_BOOLEAN, jboolean, Boolean, bool
+                            , HOTSPOT_JNI_SETBOOLEANARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *)buf),
+                            HOTSPOT_JNI_SETBOOLEANARRAYREGION_RETURN())
+DEFINE_SETSCALARARRAYREGION(T_BYTE,    jbyte,    Byte,    byte
+                            , HOTSPOT_JNI_SETBYTEARRAYREGION_ENTRY(env, array, start, len, (char *) buf),
+                            HOTSPOT_JNI_SETBYTEARRAYREGION_RETURN())
+DEFINE_SETSCALARARRAYREGION(T_SHORT,   jshort,   Short,   short
+                            , HOTSPOT_JNI_SETSHORTARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf),
+                            HOTSPOT_JNI_SETSHORTARRAYREGION_RETURN())
+DEFINE_SETSCALARARRAYREGION(T_CHAR,    jchar,    Char,    char
+                            , HOTSPOT_JNI_SETCHARARRAYREGION_ENTRY(env, array, start, len, (uint16_t *) buf),
+                            HOTSPOT_JNI_SETCHARARRAYREGION_RETURN())
+DEFINE_SETSCALARARRAYREGION(T_INT,     jint,     Int,     int
+                            , HOTSPOT_JNI_SETINTARRAYREGION_ENTRY(env, array, start, len, (uint32_t *) buf),
+                            HOTSPOT_JNI_SETINTARRAYREGION_RETURN())
+DEFINE_SETSCALARARRAYREGION(T_LONG,    jlong,    Long,    long
+                            , HOTSPOT_JNI_SETLONGARRAYREGION_ENTRY(env, array, start, len, (uintptr_t *) buf),
+                            HOTSPOT_JNI_SETLONGARRAYREGION_RETURN())
+DEFINE_SETSCALARARRAYREGION(T_FLOAT,   jfloat,   Float,   float
+                            , HOTSPOT_JNI_SETFLOATARRAYREGION_ENTRY(env, array, start, len, (float *) buf),
+                            HOTSPOT_JNI_SETFLOATARRAYREGION_RETURN())
+DEFINE_SETSCALARARRAYREGION(T_DOUBLE,  jdouble,  Double,  double
+                            , HOTSPOT_JNI_SETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf),
+                            HOTSPOT_JNI_SETDOUBLEARRAYREGION_RETURN())
+#endif /* USDT2 */
+
 
 //
 // Interception of natives
@@ -2463,13 +4016,23 @@
   return true;
 }
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(RegisterNatives, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(RegisterNatives, jint
+                    , HOTSPOT_JNI_REGISTERNATIVES_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz,
                                     const JNINativeMethod *methods,
                                     jint nMethods))
   JNIWrapper("RegisterNatives");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, RegisterNatives__entry, env, clazz, methods, nMethods);
+#else /* USDT2 */
+  HOTSPOT_JNI_REGISTERNATIVES_ENTRY(
+                                    env, clazz, (void *) methods, nMethods);
+#endif /* USDT2 */
   jint ret = 0;
   DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret);
 
@@ -2507,7 +4070,12 @@
 
 JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz))
   JNIWrapper("UnregisterNatives");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, UnregisterNatives__entry, env, clazz);
+#else /* USDT2 */
+ HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY(
+                                     env, clazz);
+#endif /* USDT2 */
   klassOop k   = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz));
   //%note jni_2
   if (Klass::cast(k)->oop_is_instance()) {
@@ -2519,7 +4087,12 @@
       }
     }
   }
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, UnregisterNatives__return, 0);
+#else /* USDT2 */
+ HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(
+                                      0);
+#endif /* USDT2 */
   return 0;
 JNI_END
 
@@ -2527,10 +4100,20 @@
 // Monitor functions
 //
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(MonitorEnter, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(MonitorEnter, jint
+                    , HOTSPOT_JNI_MONITORENTER_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jint, jni_MonitorEnter(JNIEnv *env, jobject jobj))
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, MonitorEnter__entry, env, jobj);
+#else /* USDT2 */
+ HOTSPOT_JNI_MONITORENTER_ENTRY(
+                                env, jobj);
+#endif /* USDT2 */
   jint ret = JNI_ERR;
   DT_RETURN_MARK(MonitorEnter, jint, (const jint&)ret);
 
@@ -2545,10 +4128,20 @@
   return ret;
 JNI_END
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(MonitorExit, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(MonitorExit, jint
+                    , HOTSPOT_JNI_MONITOREXIT_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 JNI_ENTRY(jint, jni_MonitorExit(JNIEnv *env, jobject jobj))
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, MonitorExit__entry, env, jobj);
+#else /* USDT2 */
+ HOTSPOT_JNI_MONITOREXIT_ENTRY(
+                               env, jobj);
+#endif /* USDT2 */
   jint ret = JNI_ERR;
   DT_RETURN_MARK(MonitorExit, jint, (const jint&)ret);
 
@@ -2568,11 +4161,21 @@
 // Extensions
 //
 
+#ifndef USDT2
 DT_VOID_RETURN_MARK_DECL(GetStringRegion);
+#else /* USDT2 */
+DT_VOID_RETURN_MARK_DECL(GetStringRegion
+                         , HOTSPOT_JNI_GETSTRINGREGION_RETURN());
+#endif /* USDT2 */
 
 JNI_ENTRY(void, jni_GetStringRegion(JNIEnv *env, jstring string, jsize start, jsize len, jchar *buf))
   JNIWrapper("GetStringRegion");
+#ifndef USDT2
   DTRACE_PROBE5(hotspot_jni, GetStringRegion__entry, env, string, start, len, buf);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETSTRINGREGION_ENTRY(
+                                   env, string, start, len, buf);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(GetStringRegion);
   oop s = JNIHandles::resolve_non_null(string);
   int s_len = java_lang_String::length(s);
@@ -2587,11 +4190,21 @@
   }
 JNI_END
 
+#ifndef USDT2
 DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion);
+#else /* USDT2 */
+DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion
+                         , HOTSPOT_JNI_GETSTRINGUTFREGION_RETURN());
+#endif /* USDT2 */
 
 JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start, jsize len, char *buf))
   JNIWrapper("GetStringUTFRegion");
+#ifndef USDT2
   DTRACE_PROBE5(hotspot_jni, GetStringUTFRegion__entry, env, string, start, len, buf);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETSTRINGUTFREGION_ENTRY(
+                                      env, string, start, len, buf);
+#endif /* USDT2 */
   DT_VOID_RETURN_MARK(GetStringUTFRegion);
   oop s = JNIHandles::resolve_non_null(string);
   int s_len = java_lang_String::length(s);
@@ -2617,7 +4230,12 @@
 
 JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy))
   JNIWrapper("GetPrimitiveArrayCritical");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, GetPrimitiveArrayCritical__entry, env, array, isCopy);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY(
+                                             env, array, (uintptr_t *) isCopy);
+#endif /* USDT2 */
   GC_locker::lock_critical(thread);
   if (isCopy != NULL) {
     *isCopy = JNI_FALSE;
@@ -2631,23 +4249,43 @@
     type = typeArrayKlass::cast(a->klass())->element_type();
   }
   void* ret = arrayOop(a)->base(type);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetPrimitiveArrayCritical__return, ret);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_RETURN(
+                                              ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 
 JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode))
   JNIWrapper("ReleasePrimitiveArrayCritical");
+#ifndef USDT2
   DTRACE_PROBE4(hotspot_jni, ReleasePrimitiveArrayCritical__entry, env, array, carray, mode);
+#else /* USDT2 */
+  HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY(
+                                                  env, array, carray, mode);
+#endif /* USDT2 */
   // The array, carray and mode arguments are ignored
   GC_locker::unlock_critical(thread);
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, ReleasePrimitiveArrayCritical__return);
+#else /* USDT2 */
+HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN(
+);
+#endif /* USDT2 */
 JNI_END
 
 
 JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy))
   JNIWrapper("GetStringCritical");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, GetStringCritical__entry, env, string, isCopy);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY(
+                                      env, string, (uintptr_t *) isCopy);
+#endif /* USDT2 */
   GC_locker::lock_critical(thread);
   if (isCopy != NULL) {
     *isCopy = JNI_FALSE;
@@ -2662,44 +4300,89 @@
   } else {
     ret = (jchar*) s_value->base(T_CHAR);
   }
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetStringCritical__return, ret);
+#else /* USDT2 */
+ HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN(
+                                      (uint16_t *) ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 
 JNI_ENTRY(void, jni_ReleaseStringCritical(JNIEnv *env, jstring str, const jchar *chars))
   JNIWrapper("ReleaseStringCritical");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, ReleaseStringCritical__entry, env, str, chars);
+#else /* USDT2 */
+  HOTSPOT_JNI_RELEASESTRINGCRITICAL_ENTRY(
+                                          env, str, (uint16_t *) chars);
+#endif /* USDT2 */
   // The str and chars arguments are ignored
   GC_locker::unlock_critical(thread);
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, ReleaseStringCritical__return);
+#else /* USDT2 */
+HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN(
+);
+#endif /* USDT2 */
 JNI_END
 
 
 JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref))
   JNIWrapper("jni_NewWeakGlobalRef");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, NewWeakGlobalRef__entry, env, ref);
+#else /* USDT2 */
+ HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY(
+                                    env, ref);
+#endif /* USDT2 */
   Handle ref_handle(thread, JNIHandles::resolve(ref));
   jweak ret = JNIHandles::make_weak_global(ref_handle);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, NewWeakGlobalRef__return, ret);
+#else /* USDT2 */
+ HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN(
+                                     ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
 // Must be JNI_ENTRY (with HandleMark)
 JNI_ENTRY(void, jni_DeleteWeakGlobalRef(JNIEnv *env, jweak ref))
   JNIWrapper("jni_DeleteWeakGlobalRef");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, DeleteWeakGlobalRef__entry, env, ref);
+#else /* USDT2 */
+  HOTSPOT_JNI_DELETEWEAKGLOBALREF_ENTRY(
+                                        env, ref);
+#endif /* USDT2 */
   JNIHandles::destroy_weak_global(ref);
+#ifndef USDT2
   DTRACE_PROBE(hotspot_jni, DeleteWeakGlobalRef__return);
+#else /* USDT2 */
+  HOTSPOT_JNI_DELETEWEAKGLOBALREF_RETURN(
+                                         );
+#endif /* USDT2 */
 JNI_END
 
 
 JNI_QUICK_ENTRY(jboolean, jni_ExceptionCheck(JNIEnv *env))
   JNIWrapper("jni_ExceptionCheck");
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, ExceptionCheck__entry, env);
+#else /* USDT2 */
+ HOTSPOT_JNI_EXCEPTIONCHECK_ENTRY(
+                                  env);
+#endif /* USDT2 */
   jni_check_async_exceptions(thread);
   jboolean ret = (thread->has_pending_exception()) ? JNI_TRUE : JNI_FALSE;
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, ExceptionCheck__return, ret);
+#else /* USDT2 */
+ HOTSPOT_JNI_EXCEPTIONCHECK_RETURN(
+                                   ret);
+#endif /* USDT2 */
   return ret;
 JNI_END
 
@@ -2791,11 +4474,21 @@
   JavaThread* thread = JavaThread::thread_from_jni_environment(env);
 
   JNIWrapper("jni_NewDirectByteBuffer");
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, NewDirectByteBuffer__entry, env, address, capacity);
+#else /* USDT2 */
+ HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_ENTRY(
+                                       env, address, capacity);
+#endif /* USDT2 */
 
   if (!directBufferSupportInitializeEnded) {
     if (!initializeDirectBufferSupport(env, thread)) {
+#ifndef USDT2
       DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, NULL);
+#else /* USDT2 */
+      HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN(
+                                             NULL);
+#endif /* USDT2 */
       return NULL;
     }
   }
@@ -2806,11 +4499,21 @@
   // takes int capacity
   jint  cap  = (jint)  capacity;
   jobject ret = env->NewObject(directByteBufferClass, directByteBufferConstructor, addr, cap);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN(
+                                         ret);
+#endif /* USDT2 */
   return ret;
 }
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(GetDirectBufferAddress, void*);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(GetDirectBufferAddress, void*
+                    , HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_RETURN((void*) _ret_ref));
+#endif /* USDT2 */
 
 extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 {
@@ -2818,7 +4521,12 @@
   JavaThread* thread = JavaThread::thread_from_jni_environment(env);
 
   JNIWrapper("jni_GetDirectBufferAddress");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetDirectBufferAddress__entry, env, buf);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_ENTRY(
+                                           env, buf);
+#endif /* USDT2 */
   void* ret = NULL;
   DT_RETURN_MARK(GetDirectBufferAddress, void*, (const void*&)ret);
 
@@ -2836,7 +4544,12 @@
   return ret;
 }
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong
+                    , HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf)
 {
@@ -2844,7 +4557,12 @@
   JavaThread* thread = JavaThread::thread_from_jni_environment(env);
 
   JNIWrapper("jni_GetDirectBufferCapacity");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetDirectBufferCapacity__entry, env, buf);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_ENTRY(
+                                            env, buf);
+#endif /* USDT2 */
   jlong ret = -1;
   DT_RETURN_MARK(GetDirectBufferCapacity, jlong, (const jlong&)ret);
 
@@ -2871,8 +4589,18 @@
 
 JNI_LEAF(jint, jni_GetVersion(JNIEnv *env))
   JNIWrapper("GetVersion");
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetVersion__entry, env);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETVERSION_ENTRY(
+                               env);
+#endif /* USDT2 */
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetVersion__return, CurrentVersion);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETVERSION_RETURN(
+                                CurrentVersion);
+#endif /* USDT2 */
   return CurrentVersion;
 JNI_END
 
@@ -2880,9 +4608,19 @@
 
 JNI_LEAF(jint, jni_GetJavaVM(JNIEnv *env, JavaVM **vm))
   JNIWrapper("jni_GetJavaVM");
+#ifndef USDT2
   DTRACE_PROBE2(hotspot_jni, GetJavaVM__entry, env, vm);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETJAVAVM_ENTRY(
+                              env, (void **) vm);
+#endif /* USDT2 */
   *vm  = (JavaVM *)(&main_vm);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, GetJavaVM__return, JNI_OK);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETJAVAVM_RETURN(
+                               JNI_OK);
+#endif /* USDT2 */
   return JNI_OK;
 JNI_END
 
@@ -3262,11 +5000,21 @@
 #define JAVASTACKSIZE (400 * 1024)    /* Default size of a thread java stack */
 enum { VERIFY_NONE, VERIFY_REMOTE, VERIFY_ALL };
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, void*);
 DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint
+                    , HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) {
+#ifndef USDT2
   HS_DTRACE_PROBE1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, args_);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_ENTRY(
+                                             args_);
+#endif /* USDT2 */
   JDK1_1InitArgs *args = (JDK1_1InitArgs *)args_;
   jint ret = JNI_ERR;
   DT_RETURN_MARK(GetDefaultJavaVMInitArgs, jint, (const jint&)ret);
@@ -3300,11 +5048,21 @@
 
 #endif
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL3(hotspot_jni, CreateJavaVM__entry, vm, penv, args);
 DT_RETURN_MARK_DECL(CreateJavaVM, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(CreateJavaVM, jint
+                    , HOTSPOT_JNI_CREATEJAVAVM_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) {
+#ifndef USDT2
   HS_DTRACE_PROBE3(hotspot_jni, CreateJavaVM__entry, vm, penv, args);
+#else /* USDT2 */
+  HOTSPOT_JNI_CREATEJAVAVM_ENTRY(
+                                 (void **) vm, penv, args);
+#endif /* USDT2 */
 
   jint result = JNI_ERR;
   DT_RETURN_MARK(CreateJavaVM, jint, (const jint&)result);
@@ -3394,31 +5152,53 @@
   return result;
 }
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL3(hotspot_jni, GetCreatedJavaVMs__entry, \
   JavaVM**, jsize, jsize*);
 HS_DTRACE_PROBE_DECL1(hotspot_jni, GetCreatedJavaVMs__return, jint);
+#endif /* !USDT2 */
 
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **vm_buf, jsize bufLen, jsize *numVMs) {
   // See bug 4367188, the wrapper can sometimes cause VM crashes
   // JNIWrapper("GetCreatedJavaVMs");
+#ifndef USDT2
   HS_DTRACE_PROBE3(hotspot_jni, GetCreatedJavaVMs__entry, \
     vm_buf, bufLen, numVMs);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETCREATEDJAVAVMS_ENTRY(
+                                      (void **) vm_buf, bufLen, (uintptr_t *) numVMs);
+#endif /* USDT2 */
   if (vm_created) {
     if (numVMs != NULL) *numVMs = 1;
     if (bufLen > 0)     *vm_buf = (JavaVM *)(&main_vm);
   } else {
     if (numVMs != NULL) *numVMs = 0;
   }
+#ifndef USDT2
   HS_DTRACE_PROBE1(hotspot_jni, GetCreatedJavaVMs__return, JNI_OK);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETCREATEDJAVAVMS_RETURN(
+                                    JNI_OK);
+#endif /* USDT2 */
   return JNI_OK;
 }
 
 extern "C" {
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(DestroyJavaVM, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(DestroyJavaVM, jint
+                    , HOTSPOT_JNI_DESTROYJAVAVM_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 jint JNICALL jni_DestroyJavaVM(JavaVM *vm) {
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, DestroyJavaVM__entry, vm);
+#else /* USDT2 */
+  HOTSPOT_JNI_DESTROYJAVAVM_ENTRY(
+                                  vm);
+#endif /* USDT2 */
   jint res = JNI_ERR;
   DT_RETURN_MARK(DestroyJavaVM, jint, (const jint&)res);
 
@@ -3536,7 +5316,7 @@
   // mark the thread as no longer attaching
   // this uses a fence to push the change through so we don't have
   // to regrab the threads_lock
-  thread->set_attached();
+  thread->set_done_attaching_via_jni();
 
   // Set java thread status.
   java_lang_Thread::set_thread_status(thread->threadObj(),
@@ -3564,34 +5344,64 @@
 
 
 jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) {
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, AttachCurrentThread__entry, vm, penv, _args);
+#else /* USDT2 */
+  HOTSPOT_JNI_ATTACHCURRENTTHREAD_ENTRY(
+                                        vm, penv, _args);
+#endif /* USDT2 */
   if (!vm_created) {
+#ifndef USDT2
     DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, JNI_ERR);
+#else /* USDT2 */
+  HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN(
+                                         (uint32_t) JNI_ERR);
+#endif /* USDT2 */
     return JNI_ERR;
   }
 
   JNIWrapper("AttachCurrentThread");
   jint ret = attach_current_thread(vm, penv, _args, false);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN(
+                                         ret);
+#endif /* USDT2 */
   return ret;
 }
 
 
 jint JNICALL jni_DetachCurrentThread(JavaVM *vm)  {
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__entry, vm);
+#else /* USDT2 */
+  HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY(
+                                        vm);
+#endif /* USDT2 */
   VM_Exit::block_if_vm_exited();
 
   JNIWrapper("DetachCurrentThread");
 
   // If the thread has been deattacted the operations is a no-op
   if (ThreadLocalStorage::thread() == NULL) {
+#ifndef USDT2
     DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK);
+#else /* USDT2 */
+  HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(
+                                         JNI_OK);
+#endif /* USDT2 */
     return JNI_OK;
   }
 
   JavaThread* thread = JavaThread::current();
   if (thread->has_last_Java_frame()) {
+#ifndef USDT2
     DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_ERR);
+#else /* USDT2 */
+  HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(
+                                         (uint32_t) JNI_ERR);
+#endif /* USDT2 */
     // Can't detach a thread that's running java, that can't work.
     return JNI_ERR;
   }
@@ -3612,14 +5422,29 @@
   thread->exit(false, JavaThread::jni_detach);
   delete thread;
 
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK);
+#else /* USDT2 */
+  HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(
+                                         JNI_OK);
+#endif /* USDT2 */
   return JNI_OK;
 }
 
+#ifndef USDT2
 DT_RETURN_MARK_DECL(GetEnv, jint);
+#else /* USDT2 */
+DT_RETURN_MARK_DECL(GetEnv, jint
+                    , HOTSPOT_JNI_GETENV_RETURN(_ret_ref));
+#endif /* USDT2 */
 
 jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) {
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, GetEnv__entry, vm, penv, version);
+#else /* USDT2 */
+  HOTSPOT_JNI_GETENV_ENTRY(
+                           vm, penv, version);
+#endif /* USDT2 */
   jint ret = JNI_ERR;
   DT_RETURN_MARK(GetEnv, jint, (const jint&)ret);
 
@@ -3674,15 +5499,30 @@
 
 
 jint JNICALL jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *_args) {
+#ifndef USDT2
   DTRACE_PROBE3(hotspot_jni, AttachCurrentThreadAsDaemon__entry, vm, penv, _args);
+#else /* USDT2 */
+  HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_ENTRY(
+                                                vm, penv, _args);
+#endif /* USDT2 */
   if (!vm_created) {
+#ifndef USDT2
     DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, JNI_ERR);
+#else /* USDT2 */
+  HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN(
+                                                 (uint32_t) JNI_ERR);
+#endif /* USDT2 */
     return JNI_ERR;
   }
 
   JNIWrapper("AttachCurrentThreadAsDaemon");
   jint ret = attach_current_thread(vm, penv, _args, true);
+#ifndef USDT2
   DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, ret);
+#else /* USDT2 */
+  HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN(
+                                                 ret);
+#endif /* USDT2 */
   return ret;
 }
 
--- a/hotspot/src/share/vm/prims/jvm.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -32,6 +32,7 @@
 #include "gc_interface/collectedHeap.inline.hpp"
 #include "memory/oopFactory.hpp"
 #include "memory/universe.inline.hpp"
+#include "oops/fieldStreams.hpp"
 #include "oops/instanceKlass.hpp"
 #include "oops/objArrayKlass.hpp"
 #include "prims/jvm.h"
@@ -72,12 +73,17 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "jvm_windows.h"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "jvm_bsd.h"
+#endif
 
 #include <errno.h>
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__begin, long long);
 HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__end, int);
 HS_DTRACE_PROBE_DECL0(hotspot, thread__yield);
+#endif /* !USDT2 */
 
 /*
   NOTE about use of any ctor or function call that can trigger a safepoint/GC:
@@ -1493,7 +1499,7 @@
 
   fieldDescriptor fd;
   KlassHandle kh(THREAD, k);
-  intptr_t offset = instanceKlass::cast(kh())->offset_from_fields(slot);
+  intptr_t offset = instanceKlass::cast(kh())->field_offset(slot);
 
   if (modifiers & JVM_ACC_STATIC) {
     // for static fields we only look in the current class
@@ -1593,9 +1599,6 @@
   // Ensure class is linked
   k->link_class(CHECK_NULL);
 
-  typeArrayHandle fields(THREAD, k->fields());
-  int fields_len = fields->length();
-
   // 4496456 We need to filter out java.lang.Throwable.backtrace
   bool skip_backtrace = false;
 
@@ -1604,12 +1607,11 @@
 
   if (publicOnly) {
     num_fields = 0;
-    for (int i = 0, j = 0; i < fields_len; i += instanceKlass::next_offset, j++) {
-      int mods = fields->ushort_at(i + instanceKlass::access_flags_offset) & JVM_RECOGNIZED_FIELD_MODIFIERS;
-      if (mods & JVM_ACC_PUBLIC) ++num_fields;
+    for (JavaFieldStream fs(k()); !fs.done(); fs.next()) {
+      if (fs.access_flags().is_public()) ++num_fields;
     }
   } else {
-    num_fields = fields_len / instanceKlass::next_offset;
+    num_fields = k->java_fields_count();
 
     if (k() == SystemDictionary::Throwable_klass()) {
       num_fields--;
@@ -1622,16 +1624,15 @@
 
   int out_idx = 0;
   fieldDescriptor fd;
-  for (int i = 0; i < fields_len; i += instanceKlass::next_offset) {
+  for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
     if (skip_backtrace) {
       // 4496456 skip java.lang.Throwable.backtrace
-      int offset = k->offset_from_fields(i);
+      int offset = fs.offset();
       if (offset == java_lang_Throwable::get_backtrace_offset()) continue;
     }
 
-    int mods = fields->ushort_at(i + instanceKlass::access_flags_offset) & JVM_RECOGNIZED_FIELD_MODIFIERS;
-    if (!publicOnly || (mods & JVM_ACC_PUBLIC)) {
-      fd.initialize(k(), i);
+    if (!publicOnly || fs.access_flags().is_public()) {
+      fd.initialize(k(), fs.index());
       oop field = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL);
       result->obj_at_put(out_idx, field);
       ++out_idx;
@@ -2119,7 +2120,7 @@
   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
   if (!Klass::cast(k)->oop_is_instance())
     return 0;
-  return instanceKlass::cast(k)->fields()->length() / instanceKlass::next_offset;
+  return instanceKlass::cast(k)->java_fields_count();
 JVM_END
 
 
@@ -2215,8 +2216,7 @@
   JVMWrapper("JVM_GetFieldIxModifiers");
   klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls));
   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
-  typeArrayOop fields = instanceKlass::cast(k)->fields();
-  return fields->ushort_at(field_index * instanceKlass::next_offset + instanceKlass::access_flags_offset) & JVM_RECOGNIZED_FIELD_MODIFIERS;
+  return instanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS;
 JVM_END
 
 
@@ -2399,7 +2399,7 @@
 JVM_END
 
 
-JVM_QUICK_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls))
+JVM_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls))
   JVMWrapper("JVM_GetCPFieldModifiers");
   klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls));
   klassOop k_called = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(called_cls));
@@ -2411,12 +2411,9 @@
     case JVM_CONSTANT_Fieldref: {
       Symbol* name      = cp->uncached_name_ref_at(cp_index);
       Symbol* signature = cp->uncached_signature_ref_at(cp_index);
-      typeArrayOop fields = instanceKlass::cast(k_called)->fields();
-      int fields_count = fields->length();
-      for (int i = 0; i < fields_count; i += instanceKlass::next_offset) {
-        if (cp_called->symbol_at(fields->ushort_at(i + instanceKlass::name_index_offset)) == name &&
-            cp_called->symbol_at(fields->ushort_at(i + instanceKlass::signature_index_offset)) == signature) {
-          return fields->ushort_at(i + instanceKlass::access_flags_offset) & JVM_RECOGNIZED_FIELD_MODIFIERS;
+      for (JavaFieldStream fs(k_called); !fs.done(); fs.next()) {
+        if (fs.name() == name && fs.signature() == signature) {
+          return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS;
         }
       }
       return -1;
@@ -2821,7 +2818,11 @@
 JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass))
   JVMWrapper("JVM_Yield");
   if (os::dont_yield()) return;
+#ifndef USDT2
   HS_DTRACE_PROBE0(hotspot, thread__yield);
+#else /* USDT2 */
+  HOTSPOT_THREAD_YIELD();
+#endif /* USDT2 */
   // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield.
   // Critical for similar threading behaviour
   if (ConvertYieldToSleep) {
@@ -2847,7 +2848,12 @@
   // And set new thread state to SLEEPING.
   JavaThreadSleepState jtss(thread);
 
+#ifndef USDT2
   HS_DTRACE_PROBE1(hotspot, thread__sleep__begin, millis);
+#else /* USDT2 */
+  HOTSPOT_THREAD_SLEEP_BEGIN(
+                             millis);
+#endif /* USDT2 */
 
   if (millis == 0) {
     // When ConvertSleepToYield is on, this matches the classic VM implementation of
@@ -2869,7 +2875,12 @@
       // An asynchronous exception (e.g., ThreadDeathException) could have been thrown on
       // us while we were sleeping. We do not overwrite those.
       if (!HAS_PENDING_EXCEPTION) {
+#ifndef USDT2
         HS_DTRACE_PROBE1(hotspot, thread__sleep__end,1);
+#else /* USDT2 */
+        HOTSPOT_THREAD_SLEEP_END(
+                                 1);
+#endif /* USDT2 */
         // TODO-FIXME: THROW_MSG returns which means we will not call set_state()
         // to properly restore the thread state.  That's likely wrong.
         THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted");
@@ -2877,7 +2888,12 @@
     }
     thread->osthread()->set_state(old_state);
   }
+#ifndef USDT2
   HS_DTRACE_PROBE1(hotspot, thread__sleep__end,0);
+#else /* USDT2 */
+  HOTSPOT_THREAD_SLEEP_END(
+                           0);
+#endif /* USDT2 */
 JVM_END
 
 JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass))
@@ -2995,6 +3011,20 @@
   }
 JVM_END
 
+JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
+  JVMWrapper("JVM_SetNativeThreadName");
+  ResourceMark rm(THREAD);
+  oop java_thread = JNIHandles::resolve_non_null(jthread);
+  JavaThread* thr = java_lang_Thread::thread(java_thread);
+  // Thread naming only supported for the current thread, doesn't work for
+  // target threads.
+  if (Thread::current() == thr && !thr->has_attached_via_jni()) {
+    // we don't set the name of an attached thread to avoid stepping
+    // on other programs
+    const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
+    os::set_native_thread_name(thread_name);
+  }
+JVM_END
 
 // java.lang.SecurityManager ///////////////////////////////////////////////////////////////////////
 
@@ -4020,249 +4050,6 @@
 #endif
 
 
-//---------------------------------------------------------------------------
-//
-// Support for old native code-based reflection (pre-JDK 1.4)
-// Disabled by default in the product build.
-//
-// See reflection.hpp for information on SUPPORT_OLD_REFLECTION
-//
-//---------------------------------------------------------------------------
-
-#ifdef SUPPORT_OLD_REFLECTION
-
-JVM_ENTRY(jobjectArray, JVM_GetClassFields(JNIEnv *env, jclass cls, jint which))
-  JVMWrapper("JVM_GetClassFields");
-  JvmtiVMObjectAllocEventCollector oam;
-  oop mirror = JNIHandles::resolve_non_null(cls);
-  objArrayOop result = Reflection::reflect_fields(mirror, which, CHECK_NULL);
-  return (jobjectArray) JNIHandles::make_local(env, result);
-JVM_END
-
-
-JVM_ENTRY(jobjectArray, JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which))
-  JVMWrapper("JVM_GetClassMethods");
-  JvmtiVMObjectAllocEventCollector oam;
-  oop mirror = JNIHandles::resolve_non_null(cls);
-  objArrayOop result = Reflection::reflect_methods(mirror, which, CHECK_NULL);
-  //%note jvm_r4
-  return (jobjectArray) JNIHandles::make_local(env, result);
-JVM_END
-
-
-JVM_ENTRY(jobjectArray, JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which))
-  JVMWrapper("JVM_GetClassConstructors");
-  JvmtiVMObjectAllocEventCollector oam;
-  oop mirror = JNIHandles::resolve_non_null(cls);
-  objArrayOop result = Reflection::reflect_constructors(mirror, which, CHECK_NULL);
-  //%note jvm_r4
-  return (jobjectArray) JNIHandles::make_local(env, result);
-JVM_END
-
-
-JVM_ENTRY(jobject, JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which))
-  JVMWrapper("JVM_GetClassField");
-  JvmtiVMObjectAllocEventCollector oam;
-  if (name == NULL) return NULL;
-  Handle str (THREAD, JNIHandles::resolve_non_null(name));
-
-  const char* cstr = java_lang_String::as_utf8_string(str());
-  TempNewSymbol field_name = SymbolTable::probe(cstr, (int)strlen(cstr));
-  if (field_name == NULL) {
-    THROW_0(vmSymbols::java_lang_NoSuchFieldException());
-  }
-
-  oop mirror = JNIHandles::resolve_non_null(cls);
-  oop result = Reflection::reflect_field(mirror, field_name, which, CHECK_NULL);
-  if (result == NULL) {
-    THROW_0(vmSymbols::java_lang_NoSuchFieldException());
-  }
-  return JNIHandles::make_local(env, result);
-JVM_END
-
-
-JVM_ENTRY(jobject, JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, jint which))
-  JVMWrapper("JVM_GetClassMethod");
-  JvmtiVMObjectAllocEventCollector oam;
-  if (name == NULL) {
-    THROW_0(vmSymbols::java_lang_NullPointerException());
-  }
-  Handle str (THREAD, JNIHandles::resolve_non_null(name));
-
-  const char* cstr = java_lang_String::as_utf8_string(str());
-  TempNewSymbol method_name = SymbolTable::probe(cstr, (int)strlen(cstr));
-  if (method_name == NULL) {
-    THROW_0(vmSymbols::java_lang_NoSuchMethodException());
-  }
-
-  oop mirror = JNIHandles::resolve_non_null(cls);
-  objArrayHandle tarray (THREAD, objArrayOop(JNIHandles::resolve(types)));
-  oop result = Reflection::reflect_method(mirror, method_name, tarray,
-                                          which, CHECK_NULL);
-  if (result == NULL) {
-    THROW_0(vmSymbols::java_lang_NoSuchMethodException());
-  }
-  return JNIHandles::make_local(env, result);
-JVM_END
-
-
-JVM_ENTRY(jobject, JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, jint which))
-  JVMWrapper("JVM_GetClassConstructor");
-  JvmtiVMObjectAllocEventCollector oam;
-  oop mirror = JNIHandles::resolve_non_null(cls);
-  objArrayHandle tarray (THREAD, objArrayOop(JNIHandles::resolve(types)));
-  oop result = Reflection::reflect_constructor(mirror, tarray, which, CHECK_NULL);
-  if (result == NULL) {
-    THROW_0(vmSymbols::java_lang_NoSuchMethodException());
-  }
-  return (jobject) JNIHandles::make_local(env, result);
-JVM_END
-
-
-// Instantiation ///////////////////////////////////////////////////////////////////////////////
-
-JVM_ENTRY(jobject, JVM_NewInstance(JNIEnv *env, jclass cls))
-  JVMWrapper("JVM_NewInstance");
-  Handle mirror(THREAD, JNIHandles::resolve_non_null(cls));
-
-  methodOop resolved_constructor = java_lang_Class::resolved_constructor(mirror());
-  if (resolved_constructor == NULL) {
-    klassOop k = java_lang_Class::as_klassOop(mirror());
-    // The java.lang.Class object caches a resolved constructor if all the checks
-    // below were done successfully and a constructor was found.
-
-    // Do class based checks
-    if (java_lang_Class::is_primitive(mirror())) {
-      const char* msg = "";
-      if      (mirror == Universe::bool_mirror())   msg = "java/lang/Boolean";
-      else if (mirror == Universe::char_mirror())   msg = "java/lang/Character";
-      else if (mirror == Universe::float_mirror())  msg = "java/lang/Float";
-      else if (mirror == Universe::double_mirror()) msg = "java/lang/Double";
-      else if (mirror == Universe::byte_mirror())   msg = "java/lang/Byte";
-      else if (mirror == Universe::short_mirror())  msg = "java/lang/Short";
-      else if (mirror == Universe::int_mirror())    msg = "java/lang/Integer";
-      else if (mirror == Universe::long_mirror())   msg = "java/lang/Long";
-      THROW_MSG_0(vmSymbols::java_lang_NullPointerException(), msg);
-    }
-
-    // Check whether we are allowed to instantiate this class
-    Klass::cast(k)->check_valid_for_instantiation(false, CHECK_NULL); // Array classes get caught here
-    instanceKlassHandle klass(THREAD, k);
-    // Make sure class is initialized (also so all methods are rewritten)
-    klass->initialize(CHECK_NULL);
-
-    // Lookup default constructor
-    resolved_constructor = klass->find_method(vmSymbols::object_initializer_name(), vmSymbols::void_method_signature());
-    if (resolved_constructor == NULL) {
-      ResourceMark rm(THREAD);
-      THROW_MSG_0(vmSymbols::java_lang_InstantiationException(), klass->external_name());
-    }
-
-    // Cache result in java.lang.Class object. Does not have to be MT safe.
-    java_lang_Class::set_resolved_constructor(mirror(), resolved_constructor);
-  }
-
-  assert(resolved_constructor != NULL, "sanity check");
-  methodHandle constructor = methodHandle(THREAD, resolved_constructor);
-
-  // We have an initialized instanceKlass with a default constructor
-  instanceKlassHandle klass(THREAD, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)));
-  assert(klass->is_initialized() || klass->is_being_initialized(), "sanity check");
-
-  // Do security check
-  klassOop caller_klass = NULL;
-  if (UsePrivilegedStack) {
-    caller_klass = thread->security_get_caller_class(2);
-
-    if (!Reflection::verify_class_access(caller_klass, klass(), false) ||
-        !Reflection::verify_field_access(caller_klass,
-                                         klass(),
-                                         klass(),
-                                         constructor->access_flags(),
-                                         false,
-                                         true)) {
-      ResourceMark rm(THREAD);
-      THROW_MSG_0(vmSymbols::java_lang_IllegalAccessException(), klass->external_name());
-    }
-  }
-
-  // Allocate object and call constructor
-  Handle receiver = klass->allocate_instance_handle(CHECK_NULL);
-  JavaCalls::call_default_constructor(thread, constructor, receiver, CHECK_NULL);
-
-  jobject res = JNIHandles::make_local(env, receiver());
-  if (JvmtiExport::should_post_vm_object_alloc()) {
-    JvmtiExport::post_vm_object_alloc(JavaThread::current(), receiver());
-  }
-  return res;
-JVM_END
-
-
-// Field ////////////////////////////////////////////////////////////////////////////////////////////
-
-JVM_ENTRY(jobject, JVM_GetField(JNIEnv *env, jobject field, jobject obj))
-  JVMWrapper("JVM_GetField");
-  JvmtiVMObjectAllocEventCollector oam;
-  Handle field_mirror(thread, JNIHandles::resolve(field));
-  Handle receiver    (thread, JNIHandles::resolve(obj));
-  fieldDescriptor fd;
-  Reflection::resolve_field(field_mirror, receiver, &fd, false, CHECK_NULL);
-  jvalue value;
-  BasicType type = Reflection::field_get(&value, &fd, receiver);
-  oop box = Reflection::box(&value, type, CHECK_NULL);
-  return JNIHandles::make_local(env, box);
-JVM_END
-
-
-JVM_ENTRY(jvalue, JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, unsigned char wCode))
-  JVMWrapper("JVM_GetPrimitiveField");
-  Handle field_mirror(thread, JNIHandles::resolve(field));
-  Handle receiver    (thread, JNIHandles::resolve(obj));
-  fieldDescriptor fd;
-  jvalue value;
-  value.j = 0;
-  Reflection::resolve_field(field_mirror, receiver, &fd, false, CHECK_(value));
-  BasicType type = Reflection::field_get(&value, &fd, receiver);
-  BasicType wide_type = (BasicType) wCode;
-  if (type != wide_type) {
-    Reflection::widen(&value, type, wide_type, CHECK_(value));
-  }
-  return value;
-JVM_END // should really be JVM_END, but that doesn't work for union types!
-
-
-JVM_ENTRY(void, JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val))
-  JVMWrapper("JVM_SetField");
-  Handle field_mirror(thread, JNIHandles::resolve(field));
-  Handle receiver    (thread, JNIHandles::resolve(obj));
-  oop box = JNIHandles::resolve(val);
-  fieldDescriptor fd;
-  Reflection::resolve_field(field_mirror, receiver, &fd, true, CHECK);
-  BasicType field_type = fd.field_type();
-  jvalue value;
-  BasicType value_type;
-  if (field_type == T_OBJECT || field_type == T_ARRAY) {
-    // Make sure we do no unbox e.g. java/lang/Integer instances when storing into an object array
-    value_type = Reflection::unbox_for_regular_object(box, &value);
-    Reflection::field_set(&value, &fd, receiver, field_type, CHECK);
-  } else {
-    value_type = Reflection::unbox_for_primitive(box, &value, CHECK);
-    Reflection::field_set(&value, &fd, receiver, value_type, CHECK);
-  }
-JVM_END
-
-
-JVM_ENTRY(void, JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, unsigned char vCode))
-  JVMWrapper("JVM_SetPrimitiveField");
-  Handle field_mirror(thread, JNIHandles::resolve(field));
-  Handle receiver    (thread, JNIHandles::resolve(obj));
-  fieldDescriptor fd;
-  Reflection::resolve_field(field_mirror, receiver, &fd, true, CHECK);
-  BasicType value_type = (BasicType) vCode;
-  Reflection::field_set(&v, &fd, receiver, value_type, CHECK);
-JVM_END
-
-
 // Method ///////////////////////////////////////////////////////////////////////////////////////////
 
 JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0))
@@ -4302,8 +4089,6 @@
   return res;
 JVM_END
 
-#endif /* SUPPORT_OLD_REFLECTION */
-
 // Atomic ///////////////////////////////////////////////////////////////////////////////////////////
 
 JVM_LEAF(jboolean, JVM_SupportsCX8())
--- a/hotspot/src/share/vm/prims/jvm.h	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvm.h	Wed Oct 26 17:59:13 2011 -0700
@@ -26,7 +26,6 @@
 #define SHARE_VM_PRIMS_JVM_H
 
 #include "prims/jni.h"
-#include "runtime/reflectionCompat.hpp"
 #ifdef TARGET_OS_FAMILY_linux
 # include "jvm_linux.h"
 #endif
@@ -36,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "jvm_windows.h"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "jvm_bsd.h"
+#endif
 
 #ifndef _JAVASOFT_JVM_H_
 #define _JAVASOFT_JVM_H_
@@ -43,8 +45,7 @@
 // HotSpot integration note:
 //
 // This file and jvm.h used with the JDK are identical,
-// except for the three includes removed below and the
-// SUPPORT_OLD_REFLECTION sections cut out of the JDK's jvm.h.
+// except for the three includes removed below
 
 // #include <sys/stat.h>
 // #include "jni.h"
@@ -290,6 +291,9 @@
 JNIEXPORT jobjectArray JNICALL
 JVM_GetAllThreads(JNIEnv *env, jclass dummy);
 
+JNIEXPORT void JNICALL
+JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name);
+
 /* getStackTrace() and getAllStackTraces() method */
 JNIEXPORT jobjectArray JNICALL
 JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
@@ -443,14 +447,6 @@
                               jsize len, jobject pd, const char *source,
                               jboolean verify);
 
-/* Define a class with a source (MLVM) */
-JNIEXPORT jclass JNICALL
-JVM_DefineClassWithCP(JNIEnv *env, const char *name, jobject loader,
-                      const jbyte *buf, jsize len, jobject pd,
-                      const char *source,
-                      // same args as JVM_DefineClassWithSource to this point
-                      jobjectArray constants);
-
 /*
  * Reflection support functions
  */
@@ -1442,65 +1438,6 @@
 JNIEXPORT void JNICALL
 JVM_RawMonitorExit(void *mon);
 
-
-#ifdef SUPPORT_OLD_REFLECTION
-
-/*
- * Support for old native code-based (pre-JDK 1.4) reflection implementation.
- * Disabled by default in the product build.
- *
- * See reflection.hpp for information on SUPPORT_OLD_REFLECTION
- */
-
-/*
- * reflecting fields and methods.
- * which: 0 --- MEMBER_PUBLIC
- *        1 --- MEMBER_DECLARED
- * NOTE: absent in product build by default
- */
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassFields(JNIEnv *env, jclass cls, jint which);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which);
-
-JNIEXPORT jobjectArray JNICALL
-JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which);
-
-JNIEXPORT jobject JNICALL
-JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which);
-
-JNIEXPORT jobject JNICALL
-JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types,
-                   jint which);
-JNIEXPORT jobject JNICALL
-JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types,
-                        jint which);
-
-/*
- * Implements Class.newInstance
- */
-JNIEXPORT jobject JNICALL
-JVM_NewInstance(JNIEnv *env, jclass cls);
-
-/*
- * java.lang.reflect.Field
- */
-JNIEXPORT jobject JNICALL
-JVM_GetField(JNIEnv *env, jobject field, jobject obj);
-
-JNIEXPORT jvalue JNICALL
-JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj,
-                      unsigned char wCode);
-
-JNIEXPORT void JNICALL
-JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val);
-
-JNIEXPORT void JNICALL
-JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v,
-                      unsigned char vCode);
-
 /*
  * java.lang.reflect.Method
  */
@@ -1513,8 +1450,6 @@
 JNIEXPORT jobject JNICALL
 JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0);
 
-#endif /* SUPPORT_OLD_REFLECTION */
-
 /*
  * java.lang.management support
  */
@@ -1650,7 +1585,8 @@
      */
     unsigned int thread_park_blocker : 1;
     unsigned int post_vm_init_hook_enabled : 1;
-    unsigned int : 30;
+    unsigned int pending_list_uses_discovered_field : 1;
+    unsigned int : 29;
     unsigned int : 32;
     unsigned int : 32;
 } jdk_version_info;
--- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/symbolTable.hpp"
 #include "interpreter/bytecodeStream.hpp"
+#include "oops/fieldStreams.hpp"
 #include "prims/jvmtiClassFileReconstituter.hpp"
 #include "runtime/signature.hpp"
 #ifdef TARGET_ARCH_x86
@@ -52,25 +53,22 @@
 // JVMSpec|     field_info fields[fields_count];
 void JvmtiClassFileReconstituter::write_field_infos() {
   HandleMark hm(thread());
-  typeArrayHandle fields(thread(), ikh()->fields());
-  int fields_length = fields->length();
-  int num_fields = fields_length / instanceKlass::next_offset;
   objArrayHandle fields_anno(thread(), ikh()->fields_annotations());
 
-  write_u2(num_fields);
-  for (int index = 0; index < fields_length; index += instanceKlass::next_offset) {
-    AccessFlags access_flags;
-    int flags = fields->ushort_at(index + instanceKlass::access_flags_offset);
-    access_flags.set_flags(flags);
-    int name_index = fields->ushort_at(index + instanceKlass::name_index_offset);
-    int signature_index = fields->ushort_at(index + instanceKlass::signature_index_offset);
-    int initial_value_index = fields->ushort_at(index + instanceKlass::initval_index_offset);
+  // Compute the real number of Java fields
+  int java_fields = ikh()->java_fields_count();
+
+  write_u2(java_fields);
+  for (JavaFieldStream fs(ikh()); !fs.done(); fs.next()) {
+    AccessFlags access_flags = fs.access_flags();
+    int name_index = fs.name_index();
+    int signature_index = fs.signature_index();
+    int initial_value_index = fs.initval_index();
     guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field");
-    int offset = ikh()->offset_from_fields( index );
-    int generic_signature_index =
-                        fields->ushort_at(index + instanceKlass::generic_signature_offset);
+    // int offset = ikh()->field_offset( index );
+    int generic_signature_index = fs.generic_signature_index();
     typeArrayHandle anno(thread(), fields_anno.not_null() ?
-                                 (typeArrayOop)(fields_anno->obj_at(index / instanceKlass::next_offset)) :
+                                 (typeArrayOop)(fields_anno->obj_at(fs.index())) :
                                  (typeArrayOop)NULL);
 
     // JVMSpec|   field_info {
@@ -81,7 +79,7 @@
     // JVMSpec|         attribute_info attributes[attributes_count];
     // JVMSpec|   }
 
-    write_u2(flags & JVM_RECOGNIZED_FIELD_MODIFIERS);
+    write_u2(access_flags.as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS);
     write_u2(name_index);
     write_u2(signature_index);
     int attr_count = 0;
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -68,6 +68,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 
@@ -2044,7 +2047,6 @@
   // make sure we haven't set this watch before
   if (fdesc_ptr->is_field_access_watched()) return JVMTI_ERROR_DUPLICATE;
   fdesc_ptr->set_is_field_access_watched(true);
-  update_klass_field_access_flag(fdesc_ptr);
 
   JvmtiEventController::change_field_watch(JVMTI_EVENT_FIELD_ACCESS, true);
 
@@ -2057,7 +2059,6 @@
   // make sure we have a watch to clear
   if (!fdesc_ptr->is_field_access_watched()) return JVMTI_ERROR_NOT_FOUND;
   fdesc_ptr->set_is_field_access_watched(false);
-  update_klass_field_access_flag(fdesc_ptr);
 
   JvmtiEventController::change_field_watch(JVMTI_EVENT_FIELD_ACCESS, false);
 
@@ -2070,7 +2071,6 @@
   // make sure we haven't set this watch before
   if (fdesc_ptr->is_field_modification_watched()) return JVMTI_ERROR_DUPLICATE;
   fdesc_ptr->set_is_field_modification_watched(true);
-  update_klass_field_access_flag(fdesc_ptr);
 
   JvmtiEventController::change_field_watch(JVMTI_EVENT_FIELD_MODIFICATION, true);
 
@@ -2083,7 +2083,6 @@
    // make sure we have a watch to clear
   if (!fdesc_ptr->is_field_modification_watched()) return JVMTI_ERROR_NOT_FOUND;
   fdesc_ptr->set_is_field_modification_watched(false);
-  update_klass_field_access_flag(fdesc_ptr);
 
   JvmtiEventController::change_field_watch(JVMTI_EVENT_FIELD_MODIFICATION, false);
 
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -565,15 +565,6 @@
 }
 
 
-// update the access_flags for the field in the klass
-void
-JvmtiEnvBase::update_klass_field_access_flag(fieldDescriptor *fd) {
-  instanceKlass* ik = instanceKlass::cast(fd->field_holder());
-  typeArrayOop fields = ik->fields();
-  fields->ushort_at_put(fd->index(), (jushort)fd->access_flags().as_short());
-}
-
-
 // return the vframe on the specified thread and depth, NULL if no such frame
 vframe*
 JvmtiEnvBase::vframeFor(JavaThread* java_thread, jint depth) {
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -267,8 +267,6 @@
   // convert to a jni jclass from a non-null klassOop
   jclass get_jni_class_non_null(klassOop k);
 
-  void update_klass_field_access_flag(fieldDescriptor *fd);
-
   jint count_locked_objects(JavaThread *java_thread, Handle hobj);
   jvmtiError get_locked_objects_in_frame(JavaThread *calling_thread,
                                    JavaThread* java_thread,
--- a/hotspot/src/share/vm/prims/jvmtiExport.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiExport.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -66,6 +66,7 @@
 // This class contains the JVMTI interface for the rest of hotspot.
 //
 class JvmtiExport : public AllStatic {
+  friend class VMStructs;
  private:
   static int         _field_access_count;
   static int         _field_modification_count;
--- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -54,6 +54,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //
 // class JvmtiAgentThread
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -30,6 +30,7 @@
 #include "interpreter/rewriter.hpp"
 #include "memory/gcLocker.hpp"
 #include "memory/universe.inline.hpp"
+#include "oops/fieldStreams.hpp"
 #include "oops/klassVtable.hpp"
 #include "prims/jvmtiImpl.hpp"
 #include "prims/jvmtiRedefineClasses.hpp"
@@ -551,41 +552,35 @@
 
   // Check if the number, names, types and order of fields declared in these classes
   // are the same.
-  typeArrayOop k_old_fields = the_class->fields();
-  typeArrayOop k_new_fields = scratch_class->fields();
-  int n_fields = k_old_fields->length();
-  if (n_fields != k_new_fields->length()) {
-    return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
-  }
-
-  for (i = 0; i < n_fields; i += instanceKlass::next_offset) {
+  JavaFieldStream old_fs(the_class);
+  JavaFieldStream new_fs(scratch_class);
+  for (; !old_fs.done() && !new_fs.done(); old_fs.next(), new_fs.next()) {
     // access
-    old_flags = k_old_fields->ushort_at(i + instanceKlass::access_flags_offset);
-    new_flags = k_new_fields->ushort_at(i + instanceKlass::access_flags_offset);
+    old_flags = old_fs.access_flags().as_short();
+    new_flags = new_fs.access_flags().as_short();
     if ((old_flags ^ new_flags) & JVM_RECOGNIZED_FIELD_MODIFIERS) {
       return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
     }
     // offset
-    if (k_old_fields->short_at(i + instanceKlass::low_offset) !=
-        k_new_fields->short_at(i + instanceKlass::low_offset) ||
-        k_old_fields->short_at(i + instanceKlass::high_offset) !=
-        k_new_fields->short_at(i + instanceKlass::high_offset)) {
+    if (old_fs.offset() != new_fs.offset()) {
       return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
     }
     // name and signature
-    jshort name_index = k_old_fields->short_at(i + instanceKlass::name_index_offset);
-    jshort sig_index = k_old_fields->short_at(i +instanceKlass::signature_index_offset);
-    Symbol* name_sym1 = the_class->constants()->symbol_at(name_index);
-    Symbol* sig_sym1 = the_class->constants()->symbol_at(sig_index);
-    name_index = k_new_fields->short_at(i + instanceKlass::name_index_offset);
-    sig_index = k_new_fields->short_at(i + instanceKlass::signature_index_offset);
-    Symbol* name_sym2 = scratch_class->constants()->symbol_at(name_index);
-    Symbol* sig_sym2 = scratch_class->constants()->symbol_at(sig_index);
+    Symbol* name_sym1 = the_class->constants()->symbol_at(old_fs.name_index());
+    Symbol* sig_sym1 = the_class->constants()->symbol_at(old_fs.signature_index());
+    Symbol* name_sym2 = scratch_class->constants()->symbol_at(new_fs.name_index());
+    Symbol* sig_sym2 = scratch_class->constants()->symbol_at(new_fs.signature_index());
     if (name_sym1 != name_sym2 || sig_sym1 != sig_sym2) {
       return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
     }
   }
 
+  // If both streams aren't done then we have a differing number of
+  // fields.
+  if (!old_fs.done() || !new_fs.done()) {
+    return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
+  }
+
   // Do a parallel walk through the old and new methods. Detect
   // cases where they match (exist in both), have been added in
   // the new methods, or have been deleted (exist only in the
@@ -2369,38 +2364,34 @@
   int i;  // for portability
 
   // update each field in klass to use new constant pool indices as needed
-  typeArrayHandle fields(THREAD, scratch_class->fields());
-  int n_fields = fields->length();
-  for (i = 0; i < n_fields; i += instanceKlass::next_offset) {
-    jshort cur_index = fields->short_at(i + instanceKlass::name_index_offset);
+  for (JavaFieldStream fs(scratch_class); !fs.done(); fs.next()) {
+    jshort cur_index = fs.name_index();
     jshort new_index = find_new_index(cur_index);
     if (new_index != 0) {
       RC_TRACE_WITH_THREAD(0x00080000, THREAD,
         ("field-name_index change: %d to %d", cur_index, new_index));
-      fields->short_at_put(i + instanceKlass::name_index_offset, new_index);
+      fs.set_name_index(new_index);
     }
-    cur_index = fields->short_at(i + instanceKlass::signature_index_offset);
+    cur_index = fs.signature_index();
     new_index = find_new_index(cur_index);
     if (new_index != 0) {
       RC_TRACE_WITH_THREAD(0x00080000, THREAD,
         ("field-signature_index change: %d to %d", cur_index, new_index));
-      fields->short_at_put(i + instanceKlass::signature_index_offset,
-        new_index);
+      fs.set_signature_index(new_index);
     }
-    cur_index = fields->short_at(i + instanceKlass::initval_index_offset);
+    cur_index = fs.initval_index();
     new_index = find_new_index(cur_index);
     if (new_index != 0) {
       RC_TRACE_WITH_THREAD(0x00080000, THREAD,
         ("field-initval_index change: %d to %d", cur_index, new_index));
-      fields->short_at_put(i + instanceKlass::initval_index_offset, new_index);
+      fs.set_initval_index(new_index);
     }
-    cur_index = fields->short_at(i + instanceKlass::generic_signature_offset);
+    cur_index = fs.generic_signature_index();
     new_index = find_new_index(cur_index);
     if (new_index != 0) {
       RC_TRACE_WITH_THREAD(0x00080000, THREAD,
         ("field-generic_signature change: %d to %d", cur_index, new_index));
-      fields->short_at_put(i + instanceKlass::generic_signature_offset,
-        new_index);
+      fs.set_generic_signature_index(new_index);
     }
   } // end for each field
 
--- a/hotspot/src/share/vm/prims/methodHandleWalk.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/methodHandleWalk.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -182,10 +182,6 @@
   HandleMark hm;
   ResourceMark rm;
   Handle mh(m);
-  print(mh);
-}
-
-void MethodHandleChain::print(Handle mh) {
   EXCEPTION_MARK;
   MethodHandleChain mhc(mh, THREAD);
   if (HAS_PENDING_EXCEPTION) {
@@ -222,16 +218,33 @@
       if (o != NULL) {
         if (o->is_instance()) {
           tty->print(" instance %s", o->klass()->klass_part()->internal_name());
+          if (java_lang_invoke_CountingMethodHandle::is_instance(o)) {
+            tty->print(" vmcount: %d", java_lang_invoke_CountingMethodHandle::vmcount(o));
+          }
         } else {
           o->print();
         }
       }
+      oop vmt = chain.vmtarget_oop();
+      if (vmt != NULL) {
+        if (vmt->is_method()) {
+          tty->print(" ");
+          methodOop(vmt)->print_short_name(tty);
+        } else if (java_lang_invoke_MethodHandle::is_instance(vmt)) {
+          tty->print(" method handle " INTPTR_FORMAT, vmt);
+        } else {
+          ShouldNotReachHere();
+        }
+      }
     } else if (chain.is_adapter()) {
       tty->print("adapter: arg_slot %d conversion op %s",
                  chain.adapter_arg_slot(),
                  adapter_op_to_string(chain.adapter_conversion_op()));
       switch (chain.adapter_conversion_op()) {
         case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY:
+          if (java_lang_invoke_CountingMethodHandle::is_instance(chain.method_handle_oop())) {
+            tty->print(" vmcount: %d", java_lang_invoke_CountingMethodHandle::vmcount(chain.method_handle_oop()));
+          }
         case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW:
         case java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST:
         case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM:
@@ -907,7 +920,10 @@
     _non_bcp_klasses(THREAD, 5),
     _cur_stack(0),
     _max_stack(0),
-    _rtype(T_ILLEGAL)
+    _rtype(T_ILLEGAL),
+    _selectAlternative_bci(-1),
+    _taken_count(0),
+    _not_taken_count(0)
 {
 
   // Element zero is always the null constant.
@@ -1115,11 +1131,50 @@
     _bytecode.push(0);
     break;
 
+  case Bytecodes::_ifeq:
+    assert((unsigned short) index == index, "index does not fit in 16-bit");
+    _bytecode.push(op);
+    _bytecode.push(index >> 8);
+    _bytecode.push(index);
+    break;
+
   default:
     ShouldNotReachHere();
   }
 }
 
+void MethodHandleCompiler::update_branch_dest(int src, int dst) {
+  switch (_bytecode.at(src)) {
+    case Bytecodes::_ifeq:
+      dst -= src; // compute the offset
+      assert((unsigned short) dst == dst, "index does not fit in 16-bit");
+      _bytecode.at_put(src + 1, dst >> 8);
+      _bytecode.at_put(src + 2, dst);
+      break;
+    default:
+      ShouldNotReachHere();
+  }
+}
+
+void MethodHandleCompiler::emit_load(ArgToken arg) {
+  TokenType tt = arg.token_type();
+  BasicType bt = arg.basic_type();
+
+  switch (tt) {
+    case tt_parameter:
+    case tt_temporary:
+      emit_load(bt, arg.index());
+      break;
+    case tt_constant:
+      emit_load_constant(arg);
+      break;
+    case tt_illegal:
+    case tt_void:
+    default:
+      ShouldNotReachHere();
+  }
+}
+
 
 void MethodHandleCompiler::emit_load(BasicType bt, int index) {
   if (index <= 3) {
@@ -1318,6 +1373,27 @@
 jvalue MethodHandleCompiler::zero_jvalue = { 0 };
 jvalue MethodHandleCompiler::one_jvalue  = { 1 };
 
+// Fetch any values from CountingMethodHandles and capture them for profiles
+bool MethodHandleCompiler::fetch_counts(ArgToken arg1, ArgToken arg2) {
+  int count1 = -1, count2 = -1;
+  if (arg1.token_type() == tt_constant && arg1.basic_type() == T_OBJECT &&
+      java_lang_invoke_CountingMethodHandle::is_instance(arg1.object()())) {
+    count1 = java_lang_invoke_CountingMethodHandle::vmcount(arg1.object()());
+  }
+  if (arg2.token_type() == tt_constant && arg2.basic_type() == T_OBJECT &&
+      java_lang_invoke_CountingMethodHandle::is_instance(arg2.object()())) {
+    count2 = java_lang_invoke_CountingMethodHandle::vmcount(arg2.object()());
+  }
+  int total = count1 + count2;
+  if (count1 != -1 && count2 != -1 && total != 0) {
+    // Normalize the collect counts to the invoke_count
+    if (count1 != 0) _not_taken_count = (int)(_invoke_count * count1 / (double)total);
+    if (count2 != 0) _taken_count = (int)(_invoke_count * count2 / (double)total);
+    return true;
+  }
+  return false;
+}
+
 // Emit bytecodes for the given invoke instruction.
 MethodHandleWalker::ArgToken
 MethodHandleCompiler::make_invoke(methodHandle m, vmIntrinsics::ID iid,
@@ -1367,6 +1443,29 @@
     }
   }
 
+  if (m->intrinsic_id() == vmIntrinsics::_selectAlternative &&
+      fetch_counts(argv[1], argv[2])) {
+    assert(argc == 3, "three arguments");
+    assert(tailcall, "only");
+
+    // do inline bytecodes so we can drop profile data into it,
+    //   0:   iload_0
+    emit_load(argv[0]);
+    //   1:   ifeq    8
+    _selectAlternative_bci = _bytecode.length();
+    emit_bc(Bytecodes::_ifeq, 0); // emit placeholder offset
+    //   4:   aload_1
+    emit_load(argv[1]);
+    //   5:   areturn;
+    emit_bc(Bytecodes::_areturn);
+    //   8:   aload_2
+    update_branch_dest(_selectAlternative_bci, cur_bci());
+    emit_load(argv[2]);
+    //   9:   areturn
+    emit_bc(Bytecodes::_areturn);
+    return ArgToken();  // Dummy return value.
+  }
+
   check_non_bcp_klass(klass, CHECK_(zero));
   if (m->is_method_handle_invoke()) {
     check_non_bcp_klasses(m->method_handle_type(), CHECK_(zero));
@@ -1377,10 +1476,6 @@
   assert(argc == asc.size() + ((op == Bytecodes::_invokestatic || op == Bytecodes::_invokedynamic) ? 0 : 1),
          "argc mismatch");
 
-  // Inline the method.
-  InvocationCounter* ic = m->invocation_counter();
-  ic->set_carry_flag();
-
   for (int i = 0; i < argc; i++) {
     ArgToken arg = argv[i];
     TokenType tt = arg.token_type();
@@ -1686,7 +1781,7 @@
 }
 
 
-methodHandle MethodHandleCompiler::get_method_oop(TRAPS) const {
+methodHandle MethodHandleCompiler::get_method_oop(TRAPS) {
   methodHandle empty;
   // Create a method that holds the generated bytecode.  invokedynamic
   // has no receiver, normal MH calls do.
@@ -1765,6 +1860,7 @@
     assert(m->method_data() == NULL, "there should not be an MDO yet");
     m->set_method_data(mdo);
 
+    bool found_selectAlternative = false;
     // Iterate over all profile data and set the count of the counter
     // data entries to the original call site counter.
     for (ProfileData* profile_data = mdo->first_data();
@@ -1774,7 +1870,15 @@
         CounterData* counter_data = profile_data->as_CounterData();
         counter_data->set_count(_invoke_count);
       }
+      if (profile_data->is_BranchData() &&
+          profile_data->bci() == _selectAlternative_bci) {
+        BranchData* bd = profile_data->as_BranchData();
+        bd->set_taken(_taken_count);
+        bd->set_not_taken(_not_taken_count);
+        found_selectAlternative = true;
+      }
     }
+    assert(_selectAlternative_bci == -1 || found_selectAlternative, "must have found profile entry");
   }
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/prims/methodHandleWalk.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/methodHandleWalk.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -74,6 +74,7 @@
     set_method_handle(MethodHandle_vmtarget_oop(), THREAD);
   }
 
+  Handle root()                 { return _root; }
   Handle method_handle()        { return _method_handle; }
   oop    method_handle_oop()    { return _method_handle(); }
   oop    method_type_oop()      { return MethodHandle_type_oop(); }
@@ -110,7 +111,6 @@
   // the signature for each method.  The signatures are printed in
   // slot order to make it easier to understand.
   void print();
-  static void print(Handle mh);
   static void print(oopDesc* mh);
 #endif
 };
@@ -277,6 +277,10 @@
   KlassHandle  _target_klass;
   Thread*      _thread;
 
+  int          _selectAlternative_bci; // These are used for capturing profiles from GWTs
+  int          _taken_count;
+  int          _not_taken_count;
+
   // Values used by the compiler.
   static jvalue zero_jvalue;
   static jvalue one_jvalue;
@@ -372,6 +376,7 @@
 
   unsigned char* bytecode()        const { return _bytecode.adr_at(0); }
   int            bytecode_length() const { return _bytecode.length(); }
+  int            cur_bci()         const { return _bytecode.length(); }
 
   // Fake constant pool.
   int cpool_oop_put(int tag, Handle con) {
@@ -436,6 +441,8 @@
   }
 
   void emit_bc(Bytecodes::Code op, int index = 0, int args_size = -1);
+  void update_branch_dest(int src, int dst);
+  void emit_load(ArgToken arg);
   void emit_load(BasicType bt, int index);
   void emit_store(BasicType bt, int index);
   void emit_load_constant(ArgToken arg);
@@ -455,11 +462,14 @@
   virtual ArgToken make_fetch(BasicType type, klassOop tk, Bytecodes::Code op, const ArgToken& base, const ArgToken& offset, TRAPS);
   virtual ArgToken make_invoke(methodHandle m, vmIntrinsics::ID iid, Bytecodes::Code op, bool tailcall, int argc, ArgToken* argv, TRAPS);
 
+  // Check for profiling information on a GWT and return true if it's found
+  bool fetch_counts(ArgToken a1, ArgToken a2);
+
   // Get a real constant pool.
   constantPoolHandle get_constant_pool(TRAPS) const;
 
   // Get a real methodOop.
-  methodHandle get_method_oop(TRAPS) const;
+  methodHandle get_method_oop(TRAPS);
 
 public:
   MethodHandleCompiler(Handle root, Symbol* name, Symbol* signature, int invoke_count, bool for_invokedynamic, TRAPS);
--- a/hotspot/src/share/vm/prims/methodHandles.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/methodHandles.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -158,6 +158,8 @@
   "adapter_fold/4/ref",
   "adapter_fold/5/ref",
 
+  "adapter_opt_profiling",
+
   NULL
 };
 
@@ -518,7 +520,7 @@
     int slot  = java_lang_reflect_Field::slot(target_oop);  // fd.index()
     int mods  = java_lang_reflect_Field::modifiers(target_oop);
     klassOop k = java_lang_Class::as_klassOop(clazz);
-    int offset = instanceKlass::cast(k)->offset_from_fields(slot);
+    int offset = instanceKlass::cast(k)->field_offset(slot);
     init_MemberName(mname_oop, k, accessFlags_from(mods), offset);
   } else {
     KlassHandle receiver_limit; int decode_flags = 0;
@@ -1630,8 +1632,6 @@
     THROW(vmSymbols::java_lang_InternalError());
   }
 
-  java_lang_invoke_MethodHandle::init_vmslots(mh());
-
   if (VerifyMethodHandles) {
     // The privileged code which invokes this routine should not make
     // a mistake about types, but it's better to verify.
@@ -1754,7 +1754,6 @@
   if (m.is_null())      { THROW(vmSymbols::java_lang_InternalError()); }
   if (m->is_abstract()) { THROW(vmSymbols::java_lang_AbstractMethodError()); }
 
-  java_lang_invoke_MethodHandle::init_vmslots(mh());
   int vmargslot = m->size_of_parameters() - 1;
   assert(java_lang_invoke_BoundMethodHandle::vmargslot(mh()) == vmargslot, "");
 
@@ -1860,7 +1859,6 @@
     THROW(vmSymbols::java_lang_InternalError());
   }
 
-  java_lang_invoke_MethodHandle::init_vmslots(mh());
   int argslot = java_lang_invoke_BoundMethodHandle::vmargslot(mh());
 
   if (VerifyMethodHandles) {
@@ -2653,6 +2651,11 @@
   // Finalize the conversion field.  (Note that it is final to Java code.)
   java_lang_invoke_AdapterMethodHandle::set_conversion(mh(), new_conversion);
 
+  if (java_lang_invoke_CountingMethodHandle::is_instance(mh())) {
+    assert(ek_orig == _adapter_retype_only, "only one handled");
+    ek_opt = _adapter_opt_profiling;
+  }
+
   // Done!
   java_lang_invoke_MethodHandle::set_vmentry(mh(), entry(ek_opt));
 
@@ -2679,6 +2682,7 @@
       java_lang_invoke_MethodTypeForm::init_vmlayout(mtform(), cookie);
     }
   }
+  assert(java_lang_invoke_MethodTypeForm::vmslots(mtform()) == argument_slot_count(mtype()), "must agree");
 }
 
 #ifdef ASSERT
@@ -2905,8 +2909,12 @@
     return MethodHandles::stack_move_unit();
   case MethodHandles::GC_CONV_OP_IMPLEMENTED_MASK:
     return MethodHandles::adapter_conversion_ops_supported_mask();
-  case MethodHandles::GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS:
-    return MethodHandles::OP_ROT_ARGS_DOWN_LIMIT_BIAS;
+  case MethodHandles::GC_COUNT_GWT:
+#ifdef COMPILER2
+    return true;
+#else
+    return false;
+#endif
   }
   return 0;
 }
@@ -3070,6 +3078,30 @@
 }
 JVM_END
 
+JVM_ENTRY(void, MHN_setCallSiteTargetNormal(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) {
+  oop call_site = JNIHandles::resolve_non_null(call_site_jh);
+  oop target    = JNIHandles::resolve(target_jh);
+  {
+    // Walk all nmethods depending on this call site.
+    MutexLocker mu(Compile_lock, thread);
+    Universe::flush_dependents_on(call_site, target);
+  }
+  java_lang_invoke_CallSite::set_target(call_site, target);
+}
+JVM_END
+
+JVM_ENTRY(void, MHN_setCallSiteTargetVolatile(JNIEnv* env, jobject igcls, jobject call_site_jh, jobject target_jh)) {
+  oop call_site = JNIHandles::resolve_non_null(call_site_jh);
+  oop target    = JNIHandles::resolve(target_jh);
+  {
+    // Walk all nmethods depending on this call site.
+    MutexLocker mu(Compile_lock, thread);
+    Universe::flush_dependents_on(call_site, target);
+  }
+  java_lang_invoke_CallSite::set_target_volatile(call_site, target);
+}
+JVM_END
+
 methodOop MethodHandles::resolve_raise_exception_method(TRAPS) {
   if (_raise_exception_method != NULL) {
     // no need to do it twice
@@ -3126,12 +3158,15 @@
 
 /// JVM_RegisterMethodHandleMethods
 
+#undef CS  // Solaris builds complain
+
 #define LANG "Ljava/lang/"
 #define JLINV "Ljava/lang/invoke/"
 
 #define OBJ   LANG"Object;"
 #define CLS   LANG"Class;"
 #define STRG  LANG"String;"
+#define CS    JLINV"CallSite;"
 #define MT    JLINV"MethodType;"
 #define MH    JLINV"MethodHandle;"
 #define MEM   JLINV"MemberName;"
@@ -3142,29 +3177,34 @@
 #define CC (char*)  /*cast a literal from (const char*)*/
 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 
-// These are the native methods on sun.invoke.MethodHandleNatives.
+// These are the native methods on java.lang.invoke.MethodHandleNatives.
 static JNINativeMethod methods[] = {
   // void init(MemberName self, AccessibleObject ref)
-  {CC"init",                    CC"("AMH""MH"I)V",              FN_PTR(MHN_init_AMH)},
-  {CC"init",                    CC"("BMH""OBJ"I)V",             FN_PTR(MHN_init_BMH)},
-  {CC"init",                    CC"("DMH""OBJ"Z"CLS")V",        FN_PTR(MHN_init_DMH)},
-  {CC"init",                    CC"("MT")V",                    FN_PTR(MHN_init_MT)},
-  {CC"init",                    CC"("MEM""OBJ")V",              FN_PTR(MHN_init_Mem)},
-  {CC"expand",                  CC"("MEM")V",                   FN_PTR(MHN_expand_Mem)},
-  {CC"resolve",                 CC"("MEM""CLS")V",              FN_PTR(MHN_resolve_Mem)},
-  {CC"getTarget",               CC"("MH"I)"OBJ,                 FN_PTR(MHN_getTarget)},
-  {CC"getConstant",             CC"(I)I",                       FN_PTR(MHN_getConstant)},
+  {CC"init",                      CC"("AMH""MH"I)V",                     FN_PTR(MHN_init_AMH)},
+  {CC"init",                      CC"("BMH""OBJ"I)V",                    FN_PTR(MHN_init_BMH)},
+  {CC"init",                      CC"("DMH""OBJ"Z"CLS")V",               FN_PTR(MHN_init_DMH)},
+  {CC"init",                      CC"("MT")V",                           FN_PTR(MHN_init_MT)},
+  {CC"init",                      CC"("MEM""OBJ")V",                     FN_PTR(MHN_init_Mem)},
+  {CC"expand",                    CC"("MEM")V",                          FN_PTR(MHN_expand_Mem)},
+  {CC"resolve",                   CC"("MEM""CLS")V",                     FN_PTR(MHN_resolve_Mem)},
+  {CC"getTarget",                 CC"("MH"I)"OBJ,                        FN_PTR(MHN_getTarget)},
+  {CC"getConstant",               CC"(I)I",                              FN_PTR(MHN_getConstant)},
   //  static native int getNamedCon(int which, Object[] name)
-  {CC"getNamedCon",             CC"(I["OBJ")I",                 FN_PTR(MHN_getNamedCon)},
+  {CC"getNamedCon",               CC"(I["OBJ")I",                        FN_PTR(MHN_getNamedCon)},
   //  static native int getMembers(Class<?> defc, String matchName, String matchSig,
   //          int matchFlags, Class<?> caller, int skip, MemberName[] results);
-  {CC"getMembers",              CC"("CLS""STRG""STRG"I"CLS"I["MEM")I",  FN_PTR(MHN_getMembers)}
+  {CC"getMembers",                CC"("CLS""STRG""STRG"I"CLS"I["MEM")I", FN_PTR(MHN_getMembers)}
+};
+
+static JNINativeMethod call_site_methods[] = {
+  {CC"setCallSiteTargetNormal",   CC"("CS""MH")V",                       FN_PTR(MHN_setCallSiteTargetNormal)},
+  {CC"setCallSiteTargetVolatile", CC"("CS""MH")V",                       FN_PTR(MHN_setCallSiteTargetVolatile)}
 };
 
 static JNINativeMethod invoke_methods[] = {
   // void init(MemberName self, AccessibleObject ref)
-  {CC"invoke",                  CC"(["OBJ")"OBJ,                FN_PTR(MH_invoke_UOE)},
-  {CC"invokeExact",             CC"(["OBJ")"OBJ,                FN_PTR(MH_invokeExact_UOE)}
+  {CC"invoke",                    CC"(["OBJ")"OBJ,                       FN_PTR(MH_invoke_UOE)},
+  {CC"invokeExact",               CC"(["OBJ")"OBJ,                       FN_PTR(MH_invokeExact_UOE)}
 };
 
 // This one function is exported, used by NativeLookup.
@@ -3177,11 +3217,11 @@
     return;  // bind nothing
   }
 
+  assert(!MethodHandles::enabled(), "must not be enabled");
   bool enable_MH = true;
 
   {
     ThreadToNativeFromVM ttnfv(thread);
-
     int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod));
     if (!env->ExceptionOccurred()) {
       const char* L_MH_name = (JLINV "MethodHandle");
@@ -3190,11 +3230,16 @@
       status = env->RegisterNatives(MH_class, invoke_methods, sizeof(invoke_methods)/sizeof(JNINativeMethod));
     }
     if (env->ExceptionOccurred()) {
-      MethodHandles::set_enabled(false);
       warning("JSR 292 method handle code is mismatched to this JVM.  Disabling support.");
       enable_MH = false;
       env->ExceptionClear();
     }
+
+    status = env->RegisterNatives(MHN_class, call_site_methods, sizeof(call_site_methods)/sizeof(JNINativeMethod));
+    if (env->ExceptionOccurred()) {
+      // Exception is okay until 7087357
+      env->ExceptionClear();
+    }
   }
 
   if (enable_MH) {
--- a/hotspot/src/share/vm/prims/methodHandles.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/methodHandles.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -187,6 +187,8 @@
     _adapter_opt_fold_FIRST = _adapter_opt_fold_ref,
     _adapter_opt_fold_LAST  = _adapter_opt_fold_5_ref,
 
+    _adapter_opt_profiling,
+
     _EK_LIMIT,
     _EK_FIRST = 0
   };
@@ -266,6 +268,8 @@
       return _adapter_fold_args;
     if (ek >= _adapter_opt_return_FIRST && ek <= _adapter_opt_return_LAST)
       return _adapter_opt_return_any;
+    if (ek == _adapter_opt_profiling)
+      return _adapter_retype_only;
     assert(false, "oob");
     return _EK_LIMIT;
   }
@@ -511,11 +515,12 @@
   }
   // Here is the transformation the i2i adapter must perform:
   static int truncate_subword_from_vminfo(jint value, int vminfo) {
-    jint tem = value << vminfo;
+    int shift = vminfo & ~CONV_VMINFO_SIGN_FLAG;
+    jint tem = value << shift;
     if ((vminfo & CONV_VMINFO_SIGN_FLAG) != 0) {
-      return (jint)tem >> vminfo;
+      return (jint)tem >> shift;
     } else {
-      return (juint)tem >> vminfo;
+      return (juint)tem >> shift;
     }
   }
 
@@ -582,6 +587,7 @@
     GC_JVM_STACK_MOVE_UNIT = 1,
     GC_CONV_OP_IMPLEMENTED_MASK = 2,
     GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS = 3,
+    GC_COUNT_GWT = 4,
 
     // format of result from getTarget / encode_target:
     ETF_HANDLE_OR_METHOD_NAME = 0, // all available data (immediate MH or method)
--- a/hotspot/src/share/vm/prims/nativeLookup.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/nativeLookup.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -49,6 +49,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 static void mangle_name_on(outputStream* st, Symbol* name, int begin, int end) {
--- a/hotspot/src/share/vm/prims/unsafe.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/prims/unsafe.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -33,7 +33,6 @@
 #include "runtime/globals.hpp"
 #include "runtime/interfaceSupport.hpp"
 #include "runtime/reflection.hpp"
-#include "runtime/reflectionCompat.hpp"
 #include "runtime/synchronizer.hpp"
 #include "services/threadService.hpp"
 #include "utilities/copy.hpp"
@@ -43,9 +42,11 @@
  *      Implementation of class sun.misc.Unsafe
  */
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL3(hotspot, thread__park__begin, uintptr_t, int, long long);
 HS_DTRACE_PROBE_DECL1(hotspot, thread__park__end, uintptr_t);
 HS_DTRACE_PROBE_DECL1(hotspot, thread__unpark, uintptr_t);
+#endif /* !USDT2 */
 
 #define MAX_OBJECT_SIZE \
   ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \
@@ -303,6 +304,19 @@
   UnsafeWrapper("Unsafe_SetObjectVolatile");
   oop x = JNIHandles::resolve(x_h);
   oop p = JNIHandles::resolve(obj);
+  // Catch VolatileCallSite.target stores (via
+  // CallSite.setTargetVolatile) and check call site dependencies.
+  if ((offset == java_lang_invoke_CallSite::target_offset_in_bytes()) && p->is_a(SystemDictionary::CallSite_klass())) {
+    oop call_site     = p;
+    oop method_handle = x;
+    assert(call_site    ->is_a(SystemDictionary::CallSite_klass()),     "must be");
+    assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "must be");
+    {
+      // Walk all nmethods depending on this call site.
+      MutexLocker mu(Compile_lock, thread);
+      Universe::flush_dependents_on(call_site, method_handle);
+    }
+  }
   void* addr = index_oop_from_field_offset_long(p, offset);
   OrderAccess::release();
   if (UseCompressedOops) {
@@ -707,7 +721,7 @@
     }
   }
 
-  int offset = instanceKlass::cast(k)->offset_from_fields(slot);
+  int offset = instanceKlass::cast(k)->field_offset(slot);
   return field_offset_from_byte_offset(offset);
 }
 
@@ -1175,10 +1189,20 @@
 
 UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time))
   UnsafeWrapper("Unsafe_Park");
+#ifndef USDT2
   HS_DTRACE_PROBE3(hotspot, thread__park__begin, thread->parker(), (int) isAbsolute, time);
+#else /* USDT2 */
+   HOTSPOT_THREAD_PARK_BEGIN(
+                             (uintptr_t) thread->parker(), (int) isAbsolute, time);
+#endif /* USDT2 */
   JavaThreadParkedState jtps(thread, time != 0);
   thread->parker()->park(isAbsolute != 0, time);
+#ifndef USDT2
   HS_DTRACE_PROBE1(hotspot, thread__park__end, thread->parker());
+#else /* USDT2 */
+  HOTSPOT_THREAD_PARK_END(
+                          (uintptr_t) thread->parker());
+#endif /* USDT2 */
 UNSAFE_END
 
 UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread))
@@ -1210,7 +1234,12 @@
     }
   }
   if (p != NULL) {
+#ifndef USDT2
     HS_DTRACE_PROBE1(hotspot, thread__unpark, p);
+#else /* USDT2 */
+    HOTSPOT_THREAD_UNPARK(
+                          (uintptr_t) p);
+#endif /* USDT2 */
     p->unpark();
   }
 UNSAFE_END
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -46,6 +46,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
 #endif
@@ -1423,6 +1426,9 @@
     if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
       FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
     }
+    // For those collectors or operating systems (eg, Windows) that do
+    // not support full UseNUMA, we will map to UseNUMAInterleaving for now
+    UseNUMAInterleaving = true;
   }
 }
 
@@ -2596,16 +2602,16 @@
       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
       FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
     } else if (match_option(option, "-XX:+ExtendedDTraceProbes", &tail)) {
-#ifdef SOLARIS
+#if defined(DTRACE_ENABLED)
       FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
       FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
       FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
       FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
-#else // ndef SOLARIS
+#else // defined(DTRACE_ENABLED)
       jio_fprintf(defaultStream::error_stream(),
-                  "ExtendedDTraceProbes flag is only applicable on Solaris\n");
+                  "ExtendedDTraceProbes flag is not applicable for this configuration\n");
       return JNI_EINVAL;
-#endif // ndef SOLARIS
+#endif // defined(DTRACE_ENABLED)
 #ifdef ASSERT
     } else if (match_option(option, "-XX:+FullGCALot", &tail)) {
       FLAG_SET_CMDLINE(bool, FullGCALot, true);
@@ -3018,9 +3024,6 @@
   }
 
 #ifdef JAVASE_EMBEDDED
-  #ifdef PPC
-    UNSUPPORTED_OPTION(EnableInvokeDynamic, "Invoke dynamic");
-  #endif
   UNSUPPORTED_OPTION(UseG1GC, "G1 GC");
 #endif
 
--- a/hotspot/src/share/vm/runtime/atomic.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/atomic.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -33,6 +33,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 #ifdef TARGET_OS_ARCH_linux_x86
 # include "atomic_linux_x86.inline.hpp"
 #endif
@@ -57,6 +60,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "atomic_linux_ppc.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "atomic_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "atomic_bsd_zero.inline.hpp"
+#endif
 
 jbyte Atomic::cmpxchg(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value) {
   assert(sizeof(jbyte) == 1, "assumption.");
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -103,7 +103,7 @@
   _frame_pcs                 = frame_pcs;
   _register_block            = NEW_C_HEAP_ARRAY(intptr_t, RegisterMap::reg_count * 2);
   _return_type               = return_type;
-  _initial_fp                = 0;
+  _initial_info              = 0;
   // PD (x86 only)
   _counter_temp              = 0;
   _unpack_kind               = 0;
@@ -486,9 +486,10 @@
                                       frame_sizes,
                                       frame_pcs,
                                       return_type);
-  // On some platforms, we need a way to pass fp to the unpacking code
-  // so the skeletal frames come out correct.
-  info->set_initial_fp((intptr_t) array->sender().fp());
+  // On some platforms, we need a way to pass some platform dependent
+  // information to the unpacking code so the skeletal frames come out
+  // correct (initial fp value, unextended sp, ...)
+  info->set_initial_info((intptr_t) array->sender().initial_deoptimization_info());
 
   if (array->frames() > 1) {
     if (VerifyStack && TraceDeoptimization) {
--- a/hotspot/src/share/vm/runtime/deoptimization.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/deoptimization.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -34,6 +34,8 @@
 class ObjectValue;
 
 class Deoptimization : AllStatic {
+  friend class VMStructs;
+
  public:
   // What condition caused the deoptimization?
   enum DeoptReason {
@@ -137,7 +139,7 @@
     address*  _frame_pcs;                 // Array of frame pc's, in bytes, for unrolling the stack
     intptr_t* _register_block;            // Block for storing callee-saved registers.
     BasicType _return_type;               // Tells if we have to restore double or long return value
-    intptr_t  _initial_fp;                // FP of the sender frame
+    intptr_t  _initial_info;              // Platform dependent data for the sender frame (was FP on x86)
     int       _caller_actual_parameters;  // The number of actual arguments at the
                                           // interpreted caller of the deoptimized frame
 
@@ -170,7 +172,7 @@
     // Returns the total size of frames
     int size_of_frames() const;
 
-    void set_initial_fp(intptr_t fp) { _initial_fp = fp; }
+    void set_initial_info(intptr_t info) { _initial_info = info; }
 
     int caller_actual_parameters() const { return _caller_actual_parameters; }
 
@@ -184,7 +186,7 @@
     static int register_block_offset_in_bytes()            { return offset_of(UnrollBlock, _register_block);            }
     static int return_type_offset_in_bytes()               { return offset_of(UnrollBlock, _return_type);               }
     static int counter_temp_offset_in_bytes()              { return offset_of(UnrollBlock, _counter_temp);              }
-    static int initial_fp_offset_in_bytes()                { return offset_of(UnrollBlock, _initial_fp);                }
+    static int initial_info_offset_in_bytes()              { return offset_of(UnrollBlock, _initial_info);              }
     static int unpack_kind_offset_in_bytes()               { return offset_of(UnrollBlock, _unpack_kind);               }
     static int sender_sp_temp_offset_in_bytes()            { return offset_of(UnrollBlock, _sender_sp_temp);            }
 
--- a/hotspot/src/share/vm/runtime/fieldDescriptor.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/fieldDescriptor.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -42,59 +42,51 @@
   objArrayOop md = ik->fields_annotations();
   if (md == NULL)
     return NULL;
-  assert((index() % instanceKlass::next_offset) == 0, "");
-  return typeArrayOop(md->obj_at(index() / instanceKlass::next_offset));
+  return typeArrayOop(md->obj_at(index()));
 }
 
 constantTag fieldDescriptor::initial_value_tag() const {
-  return constants()->tag_at(_initial_value_index);
+  return constants()->tag_at(initial_value_index());
 }
 
 jint fieldDescriptor::int_initial_value() const {
-  return constants()->int_at(_initial_value_index);
+  return constants()->int_at(initial_value_index());
 }
 
 jlong fieldDescriptor::long_initial_value() const {
-  return constants()->long_at(_initial_value_index);
+  return constants()->long_at(initial_value_index());
 }
 
 jfloat fieldDescriptor::float_initial_value() const {
-  return constants()->float_at(_initial_value_index);
+  return constants()->float_at(initial_value_index());
 }
 
 jdouble fieldDescriptor::double_initial_value() const {
-  return constants()->double_at(_initial_value_index);
+  return constants()->double_at(initial_value_index());
 }
 
 oop fieldDescriptor::string_initial_value(TRAPS) const {
-  return constants()->string_at(_initial_value_index, CHECK_0);
+  return constants()->string_at(initial_value_index(), CHECK_0);
 }
 
 void fieldDescriptor::initialize(klassOop k, int index) {
   instanceKlass* ik = instanceKlass::cast(k);
   _cp = ik->constants();
-  typeArrayOop fields = ik->fields();
-
-  assert(fields->length() % instanceKlass::next_offset == 0, "Illegal size of field array");
-  assert(fields->length() >= index + instanceKlass::next_offset, "Illegal size of field array");
+  FieldInfo* f = ik->field(index);
+  assert(!f->is_internal(), "regular Java fields only");
 
-  _access_flags.set_field_flags(fields->ushort_at(index + instanceKlass::access_flags_offset));
-  _name_index = fields->ushort_at(index + instanceKlass::name_index_offset);
-  _signature_index = fields->ushort_at(index + instanceKlass::signature_index_offset);
-  _initial_value_index = fields->ushort_at(index + instanceKlass::initval_index_offset);
-  guarantee(_name_index != 0 && _signature_index != 0, "bad constant pool index for fieldDescriptor");
-  _offset = ik->offset_from_fields( index );
-  _generic_signature_index = fields->ushort_at(index + instanceKlass::generic_signature_offset);
+  _access_flags = accessFlags_from(f->access_flags());
+  guarantee(f->name_index() != 0 && f->signature_index() != 0, "bad constant pool index for fieldDescriptor");
   _index = index;
 }
 
 #ifndef PRODUCT
 
 void fieldDescriptor::print_on(outputStream* st) const {
-  _access_flags.print_on(st);
-  constants()->symbol_at(_name_index)->print_value_on(st);
+  access_flags().print_on(st);
+  name()->print_value_on(st);
   st->print(" ");
-  constants()->symbol_at(_signature_index)->print_value_on(st);
+  signature()->print_value_on(st);
   st->print(" @%d ", offset());
   if (WizardMode && has_initial_value()) {
     st->print("(initval ");
--- a/hotspot/src/share/vm/runtime/fieldDescriptor.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/fieldDescriptor.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -40,29 +40,40 @@
 class fieldDescriptor VALUE_OBJ_CLASS_SPEC {
  private:
   AccessFlags         _access_flags;
-  int                 _name_index;
-  int                 _signature_index;
-  int                 _initial_value_index;
-  int                 _offset;
-  int                 _generic_signature_index;
-  int                 _index; // index into fields() array
+  int                 _index; // the field index
   constantPoolHandle  _cp;
 
+  // update the access_flags for the field in the klass
+  void update_klass_field_access_flag() {
+    instanceKlass* ik = instanceKlass::cast(field_holder());
+    ik->field(index())->set_access_flags(_access_flags.as_short());
+  }
+
+  FieldInfo* field() const {
+    instanceKlass* ik = instanceKlass::cast(field_holder());
+    return ik->field(_index);
+  }
+
  public:
-  Symbol* name() const                 { return _cp->symbol_at(_name_index); }
-  Symbol* signature() const            { return _cp->symbol_at(_signature_index); }
+  Symbol* name() const {
+    return field()->name(_cp);
+  }
+  Symbol* signature() const {
+    return field()->signature(_cp);
+  }
   klassOop field_holder() const        { return _cp->pool_holder(); }
   constantPoolOop constants() const    { return _cp(); }
   AccessFlags access_flags() const     { return _access_flags; }
   oop loader() const;
   // Offset (in words) of field from start of instanceOop / klassOop
-  int offset() const                   { return _offset; }
-  Symbol* generic_signature() const    { return (_generic_signature_index > 0 ? _cp->symbol_at(_generic_signature_index) : (Symbol*)NULL); }
+  int offset() const                   { return field()->offset(); }
+  Symbol* generic_signature() const    { return field()->generic_signature(_cp); }
   int index() const                    { return _index; }
   typeArrayOop annotations() const;
 
   // Initial field value
-  bool has_initial_value() const          { return _initial_value_index != 0; }
+  bool has_initial_value() const          { return field()->initval_index() != 0; }
+  int initial_value_index() const         { return field()->initval_index(); }
   constantTag initial_value_tag() const;  // The tag will return true on one of is_int(), is_long(), is_single(), is_double()
   jint        int_initial_value() const;
   jlong       long_initial_value() const;
@@ -74,25 +85,31 @@
   BasicType field_type() const            { return FieldType::basic_type(signature()); }
 
   // Access flags
-  bool is_public() const                  { return _access_flags.is_public(); }
-  bool is_private() const                 { return _access_flags.is_private(); }
-  bool is_protected() const               { return _access_flags.is_protected(); }
+  bool is_public() const                  { return access_flags().is_public(); }
+  bool is_private() const                 { return access_flags().is_private(); }
+  bool is_protected() const               { return access_flags().is_protected(); }
   bool is_package_private() const         { return !is_public() && !is_private() && !is_protected(); }
 
-  bool is_static() const                  { return _access_flags.is_static(); }
-  bool is_final() const                   { return _access_flags.is_final(); }
-  bool is_volatile() const                { return _access_flags.is_volatile(); }
-  bool is_transient() const               { return _access_flags.is_transient(); }
+  bool is_static() const                  { return access_flags().is_static(); }
+  bool is_final() const                   { return access_flags().is_final(); }
+  bool is_volatile() const                { return access_flags().is_volatile(); }
+  bool is_transient() const               { return access_flags().is_transient(); }
 
-  bool is_synthetic() const               { return _access_flags.is_synthetic(); }
+  bool is_synthetic() const               { return access_flags().is_synthetic(); }
 
-  bool is_field_access_watched() const    { return _access_flags.is_field_access_watched(); }
+  bool is_field_access_watched() const    { return access_flags().is_field_access_watched(); }
   bool is_field_modification_watched() const
-                                          { return _access_flags.is_field_modification_watched(); }
-  void set_is_field_access_watched(const bool value)
-                                          { _access_flags.set_is_field_access_watched(value); }
-  void set_is_field_modification_watched(const bool value)
-                                          { _access_flags.set_is_field_modification_watched(value); }
+                                          { return access_flags().is_field_modification_watched(); }
+
+  void set_is_field_access_watched(const bool value) {
+    _access_flags.set_is_field_access_watched(value);
+    update_klass_field_access_flag();
+  }
+
+  void set_is_field_modification_watched(const bool value) {
+    _access_flags.set_is_field_modification_watched(value);
+    update_klass_field_access_flag();
+  }
 
   // Initialization
   void initialize(klassOop k, int index);
--- a/hotspot/src/share/vm/runtime/fprofiler.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/fprofiler.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // a simple flat profiler for Java
 
--- a/hotspot/src/share/vm/runtime/frame.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/frame.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -221,6 +221,10 @@
   // returns the stack pointer of the calling frame
   intptr_t* sender_sp() const;
 
+  // Deoptimization info, if needed (platform dependent).
+  // Stored in the initial_info field of the unroll info, to be used by
+  // the platform dependent deoptimization blobs.
+  intptr_t *initial_deoptimization_info();
 
   // Interpreter frames:
 
--- a/hotspot/src/share/vm/runtime/globals.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -50,6 +50,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "globals_bsd.hpp"
+#endif
 #ifdef TARGET_OS_ARCH_linux_x86
 # include "globals_linux_x86.hpp"
 #endif
@@ -74,6 +77,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "globals_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "globals_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "globals_bsd_zero.hpp"
+#endif
 #ifdef COMPILER1
 #ifdef TARGET_ARCH_x86
 # include "c1_globals_x86.hpp"
@@ -96,6 +105,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "c1_globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "c1_globals_bsd.hpp"
+#endif
 #endif
 #ifdef COMPILER2
 #ifdef TARGET_ARCH_x86
@@ -116,6 +128,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "c2_globals_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "c2_globals_bsd.hpp"
+#endif
 #endif
 #ifdef SHARK
 #ifdef TARGET_ARCH_zero
@@ -475,6 +490,12 @@
   product(bool, UseNUMA, false,                                             \
           "Use NUMA if available")                                          \
                                                                             \
+  product(bool, UseNUMAInterleaving, false,                                 \
+          "Interleave memory across NUMA nodes if available")               \
+                                                                            \
+  product(uintx, NUMAInterleaveGranularity, 2*M,                            \
+          "Granularity to use for NUMA interleaving on Windows OS")         \
+                                                                            \
   product(bool, ForceNUMA, false,                                           \
           "Force NUMA optimizations on single-node/UMA systems")            \
                                                                             \
@@ -656,7 +677,7 @@
   notproduct(bool, WalkStackALot, false,                                    \
           "trace stack (no print) at every exit from the runtime system")   \
                                                                             \
-  develop(bool, Debugging, false,                                           \
+  product(bool, Debugging, false,                                           \
           "set when executing debug methods in debug.ccp "                  \
           "(to prevent triggering assertions)")                             \
                                                                             \
@@ -1979,6 +2000,18 @@
   product(bool, TLABStats, true,                                            \
           "Print various TLAB related information")                         \
                                                                             \
+  product(bool, UseBlockZeroing, false,                                     \
+          "Use special cpu instructions for block zeroing")                 \
+                                                                            \
+  product(intx, BlockZeroingLowLimit, 2048,                                 \
+          "Minimum size in bytes when block zeroing will be used")          \
+                                                                            \
+  product(bool, UseBlockCopy, false,                                        \
+          "Use special cpu instructions for block copy")                    \
+                                                                            \
+  product(intx, BlockCopyLowLimit, 2048,                                    \
+          "Minimum size in bytes when block copy will be used")             \
+                                                                            \
   product(bool, PrintRevisitStats, false,                                   \
           "Print revisit (klass and MDO) stack related information")        \
                                                                             \
@@ -2912,6 +2945,12 @@
   product(intx,  ReadPrefetchInstr, 0,                                      \
           "Prefetch instruction to prefetch ahead")                         \
                                                                             \
+  product(uintx,  ArraycopySrcPrefetchDistance, 0,                          \
+          "Distance to prefetch source array in arracopy")                  \
+                                                                            \
+  product(uintx,  ArraycopyDstPrefetchDistance, 0,                          \
+          "Distance to prefetch destination array in arracopy")             \
+                                                                            \
   /* deoptimization */                                                      \
   develop(bool, TraceDeoptimization, false,                                 \
           "Trace deoptimization")                                           \
@@ -3482,6 +3521,9 @@
           "C1 with MDO profiling (tier 3) invocation notification "         \
           "frequency.")                                                     \
                                                                             \
+  product(intx, Tier23InlineeNotifyFreqLog, 20,                             \
+          "Inlinee invocation (tiers 2 and 3) notification frequency")      \
+                                                                            \
   product(intx, Tier0BackedgeNotifyFreqLog, 10,                             \
           "Interpreter (tier 0) invocation notification frequency.")        \
                                                                             \
--- a/hotspot/src/share/vm/runtime/handles.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/handles.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -38,6 +38,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifdef ASSERT
 oop* HandleArea::allocate_handle(oop obj) {
--- a/hotspot/src/share/vm/runtime/handles.inline.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/handles.inline.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // these inline functions are in a separate file to break an include cycle
 // between Thread and Handle
--- a/hotspot/src/share/vm/runtime/interfaceSupport.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/interfaceSupport.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -44,6 +44,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Wrapper for all entry points to the virtual machine.
 // The HandleMarkCleaner is a faster version of HandleMark.
@@ -115,6 +118,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "interfaceSupport_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "interfaceSupport_bsd.hpp"
+#endif
 
 };
 
--- a/hotspot/src/share/vm/runtime/java.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/java.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -85,6 +85,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
@@ -102,7 +105,9 @@
 #include "opto/runtime.hpp"
 #endif
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL(hotspot, vm__shutdown);
+#endif /* !USDT2 */
 
 #ifndef PRODUCT
 
@@ -544,8 +549,12 @@
 
 void notify_vm_shutdown() {
   // For now, just a dtrace probe.
+#ifndef USDT2
   HS_DTRACE_PROBE(hotspot, vm__shutdown);
   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
+#else /* USDT2 */
+  HOTSPOT_VM_SHUTDOWN();
+#endif /* USDT2 */
 }
 
 void vm_direct_exit(int code) {
@@ -672,7 +681,8 @@
     _current = JDK_Version(major, minor, micro, info.update_version,
                            info.special_update_version, build,
                            info.thread_park_blocker == 1,
-                           info.post_vm_init_hook_enabled == 1);
+                           info.post_vm_init_hook_enabled == 1,
+                           info.pending_list_uses_discovered_field == 1);
   }
 }
 
--- a/hotspot/src/share/vm/runtime/java.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/java.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -92,6 +92,7 @@
   bool _partially_initialized;
 
   bool _thread_park_blocker;
+  bool _pending_list_uses_discovered_field;
   bool _post_vm_init_hook_enabled;
 
   bool is_valid() const {
@@ -114,15 +115,18 @@
 
   JDK_Version() : _major(0), _minor(0), _micro(0), _update(0),
                   _special(0), _build(0), _partially_initialized(false),
-                  _thread_park_blocker(false), _post_vm_init_hook_enabled(false) {}
+                  _thread_park_blocker(false), _post_vm_init_hook_enabled(false),
+                  _pending_list_uses_discovered_field(false) {}
 
   JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0,
               uint8_t update = 0, uint8_t special = 0, uint8_t build = 0,
-              bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false) :
+              bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false,
+              bool pending_list_uses_discovered_field = false) :
       _major(major), _minor(minor), _micro(micro), _update(update),
       _special(special), _build(build), _partially_initialized(false),
       _thread_park_blocker(thread_park_blocker),
-      _post_vm_init_hook_enabled(post_vm_init_hook_enabled) {}
+      _post_vm_init_hook_enabled(post_vm_init_hook_enabled),
+      _pending_list_uses_discovered_field(pending_list_uses_discovered_field) {}
 
   // Returns the current running JDK version
   static JDK_Version current() { return _current; }
@@ -149,6 +153,10 @@
   bool post_vm_init_hook_enabled() const {
     return _post_vm_init_hook_enabled;
   }
+  // For compatibility wrt pre-4965777 JDK's
+  bool pending_list_uses_discovered_field() const {
+    return _pending_list_uses_discovered_field;
+  }
 
   // Performs a full ordering comparison using all fields (update, build, etc.)
   int compare(const JDK_Version& other) const;
--- a/hotspot/src/share/vm/runtime/javaCalls.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/javaCalls.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -48,6 +48,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // -----------------------------------------------------
 // Implementation of JavaCallWrapper
@@ -557,4 +560,3 @@
   sc.check_doing_return(true);
   sc.iterate_returntype();
 }
-
--- a/hotspot/src/share/vm/runtime/javaCalls.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/javaCalls.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -54,6 +54,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // A JavaCallWrapper is constructed before each JavaCall and destructed after the call.
 // Its purpose is to allocate/deallocate a new handle block and to save/restore the last
--- a/hotspot/src/share/vm/runtime/javaFrameAnchor.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/javaFrameAnchor.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -50,6 +50,13 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "orderAccess_linux_ppc.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "orderAccess_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "orderAccess_bsd_zero.inline.hpp"
+#endif
+
 //
 // An object for encapsulating the machine/os dependent part of a JavaThread frame state
 //
--- a/hotspot/src/share/vm/runtime/jniHandles.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/jniHandles.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 JNIHandleBlock* JNIHandles::_global_handles       = NULL;
--- a/hotspot/src/share/vm/runtime/memprofiler.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/memprofiler.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -46,6 +46,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifndef PRODUCT
 
--- a/hotspot/src/share/vm/runtime/mutex.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/mutex.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -39,6 +39,10 @@
 # include "mutex_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "mutex_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 // o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
 //
--- a/hotspot/src/share/vm/runtime/mutexLocker.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Mutexes used in the VM (see comment in mutexLocker.hpp):
 //
--- a/hotspot/src/share/vm/runtime/mutexLocker.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/mutexLocker.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // Mutexes used in the VM.
 
--- a/hotspot/src/share/vm/runtime/objectMonitor.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -50,6 +50,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 #if defined(__GNUC__) && !defined(IA64)
   // Need to inhibit inlining for older versions of GCC to avoid build-time failures
@@ -64,6 +68,19 @@
 // Only bother with this argument setup if dtrace is available
 // TODO-FIXME: probes should not fire when caller is _blocked.  assert() accordingly.
 
+
+#define DTRACE_MONITOR_PROBE_COMMON(klassOop, thread)                      \
+  char* bytes = NULL;                                                      \
+  int len = 0;                                                             \
+  jlong jtid = SharedRuntime::get_java_tid(thread);                        \
+  Symbol* klassname = ((oop)(klassOop))->klass()->klass_part()->name();    \
+  if (klassname != NULL) {                                                 \
+    bytes = (char*)klassname->bytes();                                     \
+    len = klassname->utf8_length();                                        \
+  }
+
+#ifndef USDT2
+
 HS_DTRACE_PROBE_DECL4(hotspot, monitor__notify,
   jlong, uintptr_t, char*, int);
 HS_DTRACE_PROBE_DECL4(hotspot, monitor__notifyAll,
@@ -75,16 +92,6 @@
 HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__exit,
   jlong, uintptr_t, char*, int);
 
-#define DTRACE_MONITOR_PROBE_COMMON(klassOop, thread)                      \
-  char* bytes = NULL;                                                      \
-  int len = 0;                                                             \
-  jlong jtid = SharedRuntime::get_java_tid(thread);                        \
-  Symbol* klassname = ((oop)(klassOop))->klass()->klass_part()->name();    \
-  if (klassname != NULL) {                                                 \
-    bytes = (char*)klassname->bytes();                                     \
-    len = klassname->utf8_length();                                        \
-  }
-
 #define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis)       \
   {                                                                        \
     if (DTraceMonitorProbes) {                                            \
@@ -103,6 +110,33 @@
     }                                                                      \
   }
 
+#else /* USDT2 */
+
+#define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis)       \
+  {                                                                        \
+    if (DTraceMonitorProbes) {                                            \
+      DTRACE_MONITOR_PROBE_COMMON(klassOop, thread);                       \
+      HOTSPOT_MONITOR_WAIT(jtid,                                           \
+                       (monitor), bytes, len, (millis));                   \
+    }                                                                      \
+  }
+
+#define HOTSPOT_MONITOR_contended__enter HOTSPOT_MONITOR_CONTENDED_ENTER
+#define HOTSPOT_MONITOR_contended__entered HOTSPOT_MONITOR_CONTENDED_ENTERED
+#define HOTSPOT_MONITOR_contended__exit HOTSPOT_MONITOR_CONTENDED_EXIT
+#define HOTSPOT_MONITOR_notify HOTSPOT_MONITOR_NOTIFY
+#define HOTSPOT_MONITOR_notifyAll HOTSPOT_MONITOR_NOTIFYALL
+
+#define DTRACE_MONITOR_PROBE(probe, monitor, klassOop, thread)             \
+  {                                                                        \
+    if (DTraceMonitorProbes) {                                            \
+      DTRACE_MONITOR_PROBE_COMMON(klassOop, thread);                       \
+      HOTSPOT_MONITOR_##probe(jtid,                                               \
+                       (uintptr_t)(monitor), bytes, len);                  \
+    }                                                                      \
+  }
+
+#endif /* USDT2 */
 #else //  ndef DTRACE_ENABLED
 
 #define DTRACE_MONITOR_WAIT_PROBE(klassOop, thread, millis, mon)    {;}
--- a/hotspot/src/share/vm/runtime/os.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/os.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -60,6 +60,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 # include <signal.h>
 
@@ -116,7 +120,11 @@
     assert(false, "Failed localtime_pd");
     return NULL;
   }
+#if defined(_ALLBSD_SOURCE)
+  const time_t zone = (time_t) time_struct.tm_gmtoff;
+#else
   const time_t zone = timezone;
+#endif
 
   // If daylight savings time is in effect,
   // we are 1 hour East of our time zone
@@ -384,6 +392,13 @@
     if (_native_java_library == NULL) {
       vm_exit_during_initialization("Unable to load native library", ebuf);
     }
+
+#if defined(__OpenBSD__)
+    // Work-around OpenBSD's lack of $ORIGIN support by pre-loading libnet.so
+    // ignore errors
+    dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "net");
+    dll_load(buffer, ebuf, sizeof(ebuf));
+#endif
   }
   static jboolean onLoaded = JNI_FALSE;
   if (onLoaded) {
@@ -1080,6 +1095,9 @@
         "%/lib/jsse.jar:"
         "%/lib/jce.jar:"
         "%/lib/charsets.jar:"
+#ifdef __APPLE__
+        "%/lib/JObjC.jar:"
+#endif
         "%/classes";
     char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep);
     if (sysclasspath == NULL) return false;
--- a/hotspot/src/share/vm/runtime/os.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/os.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -39,6 +39,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "jvm_windows.h"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "jvm_bsd.h"
+#endif
 
 // os defines the interface to operating system; this includes traditional
 // OS services (time, I/O) as well as other functionality with system-
@@ -181,6 +184,9 @@
   //    Returns true if it worked, false if it didn't.
   static bool bind_to_processor(uint processor_id);
 
+  // Give a name to the current thread.
+  static void set_native_thread_name(const char *name);
+
   // Interface for stack banging (predetect possible stack overflow for
   // exception processing)  There are guard pages, and above that shadow
   // pages for stack overflow checking.
@@ -675,6 +681,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.hpp"
+#endif
 #ifdef TARGET_OS_ARCH_linux_x86
 # include "os_linux_x86.hpp"
 #endif
@@ -699,6 +708,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "os_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "os_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "os_bsd_zero.hpp"
+#endif
 
 
   // debugging support (mostly used by debug.cpp but also fatal error handler)
--- a/hotspot/src/share/vm/runtime/osThread.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/osThread.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -109,6 +109,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "osThread_windows.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "osThread_bsd.hpp"
+#endif
 
 };
 
--- a/hotspot/src/share/vm/runtime/reflection.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/reflection.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -844,16 +844,6 @@
 }
 
 
-//---------------------------------------------------------------------------
-//
-// Supporting routines for old native code-based reflection (pre-JDK 1.4).
-//
-// See reflection.hpp for details.
-//
-//---------------------------------------------------------------------------
-
-#ifdef SUPPORT_OLD_REFLECTION
-
 methodHandle Reflection::resolve_interface_call(instanceKlassHandle klass, methodHandle method,
                                                 KlassHandle recv_klass, Handle receiver, TRAPS) {
   assert(!method.is_null() , "method should not be null");
@@ -1081,519 +1071,6 @@
   return java_lang_Class::primitive_type(basic_type_mirror);
 }
 
-
-bool Reflection::match_parameter_types(methodHandle method, objArrayHandle types, int parameter_count, TRAPS) {
-  int types_len = types.is_null() ? 0 : types->length();
-  if (types_len != parameter_count) return false;
-  if (parameter_count > 0) {
-    objArrayHandle method_types = get_parameter_types(method, parameter_count, NULL, CHECK_false);
-    for (int index = 0; index < parameter_count; index++) {
-      if (types->obj_at(index) != method_types->obj_at(index)) {
-        return false;
-      }
-    }
-  }
-  return true;
-}
-
-
-oop Reflection::new_field(FieldStream* st, TRAPS) {
-  Symbol*  field_name = st->name();
-  Handle name = java_lang_String::create_from_symbol(field_name, CHECK_NULL);
-  Symbol*  signature = st->signature();
-  Handle type = new_type(signature, st->klass(), CHECK_NULL);
-  Handle rh  = java_lang_reflect_Field::create(CHECK_NULL);
-  oop result = rh();
-
-  java_lang_reflect_Field::set_clazz(result, st->klass()->java_mirror());
-  java_lang_reflect_Field::set_slot(result, st->index());
-  java_lang_reflect_Field::set_name(result, name());
-  java_lang_reflect_Field::set_type(result, type());
-  // Note the ACC_ANNOTATION bit, which is a per-class access flag, is never set here.
-  java_lang_reflect_Field::set_modifiers(result, st->access_flags().as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS);
-  java_lang_reflect_Field::set_override(result, false);
-  return result;
-}
-
-
-bool Reflection::resolve_field(Handle field_mirror, Handle& receiver, fieldDescriptor* fd, bool check_final, TRAPS) {
-  if (field_mirror.is_null()) {
-    THROW_(vmSymbols::java_lang_NullPointerException(), false);
-  }
-
-  instanceKlassHandle klass (THREAD, java_lang_Class::as_klassOop(java_lang_reflect_Field::clazz(field_mirror())));
-  int                 slot  = java_lang_reflect_Field::slot(field_mirror());
-
-  // Ensure klass is initialized
-  klass->initialize(CHECK_false);
-  fd->initialize(klass(), slot);
-
-  bool is_static = fd->is_static();
-  KlassHandle receiver_klass;
-
-  if (is_static) {
-    receiver = KlassHandle(THREAD, klass());
-    receiver_klass = klass;
-  } else {
-    // Check object is a non-null instance of declaring class
-    if (receiver.is_null()) {
-      THROW_(vmSymbols::java_lang_NullPointerException(), false);
-    }
-    if (!receiver->is_a(klass())) {
-      THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "object is not an instance of declaring class", false);
-    }
-    receiver_klass = KlassHandle(THREAD, receiver->klass());
-  }
-
-  // Access checking (unless overridden by Field)
-  if (!java_lang_reflect_Field::override(field_mirror())) {
-    if (!(klass->is_public() && fd->is_public())) {
-      bool access_check = reflect_check_access(klass(), fd->access_flags(), receiver_klass(), false, CHECK_false);
-      if (!access_check) {
-        return false; // exception
-      }
-    }
-  }
-
-  if (check_final && fd->is_final()) {
-    // In 1.3 we always throw an error when attempting to set a final field.
-    // In 1.2.x, this was allowed in the override bit was set by calling Field.setAccessible(true).
-    // We currently maintain backwards compatibility. See bug 4250960.
-    bool strict_final_check = !JDK_Version::is_jdk12x_version();
-    if (strict_final_check || !java_lang_reflect_Field::override(field_mirror())) {
-      THROW_MSG_(vmSymbols::java_lang_IllegalAccessException(), "field is final", false);
-    }
-  }
-  return true;
-}
-
-
-BasicType Reflection::field_get(jvalue* value, fieldDescriptor* fd, Handle receiver)  {
-  BasicType field_type = fd->field_type();
-  int offset = fd->offset();
-  switch (field_type) {
-    case T_BOOLEAN:
-      value->z = receiver->bool_field(offset);
-      break;
-    case T_CHAR:
-      value->c = receiver->char_field(offset);
-      break;
-    case T_FLOAT:
-      value->f = receiver->float_field(offset);
-      break;
-    case T_DOUBLE:
-      value->d = receiver->double_field(offset);
-      break;
-    case T_BYTE:
-      value->b = receiver->byte_field(offset);
-      break;
-    case T_SHORT:
-      value->s = receiver->short_field(offset);
-      break;
-    case T_INT:
-      value->i = receiver->int_field(offset);
-      break;
-    case T_LONG:
-      value->j = receiver->long_field(offset);
-      break;
-    case T_OBJECT:
-    case T_ARRAY:
-      value->l = (jobject) receiver->obj_field(offset);
-      break;
-    default:
-      return T_ILLEGAL;
-  }
-  return field_type;
-}
-
-
-void Reflection::field_set(jvalue* value, fieldDescriptor* fd, Handle receiver, BasicType value_type, TRAPS) {
-  BasicType field_type = fd->field_type();
-  if (field_type != value_type) {
-    widen(value, value_type, field_type, CHECK);
-  }
-
-  int offset = fd->offset();
-  switch (field_type) {
-    case T_BOOLEAN:
-      receiver->bool_field_put(offset, value->z);
-      break;
-    case T_CHAR:
-      receiver->char_field_put(offset, value->c);
-      break;
-    case T_FLOAT:
-      receiver->float_field_put(offset, value->f);
-      break;
-    case T_DOUBLE:
-      receiver->double_field_put(offset, value->d);
-      break;
-    case T_BYTE:
-      receiver->byte_field_put(offset, value->b);
-      break;
-    case T_SHORT:
-      receiver->short_field_put(offset, value->s);
-      break;
-    case T_INT:
-      receiver->int_field_put(offset, value->i);
-      break;
-    case T_LONG:
-      receiver->long_field_put(offset, value->j);
-      break;
-    case T_OBJECT:
-    case T_ARRAY: {
-      Handle obj(THREAD, (oop) value->l);
-      if (obj.not_null()) {
-        Symbol*  signature = fd->signature();
-        Handle       loader   (THREAD, fd->loader());
-        Handle       protect  (THREAD, Klass::cast(fd->field_holder())->protection_domain());
-        klassOop k = SystemDictionary::resolve_or_fail(signature, loader, protect, true, CHECK); // may block
-        if (!obj->is_a(k)) {
-          THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "field type mismatch");
-        }
-      }
-      receiver->obj_field_put(offset, obj());
-      break;
-    }
-    default:
-      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "field type mismatch");
-  }
-}
-
-
-oop Reflection::reflect_field(oop mirror, Symbol* field_name, jint which, TRAPS) {
-  // Exclude primitive types and array types
-  if (java_lang_Class::is_primitive(mirror))                             return NULL;
-  if (Klass::cast(java_lang_Class::as_klassOop(mirror))->oop_is_array()) return NULL;
-
-  instanceKlassHandle k(THREAD, java_lang_Class::as_klassOop(mirror));
-  bool local_fields_only = (which == DECLARED);
-
-  // Ensure class is linked
-  k->link_class(CHECK_NULL);
-
-  // Search class and interface fields
-  for (FieldStream st(k, local_fields_only, false); !st.eos(); st.next()) {
-    if (st.name() == field_name) {
-      if (local_fields_only || st.access_flags().is_public()) {
-        return new_field(&st, THREAD);
-      }
-    }
-  }
-
-  return NULL;
-}
-
-
-objArrayOop Reflection::reflect_fields(oop mirror, jint which, TRAPS) {
-  // Exclude primitive types and array types
-  if (java_lang_Class::is_primitive(mirror)
-      || Klass::cast(java_lang_Class::as_klassOop(mirror))->oop_is_array()) {
-    Symbol* name = vmSymbols::java_lang_reflect_Field();
-    klassOop klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NULL);
-    return oopFactory::new_objArray(klass, 0, CHECK_NULL);  // Return empty array
-  }
-
-  instanceKlassHandle k(THREAD, java_lang_Class::as_klassOop(mirror));
-
-  // Ensure class is linked
-  k->link_class(CHECK_NULL);
-
-  bool local_fields_only = (which == DECLARED);
-  int count = 0;
-  { // Compute fields count for class and interface fields
-    for (FieldStream st(k, local_fields_only, false); !st.eos(); st.next()) {
-      if (local_fields_only || st.access_flags().is_public()) {
-        count++;
-      }
-    }
-  }
-
-  // Allocate result
-  Symbol* name = vmSymbols::java_lang_reflect_Field();
-  klassOop klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NULL);
-  objArrayOop r = oopFactory::new_objArray(klass, count, CHECK_NULL);
-  objArrayHandle result (THREAD, r);
-
-  // Fill in results backwards
-  {
-    for (FieldStream st(k, local_fields_only, false); !st.eos(); st.next()) {
-      if (local_fields_only || st.access_flags().is_public()) {
-        oop field = new_field(&st, CHECK_NULL);
-        result->obj_at_put(--count, field);
-      }
-    }
-    assert(count == 0, "just checking");
-  }
-  return result();
-}
-
-
-oop Reflection::reflect_method(oop mirror, Symbol* method_name, objArrayHandle types, jint which, TRAPS) {
-  if (java_lang_Class::is_primitive(mirror))  return NULL;
-  klassOop klass = java_lang_Class::as_klassOop(mirror);
-  if (Klass::cast(klass)->oop_is_array() && which == MEMBER_DECLARED)  return NULL;
-
-  if (Klass::cast(java_lang_Class::as_klassOop(mirror))->oop_is_array()) {
-    klass = SystemDictionary::Object_klass();
-  }
-  instanceKlassHandle h_k(THREAD, klass);
-
-  // Ensure klass is linked (need not be initialized)
-  h_k->link_class(CHECK_NULL);
-
-  // For interfaces include static initializers under jdk1.2.x (since classic does that)
-  bool include_clinit = JDK_Version::is_jdk12x_version() && h_k->is_interface();
-
-  switch (which) {
-    case MEMBER_PUBLIC:
-      // First the public non-static methods (works if method holder is an interface)
-      // Note that we can ignore checks for overridden methods, since we go up the hierarchy.
-      {
-        for (MethodStream st(h_k, false, false); !st.eos(); st.next()) {
-          methodHandle m(THREAD, st.method());
-          // For interfaces include static initializers since classic does that!
-          if (method_name == m->name() && (include_clinit || (m->is_public() && !m->is_static() && !m->is_initializer()))) {
-            Symbol*  signature = m->signature();
-            bool parameter_match = match_parameter_types(m, types, ArgumentCount(signature).size(), CHECK_NULL);
-            if (parameter_match) {
-              return new_method(m, false, false, THREAD);
-            }
-          }
-        }
-      }
-      // Then the public static methods (works if method holder is an interface)
-      {
-        for (MethodStream st(h_k, false, false); !st.eos(); st.next()) {
-          methodHandle m(THREAD, st.method());
-          if (method_name == m->name() && m->is_public() && m->is_static() && !m->is_initializer()) {
-            Symbol*  signature = m->signature();
-            bool parameter_match = match_parameter_types(m, types, ArgumentCount(signature).size(), CHECK_NULL);
-            if (parameter_match) {
-              return new_method(m, false, false, THREAD);
-            }
-          }
-        }
-      }
-      break;
-    case MEMBER_DECLARED:
-      // All local methods
-      {
-        for (MethodStream st(h_k, true, true); !st.eos(); st.next()) {
-          methodHandle m(THREAD, st.method());
-          if (method_name == m->name() && !m->is_initializer()) {
-            Symbol*  signature = m->signature();
-            bool parameter_match = match_parameter_types(m, types, ArgumentCount(signature).size(), CHECK_NULL);
-            if (parameter_match) {
-              return new_method(m, false, false, THREAD);
-            }
-          }
-        }
-      }
-      break;
-    default:
-      break;
-  }
-  return NULL;
-}
-
-
-objArrayOop Reflection::reflect_methods(oop mirror, jint which, TRAPS) {
-  // Exclude primitive types
-  if (java_lang_Class::is_primitive(mirror) ||
-     (Klass::cast(java_lang_Class::as_klassOop(mirror))->oop_is_array() && (which == MEMBER_DECLARED))) {
-    klassOop klass = SystemDictionary::reflect_Method_klass();
-    return oopFactory::new_objArray(klass, 0, CHECK_NULL);  // Return empty array
-  }
-
-  klassOop klass = java_lang_Class::as_klassOop(mirror);
-  if (Klass::cast(java_lang_Class::as_klassOop(mirror))->oop_is_array()) {
-    klass = SystemDictionary::Object_klass();
-  }
-  instanceKlassHandle h_k(THREAD, klass);
-
-  // Ensure klass is linked (need not be initialized)
-  h_k->link_class(CHECK_NULL);
-
-  // We search the (super)interfaces only if h_k is an interface itself
-  bool is_interface = h_k->is_interface();
-
-  // For interfaces include static initializers under jdk1.2.x (since classic does that)
-  bool include_clinit = JDK_Version::is_jdk12x_version() && is_interface;
-
-  switch (which) {
-    case MEMBER_PUBLIC:
-      {
-
-        // Count public methods (non-static and static)
-        int count = 0;
-        {
-          for (MethodStream st(h_k, false, false); !st.eos(); st.next()) {
-            methodOop m = st.method();
-            // For interfaces include static initializers since classic does that!
-            if (include_clinit || (!m->is_initializer() && m->is_public() && !m->is_overridden_in(h_k()))) {
-              count++;
-            }
-          }
-        }
-
-        // Allocate result
-        klassOop klass = SystemDictionary::reflect_Method_klass();
-        objArrayOop r = oopFactory::new_objArray(klass, count, CHECK_NULL);
-        objArrayHandle h_result (THREAD, r);
-
-        // Fill in results backwards
-        {
-          // First the non-static public methods
-          for (MethodStream st(h_k, false, false); !st.eos(); st.next()) {
-            methodHandle m (THREAD, st.method());
-            if (!m->is_static() && !m->is_initializer() && m->is_public() && !m->is_overridden_in(h_k())) {
-              oop method = new_method(m, false, false, CHECK_NULL);
-              if (method == NULL) {
-                return NULL;
-              } else {
-                h_result->obj_at_put(--count, method);
-              }
-            }
-          }
-        }
-        {
-          // Then the static public methods
-          for (MethodStream st(h_k, false, !is_interface); !st.eos(); st.next()) {
-            methodHandle m (THREAD, st.method());
-            if (m->is_static() && (include_clinit || (!m->is_initializer()) && m->is_public() && !m->is_overridden_in(h_k()))) {
-              oop method = new_method(m, false, false, CHECK_NULL);
-              if (method == NULL) {
-                return NULL;
-              } else {
-                h_result->obj_at_put(--count, method);
-              }
-            }
-          }
-        }
-
-        assert(count == 0, "just checking");
-        return h_result();
-      }
-
-    case MEMBER_DECLARED:
-      {
-        // Count all methods
-        int count = 0;
-        {
-          for (MethodStream st(h_k, true, !is_interface); !st.eos(); st.next()) {
-            methodOop m = st.method();
-            if (!m->is_initializer()) {
-              count++;
-            }
-          }
-        }
-        // Allocate result
-        klassOop klass = SystemDictionary::reflect_Method_klass();
-        objArrayOop r = oopFactory::new_objArray(klass, count, CHECK_NULL);
-        objArrayHandle h_result (THREAD, r);
-
-        // Fill in results backwards
-        {
-          for (MethodStream st(h_k, true, true); !st.eos(); st.next()) {
-            methodHandle m (THREAD, st.method());
-            if (!m->is_initializer()) {
-              oop method = new_method(m, false, false, CHECK_NULL);
-              if (method == NULL) {
-                return NULL;
-              } else {
-                h_result->obj_at_put(--count, method);
-              }
-            }
-          }
-        }
-        assert(count == 0, "just checking");
-        return h_result();
-      }
-  }
-  ShouldNotReachHere();
-  return NULL;
-}
-
-
-oop Reflection::reflect_constructor(oop mirror, objArrayHandle types, jint which, TRAPS) {
-
-  // Exclude primitive, interface and array types
-  bool prim = java_lang_Class::is_primitive(mirror);
-  Klass* klass = prim ? NULL : Klass::cast(java_lang_Class::as_klassOop(mirror));
-  if (prim || klass->is_interface() || klass->oop_is_array()) return NULL;
-
-  // Must be instance klass
-  instanceKlassHandle h_k(THREAD, java_lang_Class::as_klassOop(mirror));
-
-  // Ensure klass is linked (need not be initialized)
-  h_k->link_class(CHECK_NULL);
-
-  bool local_only = (which == MEMBER_DECLARED);
-  for (MethodStream st(h_k, true, true); !st.eos(); st.next()) {
-    methodHandle m(THREAD, st.method());
-    if (m->name() == vmSymbols::object_initializer_name() && (local_only || m->is_public())) {
-      Symbol*  signature = m->signature();
-      bool parameter_match = match_parameter_types(m, types, ArgumentCount(signature).size(), CHECK_NULL);
-      if (parameter_match) {
-        return new_constructor(m, THREAD);
-      }
-    }
-  }
-
-  return NULL;
-}
-
-
-objArrayOop Reflection::reflect_constructors(oop mirror, jint which, TRAPS) {
-  // Exclude primitive, interface and array types
-  bool prim  = java_lang_Class::is_primitive(mirror);
-  Klass* k = prim ? NULL : Klass::cast(java_lang_Class::as_klassOop(mirror));
-  if (prim || k->is_interface() || k->oop_is_array()) {
-    return oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), 0, CHECK_NULL);  // Return empty array
-  }
-
-  // Must be instanceKlass at this point
-  instanceKlassHandle h_k(THREAD, java_lang_Class::as_klassOop(mirror));
-
-  // Ensure klass is linked (need not be initialized)
-  h_k->link_class(CHECK_NULL);
-
-  bool local_only = (which == MEMBER_DECLARED);
-  int count = 0;
-  {
-    for (MethodStream st(h_k, true, true); !st.eos(); st.next()) {
-      methodOop m = st.method();
-      if (m->name() == vmSymbols::object_initializer_name() && (local_only || m->is_public())) {
-        count++;
-      }
-    }
-  }
-
-  // Allocate result
-  Symbol* name = vmSymbols::java_lang_reflect_Constructor();
-  klassOop klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NULL);
-  objArrayOop r = oopFactory::new_objArray(klass, count, CHECK_NULL);
-  objArrayHandle h_result (THREAD, r);
-
-  // Fill in results backwards
-  {
-    for (MethodStream st(h_k, true, true); !st.eos(); st.next()) {
-      methodHandle m (THREAD, st.method());
-      if (m->name() == vmSymbols::object_initializer_name() && (local_only || m->is_public())) {
-        oop constr = new_constructor(m, CHECK_NULL);
-        if (constr == NULL) {
-          return NULL;
-        } else {
-          h_result->obj_at_put(--count, constr);
-        }
-      }
-    }
-    assert(count == 0, "just checking");
-  }
-  return h_result();
-}
-
-
 // This would be nicer if, say, java.lang.reflect.Method was a subclass
 // of java.lang.reflect.Constructor
 
@@ -1647,6 +1124,3 @@
   invoke(klass, method, receiver, override, ptypes, T_VOID, args, false, CHECK_NULL);
   return receiver();
 }
-
-
-#endif /* SUPPORT_OLD_REFLECTION */
--- a/hotspot/src/share/vm/runtime/reflection.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/reflection.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -27,7 +27,6 @@
 
 #include "oops/oop.hpp"
 #include "runtime/fieldDescriptor.hpp"
-#include "runtime/reflectionCompat.hpp"
 #include "utilities/accessFlags.hpp"
 #include "utilities/growableArray.hpp"
 
@@ -120,16 +119,6 @@
   // Create a java.lang.reflect.Field object based on a field descriptor
   static oop new_field(fieldDescriptor* fd, bool intern_name, TRAPS);
 
-  //---------------------------------------------------------------------------
-  //
-  // Support for old native code-based reflection (pre-JDK 1.4)
-  //
-  // NOTE: the method and constructor invocation code is still used
-  // for startup time reasons; see reflectionCompat.hpp.
-  //
-  //---------------------------------------------------------------------------
-
-#ifdef SUPPORT_OLD_REFLECTION
 private:
   // method resolution for invoke
   static methodHandle resolve_interface_call(instanceKlassHandle klass, methodHandle method, KlassHandle recv_klass, Handle receiver, TRAPS);
@@ -144,35 +133,11 @@
   // Conversion
   static BasicType basic_type_mirror_to_basic_type(oop basic_type_mirror, TRAPS);
 
-  static bool match_parameter_types(methodHandle method, objArrayHandle types, int parameter_count, TRAPS);
-  // Creating new java.lang.reflect.xxx wrappers
-  static oop new_field(FieldStream* st, TRAPS);
-
 public:
-  // Field lookup and verification.
-  static bool      resolve_field(Handle field_mirror, Handle& receiver, fieldDescriptor* fd, bool check_final, TRAPS);
-
-  // Reflective field access. Returns type code. Throws IllegalArgumentException.
-  static BasicType field_get(jvalue* value, fieldDescriptor* fd, Handle receiver);
-  static void      field_set(jvalue* value, fieldDescriptor* fd, Handle receiver, BasicType value_type, TRAPS);
-
-  // Reflective lookup of fields. Returns java.lang.reflect.Field instances.
-  static oop         reflect_field(oop mirror, Symbol* field_name, jint which, TRAPS);
-  static objArrayOop reflect_fields(oop mirror, jint which, TRAPS);
-
-  // Reflective lookup of methods. Returns java.lang.reflect.Method instances.
-  static oop         reflect_method(oop mirror, Symbol* method_name, objArrayHandle types, jint which, TRAPS);
-  static objArrayOop reflect_methods(oop mirror, jint which, TRAPS);
-
-  // Reflective lookup of constructors. Returns java.lang.reflect.Constructor instances.
-  static oop         reflect_constructor(oop mirror, objArrayHandle types, jint which, TRAPS);
-  static objArrayOop reflect_constructors(oop mirror, jint which, TRAPS);
-
   // Method invokation through java.lang.reflect.Method
   static oop      invoke_method(oop method_mirror, Handle receiver, objArrayHandle args, TRAPS);
   // Method invokation through java.lang.reflect.Constructor
   static oop      invoke_constructor(oop method_mirror, objArrayHandle args, TRAPS);
-#endif /* SUPPORT_OLD_REFLECTION */
 
 };
 
--- a/hotspot/src/share/vm/runtime/reflectionCompat.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
- * 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_RUNTIME_REFLECTIONCOMPAT_HPP
-#define SHARE_VM_RUNTIME_REFLECTIONCOMPAT_HPP
-
-// During the development of the JDK 1.4 reflection implementation
-// based on dynamic bytecode generation, it was hoped that the bulk of
-// the native code for reflection could be removed. Unfortunately
-// there is currently a significant cost associated with loading the
-// stub classes which impacts startup time. Until this cost can be
-// reduced, the JVM entry points JVM_InvokeMethod and
-// JVM_NewInstanceFromConstructor are still needed; these and their
-// dependents currently constitute the bulk of the native code for
-// reflection. If this cost is reduced in the future, the
-// NativeMethodAccessorImpl and NativeConstructorAccessorImpl classes
-// can be removed from sun.reflect and all of the code guarded by this
-// flag removed from the product build. (Non-product builds,
-// specifically the "optimized" target, would retain the code so they
-// could be dropped into earlier JDKs for comparative benchmarking.)
-
-//#ifndef PRODUCT
-# define SUPPORT_OLD_REFLECTION
-//#endif
-
-#endif // SHARE_VM_RUNTIME_REFLECTIONCOMPAT_HPP
--- a/hotspot/src/share/vm/runtime/reflectionUtils.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/reflectionUtils.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -107,10 +107,8 @@
 
 class FieldStream : public KlassStream {
  private:
-  int length() const                { return fields()->length(); }
-  constantPoolOop constants() const { return _klass->constants(); }
- protected:
-  typeArrayOop fields() const       { return _klass->fields(); }
+  int length() const                { return _klass->java_fields_count(); }
+
  public:
   FieldStream(instanceKlassHandle klass, bool local_only, bool classes_only)
     : KlassStream(klass, local_only, classes_only) {
@@ -118,26 +116,23 @@
     next();
   }
 
-  void next() { _index -= instanceKlass::next_offset; }
+  void next() { _index -= 1; }
 
   // Accessors for current field
   AccessFlags access_flags() const {
     AccessFlags flags;
-    flags.set_flags(fields()->ushort_at(index() + instanceKlass::access_flags_offset));
+    flags.set_flags(_klass->field_access_flags(_index));
     return flags;
   }
   Symbol* name() const {
-    int name_index = fields()->ushort_at(index() + instanceKlass::name_index_offset);
-    return constants()->symbol_at(name_index);
+    return _klass->field_name(_index);
   }
   Symbol* signature() const {
-    int signature_index = fields()->ushort_at(index() +
-                                       instanceKlass::signature_index_offset);
-    return constants()->symbol_at(signature_index);
+    return _klass->field_signature(_index);
   }
   // missing: initval()
   int offset() const {
-    return _klass->offset_from_fields( index() );
+    return _klass->field_offset( index() );
   }
 };
 
@@ -213,10 +208,10 @@
   }
   int field_count();
   void next() {
-    _index -= instanceKlass::next_offset;
+    _index -= 1;
     if (has_filtered_field()) {
       while (_index >=0 && FilteredFieldsMap::is_filtered_field((klassOop)_klass(), offset())) {
-        _index -= instanceKlass::next_offset;
+        _index -= 1;
       }
     }
   }
--- a/hotspot/src/share/vm/runtime/safepoint.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -78,6 +78,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
 #include "gc_implementation/shared/concurrentGCThread.hpp"
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -148,11 +148,13 @@
 
 #include <math.h>
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t);
 HS_DTRACE_PROBE_DECL7(hotspot, method__entry, int,
                       char*, int, char*, int, char*, int);
 HS_DTRACE_PROBE_DECL7(hotspot, method__return, int,
                       char*, int, char*, int, char*, int);
+#endif /* !USDT2 */
 
 // Implementation of SharedRuntime
 
@@ -659,12 +661,14 @@
   int scope_depth = 0;
   if (!force_unwind) {
     int bci = sd->bci();
+    bool recursive_exception = false;
     do {
       bool skip_scope_increment = false;
       // exception handler lookup
       KlassHandle ek (THREAD, exception->klass());
       handler_bci = sd->method()->fast_exception_handler_bci_for(ek, bci, THREAD);
       if (HAS_PENDING_EXCEPTION) {
+        recursive_exception = true;
         // We threw an exception while trying to find the exception handler.
         // Transfer the new exception to the exception handle which will
         // be set into thread local storage, and do another lookup for an
@@ -680,6 +684,9 @@
           skip_scope_increment = true;
         }
       }
+      else {
+        recursive_exception = false;
+      }
       if (!top_frame_only && handler_bci < 0 && !skip_scope_increment) {
         sd = sd->sender();
         if (sd != NULL) {
@@ -687,7 +694,7 @@
         }
         ++scope_depth;
       }
-    } while (!top_frame_only && handler_bci < 0 && sd != NULL);
+    } while (recursive_exception || (!top_frame_only && handler_bci < 0 && sd != NULL));
   }
 
   // found handling method => lookup exception handler
@@ -954,8 +961,14 @@
   Klass* klass = o->blueprint();
   int size = o->size();
   Symbol* name = klass->name();
+#ifndef USDT2
   HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread),
                    name->bytes(), name->utf8_length(), size * HeapWordSize);
+#else /* USDT2 */
+  HOTSPOT_OBJECT_ALLOC(
+                   get_java_tid(thread),
+                   (char *) name->bytes(), name->utf8_length(), size * HeapWordSize);
+#endif /* USDT2 */
   return 0;
 }
 
@@ -965,10 +978,18 @@
   Symbol* kname = method->klass_name();
   Symbol* name = method->name();
   Symbol* sig = method->signature();
+#ifndef USDT2
   HS_DTRACE_PROBE7(hotspot, method__entry, get_java_tid(thread),
       kname->bytes(), kname->utf8_length(),
       name->bytes(), name->utf8_length(),
       sig->bytes(), sig->utf8_length());
+#else /* USDT2 */
+  HOTSPOT_METHOD_ENTRY(
+      get_java_tid(thread),
+      (char *) kname->bytes(), kname->utf8_length(),
+      (char *) name->bytes(), name->utf8_length(),
+      (char *) sig->bytes(), sig->utf8_length());
+#endif /* USDT2 */
   return 0;
 JRT_END
 
@@ -978,10 +999,18 @@
   Symbol* kname = method->klass_name();
   Symbol* name = method->name();
   Symbol* sig = method->signature();
+#ifndef USDT2
   HS_DTRACE_PROBE7(hotspot, method__return, get_java_tid(thread),
       kname->bytes(), kname->utf8_length(),
       name->bytes(), name->utf8_length(),
       sig->bytes(), sig->utf8_length());
+#else /* USDT2 */
+  HOTSPOT_METHOD_RETURN(
+      get_java_tid(thread),
+      (char *) kname->bytes(), kname->utf8_length(),
+      (char *) name->bytes(), name->utf8_length(),
+      (char *) sig->bytes(), sig->utf8_length());
+#endif /* USDT2 */
   return 0;
 JRT_END
 
--- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -45,6 +45,8 @@
 // information, etc.
 
 class SharedRuntime: AllStatic {
+  friend class VMStructs;
+
  private:
   static methodHandle resolve_sub_helper(JavaThread *thread,
                                      bool is_virtual,
--- a/hotspot/src/share/vm/runtime/stubRoutines.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -51,8 +51,6 @@
 address StubRoutines::_forward_exception_entry                  = NULL;
 address StubRoutines::_throw_AbstractMethodError_entry          = NULL;
 address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL;
-address StubRoutines::_throw_ArithmeticException_entry          = NULL;
-address StubRoutines::_throw_NullPointerException_entry         = NULL;
 address StubRoutines::_throw_NullPointerException_at_call_entry = NULL;
 address StubRoutines::_throw_StackOverflowError_entry           = NULL;
 address StubRoutines::_throw_WrongMethodTypeException_entry     = NULL;
@@ -108,6 +106,7 @@
 address StubRoutines::_arrayof_oop_disjoint_arraycopy    = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy);
 address StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit  = CAST_FROM_FN_PTR(address, StubRoutines::arrayof_oop_copy_uninit);
 
+address StubRoutines::_zero_aligned_words = CAST_FROM_FN_PTR(address, Copy::zero_to_words);
 
 address StubRoutines::_checkcast_arraycopy               = NULL;
 address StubRoutines::_checkcast_arraycopy_uninit        = NULL;
--- a/hotspot/src/share/vm/runtime/stubRoutines.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -128,8 +128,6 @@
   static address _catch_exception_entry;
   static address _throw_AbstractMethodError_entry;
   static address _throw_IncompatibleClassChangeError_entry;
-  static address _throw_ArithmeticException_entry;
-  static address _throw_NullPointerException_entry;
   static address _throw_NullPointerException_at_call_entry;
   static address _throw_StackOverflowError_entry;
   static address _throw_WrongMethodTypeException_entry;
@@ -199,6 +197,9 @@
   static address _arrayof_jshort_fill;
   static address _arrayof_jint_fill;
 
+  // zero heap space aligned to jlong (8 bytes)
+  static address _zero_aligned_words;
+
   // These are versions of the java.lang.Math methods which perform
   // the same operations as the intrinsic version.  They are used for
   // constant folding in the compiler to ensure equivalence.  If the
@@ -251,8 +252,6 @@
   // Implicit exceptions
   static address throw_AbstractMethodError_entry()         { return _throw_AbstractMethodError_entry; }
   static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; }
-  static address throw_ArithmeticException_entry()         { return _throw_ArithmeticException_entry; }
-  static address throw_NullPointerException_entry()        { return _throw_NullPointerException_entry; }
   static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; }
   static address throw_StackOverflowError_entry()          { return _throw_StackOverflowError_entry; }
   static address throw_WrongMethodTypeException_entry()    { return _throw_WrongMethodTypeException_entry; }
@@ -332,6 +331,7 @@
 
   static address select_fill_function(BasicType t, bool aligned, const char* &name);
 
+  static address zero_aligned_words()   { return _zero_aligned_words; }
 
   static double  intrinsic_log(double d) {
     assert(_intrinsic_log != NULL, "must be defined");
--- a/hotspot/src/share/vm/runtime/synchronizer.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/synchronizer.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -51,6 +51,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 #if defined(__GNUC__) && !defined(IA64)
   // Need to inhibit inlining for older versions of GCC to avoid build-time failures
@@ -73,11 +77,6 @@
 // Only bother with this argument setup if dtrace is available
 // TODO-FIXME: probes should not fire when caller is _blocked.  assert() accordingly.
 
-HS_DTRACE_PROBE_DECL5(hotspot, monitor__wait,
-  jlong, uintptr_t, char*, int, long);
-HS_DTRACE_PROBE_DECL4(hotspot, monitor__waited,
-  jlong, uintptr_t, char*, int);
-
 #define DTRACE_MONITOR_PROBE_COMMON(klassOop, thread)                      \
   char* bytes = NULL;                                                      \
   int len = 0;                                                             \
@@ -88,6 +87,12 @@
     len = klassname->utf8_length();                                        \
   }
 
+#ifndef USDT2
+HS_DTRACE_PROBE_DECL5(hotspot, monitor__wait,
+  jlong, uintptr_t, char*, int, long);
+HS_DTRACE_PROBE_DECL4(hotspot, monitor__waited,
+  jlong, uintptr_t, char*, int);
+
 #define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis)       \
   {                                                                        \
     if (DTraceMonitorProbes) {                                            \
@@ -106,6 +111,29 @@
     }                                                                      \
   }
 
+#else /* USDT2 */
+
+#define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis)       \
+  {                                                                        \
+    if (DTraceMonitorProbes) {                                            \
+      DTRACE_MONITOR_PROBE_COMMON(klassOop, thread);                       \
+      HOTSPOT_MONITOR_WAIT(jtid,                                           \
+                           (uintptr_t)(monitor), bytes, len, (millis));  \
+    }                                                                      \
+  }
+
+#define HOTSPOT_MONITOR_PROBE_waited HOTSPOT_MONITOR_PROBE_WAITED
+
+#define DTRACE_MONITOR_PROBE(probe, monitor, klassOop, thread)             \
+  {                                                                        \
+    if (DTraceMonitorProbes) {                                            \
+      DTRACE_MONITOR_PROBE_COMMON(klassOop, thread);                       \
+      HOTSPOT_MONITOR_PROBE_##probe(jtid, /* probe = waited */             \
+                       (uintptr_t)(monitor), bytes, len);                  \
+    }                                                                      \
+  }
+
+#endif /* USDT2 */
 #else //  ndef DTRACE_ENABLED
 
 #define DTRACE_MONITOR_WAIT_PROBE(klassOop, thread, millis, mon)    {;}
--- a/hotspot/src/share/vm/runtime/task.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/task.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -39,6 +39,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 int PeriodicTask::_num_tasks = 0;
 PeriodicTask* PeriodicTask::_tasks[PeriodicTask::max_tasks];
--- a/hotspot/src/share/vm/runtime/thread.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -89,6 +89,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
 #include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
@@ -106,6 +110,7 @@
 
 // Only bother with this argument setup if dtrace is available
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL(hotspot, vm__init__begin);
 HS_DTRACE_PROBE_DECL(hotspot, vm__init__end);
 HS_DTRACE_PROBE_DECL5(hotspot, thread__start, char*, intptr_t,
@@ -126,6 +131,26 @@
       java_lang_Thread::is_daemon((javathread)->threadObj()));             \
   }
 
+#else /* USDT2 */
+
+#define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_PROBE_START
+#define HOTSPOT_THREAD_PROBE_stop HOTSPOT_THREAD_PROBE_STOP
+
+#define DTRACE_THREAD_PROBE(probe, javathread)                             \
+  {                                                                        \
+    ResourceMark rm(this);                                                 \
+    int len = 0;                                                           \
+    const char* name = (javathread)->get_thread_name();                    \
+    len = strlen(name);                                                    \
+    HOTSPOT_THREAD_PROBE_##probe(  /* probe = start, stop */               \
+      (char *) name, len,                                                           \
+      java_lang_Thread::thread_id((javathread)->threadObj()),              \
+      (uintptr_t) (javathread)->osthread()->thread_id(),                               \
+      java_lang_Thread::is_daemon((javathread)->threadObj()));             \
+  }
+
+#endif /* USDT2 */
+
 #else //  ndef DTRACE_ENABLED
 
 #define DTRACE_THREAD_PROBE(probe, javathread)
@@ -749,8 +774,9 @@
   jint thread_parity = _oops_do_parity;
   if (thread_parity != strong_roots_parity) {
     jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
-    if (res == thread_parity) return true;
-    else {
+    if (res == thread_parity) {
+      return true;
+    } else {
       guarantee(res == strong_roots_parity, "Or else what?");
       assert(SharedHeap::heap()->n_par_threads() > 0,
              "Should only fail when parallel.");
@@ -966,7 +992,7 @@
 // General purpose hook into Java code, run once when the VM is initialized.
 // The Java library method itself may be changed independently from the VM.
 static void call_postVMInitHook(TRAPS) {
-  klassOop k = SystemDictionary::sun_misc_PostVMInitHook_klass();
+  klassOop k = SystemDictionary::PostVMInitHook_klass();
   instanceKlassHandle klass (THREAD, k);
   if (klass.not_null()) {
     JavaValue result(T_VOID);
@@ -1272,7 +1298,6 @@
   _exception_oop = NULL;
   _exception_pc  = 0;
   _exception_handler_pc = 0;
-  _exception_stack_size = 0;
   _is_method_handle_return = 0;
   _jvmti_thread_state= NULL;
   _should_post_on_exceptions_flag = JNI_FALSE;
@@ -1324,7 +1349,7 @@
 DirtyCardQueueSet JavaThread::_dirty_card_queue_set;
 #endif // !SERIALGC
 
-JavaThread::JavaThread(bool is_attaching) :
+JavaThread::JavaThread(bool is_attaching_via_jni) :
   Thread()
 #ifndef SERIALGC
   , _satb_mark_queue(&_satb_mark_queue_set),
@@ -1332,7 +1357,11 @@
 #endif // !SERIALGC
 {
   initialize();
-  _is_attaching = is_attaching;
+  if (is_attaching_via_jni) {
+    _jni_attach_state = _attaching_via_jni;
+  } else {
+    _jni_attach_state = _not_attaching_via_jni;
+  }
   assert(_deferred_card_mark.is_empty(), "Default MemRegion ctor");
 }
 
@@ -1388,7 +1417,7 @@
     tty->print_cr("creating thread %p", this);
   }
   initialize();
-  _is_attaching = false;
+  _jni_attach_state = _not_attaching_via_jni;
   set_entry_point(entry_point);
   // Create the native thread itself.
   // %note runtime_23
@@ -1500,6 +1529,10 @@
   // Note: Due to JVM_StopThread we can have pending exceptions already!
   if (!this->has_pending_exception() &&
       !java_lang_Thread::is_stillborn(this->threadObj())) {
+    {
+      ResourceMark rm(this);
+      this->set_native_thread_name(this->get_thread_name());
+    }
     HandleMark hm(this);
     this->entry_point()(this, this);
   }
@@ -2679,7 +2712,7 @@
         name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length(), buf, buflen);
       }
     }
-    else if (is_attaching()) { // workaround for 6412693 - see 6404306
+    else if (is_attaching_via_jni()) { // workaround for 6412693 - see 6404306
       name_str = "<no-name - thread is attaching>";
     }
     else {
@@ -2860,6 +2893,44 @@
   }
 }
 
+class PrintAndVerifyOopClosure: public OopClosure {
+ protected:
+  template <class T> inline void do_oop_work(T* p) {
+    oop obj = oopDesc::load_decode_heap_oop(p);
+    if (obj == NULL) return;
+    tty->print(INTPTR_FORMAT ": ", p);
+    if (obj->is_oop_or_null()) {
+      if (obj->is_objArray()) {
+        tty->print_cr("valid objArray: " INTPTR_FORMAT, (oopDesc*) obj);
+      } else {
+        obj->print();
+      }
+    } else {
+      tty->print_cr("invalid oop: " INTPTR_FORMAT, (oopDesc*) obj);
+    }
+    tty->cr();
+  }
+ public:
+  virtual void do_oop(oop* p) { do_oop_work(p); }
+  virtual void do_oop(narrowOop* p)  { do_oop_work(p); }
+};
+
+
+static void oops_print(frame* f, const RegisterMap *map) {
+  PrintAndVerifyOopClosure print;
+  f->print_value();
+  f->oops_do(&print, NULL, (RegisterMap*)map);
+}
+
+// Print our all the locations that contain oops and whether they are
+// valid or not.  This useful when trying to find the oldest frame
+// where an oop has gone bad since the frame walk is from youngest to
+// oldest.
+void JavaThread::trace_oops() {
+  tty->print_cr("[Trace oops]");
+  frames_do(oops_print);
+}
+
 
 #ifdef ASSERT
 // Print or validate the layout of stack frames
@@ -3037,7 +3108,11 @@
     os::pause();
   }
 
+#ifndef USDT2
   HS_DTRACE_PROBE(hotspot, vm__init__begin);
+#else /* USDT2 */
+  HOTSPOT_VM_INIT_BEGIN();
+#endif /* USDT2 */
 
   // Record VM creation timing statistics
   TraceVmCreationTime create_vm_timer;
@@ -3292,7 +3367,11 @@
   // debug stuff, that does not work until all basic classes have been initialized.
   set_init_completed();
 
+#ifndef USDT2
   HS_DTRACE_PROBE(hotspot, vm__init__end);
+#else /* USDT2 */
+  HOTSPOT_VM_INIT_END();
+#endif /* USDT2 */
 
   // record VM initialization completion time
   Management::record_vm_init_completed();
@@ -3868,8 +3947,9 @@
     }
   }
   VMThread* vmt = VMThread::vm_thread();
-  if (vmt->claim_oops_do(is_par, cp))
+  if (vmt->claim_oops_do(is_par, cp)) {
     vmt->oops_do(f, cf);
+  }
 }
 
 #ifndef SERIALGC
--- a/hotspot/src/share/vm/runtime/thread.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/thread.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -309,6 +309,11 @@
   static void interrupt(Thread* thr);
   static bool is_interrupted(Thread* thr, bool clear_interrupted);
 
+  void set_native_thread_name(const char *name) {
+    assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
+    os::set_native_thread_name(name);
+  }
+
   ObjectMonitor** omInUseList_addr()             { return (ObjectMonitor **)&omInUseList; }
   Monitor* SR_lock() const                       { return _SR_lock; }
 
@@ -818,10 +823,17 @@
   bool                  _do_not_unlock_if_synchronized; // Do not unlock the receiver of a synchronized method (since it was
                                                  // never locked) when throwing an exception. Used by interpreter only.
 
-  //  Flag to mark a JNI thread in the process of attaching - See CR 6404306
-  //  This flag is never set true other than at construction, and in that case
-  //  is shortly thereafter set false
-  volatile bool _is_attaching;
+  // JNI attach states:
+  enum JNIAttachStates {
+    _not_attaching_via_jni = 1,  // thread is not attaching via JNI
+    _attaching_via_jni,          // thread is attaching via JNI
+    _attached_via_jni            // thread has attached via JNI
+  };
+
+  // A regular JavaThread's _jni_attach_state is _not_attaching_via_jni.
+  // A native thread that is attaching via JNI starts with a value
+  // of _attaching_via_jni and transitions to _attached_via_jni.
+  volatile JNIAttachStates _jni_attach_state;
 
  public:
   // State of the stack guard pages for this thread.
@@ -841,7 +853,6 @@
   volatile oop     _exception_oop;               // Exception thrown in compiled code
   volatile address _exception_pc;                // PC where exception happened
   volatile address _exception_handler_pc;        // PC for handler of exception
-  volatile int     _exception_stack_size;        // Size of frame where exception happened
   volatile int     _is_method_handle_return;     // true (== 1) if the current exception PC is a MethodHandle call site.
 
   // support for compilation
@@ -890,7 +901,7 @@
 
  public:
   // Constructor
-  JavaThread(bool is_attaching = false); // for main thread and JNI attached threads
+  JavaThread(bool is_attaching_via_jni = false); // for main thread and JNI attached threads
   JavaThread(ThreadFunction entry_point, size_t stack_size = 0);
   ~JavaThread();
 
@@ -1182,7 +1193,6 @@
 
   // Exception handling for compiled methods
   oop      exception_oop() const                 { return _exception_oop; }
-  int      exception_stack_size() const          { return _exception_stack_size; }
   address  exception_pc() const                  { return _exception_pc; }
   address  exception_handler_pc() const          { return _exception_handler_pc; }
   bool     is_method_handle_return() const       { return _is_method_handle_return == 1; }
@@ -1190,7 +1200,6 @@
   void set_exception_oop(oop o)                  { _exception_oop = o; }
   void set_exception_pc(address a)               { _exception_pc = a; }
   void set_exception_handler_pc(address a)       { _exception_handler_pc = a; }
-  void set_exception_stack_size(int size)        { _exception_stack_size = size; }
   void set_is_method_handle_return(bool value)   { _is_method_handle_return = value ? 1 : 0; }
 
   // Stack overflow support
@@ -1264,7 +1273,6 @@
   static ByteSize exception_oop_offset()         { return byte_offset_of(JavaThread, _exception_oop       ); }
   static ByteSize exception_pc_offset()          { return byte_offset_of(JavaThread, _exception_pc        ); }
   static ByteSize exception_handler_pc_offset()  { return byte_offset_of(JavaThread, _exception_handler_pc); }
-  static ByteSize exception_stack_size_offset()  { return byte_offset_of(JavaThread, _exception_stack_size); }
   static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); }
   static ByteSize stack_guard_state_offset()     { return byte_offset_of(JavaThread, _stack_guard_state   ); }
   static ByteSize suspend_flags_offset()         { return byte_offset_of(JavaThread, _suspend_flags       ); }
@@ -1379,6 +1387,7 @@
   void trace_stack()                             PRODUCT_RETURN;
   void trace_stack_from(vframe* start_vf)        PRODUCT_RETURN;
   void trace_frames()                            PRODUCT_RETURN;
+  void trace_oops()                              PRODUCT_RETURN;
 
   // Print an annotated view of the stack frames
   void print_frame_layout(int depth = 0, bool validate_only = false) NOT_DEBUG_RETURN;
@@ -1610,6 +1619,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "thread_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "thread_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "thread_bsd_zero.hpp"
+#endif
 
 
  public:
@@ -1638,8 +1653,9 @@
   void set_cached_monitor_info(GrowableArray<MonitorInfo*>* info) { _cached_monitor_info = info; }
 
   // clearing/querying jni attach status
-  bool is_attaching() const { return _is_attaching; }
-  void set_attached() { _is_attaching = false; OrderAccess::fence(); }
+  bool is_attaching_via_jni() const { return _jni_attach_state == _attaching_via_jni; }
+  bool has_attached_via_jni() const { return is_attaching_via_jni() || _jni_attach_state == _attached_via_jni; }
+  void set_done_attaching_via_jni() { _jni_attach_state = _attached_via_jni; OrderAccess::fence(); }
 private:
   // This field is used to determine if a thread has claimed
   // a par_id: it is -1 if the thread has not claimed a par_id;
--- a/hotspot/src/share/vm/runtime/threadLocalStorage.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/threadLocalStorage.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 // static member initialization
 int ThreadLocalStorage::_thread_index = -1;
--- a/hotspot/src/share/vm/runtime/threadLocalStorage.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/threadLocalStorage.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -68,6 +68,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "threadLS_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "threadLS_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "threadLS_bsd_zero.hpp"
+#endif
 
 
  public:
--- a/hotspot/src/share/vm/runtime/timer.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/timer.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 void elapsedTimer::add(elapsedTimer t) {
--- a/hotspot/src/share/vm/runtime/vframeArray.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/vframeArray.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,8 @@
 // represent an interpreter frame which will eventually be created.
 
 class vframeArrayElement : public _ValueObj {
+  friend class VMStructs;
+
   private:
 
     frame _frame;                                                // the interpreter frame we will unpack into
@@ -107,6 +109,8 @@
 // at the data in each vframeElement
 
 class vframeArray: public CHeapObj {
+  friend class VMStructs;
+
  private:
 
 
--- a/hotspot/src/share/vm/runtime/virtualspace.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/virtualspace.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 // ReservedSpace
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -29,6 +29,11 @@
 #include "classfile/placeholders.hpp"
 #include "classfile/symbolTable.hpp"
 #include "classfile/systemDictionary.hpp"
+#include "ci/ciField.hpp"
+#include "ci/ciInstance.hpp"
+#include "ci/ciObjArrayKlass.hpp"
+#include "ci/ciMethodData.hpp"
+#include "ci/ciSymbol.hpp"
 #include "code/codeBlob.hpp"
 #include "code/codeCache.hpp"
 #include "code/compressedStream.hpp"
@@ -38,6 +43,7 @@
 #include "code/stubs.hpp"
 #include "code/vmreg.hpp"
 #include "compiler/oopMap.hpp"
+#include "compiler/compileBroker.hpp"
 #include "gc_implementation/concurrentMarkSweep/freeBlockDictionary.hpp"
 #include "gc_implementation/shared/immutableSpace.hpp"
 #include "gc_implementation/shared/markSweep.hpp"
@@ -90,6 +96,8 @@
 #include "oops/typeArrayOop.hpp"
 #include "prims/jvmtiAgentThread.hpp"
 #include "runtime/arguments.hpp"
+#include "runtime/deoptimization.hpp"
+#include "runtime/vframeArray.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/java.hpp"
 #include "runtime/javaCalls.hpp"
@@ -125,6 +133,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef TARGET_OS_ARCH_linux_x86
 # include "vmStructs_linux_x86.hpp"
 #endif
@@ -149,6 +160,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "vmStructs_linux_ppc.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "vmStructs_bsd_x86.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "vmStructs_bsd_zero.hpp"
+#endif
 #ifndef SERIALGC
 #include "gc_implementation/concurrentMarkSweep/cmsPermGen.hpp"
 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
@@ -165,9 +182,26 @@
 #include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
 #include "gc_implementation/parallelScavenge/vmStructs_parallelgc.hpp"
+#include "gc_implementation/g1/vmStructs_g1.hpp"
 #endif
 #ifdef COMPILER2
+#include "opto/addnode.hpp"
+#include "opto/block.hpp"
+#include "opto/callnode.hpp"
+#include "opto/cfgnode.hpp"
+#include "opto/chaitin.hpp"
+#include "opto/divnode.hpp"
+#include "opto/locknode.hpp"
+#include "opto/loopnode.hpp"
+#include "opto/machnode.hpp"
 #include "opto/matcher.hpp"
+#include "opto/mulnode.hpp"
+#include "opto/phaseX.hpp"
+#include "opto/parse.hpp"
+#include "opto/regalloc.hpp"
+#include "opto/rootnode.hpp"
+#include "opto/subnode.hpp"
+#include "opto/vectornode.hpp"
 #ifdef TARGET_ARCH_MODEL_x86_32
 # include "adfiles/adGlobals_x86_32.hpp"
 #endif
@@ -261,6 +295,7 @@
   nonstatic_field(instanceKlass,               _nof_implementors,                             int)                                   \
   nonstatic_field(instanceKlass,               _implementors[0],                              klassOop)                              \
   nonstatic_field(instanceKlass,               _fields,                                       typeArrayOop)                          \
+  nonstatic_field(instanceKlass,               _java_fields_count,                             int)                                   \
   nonstatic_field(instanceKlass,               _constants,                                    constantPoolOop)                       \
   nonstatic_field(instanceKlass,               _class_loader,                                 oop)                                   \
   nonstatic_field(instanceKlass,               _protection_domain,                            oop)                                   \
@@ -293,6 +328,10 @@
   nonstatic_field(instanceKlass,               _methods_annotations,                          objArrayOop)                           \
   nonstatic_field(instanceKlass,               _methods_parameter_annotations,                objArrayOop)                           \
   nonstatic_field(instanceKlass,               _methods_default_annotations,                  objArrayOop)                           \
+  nonstatic_field(instanceKlass,               _dependencies,                                 nmethodBucket*)                        \
+  nonstatic_field(nmethodBucket,               _nmethod,                                      nmethod*)                              \
+  nonstatic_field(nmethodBucket,               _count,                                        int)                                   \
+  nonstatic_field(nmethodBucket,               _next,                                         nmethodBucket*)                        \
   nonstatic_field(Klass,                       _super_check_offset,                           juint)                                 \
   nonstatic_field(Klass,                       _secondary_super_cache,                        klassOop)                              \
   nonstatic_field(Klass,                       _secondary_supers,                             objArrayOop)                           \
@@ -311,17 +350,26 @@
   nonstatic_field(methodKlass,                 _alloc_size,                                   juint)                                 \
   nonstatic_field(methodDataOopDesc,           _size,                                         int)                                   \
   nonstatic_field(methodDataOopDesc,           _method,                                       methodOop)                             \
+  nonstatic_field(methodDataOopDesc,           _data_size,                                    int)                                   \
+  nonstatic_field(methodDataOopDesc,           _data[0],                                      intptr_t)                              \
+  nonstatic_field(methodDataOopDesc,           _nof_decompiles,                               uint)                                  \
+  nonstatic_field(methodDataOopDesc,           _nof_overflow_recompiles,                      uint)                                  \
+  nonstatic_field(methodDataOopDesc,           _nof_overflow_traps,                           uint)                                  \
+  nonstatic_field(methodDataOopDesc,           _eflags,                                       intx)                                  \
+  nonstatic_field(methodDataOopDesc,           _arg_local,                                    intx)                                  \
+  nonstatic_field(methodDataOopDesc,           _arg_stack,                                    intx)                                  \
+  nonstatic_field(methodDataOopDesc,           _arg_returned,                                 intx)                                  \
   nonstatic_field(methodOopDesc,               _constMethod,                                  constMethodOop)                        \
   nonstatic_field(methodOopDesc,               _constants,                                    constantPoolOop)                       \
-  c2_nonstatic_field(methodOopDesc,            _method_data,                                  methodDataOop)                         \
-  c2_nonstatic_field(methodOopDesc,            _interpreter_invocation_count,                 int)                                   \
+  nonstatic_field(methodOopDesc,               _method_data,                                  methodDataOop)                         \
+  nonstatic_field(methodOopDesc,               _interpreter_invocation_count,                 int)                                   \
   nonstatic_field(methodOopDesc,               _access_flags,                                 AccessFlags)                           \
   nonstatic_field(methodOopDesc,               _vtable_index,                                 int)                                   \
   nonstatic_field(methodOopDesc,               _method_size,                                  u2)                                    \
   nonstatic_field(methodOopDesc,               _max_stack,                                    u2)                                    \
   nonstatic_field(methodOopDesc,               _max_locals,                                   u2)                                    \
   nonstatic_field(methodOopDesc,               _size_of_parameters,                           u2)                                    \
-  c2_nonstatic_field(methodOopDesc,            _interpreter_throwout_count,                   u2)                                    \
+  nonstatic_field(methodOopDesc,               _interpreter_throwout_count,                   u2)                                    \
   nonstatic_field(methodOopDesc,               _number_of_breakpoints,                        u2)                                    \
   nonstatic_field(methodOopDesc,               _invocation_counter,                           InvocationCounter)                     \
   nonstatic_field(methodOopDesc,               _backedge_counter,                             InvocationCounter)                     \
@@ -407,7 +455,7 @@
      static_field(Universe,                    _constantPoolCacheKlassObj,                    klassOop)                              \
      static_field(Universe,                    _compiledICHolderKlassObj,                     klassOop)                              \
      static_field(Universe,                    _systemObjArrayKlassObj,                       klassOop)                              \
-     static_field(Universe,                    _mirrors[0],                                   oop)                                  \
+     static_field(Universe,                    _mirrors[0],                                   oop)                                   \
      static_field(Universe,                    _main_thread_group,                            oop)                                   \
      static_field(Universe,                    _system_thread_group,                          oop)                                   \
      static_field(Universe,                    _the_empty_byte_array,                         typeArrayOop)                          \
@@ -652,9 +700,16 @@
       static_field(SystemDictionary,            WK_KLASS(ThreadGroup_klass),                   klassOop)                             \
       static_field(SystemDictionary,            WK_KLASS(Properties_klass),                    klassOop)                             \
       static_field(SystemDictionary,            WK_KLASS(StringBuffer_klass),                  klassOop)                             \
+      static_field(SystemDictionary,            WK_KLASS(MethodHandle_klass),                  klassOop)                             \
       static_field(SystemDictionary,            _box_klasses[0],                               klassOop)                             \
       static_field(SystemDictionary,            _java_system_loader,                           oop)                                  \
                                                                                                                                      \
+  /*************/                                                                                                                    \
+  /* vmSymbols */                                                                                                                    \
+  /*************/                                                                                                                    \
+                                                                                                                                     \
+      static_field(vmSymbols,                   _symbols[0],                                  Symbol*)                               \
+                                                                                                                                     \
   /*******************/                                                                                                              \
   /* HashtableBucket */                                                                                                              \
   /*******************/                                                                                                              \
@@ -707,6 +762,15 @@
   nonstatic_field(LoaderConstraintEntry,       _max_loaders,                                  int)                                   \
   nonstatic_field(LoaderConstraintEntry,       _loaders,                                      oop*)                                  \
                                                                                                                                      \
+  /*******************/                                                                                                              \
+  /* GrowableArrays  */                                                                                                              \
+  /*******************/                                                                                                              \
+                                                                                                                                     \
+  nonstatic_field(GenericGrowableArray,        _len,                                          int)                                   \
+  nonstatic_field(GenericGrowableArray,        _max,                                          int)                                   \
+  nonstatic_field(GenericGrowableArray,        _arena,                                        Arena*)                                \
+  nonstatic_field(GrowableArray<int>,               _data,                                         int*) \
+                                                                                                                                     \
   /********************************/                                                                                                 \
   /* CodeCache (NOTE: incomplete) */                                                                                                 \
   /********************************/                                                                                                 \
@@ -757,12 +821,19 @@
   nonstatic_field(PcDesc,                      _pc_offset,                                    int)                                   \
   nonstatic_field(PcDesc,                      _scope_decode_offset,                          int)                                   \
   nonstatic_field(PcDesc,                      _obj_decode_offset,                            int)                                   \
-  nonstatic_field(PcDesc,                      _flags,                        PcDesc::PcDescFlags)                                   \
+  nonstatic_field(PcDesc,                      _flags,                                        int)                                   \
                                                                                                                                      \
   /***************************************************/                                                                              \
   /* CodeBlobs (NOTE: incomplete, but only a little) */                                                                              \
   /***************************************************/                                                                              \
                                                                                                                                      \
+  X86_ONLY(nonstatic_field(MethodHandles::RicochetFrame, _sender_pc,                                     address))                   \
+  X86_ONLY(nonstatic_field(MethodHandles::RicochetFrame, _exact_sender_sp,                              intptr_t*))                  \
+  X86_ONLY(nonstatic_field(MethodHandles::RicochetFrame, _sender_link,                                  intptr_t*))                  \
+  X86_ONLY(nonstatic_field(MethodHandles::RicochetFrame, _saved_args_base,                              intptr_t*))                  \
+                                                                                                                                     \
+     static_field(SharedRuntime,               _ricochet_blob,                                RicochetBlob*)                         \
+                                                                                                                                     \
   nonstatic_field(CodeBlob,                    _name,                                         const char*)                           \
   nonstatic_field(CodeBlob,                    _size,                                         int)                                   \
   nonstatic_field(CodeBlob,                    _header_size,                                  int)                                   \
@@ -774,6 +845,8 @@
   nonstatic_field(CodeBlob,                    _frame_size,                                   int)                                   \
   nonstatic_field(CodeBlob,                    _oop_maps,                                     OopMapSet*)                            \
                                                                                                                                      \
+  nonstatic_field(RuntimeStub,                 _caller_must_gc_arguments,                     bool)                                  \
+                                                                                                                                     \
   /**************************************************/                                                                               \
   /* NMethods (NOTE: incomplete, but only a little) */                                                                               \
   /**************************************************/                                                                               \
@@ -786,6 +859,7 @@
   nonstatic_field(nmethod,             _state,                                        unsigned char)                         \
   nonstatic_field(nmethod,             _exception_offset,                             int)                                   \
   nonstatic_field(nmethod,             _deoptimize_offset,                            int)                                   \
+  nonstatic_field(nmethod,             _deoptimize_mh_offset,                         int)                                   \
   nonstatic_field(nmethod,             _orig_pc_offset,                               int)                                   \
   nonstatic_field(nmethod,             _stub_offset,                                  int)                                   \
   nonstatic_field(nmethod,             _consts_offset,                                int)                                   \
@@ -802,8 +876,14 @@
   nonstatic_field(nmethod,             _lock_count,                                   jint)                                  \
   nonstatic_field(nmethod,             _stack_traversal_mark,                         long)                                  \
   nonstatic_field(nmethod,             _compile_id,                                   int)                                   \
+  nonstatic_field(nmethod,             _exception_cache,                              ExceptionCache*)                       \
   nonstatic_field(nmethod,             _marked_for_deoptimization,                    bool)                                  \
                                                                                                                                      \
+  nonstatic_field(RicochetBlob,        _bounce_offset,                                int)                                           \
+  nonstatic_field(RicochetBlob,        _exception_offset,                             int)                                           \
+                                                                                                                                     \
+  unchecked_c2_static_field(Deoptimization,         _trap_reason_name,                   void*)                                         \
+                                                                                                                                     \
   /********************************/                                                                                                 \
   /* JavaCalls (NOTE: incomplete) */                                                                                                 \
   /********************************/                                                                                                 \
@@ -824,6 +904,9 @@
      static_field(Threads,                     _number_of_non_daemon_threads,                 int)                                   \
      static_field(Threads,                     _return_code,                                  int)                                   \
                                                                                                                                      \
+  nonstatic_field(ThreadShadow,                _pending_exception,                            oop)                                   \
+  nonstatic_field(ThreadShadow,                _exception_file,                               const char*)                           \
+  nonstatic_field(ThreadShadow,                _exception_line,                               int)                                   \
    volatile_nonstatic_field(Thread,            _suspend_flags,                                uint32_t)                              \
   nonstatic_field(Thread,                      _active_handles,                               JNIHandleBlock*)                       \
   nonstatic_field(Thread,                      _tlab,                                         ThreadLocalAllocBuffer)                \
@@ -835,10 +918,22 @@
   nonstatic_field(JavaThread,                  _next,                                         JavaThread*)                           \
   nonstatic_field(JavaThread,                  _threadObj,                                    oop)                                   \
   nonstatic_field(JavaThread,                  _anchor,                                       JavaFrameAnchor)                       \
+  nonstatic_field(JavaThread,                  _vm_result,                                    oop)                                   \
+  nonstatic_field(JavaThread,                  _vm_result_2,                                  oop)                                   \
+  nonstatic_field(JavaThread,                  _pending_async_exception,                      oop)                                   \
+  volatile_nonstatic_field(JavaThread,         _exception_oop,                                oop)                                   \
+  volatile_nonstatic_field(JavaThread,         _exception_pc,                                 address)                               \
+  nonstatic_field(JavaThread,                  _is_compiling,                                 bool)                                  \
+  nonstatic_field(JavaThread,                  _special_runtime_exit_condition,               JavaThread::AsyncRequests)             \
+  nonstatic_field(JavaThread,                  _saved_exception_pc,                           address)                               \
    volatile_nonstatic_field(JavaThread,        _thread_state,                                 JavaThreadState)                       \
   nonstatic_field(JavaThread,                  _osthread,                                     OSThread*)                             \
   nonstatic_field(JavaThread,                  _stack_base,                                   address)                               \
   nonstatic_field(JavaThread,                  _stack_size,                                   size_t)                                \
+  nonstatic_field(JavaThread,                  _vframe_array_head,                            vframeArray*)                          \
+  nonstatic_field(JavaThread,                  _vframe_array_last,                            vframeArray*)                          \
+  nonstatic_field(Thread,                      _resource_area,                                ResourceArea*)                         \
+  nonstatic_field(CompilerThread,              _env,                                          ciEnv*)                                \
                                                                                                                                      \
   /************/                                                                                                                     \
   /* OSThread */                                                                                                                     \
@@ -888,7 +983,83 @@
   /* Runtime1 (NOTE: incomplete) */                                                                                                  \
   /*******************************/                                                                                                  \
                                                                                                                                      \
-  unchecked_c1_static_field(Runtime1,          _blobs,                                        sizeof(Runtime1::_blobs)) /* NOTE: no type */ \
+  unchecked_c1_static_field(Runtime1,          _blobs,                                 sizeof(Runtime1::_blobs)) /* NOTE: no type */ \
+                                                                                                                                     \
+  /**************/                                                                                                                   \
+  /* allocation */                                                                                                                   \
+  /**************/                                                                                                                   \
+                                                                                                                                     \
+  nonstatic_field(Chunk, _next, Chunk*)                                                                                              \
+  nonstatic_field(Chunk, _len, const size_t)                                                                                         \
+                                                                                                                                     \
+  nonstatic_field(Arena, _first, Chunk*)                                                                                             \
+  nonstatic_field(Arena, _chunk, Chunk*)                                                                                             \
+  nonstatic_field(Arena, _hwm, char*)                                                                                                \
+  nonstatic_field(Arena, _max, char*)                                                                                                \
+                                                                                                                                     \
+  /************/                                                                                                                     \
+  /* CI */                                                                                                                           \
+  /************/                                                                                                                     \
+                                                                                                                                     \
+ nonstatic_field(ciEnv,               _system_dictionary_modification_counter, int)                                                  \
+ nonstatic_field(ciEnv,               _compiler_data, void*)                                                                         \
+ nonstatic_field(ciEnv,               _failure_reason, const char*)                                                                  \
+ nonstatic_field(ciEnv,               _factory, ciObjectFactory*)                                                                    \
+ nonstatic_field(ciEnv,               _dependencies, Dependencies*)                                                                  \
+ nonstatic_field(ciEnv,               _task, CompileTask*)                                                                           \
+ nonstatic_field(ciEnv,               _arena, Arena*)                                                                                \
+                                                                                                                                     \
+ nonstatic_field(ciObject,    _handle, jobject)                                                                                      \
+ nonstatic_field(ciObject,    _klass, ciKlass*)                                                                                      \
+ nonstatic_field(ciObject,    _ident, uint)                                                                                          \
+                                                                                                                                     \
+ nonstatic_field(ciSymbol,    _ident, uint)                                                                                          \
+ nonstatic_field(ciSymbol,    _symbol, Symbol*)                                                                                      \
+                                                                                                                                     \
+ nonstatic_field(ciType,    _basic_type, BasicType)                                                                                  \
+                                                                                                                                     \
+ nonstatic_field(ciKlass,   _name, ciSymbol*)                                                                                        \
+                                                                                                                                     \
+ nonstatic_field(ciArrayKlass,   _dimension, jint)                                                                                   \
+                                                                                                                                     \
+ nonstatic_field(ciObjArrayKlass, _element_klass, ciKlass*)                                                                          \
+ nonstatic_field(ciObjArrayKlass, _base_element_klass, ciKlass*)                                                                     \
+                                                                                                                                     \
+ nonstatic_field(ciInstanceKlass,   _init_state, instanceKlass::ClassState)                                                          \
+ nonstatic_field(ciInstanceKlass,   _is_shared,  bool)                                                                               \
+                                                                                                                                     \
+ nonstatic_field(ciMethod,     _interpreter_invocation_count, int)                                                                   \
+ nonstatic_field(ciMethod,     _interpreter_throwout_count, int)                                                                     \
+                                                                                                                                     \
+ nonstatic_field(ciMethodData, _data_size, int)                                                                                      \
+ nonstatic_field(ciMethodData, _state, u_char)                                                                                       \
+ nonstatic_field(ciMethodData, _extra_data_size, int)                                                                                \
+ nonstatic_field(ciMethodData, _data, intptr_t*)                                                                                     \
+ nonstatic_field(ciMethodData, _hint_di, int)                                                                                        \
+ nonstatic_field(ciMethodData, _eflags, intx)                                                                                        \
+ nonstatic_field(ciMethodData, _arg_local, intx)                                                                                     \
+ nonstatic_field(ciMethodData, _arg_stack, intx)                                                                                     \
+ nonstatic_field(ciMethodData, _arg_returned, intx)                                                                                  \
+ nonstatic_field(ciMethodData, _current_mileage, int)                                                                                \
+ nonstatic_field(ciMethodData, _orig, methodDataOopDesc)                                                                             \
+                                                                                                                                     \
+ nonstatic_field(ciField,     _holder, ciInstanceKlass*)                                                                             \
+ nonstatic_field(ciField,     _name, ciSymbol*)                                                                                      \
+ nonstatic_field(ciField,     _signature, ciSymbol*)                                                                                 \
+ nonstatic_field(ciField,     _offset, int)                                                                                          \
+ nonstatic_field(ciField,     _is_constant, bool)                                                                                    \
+ nonstatic_field(ciField,     _constant_value, ciConstant)                                                                           \
+                                                                                                                                     \
+ nonstatic_field(ciObjectFactory,     _ci_objects, GrowableArray<ciObject*>*)                                                        \
+ nonstatic_field(ciObjectFactory,     _symbols, GrowableArray<ciSymbol*>*)                                                           \
+ nonstatic_field(ciObjectFactory,     _unloaded_methods, GrowableArray<ciMethod*>*)                                                  \
+                                                                                                                                     \
+ nonstatic_field(ciConstant,     _type, BasicType)                                                                                   \
+ nonstatic_field(ciConstant,     _value._int, jint)                                                                                  \
+ nonstatic_field(ciConstant,     _value._long, jlong)                                                                                \
+ nonstatic_field(ciConstant,     _value._float, jfloat)                                                                              \
+ nonstatic_field(ciConstant,     _value._double, jdouble)                                                                            \
+ nonstatic_field(ciConstant,     _value._object, ciObject*)                                                                          \
                                                                                                                                      \
   /************/                                                                                                                     \
   /* Monitors */                                                                                                                     \
@@ -910,7 +1081,114 @@
   /* Matcher (C2 only) */                                                                                                            \
   /*********************/                                                                                                            \
                                                                                                                                      \
-  unchecked_c2_static_field(Matcher,           _regEncode,                                    sizeof(Matcher::_regEncode)) /* NOTE: no type */ \
+  unchecked_c2_static_field(Matcher,           _regEncode,                          sizeof(Matcher::_regEncode)) /* NOTE: no type */ \
+                                                                                                                                     \
+  c2_nonstatic_field(Node,               _in,                      Node**)                                                           \
+  c2_nonstatic_field(Node,               _out,                     Node**)                                                           \
+  c2_nonstatic_field(Node,               _cnt,                     node_idx_t)                                                       \
+  c2_nonstatic_field(Node,               _max,                     node_idx_t)                                                       \
+  c2_nonstatic_field(Node,               _outcnt,                  node_idx_t)                                                       \
+  c2_nonstatic_field(Node,               _outmax,                  node_idx_t)                                                       \
+  c2_nonstatic_field(Node,               _idx,                     const node_idx_t)                                                 \
+  c2_nonstatic_field(Node,               _class_id,                jushort)                                                          \
+  c2_nonstatic_field(Node,               _flags,                   jushort)                                                          \
+                                                                                                                                     \
+  c2_nonstatic_field(Compile,            _root,                    RootNode*)                                                        \
+  c2_nonstatic_field(Compile,            _unique,                  uint)                                                             \
+  c2_nonstatic_field(Compile,            _entry_bci,               int)                                                              \
+  c2_nonstatic_field(Compile,            _top,                     Node*)                                                            \
+  c2_nonstatic_field(Compile,            _cfg,                     PhaseCFG*)                                                        \
+  c2_nonstatic_field(Compile,            _regalloc,                PhaseRegAlloc*)                                                   \
+  c2_nonstatic_field(Compile,            _method,                  ciMethod*)                                                        \
+  c2_nonstatic_field(Compile,            _compile_id,              const int)                                                        \
+  c2_nonstatic_field(Compile,            _save_argument_registers, const bool)                                                       \
+  c2_nonstatic_field(Compile,            _subsume_loads,           const bool)                                                       \
+  c2_nonstatic_field(Compile,            _do_escape_analysis,      const bool)                                                       \
+  c2_nonstatic_field(Compile,            _ilt,                     InlineTree*)                                                      \
+                                                                                                                                     \
+  c2_nonstatic_field(InlineTree,         _caller_jvms,             JVMState*)                                                        \
+  c2_nonstatic_field(InlineTree,         _method,                  ciMethod*)                                                        \
+  c2_nonstatic_field(InlineTree,         _caller_tree,             InlineTree*)                                                      \
+  c2_nonstatic_field(InlineTree,         _subtrees,                GrowableArray<InlineTree*>)                                       \
+                                                                                                                                     \
+  c2_nonstatic_field(OptoRegPair,        _first,                   short)                                                            \
+  c2_nonstatic_field(OptoRegPair,        _second,                  short)                                                            \
+                                                                                                                                     \
+  c2_nonstatic_field(JVMState,           _caller,                  JVMState*)                                                        \
+  c2_nonstatic_field(JVMState,           _depth,                   uint)                                                             \
+  c2_nonstatic_field(JVMState,           _locoff,                  uint)                                                             \
+  c2_nonstatic_field(JVMState,           _stkoff,                  uint)                                                             \
+  c2_nonstatic_field(JVMState,           _monoff,                  uint)                                                             \
+  c2_nonstatic_field(JVMState,           _scloff,                  uint)                                                             \
+  c2_nonstatic_field(JVMState,           _endoff,                  uint)                                                             \
+  c2_nonstatic_field(JVMState,           _sp,                      uint)                                                             \
+  c2_nonstatic_field(JVMState,           _bci,                     int)                                                              \
+  c2_nonstatic_field(JVMState,           _method,                  ciMethod*)                                                        \
+  c2_nonstatic_field(JVMState,           _map,                     SafePointNode*)                                                   \
+                                                                                                                                     \
+  c2_nonstatic_field(SafePointNode,      _jvms,                    JVMState* const)                                                  \
+                                                                                                                                     \
+  c2_nonstatic_field(MachSafePointNode,  _jvms,                    JVMState*)                                                        \
+  c2_nonstatic_field(MachSafePointNode,  _jvmadj,                  uint)                                                             \
+                                                                                                                                     \
+  c2_nonstatic_field(MachIfNode,         _prob,                    jfloat)                                                           \
+  c2_nonstatic_field(MachIfNode,         _fcnt,                    jfloat)                                                           \
+                                                                                                                                     \
+  c2_nonstatic_field(CallNode,           _entry_point,             address)                                                          \
+                                                                                                                                     \
+  c2_nonstatic_field(CallJavaNode,       _method,                  ciMethod*)                                                        \
+                                                                                                                                     \
+  c2_nonstatic_field(CallRuntimeNode,    _name,                    const char*)                                                      \
+                                                                                                                                     \
+  c2_nonstatic_field(CallStaticJavaNode, _name,                    const char*)                                                      \
+                                                                                                                                     \
+  c2_nonstatic_field(MachCallJavaNode,   _method,                  ciMethod*)                                                        \
+  c2_nonstatic_field(MachCallJavaNode,   _bci,                     int)                                                              \
+                                                                                                                                     \
+  c2_nonstatic_field(MachCallStaticJavaNode, _name,                const char*)                                                      \
+                                                                                                                                     \
+  c2_nonstatic_field(MachCallRuntimeNode,  _name,                  const char*)                                                      \
+                                                                                                                                     \
+  c2_nonstatic_field(PhaseCFG,           _num_blocks,              uint)                                                             \
+  c2_nonstatic_field(PhaseCFG,           _blocks,                  Block_List)                                                       \
+  c2_nonstatic_field(PhaseCFG,           _bbs,                     Block_Array)                                                      \
+  c2_nonstatic_field(PhaseCFG,           _broot,                   Block*)                                                           \
+                                                                                                                                     \
+  c2_nonstatic_field(PhaseRegAlloc,      _node_regs,               OptoRegPair*)                                                     \
+  c2_nonstatic_field(PhaseRegAlloc,      _node_regs_max_index,     uint)                                                             \
+  c2_nonstatic_field(PhaseRegAlloc,      _framesize,               uint)                                                             \
+  c2_nonstatic_field(PhaseRegAlloc,      _max_reg,                 OptoReg::Name)                                                    \
+                                                                                                                                     \
+  c2_nonstatic_field(PhaseChaitin,       _trip_cnt,                int)                                                              \
+  c2_nonstatic_field(PhaseChaitin,       _alternate,               int)                                                              \
+  c2_nonstatic_field(PhaseChaitin,       _lo_degree,               uint)                                                             \
+  c2_nonstatic_field(PhaseChaitin,       _lo_stk_degree,           uint)                                                             \
+  c2_nonstatic_field(PhaseChaitin,       _hi_degree,               uint)                                                             \
+  c2_nonstatic_field(PhaseChaitin,       _simplified,              uint)                                                             \
+  c2_nonstatic_field(PhaseChaitin,       _maxlrg,                  uint)                                                             \
+                                                                                                                                     \
+  c2_nonstatic_field(Block,              _nodes,                   Node_List)                                                        \
+  c2_nonstatic_field(Block,              _succs,                   Block_Array)                                                      \
+  c2_nonstatic_field(Block,              _num_succs,               uint)                                                             \
+  c2_nonstatic_field(Block,              _pre_order,               uint)                                                             \
+  c2_nonstatic_field(Block,              _dom_depth,               uint)                                                             \
+  c2_nonstatic_field(Block,              _idom,                    Block*)                                                           \
+  c2_nonstatic_field(Block,              _freq,                    jfloat)                                                           \
+                                                                                                                                     \
+  c2_nonstatic_field(CFGElement,         _freq,                    jfloat)                                                           \
+                                                                                                                                     \
+  c2_nonstatic_field(Block_List,         _cnt,                     uint)                                                             \
+                                                                                                                                     \
+  c2_nonstatic_field(Block_Array,        _size,                    uint)                                                             \
+  c2_nonstatic_field(Block_Array,        _blocks,                  Block**)                                                          \
+  c2_nonstatic_field(Block_Array,        _arena,                   Arena*)                                                           \
+                                                                                                                                     \
+  c2_nonstatic_field(Node_List,          _cnt,                     uint)                                                             \
+                                                                                                                                     \
+  c2_nonstatic_field(Node_Array,         _max,                     uint)                                                             \
+  c2_nonstatic_field(Node_Array,         _nodes,                   Node**)                                                           \
+  c2_nonstatic_field(Node_Array,         _a,                       Arena*)                                                           \
+                                                                                                                                     \
                                                                                                                                      \
   /*********************/                                                                                                            \
   /* -XX flags         */                                                                                                            \
@@ -920,6 +1198,7 @@
   nonstatic_field(Flag,                        name,                                          const char*)                           \
   unchecked_nonstatic_field(Flag,              addr,                                          sizeof(void*)) /* NOTE: no type */     \
   nonstatic_field(Flag,                        kind,                                          const char*)                           \
+  nonstatic_field(Flag,                        origin,                                        FlagValueOrigin)                       \
   static_field(Flag,                           flags,                                         Flag*)                                 \
   static_field(Flag,                           numFlags,                                      size_t)                                \
                                                                                                                                      \
@@ -937,7 +1216,14 @@
   nonstatic_field(JDK_Version,                 _partially_initialized,                        bool)                                  \
   nonstatic_field(JDK_Version,                 _major,                                        unsigned char)                         \
                                                                                                                                      \
+  /*************************/                                                                                                        \
+  /* JVMTI */                                                                                                                        \
+  /*************************/                                                                                                        \
                                                                                                                                      \
+  static_field(JvmtiExport,                     _can_access_local_variables,                  bool)                                  \
+  static_field(JvmtiExport,                     _can_hotswap_or_post_breakpoint,              bool)                                  \
+  static_field(JvmtiExport,                     _can_post_on_exceptions,                      bool)                                  \
+  static_field(JvmtiExport,                     _can_walk_any_space,                          bool)                                  \
                                                                                                                                      \
   /*************/                                                                                                                    \
   /* Arguments */                                                                                                                    \
@@ -953,20 +1239,36 @@
   /* java_lang_Class fields        */                                                                                                \
   /*********************************/                                                                                                \
                                                                                                                                      \
-  static_field(java_lang_Class,                klass_offset,                                  int)                                   \
-  static_field(java_lang_Class,                resolved_constructor_offset,                   int)                                   \
-  static_field(java_lang_Class,                array_klass_offset,                            int)                                   \
-  static_field(java_lang_Class,                oop_size_offset,                               int)                                   \
-  static_field(java_lang_Class,                static_oop_field_count_offset,                 int)                                   \
+  static_field(java_lang_Class,                _klass_offset,                                 int)                                   \
+  static_field(java_lang_Class,                _resolved_constructor_offset,                  int)                                   \
+  static_field(java_lang_Class,                _array_klass_offset,                           int)                                   \
+  static_field(java_lang_Class,                _oop_size_offset,                              int)                                   \
+  static_field(java_lang_Class,                _static_oop_field_count_offset,                int)                                   \
                                                                                                                                      \
   /************************/                                                                                                         \
   /* Miscellaneous fields */                                                                                                         \
   /************************/                                                                                                         \
                                                                                                                                      \
-  nonstatic_field(AccessFlags,                 _flags,                                        jint)                                  \
-  nonstatic_field(elapsedTimer,                _counter,                                      jlong)                                 \
-  nonstatic_field(elapsedTimer,                _active,                                       bool)                                  \
-  nonstatic_field(InvocationCounter,           _counter,                                      unsigned int)
+  nonstatic_field(CompileTask,                 _method,                                      jobject)                                \
+  nonstatic_field(CompileTask,                 _osr_bci,                                     int)                                    \
+  nonstatic_field(CompileTask,                 _comp_level,                                  int)                                    \
+  nonstatic_field(CompileTask,                 _compile_id,                                  uint)                                   \
+  nonstatic_field(CompileTask,                 _next,                                        CompileTask*)                           \
+  nonstatic_field(CompileTask,                 _prev,                                        CompileTask*)                           \
+                                                                                                                                     \
+  nonstatic_field(vframeArray,                 _next,                                        vframeArray*)                           \
+  nonstatic_field(vframeArray,                 _original,                                    frame)                                  \
+  nonstatic_field(vframeArray,                 _caller,                                      frame)                                  \
+  nonstatic_field(vframeArray,                 _frames,                                      int)                                    \
+                                                                                                                                     \
+  nonstatic_field(vframeArrayElement,          _frame,                                       frame)                                  \
+  nonstatic_field(vframeArrayElement,          _bci,                                         int)                                    \
+  nonstatic_field(vframeArrayElement,          _method,                                      methodOop)                              \
+                                                                                                                                     \
+  nonstatic_field(AccessFlags,                 _flags,                                       jint)                                   \
+  nonstatic_field(elapsedTimer,                _counter,                                     jlong)                                  \
+  nonstatic_field(elapsedTimer,                _active,                                      bool)                                   \
+  nonstatic_field(InvocationCounter,           _counter,                                     unsigned int)
 
   /* NOTE that we do not use the last_entry() macro here; it is used  */
   /* in vmStructs_<os>_<cpu>.hpp's VM_STRUCTS_OS_CPU macro (and must  */
@@ -1046,12 +1348,16 @@
   /* and are valid types for Fields.                                   */ \
   /*********************************************************************/ \
   declare_integer_type(bool)                                              \
+  declare_integer_type(short)                                             \
   declare_integer_type(int)                                               \
   declare_integer_type(long)                                              \
   declare_integer_type(char)                                              \
   declare_unsigned_integer_type(unsigned char)                            \
+  declare_unsigned_integer_type(u_char)                                   \
   declare_unsigned_integer_type(unsigned int)                             \
+  declare_unsigned_integer_type(uint)                                     \
   declare_unsigned_integer_type(unsigned short)                           \
+  declare_unsigned_integer_type(jushort)                                  \
   declare_unsigned_integer_type(unsigned long)                            \
   /* The compiler thinks this is a different type than */                 \
   /* unsigned short on Win32 */                                           \
@@ -1065,7 +1371,6 @@
   declare_toplevel_type(int*)                                             \
   declare_toplevel_type(char*)                                            \
   declare_toplevel_type(char**)                                           \
-  declare_toplevel_type(const char*)                                      \
   declare_toplevel_type(u_char*)                                          \
   declare_toplevel_type(unsigned char*)                                   \
                                                                           \
@@ -1077,14 +1382,12 @@
                                                                           \
   declare_unsigned_integer_type(size_t)                                   \
   declare_integer_type(ssize_t)                                           \
-  declare_unsigned_integer_type(const size_t)                             \
   declare_integer_type(intx)                                              \
   declare_integer_type(intptr_t)                                          \
   declare_unsigned_integer_type(uintx)                                    \
   declare_unsigned_integer_type(uintptr_t)                                \
   declare_unsigned_integer_type(uint32_t)                                 \
   declare_unsigned_integer_type(uint64_t)                                 \
-  declare_integer_type(const int)                                         \
                                                                           \
   /*******************************************************************************/ \
   /* OopDesc and Klass hierarchies (NOTE: missing methodDataOop-related classes) */ \
@@ -1110,8 +1413,8 @@
            declare_type(klassKlass, Klass)                                \
            declare_type(klassOopDesc, oopDesc)                            \
            declare_type(markOopDesc, oopDesc)                             \
-   declare_type(methodDataKlass, Klass)                           \
-   declare_type(methodDataOopDesc, oopDesc)                       \
+   declare_type(methodDataKlass, Klass)                                   \
+   declare_type(methodDataOopDesc, oopDesc)                               \
            declare_type(methodKlass, Klass)                               \
            declare_type(constMethodKlass, Klass)                          \
            declare_type(methodOopDesc, oopDesc)                           \
@@ -1125,6 +1428,8 @@
            declare_toplevel_type(Symbol)                                  \
            declare_toplevel_type(Symbol*)                                 \
                                                                           \
+  declare_toplevel_type(nmethodBucket)                                    \
+                                                                          \
   /********/                                                              \
   /* Oops */                                                              \
   /********/                                                              \
@@ -1192,7 +1497,6 @@
   declare_toplevel_type(GenerationSpec)                                   \
   declare_toplevel_type(HeapWord)                                         \
   declare_toplevel_type(MemRegion)                                        \
-  declare_toplevel_type(const MemRegion)                                  \
   declare_toplevel_type(PermanentGenerationSpec)                          \
   declare_toplevel_type(ThreadLocalAllocBuffer)                           \
   declare_toplevel_type(VirtualSpace)                                     \
@@ -1251,8 +1555,15 @@
     declare_type(LoaderConstraintEntry, HashtableEntry<klassOop>)         \
   declare_toplevel_type(HashtableBucket)                                  \
   declare_toplevel_type(SystemDictionary)                                 \
+  declare_toplevel_type(vmSymbols)                                        \
   declare_toplevel_type(ProtectionDomainEntry)                            \
                                                                           \
+  declare_toplevel_type(GenericGrowableArray)                             \
+  declare_toplevel_type(GrowableArray<int>)                               \
+  declare_toplevel_type(Arena)                                            \
+    declare_type(ResourceArea, Arena)                                     \
+  declare_toplevel_type(Chunk)                                            \
+                                                                          \
   /***********************************************************/           \
   /* Thread hierarchy (needed for run-time type information) */           \
   /***********************************************************/           \
@@ -1265,7 +1576,7 @@
            declare_type(JavaThread, Thread)                               \
            declare_type(JvmtiAgentThread, JavaThread)                     \
            declare_type(ServiceThread, JavaThread)                        \
-  declare_type(CompilerThread, JavaThread)                        \
+  declare_type(CompilerThread, JavaThread)                                \
   declare_toplevel_type(OSThread)                                         \
   declare_toplevel_type(JavaFrameAnchor)                                  \
                                                                           \
@@ -1310,24 +1621,32 @@
   /* CodeBlob hierarchy (needed for run-time type information) */         \
   /*************************************************************/         \
                                                                           \
+  declare_toplevel_type(SharedRuntime)                                    \
+  X86_ONLY(declare_toplevel_type(MethodHandles::RicochetFrame))           \
+                                                                          \
   declare_toplevel_type(CodeBlob)                                         \
-  declare_type(BufferBlob,            CodeBlob)                           \
-  declare_type(AdapterBlob,           BufferBlob)                         \
-  declare_type(nmethod,               CodeBlob)                           \
-  declare_type(RuntimeStub,           CodeBlob)                           \
-  declare_type(SingletonBlob,         CodeBlob)                           \
-  declare_type(SafepointBlob,         SingletonBlob)                      \
-  declare_type(DeoptimizationBlob,    SingletonBlob)                      \
-  declare_type(RicochetBlob,          SingletonBlob)                      \
-  declare_c2_type(ExceptionBlob,      SingletonBlob)                      \
-  declare_c2_type(UncommonTrapBlob,   CodeBlob)                           \
+  declare_type(BufferBlob,               CodeBlob)                        \
+  declare_type(AdapterBlob,              BufferBlob)                      \
+  declare_type(MethodHandlesAdapterBlob, BufferBlob)                      \
+  declare_type(nmethod,                  CodeBlob)                        \
+  declare_type(RuntimeStub,              CodeBlob)                        \
+  declare_type(SingletonBlob,            CodeBlob)                        \
+  declare_type(SafepointBlob,            SingletonBlob)                   \
+  declare_type(DeoptimizationBlob,       SingletonBlob)                   \
+  declare_type(RicochetBlob,             SingletonBlob)                   \
+  declare_c2_type(ExceptionBlob,         SingletonBlob)                   \
+  declare_c2_type(UncommonTrapBlob,      CodeBlob)                        \
                                                                           \
   /***************************************/                               \
   /* PcDesc and other compiled code info */                               \
   /***************************************/                               \
                                                                           \
   declare_toplevel_type(PcDesc)                                           \
-  declare_integer_type(PcDesc::PcDescFlags)                               \
+  declare_toplevel_type(ExceptionCache)                                   \
+  declare_toplevel_type(PcDescCache)                                      \
+  declare_toplevel_type(Dependencies)                                     \
+  declare_toplevel_type(CompileTask)                                      \
+  declare_toplevel_type(Deoptimization)                                   \
                                                                           \
   /************************/                                              \
   /* OopMap and OopMapSet */                                              \
@@ -1354,6 +1673,7 @@
                                                                           \
   declare_toplevel_type(JNIHandles)                                       \
   declare_toplevel_type(JNIHandleBlock)                                   \
+  declare_toplevel_type(jobject)                                          \
                                                                           \
   /**********************/                                                \
   /* Runtime1 (C1 only) */                                                \
@@ -1374,9 +1694,349 @@
   /* Matcher (C2 only) */                                                 \
   /*********************/                                                 \
                                                                           \
-  /* NOTE: this is not really a toplevel type, but we only need */        \
-  /* this one -- FIXME later if necessary */                              \
   declare_c2_toplevel_type(Matcher)                                       \
+  declare_c2_toplevel_type(Compile)                                       \
+  declare_c2_toplevel_type(InlineTree)                                    \
+  declare_c2_toplevel_type(OptoRegPair)                                   \
+  declare_c2_toplevel_type(JVMState)                                      \
+  declare_c2_toplevel_type(Phase)                                         \
+    declare_c2_type(PhaseCFG, Phase)                                      \
+    declare_c2_type(PhaseRegAlloc, Phase)                                 \
+    declare_c2_type(PhaseChaitin, PhaseRegAlloc)                          \
+  declare_c2_toplevel_type(CFGElement)                                    \
+    declare_c2_type(Block, CFGElement)                                    \
+  declare_c2_toplevel_type(Block_Array)                                   \
+    declare_c2_type(Block_List, Block_Array)                              \
+  declare_c2_toplevel_type(Node_Array)                                    \
+  declare_c2_type(Node_List, Node_Array)                                  \
+  declare_c2_type(Unique_Node_List, Node_List)                            \
+  declare_c2_toplevel_type(Node)                                          \
+  declare_c2_type(AddNode, Node)                                          \
+  declare_c2_type(AddINode, AddNode)                                      \
+  declare_c2_type(AddLNode, AddNode)                                      \
+  declare_c2_type(AddFNode, AddNode)                                      \
+  declare_c2_type(AddDNode, AddNode)                                      \
+  declare_c2_type(AddPNode, Node)                                         \
+  declare_c2_type(OrINode, AddNode)                                       \
+  declare_c2_type(OrLNode, AddNode)                                       \
+  declare_c2_type(XorINode, AddNode)                                      \
+  declare_c2_type(XorLNode, AddNode)                                      \
+  declare_c2_type(MaxNode, AddNode)                                       \
+  declare_c2_type(MaxINode, MaxNode)                                      \
+  declare_c2_type(MinINode, MaxNode)                                      \
+  declare_c2_type(StartNode, MultiNode)                                   \
+  declare_c2_type(StartOSRNode, StartNode)                                \
+  declare_c2_type(ParmNode, ProjNode)                                     \
+  declare_c2_type(ReturnNode, Node)                                       \
+  declare_c2_type(RethrowNode, Node)                                      \
+  declare_c2_type(TailCallNode, ReturnNode)                               \
+  declare_c2_type(TailJumpNode, ReturnNode)                               \
+  declare_c2_type(SafePointNode, MultiNode)                               \
+  declare_c2_type(CallNode, SafePointNode)                                \
+  declare_c2_type(CallJavaNode, CallNode)                                 \
+  declare_c2_type(CallStaticJavaNode, CallJavaNode)                       \
+  declare_c2_type(CallDynamicJavaNode, CallJavaNode)                      \
+  declare_c2_type(CallRuntimeNode, CallNode)                              \
+  declare_c2_type(CallLeafNode, CallRuntimeNode)                          \
+  declare_c2_type(CallLeafNoFPNode, CallLeafNode)                         \
+  declare_c2_type(AllocateNode, CallNode)                                 \
+  declare_c2_type(AllocateArrayNode, AllocateNode)                        \
+  declare_c2_type(LockNode, AbstractLockNode)                             \
+  declare_c2_type(UnlockNode, AbstractLockNode)                           \
+  declare_c2_type(FastLockNode, CmpNode)                                  \
+  declare_c2_type(FastUnlockNode, CmpNode)                                \
+  declare_c2_type(RegionNode, Node)                                       \
+  declare_c2_type(JProjNode, ProjNode)                                    \
+  declare_c2_type(PhiNode, TypeNode)                                      \
+  declare_c2_type(GotoNode, Node)                                         \
+  declare_c2_type(CProjNode, ProjNode)                                    \
+  declare_c2_type(MultiBranchNode, MultiNode)                             \
+  declare_c2_type(IfNode, MultiBranchNode)                                \
+  declare_c2_type(IfTrueNode, CProjNode)                                  \
+  declare_c2_type(IfFalseNode, CProjNode)                                 \
+  declare_c2_type(PCTableNode, MultiBranchNode)                           \
+  declare_c2_type(JumpNode, PCTableNode)                                  \
+  declare_c2_type(JumpProjNode, JProjNode)                                \
+  declare_c2_type(CatchNode, PCTableNode)                                 \
+  declare_c2_type(CatchProjNode, CProjNode)                               \
+  declare_c2_type(CreateExNode, TypeNode)                                 \
+  declare_c2_type(ClearArrayNode, Node)                                   \
+  declare_c2_type(NeverBranchNode, MultiBranchNode)                       \
+  declare_c2_type(ConNode, TypeNode)                                      \
+  declare_c2_type(ConINode, ConNode)                                      \
+  declare_c2_type(ConPNode, ConNode)                                      \
+  declare_c2_type(ConNNode, ConNode)                                      \
+  declare_c2_type(ConLNode, ConNode)                                      \
+  declare_c2_type(ConFNode, ConNode)                                      \
+  declare_c2_type(ConDNode, ConNode)                                      \
+  declare_c2_type(BinaryNode, Node)                                       \
+  declare_c2_type(CMoveNode, TypeNode)                                    \
+  declare_c2_type(CMoveDNode, CMoveNode)                                  \
+  declare_c2_type(CMoveFNode, CMoveNode)                                  \
+  declare_c2_type(CMoveINode, CMoveNode)                                  \
+  declare_c2_type(CMoveLNode, CMoveNode)                                  \
+  declare_c2_type(CMovePNode, CMoveNode)                                  \
+  declare_c2_type(CMoveNNode, CMoveNode)                                  \
+  declare_c2_type(EncodePNode, TypeNode)                                  \
+  declare_c2_type(DecodeNNode, TypeNode)                                  \
+  declare_c2_type(ConstraintCastNode, TypeNode)                           \
+  declare_c2_type(CastIINode, ConstraintCastNode)                         \
+  declare_c2_type(CastPPNode, ConstraintCastNode)                         \
+  declare_c2_type(CheckCastPPNode, TypeNode)                              \
+  declare_c2_type(Conv2BNode, Node)                                       \
+  declare_c2_type(ConvD2FNode, Node)                                      \
+  declare_c2_type(ConvD2INode, Node)                                      \
+  declare_c2_type(ConvD2LNode, Node)                                      \
+  declare_c2_type(ConvF2DNode, Node)                                      \
+  declare_c2_type(ConvF2INode, Node)                                      \
+  declare_c2_type(ConvF2LNode, Node)                                      \
+  declare_c2_type(ConvI2DNode, Node)                                      \
+  declare_c2_type(ConvI2FNode, Node)                                      \
+  declare_c2_type(ConvI2LNode, TypeNode)                                  \
+  declare_c2_type(ConvL2DNode, Node)                                      \
+  declare_c2_type(ConvL2FNode, Node)                                      \
+  declare_c2_type(ConvL2INode, Node)                                      \
+  declare_c2_type(CastX2PNode, Node)                                      \
+  declare_c2_type(CastP2XNode, Node)                                      \
+  declare_c2_type(MemBarNode, MultiNode)                                  \
+  declare_c2_type(MemBarAcquireNode, MemBarNode)                          \
+  declare_c2_type(MemBarReleaseNode, MemBarNode)                          \
+  declare_c2_type(MemBarVolatileNode, MemBarNode)                         \
+  declare_c2_type(MemBarCPUOrderNode, MemBarNode)                         \
+  declare_c2_type(InitializeNode, MemBarNode)                             \
+  declare_c2_type(ThreadLocalNode, Node)                                  \
+  declare_c2_type(Opaque1Node, Node)                                      \
+  declare_c2_type(Opaque2Node, Node)                                      \
+  declare_c2_type(PartialSubtypeCheckNode, Node)                          \
+  declare_c2_type(MoveI2FNode, Node)                                      \
+  declare_c2_type(MoveL2DNode, Node)                                      \
+  declare_c2_type(MoveF2INode, Node)                                      \
+  declare_c2_type(MoveD2LNode, Node)                                      \
+  declare_c2_type(DivINode, Node)                                         \
+  declare_c2_type(DivLNode, Node)                                         \
+  declare_c2_type(DivFNode, Node)                                         \
+  declare_c2_type(DivDNode, Node)                                         \
+  declare_c2_type(ModINode, Node)                                         \
+  declare_c2_type(ModLNode, Node)                                         \
+  declare_c2_type(ModFNode, Node)                                         \
+  declare_c2_type(ModDNode, Node)                                         \
+  declare_c2_type(DivModNode, MultiNode)                                  \
+  declare_c2_type(DivModINode, DivModNode)                                \
+  declare_c2_type(DivModLNode, DivModNode)                                \
+  declare_c2_type(BoxLockNode, Node)                                      \
+  declare_c2_type(LoopNode, RegionNode)                                   \
+  declare_c2_type(CountedLoopNode, LoopNode)                              \
+  declare_c2_type(CountedLoopEndNode, IfNode)                             \
+  declare_c2_type(MachNode, Node)                                         \
+  declare_c2_type(MachIdealNode, MachNode)                                \
+  declare_c2_type(MachTypeNode, MachNode)                                 \
+  declare_c2_type(MachBreakpointNode, MachIdealNode)                      \
+  declare_c2_type(MachUEPNode, MachIdealNode)                             \
+  declare_c2_type(MachPrologNode, MachIdealNode)                          \
+  declare_c2_type(MachEpilogNode, MachIdealNode)                          \
+  declare_c2_type(MachNopNode, MachIdealNode)                             \
+  declare_c2_type(MachSpillCopyNode, MachIdealNode)                       \
+  declare_c2_type(MachNullCheckNode, MachIdealNode)                       \
+  declare_c2_type(MachProjNode, ProjNode)                                 \
+  declare_c2_type(MachIfNode, MachNode)                                   \
+  declare_c2_type(MachFastLockNode, MachNode)                             \
+  declare_c2_type(MachReturnNode, MachNode)                               \
+  declare_c2_type(MachSafePointNode, MachReturnNode)                      \
+  declare_c2_type(MachCallNode, MachSafePointNode)                        \
+  declare_c2_type(MachCallJavaNode, MachCallNode)                         \
+  declare_c2_type(MachCallStaticJavaNode, MachCallJavaNode)               \
+  declare_c2_type(MachCallDynamicJavaNode, MachCallJavaNode)              \
+  declare_c2_type(MachCallRuntimeNode, MachCallNode)                      \
+  declare_c2_type(MachHaltNode, MachReturnNode)                           \
+  declare_c2_type(MachTempNode, MachNode)                                 \
+  declare_c2_type(MemNode, Node)                                          \
+  declare_c2_type(MergeMemNode, Node)                                     \
+  declare_c2_type(LoadNode, MemNode)                                      \
+  declare_c2_type(LoadBNode, LoadNode)                                    \
+  declare_c2_type(LoadUSNode, LoadNode)                                   \
+  declare_c2_type(LoadINode, LoadNode)                                    \
+  declare_c2_type(LoadRangeNode, LoadINode)                               \
+  declare_c2_type(LoadLNode, LoadNode)                                    \
+  declare_c2_type(LoadL_unalignedNode, LoadLNode)                         \
+  declare_c2_type(LoadFNode, LoadNode)                                    \
+  declare_c2_type(LoadDNode, LoadNode)                                    \
+  declare_c2_type(LoadD_unalignedNode, LoadDNode)                         \
+  declare_c2_type(LoadPNode, LoadNode)                                    \
+  declare_c2_type(LoadNNode, LoadNode)                                    \
+  declare_c2_type(LoadKlassNode, LoadPNode)                               \
+  declare_c2_type(LoadNKlassNode, LoadNNode)                              \
+  declare_c2_type(LoadSNode, LoadNode)                                    \
+  declare_c2_type(StoreNode, MemNode)                                     \
+  declare_c2_type(StoreBNode, StoreNode)                                  \
+  declare_c2_type(StoreCNode, StoreNode)                                  \
+  declare_c2_type(StoreINode, StoreNode)                                  \
+  declare_c2_type(StoreLNode, StoreNode)                                  \
+  declare_c2_type(StoreFNode, StoreNode)                                  \
+  declare_c2_type(StoreDNode, StoreNode)                                  \
+  declare_c2_type(StorePNode, StoreNode)                                  \
+  declare_c2_type(StoreNNode, StoreNode)                                  \
+  declare_c2_type(StoreCMNode, StoreNode)                                 \
+  declare_c2_type(LoadPLockedNode, LoadPNode)                             \
+  declare_c2_type(LoadLLockedNode, LoadLNode)                             \
+  declare_c2_type(SCMemProjNode, ProjNode)                                \
+  declare_c2_type(LoadStoreNode, Node)                                    \
+  declare_c2_type(StorePConditionalNode, LoadStoreNode)                   \
+  declare_c2_type(StoreLConditionalNode, LoadStoreNode)                   \
+  declare_c2_type(CompareAndSwapLNode, LoadStoreNode)                     \
+  declare_c2_type(CompareAndSwapINode, LoadStoreNode)                     \
+  declare_c2_type(CompareAndSwapPNode, LoadStoreNode)                     \
+  declare_c2_type(CompareAndSwapNNode, LoadStoreNode)                     \
+  declare_c2_type(PrefetchReadNode, Node)                                 \
+  declare_c2_type(PrefetchWriteNode, Node)                                \
+  declare_c2_type(MulNode, Node)                                          \
+  declare_c2_type(MulINode, MulNode)                                      \
+  declare_c2_type(MulLNode, MulNode)                                      \
+  declare_c2_type(MulFNode, MulNode)                                      \
+  declare_c2_type(MulDNode, MulNode)                                      \
+  declare_c2_type(MulHiLNode, Node)                                       \
+  declare_c2_type(AndINode, MulINode)                                     \
+  declare_c2_type(AndLNode, MulLNode)                                     \
+  declare_c2_type(LShiftINode, Node)                                      \
+  declare_c2_type(LShiftLNode, Node)                                      \
+  declare_c2_type(RShiftINode, Node)                                      \
+  declare_c2_type(RShiftLNode, Node)                                      \
+  declare_c2_type(URShiftINode, Node)                                     \
+  declare_c2_type(URShiftLNode, Node)                                     \
+  declare_c2_type(MultiNode, Node)                                        \
+  declare_c2_type(ProjNode, Node)                                         \
+  declare_c2_type(TypeNode, Node)                                         \
+  declare_c2_type(NodeHash, StackObj)                                     \
+  declare_c2_type(RootNode, LoopNode)                                     \
+  declare_c2_type(HaltNode, Node)                                         \
+  declare_c2_type(SubNode, Node)                                          \
+  declare_c2_type(SubINode, SubNode)                                      \
+  declare_c2_type(SubLNode, SubNode)                                      \
+  declare_c2_type(SubFPNode, SubNode)                                     \
+  declare_c2_type(SubFNode, SubFPNode)                                    \
+  declare_c2_type(SubDNode, SubFPNode)                                    \
+  declare_c2_type(CmpNode, SubNode)                                       \
+  declare_c2_type(CmpINode, CmpNode)                                      \
+  declare_c2_type(CmpUNode, CmpNode)                                      \
+  declare_c2_type(CmpPNode, CmpNode)                                      \
+  declare_c2_type(CmpNNode, CmpNode)                                      \
+  declare_c2_type(CmpLNode, CmpNode)                                      \
+  declare_c2_type(CmpL3Node, CmpLNode)                                    \
+  declare_c2_type(CmpFNode, CmpNode)                                      \
+  declare_c2_type(CmpF3Node, CmpFNode)                                    \
+  declare_c2_type(CmpDNode, CmpNode)                                      \
+  declare_c2_type(CmpD3Node, CmpDNode)                                    \
+  declare_c2_type(BoolNode, Node)                                         \
+  declare_c2_type(AbsNode, Node)                                          \
+  declare_c2_type(AbsINode, AbsNode)                                      \
+  declare_c2_type(AbsFNode, AbsNode)                                      \
+  declare_c2_type(AbsDNode, AbsNode)                                      \
+  declare_c2_type(CmpLTMaskNode, Node)                                    \
+  declare_c2_type(NegNode, Node)                                          \
+  declare_c2_type(NegFNode, NegNode)                                      \
+  declare_c2_type(NegDNode, NegNode)                                      \
+  declare_c2_type(CosDNode, Node)                                         \
+  declare_c2_type(SinDNode, Node)                                         \
+  declare_c2_type(TanDNode, Node)                                         \
+  declare_c2_type(AtanDNode, Node)                                        \
+  declare_c2_type(SqrtDNode, Node)                                        \
+  declare_c2_type(ExpDNode, Node)                                         \
+  declare_c2_type(LogDNode, Node)                                         \
+  declare_c2_type(Log10DNode, Node)                                       \
+  declare_c2_type(PowDNode, Node)                                         \
+  declare_c2_type(ReverseBytesINode, Node)                                \
+  declare_c2_type(ReverseBytesLNode, Node)                                \
+  declare_c2_type(VectorNode, Node)                                       \
+  declare_c2_type(AddVBNode, VectorNode)                                  \
+  declare_c2_type(AddVCNode, VectorNode)                                  \
+  declare_c2_type(AddVSNode, VectorNode)                                  \
+  declare_c2_type(AddVINode, VectorNode)                                  \
+  declare_c2_type(AddVLNode, VectorNode)                                  \
+  declare_c2_type(AddVFNode, VectorNode)                                  \
+  declare_c2_type(AddVDNode, VectorNode)                                  \
+  declare_c2_type(SubVBNode, VectorNode)                                  \
+  declare_c2_type(SubVCNode, VectorNode)                                  \
+  declare_c2_type(SubVSNode, VectorNode)                                  \
+  declare_c2_type(SubVINode, VectorNode)                                  \
+  declare_c2_type(SubVLNode, VectorNode)                                  \
+  declare_c2_type(SubVFNode, VectorNode)                                  \
+  declare_c2_type(SubVDNode, VectorNode)                                  \
+  declare_c2_type(MulVFNode, VectorNode)                                  \
+  declare_c2_type(MulVDNode, VectorNode)                                  \
+  declare_c2_type(DivVFNode, VectorNode)                                  \
+  declare_c2_type(DivVDNode, VectorNode)                                  \
+  declare_c2_type(LShiftVBNode, VectorNode)                               \
+  declare_c2_type(LShiftVCNode, VectorNode)                               \
+  declare_c2_type(LShiftVSNode, VectorNode)                               \
+  declare_c2_type(LShiftVINode, VectorNode)                               \
+  declare_c2_type(URShiftVBNode, VectorNode)                              \
+  declare_c2_type(URShiftVCNode, VectorNode)                              \
+  declare_c2_type(URShiftVSNode, VectorNode)                              \
+  declare_c2_type(URShiftVINode, VectorNode)                              \
+  declare_c2_type(AndVNode, VectorNode)                                   \
+  declare_c2_type(OrVNode, VectorNode)                                    \
+  declare_c2_type(XorVNode, VectorNode)                                   \
+  declare_c2_type(VectorLoadNode, LoadNode)                               \
+  declare_c2_type(Load16BNode, VectorLoadNode)                            \
+  declare_c2_type(Load8BNode, VectorLoadNode)                             \
+  declare_c2_type(Load4BNode, VectorLoadNode)                             \
+  declare_c2_type(Load8CNode, VectorLoadNode)                             \
+  declare_c2_type(Load4CNode, VectorLoadNode)                             \
+  declare_c2_type(Load2CNode, VectorLoadNode)                             \
+  declare_c2_type(Load8SNode, VectorLoadNode)                             \
+  declare_c2_type(Load4SNode, VectorLoadNode)                             \
+  declare_c2_type(Load2SNode, VectorLoadNode)                             \
+  declare_c2_type(Load4INode, VectorLoadNode)                             \
+  declare_c2_type(Load2INode, VectorLoadNode)                             \
+  declare_c2_type(Load2LNode, VectorLoadNode)                             \
+  declare_c2_type(Load4FNode, VectorLoadNode)                             \
+  declare_c2_type(Load2FNode, VectorLoadNode)                             \
+  declare_c2_type(Load2DNode, VectorLoadNode)                             \
+  declare_c2_type(VectorStoreNode, StoreNode)                             \
+  declare_c2_type(Store16BNode, VectorStoreNode)                          \
+  declare_c2_type(Store8BNode, VectorStoreNode)                           \
+  declare_c2_type(Store4BNode, VectorStoreNode)                           \
+  declare_c2_type(Store8CNode, VectorStoreNode)                           \
+  declare_c2_type(Store4CNode, VectorStoreNode)                           \
+  declare_c2_type(Store2CNode, VectorStoreNode)                           \
+  declare_c2_type(Store4INode, VectorStoreNode)                           \
+  declare_c2_type(Store2INode, VectorStoreNode)                           \
+  declare_c2_type(Store2LNode, VectorStoreNode)                           \
+  declare_c2_type(Store4FNode, VectorStoreNode)                           \
+  declare_c2_type(Store2FNode, VectorStoreNode)                           \
+  declare_c2_type(Store2DNode, VectorStoreNode)                           \
+  declare_c2_type(Replicate16BNode, VectorNode)                           \
+  declare_c2_type(Replicate8BNode, VectorNode)                            \
+  declare_c2_type(Replicate4BNode, VectorNode)                            \
+  declare_c2_type(Replicate8CNode, VectorNode)                            \
+  declare_c2_type(Replicate4CNode, VectorNode)                            \
+  declare_c2_type(Replicate2CNode, VectorNode)                            \
+  declare_c2_type(Replicate8SNode, VectorNode)                            \
+  declare_c2_type(Replicate4SNode, VectorNode)                            \
+  declare_c2_type(Replicate2SNode, VectorNode)                            \
+  declare_c2_type(Replicate4INode, VectorNode)                            \
+  declare_c2_type(Replicate2INode, VectorNode)                            \
+  declare_c2_type(Replicate2LNode, VectorNode)                            \
+  declare_c2_type(Replicate4FNode, VectorNode)                            \
+  declare_c2_type(Replicate2FNode, VectorNode)                            \
+  declare_c2_type(Replicate2DNode, VectorNode)                            \
+  declare_c2_type(PackNode, VectorNode)                                   \
+  declare_c2_type(PackBNode, PackNode)                                    \
+  declare_c2_type(PackCNode, PackNode)                                    \
+  declare_c2_type(PackSNode, PackNode)                                    \
+  declare_c2_type(PackINode, PackNode)                                    \
+  declare_c2_type(PackLNode, PackNode)                                    \
+  declare_c2_type(PackFNode, PackNode)                                    \
+  declare_c2_type(PackDNode, PackNode)                                    \
+  declare_c2_type(Pack2x1BNode, PackNode)                                 \
+  declare_c2_type(Pack2x2BNode, PackNode)                                 \
+  declare_c2_type(ExtractNode, Node)                                      \
+  declare_c2_type(ExtractBNode, ExtractNode)                              \
+  declare_c2_type(ExtractCNode, ExtractNode)                              \
+  declare_c2_type(ExtractSNode, ExtractNode)                              \
+  declare_c2_type(ExtractINode, ExtractNode)                              \
+  declare_c2_type(ExtractLNode, ExtractNode)                              \
+  declare_c2_type(ExtractFNode, ExtractNode)                              \
+  declare_c2_type(ExtractDNode, ExtractNode)                              \
                                                                           \
   /*********************/                                                 \
   /* Adapter Blob Entries */                                              \
@@ -1384,6 +2044,32 @@
   declare_toplevel_type(AdapterHandlerEntry)                              \
   declare_toplevel_type(AdapterHandlerEntry*)                             \
                                                                           \
+  /*********************/                                                 \
+  /* CI */                                                                \
+  /*********************/                                                 \
+  declare_toplevel_type(ciEnv)                                            \
+  declare_toplevel_type(ciObjectFactory)                                  \
+  declare_toplevel_type(ciConstant)                                       \
+  declare_toplevel_type(ciField)                                          \
+  declare_toplevel_type(void*)                                            \
+  declare_toplevel_type(ciObject)                                         \
+  declare_type(ciMethod, ciObject)                                        \
+  declare_type(ciMethodData, ciObject)                                    \
+  declare_type(ciType, ciObject)                                          \
+  declare_type(ciInstance, ciObject)                                      \
+  declare_toplevel_type(ciSymbol)                                         \
+  declare_type(ciKlass, ciType)                                           \
+  declare_type(ciInstanceKlass, ciKlass)                                  \
+  declare_type(ciArrayKlass, ciKlass)                                     \
+  declare_type(ciTypeArrayKlass, ciArrayKlass)                            \
+  declare_type(ciObjArrayKlass, ciArrayKlass)                             \
+  declare_type(ciMethodKlass, ciKlass)                                    \
+  declare_type(ciKlassKlass, ciKlass)                                     \
+  declare_type(ciInstanceKlassKlass, ciKlassKlass)                        \
+  declare_type(ciArrayKlassKlass, ciKlassKlass)                           \
+  declare_type(ciTypeArrayKlassKlass, ciArrayKlassKlass)                  \
+  declare_type(ciObjArrayKlassKlass, ciArrayKlassKlass)                   \
+                                                                          \
   /********************/                                                  \
   /* -XX flags        */                                                  \
   /********************/                                                  \
@@ -1392,6 +2078,12 @@
   declare_toplevel_type(Flag*)                                            \
                                                                           \
   /********************/                                                  \
+  /* JVMTI            */                                                  \
+  /********************/                                                  \
+                                                                          \
+  declare_toplevel_type(JvmtiExport)                                      \
+                                                                          \
+  /********************/                                                  \
   /* JDK/VM version   */                                                  \
   /********************/                                                  \
                                                                           \
@@ -1417,19 +2109,24 @@
    declare_integer_type(Location::Type)                                   \
    declare_integer_type(Location::Where)                                  \
    declare_integer_type(PermGen::Name)                                    \
+   declare_integer_type(FlagValueOrigin)                                  \
+   COMPILER2_PRESENT(declare_integer_type(OptoReg::Name))                 \
                                                                           \
    declare_integer_type(AccessFlags)  /* FIXME: wrong type (not integer) */\
   declare_toplevel_type(address)      /* FIXME: should this be an integer type? */\
+   declare_integer_type(BasicType)   /* FIXME: wrong type (not integer) */\
   declare_toplevel_type(BreakpointInfo)                                   \
   declare_toplevel_type(BreakpointInfo*)                                  \
   declare_toplevel_type(CodeBlob*)                                        \
   declare_toplevel_type(CompressedWriteStream*)                           \
   declare_toplevel_type(ConstantPoolCacheEntry)                           \
   declare_toplevel_type(elapsedTimer)                                     \
+  declare_toplevel_type(frame)                                            \
   declare_toplevel_type(intptr_t*)                                        \
    declare_unsigned_integer_type(InvocationCounter) /* FIXME: wrong type (not integer) */ \
   declare_toplevel_type(JavaThread*)                                      \
   declare_toplevel_type(java_lang_Class)                                  \
+  declare_integer_type(JavaThread::AsyncRequests)                         \
   declare_toplevel_type(jbyte*)                                           \
   declare_toplevel_type(jbyte**)                                          \
   declare_toplevel_type(jint*)                                            \
@@ -1442,6 +2139,7 @@
   declare_toplevel_type(jmethodID*)                                       \
   declare_toplevel_type(Mutex*)                                           \
   declare_toplevel_type(nmethod*)                                         \
+  COMPILER2_PRESENT(declare_unsigned_integer_type(node_idx_t))            \
   declare_toplevel_type(ObjectMonitor*)                                   \
   declare_toplevel_type(oop*)                                             \
   declare_toplevel_type(OopMap**)                                         \
@@ -1452,7 +2150,10 @@
    declare_integer_type(ReferenceType)                                    \
   declare_toplevel_type(StubQueue*)                                       \
   declare_toplevel_type(Thread*)                                          \
-  declare_toplevel_type(Universe)
+  declare_toplevel_type(Universe)                                         \
+  declare_toplevel_type(vframeArray)                                      \
+  declare_toplevel_type(vframeArrayElement)
+
 
   /* NOTE that we do not use the last_entry() macro here; it is used  */
   /* in vmStructs_<os>_<cpu>.hpp's VM_TYPES_OS_CPU macro (and must be */
@@ -1645,18 +2346,23 @@
   declare_constant(constMethodOopDesc::_has_localvariable_table)          \
                                                                           \
   /*************************************/                                 \
-  /* instanceKlass FieldOffset enum    */                                 \
+  /* instanceKlass enum                */                                 \
+  /*************************************/                                 \
+                                                                          \
+  declare_constant(instanceKlass::implementors_limit)                     \
+                                                                          \
+  /*************************************/                                 \
+  /* FieldInfo FieldOffset enum        */                                 \
   /*************************************/                                 \
                                                                           \
-  declare_constant(instanceKlass::access_flags_offset)                    \
-  declare_constant(instanceKlass::name_index_offset)                      \
-  declare_constant(instanceKlass::signature_index_offset)                 \
-  declare_constant(instanceKlass::initval_index_offset)                   \
-  declare_constant(instanceKlass::low_offset)                             \
-  declare_constant(instanceKlass::high_offset)                            \
-  declare_constant(instanceKlass::generic_signature_offset)               \
-  declare_constant(instanceKlass::next_offset)                            \
-  declare_constant(instanceKlass::implementors_limit)                     \
+  declare_constant(FieldInfo::access_flags_offset)                        \
+  declare_constant(FieldInfo::name_index_offset)                          \
+  declare_constant(FieldInfo::signature_index_offset)                     \
+  declare_constant(FieldInfo::initval_index_offset)                       \
+  declare_constant(FieldInfo::low_offset)                                 \
+  declare_constant(FieldInfo::high_offset)                                \
+  declare_constant(FieldInfo::generic_signature_offset)                   \
+  declare_constant(FieldInfo::field_slots)                                \
                                                                           \
   /************************************************/                      \
   /* instanceKlass InnerClassAttributeOffset enum */                      \
@@ -1752,6 +2458,27 @@
   declare_constant(Location::on_stack)                                    \
   declare_constant(Location::in_register)                                 \
                                                                           \
+  declare_constant(Deoptimization::Reason_many)                           \
+  declare_constant(Deoptimization::Reason_none)                           \
+  declare_constant(Deoptimization::Reason_null_check)                     \
+  declare_constant(Deoptimization::Reason_null_assert)                    \
+  declare_constant(Deoptimization::Reason_range_check)                    \
+  declare_constant(Deoptimization::Reason_class_check)                    \
+  declare_constant(Deoptimization::Reason_array_check)                    \
+  declare_constant(Deoptimization::Reason_intrinsic)                      \
+  declare_constant(Deoptimization::Reason_bimorphic)                      \
+  declare_constant(Deoptimization::Reason_unloaded)                       \
+  declare_constant(Deoptimization::Reason_uninitialized)                  \
+  declare_constant(Deoptimization::Reason_unreached)                      \
+  declare_constant(Deoptimization::Reason_unhandled)                      \
+  declare_constant(Deoptimization::Reason_constraint)                     \
+  declare_constant(Deoptimization::Reason_div0_check)                     \
+  declare_constant(Deoptimization::Reason_age)                            \
+  declare_constant(Deoptimization::Reason_predicate)                      \
+  declare_constant(Deoptimization::Reason_loop_limit_check)               \
+  declare_constant(Deoptimization::Reason_LIMIT)                          \
+  declare_constant(Deoptimization::Reason_RECORDED_LIMIT)                 \
+                                                                          \
   /*********************/                                                 \
   /* Matcher (C2 only) */                                                 \
   /*********************/                                                 \
@@ -1796,6 +2523,28 @@
                                                                           \
   declare_constant(ObjectSynchronizer::_BLOCKSIZE)                        \
                                                                           \
+  /**********************/                                                \
+  /* PcDesc             */                                                \
+  /**********************/                                                \
+                                                                          \
+  declare_constant(PcDesc::PCDESC_reexecute)                              \
+  declare_constant(PcDesc::PCDESC_is_method_handle_invoke)                \
+  declare_constant(PcDesc::PCDESC_return_oop)                             \
+                                                                          \
+  /**********************/                                                \
+  /* frame              */                                                \
+  /**********************/                                                \
+                                                                          \
+  X86_ONLY(declare_constant(frame::entry_frame_call_wrapper_offset))      \
+  declare_constant(frame::pc_return_offset)                               \
+                                                                          \
+  /*************/                                                         \
+  /* vmSymbols */                                                         \
+  /*************/                                                         \
+                                                                          \
+  declare_constant(vmSymbols::FIRST_SID)                                  \
+  declare_constant(vmSymbols::SID_LIMIT)                                  \
+                                                                          \
   /********************************/                                      \
   /* Calling convention constants */                                      \
   /********************************/                                      \
@@ -2130,6 +2879,9 @@
   VM_STRUCTS_CMS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
                  GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
                  GENERATE_STATIC_VM_STRUCT_ENTRY)
+
+  VM_STRUCTS_G1(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
+                GENERATE_STATIC_VM_STRUCT_ENTRY)
 #endif // SERIALGC
 
   VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
@@ -2173,6 +2925,9 @@
                GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
 
   VM_TYPES_PARNEW(GENERATE_VM_TYPE_ENTRY)
+
+  VM_TYPES_G1(GENERATE_VM_TYPE_ENTRY,
+              GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
 #endif // SERIALGC
 
   VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY,
@@ -2272,6 +3027,9 @@
   VM_STRUCTS_CMS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
              CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
              CHECK_STATIC_VM_STRUCT_ENTRY);
+
+  VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
+                CHECK_STATIC_VM_STRUCT_ENTRY);
 #endif // SERIALGC
 
   VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
@@ -2312,6 +3070,9 @@
                CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
 
   VM_TYPES_PARNEW(CHECK_VM_TYPE_ENTRY)
+
+  VM_TYPES_G1(CHECK_VM_TYPE_ENTRY,
+              CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
 #endif // SERIALGC
 
   VM_TYPES_CPU(CHECK_VM_TYPE_ENTRY,
@@ -2377,6 +3138,8 @@
   debug_only(VM_STRUCTS_CMS(ENSURE_FIELD_TYPE_PRESENT, \
                             ENSURE_FIELD_TYPE_PRESENT, \
                             ENSURE_FIELD_TYPE_PRESENT));
+  debug_only(VM_STRUCTS_G1(ENSURE_FIELD_TYPE_PRESENT, \
+                           ENSURE_FIELD_TYPE_PRESENT));
 #endif // SERIALGC
   debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT, \
                             ENSURE_FIELD_TYPE_PRESENT, \
@@ -2440,12 +3203,14 @@
   {
     VMTypeEntry* types = origtypes;
     while (types->typeName != NULL) {
-      if (!strcmp(typeName, types->typeName)) {
+      if (strcmp(typeName, types->typeName) == 0) {
+        // Found it
         return 1;
       }
       ++types;
     }
   }
+  // Search for the base type by peeling off const and *
   size_t len = strlen(typeName);
   if (typeName[len-1] == '*') {
     char * s = new char[len];
@@ -2490,7 +3255,7 @@
   if (!isRecurse) {
     tty->print_cr("type \"%s\" not found", typeName);
   }
-  return 2;
+  return 0;
 }
 
 
--- a/hotspot/src/share/vm/runtime/vmThread.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/vmThread.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -46,10 +46,15 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL3(hotspot, vmops__request, char *, uintptr_t, int);
 HS_DTRACE_PROBE_DECL3(hotspot, vmops__begin, char *, uintptr_t, int);
 HS_DTRACE_PROBE_DECL3(hotspot, vmops__end, char *, uintptr_t, int);
+#endif /* !USDT2 */
 
 // Dummy VM operation to act as first element in our circular double-linked list
 class VM_Dummy: public VM_Operation {
@@ -159,8 +164,14 @@
 // High-level interface
 bool VMOperationQueue::add(VM_Operation *op) {
 
+#ifndef USDT2
   HS_DTRACE_PROBE3(hotspot, vmops__request, op->name(), strlen(op->name()),
                    op->evaluation_mode());
+#else /* USDT2 */
+  HOTSPOT_VMOPS_REQUEST(
+                   (char *) op->name(), strlen(op->name()),
+                   op->evaluation_mode());
+#endif /* USDT2 */
 
   // Encapsulates VM queue policy. Currently, that
   // only involves putting them on the right list
@@ -357,11 +368,23 @@
 
   {
     PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time());
+#ifndef USDT2
     HS_DTRACE_PROBE3(hotspot, vmops__begin, op->name(), strlen(op->name()),
                      op->evaluation_mode());
+#else /* USDT2 */
+    HOTSPOT_VMOPS_BEGIN(
+                     (char *) op->name(), strlen(op->name()),
+                     op->evaluation_mode());
+#endif /* USDT2 */
     op->evaluate();
+#ifndef USDT2
     HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()),
                      op->evaluation_mode());
+#else /* USDT2 */
+    HOTSPOT_VMOPS_END(
+                     (char *) op->name(), strlen(op->name()),
+                     op->evaluation_mode());
+#endif /* USDT2 */
   }
 
   // Last access of info in _cur_vm_operation!
--- a/hotspot/src/share/vm/runtime/vmThread.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/vmThread.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 //
 // Prioritized queue of VM operations.
--- a/hotspot/src/share/vm/runtime/vm_operations.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -45,6 +45,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #define VM_OP_NAME_INITIALIZE(name) #name,
 
--- a/hotspot/src/share/vm/runtime/vm_version.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -128,7 +128,7 @@
 #ifndef HOTSPOT_VM_DISTRO
   #error HOTSPOT_VM_DISTRO must be defined
 #endif
-#define VMNAME HOTSPOT_VM_DISTRO " " VMLP VMTYPE " VM"
+#define VMNAME HOTSPOT_VM_DISTRO " " VMLP EMBEDDED_ONLY("Embedded ") VMTYPE " VM"
 
 const char* Abstract_VM_Version::vm_name() {
   return VMNAME;
@@ -167,7 +167,8 @@
 
 #define OS       LINUX_ONLY("linux")             \
                  WINDOWS_ONLY("windows")         \
-                 SOLARIS_ONLY("solaris")
+                 SOLARIS_ONLY("solaris")         \
+                 BSD_ONLY("bsd")
 
 #ifdef ZERO
 #define CPU      ZERO_LIBARCH
--- a/hotspot/src/share/vm/services/classLoadingService.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/services/classLoadingService.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,6 +36,8 @@
 
 // Only bother with this argument setup if dtrace is available
 
+#ifndef USDT2
+
 HS_DTRACE_PROBE_DECL4(hotspot, class__loaded, char*, int, oop, bool);
 HS_DTRACE_PROBE_DECL4(hotspot, class__unloaded, char*, int, oop, bool);
 
@@ -52,6 +54,24 @@
       data, len, (clss)->class_loader(), (shared)); \
   }
 
+#else /* USDT2 */
+
+#define HOTSPOT_CLASS_unloaded HOTSPOT_CLASS_UNLOADED
+#define HOTSPOT_CLASS_loaded HOTSPOT_CLASS_LOADED
+#define DTRACE_CLASSLOAD_PROBE(type, clss, shared)  \
+  {                                                 \
+    char* data = NULL;                              \
+    int len = 0;                                    \
+    Symbol* name = (clss)->name();                  \
+    if (name != NULL) {                             \
+      data = (char*)name->bytes();                  \
+      len = name->utf8_length();                    \
+    }                                               \
+    HOTSPOT_CLASS_##type( /* type = unloaded, loaded */ \
+      data, len, (clss)->class_loader(), (shared)); \
+  }
+
+#endif /* USDT2 */
 #else //  ndef DTRACE_ENABLED
 
 #define DTRACE_CLASSLOAD_PROBE(type, clss, shared)
--- a/hotspot/src/share/vm/services/g1MemoryPool.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/services/g1MemoryPool.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -32,71 +32,44 @@
 G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h,
                                      const char* name,
                                      size_t init_size,
+                                     size_t max_size,
                                      bool support_usage_threshold) :
-  _g1h(g1h), CollectedMemoryPool(name,
-                                   MemoryPool::Heap,
-                                   init_size,
-                                   undefined_max(),
-                                   support_usage_threshold) {
+  _g1mm(g1h->g1mm()), CollectedMemoryPool(name,
+                                          MemoryPool::Heap,
+                                          init_size,
+                                          max_size,
+                                          support_usage_threshold) {
   assert(UseG1GC, "sanity");
 }
 
-// See the comment at the top of g1MemoryPool.hpp
-size_t G1MemoryPoolSuper::eden_space_committed(G1CollectedHeap* g1h) {
-  return MAX2(eden_space_used(g1h), (size_t) HeapRegion::GrainBytes);
-}
-
-// See the comment at the top of g1MemoryPool.hpp
-size_t G1MemoryPoolSuper::eden_space_used(G1CollectedHeap* g1h) {
-  return g1h->g1mm()->eden_space_used();
-}
-
-// See the comment at the top of g1MemoryPool.hpp
-size_t G1MemoryPoolSuper::survivor_space_committed(G1CollectedHeap* g1h) {
-  return g1h->g1mm()->survivor_space_committed();
-}
-
-// See the comment at the top of g1MemoryPool.hpp
-size_t G1MemoryPoolSuper::survivor_space_used(G1CollectedHeap* g1h) {
-  return g1h->g1mm()->survivor_space_used();
-}
-
-// See the comment at the top of g1MemoryPool.hpp
-size_t G1MemoryPoolSuper::old_space_committed(G1CollectedHeap* g1h) {
-  return g1h->g1mm()->old_space_committed();
-}
-
-// See the comment at the top of g1MemoryPool.hpp
-size_t G1MemoryPoolSuper::old_space_used(G1CollectedHeap* g1h) {
-  return g1h->g1mm()->old_space_used();
-}
-
 G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) :
   G1MemoryPoolSuper(g1h,
-                    "G1 Eden",
-                    eden_space_committed(g1h), /* init_size */
+                    "G1 Eden Space",
+                    g1h->g1mm()->eden_space_committed(), /* init_size */
+                    _undefined_max,
                     false /* support_usage_threshold */) { }
 
 MemoryUsage G1EdenPool::get_memory_usage() {
   size_t initial_sz = initial_size();
   size_t max_sz     = max_size();
   size_t used       = used_in_bytes();
-  size_t committed  = eden_space_committed(_g1h);
+  size_t committed  = _g1mm->eden_space_committed();
 
   return MemoryUsage(initial_sz, used, committed, max_sz);
 }
 
 G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) :
   G1MemoryPoolSuper(g1h,
-                    "G1 Survivor",
-                    survivor_space_committed(g1h), /* init_size */
+                    "G1 Survivor Space",
+                    g1h->g1mm()->survivor_space_committed(), /* init_size */
+                    _undefined_max,
                     false /* support_usage_threshold */) { }
 
 MemoryUsage G1SurvivorPool::get_memory_usage() {
   size_t initial_sz = initial_size();
   size_t max_sz     = max_size();
   size_t used       = used_in_bytes();
-  size_t committed  = survivor_space_committed(_g1h);
+  size_t committed  = _g1mm->survivor_space_committed();
 
   return MemoryUsage(initial_sz, used, committed, max_sz);
 }
@@ -104,14 +77,15 @@
 G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) :
   G1MemoryPoolSuper(g1h,
                     "G1 Old Gen",
-                    old_space_committed(g1h), /* init_size */
+                    g1h->g1mm()->old_space_committed(), /* init_size */
+                    _undefined_max,
                     true /* support_usage_threshold */) { }
 
 MemoryUsage G1OldGenPool::get_memory_usage() {
   size_t initial_sz = initial_size();
   size_t max_sz     = max_size();
   size_t used       = used_in_bytes();
-  size_t committed  = old_space_committed(_g1h);
+  size_t committed  = _g1mm->old_space_committed();
 
   return MemoryUsage(initial_sz, used, committed, max_sz);
 }
--- a/hotspot/src/share/vm/services/g1MemoryPool.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/services/g1MemoryPool.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -26,12 +26,11 @@
 #define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP
 
 #ifndef SERIALGC
+#include "gc_implementation/g1/g1MonitoringSupport.hpp"
 #include "services/memoryPool.hpp"
 #include "services/memoryUsage.hpp"
 #endif
 
-class G1CollectedHeap;
-
 // This file contains the three classes that represent the memory
 // pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and
 // G1OldGenPool. In G1, unlike our other GCs, we do not have a
@@ -50,37 +49,19 @@
 // on this model.
 //
 
-
 // This class is shared by the three G1 memory pool classes
-// (G1EdenPool, G1SurvivorPool, G1OldGenPool). Given that the way we
-// calculate used / committed bytes for these three pools is related
-// (see comment above), we put the calculations in this class so that
-// we can easily share them among the subclasses.
+// (G1EdenPool, G1SurvivorPool, G1OldGenPool).
 class G1MemoryPoolSuper : public CollectedMemoryPool {
 protected:
-  G1CollectedHeap* _g1h;
+  const static size_t _undefined_max = (size_t) -1;
+  G1MonitoringSupport* _g1mm;
 
   // Would only be called from subclasses.
   G1MemoryPoolSuper(G1CollectedHeap* g1h,
                     const char* name,
                     size_t init_size,
+                    size_t max_size,
                     bool support_usage_threshold);
-
-  // The reason why all the code is in static methods is so that it
-  // can be safely called from the constructors of the subclasses.
-
-  static size_t undefined_max() {
-    return (size_t) -1;
-  }
-
-  static size_t eden_space_committed(G1CollectedHeap* g1h);
-  static size_t eden_space_used(G1CollectedHeap* g1h);
-
-  static size_t survivor_space_committed(G1CollectedHeap* g1h);
-  static size_t survivor_space_used(G1CollectedHeap* g1h);
-
-  static size_t old_space_committed(G1CollectedHeap* g1h);
-  static size_t old_space_used(G1CollectedHeap* g1h);
 };
 
 // Memory pool that represents the G1 eden.
@@ -89,10 +70,10 @@
   G1EdenPool(G1CollectedHeap* g1h);
 
   size_t used_in_bytes() {
-    return eden_space_used(_g1h);
+    return _g1mm->eden_space_used();
   }
   size_t max_size() const {
-    return undefined_max();
+    return _undefined_max;
   }
   MemoryUsage get_memory_usage();
 };
@@ -103,10 +84,10 @@
   G1SurvivorPool(G1CollectedHeap* g1h);
 
   size_t used_in_bytes() {
-    return survivor_space_used(_g1h);
+    return _g1mm->survivor_space_used();
   }
   size_t max_size() const {
-    return undefined_max();
+    return _undefined_max;
   }
   MemoryUsage get_memory_usage();
 };
@@ -117,10 +98,10 @@
   G1OldGenPool(G1CollectedHeap* g1h);
 
   size_t used_in_bytes() {
-    return old_space_used(_g1h);
+    return _g1mm->old_space_used();
   }
   size_t max_size() const {
-    return undefined_max();
+    return _undefined_max;
   }
   MemoryUsage get_memory_usage();
 };
--- a/hotspot/src/share/vm/services/memoryManager.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/services/memoryManager.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -36,10 +36,12 @@
 #include "services/gcNotifier.hpp"
 #include "utilities/dtrace.hpp"
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__begin, char*, int, char*, int,
   size_t, size_t, size_t, size_t);
 HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__end, char*, int, char*, int,
   size_t, size_t, size_t, size_t);
+#endif /* !USDT2 */
 
 MemoryManager::MemoryManager() {
   _num_pools = 0;
@@ -238,11 +240,19 @@
       MemoryPool* pool = MemoryService::get_memory_pool(i);
       MemoryUsage usage = pool->get_memory_usage();
       _current_gc_stat->set_before_gc_usage(i, usage);
+#ifndef USDT2
       HS_DTRACE_PROBE8(hotspot, mem__pool__gc__begin,
         name(), strlen(name()),
         pool->name(), strlen(pool->name()),
         usage.init_size(), usage.used(),
         usage.committed(), usage.max_size());
+#else /* USDT2 */
+      HOTSPOT_MEM_POOL_GC_BEGIN(
+        (char *) name(), strlen(name()),
+        (char *) pool->name(), strlen(pool->name()),
+        usage.init_size(), usage.used(),
+        usage.committed(), usage.max_size());
+#endif /* USDT2 */
     }
   }
 }
@@ -268,11 +278,19 @@
       MemoryPool* pool = MemoryService::get_memory_pool(i);
       MemoryUsage usage = pool->get_memory_usage();
 
+#ifndef USDT2
       HS_DTRACE_PROBE8(hotspot, mem__pool__gc__end,
         name(), strlen(name()),
         pool->name(), strlen(pool->name()),
         usage.init_size(), usage.used(),
         usage.committed(), usage.max_size());
+#else /* USDT2 */
+      HOTSPOT_MEM_POOL_GC_END(
+        (char *) name(), strlen(name()),
+        (char *) pool->name(), strlen(pool->name()),
+        usage.init_size(), usage.used(),
+        usage.committed(), usage.max_size());
+#endif /* USDT2 */
 
       _current_gc_stat->set_after_gc_usage(i, usage);
     }
--- a/hotspot/src/share/vm/services/runtimeService.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/services/runtimeService.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -30,8 +30,10 @@
 #include "utilities/dtrace.hpp"
 #include "utilities/exceptions.hpp"
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin);
 HS_DTRACE_PROBE_DECL(hs_private, safepoint__end);
+#endif /* !USDT2 */
 
 TimeStamp RuntimeService::_app_timer;
 TimeStamp RuntimeService::_safepoint_timer;
@@ -108,7 +110,11 @@
 }
 
 void RuntimeService::record_safepoint_begin() {
+#ifndef USDT2
   HS_DTRACE_PROBE(hs_private, safepoint__begin);
+#else /* USDT2 */
+  HS_PRIVATE_SAFEPOINT_BEGIN();
+#endif /* USDT2 */
 
   // Print the time interval in which the app was executing
   if (PrintGCApplicationConcurrentTime) {
@@ -133,7 +139,11 @@
 }
 
 void RuntimeService::record_safepoint_end() {
+#ifndef USDT2
   HS_DTRACE_PROBE(hs_private, safepoint__end);
+#else /* USDT2 */
+  HS_PRIVATE_SAFEPOINT_END();
+#endif /* USDT2 */
 
   // Print the time interval for which the app was stopped
   // during the current safepoint operation.
--- a/hotspot/src/share/vm/services/threadService.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/services/threadService.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -751,7 +751,7 @@
       _blocker_object = obj();
       JavaThread* owner = ObjectSynchronizer::get_lock_owner(obj, false);
       if ((owner == NULL && _thread_status == java_lang_Thread::BLOCKED_ON_MONITOR_ENTER)
-          || (owner != NULL && owner->is_attaching())) {
+          || (owner != NULL && owner->is_attaching_via_jni())) {
         // ownership information of the monitor is not available
         // (may no longer be owned or releasing to some other thread)
         // make this thread in RUNNABLE state.
@@ -899,7 +899,7 @@
     }
 
     // skip jni threads in the process of attaching
-    if (!include_jni_attaching_threads && jt->is_attaching()) {
+    if (!include_jni_attaching_threads && jt->is_attaching_via_jni()) {
       continue;
     }
 
--- a/hotspot/src/share/vm/utilities/accessFlags.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/accessFlags.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -34,6 +34,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 void AccessFlags::atomic_set_bits(jint bits) {
--- a/hotspot/src/share/vm/utilities/accessFlags.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/accessFlags.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -79,9 +79,14 @@
   // Note that the class-related ACC_ANNOTATION bit conflicts with these flags.
   JVM_ACC_FIELD_ACCESS_WATCHED       = 0x00002000,  // field access is watched by JVMTI
   JVM_ACC_FIELD_MODIFICATION_WATCHED = 0x00008000,  // field modification is watched by JVMTI
+  JVM_ACC_FIELD_INTERNAL             = 0x00000400,  // internal field, same as JVM_ACC_ABSTRACT
+
+  JVM_ACC_FIELD_INTERNAL_FLAGS       = JVM_ACC_FIELD_ACCESS_WATCHED |
+                                       JVM_ACC_FIELD_MODIFICATION_WATCHED |
+                                       JVM_ACC_FIELD_INTERNAL,
 
                                                     // flags accepted by set_field_flags()
-  JVM_ACC_FIELD_FLAGS                = 0x00008000 | JVM_ACC_WRITTEN_FLAGS
+  JVM_ACC_FIELD_FLAGS                = JVM_RECOGNIZED_FIELD_MODIFIERS | JVM_ACC_FIELD_INTERNAL_FLAGS
 
 };
 
@@ -150,13 +155,17 @@
   bool is_field_access_watched() const  { return (_flags & JVM_ACC_FIELD_ACCESS_WATCHED) != 0; }
   bool is_field_modification_watched() const
                                         { return (_flags & JVM_ACC_FIELD_MODIFICATION_WATCHED) != 0; }
+  bool is_internal() const              { return (_flags & JVM_ACC_FIELD_INTERNAL) != 0; }
 
   // get .class file flags
   jint get_flags               () const { return (_flags & JVM_ACC_WRITTEN_FLAGS); }
 
   // Initialization
   void add_promoted_flags(jint flags)   { _flags |= (flags & JVM_ACC_PROMOTED_FLAGS); }
-  void set_field_flags(jint flags)      { _flags = (flags & JVM_ACC_FIELD_FLAGS); }
+  void set_field_flags(jint flags)      {
+    assert((flags & JVM_ACC_FIELD_FLAGS) == flags, "only recognized flags");
+    _flags = (flags & JVM_ACC_FIELD_FLAGS);
+  }
   void set_flags(jint flags)            { _flags = (flags & JVM_ACC_WRITTEN_FLAGS); }
 
   void set_queued_for_compilation()    { atomic_set_bits(JVM_ACC_QUEUED); }
@@ -218,8 +227,8 @@
                                        }
 
   // Conversion
-  jshort as_short()                    { return (jshort)_flags; }
-  jint   as_int()                      { return _flags; }
+  jshort as_short() const              { return (jshort)_flags; }
+  jint   as_int() const                { return _flags; }
 
   inline friend AccessFlags accessFlags_from(jint flags);
 
--- a/hotspot/src/share/vm/utilities/array.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/array.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -34,6 +34,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 #ifdef ASSERT
--- a/hotspot/src/share/vm/utilities/bitMap.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/bitMap.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 
 BitMap::BitMap(bm_word_t* map, idx_t size_in_bits) :
--- a/hotspot/src/share/vm/utilities/debug.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/debug.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -62,6 +62,10 @@
 # include "os_windows.inline.hpp"
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifndef ASSERT
 #  ifdef _DEBUG
@@ -205,7 +209,7 @@
 // Place-holder for non-existent suppression check:
 #define error_is_suppressed(file_name, line_no) (false)
 
-#endif //PRODUCT
+#endif // !PRODUCT
 
 void report_vm_error(const char* file, int line, const char* error_msg,
                      const char* detail_msg)
@@ -260,7 +264,7 @@
 void report_untested(const char* file, int line, const char* message) {
 #ifndef PRODUCT
   warning("Untested: %s in %s: %d\n", message, file, line);
-#endif // PRODUCT
+#endif // !PRODUCT
 }
 
 void report_out_of_shared_space(SharedSpaceType shared_space) {
@@ -305,9 +309,6 @@
   }
 }
 
-
-extern "C" void ps();
-
 static bool error_reported = false;
 
 // call this when the VM is dying--it might loosen some asserts
@@ -362,11 +363,10 @@
     default: ShouldNotReachHere();
   }
 }
-#endif // #ifndef PRODUCT
+#endif // !PRODUCT
 
 // ------ helper functions for debugging go here ------------
 
-#ifndef PRODUCT
 // All debug entries should be wrapped with a stack allocated
 // Command object. It makes sure a resource mark is set and
 // flushes the logfile to prevent file sharing problems.
@@ -387,11 +387,17 @@
     tty->print_cr("\"Executing %s\"", str);
   }
 
-  ~Command() { tty->flush(); Debugging = debug_save; level--; }
+  ~Command() {
+        tty->flush();
+        Debugging = debug_save;
+        level--;
+  }
 };
 
 int Command::level = 0;
 
+#ifndef PRODUCT
+
 extern "C" void blob(CodeBlob* cb) {
   Command c("blob");
   cb->print();
@@ -474,7 +480,7 @@
     oop obj = oop(p);
     obj->print();
   } else {
-    tty->print("%#p", p);
+    tty->print(PTR_FORMAT, p);
   }
 }
 
@@ -483,7 +489,10 @@
 extern "C" void pa(intptr_t p)   { ((AllocatedObj*) p)->print(); }
 extern "C" void findpc(intptr_t x);
 
+#endif // !PRODUCT
+
 extern "C" void ps() { // print stack
+  if (Thread::current() == NULL) return;
   Command c("ps");
 
 
@@ -496,6 +505,11 @@
   if (p->has_last_Java_frame()) {
     // If the last_Java_fp is set we are in C land and
     // can call the standard stack_trace function.
+#ifdef PRODUCT
+    p->print_stack();
+  } else {
+    tty->print_cr("Cannot find the last Java frame, printing stack disabled.");
+#else // !PRODUCT
     p->trace_stack();
   } else {
     frame f = os::current_frame();
@@ -504,6 +518,7 @@
     tty->print("(guessing starting frame id=%#p based on current fp)\n", f.id());
     p->trace_stack_from(vframe::new_vframe(&f, &reg_map, p));
   pd_ps(f);
+#endif // PRODUCT
   }
 
 }
@@ -520,6 +535,8 @@
   }
 }
 
+#ifndef PRODUCT
+
 extern "C" void psf() { // print stack frames
   {
     Command c("psf");
@@ -551,12 +568,15 @@
   SafepointSynchronize::print_state();
 }
 
+#endif // !PRODUCT
 
 extern "C" void pss() { // print all stacks
+  if (Thread::current() == NULL) return;
   Command c("pss");
-  Threads::print(true, true);
+  Threads::print(true, PRODUCT_ONLY(false) NOT_PRODUCT(true));
 }
 
+#ifndef PRODUCT
 
 extern "C" void debug() {               // to set things up for compiler debugging
   Command c("debug");
@@ -907,4 +927,4 @@
 }
 #endif
 
-#endif // PRODUCT
+#endif // !PRODUCT
--- a/hotspot/src/share/vm/utilities/decoder.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/decoder.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -29,7 +29,7 @@
 Decoder::decoder_status  Decoder::_decoder_status = Decoder::no_error;
 bool                     Decoder::_initialized = false;
 
-#ifndef _WINDOWS
+#if !defined(_WINDOWS) && !defined(__APPLE__)
 
 // Implementation of common functionalities among Solaris and Linux
 #include "utilities/elfFile.hpp"
@@ -101,4 +101,3 @@
 }
 
 #endif
-
--- a/hotspot/src/share/vm/utilities/decoder.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/decoder.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -38,6 +38,8 @@
 typedef BOOL  (WINAPI *pfn_SymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64);
 typedef DWORD (WINAPI *pfn_UndecorateSymbolName)(const char*, char*, DWORD, DWORD);
 
+#elif defined(__APPLE__)
+
 #else
 
 class ElfFile;
@@ -79,7 +81,7 @@
 
   static decoder_status    get_status() { return _decoder_status; };
 
-#ifndef _WINDOWS
+#if !defined(_WINDOWS) && !defined(__APPLE__)
  private:
   static ElfFile*         get_elf_file(const char* filepath);
 #endif // _WINDOWS
@@ -94,6 +96,7 @@
   static bool                      _can_decode_in_vm;
   static pfn_SymGetSymFromAddr64   _pfnSymGetSymFromAddr64;
   static pfn_UndecorateSymbolName  _pfnUndecorateSymbolName;
+#elif __APPLE__
 #else
   static ElfFile*                  _opened_elf_files;
 #endif // _WINDOWS
--- a/hotspot/src/share/vm/utilities/dtrace.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/dtrace.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -25,7 +25,7 @@
 #ifndef SHARE_VM_UTILITIES_DTRACE_HPP
 #define SHARE_VM_UTILITIES_DTRACE_HPP
 
-#if defined(SOLARIS) && defined(DTRACE_ENABLED)
+#if defined(DTRACE_ENABLED)
 
 #include <sys/sdt.h>
 
@@ -36,11 +36,27 @@
 #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() \
   do { volatile size_t dtrace_workaround_tail_call_bug = 1; } while (0)
 
-#else // ndef SOLARIS || ndef DTRACE_ENABLED
+#if defined(SOLARIS)
+#define USDT1 1
+#elif defined(__APPLE__)
+#define USDT2 1
+#include <sys/types.h>
+#include "dtracefiles/hotspot.h"
+#include "dtracefiles/hotspot_jni.h"
+#include "dtracefiles/hs_private.h"
+#else
+#error "dtrace enabled for unknown os"
+#endif /* defined(SOLARIS) */
+
+#else /* defined(DTRACE_ENABLED) */
 
 #define DTRACE_ONLY(x)
 #define NOT_DTRACE(x) x
 
+#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG()
+
+#ifndef USDT2
+
 #define DTRACE_PROBE(a,b) {;}
 #define DTRACE_PROBE1(a,b,c) {;}
 #define DTRACE_PROBE2(a,b,c,d) {;}
@@ -48,9 +64,14 @@
 #define DTRACE_PROBE4(a,b,c,d,e,f) {;}
 #define DTRACE_PROBE5(a,b,c,d,e,f,g) {;}
 
-#define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG()
+#else /* USDT2 */
 
-#endif
+#include "dtrace_usdt2_disabled.hpp"
+#endif /* USDT2 */
+
+#endif /* defined(DTRACE_ENABLED) */
+
+#ifndef USDT2
 
 #define HS_DTRACE_PROBE_FN(provider,name)\
   __dtrace_##provider##___##name
@@ -133,4 +154,6 @@
     (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\
     (uintptr_t)a8,(uintptr_t)a9))
 
+#endif /* !USDT2 */
+
 #endif // SHARE_VM_UTILITIES_DTRACE_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/utilities/dtrace_usdt2_disabled.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,1097 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_UTILITIES_DTRACE_USDT2_DISABLED_HPP
+#define SHARE_VM_UTILITIES_DTRACE_USDT2_DISABLED_HPP
+
+/* This file contains dummy provider probes needed when compiling a hotspot
+ * that does not support dtrace probes. This could be because we're building
+ * on a system that doesn't suuport dtrace or because we're bulding a variant
+ * of hotspot (like core) where we do not support dtrace
+ */
+#if !defined(DTRACE_ENABLED)
+
+#ifdef USDT2
+
+/* hotspot provider probes */
+#define HOTSPOT_CLASS_LOADED(arg0, arg1, arg2, arg3)
+#define HOTSPOT_CLASS_LOADED_ENABLED()  0
+#define HOTSPOT_CLASS_UNLOADED(arg0, arg1, arg2, arg3)
+#define HOTSPOT_CLASS_UNLOADED_ENABLED()  0
+#define HOTSPOT_CLASS_INITIALIZATION_REQUIRED(arg0, arg1, arg2, arg3)
+#define HOTSPOT_CLASS_INITIALIZATION_REQUIRED_ENABLED() 0
+#define HOTSPOT_CLASS_INITIALIZATION_RECURSIVE(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_CLASS_INITIALIZATION_RECURSIVE_ENABLED() 0
+#define HOTSPOT_CLASS_INITIALIZATION_CONCURRENT(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_CLASS_INITIALIZATION_CONCURRENT_ENABLED() 0
+#define HOTSPOT_CLASS_INITIALIZATION_ERRONEOUS(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_CLASS_INITIALIZATION_ERRONEOUS_ENABLED() 0
+#define HOTSPOT_CLASS_INITIALIZATION_SUPER_FAILED(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_CLASS_INITIALIZATION_SUPER_FAILED_ENABLED() 0
+#define HOTSPOT_CLASS_INITIALIZATION_CLINIT(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_CLASS_INITIALIZATION_CLINIT_ENABLED() 0
+#define HOTSPOT_CLASS_INITIALIZATION_ERROR(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_CLASS_INITIALIZATION_ERROR_ENABLED() 0
+#define HOTSPOT_CLASS_INITIALIZATION_END(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_CLASS_INITIALIZATION_END_ENABLED() 0
+#define HOTSPOT_COMPILED_METHOD_LOAD(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
+#define HOTSPOT_COMPILED_METHOD_LOAD_ENABLED()  0
+#define HOTSPOT_COMPILED_METHOD_UNLOAD(arg0, arg1, arg2, arg3, arg4, arg5)
+#define HOTSPOT_COMPILED_METHOD_UNLOAD_ENABLED() 0
+#define HOTSPOT_GC_BEGIN(arg0)
+#define HOTSPOT_GC_BEGIN_ENABLED() 0
+#define HOTSPOT_GC_END()
+#define HOTSPOT_GC_END_ENABLED() 0
+#define HOTSPOT_MEM_POOL_GC_BEGIN(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
+#define HOTSPOT_MEM_POOL_GC_BEGIN_ENABLED() 0
+#define HOTSPOT_MEM_POOL_GC_END(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
+#define HOTSPOT_MEM_POOL_GC_END_ENABLED() 0
+#define HOTSPOT_METHOD_COMPILE_BEGIN(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
+#define HOTSPOT_METHOD_COMPILE_BEGIN_ENABLED() 0
+#define HOTSPOT_METHOD_COMPILE_END(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
+#define HOTSPOT_METHOD_COMPILE_END_ENABLED() 0
+#define HOTSPOT_METHOD_ENTRY(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
+#define HOTSPOT_METHOD_ENTRY_ENABLED() 0
+#define HOTSPOT_METHOD_RETURN(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
+#define HOTSPOT_METHOD_RETURN_ENABLED() 0
+#define HOTSPOT_MONITOR_CONTENDED_ENTER(arg0, arg1, arg2, arg3)
+#define HOTSPOT_MONITOR_CONTENDED_ENTER_ENABLED() 0
+#define HOTSPOT_MONITOR_CONTENDED_ENTERED(arg0, arg1, arg2, arg3)
+#define HOTSPOT_MONITOR_CONTENDED_ENTERED_ENABLED() 0
+#define HOTSPOT_MONITOR_CONTENDED_EXIT(arg0, arg1, arg2, arg3)
+#define HOTSPOT_MONITOR_CONTENDED_EXIT_ENABLED() 0
+#define HOTSPOT_MONITOR_NOTIFY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_MONITOR_NOTIFY_ENABLED() 0
+#define HOTSPOT_MONITOR_NOTIFYALL(arg0, arg1, arg2, arg3)
+#define HOTSPOT_MONITOR_NOTIFYALL_ENABLED() 0
+#define HOTSPOT_MONITOR_WAIT(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_MONITOR_WAIT_ENABLED() 0
+#define HOTSPOT_MONITOR_WAIT_PROBE(arg0, arg1, arg2, arg3)
+#define HOTSPOT_MONITOR_WAIT_PROBE_ENABLED() 0
+#define HOTSPOT_MONITOR_WAITED(arg0, arg1, arg2, arg3)
+#define HOTSPOT_MONITOR_WAITED_ENABLED() 0
+#define HOTSPOT_OBJECT_ALLOC(arg0, arg1, arg2, arg3)
+#define HOTSPOT_OBJECT_ALLOC_ENABLED() 0
+#define HOTSPOT_THREAD_START(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_THREAD_START_ENABLED() 0
+#define HOTSPOT_THREAD_STOP(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_THREAD_STOP_ENABLED() 0
+#define HOTSPOT_THREAD_SLEEP_BEGIN(arg0)
+#define HOTSPOT_THREAD_SLEEP_BEGIN_ENABLED() 0
+#define HOTSPOT_THREAD_SLEEP_END(arg0)
+#define HOTSPOT_THREAD_SLEEP_END_ENABLED() 0
+#define HOTSPOT_THREAD_YIELD()
+#define HOTSPOT_THREAD_YIELD_ENABLED() 0
+#define HOTSPOT_THREAD_PARK_BEGIN(arg0, arg1, arg2)
+#define HOTSPOT_THREAD_PARK_BEGIN_ENABLED() 0
+#define HOTSPOT_THREAD_PARK_END(arg0)
+#define HOTSPOT_THREAD_PARK_END_ENABLED() 0
+#define HOTSPOT_THREAD_UNPARK()
+#define HOTSPOT_THREAD_UNPARK_ENABLED() 0
+#define HOTSPOT_VM_INIT_BEGIN()
+#define HOTSPOT_VM_INIT_BEGIN_ENABLED() 0
+#define HOTSPOT_VM_INIT_END()
+#define HOTSPOT_VM_INIT_END_ENABLED() 0
+#define HOTSPOT_VM_SHUTDOWN()
+#define HOTSPOT_VM_SHUTDOWN_ENABLED() 0
+#define HOTSPOT_VMOPS_REQUEST(arg0, arg1, arg2)
+#define HOTSPOT_VMOPS_REQUEST_ENABLED() 0
+#define HOTSPOT_VMOPS_BEGIN(arg0, arg1, arg2)
+#define HOTSPOT_VMOPS_BEGIN_ENABLED() 0
+#define HOTSPOT_VMOPS_END(arg0, arg1, arg2)
+#define HOTSPOT_VMOPS_END_ENABLED() 0
+
+/* hs_private provider probes */
+#define HS_PRIVATE_CMS_INITMARK_BEGIN()
+#define HS_PRIVATE_CMS_INITMARK_BEGIN_ENABLED() 0
+#define HS_PRIVATE_CMS_INITMARK_END()
+#define HS_PRIVATE_CMS_INITMARK_END_ENABLED() 0
+#define HS_PRIVATE_CMS_REMARK_BEGIN()
+#define HS_PRIVATE_CMS_REMARK_BEGIN_ENABLED() 0
+#define HS_PRIVATE_CMS_REMARK_END()
+#define HS_PRIVATE_CMS_REMARK_END_ENABLED() 0
+#define HS_PRIVATE_HASHTABLE_NEW_ENTRY(arg0, arg1, arg2, arg3)
+#define HS_PRIVATE_HASHTABLE_NEW_ENTRY_ENABLED() 0
+#define HS_PRIVATE_SAFEPOINT_BEGIN()
+#define HS_PRIVATE_SAFEPOINT_BEGIN_ENABLED() 0
+#define HS_PRIVATE_SAFEPOINT_END()
+#define HS_PRIVATE_SAFEPOINT_END_ENABLED() 0
+
+/* hotspot_jni provider probes */
+#define HOTSPOT_JNI_ALLOCOBJECT_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_ALLOCOBJECT_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_ALLOCOBJECT_RETURN(arg0)
+#define HOTSPOT_JNI_ALLOCOBJECT_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_ATTACHCURRENTTHREAD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_ATTACHCURRENTTHREAD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN(arg0)
+#define HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN(arg0)
+#define HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLBOOLEANMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLBOOLEANMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLBOOLEANMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLBOOLEANMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLBOOLEANMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLBOOLEANMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLBOOLEANMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLBOOLEANMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLBYTEMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLBYTEMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLBYTEMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLBYTEMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLBYTEMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLBYTEMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLBYTEMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLBYTEMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLBYTEMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLCHARMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLCHARMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLCHARMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLCHARMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLCHARMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLCHARMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLCHARMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLCHARMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLCHARMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLCHARMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLCHARMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLDOUBLEMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLDOUBLEMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLDOUBLEMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLDOUBLEMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLDOUBLEMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLDOUBLEMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLDOUBLEMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLDOUBLEMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLFLOATMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLFLOATMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLFLOATMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLFLOATMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLFLOATMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLFLOATMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLFLOATMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLFLOATMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLFLOATMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLINTMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLINTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLINTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLINTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLINTMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLINTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLINTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLINTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLINTMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLINTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLINTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLINTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLLONGMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLLONGMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLLONGMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLLONGMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLLONGMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLLONGMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLLONGMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLLONGMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLLONGMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLLONGMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLLONGMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALBOOLEANMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALBYTEMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALCHARMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALDOUBLEMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALFLOATMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALINTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALLONGMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALOBJECTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLNONVIRTUALSHORTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLOBJECTMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLOBJECTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLOBJECTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLOBJECTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLOBJECTMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLOBJECTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLOBJECTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLOBJECTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSHORTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSHORTMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSHORTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSHORTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSHORTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSHORTMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSHORTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSHORTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSHORTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICBOOLEANMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICBYTEMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICCHARMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICCHARMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICCHARMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICCHARMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICCHARMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICCHARMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICCHARMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICCHARMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICCHARMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICCHARMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICCHARMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICCHARMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLSTATICDOUBLEMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLSTATICFLOATMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICINTMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICINTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICINTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICINTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICINTMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICINTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICINTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICINTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICINTMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICINTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICINTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICINTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICLONGMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICLONGMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICLONGMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICLONGMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICLONGMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICLONGMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICLONGMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICLONGMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICLONGMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICLONGMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICLONGMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICLONGMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICOBJECTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHODA_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHODV_RETURN(arg0)
+#define HOTSPOT_JNI_CALLSTATICSHORTMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLSTATICVOIDMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLVOIDMETHOD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLVOIDMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLVOIDMETHOD_RETURN()
+#define HOTSPOT_JNI_CALLVOIDMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLVOIDMETHODA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLVOIDMETHODA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLVOIDMETHODA_RETURN()
+#define HOTSPOT_JNI_CALLVOIDMETHODA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CALLVOIDMETHODV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CALLVOIDMETHODV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CALLVOIDMETHODV_RETURN()
+#define HOTSPOT_JNI_CALLVOIDMETHODV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_CREATEJAVAVM_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_CREATEJAVAVM_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_CREATEJAVAVM_RETURN(arg0)
+#define HOTSPOT_JNI_CREATEJAVAVM_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_DEFINECLASS_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_DEFINECLASS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_DEFINECLASS_RETURN(arg0)
+#define HOTSPOT_JNI_DEFINECLASS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_DELETEGLOBALREF_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_DELETEGLOBALREF_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_DELETEGLOBALREF_RETURN()
+#define HOTSPOT_JNI_DELETEGLOBALREF_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_DELETELOCALREF_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_DELETELOCALREF_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_DELETELOCALREF_RETURN()
+#define HOTSPOT_JNI_DELETELOCALREF_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_DELETEWEAKGLOBALREF_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_DELETEWEAKGLOBALREF_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_DELETEWEAKGLOBALREF_RETURN()
+#define HOTSPOT_JNI_DELETEWEAKGLOBALREF_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_DESTROYJAVAVM_ENTRY(arg0)
+#define HOTSPOT_JNI_DESTROYJAVAVM_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_DESTROYJAVAVM_RETURN(arg0)
+#define HOTSPOT_JNI_DESTROYJAVAVM_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY(arg0)
+#define HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(arg0)
+#define HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_ENSURELOCALCAPACITY_RETURN(arg0)
+#define HOTSPOT_JNI_ENSURELOCALCAPACITY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_EXCEPTIONCHECK_ENTRY(arg0)
+#define HOTSPOT_JNI_EXCEPTIONCHECK_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_EXCEPTIONCHECK_RETURN(arg0)
+#define HOTSPOT_JNI_EXCEPTIONCHECK_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_EXCEPTIONCLEAR_ENTRY(arg0)
+#define HOTSPOT_JNI_EXCEPTIONCLEAR_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_EXCEPTIONCLEAR_RETURN()
+#define HOTSPOT_JNI_EXCEPTIONCLEAR_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_EXCEPTIONDESCRIBE_ENTRY(arg0)
+#define HOTSPOT_JNI_EXCEPTIONDESCRIBE_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_EXCEPTIONDESCRIBE_RETURN()
+#define HOTSPOT_JNI_EXCEPTIONDESCRIBE_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_EXCEPTIONOCCURRED_ENTRY(arg0)
+#define HOTSPOT_JNI_EXCEPTIONOCCURRED_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_EXCEPTIONOCCURRED_RETURN(arg0)
+#define HOTSPOT_JNI_EXCEPTIONOCCURRED_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_FATALERROR_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_FATALERROR_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_FINDCLASS_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_FINDCLASS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_FINDCLASS_RETURN(arg0)
+#define HOTSPOT_JNI_FINDCLASS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_FROMREFLECTEDFIELD_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_FROMREFLECTEDFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_FROMREFLECTEDFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_FROMREFLECTEDFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_FROMREFLECTEDMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_FROMREFLECTEDMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETARRAYLENGTH_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETARRAYLENGTH_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETARRAYLENGTH_RETURN(arg0)
+#define HOTSPOT_JNI_GETARRAYLENGTH_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_RETURN(arg0)
+#define HOTSPOT_JNI_GETBOOLEANARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETBOOLEANARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETBOOLEANARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETBOOLEANARRAYREGION_RETURN()
+#define HOTSPOT_JNI_GETBOOLEANARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETBOOLEANFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETBOOLEANFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETBOOLEANFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETBOOLEANFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETBYTEARRAYELEMENTS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETBYTEARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETBYTEARRAYELEMENTS_RETURN(arg0)
+#define HOTSPOT_JNI_GETBYTEARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETBYTEARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETBYTEARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETBYTEARRAYREGION_RETURN()
+#define HOTSPOT_JNI_GETBYTEARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETBYTEFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETBYTEFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETBYTEFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETBYTEFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETCHARARRAYELEMENTS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETCHARARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETCHARARRAYELEMENTS_RETURN(arg0)
+#define HOTSPOT_JNI_GETCHARARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETCHARARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETCHARARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETCHARARRAYREGION_RETURN()
+#define HOTSPOT_JNI_GETCHARARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETCHARFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETCHARFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETCHARFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETCHARFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETCREATEDJAVAVMS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETCREATEDJAVAVMS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETCREATEDJAVAVMS_RETURN(arg0)
+#define HOTSPOT_JNI_GETCREATEDJAVAVMS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_ENTRY(arg0)
+#define HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_RETURN(arg0)
+#define HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_RETURN(arg0)
+#define HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_RETURN(arg0)
+#define HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_RETURN(arg0)
+#define HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETDOUBLEARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETDOUBLEARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETDOUBLEARRAYREGION_RETURN()
+#define HOTSPOT_JNI_GETDOUBLEARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETDOUBLEFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETDOUBLEFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETDOUBLEFIELD_RETURN()
+#define HOTSPOT_JNI_GETDOUBLEFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETENV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETENV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETENV_RETURN(arg0)
+#define HOTSPOT_JNI_GETENV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETFIELDID_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_GETFIELDID_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETFIELDID_RETURN(arg0)
+#define HOTSPOT_JNI_GETFIELDID_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETFLOATARRAYELEMENTS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETFLOATARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETFLOATARRAYELEMENTS_RETURN(arg0)
+#define HOTSPOT_JNI_GETFLOATARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETFLOATARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETFLOATARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETFLOATARRAYREGION_RETURN()
+#define HOTSPOT_JNI_GETFLOATARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETFLOATFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETFLOATFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETFLOATFIELD_RETURN()
+#define HOTSPOT_JNI_GETFLOATFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETINTARRAYELEMENTS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETINTARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETINTARRAYELEMENTS_RETURN(arg0)
+#define HOTSPOT_JNI_GETINTARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETINTARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETINTARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETINTARRAYREGION_RETURN()
+#define HOTSPOT_JNI_GETINTARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETINTFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETINTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETINTFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETINTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETJAVAVM_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETJAVAVM_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETJAVAVM_RETURN(arg0)
+#define HOTSPOT_JNI_GETJAVAVM_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETLONGARRAYELEMENTS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETLONGARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETLONGARRAYELEMENTS_RETURN(arg0)
+#define HOTSPOT_JNI_GETLONGARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETLONGARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETLONGARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETLONGARRAYREGION_RETURN()
+#define HOTSPOT_JNI_GETLONGARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETLONGFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETLONGFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETLONGFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETLONGFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETMETHODID_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_GETMETHODID_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETMETHODID_RETURN(arg0)
+#define HOTSPOT_JNI_GETMETHODID_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN(arg0)
+#define HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETOBJECTCLASS_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETOBJECTCLASS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETOBJECTCLASS_RETURN(arg0)
+#define HOTSPOT_JNI_GETOBJECTCLASS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETOBJECTFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETOBJECTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETOBJECTFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETOBJECTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETOBJECTREFTYPE_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETOBJECTREFTYPE_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETOBJECTREFTYPE_RETURN(arg0)
+#define HOTSPOT_JNI_GETOBJECTREFTYPE_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_RETURN(arg0)
+#define HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSHORTARRAYELEMENTS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSHORTARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSHORTARRAYELEMENTS_RETURN(arg0)
+#define HOTSPOT_JNI_GETSHORTARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSHORTARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETSHORTARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSHORTARRAYREGION_RETURN()
+#define HOTSPOT_JNI_GETSHORTARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSHORTFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSHORTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSHORTFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETSHORTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICBOOLEANFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICBOOLEANFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICBOOLEANFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICBOOLEANFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICBYTEFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICBYTEFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICBYTEFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICBYTEFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICCHARFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICCHARFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICCHARFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICCHARFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICDOUBLEFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICDOUBLEFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICDOUBLEFIELD_RETURN()
+#define HOTSPOT_JNI_GETSTATICDOUBLEFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICFIELDID_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_GETSTATICFIELDID_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICFIELDID_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICFIELDID_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICFLOATFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICFLOATFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICFLOATFIELD_RETURN()
+#define HOTSPOT_JNI_GETSTATICFLOATFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICINTFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICINTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICINTFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICINTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICLONGFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICLONGFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICLONGFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICLONGFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICMETHODID_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_GETSTATICMETHODID_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICMETHODID_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICMETHODID_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICOBJECTFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICOBJECTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICSHORTFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTATICSHORTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTATICSHORTFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTATICSHORTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGCHARS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTRINGCHARS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGCHARS_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTRINGCHARS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGLENGTH_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETSTRINGLENGTH_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGLENGTH_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTRINGLENGTH_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETSTRINGREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGREGION_RETURN()
+#define HOTSPOT_JNI_GETSTRINGREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGUTFLENGTH_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETSTRINGUTFLENGTH_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGUTFLENGTH_RETURN(arg0)
+#define HOTSPOT_JNI_GETSTRINGUTFLENGTH_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGUTFREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_GETSTRINGUTFREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSTRINGUTFREGION_RETURN()
+#define HOTSPOT_JNI_GETSTRINGUTFREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETSUPERCLASS_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_GETSUPERCLASS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETSUPERCLASS_RETURN(arg0)
+#define HOTSPOT_JNI_GETSUPERCLASS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_GETVERSION_ENTRY(arg0)
+#define HOTSPOT_JNI_GETVERSION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_GETVERSION_RETURN(arg0)
+#define HOTSPOT_JNI_GETVERSION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_ISASSIGNABLEFROM_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_ISASSIGNABLEFROM_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN(arg0)
+#define HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_ISINSTANCEOF_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_ISINSTANCEOF_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_ISINSTANCEOF_RETURN(arg0)
+#define HOTSPOT_JNI_ISINSTANCEOF_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_ISSAMEOBJECT_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_ISSAMEOBJECT_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_ISSAMEOBJECT_RETURN(arg0)
+#define HOTSPOT_JNI_ISSAMEOBJECT_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_MONITORENTER_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_MONITORENTER_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_MONITORENTER_RETURN(arg0)
+#define HOTSPOT_JNI_MONITORENTER_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_MONITOREXIT_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_MONITOREXIT_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_MONITOREXIT_RETURN(arg0)
+#define HOTSPOT_JNI_MONITOREXIT_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWBOOLEANARRAY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWBOOLEANARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWBOOLEANARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWBOOLEANARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWBYTEARRAY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWBYTEARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWBYTEARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWBYTEARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWCHARARRAY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWCHARARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWCHARARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWCHARARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN(arg0)
+#define HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWDOUBLEARRAY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWDOUBLEARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWDOUBLEARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWDOUBLEARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWFLOATARRAY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWFLOATARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWFLOATARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWFLOATARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWGLOBALREF_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWGLOBALREF_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWGLOBALREF_RETURN(arg0)
+#define HOTSPOT_JNI_NEWGLOBALREF_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWINTARRAY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWINTARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWINTARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWINTARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWLOCALREF_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWLOCALREF_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWLOCALREF_RETURN(arg0)
+#define HOTSPOT_JNI_NEWLOCALREF_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWLONGARRAY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWLONGARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWLONGARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWLONGARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWOBJECT_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_NEWOBJECT_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWOBJECT_RETURN(arg0)
+#define HOTSPOT_JNI_NEWOBJECT_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWOBJECTA_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_NEWOBJECTA_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWOBJECTA_RETURN(arg0)
+#define HOTSPOT_JNI_NEWOBJECTA_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWOBJECTARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWOBJECTARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWOBJECTV_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_NEWOBJECTV_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWOBJECTV_RETURN(arg0)
+#define HOTSPOT_JNI_NEWOBJECTV_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWSHORTARRAY_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWSHORTARRAY_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWSHORTARRAY_RETURN(arg0)
+#define HOTSPOT_JNI_NEWSHORTARRAY_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWSTRING_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_NEWSTRING_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWSTRING_RETURN(arg0)
+#define HOTSPOT_JNI_NEWSTRING_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWSTRINGUTF_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWSTRINGUTF_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWSTRINGUTF_RETURN(arg0)
+#define HOTSPOT_JNI_NEWSTRINGUTF_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN(arg0)
+#define HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_POPLOCALFRAME_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_POPLOCALFRAME_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_POPLOCALFRAME_RETURN(arg0)
+#define HOTSPOT_JNI_POPLOCALFRAME_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_PUSHLOCALFRAME_RETURN(arg0)
+#define HOTSPOT_JNI_PUSHLOCALFRAME_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_REGISTERNATIVES_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_REGISTERNATIVES_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_REGISTERNATIVES_RETURN(arg0)
+#define HOTSPOT_JNI_REGISTERNATIVES_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_RETURN()
+#define HOTSPOT_JNI_RELEASEBOOLEANARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_RETURN()
+#define HOTSPOT_JNI_RELEASEBYTEARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_RETURN()
+#define HOTSPOT_JNI_RELEASECHARARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_RETURN()
+#define HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_RETURN()
+#define HOTSPOT_JNI_RELEASEFLOATARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_RETURN()
+#define HOTSPOT_JNI_RELEASEINTARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_RETURN()
+#define HOTSPOT_JNI_RELEASELONGARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN()
+#define HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_RETURN()
+#define HOTSPOT_JNI_RELEASESHORTARRAYELEMENTS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASESTRINGCHARS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_RELEASESTRINGCHARS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASESTRINGCHARS_RETURN()
+#define HOTSPOT_JNI_RELEASESTRINGCHARS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASESTRINGCRITICAL_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_RELEASESTRINGCRITICAL_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN()
+#define HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_RELEASESTRINGUTFCHARS_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_RELEASESTRINGUTFCHARS_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_RELEASESTRINGUTFCHARS_RETURN()
+#define HOTSPOT_JNI_RELEASESTRINGUTFCHARS_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETBOOLEANARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_SETBOOLEANARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETBOOLEANARRAYREGION_RETURN()
+#define HOTSPOT_JNI_SETBOOLEANARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()
+#define HOTSPOT_JNI_SETBOOLEANFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETBYTEARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_SETBYTEARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETBYTEARRAYREGION_RETURN()
+#define HOTSPOT_JNI_SETBYTEARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETBYTEFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETBYTEFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETBYTEFIELD_RETURN()
+#define HOTSPOT_JNI_SETBYTEFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETCHARARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_SETCHARARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETCHARARRAYREGION_RETURN()
+#define HOTSPOT_JNI_SETCHARARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETCHARFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETCHARFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETCHARFIELD_RETURN()
+#define HOTSPOT_JNI_SETCHARFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETDOUBLEARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_SETDOUBLEARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETDOUBLEARRAYREGION_RETURN()
+#define HOTSPOT_JNI_SETDOUBLEARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETDOUBLEFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_SETDOUBLEFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETDOUBLEFIELD_RETURN()
+#define HOTSPOT_JNI_SETDOUBLEFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETFLOATARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_SETFLOATARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETFLOATARRAYREGION_RETURN()
+#define HOTSPOT_JNI_SETFLOATARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETFLOATFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_SETFLOATFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETFLOATFIELD_RETURN()
+#define HOTSPOT_JNI_SETFLOATFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETINTARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_SETINTARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETINTARRAYREGION_RETURN()
+#define HOTSPOT_JNI_SETINTARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETINTFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETINTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETINTFIELD_RETURN()
+#define HOTSPOT_JNI_SETINTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETLONGARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_SETLONGARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETLONGARRAYREGION_RETURN()
+#define HOTSPOT_JNI_SETLONGARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETLONGFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETLONGFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETLONGFIELD_RETURN()
+#define HOTSPOT_JNI_SETLONGFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETOBJECTARRAYELEMENT_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETOBJECTARRAYELEMENT_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETOBJECTARRAYELEMENT_RETURN()
+#define HOTSPOT_JNI_SETOBJECTARRAYELEMENT_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETOBJECTFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETOBJECTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETOBJECTFIELD_RETURN()
+#define HOTSPOT_JNI_SETOBJECTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSHORTARRAYREGION_ENTRY(arg0, arg1, arg2, arg3, arg4)
+#define HOTSPOT_JNI_SETSHORTARRAYREGION_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSHORTARRAYREGION_RETURN()
+#define HOTSPOT_JNI_SETSHORTARRAYREGION_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSHORTFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETSHORTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSHORTFIELD_RETURN()
+#define HOTSPOT_JNI_SETSHORTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICBOOLEANFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETSTATICBOOLEANFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICBOOLEANFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICBOOLEANFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICBYTEFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICBYTEFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICCHARFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETSTATICCHARFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICCHARFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICCHARFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICDOUBLEFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_SETSTATICDOUBLEFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICDOUBLEFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICDOUBLEFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICFLOATFIELD_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_SETSTATICFLOATFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICFLOATFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICFLOATFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICINTFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETSTATICINTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICINTFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICINTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICLONGFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETSTATICLONGFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICLONGFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICLONGFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICOBJECTFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETSTATICOBJECTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICSHORTFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_SETSTATICSHORTFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_SETSTATICSHORTFIELD_RETURN()
+#define HOTSPOT_JNI_SETSTATICSHORTFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_THROW_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_THROW_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_THROW_RETURN(arg0)
+#define HOTSPOT_JNI_THROW_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_THROWNEW_ENTRY(arg0, arg1, arg2)
+#define HOTSPOT_JNI_THROWNEW_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_THROWNEW_RETURN(arg0)
+#define HOTSPOT_JNI_THROWNEW_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_TOREFLECTEDFIELD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_TOREFLECTEDFIELD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_TOREFLECTEDFIELD_RETURN(arg0)
+#define HOTSPOT_JNI_TOREFLECTEDFIELD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_TOREFLECTEDMETHOD_ENTRY(arg0, arg1, arg2, arg3)
+#define HOTSPOT_JNI_TOREFLECTEDMETHOD_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_TOREFLECTEDMETHOD_RETURN(arg0)
+#define HOTSPOT_JNI_TOREFLECTEDMETHOD_RETURN_ENABLED()  0
+#define HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY(arg0, arg1)
+#define HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY_ENABLED()  0
+#define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(arg0)
+#define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN_ENABLED()  0
+
+#else /* USDT2 */
+#error This file should only be included for USDT2
+#endif /* USDT2 */
+
+#else /* !defined(DTRACE_ENABLED) */
+#error This file should only be included when dtrace is not enabled
+#end /* !defined(DTRACE_ENABLED) */
+
+#endif // SHARE_VM_UTILITIES_DTRACE_USDT2_DISABLED_HPP
--- a/hotspot/src/share/vm/utilities/elfFile.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/elfFile.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -24,7 +24,7 @@
 
 #include "precompiled.hpp"
 
-#ifndef _WINDOWS
+#if !defined(_WINDOWS) && !defined(__APPLE__)
 
 #include <string.h>
 #include <stdio.h>
--- a/hotspot/src/share/vm/utilities/elfFile.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/elfFile.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -25,9 +25,13 @@
 #ifndef __ELF_FILE_HPP
 #define __ELF_FILE_HPP
 
-#ifndef _WINDOWS
+#if !defined(_WINDOWS) && !defined(__APPLE__)
 
+#if defined(__OpenBSD__)
+#include <sys/exec_elf.h>
+#else
 #include <elf.h>
+#endif
 #include <stdio.h>
 
 #ifdef _LP64
@@ -41,7 +45,9 @@
 typedef Elf64_Shdr      Elf_Shdr;
 typedef Elf64_Sym       Elf_Sym;
 
+#if !defined(_ALLBSD_SOURCE) || defined(__APPLE__)
 #define ELF_ST_TYPE ELF64_ST_TYPE
+#endif
 
 #else
 
@@ -55,8 +61,10 @@
 typedef Elf32_Shdr      Elf_Shdr;
 typedef Elf32_Sym       Elf_Sym;
 
+#if !defined(_ALLBSD_SOURCE) || defined(__APPLE__)
 #define ELF_ST_TYPE ELF32_ST_TYPE
 #endif
+#endif
 
 #include "globalDefinitions.hpp"
 #include "memory/allocation.hpp"
@@ -137,4 +145,3 @@
 #endif // _WINDOWS
 
 #endif // __ELF_FILE_HPP
-
--- a/hotspot/src/share/vm/utilities/elfStringTable.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/elfStringTable.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -24,7 +24,7 @@
 
 #include "precompiled.hpp"
 
-#ifndef _WINDOWS
+#if !defined(_WINDOWS) && !defined(__APPLE__)
 
 #include "memory/allocation.inline.hpp"
 #include "runtime/os.hpp"
@@ -87,4 +87,3 @@
 }
 
 #endif // _WINDOWS
-
--- a/hotspot/src/share/vm/utilities/elfStringTable.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/elfStringTable.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -25,7 +25,7 @@
 #ifndef __ELF_STRING_TABLE_HPP
 #define __ELF_STRING_TABLE_HPP
 
-#ifndef _WINDOWS
+#if !defined(_WINDOWS) && !defined(__APPLE__)
 
 #include "memory/allocation.hpp"
 #include "utilities/decoder.hpp"
@@ -79,4 +79,3 @@
 #endif // _WINDOWS
 
 #endif // __ELF_STRING_TABLE_HPP
-
--- a/hotspot/src/share/vm/utilities/elfSymbolTable.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/elfSymbolTable.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -24,7 +24,7 @@
 
 #include "precompiled.hpp"
 
-#ifndef _WINDOWS
+#if !defined(_WINDOWS) && !defined(__APPLE__)
 
 #include "memory/allocation.inline.hpp"
 #include "utilities/elfSymbolTable.hpp"
--- a/hotspot/src/share/vm/utilities/elfSymbolTable.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/elfSymbolTable.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -25,7 +25,7 @@
 #ifndef __ELF_SYMBOL_TABLE_HPP
 #define __ELF_SYMBOL_TABLE_HPP
 
-#ifndef _WINDOWS
+#if !defined(_WINDOWS) && !defined(__APPLE__)
 
 
 #include "memory/allocation.hpp"
@@ -68,6 +68,3 @@
 #endif // _WINDOWS
 
 #endif // __ELF_SYMBOL_TABLE_HPP
-
-
-
--- a/hotspot/src/share/vm/utilities/events.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/events.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -38,6 +38,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/utilities/exceptions.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/exceptions.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -42,6 +42,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 
 // Implementation of ThreadShadow
--- a/hotspot/src/share/vm/utilities/exceptions.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/exceptions.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -58,6 +58,8 @@
 // include hierachy reasons).
 
 class ThreadShadow: public CHeapObj {
+  friend class VMStructs;
+
  protected:
   oop  _pending_exception;                       // Thread has gc actions.
   const char* _exception_file;                   // file information for exception (debugging only)
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -25,6 +25,10 @@
 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
 
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+
 #ifdef TARGET_COMPILER_gcc
 # include "utilities/globalDefinitions_gcc.hpp"
 #endif
@@ -1178,67 +1182,47 @@
 }
 
 // Printf-style formatters for fixed- and variable-width types as pointers and
-// integers.
-//
-// Each compiler-specific definitions file (e.g., globalDefinitions_gcc.hpp)
-// must define the macro FORMAT64_MODIFIER, which is the modifier for '%x' or
-// '%d' formats to indicate a 64-bit quantity; commonly "l" (in LP64) or "ll"
-// (in ILP32).
+// integers.  These are derived from the definitions in inttypes.h.  If the platform
+// doesn't provide appropriate definitions, they should be provided in
+// the compiler-specific definitions file (e.g., globalDefinitions_gcc.hpp)
 
 #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false")
 
 // Format 32-bit quantities.
-#define INT32_FORMAT  "%d"
-#define UINT32_FORMAT "%u"
-#define INT32_FORMAT_W(width)   "%" #width "d"
-#define UINT32_FORMAT_W(width)  "%" #width "u"
+#define INT32_FORMAT           "%" PRId32
+#define UINT32_FORMAT          "%" PRIu32
+#define INT32_FORMAT_W(width)  "%" #width PRId32
+#define UINT32_FORMAT_W(width) "%" #width PRIu32
 
-#define PTR32_FORMAT  "0x%08x"
+#define PTR32_FORMAT           "0x%08" PRIx32
 
 // Format 64-bit quantities.
-#define INT64_FORMAT  "%" FORMAT64_MODIFIER "d"
-#define UINT64_FORMAT "%" FORMAT64_MODIFIER "u"
-#define PTR64_FORMAT  "0x%016" FORMAT64_MODIFIER "x"
-
-#define INT64_FORMAT_W(width)  "%" #width FORMAT64_MODIFIER "d"
-#define UINT64_FORMAT_W(width) "%" #width FORMAT64_MODIFIER "u"
+#define INT64_FORMAT           "%" PRId64
+#define UINT64_FORMAT          "%" PRIu64
+#define INT64_FORMAT_W(width)  "%" #width PRId64
+#define UINT64_FORMAT_W(width) "%" #width PRIu64
 
-// Format macros that allow the field width to be specified.  The width must be
-// a string literal (e.g., "8") or a macro that evaluates to one.
-#ifdef _LP64
-#define UINTX_FORMAT_W(width)   UINT64_FORMAT_W(width)
-#define SSIZE_FORMAT_W(width)   INT64_FORMAT_W(width)
-#define SIZE_FORMAT_W(width)    UINT64_FORMAT_W(width)
-#else
-#define UINTX_FORMAT_W(width)   UINT32_FORMAT_W(width)
-#define SSIZE_FORMAT_W(width)   INT32_FORMAT_W(width)
-#define SIZE_FORMAT_W(width)    UINT32_FORMAT_W(width)
-#endif // _LP64
+#define PTR64_FORMAT           "0x%016" PRIx64
 
-// Format pointers and size_t (or size_t-like integer types) which change size
-// between 32- and 64-bit. The pointer format theoretically should be "%p",
-// however, it has different output on different platforms. On Windows, the data
-// will be padded with zeros automatically. On Solaris, we can use "%016p" &
-// "%08p" on 64 bit & 32 bit platforms to make the data padded with extra zeros.
-// On Linux, "%016p" or "%08p" is not be allowed, at least on the latest GCC
-// 4.3.2. So we have to use "%016x" or "%08x" to simulate the printing format.
-// GCC 4.3.2, however requires the data to be converted to "intptr_t" when
-// using "%x".
+// Format pointers which change size between 32- and 64-bit.
 #ifdef  _LP64
-#define PTR_FORMAT    PTR64_FORMAT
-#define UINTX_FORMAT  UINT64_FORMAT
-#define INTX_FORMAT   INT64_FORMAT
-#define SIZE_FORMAT   UINT64_FORMAT
-#define SSIZE_FORMAT  INT64_FORMAT
+#define INTPTR_FORMAT "0x%016" PRIxPTR
+#define PTR_FORMAT    "0x%016" PRIxPTR
 #else   // !_LP64
-#define PTR_FORMAT    PTR32_FORMAT
-#define UINTX_FORMAT  UINT32_FORMAT
-#define INTX_FORMAT   INT32_FORMAT
-#define SIZE_FORMAT   UINT32_FORMAT
-#define SSIZE_FORMAT  INT32_FORMAT
+#define INTPTR_FORMAT "0x%08"  PRIxPTR
+#define PTR_FORMAT    "0x%08"  PRIxPTR
 #endif  // _LP64
 
-#define INTPTR_FORMAT PTR_FORMAT
+#define SSIZE_FORMAT          "%" PRIdPTR
+#define SIZE_FORMAT           "%" PRIuPTR
+#define SSIZE_FORMAT_W(width) "%" #width PRIdPTR
+#define SIZE_FORMAT_W(width)  "%" #width PRIuPTR
+
+#define INTX_FORMAT           "%" PRIdPTR
+#define UINTX_FORMAT          "%" PRIuPTR
+#define INTX_FORMAT_W(width)  "%" #width PRIdPTR
+#define UINTX_FORMAT_W(width) "%" #width PRIuPTR
+
 
 // Enable zap-a-lot if in debug version.
 
--- a/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -76,15 +76,28 @@
 # include <sys/procfs.h>
 # endif
 
-#ifdef LINUX
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
 #endif // __STDC_LIMIT_MACROS
 #include <inttypes.h>
 #include <signal.h>
+#ifndef __OpenBSD__
 #include <ucontext.h>
+#endif
+#ifdef __APPLE__
+  #include <AvailabilityMacros.h>
+  #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
+    // Mac OS X 10.4 defines EFL_AC and EFL_ID,
+    // which conflict with hotspot variable names.
+    //
+    // This has been fixed in Mac OS X 10.5.
+    #undef EFL_AC
+    #undef EFL_ID
+  #endif
+#endif
 #include <sys/time.h>
-#endif // LINUX
+#endif // LINUX || _ALLBSD_SOURCE
 
 // 4810578: varargs unsafe on 32-bit integer/64-bit pointer architectures
 // When __cplusplus is defined, NULL is defined as 0 (32-bit constant) in
@@ -120,7 +133,7 @@
 // pointer is stored as integer value.  On some platforms, sizeof(intptr_t) >
 // sizeof(void*), so here we want something which is integer type, but has the
 // same size as a pointer.
-#ifdef LINUX
+#ifdef __GNUC__
   #ifdef _LP64
     #define NULL_WORD  0L
   #else
@@ -132,7 +145,7 @@
   #define NULL_WORD  NULL
 #endif
 
-#ifndef LINUX
+#if !defined(LINUX) && !defined(_ALLBSD_SOURCE)
 // Compiler-specific primitive types
 typedef unsigned short     uint16_t;
 #ifndef _UINT32_T
@@ -152,7 +165,7 @@
 // prior definition of intptr_t, and add "&& !defined(XXX)" above.
 #endif // _SYS_INT_TYPES_H
 
-#endif // !LINUX
+#endif // !LINUX && !_ALLBSD_SOURCE
 
 // Additional Java basic types
 
@@ -244,7 +257,9 @@
 inline int g_isnan(float  f) { return isnand(f); }
 #endif
 inline int g_isnan(double f) { return isnand(f); }
-#elif LINUX
+#elif defined(__APPLE__)
+inline int g_isnan(double f) { return isnan(f); }
+#elif defined(LINUX) || defined(_ALLBSD_SOURCE)
 inline int g_isnan(float  f) { return isnanf(f); }
 inline int g_isnan(double f) { return isnan(f); }
 #else
--- a/hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -74,8 +74,25 @@
 # ifdef SOLARIS_MUTATOR_LIBTHREAD
 # include <sys/procfs.h>
 # endif
+
+#include <inttypes.h>
+
+// Solaris 8 doesn't provide definitions of these
+#ifdef SOLARIS
+#ifndef PRIdPTR
+#if defined(_LP64)
+#define PRIdPTR                 "ld"
+#define PRIuPTR                 "lu"
+#define PRIxPTR                 "lx"
+#else
+#define PRIdPTR                 "d"
+#define PRIuPTR                 "u"
+#define PRIxPTR                 "x"
+#endif
+#endif
+#endif
+
 #ifdef LINUX
-# include <inttypes.h>
 # include <signal.h>
 # include <ucontext.h>
 # include <sys/time.h>
--- a/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -207,6 +207,20 @@
 // Formatting.
 #define FORMAT64_MODIFIER "I64"
 
+// Visual Studio doesn't provide inttypes.h so provide appropriate definitions here.
+// The 32 bits ones might need I32 but seem to work ok without it.
+#define PRId32       "d"
+#define PRIu32       "u"
+#define PRIx32       "x"
+
+#define PRId64       "I64d"
+#define PRIu64       "I64u"
+#define PRIx64       "I64x"
+
+#define PRIdPTR       "d"
+#define PRIuPTR       "u"
+#define PRIxPTR       "x"
+
 #define offset_of(klass,field) offsetof(klass,field)
 
 #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP
--- a/hotspot/src/share/vm/utilities/growableArray.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/growableArray.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -34,6 +34,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 #ifdef ASSERT
 void GenericGrowableArray::set_nesting() {
   if (on_stack()) {
--- a/hotspot/src/share/vm/utilities/growableArray.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/growableArray.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,6 +77,8 @@
 }
 
 class GenericGrowableArray : public ResourceObj {
+  friend class VMStructs;
+
  protected:
   int    _len;          // current length
   int    _max;          // maximum length
@@ -136,6 +138,8 @@
 };
 
 template<class E> class GrowableArray : public GenericGrowableArray {
+  friend class VMStructs;
+
  private:
   E*     _data;         // data array
 
--- a/hotspot/src/share/vm/utilities/hashtable.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/hashtable.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -32,8 +32,10 @@
 #include "utilities/hashtable.inline.hpp"
 
 
+#ifndef USDT2
 HS_DTRACE_PROBE_DECL4(hs_private, hashtable__new_entry,
   void*, unsigned int, void*, void*);
+#endif /* !USDT2 */
 
 // This is a generic hashtable, designed to be used for the symbol
 // and string tables.
@@ -73,8 +75,13 @@
 
   entry = (HashtableEntry<T>*)BasicHashtable::new_entry(hashValue);
   entry->set_literal(obj);
+#ifndef USDT2
   HS_DTRACE_PROBE4(hs_private, hashtable__new_entry,
     this, hashValue, obj, entry);
+#else /* USDT2 */
+  HS_PRIVATE_HASHTABLE_NEW_ENTRY(
+    this, hashValue, (uintptr_t) obj, entry);
+#endif /* USDT2 */
   return entry;
 }
 
--- a/hotspot/src/share/vm/utilities/histogram.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/histogram.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 // This class provides a framework for collecting various statistics.
 // The current implementation is oriented towards counting invocations
--- a/hotspot/src/share/vm/utilities/macros.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/macros.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -161,6 +161,14 @@
 #define NOT_WINDOWS(code) code
 #endif
 
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+#define BSD_ONLY(code) code
+#define NOT_BSD(code)
+#else
+#define BSD_ONLY(code)
+#define NOT_BSD(code) code
+#endif
+
 #ifdef _WIN64
 #define WIN64_ONLY(code) code
 #define NOT_WIN64(code)
--- a/hotspot/src/share/vm/utilities/ostream.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/ostream.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -39,6 +39,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "os_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "os_bsd.inline.hpp"
+#endif
 
 extern "C" void jio_print(const char* s); // Declarationtion of jvm method
 
@@ -992,7 +995,7 @@
 
 #ifndef PRODUCT
 
-#if defined(SOLARIS) || defined(LINUX)
+#if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
--- a/hotspot/src/share/vm/utilities/preserveException.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/preserveException.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // This file provides more support for exception handling; see also exceptions.hpp
 class PreserveExceptionMark {
--- a/hotspot/src/share/vm/utilities/quickSort.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/quickSort.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -54,16 +54,18 @@
   return 1;
 }
 
-static int test_stdlib_comparator(const void* a, const void* b) {
-  int ai = *(int*)a;
-  int bi = *(int*)b;
-  if (ai == bi) {
-    return 0;
+extern "C" {
+  static int test_stdlib_comparator(const void* a, const void* b) {
+    int ai = *(int*)a;
+    int bi = *(int*)b;
+    if (ai == bi) {
+      return 0;
+    }
+    if (ai < bi) {
+      return -1;
+    }
+    return 1;
   }
-  if (ai < bi) {
-    return -1;
-  }
-  return 1;
 }
 
 void QuickSort::print_array(const char* prefix, int* array, int length) {
--- a/hotspot/src/share/vm/utilities/taskqueue.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/taskqueue.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -37,6 +37,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 #ifdef TRACESPINNING
 uint ParallelTaskTerminator::_total_yields = 0;
@@ -274,4 +277,3 @@
   reset_for_reuse();
   _n_threads = n_threads;
 }
-
--- a/hotspot/src/share/vm/utilities/taskqueue.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/taskqueue.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -53,6 +53,12 @@
 #ifdef TARGET_OS_ARCH_linux_ppc
 # include "orderAccess_linux_ppc.inline.hpp"
 #endif
+#ifdef TARGET_OS_ARCH_bsd_x86
+# include "orderAccess_bsd_x86.inline.hpp"
+#endif
+#ifdef TARGET_OS_ARCH_bsd_zero
+# include "orderAccess_bsd_zero.inline.hpp"
+#endif
 
 // Simple TaskQueue stats that are collected by default in debug builds.
 
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -45,13 +45,18 @@
   "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH",
   "JAVA_COMPILER", "PATH", "USERNAME",
 
-  // Env variables that are defined on Solaris/Linux
+  // Env variables that are defined on Solaris/Linux/BSD
   "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY",
   "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE",
 
   // defined on Linux
   "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM",
 
+  // defined on Darwin
+  "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH",
+  "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH",
+  "DYLD_INSERT_LIBRARIES",
+
   // defined on Windows
   "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR",
 
@@ -958,7 +963,7 @@
     const char* ptr = OnError;
     while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
       out.print_raw   ("#   Executing ");
-#if defined(LINUX)
+#if defined(LINUX) || defined(_ALLBSD_SOURCE)
       out.print_raw   ("/bin/sh -c ");
 #elif defined(SOLARIS)
       out.print_raw   ("/usr/bin/sh -c ");
--- a/hotspot/src/share/vm/utilities/workgroup.hpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/src/share/vm/utilities/workgroup.hpp	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,9 @@
 #ifdef TARGET_OS_FAMILY_windows
 # include "thread_windows.inline.hpp"
 #endif
+#ifdef TARGET_OS_FAMILY_bsd
+# include "thread_bsd.inline.hpp"
+#endif
 
 // Task class hierarchy:
 //   AbstractGangTask
--- a/hotspot/test/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/test/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -44,6 +44,22 @@
     ARCH = i586
   endif
 endif
+ifeq ($(OSNAME), Darwin)
+  PLATFORM = bsd
+  SLASH_JAVA = /java
+  ARCH = $(shell uname -m)
+  ifeq ($(ARCH), i386)
+    ARCH = i586
+  endif
+endif
+ifeq ($(findstring BSD,$(OSNAME)), BSD)
+  PLATFORM = bsd
+  SLASH_JAVA = /java
+  ARCH = $(shell uname -m)
+  ifeq ($(ARCH), i386)
+    ARCH = i586
+  endif
+endif
 ifeq ($(OSNAME), Windows_NT)
   PLATFORM = windows
   SLASH_JAVA = J:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6865265/StackOverflowBug.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6865265
+ * @summary JVM crashes with "missing exception handler" error
+ * @author volker.simonis@sap.com
+ *
+ * @run main/othervm -XX:CompileThreshold=100 -Xbatch -Xss128k StackOverflowBug
+ */
+
+
+public class StackOverflowBug {
+
+  public static int run() {
+    try {
+      try {
+        return run();
+      } catch (Throwable e) {
+        // Notice that the class 'Throwable' is NOT resolved by the verifier,
+        // because the verifier only checks if 'Throwable' is assignable to
+        // 'java.lang.Throwable' and this check succeeds immediately if the two
+        // types have equal names (see 'VerificationType::is_assignable_from' which
+        // is called from 'ClassVerifier::verify_exception_handler_table').
+        // This is strange, because if the two classes have different names,
+        // 'is_assignable_from()' calls 'is_reference_assignable_from()' which resolves
+        // both classes by calling 'SystemDictionary::resolve_or_fail()'. This call
+        // also takes into account the current class loader (i.e. the one which was used
+        // to load this class) and would place a corresponding
+        // "java.lang.Throwable / current-Classloader" entry into the system dictionary.
+        // This would in turn allow C2 to see 'java.lang.Throwable' as "loaded"
+        // (see 'Parse::catch_inline_exceptions()') when this method is compiled.
+        return 42;
+      }
+    }
+    finally {
+    }
+  }
+
+  public static void main(String argv[]) {
+    run();
+  }
+}
+
+/*
+  public static int run();
+    Code:
+       0: invokestatic  #2                  // Method run:()I
+       3: istore_0
+       4: iload_0
+       5: ireturn
+       6: astore_0
+       7: bipush        42
+       9: istore_1
+      10: iload_1
+      11: ireturn
+      12: astore_2
+      13: aload_2
+      14: athrow
+    Exception table:
+       from    to  target type
+           0     4     6   Class java/lang/Throwable
+           0     4    12   any
+           6    10    12   any
+          12    13    12   any
+
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7068051/Test7068051.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 7068051
+ * @summary SIGSEGV in PhaseIdealLoop::build_loop_late_post on T5440
+ *
+ * @run shell/timeout=300 Test7068051.sh
+ */
+
+import java.io.*;
+import java.nio.*;
+import java.util.*;
+import java.util.zip.*;
+
+public class Test7068051 {
+
+    public static void main (String[] args) throws Throwable {
+
+        ZipFile zf = new ZipFile(args[0]);
+
+        Enumeration<? extends ZipEntry> entries = zf.entries();
+        ArrayList<String> names = new ArrayList<String>();
+        while (entries.hasMoreElements()) {
+            names.add(entries.nextElement().getName());
+        }
+
+        byte[] bytes = new byte[16];
+        for (String name : names) {
+            ZipEntry e = zf.getEntry(name);
+
+            if (e.isDirectory())
+                continue;
+
+            final InputStream is = zf.getInputStream(e);
+
+            try  {
+                while (is.read(bytes) >= 0) {
+                }
+                is.close();
+
+            } catch (IOException x) {
+                 System.out.println("..................................");
+                 System.out.println("          -->  is :" + is);
+                 System.out.println("          is.hash :" + is.hashCode());
+                 System.out.println();
+                 System.out.println("           e.name :" + e.getName());
+                 System.out.println("           e.hash :" + e.hashCode());
+                 System.out.println("         e.method :" + e.getMethod());
+                 System.out.println("           e.size :" + e.getSize());
+                 System.out.println("          e.csize :" + e.getCompressedSize());
+
+                 x.printStackTrace();
+                 System.out.println("..................................");
+                 System.exit(97);
+            }
+        }
+        zf.close();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7068051/Test7068051.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,49 @@
+#!/bin/sh
+# 
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+# 
+# 
+
+if [ "${TESTSRC}" = "" ]
+then
+  echo "TESTSRC not set.  Test cannot execute.  Failed."
+  exit 1
+fi
+echo "TESTSRC=${TESTSRC}"
+if [ "${TESTJAVA}" = "" ]
+then
+  echo "TESTJAVA not set.  Test cannot execute.  Failed."
+  exit 1
+fi
+echo "TESTJAVA=${TESTJAVA}"
+
+set -x
+
+${TESTJAVA}/bin/jar xf ${TESTJAVA}/jre/lib/javaws.jar
+${TESTJAVA}/bin/jar cf foo.jar *
+cp ${TESTSRC}/Test7068051.java ./
+${TESTJAVA}/bin/jar -uf0 foo.jar Test7068051.java
+
+${TESTJAVA}/bin/javac -d . Test7068051.java
+
+${TESTJAVA}/bin/java -showversion -Xbatch ${TESTVMOPTS} Test7068051 foo.jar
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7082949/Test7082949.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 7082949
+ * @summary JSR 292: missing ResourceMark in methodOopDesc::make_invoke_method
+ *
+ * @run main Test7082949
+ */
+
+import java.lang.invoke.*;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+
+public class Test7082949 implements Runnable {
+    public static void main(String... args) throws Throwable {
+        new Thread(new Test7082949()).start();
+    }
+
+    public static Test7082949 test() {
+        return null;
+    }
+
+    public void run() {
+        try {
+            MethodHandle m1 = MethodHandles.lookup().findStatic(Test7082949.class, "test",  methodType(Test7082949.class));
+            Test7082949 v = (Test7082949)m1.invokeExact();
+        } catch (Throwable t) {
+            t.printStackTrace();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7088020/Test7088020.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 7088020
+ * @summary SEGV in JNIHandleBlock::release_block
+ *
+ * @run main Test7088020
+ */
+
+import java.lang.invoke.*;
+
+
+public class Test7088020 {
+    public static boolean test() {
+        return false;
+    }
+
+    public static void main(String... args) throws Throwable {
+        MethodHandle test = MethodHandles.lookup().findStatic(Test7088020.class, "test",  MethodType.methodType(Boolean.TYPE));
+
+        // Exercise WMT with different argument alignments
+        int thrown = 0;
+        try {
+            test.invokeExact(0);
+        } catch (WrongMethodTypeException wmt) {
+            thrown++;
+            if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
+        }
+        try {
+            test.invokeExact(0, 1);
+        } catch (WrongMethodTypeException wmt) {
+            thrown++;
+            if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
+        }
+        try {
+            test.invokeExact(0, 1, 2);
+        } catch (WrongMethodTypeException wmt) {
+            thrown++;
+            if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
+        }
+        try {
+            test.invokeExact(0, 1, 2, 3);
+        } catch (WrongMethodTypeException wmt) {
+            thrown++;
+            if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
+        }
+        try {
+            thrown++;
+            test.invokeExact(0, 1, 2, 3, 4);
+        } catch (WrongMethodTypeException wmt) {
+            if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
+        }
+        if (thrown != 5) {
+            throw new InternalError("not enough throws");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7100757/Test7100757.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 7100757
+ * @summary The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
+ *
+ * @run main/timeout=300 Test7100757
+ */
+
+import java.util.*;
+
+public class Test7100757 {
+
+  public static final int NBITS = 256;
+
+  public static void main(String[] args) {
+
+    BitSet bs = new BitSet(NBITS);
+    Random rnd = new Random();
+    long[] ra = new long[(NBITS+63)/64];
+
+    for(int l=0; l < 5000000; l++) {
+
+      for(int r = 0; r < ra.length; r++) {
+        ra[r] = rnd.nextLong();
+      }
+      test(ra, bs);
+    }
+  }
+
+  static void test(long[] ra, BitSet bs) {
+      bs.clear();
+      int bits_set = 0;
+      for(int i = 0, t = 0, b = 0; i < NBITS; i++) {
+        long bit = 1L << b++;
+        if((ra[t]&bit) != 0) {
+          bs.set(i);
+          bits_set++;
+        }
+        if(b == 64) {
+          t++;
+          b = 0;
+        }
+      }
+      // Test Long.bitCount()
+      int check_bits = bs.cardinality();
+      if (check_bits != bits_set) {
+        String bs_str = bs.toString();
+        System.err.printf("cardinality bits: %d != %d  bs: %s\n", check_bits, bits_set, bs_str);
+        System.exit(97);
+      }
+      // Test Long.numberOfTrailingZeros()
+      check_bits = 0;
+      for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
+        check_bits++;
+      }
+      if (check_bits != bits_set) {
+        String bs_str = bs.toString();
+        System.err.printf("nextSetBit bits: %d != %d  bs: %s\n", check_bits, bits_set, bs_str);
+        System.exit(97);
+      }
+      // Test Long.numberOfLeadingZeros()
+      for(int i = bs.length(); i > 0; i = bs.length()) {
+        bs.clear(i-1);
+      }
+      // Test Long.bitCount()
+      check_bits = bs.cardinality();
+      if (check_bits != 0) {
+        String bs_str = bs.toString();
+        System.err.printf("after clear bits: %d != 0  bs: %s\n", check_bits, bs_str);
+        System.exit(97);
+      }
+  }
+
+};
--- a/hotspot/test/jprt.config	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/test/jprt.config	Wed Oct 26 17:59:13 2011 -0700
@@ -75,8 +75,8 @@
 
 # Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
 osname=`uname -s`
-if [ "${osname}" = SunOS ] ; then
-   
+case "${osname}" in
+  SunOS )
     # SOLARIS: Sparc or X86
     osarch=`uname -p`
     if [ "${osarch}" = sparc ] ; then
@@ -100,9 +100,9 @@
 
     # File creation mask
     umask 002
+    ;;
 
-elif [ "${osname}" = Linux ] ; then
-   
+  Linux | Darwin )
     # Add basic paths
     path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
 
@@ -111,9 +111,31 @@
     fileMustExist "${make}" make
 
     umask 002
+    ;;
 
-else
+  FreeBSD | OpenBSD )
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
+
+    # Find GNU make
+    make=/usr/local/bin/gmake
+    fileMustExist "${make}" make
+
+    umask 002
+    ;;
 
+  NetBSD )
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
+
+    # Find GNU make
+    make=/usr/pkg/bin/gmake
+    fileMustExist "${make}" make
+
+    umask 002
+    ;;
+
+  * )
     # Windows: Differs on CYGWIN vs. MKS.
    
     # We need to determine if we are running a CYGWIN shell or an MKS shell
@@ -154,8 +176,8 @@
     if [ "${unix_toolset}" = CYGWIN ] ; then
 	path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
     fi
-
-fi
+    ;;
+esac
 
 # Export PATH setting
 PATH="${path4sdk}"
--- a/hotspot/test/runtime/6929067/Test6929067.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/hotspot/test/runtime/6929067/Test6929067.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -29,7 +29,7 @@
     PS=":"
     FS="/"
     ;;
-  SunOS | Windows_* )
+  SunOS | Windows_* | *BSD)
     NULL=NUL
     PS=";"
     FS="\\"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/7051189/Xchecksig.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,151 @@
+# 
+#  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+#  This code is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License version 2 only, as
+#  published by the Free Software Foundation.
+# 
+#  This code is distributed in the hope that it will be useful, but WITHOUT
+#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#  version 2 for more details (a copy is included in the LICENSE file that
+#  accompanied this code).
+# 
+#  You should have received a copy of the GNU General Public License version
+#  2 along with this work; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+#  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+#  or visit www.oracle.com if you need additional information or have any
+#  questions.
+# 
+
+ 
+# @test Xchecksig.sh
+# @bug 7051189
+# @summary Need to suppress info message if -xcheck:jni used with libjsig.so
+# @run shell Xchecksig.sh
+#
+
+if [ "${TESTSRC}" = "" ]
+  then TESTSRC=.
+fi
+
+if [ "${TESTJAVA}" = "" ]
+then
+  PARENT=`dirname \`which java\``
+  TESTJAVA=`dirname ${PARENT}`
+  printf "TESTJAVA not set, selecting " ${TESTJAVA}
+  printf "  If this is incorrect, try setting the variable manually.\n"
+fi
+
+
+BIT_FLAG=""
+
+OS=`uname -s`
+case "$OS" in
+  SunOS | Linux )
+    FS="/"
+    ## for solaris, linux it's HOME
+    FILE_LOCATION=$HOME
+    if [ -f ${FILE_LOCATION}${FS}JDK64BIT -a ${OS} = "SunOS" ]
+    then
+        BIT_FLAG=`cat ${FILE_LOCATION}${FS}JDK64BIT`
+    fi
+    ;;
+  Windows_* )
+    printf "Not testing libjsig.so on Windows. PASSED.\n "
+    exit 0
+    ;;
+  * )
+    printf "Not testing libjsig.so on unrecognised system. PASSED.\n "
+    exit 0
+    ;;
+esac
+
+
+JAVA=${TESTJAVA}${FS}bin${FS}java
+
+# LD_PRELOAD arch needs to match the binary we run, so run the java
+# 64-bit binary directly if we are testing 64-bit (bin/ARCH/java).
+
+# However JPRT runs: .../solaris_x64_5.10-debug/bin/java
+# ..which is 32-bit, when it has built the 64-bit version to test.
+#
+# How does this script know we are meant to run the 64-bit version?
+# Can check for the path of the binary containing "x64" on Solaris.
+
+if [ ${OS} -eq "SunOS" ]
+then
+  printf  "SunOS test JAVA=${JAVA}"
+  printf ${JAVA} | grep x64 > /dev/null
+  if [ $? -eq 0 ]
+  then
+    printf "SunOS x64 test, forcing -d64\n"
+    BIT_FLAG=-d64
+  fi
+fi
+
+ARCH=`uname -p`
+case $ARCH in
+  i386)
+    if [ X${BIT_FLAG} != "X" ]
+    then
+      ARCH=amd64
+      JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java
+    fi
+    ;;
+  sparc)
+    if [ X${BIT_FLAG} != "X" ]
+    then
+      ARCH=sparcv9
+      JAVA=${TESTJAVA}${FS}bin${FS}${ARCH}${FS}java
+    fi
+    ;;
+  * )
+    printf "Not testing architecture $ARCH, skipping test.\n"
+    exit 0
+  ;; 
+esac
+
+LIBJSIG=${TESTJAVA}${FS}jre${FS}lib${FS}${ARCH}${FS}libjsig.so
+
+# If libjsig and binary do not match, skip test.
+
+A=`file ${LIBJSIG} | awk '{ print $3 }'`
+B=`file ${JAVA}    | awk '{ print $3 }'`
+
+if [ $A -ne $B ]
+then
+  printf "Mismatching binary and library to preload, skipping test.\n"
+  exit 0
+fi
+
+if [ ! -f ${LIBJSIG} ]
+then
+  printf "Skipping test: libjsig missing for given architecture: ${LIBJSIG}\n"
+  exit 0
+fi
+# Use java -version to test, java version info appeas on stderr,
+# the libjsig message we are removing appears on stdout.
+
+# grep returns zero meaning found, non-zero means not found:
+
+LD_PRELOAD=${LIBJSIG} ${JAVA} ${BIT_FLAG} -Xcheck:jni -version 2>&1  | grep "libjsig is activated"
+
+if [ $? -eq 0 ]; then
+  printf "Failed: -Xcheck:jni prints message when libjsig.so is loaded.\n"
+  exit 1
+fi
+
+
+LD_PRELOAD=${LIBJSIG} ${JAVA} ${BIT_FLAG} -Xcheck:jni -verbose:jni -version 2>&1 | grep "libjsig is activated"
+if [ $? != 0 ]; then
+  printf "Failed: -Xcheck:jni does not print message when libjsig.so is loaded and -verbose:jni is set.\n"
+  exit 1
+fi
+
+printf "PASSED\n"
+exit 0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/7100935/TestConjointAtomicArraycopy.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2011 SAP AG.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestConjointAtomicArraycopy
+ * @bug 7100935
+ * @summary verify that oops are copied element-wise atomic
+ * @run main/othervm -Xint TestConjointAtomicArraycopy
+ * @run main/othervm -Xcomp -Xbatch TestConjointAtomicArraycopy
+ * @author axel.siebenborn@sap.com
+ */
+
+public class TestConjointAtomicArraycopy {
+
+  static volatile Object [] testArray = new Object [4];
+
+  static short[] a1 = new short[8];
+  static short[] a2 = new short[8];
+  static short[] a3 = new short[8];
+
+  static volatile boolean keepRunning = true;
+
+  static void testOopsCopy() throws InterruptedException{
+
+  }
+
+  public static void main(String[] args ) throws InterruptedException{
+    for (int i = 0; i < testArray.length; i++){
+      testArray[i] = new String("A");
+    }
+
+    Thread writer = new Thread (new Runnable(){
+      public void run(){
+        for (int i = 0 ; i < 1000000; i++) {
+          System.arraycopy(testArray, 1, testArray, 0, 3);
+          testArray[2] = new String("a");
+        }
+      }
+    });
+
+    Thread reader = new Thread( new Runnable(){
+      public void run(){
+        while (keepRunning){
+          String name = testArray[2].getClass().getName();
+          if(!(name.endsWith("String"))){
+            throw new RuntimeException("got wrong class name");
+          }
+        }
+      }
+    });
+    keepRunning = true;
+    reader.start();
+    writer.start();
+    writer.join();
+    keepRunning = false;
+    reader.join();
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/7100935/TestShortArraycopy.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2011 SAP AG.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestShortArraycopy
+ * @bug 7100935
+ * @summary  verify that shorts are copied element-wise atomic.
+ * @run main/othervm -Xint TestShortArraycopy
+ * @run main/othervm -Xcomp -Xbatch TestShortArraycopy
+ * @author volker.simonis@gmail.com
+ */
+
+public class TestShortArraycopy {
+
+  static short[] a1 = new short[8];
+  static short[] a2 = new short[8];
+  static short[] a3 = new short[8];
+
+  static volatile boolean keepRunning = true;
+
+  public static void main(String[] args) throws InterruptedException {
+
+    for (int i = 0; i < a1.length ; i++) {
+      a1[i] = (short)0xffff;
+      a2[i] = (short)0xffff;
+      a3[i] = (short)0x0000;
+    }
+    Thread reader = new Thread() {
+      public void run() {
+        while (keepRunning) {
+          for (int j = 0; j < a1.length; j++) {
+            short s = a1[j];
+            if (s != (short)0xffff && s != (short)0x0000) {
+              System.out.println("Error: s = " + s);
+              throw new RuntimeException("wrong result");
+
+            }
+          }
+        }
+      }
+    };
+    Thread writer = new Thread() {
+      public void run() {
+        for (int i = 0; i < 1000000; i++) {
+          System.arraycopy(a2, 5, a1, 3, 3);
+          System.arraycopy(a3, 5, a1, 3, 3);
+        }
+      }
+    };
+    keepRunning = true;
+    reader.start();
+    writer.start();
+    writer.join();
+    keepRunning = false;
+    reader.join();
+  }
+}
--- a/jaxp/.hgtags	Mon Oct 24 09:58:47 2011 -0700
+++ b/jaxp/.hgtags	Wed Oct 26 17:59:13 2011 -0700
@@ -127,3 +127,8 @@
 7a74371ce0c64108b857c497ae130dfe9514532c jdk8-b03
 acbcadef0b21582abf406f07f1b74d2b8f80dc01 jdk8-b04
 ff0a3d78e7a22743eabbaa71e9d17b2f094ddf62 jdk8-b05
+d7b8192e7277c49b9c702f4c4fd99bd83ba947ea jdk8-b06
+c114306576dcc1cb871a48058b41bf7d87ce882a jdk8-b07
+de4794dd69c48b08029d158a972993ff9d5627df jdk8-b08
+93554324c014282571aeeb48552ad00d3fedb089 jdk8-b09
+d21a4d5141c04bc9e88f2c0253121d449b66d667 jdk8-b10
--- a/jaxws/.hgtags	Mon Oct 24 09:58:47 2011 -0700
+++ b/jaxws/.hgtags	Wed Oct 26 17:59:13 2011 -0700
@@ -127,3 +127,8 @@
 7dcb0307508f408507d878cd7c2048c102b15158 jdk8-b03
 3f6f08163331ed75b30a6de1246670ce655645c8 jdk8-b04
 7d5d91fddbceb1fc3ae7ff409e732ae4a0391b34 jdk8-b05
+acffff22a9465005e8eb206224fae9f2ea4fd469 jdk8-b06
+134b0debf7b04fe6e317394b04b8e7a4a0181b1b jdk8-b07
+1c9d4f59acf8f71477473c170239b43b2c9dee24 jdk8-b08
+70172e57cf29efe271b068987eefb601c2a77780 jdk8-b09
+8e7fdc8e3c758644ca6d0fd70bb255e9d2e64cda jdk8-b10
--- a/jdk/.hgtags	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/.hgtags	Wed Oct 26 17:59:13 2011 -0700
@@ -127,3 +127,8 @@
 7989ee9fe673a87f4db3917fa6a005732a6a9b85 jdk8-b03
 fc569517f3cf242f90ce3503b743eb5553938946 jdk8-b04
 0b32369b83d81c226a2e79e730f3a8c0d2595e92 jdk8-b05
+bdb870cc269ef8b221d17a217be89092400b59d2 jdk8-b06
+19f0a3db863cc491affc78b48c4a81a6679b2433 jdk8-b07
+1c023bcd0c5a01ac07bc7eea728aafbb0d8991e9 jdk8-b08
+f1ec21b8142168ff40f3278d2f6b5fe4bd5f3b26 jdk8-b09
+4788745572ef2bde34924ef34e7e4d55ba07e979 jdk8-b10
--- a/jdk/make/com/sun/net/httpserver/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/com/sun/net/httpserver/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 BUILDDIR = ../../../..
 PACKAGE = com.sun.net.httpserver
 PRODUCT = sun
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/jdk/make/com/sun/net/ssl/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/com/sun/net/ssl/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -26,6 +26,9 @@
 BUILDDIR = ../../../..
 PACKAGE = com.sun.net.ssl
 PRODUCT = sun
+JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/jdk/make/com/sun/org/apache/xml/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/com/sun/org/apache/xml/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -30,6 +30,8 @@
 BUILDDIR = ../../../../..
 PACKAGE = com.sun.org.apache.xml
 PRODUCT = xml
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/jdk/make/common/Defs-linux.gmk	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/common/Defs-linux.gmk	Wed Oct 26 17:59:13 2011 -0700
@@ -74,6 +74,57 @@
 CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
 CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
 
+# Default OBJCOPY comes from GNU Binutils on Linux:
+DEF_OBJCOPY=/usr/bin/objcopy
+ifdef CROSS_COMPILE_ARCH
+  # don't try to generate .debuginfo files when cross compiling
+  _JUNK_ := $(shell \
+    echo >&2 "INFO: cross compiling for ARCH $(CROSS_COMPILE_ARCH)," \
+      "skipping .debuginfo generation.")
+  OBJCOPY=
+else
+  OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
+  ifneq ($(ALT_OBJCOPY),)
+    _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
+    # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
+    OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
+  endif
+endif
+
+ifdef LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+# The setting of OBJCOPY above enables the JDK build to import
+# .debuginfo files from the HotSpot build. However, adding FDS
+# support to the JDK build will occur in phases so a different
+# make variable is used to indicate that a particular library
+# supports FDS.
+
+ifeq ($(OBJCOPY),)
+  _JUNK_ := $(shell \
+    echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
+else
+  _JUNK_ := $(shell \
+    echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")
+
+  # Library stripping policies for .debuginfo configs:
+  #   all_strip - strips everything from the library
+  #   min_strip - strips most stuff from the library; leaves minimum symbols
+  #   no_strip  - does not strip the library at all
+  #
+  # Oracle security policy requires "all_strip". A waiver was granted on
+  # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
+  #
+  DEF_STRIP_POLICY="min_strip"
+  ifeq ($(ALT_STRIP_POLICY),)
+    STRIP_POLICY=$(DEF_STRIP_POLICY)
+  else
+    STRIP_POLICY=$(ALT_STRIP_POLICY)
+  endif
+
+  _JUNK_ := $(shell \
+    echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
+endif
+endif
+
 #
 # Default optimization
 #
@@ -322,6 +373,7 @@
 override LIBPOSIX4               =
 override LIBSOCKET               =
 override LIBNSL                  =
+override LIBSCF                  =
 override LIBTHREAD               =
 override MOOT_PRIORITIES         = true
 override NO_INTERRUPTIBLE_IO     = true
@@ -359,6 +411,7 @@
 # Settings for the JDI - Serviceability Agent binding.
 HOTSPOT_SALIB_PATH   = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
 SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
+SA_DEBUGINFO_NAME = $(LIB_PREFIX)saproc.debuginfo
 
 # The JDI - Serviceability Agent binding is not currently supported
 # on Linux-ia64.
--- a/jdk/make/common/Defs-solaris.gmk	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/common/Defs-solaris.gmk	Wed Oct 26 17:59:13 2011 -0700
@@ -74,6 +74,69 @@
 CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
 CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
 
+ifdef ENABLE_FULL_DEBUG_SYMBOLS
+# Only check for Full Debug Symbols support on Solaris if it is
+# specifically enabled. Hopefully, it can be enabled by default
+# once the .debuginfo size issues are worked out.
+
+# Default OBJCOPY comes from the SUNWbinutils package:
+DEF_OBJCOPY=/usr/sfw/bin/gobjcopy
+ifeq ($(PLATFORM)-$(LIBARCH), solaris-amd64)
+  # On Solaris AMD64/X64, gobjcopy is not happy and fails:
+  #
+  # usr/sfw/bin/gobjcopy --add-gnu-debuglink=<lib>.debuginfo <lib>.so
+  # BFD: stKPaiop: Not enough room for program headers, try linking with -N
+  # /usr/sfw/bin/gobjcopy: stKPaiop: Bad value
+  # BFD: stKPaiop: Not enough room for program headers, try linking with -N
+  # /usr/sfw/bin/gobjcopy: libsaproc.debuginfo: Bad value
+  # BFD: stKPaiop: Not enough room for program headers, try linking with -N
+  # /usr/sfw/bin/gobjcopy: stKPaiop: Bad value
+  _JUNK_ := $(shell \
+    echo >&2 "INFO: $(DEF_OBJCOPY) is not working on Solaris AMD64/X64")
+  OBJCOPY=
+else
+  OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
+  ifneq ($(ALT_OBJCOPY),)
+    _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
+    # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
+    OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
+  endif
+endif
+
+ifdef LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+# The setting of OBJCOPY above enables the JDK build to import
+# .debuginfo files from the HotSpot build. However, adding FDS
+# support to the JDK build will occur in phases so a different
+# make variable is used to indicate that a particular library
+# supports FDS.
+
+ifeq ($(OBJCOPY),)
+  _JUNK_ := $(shell \
+    echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
+else
+  _JUNK_ := $(shell \
+    echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")
+
+  # Library stripping policies for .debuginfo configs:
+  #   all_strip - strips everything from the library
+  #   min_strip - strips most stuff from the library; leaves minimum symbols
+  #   no_strip  - does not strip the library at all
+  #
+  # Oracle security policy requires "all_strip". A waiver was granted on
+  # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
+  #
+  DEF_STRIP_POLICY="min_strip"
+  ifeq ($(ALT_STRIP_POLICY),)
+    STRIP_POLICY=$(DEF_STRIP_POLICY)
+  else
+    STRIP_POLICY=$(ALT_STRIP_POLICY)
+  endif
+  _JUNK_ := $(shell \
+    echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
+endif
+endif
+endif
+
 #
 # Java default optimization (-x04/-O2) etc.  Applies to the VM.
 #
@@ -648,6 +711,9 @@
 # Network Services library
 LIBNSL = -lnsl
 
+# service configuration facility library
+LIBSCF = -lscf
+
 # GLOBAL_KPIC: If set means all libraries are PIC, position independent code
 #    EXCEPT for select compiles
 #    If a .o file is compiled non-PIC then it should be forced
@@ -684,5 +750,6 @@
 # Settings for the JDI - Serviceability Agent binding.
 HOTSPOT_SALIB_PATH   = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
 SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
+SA_DEBUGINFO_NAME = $(LIB_PREFIX)saproc.debuginfo
 INCLUDE_SA=true
 
--- a/jdk/make/java/java/FILES_java.gmk	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/java/java/FILES_java.gmk	Wed Oct 26 17:59:13 2011 -0700
@@ -208,7 +208,6 @@
     java/util/Observable.java \
     java/util/Observer.java \
     java/util/Properties.java \
-        java/util/XMLUtils.java \
         java/util/InvalidPropertiesFormatException.java \
     java/util/PropertyPermission.java \
     java/util/PropertyResourceBundle.java \
--- a/jdk/make/java/java/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/java/java/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -208,7 +208,7 @@
 		       -libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib \
 		       shell32.lib delayimp.lib /DELAYLOAD:shell32.dll
 else
-OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \
+OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) $(LIBSCF) -ldl \
 		-L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH)
 endif
 
--- a/jdk/make/java/net/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/java/net/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -27,6 +27,9 @@
 PACKAGE = java.net
 LIBRARY = net
 PRODUCT = sun
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
+JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/jdk/make/java/nio/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/java/nio/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -206,7 +206,6 @@
 	sun/nio/fs/LinuxUserDefinedFileAttributeView.java \
 	sun/nio/fs/LinuxNativeDispatcher.java \
 	sun/nio/fs/LinuxWatchService.java \
-	sun/nio/fs/PollingWatchService.java \
 	sun/nio/fs/UnixChannelFactory.java \
 	sun/nio/fs/UnixCopyFile.java \
 	sun/nio/fs/UnixDirectoryStream.java \
--- a/jdk/make/java/redist/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/java/redist/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -58,6 +58,11 @@
 JVMDB_NAME             = $(LIB_PREFIX)jvm$(DB_SUFFIX).$(LIBRARY_SUFFIX)
 JVMDTRACE_NAME         = $(LIB_PREFIX)jvm$(DTRACE_SUFFIX).$(LIBRARY_SUFFIX)
 
+JVM_DEBUGINFO_NAME       = $(LIB_PREFIX)jvm.debuginfo
+LIBJSIG_DEBUGINFO_NAME   = $(LIB_PREFIX)jsig.debuginfo
+JVMDB_DEBUGINFO_NAME     = $(LIB_PREFIX)jvm$(DB_SUFFIX).debuginfo
+JVMDTRACE_DEBUGINFO_NAME = $(LIB_PREFIX)jvm$(DTRACE_SUFFIX).debuginfo
+
 CLASSSHARINGDATA_DIR   = $(BUILDDIR)/tools/sharing
 
 # Needed to do file copy
@@ -79,6 +84,12 @@
 ifndef BUILD_CLIENT_ONLY
   IMPORT_LIST = $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME) \
                 $(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt
+  ifneq ($(OBJCOPY),)
+    # the import JDK may not contain .debuginfo files
+    ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/$(JVM_DEBUGINFO_NAME)),)
+      IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_DEBUGINFO_NAME)
+    endif
+  endif
 else
   IMPORT_LIST =
 endif
@@ -88,6 +99,12 @@
 ifeq ($(ARCH_DATA_MODEL), 32)
   IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVM_NAME) \
                  $(LIB_LOCATION)/$(CLIENT_LOCATION)/Xusage.txt
+  ifneq ($(OBJCOPY),)
+    # the import JDK may not contain .debuginfo files
+    ifneq ($(wildcard $(HOTSPOT_CLIENT_PATH)/$(JVM_DEBUGINFO_NAME)),)
+      IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVM_DEBUGINFO_NAME)
+    endif
+  endif
 endif
 endif
 
@@ -157,16 +174,40 @@
 #  NOT Windows vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv  NOT Windows
 
 IMPORT_LIST += $(LIB_LOCATION)/$(LIBJSIG_NAME) 
+ifneq ($(OBJCOPY),)
+  # the import JDK may not contain .debuginfo files
+  ifneq ($(wildcard $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_DEBUGINFO_NAME)),)
+    IMPORT_LIST += $(LIB_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME)
+  endif
+endif
 ifndef BUILD_CLIENT_ONLY
   IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME)
+  ifneq ($(OBJCOPY),)
+    # the import JDK may not contain the target of the symlink
+    ifneq ($(wildcard $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_DEBUGINFO_NAME)),)
+      IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME)
+    endif
+  endif
 endif
 
 ifeq ($(PLATFORM), solaris)
   ifndef BUILD_CLIENT_ONLY
     IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME)
+    ifneq ($(OBJCOPY),)
+      # the import JDK may not contain .debuginfo files
+      ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/$(JVMDB_DEBUGINFO_NAME)),)
+        IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_DEBUGINFO_NAME)
+      endif
+    endif
     # The conditional can be removed when import JDKs contain these files.
     ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)),)
       IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME)
+      ifneq ($(OBJCOPY),)
+        # the import JDK may not contain .debuginfo files
+        ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_DEBUGINFO_NAME)),)
+          IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_DEBUGINFO_NAME)
+        endif
+      endif
     else
       $(warning WARNING: $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME) not found!)
     endif 
@@ -177,17 +218,37 @@
 ifeq ($(ARCH_DATA_MODEL), 32)
 
 IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME)
+ifneq ($(OBJCOPY),)
+  # the import JDK may not contain the target of the symlink
+  ifneq ($(wildcard $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_DEBUGINFO_NAME)),)
+    IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME)
+  endif
+endif
 
 ifeq ($(PLATFORM), solaris)
 #  solaris   vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv  solaris
 
 IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME)
+ifneq ($(OBJCOPY),)
+  # the import JDK may not contain .debuginfo files
+  ifneq ($(wildcard $(HOTSPOT_CLIENT_PATH)/$(JVMDB_DEBUGINFO_NAME)),)
+    IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_DEBUGINFO_NAME)
+  endif
+endif
 
 # The conditional can be removed when import JDKs contain these files.
 ifneq ($(wildcard $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)),)
   IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME)
   IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_NAME)
   IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_NAME)
+  ifneq ($(OBJCOPY),)
+    # the import JDK may not contain .debuginfo files
+    ifneq ($(wildcard $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_DEBUGINFO_NAME)),)
+      IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_DEBUGINFO_NAME)
+      IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_DEBUGINFO_NAME)
+      IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_DEBUGINFO_NAME)
+  endif
+  endif
 else
   $(warning WARNING: $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME) not found!)
 endif
@@ -196,6 +257,12 @@
   # The conditional can be removed when import JDKs contain these files.
   ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)),)
     IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME)
+    ifneq ($(OBJCOPY),)
+      # the import JDK may not contain .debuginfo files
+      ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_DEBUGINFO_NAME)),)
+        IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_DEBUGINFO_NAME)
+      endif
+    endif
   else
     $(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME) not found!)
   endif
@@ -203,6 +270,12 @@
   # The conditional can be removed when import JDKs contain these files.
   ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)),)
     IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME)
+    ifneq ($(OBJCOPY),)
+      # the import JDK may not contain .debuginfo files
+      ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_DEBUGINFO_NAME)),)
+        IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_DEBUGINFO_NAME)
+      endif
+    endif
   else
     $(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME) not found!)
  endif
@@ -229,6 +302,11 @@
 	$(install-import-file)
 	@$(call binary_file_verification,$@)
 
+ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVM_DEBUGINFO_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVM_DEBUGINFO_NAME)
+	$(install-import-file)
+endif
+
 $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVM_NAME): $(HOTSPOT_KERNEL_PATH)/$(JVM_NAME)
 	$(install-file)
 	@$(call binary_file_verification,$@)
@@ -237,15 +315,33 @@
 	$(install-import-file)
 	@$(call binary_file_verification,$@)
 
+ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME): $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_DEBUGINFO_NAME)
+	$(install-import-file)
+endif
+
 ifndef BUILD_CLIENT_ONLY
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME) \
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME):
 	@$(prep-target)
 	$(call install-sym-link, ../$(LIBJSIG_NAME))
+
+ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME) \
+$(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME):
+	@$(prep-target)
+	$(call install-sym-link, ../$(LIBJSIG_DEBUGINFO_NAME))
+endif
 else
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME):
 	@$(prep-target)
 	$(call install-sym-link, ../$(LIBJSIG_NAME))
+
+ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_DEBUGINFO_NAME):
+	@$(prep-target)
+	$(call install-sym-link, ../$(LIBJSIG_DEBUGINFO_NAME))
+endif
 endif
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDB_NAME)
@@ -256,6 +352,14 @@
 	$(install-import-file)
 	@$(call binary_file_verification,$@)
 
+ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_DEBUGINFO_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDB_DEBUGINFO_NAME)
+	$(install-import-file)
+
+$(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_DEBUGINFO_NAME): $(HOTSPOT_CLIENT_PATH)/64/$(JVMDB_DEBUGINFO_NAME)
+	$(install-import-file)
+endif
+
 ifndef BUILD_CLIENT_ONLY
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME)
 	$(install-import-file)
@@ -264,6 +368,14 @@
 $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)
 	$(install-import-file)
 	@$(call binary_file_verification,$@)
+
+ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_DEBUGINFO_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB_DEBUGINFO_NAME)
+	$(install-import-file)
+
+$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_DEBUGINFO_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_DEBUGINFO_NAME)
+	$(install-import-file)
+endif
 endif
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)
@@ -274,6 +386,14 @@
 	$(install-import-file)
 	@$(call binary_file_verification,$@)
 
+ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_DEBUGINFO_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_DEBUGINFO_NAME)
+	$(install-import-file)
+
+$(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_DEBUGINFO_NAME): $(HOTSPOT_CLIENT_PATH)/64/$(JVMDTRACE_DEBUGINFO_NAME)
+	$(install-import-file)
+endif
+
 ifndef BUILD_CLIENT_ONLY
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)
 	$(install-import-file)
@@ -287,6 +407,17 @@
 	$(install-import-file)
 	@$(call binary_file_verification,$@)
 
+ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_DEBUGINFO_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_DEBUGINFO_NAME)
+	$(install-import-file)
+
+$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_DEBUGINFO_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_DEBUGINFO_NAME)
+	$(install-import-file)
+
+$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_DEBUGINFO_NAME): $(HOTSPOT_SERVER_PATH)/$(JVM_DEBUGINFO_NAME)
+	$(install-import-file)
+endif
+
 $(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt : $(HOTSPOT_SERVER_PATH)/Xusage.txt
 	$(install-import-file)
 endif
--- a/jdk/make/java/redist/sajdi/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/java/redist/sajdi/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -56,6 +56,12 @@
     IMPORT_LIST += $(LIB_LOCATION)/$(SAMAP_NAME) \
                    $(LIB_LOCATION)/$(SAPDB_NAME)
   endif
+  ifneq ($(OBJCOPY),)
+    # the import JDK may not contain .debuginfo files
+    ifneq ($(wildcard $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(SA_DEBUGINFO_NAME)),)
+      IMPORT_LIST += $(LIB_LOCATION)/$(SA_DEBUGINFO_NAME)
+    endif
+  endif
 endif # INCLUDE_SA
 
 
@@ -79,6 +85,11 @@
 $(LIB_LOCATION)/$(SAMAP_NAME): $(HOTSPOT_SALIB_PATH)/$(SAMAP_NAME)
 	$(install-import-file)
 endif # windows
+
+  ifneq ($(OBJCOPY),)
+$(LIB_LOCATION)/$(SA_DEBUGINFO_NAME): $(HOTSPOT_SALIB_PATH)/$(SA_DEBUGINFO_NAME)
+	$(install-import-file)
+  endif
 endif # INCLUDE_SA
 
 all: $(IMPORT_LIST)
--- a/jdk/make/java/security/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/java/security/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -26,8 +26,8 @@
 BUILDDIR = ../..
 PACKAGE = java.security
 PRODUCT = sun
-JAVAC_MAX_WARNINGS = false
-JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
+JAVAC_MAX_WARNINGS = true 
+JAVAC_LINT_OPTIONS = -Xlint:all
 JAVAC_WARNINGS_FATAL = true
 include $(BUILDDIR)/common/Defs.gmk
 
--- a/jdk/make/javax/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/javax/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 BUILDDIR = ..
 include $(BUILDDIR)/common/Defs.gmk
 
-SUBDIRS = others
+SUBDIRS = others security
 
 SUBDIRS_management = management
 
--- a/jdk/make/javax/others/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/javax/others/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -28,7 +28,6 @@
 #
 
 BUILDDIR = ../..
-JAVAC_MAX_WARNINGS = true
 include $(BUILDDIR)/common/Defs.gmk
 
 #
@@ -39,10 +38,6 @@
     com/sun/naming/internal  \
     javax/net                \
     javax/script             \
-    javax/security/auth      \
-    javax/security/cert      \
-    javax/security/sasl      \
-    javax/smartcardio        \
     javax/tools              \
     javax/xml
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/javax/security/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# Makefile for building javax (security classes)
+#
+
+BUILDDIR = ../..
+JAVAC_MAX_WARNINGS = true 
+JAVAC_WARNINGS_FATAL = true 
+
+include $(BUILDDIR)/common/Defs.gmk
+
+#
+# Files to compile
+#
+AUTO_FILES_JAVA_DIRS =       \
+    javax/security/auth      \
+    javax/security/cert      \
+    javax/security/sasl      \
+    javax/smartcardio
+
+#
+# Rules
+#
+include $(BUILDDIR)/common/Classes.gmk
+
--- a/jdk/make/netbeans/README	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/README	Wed Oct 26 17:59:13 2011 -0700
@@ -5,7 +5,7 @@
 
 Getting Started
     In addition to the source bundle for Open JDK, you'll need to download
-    and install copies of the JDK and of NetBeans 6. And if you want to run
+    and install copies of the JDK and of NetBeans. And if you want to run
     tests on the JDK (you do want to run tests, right?), you'll need to
     install the jtreg test harness.
 
@@ -20,30 +20,28 @@
 
     Downloading the JDK
         You've probably done this a million times. Download and install it
-        from http://java.sun.com/javase
+        from http://www.oracle.com/technetwork/java/javase/overview/index.html
 
     Downloading the OpenJDK sources
         Since you're reading this, d you've already downloaded the OpenJDK
         source bundle.  Later in this document we'll refer to the location
         where you installed the Open JDK sources as *install-dir*.
 
-    Downloading a pre-built, JDK 7
+    Downloading a pre-built, JDK 8
         This will be necessary to do builds of some of the projects.  In
         general, you want to download and install a pre-built JDK that
         corresponds to the OpenJDK sources you download.  Building the entire
         OpenJDK depends on a few parts of the pre-built JDK.  Get this from
-        http://download.java.net/jdk7/binaries
+        http://download.java.net/jdk8/binaries
 
-        Note: For working on certain projects, like JMX and JConsole, you 
-              may find convenient to use a pre-built version of JDK 7 (or 
+        Note: For working on certain projects, like JMX and JConsole, you
+              may find convenient to use a pre-built version of JDK 8 (or
               OpenJDK) rather than building your own. This will allow you
               to build only that part of the OpenJDK sources which correspond
-              to that project. 
+              to that project.
 
-    NetBeans 6
-        Yep, NetBeans *6*. Nope, not FCS'd yet. We're on the edge here,
-        enjoy it! Get the latest working development build of NetBeans 6
-        from http://netbeans.org
+    NetBeans 7.0 or later
+        Older versions may also work but are unsupported.
 
     jtreg
         "jtreg" is the test harness for running OpenJDK's regression tests.
@@ -51,7 +49,7 @@
 
     Ant
        NetBeans comes with ant, but if you use a separately-installed copy
-       please make sure that it is at least version 1.7.0.
+       please make sure that it is at least version 1.8.1.
 
 Configuring
     Building OpenJDK is hard and complex. No, strike that. While it's not
@@ -92,8 +90,8 @@
         situation:
 
         make.options=\
-            ALT_BOOTDIR=/home/me/bin/jdk1.6.0 \
-            ALT_JDK_IMPORT_PATH=/home/me/bin/jdk1.7.0 \
+            ALT_BOOTDIR=/home/me/bin/jdk1.7.0 \
+            ALT_JDK_IMPORT_PATH=/home/me/bin/jdk1.8.0 \
             OPENJDK=true
 
         The trailing '\' are important, so that make gets the above as a
@@ -107,7 +105,7 @@
   Windows-specific configuration
     First, please note that the entire JDK cannot currently be built on
     Windows platforms.  This will likely limit your ability to build
-    make-based projects.  See 
+    make-based projects.  See
          *install-dir*/jdk/make/README-builds.html
     for full information on issues with building on the Windows platform.
 
@@ -141,7 +139,7 @@
     editor.
 
   Locale Requirements
-    To build the Open JDK sources, be certain that you are using the "C"
+    To build the OpenJDK sources, be certain that you are using the "C"
     locale on Unix (R) platforms, or "English (United States)" locale on
     Windows.
 
@@ -220,13 +218,13 @@
         running and debugging JConsole.
 
         This ant-based project does *not* require that you build the jdk
-        project first, provided that you use a pre-built version of JDK 7. 
+        project first, provided that you use a pre-built version of JDK 7.
 
     Java (TM) Management Extensions (JMX(TM)) API (directory "jmx")
         For working on JMX source code. Creates ../dist/lib/jmx.jar.
 
         This ant-based project does *not* require that you build the jdk
-        project first, provided that you use a pre-built version of JDK 7. 
+        project first, provided that you use a pre-built version of JDK 7.
 
     Jar & Zip (directory "jarzip")
         For working on jar & zip. It builds the zip library (including
@@ -242,12 +240,12 @@
         running and debugging the SampleTree demo.
 
         This ant-based project does *not* require that you build the jdk
-        project first, provided that you use a pre-built version of JDK 7. 
+        project first, provided that you use a pre-built version of JDK 7.
 
     In addition, there are projects for building the compiler, javadoc,
     and related tools, in the OpenJDK langtools component.  These
     projects are separate from those described here, and have their
-    own set of guidelines and conventions. For more details, see the 
+    own set of guidelines and conventions. For more details, see the
     README files in make/netbeans in the OpenJDK langtools component.
 
 Running Tests
@@ -603,13 +601,6 @@
     * -clean-make
 
 Known Issues
-  Tests won't run: waiting for lock
-    Occasionally when running tests, there will be a delay, followed by a
-    message like this:
-        Waiting to lock test result cache for
-           /tmp/jdk/build/linux-i586/jtreg/jconsole/JTwork for 20 seconds
-    The workaround is to stop the tests, rm -rf the offending jtreg/<project>
-    directory by hand, and re-run the tests.
 
   Can't run nor debug a single test in the JConsole test
     In most projects, you can run a single test by opening it in the editor,
--- a/jdk/make/netbeans/common/closed-share-view.ent	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/common/closed-share-view.ent	Wed Oct 26 17:59:13 2011 -0700
@@ -31,8 +31,8 @@
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->
 
-<source-folder style="packages">
-    <label>Closed-Source Packages</label>
+<source-folder style="tree">
+    <label>Closed Sources</label>
     <location>${root}/src/closed/share/classes</location>
     <includes>${includes}</includes>
     <excludes>${excludes}</excludes>
--- a/jdk/make/netbeans/common/java-data-native.ent	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/common/java-data-native.ent	Wed Oct 26 17:59:13 2011 -0700
@@ -38,7 +38,12 @@
         <package-root>${root}/src/solaris/classes</package-root>
         <classpath mode="boot">${bootstrap.jdk}/jre/lib/rt.jar</classpath>
         <built-to>${root}/build/${platform}-${arch}/classes</built-to>
-        <javadoc-built-to>${root}/build/javadoc/${name}</javadoc-built-to>
+        <javadoc-built-to>${root}/build/${platform}-${arch}/docs/api</javadoc-built-to>
+        <source-level>1.7</source-level>
+    </compilation-unit>
+    <compilation-unit>
+        <package-root>${root}/test</package-root>
+        <unit-tests/>
         <source-level>1.7</source-level>
     </compilation-unit>
 </java-data>
--- a/jdk/make/netbeans/common/java-data-no-native.ent	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/common/java-data-no-native.ent	Wed Oct 26 17:59:13 2011 -0700
@@ -36,7 +36,12 @@
         <package-root>${root}/src/share/classes</package-root>
         <classpath mode="boot">${bootstrap.jdk}/jre/lib/rt.jar</classpath>
         <built-to>${root}/build/${platform}-${arch}/classes</built-to>
-        <javadoc-built-to>${root}/build/javadoc/${name}</javadoc-built-to>
+        <javadoc-built-to>${root}/build/${platform}-${arch}/docs/api</javadoc-built-to>
+        <source-level>1.7</source-level>
+    </compilation-unit>
+    <compilation-unit>
+        <package-root>${root}/test</package-root>
+        <unit-tests/>
         <source-level>1.7</source-level>
     </compilation-unit>
 </java-data>
--- a/jdk/make/netbeans/common/jtreg-view.ent	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/common/jtreg-view.ent	Wed Oct 26 17:59:13 2011 -0700
@@ -31,7 +31,7 @@
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->
 
-<source-folder style="packages">
+<source-folder style="tree">
     <label>Tests</label>
     <location>${root}/test</location>
     <includes>${jtreg.tests}</includes>
--- a/jdk/make/netbeans/common/sample-view.ent	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/common/sample-view.ent	Wed Oct 26 17:59:13 2011 -0700
@@ -31,7 +31,7 @@
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->
 
-<source-folder style="packages">
+<source-folder style="tree">
     <label>Samples</label>
     <location>${root}/src/share/sample</location>
     <includes>${samples}</includes>
--- a/jdk/make/netbeans/common/share-view.ent	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/common/share-view.ent	Wed Oct 26 17:59:13 2011 -0700
@@ -31,7 +31,7 @@
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->
 
-<source-folder style="packages">
+<source-folder style="tree">
     <label>Sources for All Platforms</label>
     <location>${root}/src/share/classes</location>
     <includes>${includes}</includes>
--- a/jdk/make/netbeans/common/unix-view.ent	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/common/unix-view.ent	Wed Oct 26 17:59:13 2011 -0700
@@ -35,7 +35,7 @@
   UNIX is a registered trademark in the United States and other countries,
   exclusively licensed through X/Open Company, Ltd.
 -->
-<source-folder style="packages">
+<source-folder style="tree">
     <label>Sources for Unix® Platform</label>
     <location>${root}/src/solaris/classes</location>
     <includes>${includes}</includes>
--- a/jdk/make/netbeans/common/windows-view.ent	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/common/windows-view.ent	Wed Oct 26 17:59:13 2011 -0700
@@ -31,7 +31,7 @@
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->
 
-<source-folder style="packages">
+<source-folder style="tree">
     <label>Sources for Windows Platform</label>
     <location>${root}/src/windows/classes</location>
     <includes>${includes}</includes>
--- a/jdk/make/netbeans/j2se/nbproject/project.xml	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/netbeans/j2se/nbproject/project.xml	Wed Oct 26 17:59:13 2011 -0700
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
- Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
 
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
@@ -36,11 +36,13 @@
     <!ENTITY share-sources SYSTEM "../../common/share-sources.ent">
     <!ENTITY unix-sources SYSTEM "../../common/unix-sources.ent">
     <!ENTITY windows-sources SYSTEM "../../common/windows-sources.ent">
+    <!ENTITY jtreg-sources SYSTEM "../../common/jtreg-sources.ent">
     <!ENTITY build-folder SYSTEM "../../common/build-folder.ent">
     <!ENTITY standard-bindings SYSTEM "../../common/standard-bindings.ent">
     <!ENTITY share-view SYSTEM "../../common/share-view.ent">
     <!ENTITY unix-view SYSTEM "../../common/unix-view.ent">
     <!ENTITY windows-view SYSTEM "../../common/windows-view.ent">
+    <!ENTITY jtreg-view SYSTEM "../../common/jtreg-view.ent">
     <!ENTITY file-view SYSTEM "../../common/file-view.ent">
     <!ENTITY standard-actions SYSTEM "../../common/standard-actions.ent">
     <!ENTITY java-data-native SYSTEM "../../common/java-data-native.ent">
@@ -59,6 +61,7 @@
                 &unix-sources;
                 &windows-sources;
                 &build-folder;
+		&jtreg-sources;
             </folders>
             <ide-actions>
                 <action name="build">
@@ -82,6 +85,7 @@
                     &share-view;
                     &unix-view;
                     &windows-view;
+                    &jtreg-view;
                     &file-view;
                 </items>
                 <context-menu>
--- a/jdk/make/org/ietf/jgss/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/org/ietf/jgss/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -26,6 +26,8 @@
 BUILDDIR = ../../..
 PACKAGE = org.ietf.jgss
 PRODUCT = sun
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
 include $(BUILDDIR)/common/Defs.gmk
 
 #
--- a/jdk/make/sun/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -68,7 +68,7 @@
 endif
 
 # nio need to be compiled before awt to have all charsets ready
-SUBDIRS            = jar security javazic misc net nio text launcher
+SUBDIRS            = jar security javazic misc net nio text util launcher
 
 ifdef BUILD_HEADLESS_ONLY
   DISPLAY_LIBS = awt $(HEADLESS_SUBDIR)
--- a/jdk/make/sun/javazic/tzdata/VERSION	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/VERSION	Wed Oct 26 17:59:13 2011 -0700
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2011g
+tzdata2011j
--- a/jdk/make/sun/javazic/tzdata/africa	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/africa	Wed Oct 26 17:59:13 2011 -0700
@@ -80,7 +80,7 @@
 # I invented the following abbreviations; corrections are welcome!
 #	 2:00	WAST	West Africa Summer Time
 #	 2:30	BEAT	British East Africa Time (no longer used)
-#	 2:44:45 BEAUT	British East Africa Unified Time (no longer used)
+#	 2:45	BEAUT	British East Africa Unified Time (no longer used)
 #	 3:00	CAST	Central Africa Summer Time (no longer used)
 #	 3:00	SAST	South Africa Summer Time (no longer used)
 #	 3:00	EAT	East Africa Time
@@ -418,7 +418,7 @@
 Zone	Africa/Nairobi	2:27:16	-	LMT	1928 Jul
 			3:00	-	EAT	1930
 			2:30	-	BEAT	1940
-			2:44:45	-	BEAUT	1960
+			2:45	-	BEAUT	1960
 			3:00	-	EAT
 
 # Lesotho
@@ -979,6 +979,11 @@
 			2:00	Sudan	CA%sT	2000 Jan 15 12:00
 			3:00	-	EAT
 
+# South Sudan
+Zone	Africa/Juba	2:06:24 -	LMT	1931
+			2:00	Sudan	CA%sT	2000 Jan 15 12:00
+			3:00	-	EAT
+
 # Swaziland
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Mbabane	2:04:24 -	LMT	1903 Mar
@@ -988,7 +993,7 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Africa/Dar_es_Salaam 2:37:08 -	LMT	1931
 			3:00	-	EAT	1948
-			2:44:45	-	BEAUT	1961
+			2:45	-	BEAUT	1961
 			3:00	-	EAT
 
 # Togo
@@ -1114,7 +1119,7 @@
 Zone	Africa/Kampala	2:09:40 -	LMT	1928 Jul
 			3:00	-	EAT	1930
 			2:30	-	BEAT	1948
-			2:44:45	-	BEAUT	1957
+			2:45	-	BEAUT	1957
 			3:00	-	EAT
 
 # Zambia
--- a/jdk/make/sun/javazic/tzdata/antarctica	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/antarctica	Wed Oct 26 17:59:13 2011 -0700
@@ -41,18 +41,6 @@
 # I made up all time zone abbreviations mentioned here; corrections welcome!
 # FORMAT is `zzz' and GMTOFF is 0 for locations while uninhabited.
 
-# These rules are stolen from the `europe' file.
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	RussAQ	1981	1984	-	Apr	 1	 0:00	1:00	S
-Rule	RussAQ	1981	1983	-	Oct	 1	 0:00	0	-
-Rule	RussAQ	1984	1991	-	Sep	lastSun	 2:00s	0	-
-Rule	RussAQ	1985	1991	-	Mar	lastSun	 2:00s	1:00	S
-Rule	RussAQ	1992	only	-	Mar	lastSat	 23:00	1:00	S
-Rule	RussAQ	1992	only	-	Sep	lastSat	 23:00	0	-
-Rule	RussAQ	1993	max	-	Mar	lastSun	 2:00s	1:00	S
-Rule	RussAQ	1993	1995	-	Sep	lastSun	 2:00s	0	-
-Rule	RussAQ	1996	max	-	Oct	lastSun	 2:00s	0	-
-
 # These rules are stolen from the `southamerica' file.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	ArgAQ	1964	1966	-	Mar	 1	0:00	0	-
--- a/jdk/make/sun/javazic/tzdata/asia	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/asia	Wed Oct 26 17:59:13 2011 -0700
@@ -99,6 +99,10 @@
 Rule RussiaAsia	1993	1995	-	Sep	lastSun	 2:00s	0	-
 Rule RussiaAsia	1996	max	-	Oct	lastSun	 2:00s	0	-
 
+# From Arthur David Olson (2011-06-15):
+# While Russia abandoned DST in 2011, Armenia may choose to
+# follow Russia's "old" rules.
+
 # Afghanistan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Kabul	4:36:48 -	LMT	1890
--- a/jdk/make/sun/javazic/tzdata/australasia	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/australasia	Wed Oct 26 17:59:13 2011 -0700
@@ -521,7 +521,7 @@
 # http://www.parliament.gov.ws/documents/acts/Daylight%20Saving%20Act%20%202009%20%28English%29%20-%20Final%207-7-091.pdf
 # </a>
 
-# From Raymond Hughes (2010-10-07):
+# From Laupue Raymond Hughes (2010-10-07):
 # Please see
 # <a href="http://www.mcil.gov.ws">
 # http://www.mcil.gov.ws
@@ -531,7 +531,7 @@
 # to 01:00am and First Sunday April 2011 (03/04/11) - adjust clocks
 # backwards from 1:00am to 12:00am"
 
-# From Raymond Hughes (2011-03-07)
+# From Laupue Raymond Hughes (2011-03-07):
 # I believe this will be posted shortly on the website
 # <a href="http://www.mcil.gov.ws">
 # www.mcil.gov.ws
@@ -551,12 +551,74 @@
 # Margaret Fruean ACTING CHIEF EXECUTIVE OFFICER MINISTRY OF COMMERCE,
 # INDUSTRY AND LABOUR 28th February 2011
 
+# From David Zuelke (2011-05-09):
+# Subject: Samoa to move timezone from east to west of international date line
+# 
+# <a href="http://www.morningstar.co.uk/uk/markets/newsfeeditem.aspx?id=138501958347963">
+# http://www.morningstar.co.uk/uk/markets/newsfeeditem.aspx?id=138501958347963
+# </a>
+
+# From Mark Sim-Smith (2011-08-17):
+# I have been in contact with Leilani Tuala Warren from the Samoa Law
+# Reform Commission, and she has sent me a copy of the Bill that she
+# confirmed has been passed...Most of the sections are about maps rather
+# than the time zone change, but I'll paste the relevant bits below. But
+# the essence is that at midnight 29 Dec (UTC-11 I suppose), Samoa
+# changes from UTC-11 to UTC+13:
+#
+# International Date Line Bill 2011
+#
+# AN ACT to provide for the change to standard time in Samoa and to make
+# consequential amendments to the position of the International Date
+# Line, and for related purposes.
+#
+# BE IT ENACTED by the Legislative Assembly of Samoa in Parliament
+# assembled as follows:
+#
+# 1. Short title and commencement-(1) This Act may be cited as the
+# International Date Line Act 2011. (2) Except for section 5(3) this Act
+# commences at 12 o'clock midnight, on Thursday 29th December 2011. (3)
+# Section 5(3) commences on the date of assent by the Head of State.
+#
+# [snip]
+#
+# 3. Interpretation - [snip] "Samoa standard time" in this Act and any
+# other statute of Samoa which refers to 'Samoa standard time' means the
+# time 13 hours in advance of Co-ordinated Universal Time.
+#
+# 4. Samoa standard time - (1) Upon the commencement of this Act, Samoa
+# standard time shall be set at 13 hours in advance of Co-ordinated
+# Universal Time for the whole of Samoa. (2) All references to Samoa's
+# time zone and to Samoa standard time in Samoa in all legislation and
+# instruments after the commencement of this Act shall be references to
+# Samoa standard time as provided for in this Act. (3) Nothing in this
+# Act affects the provisions of the Daylight Saving Act 2009, except that
+# it defines Samoa standard time....
+
+# From Laupue Raymond Hughes (2011-09-02):
+# <a href="http://www.mcil.gov.ws/mcil_publications.html">
+# http://www.mcil.gov.ws/mcil_publications.html
+# </a>
+#
+# here is the official website publication for Samoa DST and dateline change
+#
+# DST
+# Year	End	Time	Start	Time
+# 2011	- - -	- - -	24 September	3:00am to 4:00am
+# 2012	01 April	4:00am to 3:00am	- - -	- - -
+#
+# Dateline Change skip Friday 30th Dec 2011
+# Thursday 29th December 2011	23:59:59 Hours
+# Saturday 31st December 2011	00:00:00 Hours
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time
 			-11:00	-	WST	2010 Sep 26
 			-11:00	1:00	WSDT	2011 Apr 2 4:00
-			-11:00	-	WST
+			-11:00	-	WST	2011 Sep 24 3:00
+			-11:00	1:00	WSDT	2011 Dec 30
+			 13:00	1:00	WSDT	2012 Apr 1 4:00
+			 13:00	-	WST
 
 # Solomon Is
 # excludes Bougainville, for which see Papua New Guinea
@@ -1228,7 +1290,7 @@
 # Lord Howe Island Board (controlling authority for the Island) is
 # seeking the community's views on various options for summer time
 # arrangements on the Island, e.g. advance clocks by 1 full hour
-# instead of only 30 minutes.  Dependant on the wishes of residents
+# instead of only 30 minutes.  [Dependent] on the wishes of residents
 # the Board may approach the NSW government to change the existing
 # arrangements.  The starting date for summer time on the Island will
 # however always coincide with the rest of NSW.
@@ -1354,7 +1416,7 @@
 
 # From Paul Eggert (1996-01-22):
 # Today's _Wall Street Journal_ (page 1) reports that Kiribati
-# ``declared it the same day throught the country as of Jan. 1, 1995''
+# ``declared it the same day [throughout] the country as of Jan. 1, 1995''
 # as part of the competition to be first into the 21st century.
 
 
--- a/jdk/make/sun/javazic/tzdata/europe	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/europe	Wed Oct 26 17:59:13 2011 -0700
@@ -587,6 +587,26 @@
 Rule	Russia	1993	1995	-	Sep	lastSun	 2:00s	0	-
 Rule	Russia	1996	max	-	Oct	lastSun	 2:00s	0	-
 
+# From Alexander Krivenyshev (2011-06-14):
+# According to Kremlin press service, Russian President Dmitry Medvedev
+# signed a federal law "On calculation of time" on June 9, 2011.
+# According to the law Russia is abolishing daylight saving time.
+# 
+# Medvedev signed a law "On the Calculation of Time" (in russian): 
+# <a href="http://bmockbe.ru/events/?ID=7583">
+# http://bmockbe.ru/events/?ID=7583
+# </a>
+# 
+# Medvedev signed a law on the calculation of the time (in russian):
+# <a href="http://www.regnum.ru/news/polit/1413906.html">
+# http://www.regnum.ru/news/polit/1413906.html
+# </a>
+
+# From Arthur David Olson (2011-06-15):
+# Take "abolishing daylight saving time" to mean that time is now considered
+# to be standard.
+# At least for now, keep the "old" Russia rules for the benefit of Belarus.
+
 # These are for backward compatibility with older versions.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2035,7 +2055,8 @@
 			 1:00	C-Eur	CE%sT	1945
 			 2:00	Poland	CE%sT	1946
 			 3:00	Russia	MSK/MSD	1991 Mar 31 2:00s
-			 2:00	Russia	EE%sT
+			 2:00	Russia	EE%sT	2011 Mar 27 2:00s
+			 3:00	-	KALT
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Respublika Adygeya, Arkhangel'skaya oblast',
@@ -2064,7 +2085,8 @@
 			 2:00	-	EET	1930 Jun 21
 			 3:00	Russia	MSK/MSD	1991 Mar 31 2:00s
 			 2:00	Russia	EE%sT	1992 Jan 19 2:00s
-			 3:00	Russia	MSK/MSD
+			 3:00	Russia	MSK/MSD	2011 Mar 27 2:00s
+			 4:00	-	MSK
 #
 # Astrakhanskaya oblast', Kirovskaya oblast', Saratovskaya oblast',
 # Volgogradskaya oblast'.  Shanks & Pottenger say Kirov is still at +0400
@@ -2077,7 +2099,8 @@
 			 4:00	Russia	VOL%sT	1989 Mar 26 2:00s # Volgograd T
 			 3:00	Russia	VOL%sT	1991 Mar 31 2:00s
 			 4:00	-	VOLT	1992 Mar 29 2:00s
-			 3:00	Russia	VOL%sT
+			 3:00	Russia	VOL%sT	2011 Mar 27 2:00s
+			 4:00	-	VOLT
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Samarskaya oblast', Udmyrtskaya respublika
@@ -2089,7 +2112,8 @@
 			 2:00	Russia	KUY%sT	1991 Sep 29 2:00s
 			 3:00	-	KUYT	1991 Oct 20 3:00
 			 4:00	Russia	SAM%sT	2010 Mar 28 2:00s # Samara Time
-			 3:00	Russia	SAM%sT
+			 3:00	Russia	SAM%sT	2011 Mar 27 2:00s
+			 4:00	-	SAMT
 
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
@@ -2102,7 +2126,8 @@
 			 4:00	-	SVET	1930 Jun 21 # Sverdlovsk Time
 			 5:00	Russia	SVE%sT	1991 Mar 31 2:00s
 			 4:00	Russia	SVE%sT	1992 Jan 19 2:00s
-			 5:00	Russia	YEK%sT	# Yekaterinburg Time
+			 5:00	Russia	YEK%sT	2011 Mar 27 2:00s
+			 6:00	-	YEKT	# Yekaterinburg Time
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Respublika Altaj, Altajskij kraj, Omskaya oblast'.
@@ -2110,7 +2135,8 @@
 			 5:00	-	OMST	1930 Jun 21 # Omsk TIme
 			 6:00	Russia	OMS%sT	1991 Mar 31 2:00s
 			 5:00	Russia	OMS%sT	1992 Jan 19 2:00s
-			 6:00	Russia	OMS%sT
+			 6:00	Russia	OMS%sT	2011 Mar 27 2:00s
+			 7:00	-	OMST
 #
 # From Paul Eggert (2006-08-19): I'm guessing about Tomsk here; it's
 # not clear when it switched from +7 to +6.
@@ -2120,7 +2146,8 @@
 			 7:00	Russia	NOV%sT	1991 Mar 31 2:00s
 			 6:00	Russia	NOV%sT	1992 Jan 19 2:00s
 			 7:00	Russia	NOV%sT	1993 May 23 # say Shanks & P.
-			 6:00	Russia	NOV%sT
+			 6:00	Russia	NOV%sT	2011 Mar 27 2:00s
+			 7:00	-	NOVT
 
 # From Alexander Krivenyshev (2009-10-13):
 # Kemerovo oblast' (Kemerovo region) in Russia will change current time zone on
@@ -2153,7 +2180,8 @@
 			 7:00	Russia	KRA%sT	1991 Mar 31 2:00s
 			 6:00	Russia	KRA%sT	1992 Jan 19 2:00s
 			 7:00	Russia	KRA%sT	2010 Mar 28 2:00s
-			 6:00	Russia	NOV%sT # Novosibirsk/Novokuznetsk Time
+			 6:00	Russia	NOV%sT	2011 Mar 27 2:00s
+			 7:00	-	NOVT # Novosibirsk/Novokuznetsk Time
 
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
@@ -2164,7 +2192,8 @@
 			 6:00	-	KRAT	1930 Jun 21 # Krasnoyarsk Time
 			 7:00	Russia	KRA%sT	1991 Mar 31 2:00s
 			 6:00	Russia	KRA%sT	1992 Jan 19 2:00s
-			 7:00	Russia	KRA%sT
+			 7:00	Russia	KRA%sT	2011 Mar 27 2:00s
+			 8:00	-	KRAT
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Respublika Buryatiya, Irkutskaya oblast',
@@ -2174,7 +2203,8 @@
 			 7:00	-	IRKT	1930 Jun 21 # Irkutsk Time
 			 8:00	Russia	IRK%sT	1991 Mar 31 2:00s
 			 7:00	Russia	IRK%sT	1992 Jan 19 2:00s
-			 8:00	Russia	IRK%sT
+			 8:00	Russia	IRK%sT	2011 Mar 27 2:00s
+			 9:00	-	IRKT
 #
 # From Oscar van Vlijmen (2003-10-18): [This region consists of]
 # Aginskij Buryatskij avtonomnyj okrug, Amurskaya oblast',
@@ -2197,7 +2227,8 @@
 			 8:00	-	YAKT	1930 Jun 21 # Yakutsk Time
 			 9:00	Russia	YAK%sT	1991 Mar 31 2:00s
 			 8:00	Russia	YAK%sT	1992 Jan 19 2:00s
-			 9:00	Russia	YAK%sT
+			 9:00	Russia	YAK%sT	2011 Mar 27 2:00s
+			 10:00	-	YAKT
 #
 # From Oscar van Vlijmen (2003-10-18): [This region consists of]
 # Evrejskaya avtonomnaya oblast', Khabarovskij kraj, Primorskij kraj,
@@ -2210,7 +2241,8 @@
 			 9:00	-	VLAT	1930 Jun 21 # Vladivostok Time
 			10:00	Russia	VLA%sT	1991 Mar 31 2:00s
 			 9:00	Russia	VLA%sST	1992 Jan 19 2:00s
-			10:00	Russia	VLA%sT
+			10:00	Russia	VLA%sT	2011 Mar 27 2:00s
+			11:00	-	VLAT
 #
 # Sakhalinskaya oblast'.
 # The Zone name should be Yuzhno-Sakhalinsk, but that's too long.
@@ -2220,7 +2252,8 @@
 			11:00	Russia	SAK%sT	1991 Mar 31 2:00s # Sakhalin T.
 			10:00	Russia	SAK%sT	1992 Jan 19 2:00s
 			11:00	Russia	SAK%sT	1997 Mar lastSun 2:00s
-			10:00	Russia	SAK%sT
+			10:00	Russia	SAK%sT	2011 Mar 27 2:00s
+			11:00	-	SAKT
 #
 # From Oscar van Vlijmen (2003-10-18): [This region consists of]
 # Magadanskaya oblast', Respublika Sakha (Yakutiya).
@@ -2233,7 +2266,8 @@
 			10:00	-	MAGT	1930 Jun 21 # Magadan Time
 			11:00	Russia	MAG%sT	1991 Mar 31 2:00s
 			10:00	Russia	MAG%sT	1992 Jan 19 2:00s
-			11:00	Russia	MAG%sT
+			11:00	Russia	MAG%sT	2011 Mar 27 2:00s
+			12:00	-	MAGT
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
 # Kamchatskaya oblast', Koryakskij avtonomnyj okrug.
@@ -2244,7 +2278,8 @@
 			12:00	Russia	PET%sT	1991 Mar 31 2:00s
 			11:00	Russia	PET%sT	1992 Jan 19 2:00s
 			12:00	Russia	PET%sT	2010 Mar 28 2:00s
-			11:00	Russia	PET%sT
+			11:00	Russia	PET%sT	2011 Mar 27 2:00s
+			12:00	-	PETT
 #
 # Chukotskij avtonomnyj okrug
 Zone Asia/Anadyr	11:49:56 -	LMT	1924 May  2
@@ -2253,7 +2288,8 @@
 			12:00	Russia	ANA%sT	1991 Mar 31 2:00s
 			11:00	Russia	ANA%sT	1992 Jan 19 2:00s
 			12:00	Russia	ANA%sT	2010 Mar 28 2:00s
-			11:00	Russia	ANA%sT
+			11:00	Russia	ANA%sT	2011 Mar 27 2:00s
+			12:00	-	ANAT
 
 # Serbia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
--- a/jdk/make/sun/javazic/tzdata/iso3166.tab	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/iso3166.tab	Wed Oct 26 17:59:13 2011 -0700
@@ -43,6 +43,9 @@
 #
 # Lines beginning with `#' are comments.
 #
+# From Arthur David Olson (2011-08-17):
+# Resynchronized today with the ISO 3166 site (adding SS for South Sudan).
+#
 #country-
 #code	country name
 AD	Andorra
@@ -52,7 +55,6 @@
 AI	Anguilla
 AL	Albania
 AM	Armenia
-AN	Netherlands Antilles
 AO	Angola
 AQ	Antarctica
 AR	Argentina
@@ -75,6 +77,7 @@
 BM	Bermuda
 BN	Brunei
 BO	Bolivia
+BQ	Bonaire Sint Eustatius & Saba
 BR	Brazil
 BS	Bahamas
 BT	Bhutan
@@ -97,6 +100,7 @@
 CR	Costa Rica
 CU	Cuba
 CV	Cape Verde
+CW	Curacao
 CX	Christmas Island
 CY	Cyprus
 CZ	Czech Republic
@@ -251,8 +255,10 @@
 SN	Senegal
 SO	Somalia
 SR	Suriname
+SS	South Sudan
 ST	Sao Tome & Principe
 SV	El Salvador
+SX	Sint Maarten
 SY	Syria
 SZ	Swaziland
 TC	Turks & Caicos Is
--- a/jdk/make/sun/javazic/tzdata/northamerica	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/northamerica	Wed Oct 26 17:59:13 2011 -0700
@@ -490,6 +490,10 @@
 # own time. I asked about daylight saving; they said it wasn't used. I
 # did not inquire about practices in the past.
 
+# From Arthur David Olson (2011-08-17):
+# For lack of better information, assume that Metlakatla's
+# abandonment of use of daylight saving resulted from the 1983 vote.
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Juneau	 15:02:19 -	LMT	1867 Oct 18
 			 -8:57:41 -	LMT	1900 Aug 20 12:00
@@ -515,7 +519,7 @@
 			 -8:00	US	P%sT	1946
 			 -8:00	-	PST	1969
 			 -8:00	US	P%sT	1983 Oct 30 2:00
-			 -8:00	US	MeST
+			 -8:00	-	MeST
 Zone America/Yakutat	 14:41:05 -	LMT	1867 Oct 18
 			 -9:18:55 -	LMT	1900 Aug 20 12:00
 			 -9:00	-	YST	1942
@@ -615,8 +619,8 @@
 			-10:30	-	HST	1933 Apr 30 2:00 #Laws 1933
 			-10:30	1:00	HDT	1933 May 21 12:00 #Laws 1933+12
 			-10:30	-	HST	1942 Feb 09 2:00 #Schmitt&Cox+2
-			-10:30	1:00	HDT	1945 Sep 30 2:00 #Schmitt&Fox+2
-			-10:30	US	H%sT	1947 Jun  8 2:00 #Schmitt&Fox+2
+			-10:30	1:00	HDT	1945 Sep 30 2:00 #Schmitt&Cox+2
+			-10:30	-	HST	1947 Jun  8 2:00 #Schmitt&Cox+2
 			-10:00	-	HST
 
 # Now we turn to US areas that have diverged from the consensus since 1970.
@@ -1185,12 +1189,39 @@
 # From Paul Eggert (2000-10-02):
 # INMS (2000-09-12) says that, since 1988 at least, Newfoundland switches
 # at 00:01 local time.  For now, assume it started in 1987.
+
+# From Michael Pelley (2011-08-05):
+# The Government of Newfoundland and Labrador has pending changes to
+# modify the hour for daylight savings time to come into effect in
+# November 2011. This modification would change the time from 12:01AM to
+# 2:00AM on the dates of the switches of Daylight Savings Time to/from
+# Standard Time.
+#
+# As a matter of reference, in Canada provinces have the authority of
+# setting time zone information. The legislation has passed our
+# legislative body (The House of Assembly) and is awaiting the
+# proclamation to come into effect. You may find this information at:
+# <a href="http://www.assembly.nl.ca/legislation/sr/lists/Proclamation.htm">
+# http://www.assembly.nl.ca/legislation/sr/lists/Proclamation.htm
+# </a>
+# and
+# search within that web page for Standard Time (Amendment) Act. The Act
+# may be found at:
+# <a href="http://www.assembly.nl.ca/business/bills/Bill1106.htm">
+# http://www.assembly.nl.ca/business/bills/Bill1106.htm
+# </a>
+# ...
+# MICHAEL PELLEY | Manager of Enterprise Architecture - Solution Delivery
+# Office of the Chief Information Officer Executive Council Government of
+# Newfoundland & Labrador P.O. Box 8700, 40 Higgins Line, St. John's NL
+# A1B 4J6
+
 Rule	StJohns	1987	only	-	Apr	Sun>=1	0:01	1:00	D
 Rule	StJohns	1987	2006	-	Oct	lastSun	0:01	0	S
 Rule	StJohns	1988	only	-	Apr	Sun>=1	0:01	2:00	DD
 Rule	StJohns	1989	2006	-	Apr	Sun>=1	0:01	1:00	D
-Rule	StJohns	2007	max	-	Mar	Sun>=8	0:01	1:00	D
-Rule	StJohns	2007	max	-	Nov	Sun>=1	0:01	0	S
+Rule	StJohns	2007	2011	-	Mar	Sun>=8	0:01	1:00	D
+Rule	StJohns	2007	2010	-	Nov	Sun>=1	0:01	0	S
 #
 # St John's has an apostrophe, but Posix file names can't have apostrophes.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -1200,7 +1231,8 @@
 			-3:30:52 StJohns N%sT	1935 Mar 30
 			-3:30	StJohns	N%sT	1942 May 11
 			-3:30	Canada	N%sT	1946
-			-3:30	StJohns	N%sT
+			-3:30	StJohns	N%sT	2011 Nov
+			-3:30	Canada	N%sT
 
 # most of east Labrador
 
@@ -1214,7 +1246,8 @@
 			-3:30	StJohns	N%sT	1942 May 11
 			-3:30	Canada	N%sT	1946
 			-3:30	StJohns	N%sT	1966 Mar 15 2:00
-			-4:00	StJohns	A%sT
+			-4:00	StJohns	A%sT	2011 Nov
+			-4:00	Canada	A%sT
 
 
 # west Labrador, Nova Scotia, Prince Edward I
@@ -1946,20 +1979,69 @@
 # daylight saving....
 # http://www.nnsl.com/frames/newspapers/2006-11/nov13_06none.html
 
-# From Chris Walton (2007-03-14):
-# Today I phoned the "hamlet office" to find out what Resolute was doing with
-# its clocks.
+# From Chris Walton (2011-03-21):
+# Back in 2007 I initiated the creation of a new "zone file" for Resolute
+# Bay. Resolute Bay is a small community located about 900km north of
+# the Arctic Circle. The zone file was required because Resolute Bay had
+# decided to use UTC-5 instead of UTC-6 for the winter of 2006-2007.
+#
+# According to new information which I received last week, Resolute Bay
+# went back to using UTC-6 in the winter of 2007-2008...
+#
+# On March 11/2007 most of Canada went onto daylight saving. On March
+# 14/2007 I phoned the Resolute Bay hamlet office to do a "time check." I
+# talked to somebody that was both knowledgeable and helpful. I was able
+# to confirm that Resolute Bay was still operating on UTC-5. It was
+# explained to me that Resolute Bay had been on the Eastern Time zone
+# (EST) in the winter, and was now back on the Central Time zone (CDT).
+# i.e. the time zone had changed twice in the last year but the clocks
+# had not moved. The residents had to know which time zone they were in
+# so they could follow the correct TV schedule...
+#
+# On Nov 02/2008 most of Canada went onto standard time. On Nov 03/2008 I
+# phoned the Resolute Bay hamlet office...[D]ue to the challenging nature
+# of the phone call, I decided to seek out an alternate source of
+# information. I found an e-mail address for somebody by the name of
+# Stephanie Adams whose job was listed as "Inns North Support Officer for
+# Arctic Co-operatives." I was under the impression that Stephanie lived
+# and worked in Resolute Bay...
 #
-# The individual that answered the phone confirmed that the clocks did not
-# move at the end of daylight saving on October 29/2006.  He also told me that
-# the clocks did not move this past weekend (March 11/2007)....
-
-# From Chris Walton (2008-11-13):
-# ...the residents of Resolute believe that they are changing "time zones"
-# twice a year.  In winter months, local time is qualified with "Eastern
-# Time" which is really "Eastern Standard Time (UTC-5)".  In summer
-# months, local time is qualified with "Central Time" which is really
-# "Central Daylight Time (UTC-5)"...
+# On March 14/2011 I phoned the hamlet office again. I was told that
+# Resolute Bay had been using Central Standard Time over the winter of
+# 2010-2011 and that the clocks had therefore been moved one hour ahead
+# on March 13/2011. The person I talked to was aware that Resolute Bay
+# had previously experimented with Eastern Standard Time but he could not
+# tell me when the practice had stopped.
+#
+# On March 17/2011 I searched the Web to find an e-mail address of
+# somebody that might be able to tell me exactly when Resolute Bay went
+# off Eastern Standard Time. I stumbled on the name "Aziz Kheraj." Aziz
+# used to be the mayor of Resolute Bay and he apparently owns half the
+# businesses including "South Camp Inn." This website has some info on
+# Aziz:
+# <a href="http://www.uphere.ca/node/493">
+# http://www.uphere.ca/node/493
+# </a>
+#
+# I sent Aziz an e-mail asking when Resolute Bay had stopped using
+# Eastern Standard Time.
+#
+# Aziz responded quickly with this: "hi, The time was not changed for the
+# 1 year only, the following year, the community went back to the old way
+# of "spring ahead-fall behind" currently we are zulu plus 5 hrs and in
+# the winter Zulu plus 6 hrs"
+#
+# This of course conflicted with everything I had ascertained in November 2008.
+#
+# I sent Aziz a copy of my 2008 e-mail exchange with Stephanie. Aziz
+# responded with this: "Hi, Stephanie lives in Winnipeg. I live here, You
+# may want to check with the weather office in Resolute Bay or do a
+# search on the weather through Env. Canada. web site"
+#
+# If I had realized the Stephanie did not live in Resolute Bay I would
+# never have contacted her.  I now believe that all the information I
+# obtained in November 2008 should be ignored...
+# I apologize for reporting incorrect information in 2008.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	NT_YK	1918	only	-	Apr	14	2:00	1:00	D
@@ -1987,14 +2069,12 @@
 			-6:00	Canada	C%sT	2000 Oct 29 2:00
 			-5:00	Canada	E%sT
 # aka Qausuittuq
-# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
-Rule	Resolute 2006	max	-	Nov	Sun>=1	2:00	0	ES
-Rule	Resolute 2007	max	-	Mar	Sun>=8	2:00	0	CD
 Zone America/Resolute	0	-	zzz	1947 Aug 31 # Resolute founded
 			-6:00	NT_YK	C%sT	2000 Oct 29 2:00
 			-5:00	-	EST	2001 Apr  1 3:00
 			-6:00	Canada	C%sT	2006 Oct 29 2:00
-			-5:00	Resolute	%sT
+			-5:00	-	EST	2007 Mar 11 3:00
+			-6:00	Canada	C%sT
 # aka Kangiqiniq
 Zone America/Rankin_Inlet 0	-	zzz	1957 # Rankin Inlet founded
 			-6:00	NT_YK	C%sT	2000 Oct 29 2:00
--- a/jdk/make/sun/javazic/tzdata/southamerica	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/southamerica	Wed Oct 26 17:59:13 2011 -0700
@@ -1298,6 +1298,14 @@
 			-4:30	-	ANT	1965 # Netherlands Antilles Time
 			-4:00	-	AST
 
+# From Arthur David Olson (2011-06-15):
+# At least for now, use links for places with new iso3166 codes.
+# The name "Lower Prince's Quarter" is both longer than fourteen charaters
+# and contains an apostrophe; use "Lower_Princes" below.
+
+Link	America/Curacao	America/Lower_Princes # Sint Maarten
+Link	America/Curacao	America/Kralendijk # Bonaire, Sint Estatius and Saba
+
 # Ecuador
 #
 # From Paul Eggert (2007-03-04):
--- a/jdk/make/sun/javazic/tzdata/zone.tab	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/javazic/tzdata/zone.tab	Wed Oct 26 17:59:13 2011 -0700
@@ -54,7 +54,6 @@
 AI	+1812-06304	America/Anguilla
 AL	+4120+01950	Europe/Tirane
 AM	+4011+04430	Asia/Yerevan
-AN	+1211-06900	America/Curacao
 AO	-0848+01314	Africa/Luanda
 AQ	-7750+16636	Antarctica/McMurdo	McMurdo Station, Ross Island
 AQ	-9000+00000	Antarctica/South_Pole	Amundsen-Scott Station, South Pole
@@ -109,6 +108,7 @@
 BM	+3217-06446	Atlantic/Bermuda
 BN	+0456+11455	Asia/Brunei
 BO	-1630-06809	America/La_Paz
+BQ	+120903-0681636	America/Kralendijk
 BR	-0351-03225	America/Noronha	Atlantic islands
 BR	-0127-04829	America/Belem	Amapa, E Para
 BR	-0343-03830	America/Fortaleza	NE Brazil (MA, PI, CE, RN, PB)
@@ -142,7 +142,7 @@
 CA	+4823-08915	America/Thunder_Bay	Eastern Time - Thunder Bay, Ontario
 CA	+6344-06828	America/Iqaluit	Eastern Time - east Nunavut - most locations
 CA	+6608-06544	America/Pangnirtung	Eastern Time - Pangnirtung, Nunavut
-CA	+744144-0944945	America/Resolute	Eastern Standard Time - Resolute, Nunavut
+CA	+744144-0944945	America/Resolute	Central Standard Time - Resolute, Nunavut
 CA	+484531-0913718	America/Atikokan	Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
 CA	+624900-0920459	America/Rankin_Inlet	Central Time - central Nunavut
 CA	+4953-09709	America/Winnipeg	Central Time - Manitoba & west Ontario
@@ -177,6 +177,7 @@
 CR	+0956-08405	America/Costa_Rica
 CU	+2308-08222	America/Havana
 CV	+1455-02331	Atlantic/Cape_Verde
+CW	+1211-06900	America/Curacao
 CX	-1025+10543	Indian/Christmas
 CY	+3510+03322	Asia/Nicosia
 CZ	+5005+01426	Europe/Prague
@@ -382,8 +383,10 @@
 SN	+1440-01726	Africa/Dakar
 SO	+0204+04522	Africa/Mogadishu
 SR	+0550-05510	America/Paramaribo
+SS	+0451+03136	Africa/Juba
 ST	+0020+00644	Africa/Sao_Tome
 SV	+1342-08912	America/El_Salvador
+SX	+180305-0630250	America/Lower_Princes
 SY	+3330+03618	Asia/Damascus
 SZ	-2618+03106	Africa/Mbabane
 TC	+2128-07108	America/Grand_Turk
--- a/jdk/make/sun/net/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/net/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 BUILDDIR = ../..
 PACKAGE = sun.net
 PRODUCT = sun
+SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
+SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
 include $(BUILDDIR)/common/Defs.gmk
 
 SUBDIRS = others spi
--- a/jdk/make/sun/net/spi/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/net/spi/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -24,6 +24,8 @@
 #
 
 BUILDDIR = ../../..
+SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
+
 include $(BUILDDIR)/common/Defs.gmk
 
 SUBDIRS_misc = nameservice 
--- a/jdk/make/sun/net/spi/nameservice/dns/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/net/spi/nameservice/dns/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -28,7 +28,8 @@
 #
 
 BUILDDIR = ../../../../..
-
+JAVAC_MAX_WARNINGS = true
+JAVAC_WARNINGS_FATAL = true
 # dns should probably be its own module
 PACKAGE = sun.net.spi.nameservice.dns
 PRODUCT = sun
--- a/jdk/make/sun/security/other/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/sun/security/other/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -26,7 +26,7 @@
 BUILDDIR = ../../..
 PACKAGE = sun.security.other
 PRODUCT = sun
-JAVAC_MAX_WARNINGS=false
+JAVAC_MAX_WARNINGS=true
 JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
 JAVAC_WARNINGS_FATAL=true
 include $(BUILDDIR)/common/Defs.gmk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/sun/util/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+BUILDDIR = ../..
+PACKAGE = sun.util
+PRODUCT = sun
+include $(BUILDDIR)/common/Defs.gmk
+
+#
+# Files
+#
+AUTO_FILES_JAVA_DIRS = sun/util/xml
+
+#
+# Rules
+#
+include $(BUILDDIR)/common/Classes.gmk
+
--- a/jdk/make/tools/src/build/tools/javazic/Mappings.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/make/tools/src/build/tools/javazic/Mappings.java	Wed Oct 26 17:59:13 2011 -0700
@@ -76,8 +76,8 @@
             // If the GMT offset of this Zone will change in some
             // future time, this Zone is added to the exclude list.
             boolean isExcluded = false;
-            if (zone.size() > 1) {
-                ZoneRec zrec = zone.get(zone.size()-2);
+            for (int i = 0; i < zone.size(); i++) {
+                ZoneRec zrec = zone.get(i);
                 if ((zrec.getGmtOffset() != rawOffset)
                     && (zrec.getUntilTime(0) > Time.getCurrentTime())) {
                     if (excludeList == null) {
@@ -85,6 +85,7 @@
                     }
                     excludeList.add(zone.getName());
                     isExcluded = true;
+                    break;
                 }
             }
 
--- a/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java	Wed Oct 26 17:59:13 2011 -0700
@@ -32,6 +32,7 @@
 import java.io.OutputStream;
 import java.io.InputStream;
 import java.net.Socket;
+import javax.net.ssl.SSLSocket;
 
 import javax.naming.CommunicationException;
 import javax.naming.ServiceUnavailableException;
@@ -361,6 +362,19 @@
             }
         }
 
+        // For LDAP connect timeouts on LDAP over SSL connections must treat
+        // the SSL handshake following socket connection as part of the timeout.
+        // So explicitly set a socket read timeout, trigger the SSL handshake,
+        // then reset the timeout.
+        if (connectTimeout > 0 && socket instanceof SSLSocket) {
+            SSLSocket sslSocket = (SSLSocket) socket;
+            int socketTimeout = sslSocket.getSoTimeout();
+
+            sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value
+            sslSocket.startHandshake();
+            sslSocket.setSoTimeout(socketTimeout);
+        }
+
         return socket;
     }
 
--- a/jdk/src/share/classes/com/sun/net/httpserver/BasicAuthenticator.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/net/httpserver/BasicAuthenticator.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,13 +54,13 @@
 
     public Result authenticate (HttpExchange t)
     {
-        Headers rmap = (Headers) t.getRequestHeaders();
+        Headers rmap = t.getRequestHeaders();
         /*
          * look for auth token
          */
         String auth = rmap.getFirst ("Authorization");
         if (auth == null) {
-            Headers map = (Headers) t.getResponseHeaders();
+            Headers map = t.getResponseHeaders();
             map.set ("WWW-Authenticate", "Basic realm=" + "\""+realm+"\"");
             return new Authenticator.Retry (401);
         }
@@ -83,7 +83,7 @@
         } else {
             /* reject the request again with 401 */
 
-            Headers map = (Headers) t.getResponseHeaders();
+            Headers map = t.getResponseHeaders();
             map.set ("WWW-Authenticate", "Basic realm=" + "\""+realm+"\"");
             return new Authenticator.Failure(401);
         }
--- a/jdk/src/share/classes/com/sun/net/httpserver/Headers.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/net/httpserver/Headers.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -117,7 +117,7 @@
          * @return the first string value associated with the key
          */
         public String getFirst (String key) {
-            List<String> l = map.get(normalize((String)key));
+            List<String> l = map.get(normalize(key));
             if (l == null) {
                 return null;
             }
--- a/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,29 +81,27 @@
         if (cn == null)
             return false;
         try {
-            Class c = Class.forName(cn, true,
+            Class<?> c = Class.forName(cn, true,
                                     ClassLoader.getSystemClassLoader());
             provider = (HttpServerProvider)c.newInstance();
             return true;
-        } catch (ClassNotFoundException x) {
-            throw new ServiceConfigurationError(x);
-        } catch (IllegalAccessException x) {
-            throw new ServiceConfigurationError(x);
-        } catch (InstantiationException x) {
-            throw new ServiceConfigurationError(x);
-        } catch (SecurityException x) {
+        } catch (ClassNotFoundException |
+                 IllegalAccessException |
+                 InstantiationException |
+                 SecurityException x) {
             throw new ServiceConfigurationError(x);
         }
     }
 
     private static boolean loadProviderAsService() {
-        Iterator i = Service.providers(HttpServerProvider.class,
+        @SuppressWarnings("unchecked")
+        Iterator<HttpServerProvider> i = Service.providers(HttpServerProvider.class,
                                        ClassLoader.getSystemClassLoader());
         for (;;) {
             try {
                 if (!i.hasNext())
                     return false;
-                provider = (HttpServerProvider)i.next();
+                provider = i.next();
                 return true;
             } catch (ServiceConfigurationError sce) {
                 if (sce.getCause() instanceof SecurityException) {
--- a/jdk/src/share/classes/com/sun/net/ssl/SSLSecurity.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/net/ssl/SSLSecurity.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,7 +77,7 @@
     {
         Provider provider = service.getProvider();
         String className = service.getClassName();
-        Class implClass;
+        Class<?> implClass;
         try {
             ClassLoader cl = provider.getClass().getClassLoader();
             if (cl == null) {
@@ -133,8 +133,8 @@
              * or someone has removed classes from the jsse.jar file.
              */
 
-            Class typeClassJavax;
-            Class typeClassCom;
+            Class<?> typeClassJavax;
+            Class<?> typeClassCom;
             Object obj = null;
 
             /*
@@ -237,7 +237,7 @@
     /*
      * Checks whether one class is the superclass of another
      */
-    private static boolean checkSuperclass(Class subclass, Class superclass) {
+    private static boolean checkSuperclass(Class<?> subclass, Class<?> superclass) {
         if ((subclass == null) || (superclass == null))
                 return false;
 
@@ -276,7 +276,6 @@
  * object.  This also mean that anything going down into the SPI
  * needs to be wrapped, as well as anything coming back up.
  */
-
 final class SSLContextSpiWrapper extends SSLContextSpi {
 
     private javax.net.ssl.SSLContext theSSLContext;
--- a/jdk/src/share/classes/com/sun/net/ssl/internal/www/protocol/https/DelegateHttpsURLConnection.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/net/ssl/internal/www/protocol/https/DelegateHttpsURLConnection.java	Wed Oct 26 17:59:13 2011 -0700
@@ -165,10 +165,10 @@
     private static String getServername(X509Certificate peerCert) {
         try {
             // compare to subjectAltNames if dnsName is present
-            Collection subjAltNames = peerCert.getSubjectAlternativeNames();
+            Collection<List<?>> subjAltNames = peerCert.getSubjectAlternativeNames();
             if (subjAltNames != null) {
-                for (Iterator itr = subjAltNames.iterator(); itr.hasNext(); ) {
-                    List next = (List)itr.next();
+                for (Iterator<List<?>> itr = subjAltNames.iterator(); itr.hasNext(); ) {
+                    List<?> next = itr.next();
                     if (((Integer)next.get(0)).intValue() == 2) {
                         // compare dNSName with host in url
                         String dnsName = ((String)next.get(1));
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java	Wed Oct 26 17:59:13 2011 -0700
@@ -115,9 +115,9 @@
             // provider mechanism instead if implementing their own
             // transform or canonicalization algorithms.
             // InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml");
-            InputStream is = (InputStream) AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public Object run() {
+            InputStream is = AccessController.doPrivileged(
+                new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
 //                        String cfile = System.getProperty
 //                            ("com.sun.org.apache.xml.internal.security.resource.config");
                         return getClass().getResourceAsStream
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java	Wed Oct 26 17:59:13 2011 -0700
@@ -45,9 +45,9 @@
 
 
 
-   private static Map uriToJCEName;
+   private static Map<String, String> uriToJCEName;
 
-   private static Map algorithmsMap;
+   private static Map<String, Algorithm> algorithmsMap;
 
    private static String providerName = null;
    /**
@@ -63,8 +63,8 @@
 
    static void loadAlgorithms( Element algorithmsEl) {
        Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm");
-       uriToJCEName = new HashMap( algorithms.length * 2);
-       algorithmsMap = new HashMap( algorithms.length * 2);
+       uriToJCEName = new HashMap<String, String>( algorithms.length * 2);
+       algorithmsMap = new HashMap<String, Algorithm>( algorithms.length * 2);
        for (int i = 0 ;i < algorithms.length ;i ++) {
            Element el = algorithms[i];
            String id = el.getAttribute("URI");
@@ -76,7 +76,7 @@
    }
 
    static Algorithm getAlgorithmMapping(String algoURI) {
-           return ((Algorithm)algorithmsMap.get(algoURI));
+           return algorithmsMap.get(algoURI);
    }
 
    /**
@@ -90,7 +90,7 @@
       if (log.isLoggable(java.util.logging.Level.FINE))
           log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
 
-      String jceName = (String) uriToJCEName.get(AlgorithmURI);
+      String jceName = uriToJCEName.get(AlgorithmURI);
       return jceName;
    }
 
@@ -106,7 +106,7 @@
        if (log.isLoggable(java.util.logging.Level.FINE))
            log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
 
-       return ((Algorithm) algorithmsMap.get(AlgorithmURI)).algorithmClass;
+       return (algorithmsMap.get(AlgorithmURI)).algorithmClass;
    }
 
    /**
@@ -116,7 +116,7 @@
     * @return The length of the key used in the alogrithm
     */
    public static int getKeyLengthFromURI(String AlgorithmURI) {
-       return Integer.parseInt(((Algorithm) algorithmsMap.get(AlgorithmURI)).keyLength);
+       return Integer.parseInt((algorithmsMap.get(AlgorithmURI)).keyLength);
    }
 
    /**
@@ -128,7 +128,7 @@
     */
    public static String getJCEKeyAlgorithmFromURI(String AlgorithmURI) {
 
-        return  ((Algorithm) algorithmsMap.get(AlgorithmURI)).requiredKey;
+        return  (algorithmsMap.get(AlgorithmURI)).requiredKey;
 
    }
 
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java	Wed Oct 26 17:59:13 2011 -0700
@@ -71,9 +71,10 @@
       this.algorithm = messageDigest;
    }
 
-   static ThreadLocal instances=new ThreadLocal() {
-           protected Object initialValue() {
-                   return new HashMap();
+   static ThreadLocal<Map<String, MessageDigest>> instances=new
+       ThreadLocal<Map<String, MessageDigest>>() {
+           protected Map<String, MessageDigest> initialValue() {
+               return new HashMap<String, MessageDigest>();
            };
    };
 
@@ -92,7 +93,7 @@
    }
 
 private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
-        MessageDigest result=(MessageDigest) ((Map)instances.get()).get(algorithmURI);
+        MessageDigest result= instances.get().get(algorithmURI);
         if (result!=null)
                 return result;
     String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
@@ -121,7 +122,7 @@
 
         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
         }
-      ((Map)instances.get()).put(algorithmURI, md);
+        instances.get().put(algorithmURI, md);
         return md;
 }
 
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java	Wed Oct 26 17:59:13 2011 -0700
@@ -51,28 +51,28 @@
    static boolean _alreadyInitialized = false;
 
    /** All available algorithm classes are registered here */
-   static HashMap _algorithmHash = null;
+   static Map<String, Class<? extends SignatureAlgorithmSpi>> _algorithmHash = null;
 
-   static ThreadLocal instancesSigning=new ThreadLocal() {
-           protected Object initialValue() {
-                   return new HashMap();
+   static ThreadLocal<Map<String, SignatureAlgorithmSpi>> instancesSigning=new ThreadLocal<Map<String, SignatureAlgorithmSpi>>() {
+           protected Map<String, SignatureAlgorithmSpi> initialValue() {
+                   return new HashMap<String, SignatureAlgorithmSpi>();
            };
    };
 
-   static ThreadLocal instancesVerify=new ThreadLocal() {
-           protected Object initialValue() {
-                   return new HashMap();
+   static ThreadLocal<Map<String, SignatureAlgorithmSpi>> instancesVerify=new ThreadLocal<Map<String, SignatureAlgorithmSpi>>() {
+           protected Map<String, SignatureAlgorithmSpi> initialValue() {
+                   return new HashMap<String, SignatureAlgorithmSpi>();
            };
    };
 
-   static ThreadLocal keysSigning=new ThreadLocal() {
-           protected Object initialValue() {
-                   return new HashMap();
+   static ThreadLocal<Map<String, Key>> keysSigning=new ThreadLocal<Map<String, Key>>() {
+           protected Map<String, Key> initialValue() {
+                   return new HashMap<String, Key>();
            };
    };
-   static ThreadLocal keysVerify=new ThreadLocal() {
-           protected Object initialValue() {
-                   return new HashMap();
+   static ThreadLocal<Map<String, Key>> keysVerify=new ThreadLocal<Map<String, Key>>() {
+           protected Map<String, Key> initialValue() {
+                   return new HashMap<String, Key>();
            };
    };
 //   boolean isForSigning=false;
@@ -105,34 +105,34 @@
                       .engineGetContextFromElement(this._constructionElement);
    }
    private static SignatureAlgorithmSpi getInstanceForSigning(String algorithmURI) throws XMLSignatureException {
-           SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesSigning.get()).get(algorithmURI);
+           SignatureAlgorithmSpi result= instancesSigning.get().get(algorithmURI);
            if (result!=null) {
                    result.reset();
                    return result;
            }
            result=buildSigner(algorithmURI, result);
-           ((Map)instancesSigning.get()).put(algorithmURI,result);
+           instancesSigning.get().put(algorithmURI,result);
            return result;
    }
    private static SignatureAlgorithmSpi getInstanceForVerify(String algorithmURI) throws XMLSignatureException {
-           SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesVerify.get()).get(algorithmURI);
+           SignatureAlgorithmSpi result= instancesVerify.get().get(algorithmURI);
            if (result!=null) {
                    result.reset();
                    return result;
            }
            result=buildSigner(algorithmURI, result);
-           ((Map)instancesVerify.get()).put(algorithmURI,result);
+           instancesVerify.get().put(algorithmURI,result);
            return result;
    }
 
    private static SignatureAlgorithmSpi buildSigner(String algorithmURI, SignatureAlgorithmSpi result) throws XMLSignatureException {
         try {
-         Class implementingClass =
+         Class<? extends SignatureAlgorithmSpi> implementingClass =
             SignatureAlgorithm.getImplementingClass(algorithmURI);
          if (log.isLoggable(java.util.logging.Level.FINE))
                 log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
                    + implementingClass + "\"");
-         result=(SignatureAlgorithmSpi) implementingClass.newInstance();
+         result= implementingClass.newInstance();
          return   result;
       }  catch (IllegalAccessException ex) {
          Object exArgs[] = { algorithmURI, ex.getMessage() };
@@ -270,7 +270,7 @@
     */
    public void initSign(Key signingKey) throws XMLSignatureException {
            initializeAlgorithm(true);
-           Map map=(Map)keysSigning.get();
+           Map<String, Key> map=keysSigning.get();
        if (map.get(this.algorithmURI)==signingKey) {
            return;
        }
@@ -329,7 +329,7 @@
     */
    public void initVerify(Key verificationKey) throws XMLSignatureException {
            initializeAlgorithm(false);
-           Map map=(Map)keysVerify.get();
+           Map<String, Key> map=keysVerify.get();
            if (map.get(this.algorithmURI)==verificationKey) {
            return;
        }
@@ -375,7 +375,7 @@
       log.log(java.util.logging.Level.FINE, "Init() called");
 
       if (!SignatureAlgorithm._alreadyInitialized) {
-         SignatureAlgorithm._algorithmHash = new HashMap(10);
+         SignatureAlgorithm._algorithmHash = new HashMap<String, Class<? extends SignatureAlgorithmSpi>>(10);
          SignatureAlgorithm._alreadyInitialized = true;
       }
    }
@@ -388,6 +388,7 @@
     * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
     * @throws XMLSignatureException
     */
+   @SuppressWarnings("unchecked")
    public static void register(String algorithmURI, String implementingClass)
            throws AlgorithmAlreadyRegisteredException,XMLSignatureException {
 
@@ -396,7 +397,7 @@
                 log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
 
          // are we already registered?
-         Class registeredClassClass =
+         Class<? extends SignatureAlgorithmSpi> registeredClassClass =
             SignatureAlgorithm.getImplementingClass(algorithmURI);
                  if (registeredClassClass!=null) {
                          String registeredClass = registeredClassClass.getName();
@@ -409,7 +410,7 @@
                          }
                  }
                  try {
-                         SignatureAlgorithm._algorithmHash.put(algorithmURI, Class.forName(implementingClass));
+                         SignatureAlgorithm._algorithmHash.put(algorithmURI, (Class <? extends SignatureAlgorithmSpi>)Class.forName(implementingClass));
               } catch (ClassNotFoundException ex) {
                  Object exArgs[] = { algorithmURI, ex.getMessage() };
 
@@ -431,13 +432,13 @@
     * @param URI
     * @return the class that implements the URI
     */
-   private static Class getImplementingClass(String URI) {
+   private static Class<? extends SignatureAlgorithmSpi> getImplementingClass(String URI) {
 
       if (SignatureAlgorithm._algorithmHash == null) {
          return null;
       }
 
-      return (Class) SignatureAlgorithm._algorithmHash.get(URI);
+      return SignatureAlgorithm._algorithmHash.get(URI);
    }
 
    /**
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java	Wed Oct 26 17:59:13 2011 -0700
@@ -28,6 +28,7 @@
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
 
 import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
 import org.w3c.dom.Document;
@@ -83,7 +84,7 @@
         ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments";
 
     static boolean _alreadyInitialized = false;
-    static Map _canonicalizerHash = null;
+    static Map<String,Class<? extends CanonicalizerSpi>> _canonicalizerHash = null;
 
     protected CanonicalizerSpi canonicalizerSpi = null;
 
@@ -94,7 +95,7 @@
     public static void init() {
 
         if (!Canonicalizer._alreadyInitialized) {
-            Canonicalizer._canonicalizerHash = new HashMap(10);
+            Canonicalizer._canonicalizerHash = new HashMap<String, Class<? extends CanonicalizerSpi>>(10);
             Canonicalizer._alreadyInitialized = true;
         }
     }
@@ -109,10 +110,11 @@
            throws InvalidCanonicalizerException {
 
         try {
-            Class implementingClass = getImplementingClass(algorithmURI);
+            Class<? extends CanonicalizerSpi> implementingClass =
+                getImplementingClass(algorithmURI);
 
             this.canonicalizerSpi =
-                (CanonicalizerSpi) implementingClass.newInstance();
+                 implementingClass.newInstance();
             this.canonicalizerSpi.reset=true;
         } catch (Exception e) {
             Object exArgs[] = { algorithmURI };
@@ -144,11 +146,12 @@
      * @param implementingClass
      * @throws AlgorithmAlreadyRegisteredException
      */
+    @SuppressWarnings("unchecked")
     public static void register(String algorithmURI, String implementingClass)
            throws AlgorithmAlreadyRegisteredException {
 
         // check whether URI is already registered
-        Class registeredClass = getImplementingClass(algorithmURI);
+        Class<? extends CanonicalizerSpi> registeredClass = getImplementingClass(algorithmURI);
 
         if (registeredClass != null)  {
             Object exArgs[] = { algorithmURI, registeredClass };
@@ -158,7 +161,7 @@
         }
 
         try {
-            _canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
+            _canonicalizerHash.put(algorithmURI, (Class<? extends CanonicalizerSpi>) Class.forName(implementingClass));
         } catch (ClassNotFoundException e) {
             throw new RuntimeException("c14n class not found");
         }
@@ -304,7 +307,7 @@
      * @return the result of the c14n.
      * @throws CanonicalizationException
      */
-    public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet)
+    public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
            throws CanonicalizationException {
         return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
     }
@@ -317,7 +320,7 @@
      * @return the result of the c14n.
      * @throws CanonicalizationException
      */
-    public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet,
+    public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
         String inclusiveNamespaces) throws CanonicalizationException {
         return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
             inclusiveNamespaces);
@@ -347,8 +350,8 @@
      * @param URI
      * @return the name of the class that implements the given URI
      */
-    private static Class getImplementingClass(String URI) {
-        return (Class) _canonicalizerHash.get(URI);
+    private static Class<? extends CanonicalizerSpi> getImplementingClass(String URI) {
+        return _canonicalizerHash.get(URI);
     }
 
     /**
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java	Wed Oct 26 17:59:13 2011 -0700
@@ -28,6 +28,7 @@
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
 
 import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
 import org.w3c.dom.Document;
@@ -151,7 +152,7 @@
     * @return the c14n bytes
     * @throws CanonicalizationException
     */
-   public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
+   public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
       throws CanonicalizationException;
 
    /**
@@ -162,7 +163,7 @@
     * @return the c14n bytes
     * @throws CanonicalizationException
     */
-   public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces)
+   public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces)
       throws CanonicalizationException;
 
    /**
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java	Wed Oct 26 17:59:13 2011 -0700
@@ -41,7 +41,7 @@
  *
  * @author Christian Geuer-Pollmann
  */
-public class AttrCompare implements Comparator, Serializable {
+public class AttrCompare implements Comparator<Attr>, Serializable {
 
     private final static long serialVersionUID = -7113259629930576230L;
     private final static int ATTR0_BEFORE_ATTR1 = -1;
@@ -62,16 +62,14 @@
      *   key (an empty namespace URI is lexicographically least).
      * </UL>
      *
-     * @param obj0 casted Attr
-     * @param obj1 casted Attr
+     * @param attr0
+     * @param attr1
      * @return returns a negative integer, zero, or a positive integer as
      *   obj0 is less than, equal to, or greater than obj1
      *
      */
-    public int compare(Object obj0, Object obj1) {
+    public int compare(Attr attr0, Attr attr1) {
 
-        Attr attr0 = (Attr) obj0;
-        Attr attr1 = (Attr) obj1;
         String namespaceURI0 = attr0.getNamespaceURI();
         String namespaceURI1 = attr1.getNamespaceURI();
 
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java	Wed Oct 26 17:59:13 2011 -0700
@@ -25,6 +25,7 @@
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -33,6 +34,7 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -59,7 +61,7 @@
  */
 public abstract class Canonicalizer11 extends CanonicalizerBase {
     boolean firstCall = true;
-    final SortedSet result = new TreeSet(COMPARE);
+    final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
     static final String XMLNS_URI = Constants.NamespaceSpecNS;
     static final String XML_LANG_URI = Constants.XML_LANG_SPACE_SpecNS;
 
@@ -72,9 +74,9 @@
         static class XmlsStackElement {
             int level;
             boolean rendered = false;
-            List nodes = new ArrayList();
+            List<Attr> nodes = new ArrayList<Attr>();
         };
-        List levels = new ArrayList();
+        List<XmlsStackElement> levels = new ArrayList<XmlsStackElement>();
         void push(int level) {
             currentLevel = level;
             if (currentLevel == -1)
@@ -86,7 +88,7 @@
                     lastlevel = 0;
                     return;
                 }
-                lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
+                lastlevel=(levels.get(levels.size()-1)).level;
             }
         }
         void addXmlnsAttr(Attr n) {
@@ -98,7 +100,7 @@
             }
             cur.nodes.add(n);
         }
-        void getXmlnsAttr(Collection col) {
+        void getXmlnsAttr(Collection<Attr> col) {
             if (cur == null) {
                 cur = new XmlsStackElement();
                 cur.level = currentLevel;
@@ -111,7 +113,7 @@
             if (size == -1) {
                 parentRendered = true;
             } else {
-                e = (XmlsStackElement) levels.get(size);
+                e = levels.get(size);
                 if (e.rendered && e.level+1 == currentLevel)
                     parentRendered = true;
             }
@@ -121,17 +123,17 @@
                 return;
             }
 
-            Map loa = new HashMap();
-            List baseAttrs = new ArrayList();
+            Map<String, Attr> loa = new HashMap<String, Attr>();
+            List<Attr> baseAttrs = new ArrayList<Attr>();
             boolean successiveOmitted = true;
             for (;size>=0;size--) {
-                e = (XmlsStackElement) levels.get(size);
+                e = levels.get(size);
                 if (e.rendered) {
                     successiveOmitted = false;
                 }
-                Iterator it = e.nodes.iterator();
+                Iterator<Attr> it = e.nodes.iterator();
                 while (it.hasNext() && successiveOmitted) {
-                    Attr n = (Attr) it.next();
+                    Attr n = it.next();
                     if (n.getLocalName().equals("base")) {
                         if (!e.rendered) {
                             baseAttrs.add(n);
@@ -141,11 +143,11 @@
                 }
             }
             if (!baseAttrs.isEmpty()) {
-                Iterator it = cur.nodes.iterator();
+                Iterator<Attr> it = cur.nodes.iterator();
                 String base = null;
                 Attr baseAttr = null;
                 while (it.hasNext()) {
-                    Attr n = (Attr) it.next();
+                    Attr n = it.next();
                     if (n.getLocalName().equals("base")) {
                         base = n.getValue();
                         baseAttr = n;
@@ -154,7 +156,7 @@
                 }
                 it = baseAttrs.iterator();
                 while (it.hasNext()) {
-                    Attr n = (Attr) it.next();
+                    Attr n = it.next();
                     if (base == null) {
                         base = n.getValue();
                         baseAttr = n;
@@ -202,13 +204,13 @@
      * @return the Attr[]s to be outputted
      * @throws CanonicalizationException
      */
-    Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
+    Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
         throws CanonicalizationException {
         if (!E.hasAttributes() && !firstCall) {
             return null;
         }
         // result will contain the attrs which have to be outputted
-        final SortedSet result = this.result;
+        final SortedSet<Attr> result = this.result;
         result.clear();
         NamedNodeMap attrs = E.getAttributes();
         int attrsLength = attrs.getLength();
@@ -236,7 +238,7 @@
 
             if (n != null) {
                 // Render the ns definition
-                result.add(n);
+                result.add((Attr)n);
                 if (C14nHelper.namespaceIsRelative(N)) {
                     Object exArgs[] = {E.getTagName(), NName, N.getNodeValue()};
                     throw new CanonicalizationException(
@@ -251,13 +253,15 @@
             // to the output.
             ns.getUnrenderedNodes(result);
             // output the attributes in the xml namespace.
-            xmlattrStack.getXmlnsAttr(result);
+            xmlattrStack.getXmlnsAttr(getSortedSetAsCollection(result));
             firstCall = false;
         }
 
         return result.iterator();
     }
 
+
+
     /**
      * Returns the Attr[]s to be outputted for the given element.
      * <br>
@@ -271,7 +275,7 @@
      * @return the Attr[]s to be outputted
      * @throws CanonicalizationException
      */
-    Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
+    Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns)
         throws CanonicalizationException {
         // result will contain the attrs which have to be output
         xmlattrStack.push(ns.getLevel());
@@ -283,11 +287,11 @@
             attrsLength = attrs.getLength();
         }
 
-        SortedSet result = this.result;
+        SortedSet<Attr> result = this.result;
         result.clear();
 
         for (int i = 0; i < attrsLength; i++) {
-            Attr N = (Attr) attrs.item(i);
+            Attr N = (Attr)attrs.item(i);
             String NUri = N.getNamespaceURI();
 
             if (XMLNS_URI != NUri) {
@@ -332,7 +336,7 @@
                 //      (NName, NValue, N, isRealVisible);
                 Node n = ns.addMappingAndRender(NName, NValue, N);
                 if (n != null) {
-                    result.add(n);
+                    result.add((Attr)n);
                     if (C14nHelper.namespaceIsRelative(N)) {
                         Object exArgs[] =
                             { E.getTagName(), NName, N.getNodeValue() };
@@ -362,7 +366,7 @@
             }
             // output the xmlns def if needed.
             if (n != null) {
-                result.add(n);
+                result.add((Attr)n);
             }
             // Float all xml:* attributes of the unselected parent elements to
             // this one. addXmlAttributes(E,result);
@@ -381,7 +385,7 @@
      * @return none it always fails
      * @throws CanonicalizationException always
      */
-    public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
+    public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
         String inclusiveNamespaces) throws CanonicalizationException {
         throw new CanonicalizationException(
          "c14n.Canonicalizer.UnsupportedOperation");
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java	Wed Oct 26 17:59:13 2011 -0700
@@ -57,7 +57,7 @@
  */
 public abstract class Canonicalizer20010315 extends CanonicalizerBase {
         boolean firstCall=true;
-        final SortedSet result= new TreeSet(COMPARE);
+        final SortedSet<Attr> result= new TreeSet<Attr>(COMPARE);
     static final String XMLNS_URI=Constants.NamespaceSpecNS;
     static final String XML_LANG_URI=Constants.XML_LANG_SPACE_SpecNS;
     static class XmlAttrStack {
@@ -67,9 +67,9 @@
         static class XmlsStackElement {
                 int level;
                 boolean rendered=false;
-                List nodes=new ArrayList();
+                List<Attr> nodes=new ArrayList<Attr>();
         };
-        List levels=new ArrayList();
+        List<XmlsStackElement> levels=new ArrayList<XmlsStackElement>();
         void push(int level) {
                 currentLevel=level;
                 if (currentLevel==-1)
@@ -81,7 +81,7 @@
                                 lastlevel=0;
                                 return;
                         }
-                        lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
+                        lastlevel=(levels.get(levels.size()-1)).level;
                 }
         }
         void addXmlnsAttr(Attr n) {
@@ -93,7 +93,7 @@
                 }
                 cur.nodes.add(n);
         }
-        void getXmlnsAttr(Collection col) {
+        void getXmlnsAttr(Collection<Attr> col) {
                 int size=levels.size()-1;
                 if (cur==null) {
                         cur=new XmlsStackElement();
@@ -106,7 +106,7 @@
                 if (size==-1) {
                         parentRendered=true;
                 } else {
-                        e=(XmlsStackElement)levels.get(size);
+                        e=levels.get(size);
                         if (e.rendered && e.level+1==currentLevel)
                                 parentRendered=true;
 
@@ -117,12 +117,12 @@
                                 return;
                         }
 
-                        Map loa = new HashMap();
+                        Map<String,Attr> loa = new HashMap<String,Attr>();
                 for (;size>=0;size--) {
-                        e=(XmlsStackElement)levels.get(size);
-                        Iterator it=e.nodes.iterator();
+                        e=levels.get(size);
+                        Iterator<Attr> it=e.nodes.iterator();
                         while (it.hasNext()) {
-                                Attr n=(Attr)it.next();
+                                Attr n=it.next();
                                 if (!loa.containsKey(n.getName()))
                                         loa.put(n.getName(),n);
                         }
@@ -161,13 +161,13 @@
     * @return the Attr[]s to be outputted
     * @throws CanonicalizationException
     */
-   Iterator handleAttributesSubtree(Element E,  NameSpaceSymbTable ns )
+   Iterator<Attr> handleAttributesSubtree(Element E,  NameSpaceSymbTable ns )
            throws CanonicalizationException {
           if (!E.hasAttributes() && !firstCall) {
          return null;
       }
       // result will contain the attrs which have to be outputted
-      final SortedSet result = this.result;
+      final SortedSet<Attr> result = this.result;
       result.clear();
       NamedNodeMap attrs = E.getAttributes();
       int attrsLength = attrs.getLength();
@@ -194,7 +194,7 @@
 
           if (n!=null) {
                  //Render the ns definition
-             result.add(n);
+             result.add((Attr)n);
              if (C14nHelper.namespaceIsRelative(N)) {
                 Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
                 throw new CanonicalizationException(
@@ -206,7 +206,7 @@
       if (firstCall) {
         //It is the first node of the subtree
         //Obtain all the namespaces defined in the parents, and added to the output.
-        ns.getUnrenderedNodes(result);
+        ns.getUnrenderedNodes(getSortedSetAsCollection(result));
         //output the attributes in the xml namespace.
         xmlattrStack.getXmlnsAttr(result);
                 firstCall=false;
@@ -227,7 +227,7 @@
     * @return the Attr[]s to be outputted
     * @throws CanonicalizationException
     */
-   Iterator handleAttributes(Element E,  NameSpaceSymbTable ns ) throws CanonicalizationException {
+   Iterator<Attr> handleAttributes(Element E,  NameSpaceSymbTable ns ) throws CanonicalizationException {
     // result will contain the attrs which have to be outputted
         xmlattrStack.push(ns.getLevel());
     boolean isRealVisible=isVisibleDO(E,ns.getLevel())==1;
@@ -239,7 +239,7 @@
     }
 
 
-    SortedSet result = this.result;
+    SortedSet<Attr> result = this.result;
     result.clear();
 
     for (int i = 0; i < attrsLength; i++) {
@@ -277,7 +277,7 @@
                 //Node n=ns.addMappingAndRenderXNodeSet(NName,NValue,N,isRealVisible);
                 Node n=ns.addMappingAndRender(NName,NValue,N);
                         if (n!=null) {
-                                        result.add(n);
+                                        result.add((Attr)n);
                     if (C14nHelper.namespaceIsRelative(N)) {
                        Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
                        throw new CanonicalizationException(
@@ -306,12 +306,12 @@
         }
         //output the xmlns def if needed.
         if (n!=null) {
-                        result.add(n);
+                        result.add((Attr)n);
         }
         //Float all xml:* attributes of the unselected parent elements to this one.
         //addXmlAttributes(E,result);
         xmlattrStack.getXmlnsAttr(result);
-        ns.getUnrenderedNodes(result);
+        ns.getUnrenderedNodes(getSortedSetAsCollection(result));
 
     }
 
@@ -325,7 +325,7 @@
     * @return none it always fails
     * @throws CanonicalizationException always
     */
-   public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces)
+   public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces)
            throws CanonicalizationException {
 
       /** $todo$ well, should we throw UnsupportedOperationException ? */
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -61,9 +61,9 @@
       * This Set contains the names (Strings like "xmlns" or "xmlns:foo") of
       * the inclusive namespaces.
       */
-    TreeSet _inclusiveNSSet = new TreeSet();
+    TreeSet<String> _inclusiveNSSet = new TreeSet<String>();
     static final String XMLNS_URI=Constants.NamespaceSpecNS;
-    final SortedSet result = new TreeSet(COMPARE);
+    final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
         /**
          * Constructor Canonicalizer20010315Excl
          *
@@ -106,8 +106,7 @@
          */
         public byte[] engineCanonicalizeSubTree(Node rootNode,
                         String inclusiveNamespaces,Node excl) throws CanonicalizationException {
-                        this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
-                                        .prefixStr2Set(inclusiveNamespaces);
+                        this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
                         return super.engineCanonicalizeSubTree(rootNode,excl);
         }
         /**
@@ -117,10 +116,10 @@
          * @return the rootNode c14n.
          * @throws CanonicalizationException
          */
+        @SuppressWarnings("unchecked")
         public byte[] engineCanonicalize(XMLSignatureInput rootNode,
                         String inclusiveNamespaces) throws CanonicalizationException {
-                        this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
-                                        .prefixStr2Set(inclusiveNamespaces);
+                        this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
                         return super.engineCanonicalize(rootNode);
         }
 
@@ -130,12 +129,12 @@
          * @param E
          * @throws CanonicalizationException
          */
-        Iterator handleAttributesSubtree(Element E,NameSpaceSymbTable ns)
+        Iterator<Attr> handleAttributesSubtree(Element E,NameSpaceSymbTable ns)
                         throws CanonicalizationException {
                 // System.out.println("During the traversal, I encountered " +
                 // XMLUtils.getXPath(E));
                 // result will contain the attrs which have to be outputted
-                SortedSet result = this.result;
+                SortedSet<Attr> result = this.result;
             result.clear();
                 NamedNodeMap attrs=null;
 
@@ -145,7 +144,7 @@
                 attrsLength = attrs.getLength();
         }
                 //The prefix visibly utilized(in the attribute or in the name) in the element
-                SortedSet visiblyUtilized =(SortedSet) _inclusiveNSSet.clone();
+                SortedSet<String> visiblyUtilized = getNSSetClone();
 
                 for (int i = 0; i < attrsLength; i++) {
                         Attr N = (Attr) attrs.item(i);
@@ -187,9 +186,9 @@
                 visiblyUtilized.add(prefix);
 
                 //This can be optimezed by I don't have time
-                Iterator it=visiblyUtilized.iterator();
+                Iterator<String> it=visiblyUtilized.iterator();
                 while (it.hasNext()) {
-                        String s=(String)it.next();
+                        String s=it.next();
                         Attr key=ns.getMapping(s);
                         if (key==null) {
                                 continue;
@@ -207,25 +206,35 @@
          * @param inclusiveNamespaces
          * @throws CanonicalizationException
          */
-        public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
+        public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
                         String inclusiveNamespaces) throws CanonicalizationException {
 
-
-                        this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
-                                        .prefixStr2Set(inclusiveNamespaces);
+                        this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
                         return super.engineCanonicalizeXPathNodeSet(xpathNodeSet);
 
         }
 
+    @SuppressWarnings("unchecked")
+    private TreeSet<String> getInclusiveNameSpace(String inclusiveNameSpaces) {
+        return (TreeSet<String>)InclusiveNamespaces.prefixStr2Set(inclusiveNameSpaces);
+    }
+
+
+    @SuppressWarnings("unchecked")
+    private SortedSet<String> getNSSetClone() {
+        return (SortedSet<String>) this._inclusiveNSSet.clone();
+    }
+
+
         /**
      * @inheritDoc
          * @param E
          * @throws CanonicalizationException
          */
-        final Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
+        final Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns)
                         throws CanonicalizationException {
                 // result will contain the attrs which have to be outputted
-                SortedSet result = this.result;
+                SortedSet<Attr> result = this.result;
             result.clear();
                 NamedNodeMap attrs = null;
                 int attrsLength = 0;
@@ -234,11 +243,11 @@
                 attrsLength = attrs.getLength();
         }
                 //The prefix visibly utilized(in the attribute or in the name) in the element
-                Set visiblyUtilized =null;
+                Set<String> visiblyUtilized =null;
                 //It's the output selected.
                 boolean isOutputElement=isVisibleDO(E,ns.getLevel())==1;
                 if (isOutputElement) {
-                        visiblyUtilized =  (Set) this._inclusiveNSSet.clone();
+                        visiblyUtilized =  getNSSetClone();
                 }
 
                 for (int i = 0; i < attrsLength; i++) {
@@ -272,7 +281,7 @@
                         if (!isOutputElement && isVisible(N) && _inclusiveNSSet.contains(NName) && !ns.removeMappingIfRender(NName)) {
                                 Node n=ns.addMappingAndRender(NName,NNodeValue,N);
                                 if (n!=null) {
-                                                result.add(n);
+                                                result.add((Attr)n);
                             if (C14nHelper.namespaceIsRelative(N)) {
                                Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
                                throw new CanonicalizationException(
@@ -315,9 +324,9 @@
                         }
                         //This can be optimezed by I don't have time
                         //visiblyUtilized.addAll(this._inclusiveNSSet);
-                        Iterator it=visiblyUtilized.iterator();
+                        Iterator<String> it=visiblyUtilized.iterator();
                         while (it.hasNext()) {
-                                String s=(String)it.next();
+                                String s=it.next();
                                 Attr key=ns.getMapping(s);
                                 if (key==null) {
                                         continue;
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java	Wed Oct 26 17:59:13 2011 -0700
@@ -33,9 +33,12 @@
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.SortedSet;
+import java.util.Collection;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
 
 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizerSpi;
@@ -94,10 +97,10 @@
     }
    }
 
-   List nodeFilter;
+   List<NodeFilter> nodeFilter;
 
    boolean _includeComments;
-   Set _xpathNodeSet = null;
+   Set<Node> _xpathNodeSet = null;
    /**
     * The node to be skiped/excluded from the DOM tree
     * in subtree canonicalizations.
@@ -130,7 +133,7 @@
     * @param xpathNodeSet
     * @throws CanonicalizationException
     */
-   public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
+   public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
            throws CanonicalizationException {
            this._xpathNodeSet = xpathNodeSet;
            return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
@@ -251,7 +254,7 @@
         final OutputStream writer=this._writer;
         final Node excludeNode=this._excludeNode;
         final boolean includeComments=this._includeComments;
-        Map cache=new HashMap();
+        Map<String, byte[]> cache=new HashMap<String, byte[]>();
         do {
                 switch (currentNode.getNodeType()) {
 
@@ -298,11 +301,11 @@
                         String name=currentElement.getTagName();
                         UtfHelpper.writeByte(name,writer,cache);
 
-                        Iterator attrs = this.handleAttributesSubtree(currentElement,ns);
+                        Iterator<Attr> attrs = this.handleAttributesSubtree(currentElement,ns);
                         if (attrs!=null) {
                                 //we output all Attrs which are available
                                 while (attrs.hasNext()) {
-                                        Attr attr = (Attr) attrs.next();
+                                        Attr attr = attrs.next();
                                         outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
                                 }
                         }
@@ -394,7 +397,7 @@
         Node parentNode=null;
         OutputStream writer=this._writer;
         int documentLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
-        Map cache=new HashMap();
+        Map<String, byte[]> cache=new HashMap<String,byte[]>();
         do {
                 switch (currentNode.getNodeType()) {
 
@@ -464,11 +467,11 @@
                                 ns.push();
                         }
 
-                        Iterator attrs = handleAttributes(currentElement,ns);
+                        Iterator<Attr> attrs = handleAttributes(currentElement,ns);
                         if (attrs!=null) {
                                 //we output all Attrs which are available
                                 while (attrs.hasNext()) {
-                                        Attr attr = (Attr) attrs.next();
+                                        Attr attr = attrs.next();
                                         outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
                                 }
                         }
@@ -522,9 +525,9 @@
    }
    int isVisibleDO(Node currentNode,int level) {
            if (nodeFilter!=null) {
-                        Iterator it=nodeFilter.iterator();
+                        Iterator<NodeFilter> it=nodeFilter.iterator();
                         while (it.hasNext()) {
-                                int i=((NodeFilter)it.next()).isNodeIncludeDO(currentNode,level);
+                                int i=(it.next()).isNodeIncludeDO(currentNode,level);
                                 if (i!=1)
                                         return i;
                         }
@@ -535,9 +538,9 @@
    }
    int isVisibleInt(Node currentNode) {
            if (nodeFilter!=null) {
-                Iterator it=nodeFilter.iterator();
+                Iterator<NodeFilter> it=nodeFilter.iterator();
                 while (it.hasNext()) {
-                        int i=((NodeFilter)it.next()).isNodeInclude(currentNode);
+                        int i=(it.next()).isNodeInclude(currentNode);
                         if (i!=1)
                                 return i;
                 }
@@ -549,9 +552,9 @@
 
    boolean isVisible(Node currentNode) {
            if (nodeFilter!=null) {
-                Iterator it=nodeFilter.iterator();
+                Iterator<NodeFilter> it=nodeFilter.iterator();
                 while (it.hasNext()) {
-                        if (((NodeFilter)it.next()).isNodeInclude(currentNode)!=1)
+                        if ((it.next()).isNodeInclude(currentNode)!=1)
                                 return false;
                 }
            }
@@ -589,7 +592,7 @@
          * @param ns
          */
         final void getParentNameSpaces(Element el,NameSpaceSymbTable ns)  {
-                List parents=new ArrayList(10);
+                List<Element> parents=new ArrayList<Element>(10);
                 Node n1=el.getParentNode();
                 if (!(n1 instanceof Element)) {
                         return;
@@ -605,9 +608,9 @@
                         parent=(Element)n;
                 }
                 //Visit them in reverse order.
-                ListIterator it=parents.listIterator(parents.size());
+                ListIterator<Element> it=parents.listIterator(parents.size());
                 while (it.hasPrevious()) {
-                        Element ele=(Element)it.previous();
+                        Element ele=it.previous();
                         handleParent(ele, ns);
         }
         Attr nsprefix;
@@ -624,7 +627,7 @@
         * @return the attributes nodes to output.
     * @throws CanonicalizationException
     */
-   abstract Iterator handleAttributes(Element E, NameSpaceSymbTable ns )
+   abstract Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns )
    throws CanonicalizationException;
 
    /**
@@ -635,7 +638,7 @@
         * @return the attributes nodes to output.
     * @throws CanonicalizationException
     */
-   abstract Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
+   abstract Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
    throws CanonicalizationException;
 
    abstract void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException;
@@ -660,7 +663,7 @@
             * @throws IOException
             */
            static final void outputAttrToWriter(final String name, final String value, final OutputStream writer,
-                                final Map cache) throws IOException {
+                                final Map<String, byte[]> cache) throws IOException {
               writer.write(' ');
               UtfHelpper.writeByte(name,writer,cache);
               writer.write(equalsStr);
@@ -841,4 +844,10 @@
               }
            }
 
+    @SuppressWarnings("unchecked")
+    protected Collection<Attr> getSortedSetAsCollection(SortedSet<Attr> result) {
+        return (Collection<Attr>)(Collection)result;
+    }
+
+
 }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java	Wed Oct 26 17:59:13 2011 -0700
@@ -44,7 +44,7 @@
         /**The level of nameSpaces (for Inclusive visibility).*/
         int nameSpaces=0;
         /**The stacks for removing the definitions when doing pop.*/
-        List level;
+        List<SymbMap> level;
     boolean cloned=true;
         static final String XMLNS="xmlns";
         final static SymbMap initialMap=new SymbMap();
@@ -57,7 +57,7 @@
      * Default constractor
      **/
     public NameSpaceSymbTable() {
-        level = new ArrayList(10);
+        level = new ArrayList<SymbMap>(10);
         //Insert the default binding for xmlns.
         symb=(SymbMap) initialMap.clone();
     }
@@ -67,11 +67,11 @@
          * For Inclusive rendering
      * @param result the list where to fill the unrendered xmlns definitions.
          **/
-        public  void getUnrenderedNodes(Collection result) {
+        public  void getUnrenderedNodes(Collection<Attr> result) {
            //List result=new ArrayList();
-           Iterator it=symb.entrySet().iterator();
+           Iterator<NameSpaceSymbEntry> it=symb.entrySet().iterator();
            while (it.hasNext()) {
-                        NameSpaceSymbEntry n=(NameSpaceSymbEntry)(it.next());
+                        NameSpaceSymbEntry n= it.next();
                         //put them rendered?
                         if ((!n.rendered) && (n.n!=null)) {
                                 n=(NameSpaceSymbEntry) n.clone();
@@ -339,8 +339,8 @@
         }
     }
 
-    List entrySet() {
-        List a=new ArrayList();
+    List<NameSpaceSymbEntry> entrySet() {
+        List<NameSpaceSymbEntry> a=new ArrayList<NameSpaceSymbEntry>();
         for (int i=0;i<entries.length;i++) {
                 if ((entries[i]!=null) && !("".equals(entries[i].uri))) {
                         a.add(entries[i]);
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java	Wed Oct 26 17:59:13 2011 -0700
@@ -6,8 +6,8 @@
 
 public class UtfHelpper {
 
-        final static void writeByte(final String str,final OutputStream out,Map cache) throws IOException {
-                   byte []result=(byte[]) cache.get(str);
+        final static void writeByte(final String str,final OutputStream out,Map<String,byte[]> cache) throws IOException {
+                   byte []result= cache.get(str);
                    if (result==null) {
                            result=getStringInUtf8(str);
                            cache.put(str,result);
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/AgreementMethod.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/AgreementMethod.java	Wed Oct 26 17:59:13 2011 -0700
@@ -95,7 +95,7 @@
      * Returns aditional information regarding the <code>AgreementMethod</code>.
      * @return
      */
-    Iterator getAgreementMethodInformation();
+    Iterator<Element> getAgreementMethodInformation();
 
     /**
      * Adds additional <code>AgreementMethod</code> information.
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionMethod.java	Wed Oct 26 17:59:13 2011 -0700
@@ -89,7 +89,7 @@
      * @return an <code>Iterator</code> over all the additional infomation
      *   about the <code>EncryptionMethod</code>.
      */
-    Iterator getEncryptionMethodInformation();
+    Iterator<Element> getEncryptionMethodInformation();
 
     /**
      * Adds encryption method information.
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java	Wed Oct 26 17:59:13 2011 -0700
@@ -67,7 +67,7 @@
      *
      * @return an <code>Iterator</code> over all the encryption properties.
      */
-    Iterator getEncryptionProperties();
+    Iterator<EncryptionProperty> getEncryptionProperties();
 
     /**
      * Adds an <code>EncryptionProperty</code>.
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperty.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperty.java	Wed Oct 26 17:59:13 2011 -0700
@@ -101,7 +101,7 @@
      * @return an <code>Iterator</code> over all the addiitonal encryption
      *   information contained in this class.
      */
-    Iterator getEncryptionInformation();
+    Iterator<Element> getEncryptionInformation();
 
     /**
      * Adds encryption information.
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/Reference.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/Reference.java	Wed Oct 26 17:59:13 2011 -0700
@@ -74,7 +74,7 @@
      *
      * @return child elements.
      */
-    Iterator getElementRetrievalInformation();
+    Iterator<Element> getElementRetrievalInformation();
 
     /**
      * Adds retrieval information.
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/ReferenceList.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/ReferenceList.java	Wed Oct 26 17:59:13 2011 -0700
@@ -87,7 +87,7 @@
      *
      * @return Iterator.
      */
-    public Iterator getReferences();
+    public Iterator<Reference> getReferences();
 
     /**
      * <code>DataReference</code> factory method. Returns a
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java	Wed Oct 26 17:59:13 2011 -0700
@@ -2772,7 +2772,7 @@
         // </complexType>
         private class AgreementMethodImpl implements AgreementMethod {
             private byte[] kaNonce = null;
-            private List agreementMethodInformation = null;
+            private List<Element> agreementMethodInformation = null;
             private KeyInfo originatorKeyInfo = null;
             private KeyInfo recipientKeyInfo = null;
             private String algorithmURI = null;
@@ -2781,7 +2781,7 @@
              * @param algorithm
              */
             public AgreementMethodImpl(String algorithm) {
-                agreementMethodInformation = new LinkedList();
+                agreementMethodInformation = new LinkedList<Element>();
                 URI tmpAlgorithm = null;
                 try {
                     tmpAlgorithm = new URI(algorithm);
@@ -2802,7 +2802,7 @@
             }
 
             /** @inheritDoc */
-            public Iterator getAgreementMethodInformation() {
+            public Iterator<Element> getAgreementMethodInformation() {
                 return (agreementMethodInformation.iterator());
             }
 
@@ -2879,9 +2879,9 @@
                             _contextDocument.createTextNode(new String(kaNonce)));
                 }
                 if (!agreementMethodInformation.isEmpty()) {
-                    Iterator itr = agreementMethodInformation.iterator();
+                    Iterator<Element> itr = agreementMethodInformation.iterator();
                     while (itr.hasNext()) {
-                        result.appendChild((Element) itr.next());
+                        result.appendChild(itr.next());
                     }
                 }
                 if (null != originatorKeyInfo) {
@@ -3486,7 +3486,7 @@
             private String algorithm = null;
             private int keySize = Integer.MIN_VALUE;
             private byte[] oaepParams = null;
-            private List encryptionMethodInformation = null;
+            private List<Element> encryptionMethodInformation = null;
             /**
              *
              * @param algorithm
@@ -3499,7 +3499,7 @@
                     // complain
                 }
                 this.algorithm = tmpAlgorithm.toString();
-                encryptionMethodInformation = new LinkedList();
+                encryptionMethodInformation = new LinkedList<Element>();
             }
             /** @inheritDoc */
             public String getAlgorithm() {
@@ -3522,7 +3522,7 @@
                 oaepParams = params;
             }
             /** @inheritDoc */
-            public Iterator getEncryptionMethodInformation() {
+            public Iterator<Element> getEncryptionMethodInformation() {
                 return (encryptionMethodInformation.iterator());
             }
             /** @inheritDoc */
@@ -3565,8 +3565,8 @@
                                 new String(oaepParams))));
                 }
                 if (!encryptionMethodInformation.isEmpty()) {
-                    Iterator itr = encryptionMethodInformation.iterator();
-                    result.appendChild((Element) itr.next());
+                    Iterator<Element> itr = encryptionMethodInformation.iterator();
+                    result.appendChild(itr.next());
                 }
 
                 return (result);
@@ -3582,13 +3582,13 @@
         // </complexType>
         private class EncryptionPropertiesImpl implements EncryptionProperties {
             private String id = null;
-            private List encryptionProperties = null;
+            private List<EncryptionProperty> encryptionProperties = null;
             /**
              *
              *
              */
             public EncryptionPropertiesImpl() {
-                encryptionProperties = new LinkedList();
+                encryptionProperties = new LinkedList<EncryptionProperty>();
             }
             /** @inheritDoc */
             public String getId() {
@@ -3599,7 +3599,7 @@
                 this.id = id;
             }
             /** @inheritDoc */
-            public Iterator getEncryptionProperties() {
+            public Iterator<EncryptionProperty> getEncryptionProperties() {
                 return (encryptionProperties.iterator());
             }
             /** @inheritDoc */
@@ -3625,7 +3625,7 @@
                 if (null != id) {
                     result.setAttributeNS(null, EncryptionConstants._ATT_ID, id);
                 }
-                Iterator itr = getEncryptionProperties();
+                Iterator<EncryptionProperty> itr = getEncryptionProperties();
                 while (itr.hasNext()) {
                     result.appendChild(((EncryptionPropertyImpl)
                         itr.next()).toElement());
@@ -3647,15 +3647,15 @@
         private class EncryptionPropertyImpl implements EncryptionProperty {
             private String target = null;
             private String id = null;
-            private HashMap attributeMap = new HashMap();
-            private List encryptionInformation = null;
+            private HashMap<String,String> attributeMap = new HashMap<String,String>();
+            private List<Element> encryptionInformation = null;
 
             /**
              *
              *
              */
             public EncryptionPropertyImpl() {
-                encryptionInformation = new LinkedList();
+                encryptionInformation = new LinkedList<Element>();
             }
             /** @inheritDoc */
             public String getTarget() {
@@ -3692,14 +3692,14 @@
             }
             /** @inheritDoc */
             public String getAttribute(String attribute) {
-                return (String) attributeMap.get(attribute);
+                return attributeMap.get(attribute);
             }
             /** @inheritDoc */
             public void setAttribute(String attribute, String value) {
                 attributeMap.put(attribute, value);
             }
             /** @inheritDoc */
-            public Iterator getEncryptionInformation() {
+            public Iterator<Element> getEncryptionInformation() {
                 return (encryptionInformation.iterator());
             }
             /** @inheritDoc */
@@ -3821,8 +3821,8 @@
         //    </complexType>
         //</element>
         private class ReferenceListImpl implements ReferenceList {
-            private Class sentry;
-            private List references;
+            private Class<?> sentry;
+            private List<Reference> references;
             /**
              *
              * @param type
@@ -3835,7 +3835,7 @@
                 } else {
                     throw new IllegalArgumentException();
                 }
-                references = new LinkedList();
+                references = new LinkedList<Reference>();
             }
             /** @inheritDoc */
             public void add(Reference reference) {
@@ -3860,7 +3860,7 @@
                 return (references.isEmpty());
             }
             /** @inheritDoc */
-            public Iterator getReferences() {
+            public Iterator<Reference> getReferences() {
                 return (references.iterator());
             }
 
@@ -3869,9 +3869,9 @@
                     _contextDocument,
                     EncryptionConstants.EncryptionSpecNS,
                     EncryptionConstants._TAG_REFERENCELIST);
-                Iterator eachReference = references.iterator();
+                Iterator<Reference> eachReference = references.iterator();
                 while (eachReference.hasNext()) {
-                    Reference reference = (Reference) eachReference.next();
+                    Reference reference = eachReference.next();
                     result.appendChild(
                         ((ReferenceImpl) reference).toElement());
                 }
@@ -3894,18 +3894,18 @@
              */
             private abstract class ReferenceImpl implements Reference {
                 private String uri;
-                private List referenceInformation;
+                private List<Element> referenceInformation;
 
                 ReferenceImpl(String _uri) {
                     this.uri = _uri;
-                    referenceInformation = new LinkedList();
+                    referenceInformation = new LinkedList<Element>();
                 }
                 /** @inheritDoc */
                 public String getURI() {
                     return (uri);
                 }
                 /** @inheritDoc */
-                public Iterator getElementRetrievalInformation() {
+                public Iterator<Element> getElementRetrievalInformation() {
                     return (referenceInformation.iterator());
                 }
                 /** @inheritDoc */
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java	Wed Oct 26 17:59:13 2011 -0700
@@ -97,12 +97,12 @@
    /** {@link java.util.logging} logging facility */
     static java.util.logging.Logger log =
         java.util.logging.Logger.getLogger(KeyInfo.class.getName());
-    List x509Datas=null;
-    List encryptedKeys=null;
+    List<X509Data> x509Datas=null;
+    List<EncryptedKey> encryptedKeys=null;
 
-    static final List nullList;
+    static final List<StorageResolver> nullList;
     static {
-        List list = new ArrayList();
+        List<StorageResolver> list = new ArrayList<StorageResolver>(1);
         list.add(null);
         nullList = Collections.unmodifiableList(list);
     }
@@ -297,7 +297,7 @@
     */
    public void add(X509Data x509data) {
           if (x509Datas==null)
-                  x509Datas=new ArrayList();
+                  x509Datas=new ArrayList<X509Data>();
           x509Datas.add(x509data);
          this._constructionElement.appendChild(x509data.getElement());
          XMLUtils.addReturnToElement(this._constructionElement);
@@ -313,7 +313,7 @@
         public void add(EncryptedKey encryptedKey)
                 throws XMLEncryptionException {
                         if (encryptedKeys==null)
-                                encryptedKeys=new ArrayList();
+                                encryptedKeys=new ArrayList<EncryptedKey>();
                         encryptedKeys.add(encryptedKey);
                         XMLCipher cipher = XMLCipher.getInstance();
                         this._constructionElement.appendChild(cipher.martial(encryptedKey));
@@ -541,7 +541,7 @@
     */
    public X509Data itemX509Data(int i) throws XMLSecurityException {
            if (x509Datas!=null) {
-                   return (X509Data) x509Datas.get(i);
+                   return x509Datas.get(i);
            }
       Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
                                                 Constants._TAG_X509DATA,i);
@@ -562,7 +562,7 @@
 
         public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
                 if (encryptedKeys!=null) {
-                        return (EncryptedKey) encryptedKeys.get(i);
+                        return encryptedKeys.get(i);
                 }
                 Element e =
                         XMLUtils.selectXencNode(this._constructionElement.getFirstChild(),
@@ -728,16 +728,16 @@
    PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
           int length=KeyResolver.length();
           int storageLength=this._storageResolvers.size();
-          Iterator it= KeyResolver.iterator();
+          Iterator<KeyResolverSpi> it= KeyResolver.iterator();
       for (int i = 0; i < length; i++) {
-         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+         KeyResolverSpi keyResolver = it.next();
          Node currentChild=this._constructionElement.getFirstChild();
          String uri= this.getBaseURI();
          while (currentChild!=null)      {
             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                   for (int k = 0; k < storageLength; k++) {
                      StorageResolver storage =
-                        (StorageResolver) this._storageResolvers.get(k);
+                        this._storageResolvers.get(k);
 
                      PublicKey pk =
                            keyResolver.engineLookupAndResolvePublicKey((Element) currentChild,
@@ -776,7 +776,7 @@
             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (int k = 0; k < storageLength; k++) {
                    StorageResolver storage =
-                      (StorageResolver) this._storageResolvers.get(k);
+                       this._storageResolvers.get(k);
                    PublicKey pk = keyResolver
                            .engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);
 
@@ -845,9 +845,9 @@
       String uri=this.getBaseURI();
       int length= KeyResolver.length();
       int storageLength=this._storageResolvers.size();
-      Iterator it = KeyResolver.iterator();
+      Iterator<KeyResolverSpi> it = KeyResolver.iterator();
       for (int i = 0; i <length; i++) {
-         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+         KeyResolverSpi keyResolver =  it.next();
          X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
          if (cert!=null) {
                  KeyResolver.hit(it);
@@ -863,7 +863,7 @@
                    if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (int k = 0; k < storageLength; k++) {
                    StorageResolver storage =
-                      (StorageResolver) this._storageResolvers.get(k);
+                      this._storageResolvers.get(k);
 
                    X509Certificate cert = keyResolver
                         .engineLookupResolveX509Certificate((Element) currentChild, uri,
@@ -944,9 +944,9 @@
    SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
           final int length=KeyResolver.length();
           int storageLength=this._storageResolvers.size();
-          Iterator it = KeyResolver.iterator();
+          Iterator<KeyResolverSpi> it = KeyResolver.iterator();
       for (int i = 0; i < length; i++) {
-         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+         KeyResolverSpi keyResolver = it.next();
 
          Node currentChild=this._constructionElement.getFirstChild();
          String uri=this.getBaseURI();
@@ -954,7 +954,7 @@
             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                   for (int k = 0; k < storageLength; k++) {
                      StorageResolver storage =
-                        (StorageResolver) this._storageResolvers.get(k);
+                        this._storageResolvers.get(k);
 
                      SecretKey sk =
                            keyResolver.engineLookupAndResolveSecretKey((Element) currentChild,
@@ -992,7 +992,7 @@
             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (int k = 0; k < storageLength; k++) {
                      StorageResolver storage =
-                        (StorageResolver) this._storageResolvers.get(k);
+                        this._storageResolvers.get(k);
 
                      SecretKey sk = keyResolver
                            .engineLookupAndResolveSecretKey((Element) currentChild, uri, storage);
@@ -1012,7 +1012,7 @@
    /**
     * Stores the individual (per-KeyInfo) {@link KeyResolver}s
     */
-   List _internalKeyResolvers = null;
+   List<KeyResolverSpi> _internalKeyResolvers = null;
 
    /**
     * This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo
@@ -1022,7 +1022,7 @@
     */
    public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
            if (_internalKeyResolvers==null) {
-                   _internalKeyResolvers=new ArrayList();
+                   _internalKeyResolvers=new ArrayList<KeyResolverSpi>();
            }
       this._internalKeyResolvers.add(realKeyResolver);
    }
@@ -1044,11 +1044,11 @@
     * @return the KeyResolverSpi for the index.
     */
    KeyResolverSpi itemInternalKeyResolver(int i) {
-      return (KeyResolverSpi) this._internalKeyResolvers.get(i);
+      return this._internalKeyResolvers.get(i);
    }
 
    /** Field _storageResolvers */
-   List _storageResolvers = nullList;
+   List<StorageResolver> _storageResolvers = nullList;
 
    /**
     * Method addStorageResolver
@@ -1057,7 +1057,7 @@
     */
    public void addStorageResolver(StorageResolver storageResolver) {
            if  (_storageResolvers == nullList  ){
-                   _storageResolvers=new ArrayList();
+                   _storageResolvers=new ArrayList<StorageResolver>();
            }
          this._storageResolvers.add(storageResolver);
 
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java	Wed Oct 26 17:59:13 2011 -0700
@@ -52,7 +52,7 @@
    static boolean _alreadyInitialized = false;
 
    /** Field _resolverVector */
-   static List _resolverVector = null;
+   static List<KeyResolver> _resolverVector = null;
 
    /** Field _resolverSpi */
    protected KeyResolverSpi _resolverSpi = null;
@@ -85,12 +85,12 @@
       return KeyResolver._resolverVector.size();
    }
 
-   public static void hit(Iterator hintI) {
+   public static void hit(Iterator<KeyResolverSpi> hintI) {
            ResolverIterator hint = (ResolverIterator) hintI;
            int i = hint.i;
            if (i!=1 && hint.res ==_resolverVector) {
-                   List resolverVector=(List)((ArrayList)_resolverVector).clone();
-                Object ob=resolverVector.remove(i-1);
+                   List<KeyResolver> resolverVector=getResolverVectorClone();
+                KeyResolver ob=resolverVector.remove(i-1);
                 resolverVector.add(0,ob);
                  _resolverVector=resolverVector;
          } else {
@@ -113,12 +113,9 @@
               throws KeyResolverException {
 
           // use the old vector to not be hit by updates
-          List resolverVector = KeyResolver._resolverVector;
-      for (int i = 0; i < resolverVector.size(); i++) {
-                  KeyResolver resolver=
-            (KeyResolver) resolverVector.get(i);
-
-                  if (resolver==null) {
+          List<KeyResolver> resolverVector = KeyResolver._resolverVector;
+      for (KeyResolver resolver : resolverVector) {
+         if (resolver==null) {
             Object exArgs[] = {
                (((element != null)
                  && (element.getNodeType() == Node.ELEMENT_NODE))
@@ -157,10 +154,8 @@
            Element element, String BaseURI, StorageResolver storage)
               throws KeyResolverException {
 
-          List resolverVector = KeyResolver._resolverVector;
-      for (int i = 0; i < resolverVector.size(); i++) {
-                  KeyResolver resolver=
-            (KeyResolver) resolverVector.get(i);
+          List<KeyResolver> resolverVector = KeyResolver._resolverVector;
+      for (KeyResolver resolver : resolverVector) {
 
                   if (resolver==null) {
             Object exArgs[] = {
@@ -176,11 +171,11 @@
 
          PublicKey cert=resolver.resolvePublicKey(element, BaseURI, storage);
          if (cert!=null) {
-                 if (i!=0 && resolverVector==_resolverVector) {
+                 if (resolverVector.indexOf(resolver)!=0 && resolverVector==_resolverVector) {
                          //update resolver.
-                         resolverVector=(List)((ArrayList)_resolverVector).clone();
-                                 Object ob=resolverVector.remove(i);
-                                 resolverVector.add(0,ob);
+                         resolverVector=getResolverVectorClone();
+                                 resolverVector.remove(resolver);
+                                 resolverVector.add(0,resolver);
                                  _resolverVector=resolverVector;
                  }
                  return cert;
@@ -195,13 +190,19 @@
       throw new KeyResolverException("utils.resolver.noClass", exArgs);
    }
 
+
+   @SuppressWarnings("unchecked")
+   private static List<KeyResolver> getResolverVectorClone() {
+       return (List<KeyResolver>)((ArrayList<KeyResolver>)_resolverVector).clone();
+   }
+
    /**
     * The init() function is called by com.sun.org.apache.xml.internal.security.Init.init()
     */
    public static void init() {
 
       if (!KeyResolver._alreadyInitialized) {
-         KeyResolver._resolverVector = new ArrayList(10);
+         KeyResolver._resolverVector = new ArrayList<KeyResolver>(10);
          _alreadyInitialized = true;
       }
    }
@@ -230,8 +231,8 @@
     *
     * @param className
     */
-   public static void registerAtStart(String className) {
-      KeyResolver._resolverVector.add(0, className);
+   public static void registerAtStart(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+       register(className);
    }
 
    /**
@@ -322,11 +323,11 @@
       return this._resolverSpi.getClass().getName();
    }
 
-   static class ResolverIterator implements Iterator {
-           List res;
-                Iterator it;
+   static class ResolverIterator implements Iterator<KeyResolverSpi> {
+                List<KeyResolver> res;
+                Iterator<KeyResolver> it;
                 int i;
-           public ResolverIterator(List list) {
+           public ResolverIterator(List<KeyResolver> list) {
                 res = list;
                 it = res.iterator();
         }
@@ -335,9 +336,9 @@
                         return it.hasNext();
                 }
 
-                public Object next() {
+                public KeyResolverSpi next() {
                         i++;
-                        KeyResolver resolver = (KeyResolver) it.next();
+                        KeyResolver resolver =  it.next();
                       if (resolver==null) {
                          throw new RuntimeException("utils.resolver.noClass");
                       }
@@ -351,7 +352,7 @@
                 }
 
         };
-        public static Iterator iterator() {
+        public static Iterator<KeyResolverSpi> iterator() {
                 return new ResolverIterator(_resolverVector);
    }
 }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java	Wed Oct 26 17:59:13 2011 -0700
@@ -32,7 +32,7 @@
 /**
  * This class is abstract class for a child KeyInfo Elemnet.
  *
- * If you want the your KeyResolver, at firstly you must extand this class, and register
+ * If you want your KeyResolver, at first you must extend this class, and register
  * as following in config.xml
  * <PRE>
  *  &lt;KeyResolver URI="http://www.w3.org/2000/09/xmldsig#KeyValue"
@@ -177,7 +177,7 @@
    }
 
    /** Field _properties */
-   protected java.util.Map _properties = null;
+   protected java.util.Map<String,String> _properties = null;
 
    protected boolean globalResolver=false;
 
@@ -189,7 +189,7 @@
     */
    public void engineSetProperty(String key, String value) {
            if (_properties==null)
-                   _properties=new HashMap();
+                   _properties=new HashMap<String,String>();
       this._properties.put(key, value);
    }
 
@@ -203,7 +203,7 @@
            if (_properties==null)
                    return null;
 
-      return (String) this._properties.get(key);
+      return this._properties.get(key);
    }
 
    /**
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java	Wed Oct 26 17:59:13 2011 -0700
@@ -278,18 +278,18 @@
       return null;
    }
 
-   static Element getDocumentElement(Set set) {
-           Iterator it=set.iterator();
+   static Element getDocumentElement(Set<Node> set) {
+           Iterator<Node> it=set.iterator();
            Element e=null;
            while (it.hasNext()) {
-                   Node currentNode=(Node)it.next();
+                   Node currentNode=it.next();
                    if (currentNode instanceof Element) {
                            e=(Element)currentNode;
                            break;
                    }
 
            }
-           List parents=new ArrayList(10);
+           List<Element> parents=new ArrayList<Element>(10);
 
                 //Obtain all the parents of the elemnt
                 do {
@@ -301,10 +301,10 @@
                         e=(Element)n;
                 } while (e!=null);
                 //Visit them in reverse order.
-                ListIterator it2=parents.listIterator(parents.size()-1);
+                ListIterator<Element> it2=parents.listIterator(parents.size()-1);
                 Element ele=null;
                 while (it2.hasPrevious()) {
-                        ele=(Element)it2.previous();
+                        ele=it2.previous();
                         if (set.contains(ele)) {
                                 return ele;
                         }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java	Wed Oct 26 17:59:13 2011 -0700
@@ -42,10 +42,10 @@
         java.util.logging.Logger.getLogger(StorageResolver.class.getName());
 
    /** Field _storageResolvers */
-   List _storageResolvers = null;
+   List<Object> _storageResolvers = null;
 
    /** Field _iterator */
-   Iterator _iterator = null;
+   Iterator<Object> _iterator = null;
 
    /**
     * Constructor StorageResolver
@@ -69,7 +69,7 @@
     */
    public void add(StorageResolverSpi resolver) {
            if (_storageResolvers==null)
-                   _storageResolvers=new ArrayList();
+                   _storageResolvers=new ArrayList<Object>();
       this._storageResolvers.add(resolver);
 
       this._iterator = null;
@@ -121,11 +121,11 @@
     * @return the iterator for the resolvers.
     *
     */
-   public Iterator getIterator() {
+   public Iterator<Object> getIterator() {
 
       if (this._iterator == null) {
          if (_storageResolvers==null)
-                   _storageResolvers=new ArrayList();
+                   _storageResolvers=new ArrayList<Object>();
          this._iterator = new StorageResolverIterator(this._storageResolvers.iterator());
       }
 
@@ -141,7 +141,7 @@
 
       if (this._iterator == null) {
           if (_storageResolvers==null)
-                   _storageResolvers=new ArrayList();
+                   _storageResolvers=new ArrayList<Object>();
          this._iterator = new StorageResolverIterator(this._storageResolvers.iterator());
       }
 
@@ -163,17 +163,17 @@
     * @author $Author: mullan $
     * @version $Revision: 1.5 $
     */
-   static class StorageResolverIterator implements Iterator {
+   static class StorageResolverIterator implements Iterator<Object> {
 
       /** Field _resolvers */
-      Iterator _resolvers = null;
+      Iterator<Object> _resolvers = null;
 
       /**
        * Constructor FilesystemIterator
        *
        * @param resolvers
        */
-      public StorageResolverIterator(Iterator resolvers) {
+      public StorageResolverIterator(Iterator<Object> resolvers) {
          this._resolvers = resolvers;
       }
 
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java	Wed Oct 26 17:59:13 2011 -0700
@@ -36,5 +36,5 @@
     *
     * @return the iterator for the storage
     */
-   public abstract Iterator getIterator();
+   public abstract Iterator<?> getIterator();
 }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java	Wed Oct 26 17:59:13 2011 -0700
@@ -54,10 +54,10 @@
    String _merlinsCertificatesDir = null;
 
    /** Field _certs */
-   private List _certs = new ArrayList();
+   private List<X509Certificate> _certs = new ArrayList<X509Certificate>();
 
    /** Field _iterator */
-   Iterator _iterator = null;
+   Iterator<X509Certificate> _iterator = null;
 
    /**
     *
@@ -83,7 +83,7 @@
    private void readCertsFromHarddrive() throws StorageResolverException {
 
       File certDir = new File(this._merlinsCertificatesDir);
-      ArrayList al = new ArrayList();
+      ArrayList<String> al = new ArrayList<String>();
       String[] names = certDir.list();
 
       for (int i = 0; i < names.length; i++) {
@@ -108,7 +108,7 @@
 
       for (int i = 0; i < al.size(); i++) {
          String filename = certDir.getAbsolutePath() + File.separator
-                           + (String) al.get(i);
+                           + al.get(i);
          File file = new File(filename);
          boolean added = false;
          String dn = null;
@@ -146,7 +146,7 @@
    }
 
    /** @inheritDoc */
-   public Iterator getIterator() {
+   public Iterator<X509Certificate> getIterator() {
       return this._iterator;
    }
 
@@ -156,10 +156,10 @@
     * @author $Author: mullan $
     * @version $Revision: 1.5 $
     */
-   private static class FilesystemIterator implements Iterator {
+   private static class FilesystemIterator implements Iterator<X509Certificate> {
 
       /** Field _certs */
-      List _certs = null;
+      List<X509Certificate> _certs = null;
 
       /** Field _i */
       int _i;
@@ -169,7 +169,7 @@
        *
        * @param certs
        */
-      public FilesystemIterator(List certs) {
+      public FilesystemIterator(List<X509Certificate> certs) {
          this._certs = certs;
          this._i = 0;
       }
@@ -180,7 +180,7 @@
       }
 
       /** @inheritDoc */
-      public Object next() {
+      public X509Certificate next() {
          return this._certs.get(this._i++);
       }
 
@@ -206,8 +206,8 @@
          new CertsInFilesystemDirectoryResolver(
             "data/ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/certs");
 
-      for (Iterator i = krs.getIterator(); i.hasNext(); ) {
-         X509Certificate cert = (X509Certificate) i.next();
+      for (Iterator<X509Certificate> i = krs.getIterator(); i.hasNext(); ) {
+         X509Certificate cert = i.next();
          byte[] ski =
             com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI
                .getSKIBytesFromCert(cert);
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java	Wed Oct 26 17:59:13 2011 -0700
@@ -42,7 +42,7 @@
    KeyStore _keyStore = null;
 
    /** Field _iterator */
-   Iterator _iterator = null;
+   Iterator<X509Certificate> _iterator = null;
 
    /**
     * Constructor KeyStoreResolver
@@ -56,7 +56,7 @@
    }
 
    /** @inheritDoc */
-   public Iterator getIterator() {
+   public Iterator<X509Certificate> getIterator() {
       return this._iterator;
    }
 
@@ -66,13 +66,13 @@
     * @author $Author: mullan $
     * @version $Revision: 1.5 $
     */
-   static class KeyStoreIterator implements Iterator {
+   static class KeyStoreIterator implements Iterator<X509Certificate> {
 
       /** Field _keyStore */
       KeyStore _keyStore = null;
 
       /** Field _aliases */
-      Enumeration _aliases = null;
+      Enumeration<String> _aliases = null;
 
       /**
        * Constructor KeyStoreIterator
@@ -97,12 +97,13 @@
       }
 
       /** @inheritDoc */
-      public Object next() {
+      @SuppressWarnings("unchecked")
+      public X509Certificate next() {
 
-         String alias = (String) this._aliases.nextElement();
+         String alias = this._aliases.nextElement();
 
          try {
-            return this._keyStore.getCertificate(alias);
+            return (X509Certificate)this._keyStore.getCertificate(alias);
          } catch (KeyStoreException ex) {
             return null;
          }
@@ -135,8 +136,8 @@
 
       KeyStoreResolver krs = new KeyStoreResolver(ks);
 
-      for (Iterator i = krs.getIterator(); i.hasNext(); ) {
-         X509Certificate cert = (X509Certificate) i.next();
+      for (Iterator<X509Certificate> i = krs.getIterator(); i.hasNext(); ) {
+         X509Certificate cert = i.next();
          byte[] ski =
             com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI
                .getSKIBytesFromCert(cert);
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java	Wed Oct 26 17:59:13 2011 -0700
@@ -38,7 +38,7 @@
    X509Certificate _certificate = null;
 
    /** Field _iterator */
-   Iterator _iterator = null;
+   Iterator<X509Certificate> _iterator = null;
 
    /**
     *
@@ -51,7 +51,7 @@
    }
 
    /** @inheritDoc */
-   public Iterator getIterator() {
+   public Iterator<X509Certificate> getIterator() {
       return this._iterator;
    }
 
@@ -61,7 +61,7 @@
     * @author $Author: mullan $
     * @version $Revision: 1.5 $
     */
-   static class InternalIterator implements Iterator {
+   static class InternalIterator implements Iterator<X509Certificate> {
 
       /** Field _alreadyReturned */
       boolean _alreadyReturned = false;
@@ -84,7 +84,7 @@
       }
 
       /** @inheritDoc */
-      public Object next() {
+      public X509Certificate next() {
 
          this._alreadyReturned = true;
 
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java	Wed Oct 26 17:59:13 2011 -0700
@@ -28,6 +28,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.Map;
 
 import javax.xml.parsers.ParserConfigurationException;
 
@@ -62,17 +63,17 @@
         java.util.logging.Logger.getLogger(Manifest.class.getName());
 
    /** Field _references */
-   List _references;
+   List<Reference> _references;
    Element[] _referencesEl;
 
    /** Field verificationResults[] */
    private boolean verificationResults[] = null;
 
    /** Field _resolverProperties */
-   HashMap _resolverProperties = null;
+   Map<String,String> _resolverProperties = null;
 
    /** Field _perManifestResolvers */
-   List _perManifestResolvers = null;
+   List<ResourceResolver> _perManifestResolvers = null;
 
    /**
     * Consturts {@link Manifest}
@@ -85,7 +86,7 @@
 
       XMLUtils.addReturnToElement(this._constructionElement);
 
-      this._references = new ArrayList();
+      this._references = new ArrayList<Reference>();
    }
 
    /**
@@ -117,7 +118,7 @@
       }
 
       // create Vector
-      this._references = new ArrayList(le);
+      this._references = new ArrayList<Reference>(le);
 
       for (int i = 0; i < le; i++) {
          this._references.add(null);
@@ -175,7 +176,7 @@
          for (int i = 0; i < this.getLength(); i++) {
 
             // update the cached Reference object, the Element content is automatically updated
-            Reference currentRef = (Reference) this._references.get(i);
+            Reference currentRef = this._references.get(i);
 
             currentRef.generateDigestValue();
          }
@@ -208,7 +209,7 @@
             this._references.set(i, ref);
          }
 
-         return (Reference) this._references.get(i);
+         return this._references.get(i);
 
    }
 
@@ -323,12 +324,12 @@
                 try {
                   XMLSignatureInput signedManifestNodes =
                     currentRef.dereferenceURIandPerformTransforms(null);
-                  Set nl = signedManifestNodes.getNodeSet();
+                  Set<Node> nl = signedManifestNodes.getNodeSet();
                   Manifest referencedManifest = null;
-                  Iterator nlIterator = nl.iterator();
+                  Iterator<Node> nlIterator = nl.iterator();
 
                   findManifest: while (nlIterator.hasNext()) {
-                     Node n = (Node) nlIterator.next();
+                     Node n =  nlIterator.next();
 
                      if ((n.getNodeType() == Node.ELEMENT_NODE) && ((Element) n)
                              .getNamespaceURI()
@@ -449,7 +450,7 @@
           return;
       }
       if (_perManifestResolvers==null)
-          _perManifestResolvers = new ArrayList();
+          _perManifestResolvers = new ArrayList<ResourceResolver>();
       this._perManifestResolvers.add(resolver);
 
    }
@@ -465,7 +466,7 @@
           return;
       }
       if (_perManifestResolvers==null)
-                  _perManifestResolvers = new ArrayList();
+                  _perManifestResolvers = new ArrayList<ResourceResolver>();
       this._perManifestResolvers.add(new ResourceResolver(resolverSpi));
 
    }
@@ -479,7 +480,7 @@
     */
    public void setResolverProperty(String key, String value) {
            if (_resolverProperties==null) {
-                   _resolverProperties=new HashMap(10);
+                   _resolverProperties=new HashMap<String, String>(10);
            }
       this._resolverProperties.put(key, value);
    }
@@ -491,7 +492,7 @@
     * @return the value
     */
    public String getResolverProperty(String key) {
-      return (String) this._resolverProperties.get(key);
+      return this._resolverProperties.get(key);
    }
 
    /**
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java	Wed Oct 26 17:59:13 2011 -0700
@@ -436,6 +436,7 @@
     *
     * @deprecated use getContentsBeforeTransformation
     */
+   @Deprecated
    public XMLSignatureInput getTransformsInput() throws ReferenceNotInitializedException
         {
                 XMLSignatureInput input=getContentsBeforeTransformation();
@@ -557,7 +558,7 @@
 
       try {
          XMLSignatureInput nodes = this.getNodesetBeforeFirstCanonicalization();
-         Set inclusiveNamespaces = new HashSet();
+         Set<String> inclusiveNamespaces = new HashSet<String>();
 
          {
             Transforms transforms = this.getTransforms();
@@ -710,7 +711,7 @@
          XMLSignatureInput output=this.dereferenceURIandPerformTransforms(os);
          // if signing and c14n11 property == true explicitly add
          // C14N11 transform if needed
-         if (this.useC14N11 && !validating &&
+         if (Reference.useC14N11 && !validating &&
              !output.isOutputStreamSet() && !output.isOctetStream()) {
              if (transforms == null) {
                  transforms = new Transforms(this._doc);
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java	Wed Oct 26 17:59:13 2011 -0700
@@ -74,7 +74,7 @@
     /**
      * The original NodeSet for this XMLSignatureInput
      */
-    Set _inputNodeSet = null;
+    Set<Node> _inputNodeSet = null;
     /**
      * The original Element
      */
@@ -107,7 +107,7 @@
     /**
      * Node Filter list.
      */
-    List nodeFilters=new ArrayList();
+    List<NodeFilter> nodeFilters=new ArrayList<NodeFilter>();
 
     boolean needsToBeExpanded=false;
     OutputStream outputStream=null;
@@ -164,6 +164,7 @@
      * @deprecated
      * @param inputStr the input String which including XML document or node
      */
+    @Deprecated
     public XMLSignatureInput(String inputStr) {
         this(inputStr.getBytes());
     }
@@ -179,6 +180,7 @@
      * @param encoding the encoding of <code>inputStr</code>
      * @throws UnsupportedEncodingException
      */
+    @Deprecated
     public XMLSignatureInput(String inputStr, String encoding)
            throws UnsupportedEncodingException {
         this(inputStr.getBytes(encoding));
@@ -201,7 +203,7 @@
      * @param inputNodeSet
      * @param usedXPathAPI
      */
-    public XMLSignatureInput(Set inputNodeSet) {
+    public XMLSignatureInput(Set<Node> inputNodeSet) {
         this._inputNodeSet = inputNodeSet;
     }
 
@@ -215,7 +217,7 @@
      * @throws ParserConfigurationException
      * @throws CanonicalizationException
      */
-    public Set getNodeSet() throws CanonicalizationException,
+    public Set<Node> getNodeSet() throws CanonicalizationException,
         ParserConfigurationException, IOException, SAXException {
         return getNodeSet(false);
     }
@@ -231,7 +233,7 @@
      * @throws ParserConfigurationException
      * @throws CanonicalizationException
      */
-    public Set getNodeSet(boolean circumvent)
+    public Set<Node> getNodeSet(boolean circumvent)
            throws ParserConfigurationException, IOException, SAXException,
                   CanonicalizationException {
         if (this._inputNodeSet!=null) {
@@ -242,13 +244,13 @@
             if (circumvent) {
                 XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode));
             }
-            this._inputNodeSet = new HashSet();
+            this._inputNodeSet = new HashSet<Node>();
             XMLUtils.getSet(_subNode,this._inputNodeSet, excludeNode, this.excludeComments);
 
             return this._inputNodeSet;
         } else if (this.isOctetStream()) {
             convertToNodes();
-            HashSet result=new HashSet();
+            HashSet<Node> result=new HashSet<Node>();
             XMLUtils.getSet(_subNode, result,null,false);
             //this._inputNodeSet=result;
             return result;
@@ -447,7 +449,7 @@
      * @throws XMLSignatureException
      * @return The HTML representation for this XMLSignature
      */
-    public String getHTMLRepresentation(Set inclusiveNamespaces)
+    public String getHTMLRepresentation(Set<String> inclusiveNamespaces)
            throws XMLSignatureException {
 
         XMLSignatureInputDebugger db = new XMLSignatureInputDebugger( this,
@@ -584,7 +586,7 @@
     /**
      * @return the node filters
      */
-    public List getNodeFilters() {
+    public List<NodeFilter> getNodeFilters() {
         // TODO Auto-generated method stub
         return nodeFilters;
     }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java	Wed Oct 26 17:59:13 2011 -0700
@@ -47,9 +47,9 @@
 
 
         /** Field _xmlSignatureInput */
-        private Set _xpathNodeSet;
+        private Set<Node> _xpathNodeSet;
 
-        private Set _inclusiveNamespaces;
+        private Set<String> _inclusiveNamespaces;
 
         /** Field _doc */
         private Document _doc = null;
@@ -159,7 +159,7 @@
          * @param inclusiveNamespace
          */
         public XMLSignatureInputDebugger(
-                        XMLSignatureInput xmlSignatureInput, Set inclusiveNamespace) {
+                        XMLSignatureInput xmlSignatureInput, Set<String> inclusiveNamespace) {
 
                 this(xmlSignatureInput);
 
@@ -182,7 +182,7 @@
                 {
 
                         // get only a single node as anchor to fetch the owner document
-                        Node n = (Node) this._xpathNodeSet.iterator().next();
+                        Node n = this._xpathNodeSet.iterator().next();
 
                         this._doc = XMLUtils.getOwnerDocument(n);
                 }
@@ -341,10 +341,10 @@
                         // we output all Attrs which are available
                         NamedNodeMap attrs = currentElement.getAttributes();
                         int attrsLength = attrs.getLength();
-                        Object attrs2[] = new Object[attrsLength];
+                        Attr attrs2[] = new Attr[attrsLength];
 
                         for (int i = 0; i < attrsLength; i++) {
-                                attrs2[i] = attrs.item(i);
+                                attrs2[i] = (Attr)attrs.item(i);
                         }
 
                         Arrays.sort(attrs2, ATTR_COMPARE);
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java	Wed Oct 26 17:59:13 2011 -0700
@@ -25,6 +25,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.HashMap;
+import java.util.Map;
 import javax.xml.parsers.ParserConfigurationException;
 
 import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
@@ -65,9 +66,9 @@
     private static boolean alreadyInitialized = false;
 
     /** All available Transform classes are registered here */
-    private static HashMap transformClassHash = null;
+    private static Map<String, Class<?>> transformClassHash = null;
 
-    private static HashMap transformSpiHash = new HashMap();
+    private static Map<String, TransformSpi> transformSpiHash = new HashMap<String, TransformSpi>();
 
     private TransformSpi transformSpi = null;
 
@@ -209,7 +210,7 @@
      */
     public static void init() {
         if (!alreadyInitialized) {
-            transformClassHash = new HashMap(10);
+            transformClassHash = new HashMap<String,Class<?>>(10);
             // make sure builtin algorithms are all registered first
             com.sun.org.apache.xml.internal.security.Init.init();
             alreadyInitialized = true;
@@ -231,7 +232,7 @@
         throws AlgorithmAlreadyRegisteredException {
 
         // are we already registered?
-        Class registeredClass = getImplementingClass(algorithmURI);
+        Class<? extends TransformSpi> registeredClass = getImplementingClass(algorithmURI);
         if ((registeredClass != null) ) {
             Object exArgs[] = { algorithmURI, registeredClass };
             throw new AlgorithmAlreadyRegisteredException(
@@ -331,20 +332,21 @@
      * @param URI
      * @return The name of the class implementing the URI.
      */
-    private static Class getImplementingClass(String URI) {
-        return (Class) transformClassHash.get(URI);
+    @SuppressWarnings("unchecked")
+    private static Class<? extends TransformSpi> getImplementingClass(String URI) {
+        return (Class<? extends TransformSpi>)transformClassHash.get(URI);
     }
 
     private static TransformSpi getTransformSpi(String URI)
         throws InvalidTransformException {
         try {
-            Object value = transformSpiHash.get(URI);
+            TransformSpi value = transformSpiHash.get(URI);
             if (value != null) {
-                return (TransformSpi) value;
+                return value;
             }
-            Class cl = (Class) transformClassHash.get(URI);
+            Class<? extends TransformSpi> cl = getImplementingClass(URI);
             if (cl != null) {
-                TransformSpi tr = (TransformSpi) cl.newInstance();
+                TransformSpi tr = cl.newInstance();
                 transformSpiHash.put(URI, tr);
                 return tr;
             }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java	Wed Oct 26 17:59:13 2011 -0700
@@ -41,6 +41,7 @@
      * For API compatibility not thread safe.
      * @deprecated
      */
+    @Deprecated
     protected Transform _transformObject = null;
     /**
      * Set the transform object.
@@ -48,6 +49,7 @@
      * @param transform the Transform
      * @deprecated
      */
+    @Deprecated
     protected void setTransform(Transform transform) {
         this._transformObject = transform;
     }
@@ -120,6 +122,7 @@
      * @throws SAXException
      * @throws TransformationException
      */
+    @Deprecated
     protected XMLSignatureInput enginePerformTransform(
         XMLSignatureInput input)
         throws IOException,
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHere.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHere.java	Wed Oct 26 17:59:13 2011 -0700
@@ -154,6 +154,7 @@
     * @param vars
     * @param globalsSize
     */
+   @SuppressWarnings("rawtypes")
    public void fixupVariables(java.util.Vector vars, int globalsSize) {
 
       // do nothing
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java	Wed Oct 26 17:59:13 2011 -0700
@@ -96,9 +96,9 @@
            throws TransformationException {
           CachedXPathAPIHolder.setDoc(_transformObject.getElement().getOwnerDocument());
       try {
-          List unionNodes=new ArrayList();
-           List substractNodes=new ArrayList();
-           List intersectNodes=new ArrayList();
+          List<NodeList> unionNodes=new ArrayList<NodeList>();
+          List<NodeList> substractNodes=new ArrayList<NodeList>();
+          List<NodeList> intersectNodes=new ArrayList<NodeList>();
 
          CachedXPathFuncHereAPI xPathFuncHereAPI =
             new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI());
@@ -170,18 +170,15 @@
          throw new TransformationException("empty", ex);
       }
    }
-   static Set convertNodeListToSet(List l){
-           Set result=new HashSet();
-           for (int j=0;j<l.size();j++) {
-                   NodeList rootNodes=(NodeList) l.get(j);
+   static Set<Node> convertNodeListToSet(List<NodeList> l){
+           Set<Node> result=new HashSet<Node>();
+
+           for (NodeList rootNodes : l) {
                int length = rootNodes.getLength();
-
                for (int i = 0; i < length; i++) {
                     Node rootNode = rootNodes.item(i);
                     result.add(rootNode);
-
                  }
-
            }
            return result;
    }
@@ -191,8 +188,8 @@
         boolean hasUnionNodes;
         boolean hasSubstractNodes;
         boolean hasIntersectNodes;
-        XPath2NodeFilter(Set unionNodes, Set substractNodes,
-                        Set intersectNodes) {
+        XPath2NodeFilter(Set<Node> unionNodes, Set<Node> substractNodes,
+                        Set<Node> intersectNodes) {
                 this.unionNodes=unionNodes;
                 hasUnionNodes=!unionNodes.isEmpty();
                 this.substractNodes=substractNodes;
@@ -200,9 +197,9 @@
                 this.intersectNodes=intersectNodes;
                 hasIntersectNodes=!intersectNodes.isEmpty();
         }
-        Set unionNodes;
-        Set substractNodes;
-        Set intersectNodes;
+        Set<Node> unionNodes;
+        Set<Node> substractNodes;
+        Set<Node> intersectNodes;
 
 
    /**
@@ -282,16 +279,15 @@
     *
     * @return if rooted bye the rootnodes
     */
-   static boolean  rooted(Node currentNode, Set nodeList ) {
+   static boolean  rooted(Node currentNode, Set<Node> nodeList ) {
            if (nodeList.contains(currentNode)) {
                    return true;
            }
-           Iterator it=nodeList.iterator();
-           while (it.hasNext()) {
-                        Node rootNode = (Node) it.next();
-                        if (XMLUtils.isDescendantOrSelf(rootNode,currentNode)) {
-                                   return true;
-                        }
+
+           for(Node rootNode : nodeList) {
+               if (XMLUtils.isDescendantOrSelf(rootNode,currentNode)) {
+                   return true;
+               }
            }
            return false;
    }
@@ -303,7 +299,7 @@
        *
        * @return if rooted bye the rootnodes
        */
-      static boolean  inList(Node currentNode, Set nodeList ) {
+      static boolean  inList(Node currentNode, Set<Node> nodeList ) {
               return nodeList.contains(currentNode);
       }
 }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java	Wed Oct 26 17:59:13 2011 -0700
@@ -62,14 +62,6 @@
    static final String defaultXSLTSpecNSprefix = "xslt";
    static final String XSLTSTYLESHEET          = "stylesheet";
 
-   // check for secure processing feature
-   private static Class xClass = null;
-   static {
-      try {
-         xClass = Class.forName("javax.xml.XMLConstants");
-      } catch (Exception e) {}
-   }
-
    static java.util.logging.Logger log =
       java.util.logging.Logger.getLogger(
          TransformXSLT.class.getName());
@@ -101,10 +93,6 @@
     protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream baos, Transform _transformObject)
     throws IOException,
            TransformationException {
-      if (xClass == null) {
-         Object exArgs[] = { "SECURE_PROCESSING_FEATURE not supported" };
-         throw new TransformationException("generic.EmptyMessage", exArgs);
-      }
       try {
          Element transformElement = _transformObject.getElement();
 
@@ -119,11 +107,9 @@
          }
 
          TransformerFactory tFactory = TransformerFactory.newInstance();
-         Class c = tFactory.getClass();
-         Method m = c.getMethod("setFeature", new Class[] {String.class, boolean.class});
+
          // Process XSLT stylesheets in a secure manner
-         m.invoke(tFactory, new Object[] {"http://javax.xml.XMLConstants/feature/secure-processing", Boolean.TRUE});
-
+         tFactory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", Boolean.TRUE);
          /*
           * This transform requires an octet stream as input. If the actual
           * input is an XPath node-set, then the signature application should
@@ -193,18 +179,6 @@
          Object exArgs[] = { ex.getMessage() };
 
          throw new TransformationException("generic.EmptyMessage", exArgs, ex);
-      } catch (NoSuchMethodException ex) {
-         Object exArgs[] = { ex.getMessage() };
-
-         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
-      } catch (IllegalAccessException ex) {
-         Object exArgs[] = { ex.getMessage() };
-
-         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
-      } catch (java.lang.reflect.InvocationTargetException ex) {
-         Object exArgs[] = { ex.getMessage() };
-
-         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
       }
    }
 }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/InclusiveNamespaces.java	Wed Oct 26 17:59:13 2011 -0700
@@ -74,19 +74,16 @@
     * @param doc
     * @param prefixes
     */
-   public InclusiveNamespaces(Document doc, Set prefixes) {
+   public InclusiveNamespaces(Document doc, Set<String> prefixes) {
 
       super(doc);
 
       StringBuffer sb = new StringBuffer();
-      SortedSet prefixList = new TreeSet(prefixes);
+      SortedSet<String> prefixList = new TreeSet<String>(prefixes);
 
 
-      Iterator it = prefixList.iterator();
 
-      while (it.hasNext()) {
-         String prefix = (String) it.next();
-
+      for (String prefix : prefixList) {
          if (prefix.equals("xmlns")) {
             sb.append("#default ");
          } else {
@@ -138,9 +135,9 @@
     * @param inclusiveNamespaces
     * @return A set to string
     */
-   public static SortedSet prefixStr2Set(String inclusiveNamespaces) {
+   public static SortedSet<String> prefixStr2Set(String inclusiveNamespaces) {
 
-      SortedSet prefixes = new TreeSet();
+      SortedSet<String> prefixes = new TreeSet<String>();
 
       if ((inclusiveNamespaces == null)
               || (inclusiveNamespaces.length() == 0)) {
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java	Wed Oct 26 17:59:13 2011 -0700
@@ -28,8 +28,8 @@
  */
 public class CachedXPathAPIHolder {
 
-    static ThreadLocal  local=new ThreadLocal();
-    static ThreadLocal localDoc=new ThreadLocal();
+    static ThreadLocal<CachedXPathAPI>  local=new ThreadLocal<CachedXPathAPI>();
+    static ThreadLocal<Document> localDoc=new ThreadLocal<Document>();
 
     /**
      * Sets the doc for the xpath transformation. Resets the cache if needed
@@ -37,7 +37,7 @@
      */
     public static void setDoc(Document doc) {
         if (localDoc.get()!=doc) {
-            CachedXPathAPI cx=(CachedXPathAPI)local.get();
+            CachedXPathAPI cx=local.get();
             if (cx==null) {
                 cx=new CachedXPathAPI();
                 local.set(cx);
@@ -54,7 +54,7 @@
      * @return the cachexpathapi for this thread
      */
     public static CachedXPathAPI getCachedXPathAPI() {
-        CachedXPathAPI cx=(CachedXPathAPI)local.get();
+        CachedXPathAPI cx=local.get();
         if (cx==null) {
             cx=new CachedXPathAPI();
             local.set(cx);
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java	Wed Oct 26 17:59:13 2011 -0700
@@ -173,6 +173,7 @@
     * @throws TransformerException
     * @deprecated
     */
+   @Deprecated
    public NodeIterator selectNodeIterator(
            Node contextNode, Node xpathnode, Node namespaceNode)
               throws TransformerException {
@@ -195,6 +196,7 @@
     * @throws TransformerException
     * @deprecated
     */
+   @Deprecated
    public NodeList selectNodeList(Node contextNode, Node xpathnode)
            throws TransformerException {
       return selectNodeList(contextNode, xpathnode, getStrFromNode(xpathnode), contextNode);
@@ -239,6 +241,7 @@
     * @throws TransformerException
     * @deprecated
     */
+   @Deprecated
    public XObject eval(Node contextNode, Node xpathnode)
            throws TransformerException {
       return eval(contextNode, xpathnode, getStrFromNode(xpathnode),contextNode);
@@ -375,12 +378,12 @@
 
     private XPath createXPath(String str, PrefixResolver prefixResolver) throws TransformerException {
         XPath xpath = null;
-        Class[] classes = new Class[]{String.class, SourceLocator.class, PrefixResolver.class, int.class,
+        Class<?>[] classes = new Class<?>[]{String.class, SourceLocator.class, PrefixResolver.class, int.class,
                 ErrorListener.class, FunctionTable.class};
         Object[] objects = new Object[]{str, null, prefixResolver, new Integer(XPath.SELECT), null, _funcTable};
         try {
-            Constructor constructor = XPath.class.getConstructor(classes);
-            xpath = (XPath) constructor.newInstance(objects);
+            Constructor<XPath> constructor = XPath.class.getConstructor(classes);
+            xpath = constructor.newInstance(objects);
         } catch (Throwable t) {
         }
         if (xpath == null) {
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java	Wed Oct 26 17:59:13 2011 -0700
@@ -24,6 +24,7 @@
 
 import java.math.BigInteger;
 import java.util.HashMap;
+import java.util.Map;
 
 import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
@@ -370,6 +371,7 @@
     * @return the bytes
     * @throws XMLSecurityException
     */
+   @Deprecated
    public byte[] getBytesFromChildElement(String localname, String namespace)
            throws XMLSecurityException {
 
@@ -392,14 +394,12 @@
     */
    public String getTextFromChildElement(String localname, String namespace) {
 
-         Text t =
-             (Text) XMLUtils.selectNode(
-                        this._constructionElement.getFirstChild(),
-                        namespace,
-                        localname,
-                        0).getFirstChild();
+         return     XMLUtils.selectNode(
+                    this._constructionElement.getFirstChild(),
+                    namespace,
+                    localname,
+                    0).getFirstChild().getNodeValue();
 
-         return t.getData();
    }
 
    /**
@@ -493,8 +493,8 @@
    }
 
    /** Field _prefixMappings */
-   static HashMap _prefixMappings = new HashMap();
-   static HashMap _prefixMappingsBindings = new HashMap();
+   static Map<String, String> _prefixMappings = new HashMap<String,String>();
+   static Map<String, String> _prefixMappingsBindings = new HashMap<String,String>();
 
     /**
      * Method setDefaultPrefix
@@ -533,10 +533,10 @@
      * @return the default prefix bind to this element.
      */
     public static String getDefaultPrefix(String namespace) {
-        return (String) ElementProxy._prefixMappings.get(namespace);
+        return ElementProxy._prefixMappings.get(namespace);
     }
 
     public static String getDefaultPrefixBindings(String namespace) {
-        return (String) ElementProxy._prefixMappingsBindings.get(namespace);
+        return ElementProxy._prefixMappingsBindings.get(namespace);
     }
 }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java	Wed Oct 26 17:59:13 2011 -0700
@@ -21,6 +21,7 @@
 package com.sun.org.apache.xml.internal.security.utils;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -34,7 +35,7 @@
 public class HelperNodeList implements NodeList {
 
    /** Field nodes */
-   ArrayList nodes = new ArrayList(20);
+   List<Node> nodes = new ArrayList<Node>(20);
    boolean _allNodesMustHaveSameParent = false;
 
    /**
@@ -62,7 +63,7 @@
 
       // log.log(java.util.logging.Level.FINE, "item(" + index + ") of " + this.getLength() + " nodes");
 
-      return (Node) nodes.get(index);
+      return nodes.get(index);
    }
 
    /**
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java	Wed Oct 26 17:59:13 2011 -0700
@@ -23,6 +23,7 @@
 import java.lang.ref.WeakReference;
 import java.util.Arrays;
 import java.util.WeakHashMap;
+import java.util.Map;
 
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -52,7 +53,8 @@
     private static java.util.logging.Logger log =
         java.util.logging.Logger.getLogger(IdResolver.class.getName());
 
-    private static WeakHashMap docMap = new WeakHashMap();
+    private static Map<Document, Map<String, WeakReference<Element>>> docMap =
+                    new WeakHashMap<Document, Map<String, WeakReference<Element>>>();
 
     /**
      * Constructor IdResolver
@@ -70,15 +72,15 @@
      */
     public static void registerElementById(Element element, String idValue) {
         Document doc = element.getOwnerDocument();
-        WeakHashMap elementMap;
+        Map<String, WeakReference<Element>> elementMap;
         synchronized (docMap) {
-            elementMap = (WeakHashMap) docMap.get(doc);
+            elementMap = docMap.get(doc);
             if (elementMap == null) {
-                elementMap = new WeakHashMap();
+                elementMap = new WeakHashMap<String, WeakReference<Element>>();
                 docMap.put(doc, elementMap);
             }
         }
-        elementMap.put(idValue, new WeakReference(element));
+        elementMap.put(idValue, new WeakReference<Element>(element));
     }
 
     /**
@@ -156,20 +158,20 @@
     private static Element getElementByIdType(Document doc, String id) {
         if (log.isLoggable(java.util.logging.Level.FINE))
             log.log(java.util.logging.Level.FINE, "getElementByIdType() Search for ID " + id);
-        WeakHashMap elementMap;
+        Map<String, WeakReference<Element>> elementMap;
         synchronized (docMap) {
-            elementMap = (WeakHashMap) docMap.get(doc);
+            elementMap = docMap.get(doc);
         }
         if (elementMap != null) {
-            WeakReference weakReference = (WeakReference) elementMap.get(id);
+            WeakReference<Element> weakReference =  elementMap.get(id);
             if (weakReference != null) {
-                return (Element) weakReference.get();
+                return weakReference.get();
             }
         }
         return null;
     }
 
-    private static java.util.List names;
+    private static java.util.List<String> names;
     private static int namesLength;
     static {
         String namespaces[]={
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java	Wed Oct 26 17:59:13 2011 -0700
@@ -33,8 +33,8 @@
 
         final byte[] buf;
         static final int size=8*1024;
-        private static ThreadLocal bufCahce = new ThreadLocal() {
-        protected synchronized Object initialValue() {
+        private static ThreadLocal<byte[]> bufCahce = new ThreadLocal<byte[]>() {
+        protected synchronized byte[] initialValue() {
             return new byte[size];
         }
     };
@@ -44,7 +44,7 @@
          * @param out the outputstream to buffer
          */
         public UnsyncBufferedOutputStream(OutputStream out) {
-                buf=(byte[])bufCahce.get();
+                buf=bufCahce.get();
                 this.out=out;
         }
 
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java	Wed Oct 26 17:59:13 2011 -0700
@@ -29,8 +29,8 @@
  */
 public class UnsyncByteArrayOutputStream extends OutputStream  {
     private static final int INITIAL_SIZE = 8192;
-    private static ThreadLocal bufCache = new ThreadLocal() {
-        protected synchronized Object initialValue() {
+    private static ThreadLocal<byte[]> bufCache = new ThreadLocal<byte[]>() {
+        protected synchronized byte[] initialValue() {
             return new byte[INITIAL_SIZE];
         }
     };
@@ -40,7 +40,7 @@
     private int pos = 0;
 
     public UnsyncByteArrayOutputStream() {
-        buf = (byte[])bufCache.get();
+        buf = bufCache.get();
     }
 
     public void write(byte[] arg0) {
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java	Wed Oct 26 17:59:13 2011 -0700
@@ -82,13 +82,15 @@
     * @param exclude
     * @param com wheather comments or not
     */
-   public static void getSet(Node rootNode,Set result,Node exclude ,boolean com) {
+   public static void getSet(Node rootNode,Set<Node> result,Node exclude ,boolean com) {
           if ((exclude!=null) && isDescendantOrSelf(exclude,rootNode)){
                 return;
       }
       getSetRec(rootNode,result,exclude,com);
    }
-   static final void getSetRec(final Node rootNode,final Set result,
+
+   @SuppressWarnings("fallthrough")
+   static final void getSetRec(final Node rootNode,final Set<Node> result,
         final Node exclude ,final boolean com) {
            //Set result = new HashSet();
        if (rootNode==exclude) {
@@ -104,7 +106,7 @@
                                         result.add(nl.item(i));
                                 }
                 }
-                //no return keep working
+                //no return keep working - ignore fallthrough warning
                 case Node.DOCUMENT_NODE:
                                 for (Node r=rootNode.getFirstChild();r!=null;r=r.getNextSibling()){
                                         if (r.getNodeType()==Node.TEXT_NODE) {
@@ -230,7 +232,7 @@
 
 
    static  String dsPrefix=null;
-   static Map namePrefixes=new HashMap();
+   static Map<String, String> namePrefixes=new HashMap<String, String>();
    /**
     * Creates an Element in the XML Signature specification namespace.
     *
@@ -248,7 +250,7 @@
       if ((dsPrefix == null) || (dsPrefix.length() == 0)) {
          return doc.createElementNS(Constants.SignatureSpecNS, elementName);
       }
-      String namePrefix=(String) namePrefixes.get(elementName);
+      String namePrefix= namePrefixes.get(elementName);
       if (namePrefix==null) {
           StringBuffer tag=new StringBuffer(dsPrefix);
           tag.append(':');
@@ -318,11 +320,9 @@
      * @param xpathNodeSet
      * @return the owner document
      */
-    public static Document getOwnerDocument(Set xpathNodeSet) {
+    public static Document getOwnerDocument(Set<Node> xpathNodeSet) {
        NullPointerException npe = null;
-       Iterator iterator = xpathNodeSet.iterator();
-       while(iterator.hasNext()) {
-           Node node = (Node) iterator.next();
+       for (Node node : xpathNodeSet) {
            int nodeType =node.getNodeType();
            if (nodeType == Node.DOCUMENT_NODE) {
               return (Document) node;
@@ -397,14 +397,14 @@
     * @param xpathNodeSet
     * @return the set with the nodelist
     */
-   public static Set convertNodelistToSet(NodeList xpathNodeSet) {
+   public static Set<Node> convertNodelistToSet(NodeList xpathNodeSet) {
 
       if (xpathNodeSet == null) {
-         return new HashSet();
+         return new HashSet<Node>();
       }
 
       int length = xpathNodeSet.getLength();
-      Set set = new HashSet(length);
+      Set<Node> set = new HashSet<Node>(length);
 
       for (int i = 0; i < length; i++) {
          set.add(xpathNodeSet.item(i));
@@ -446,6 +446,7 @@
     * @param node
     * @see <A HREF="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2650">Namespace axis resolution is not XPath compliant </A>
     */
+   @SuppressWarnings("fallthrough")
    private static void circumventBug2650internal(Node node) {
            Node parent=null;
            Node sibling=null;
@@ -642,12 +643,12 @@
     * @param inputSet
     * @return nodes with the constrain
     */
-    public static Set excludeNodeFromSet(Node signatureElement, Set inputSet) {
-          Set resultSet = new HashSet();
-          Iterator iterator = inputSet.iterator();
+    public static Set<Node> excludeNodeFromSet(Node signatureElement, Set<Node> inputSet) {
+          Set<Node> resultSet = new HashSet<Node>();
+          Iterator<Node> iterator = inputSet.iterator();
 
           while (iterator.hasNext()) {
-            Node inputNode = (Node) iterator.next();
+            Node inputNode = iterator.next();
 
             if (!XMLUtils
                     .isDescendantOrSelf(signatureElement, inputNode)) {
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java	Wed Oct 26 17:59:13 2011 -0700
@@ -56,7 +56,7 @@
    static boolean _alreadyInitialized = false;
 
    /** these are the system-wide resolvers */
-   static List _resolverVector = null;
+   static List<ResourceResolver> _resolverVector = null;
 
    static boolean allThreadSafeInList=true;
 
@@ -102,7 +102,7 @@
       int length=ResourceResolver._resolverVector.size();
       for (int i = 0; i < length; i++) {
                   ResourceResolver resolver =
-            (ResourceResolver) ResourceResolver._resolverVector.get(i);
+            ResourceResolver._resolverVector.get(i);
                   ResourceResolver resolverTmp=null;
                   try {
                         resolverTmp =  allThreadSafeInList || resolver._resolverSpi.engineIsThreadSafe() ? resolver :
@@ -120,7 +120,7 @@
                  if (i!=0) {
                  //update resolver.
                          //System.out.println("Swaping");
-                         List resolverVector=(List)((ArrayList)_resolverVector).clone();
+                         List<ResourceResolver> resolverVector=getResolverVectorClone();
                          resolverVector.remove(i);
                          resolverVector.add(0,resolver);
                          _resolverVector=resolverVector;
@@ -139,6 +139,17 @@
       throw new ResourceResolverException("utils.resolver.noClass", exArgs,
                                           uri, BaseURI);
    }
+
+   /**
+    * Method getResolverVectorClone
+    *
+    * @return clone of _resolverVector
+    */
+   @SuppressWarnings("unchecked")
+   private static List<ResourceResolver> getResolverVectorClone() {
+       return (List<ResourceResolver>)((ArrayList<ResourceResolver>)_resolverVector).clone();
+   }
+
    /**
     * Method getInstance
     *
@@ -150,7 +161,7 @@
     * @throws ResourceResolverException
     */
    public static final ResourceResolver getInstance(
-           Attr uri, String BaseURI, List individualResolvers)
+           Attr uri, String BaseURI, List<ResourceResolver> individualResolvers)
               throws ResourceResolverException {
       if (log.isLoggable(java.util.logging.Level.FINE)) {
 
@@ -163,7 +174,7 @@
       if ((individualResolvers != null) && ((size=individualResolvers.size()) > 0)) {
          for (int i = 0; i < size; i++) {
             ResourceResolver resolver =
-               (ResourceResolver) individualResolvers.get(i);
+               individualResolvers.get(i);
 
             if (resolver != null) {
                String currentClass = resolver._resolverSpi.getClass().getName();
@@ -186,7 +197,7 @@
    public static void init() {
 
       if (!ResourceResolver._alreadyInitialized) {
-         ResourceResolver._resolverVector = new ArrayList(10);
+         ResourceResolver._resolverVector = new ArrayList<ResourceResolver>(10);
          _alreadyInitialized = true;
       }
    }
@@ -288,7 +299,7 @@
     *
     * @param properties
     */
-   public void addProperties(Map properties) {
+   public void addProperties(Map<String,String> properties) {
       this._resolverSpi.engineAddProperies(properties);
    }
 
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java	Wed Oct 26 17:59:13 2011 -0700
@@ -41,7 +41,7 @@
                     ResourceResolverSpi.class.getName());
 
    /** Field _properties */
-   protected java.util.Map _properties = null;
+   protected java.util.Map<String,String> _properties = null;
 
    /**
     * This is the workhorse method used to resolve resources.
@@ -63,7 +63,7 @@
     */
    public void engineSetProperty(String key, String value) {
           if (_properties==null) {
-                  _properties=new HashMap();
+                  _properties=new HashMap<String,String>();
           }
       this._properties.put(key, value);
    }
@@ -78,17 +78,17 @@
           if (_properties==null) {
                         return null;
           }
-      return (String) this._properties.get(key);
+      return this._properties.get(key);
    }
 
    /**
     *
     * @param properties
     */
-   public void engineAddProperies(Map properties) {
+   public void engineAddProperies(Map<String,String> properties) {
           if (properties!=null) {
                   if (_properties==null) {
-                          _properties=new HashMap();
+                          _properties=new HashMap<String,String>();
                   }
                   this._properties.putAll(properties);
           }
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java	Wed Oct 26 17:59:13 2011 -0700
@@ -289,7 +289,7 @@
     * @inheritDoc
     */
    public String[] engineGetPropertyKeys() {
-      return (String[]) ResolverDirectHTTP.properties.clone();
+      return ResolverDirectHTTP.properties.clone();
    }
 
    private URI getNewURI(String uri, String BaseURI)
--- a/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/security/auth/module/Krb5LoginModule.java	Wed Oct 26 17:59:13 2011 -0700
@@ -725,7 +725,7 @@
                         cred = builder.action().getCreds();
                     }
                     if (storeKey) {
-                        encKeys = builder.getKeys();
+                        encKeys = builder.getKeys(isInitiator);
                         // When encKeys is empty, the login actually fails.
                         // For compatibility, exception is thrown in commit().
                     }
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -91,6 +91,9 @@
 FileChooser.helpButtonToolTipText=FileChooser help
 FileChooser.directoryOpenButtonToolTipText=Open selected directory
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=Preview
 ColorChooser.okText=OK
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_de.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_de.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=FileChooser-Hilfe
 FileChooser.directoryOpenButtonToolTipText=Ausgew\u00E4hltes Verzeichnis \u00F6ffnen
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=Vorschau
 ColorChooser.okText=OK
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_es.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_es.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=Ayuda del Selector de Archivos
 FileChooser.directoryOpenButtonToolTipText=Abrir directorio seleccionado
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=Presentaci\u00F3n Preliminar
 ColorChooser.okText=Aceptar
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_fr.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_fr.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=Aide du s\u00E9lecteur de fichiers
 FileChooser.directoryOpenButtonToolTipText=Ouvre le r\u00E9pertoire s\u00E9lectionn\u00E9
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=Aper\u00E7u
 ColorChooser.okText=OK
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_it.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_it.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=Guida FileChooser
 FileChooser.directoryOpenButtonToolTipText=Apre la directory selezionata
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=Anteprima
 ColorChooser.okText=OK
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=FileChooser\u306E\u30D8\u30EB\u30D7\u3067\u3059
 FileChooser.directoryOpenButtonToolTipText=\u9078\u629E\u3057\u305F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u958B\u304D\u307E\u3059
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=\u30D7\u30EC\u30D3\u30E5\u30FC
 ColorChooser.okText=OK
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=FileChooser \uB3C4\uC6C0\uB9D0
 FileChooser.directoryOpenButtonToolTipText=\uC120\uD0DD\uB41C \uB514\uB809\uD1A0\uB9AC \uC5F4\uAE30
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=\uBBF8\uB9AC\uBCF4\uAE30
 ColorChooser.okText=\uD655\uC778
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_pt_BR.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_pt_BR.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=Ajuda do FileChooser
 FileChooser.directoryOpenButtonToolTipText=Abrir diret\u00F3rio selecionado
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=Visualizar
 ColorChooser.okText=OK
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=Hj\u00E4lp - Filv\u00E4ljare
 FileChooser.directoryOpenButtonToolTipText=\u00D6ppna vald katalog
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=Granska
 ColorChooser.okText=OK
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=FileChooser \u5E2E\u52A9
 FileChooser.directoryOpenButtonToolTipText=\u6253\u5F00\u9009\u62E9\u7684\u76EE\u5F55
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=\u9884\u89C8
 ColorChooser.okText=\u786E\u5B9A
--- a/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -90,6 +90,9 @@
 FileChooser.helpButtonToolTipText=\u300C\u6A94\u6848\u9078\u64C7\u5668\u300D\u8AAA\u660E
 FileChooser.directoryOpenButtonToolTipText=\u958B\u555F\u9078\u53D6\u7684\u76EE\u9304
 
+FileChooser.filesListAccessibleName=Files List
+FileChooser.filesDetailsAccessibleName=Files Details
+
 ############ COLOR CHOOSER STRINGS #############
 ColorChooser.previewText=\u9810\u89BD
 ColorChooser.okText=\u78BA\u5B9A
--- a/jdk/src/share/classes/java/awt/AWTKeyStroke.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/awt/AWTKeyStroke.java	Wed Oct 26 17:59:13 2011 -0700
@@ -777,10 +777,6 @@
      */
     protected Object readResolve() throws java.io.ObjectStreamException {
         synchronized (AWTKeyStroke.class) {
-            Class newClass = getClass();
-            if (!newClass.equals(ctor.getDeclaringClass())) {
-                registerSubclass(newClass);
-            }
             return getCachedStroke(keyChar, keyCode, modifiers, onKeyRelease);
         }
     }
--- a/jdk/src/share/classes/java/awt/EventDispatchThread.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/awt/EventDispatchThread.java	Wed Oct 26 17:59:13 2011 -0700
@@ -34,8 +34,10 @@
 import sun.security.action.GetPropertyAction;
 import sun.awt.AWTAutoShutdown;
 import sun.awt.SunToolkit;
+import sun.awt.AppContext;
 
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
 import sun.util.logging.PlatformLogger;
 
 import sun.awt.dnd.SunDragSourceContextPeer;
@@ -66,11 +68,11 @@
 
     private EventQueue theQueue;
     private boolean doDispatch = true;
-    private boolean threadDeathCaught = false;
+    private volatile boolean shutdown = false;
 
     private static final int ANY_EVENT = -1;
 
-    private Vector<EventFilter> eventFilters = new Vector<EventFilter>();
+    private ArrayList<EventFilter> eventFilters = new ArrayList<EventFilter>();
 
     EventDispatchThread(ThreadGroup group, String name, EventQueue queue) {
         super(group, name);
@@ -84,6 +86,11 @@
         doDispatch = false;
     }
 
+    public void interrupt() {
+        shutdown = true;
+        super.interrupt();
+    }
+
     public void run() {
         while (true) {
             try {
@@ -93,8 +100,7 @@
                     }
                 });
             } finally {
-                EventQueue eq = getEventQueue();
-                if (eq.detachDispatchThread(this) || threadDeathCaught) {
+                if(getEventQueue().detachDispatchThread(this, shutdown)) {
                     break;
                 }
             }
@@ -124,10 +130,9 @@
     void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
         addEventFilter(filter);
         doDispatch = true;
-        while (doDispatch && cond.evaluate()) {
-            if (isInterrupted() || !pumpOneEventForFilters(id)) {
-                doDispatch = false;
-            }
+        shutdown |= isInterrupted();
+        while (doDispatch && !shutdown && cond.evaluate()) {
+            pumpOneEventForFilters(id);
         }
         removeEventFilter(filter);
     }
@@ -163,7 +168,7 @@
         }
     }
 
-    boolean pumpOneEventForFilters(int id) {
+    void pumpOneEventForFilters(int id) {
         AWTEvent event = null;
         boolean eventOK = false;
         try {
@@ -212,24 +217,18 @@
             if (delegate != null) {
                 delegate.afterDispatch(event, handle);
             }
-
-            return true;
         }
         catch (ThreadDeath death) {
-            threadDeathCaught = true;
-            return false;
-
+            shutdown = true;
+            throw death;
         }
         catch (InterruptedException interruptedException) {
-            return false; // AppContext.dispose() interrupts all
-                          // Threads in the AppContext
-
+            shutdown = true; // AppContext.dispose() interrupts all
+                             // Threads in the AppContext
         }
         catch (Throwable e) {
             processException(e);
         }
-
-        return true;
     }
 
     private void processException(Throwable e) {
--- a/jdk/src/share/classes/java/awt/EventQueue.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/awt/EventQueue.java	Wed Oct 26 17:59:13 2011 -0700
@@ -47,6 +47,7 @@
 
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import java.security.AccessControlContext;
 import java.security.ProtectionDomain;
@@ -99,12 +100,7 @@
  * @since       1.1
  */
 public class EventQueue {
-
-    // From Thread.java
-    private static int threadInitNumber;
-    private static synchronized int nextThreadNum() {
-        return threadInitNumber++;
-    }
+    private static final AtomicInteger threadInitNumber = new AtomicInteger(0);
 
     private static final int LOW_PRIORITY = 0;
     private static final int NORM_PRIORITY = 1;
@@ -175,9 +171,9 @@
      * Non-zero if a thread is waiting in getNextEvent(int) for an event of
      * a particular ID to be posted to the queue.
      */
-    private int waitForID;
+    private volatile int waitForID;
 
-    private final String name = "AWT-EventQueue-" + nextThreadNum();
+    private final String name = "AWT-EventQueue-" + threadInitNumber.getAndIncrement();
 
     private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
 
@@ -1030,7 +1026,7 @@
         }
     }
 
-    final boolean detachDispatchThread(EventDispatchThread edt) {
+    final boolean detachDispatchThread(EventDispatchThread edt, boolean forceDetach) {
         /*
          * This synchronized block is to secure that the event dispatch
          * thread won't die in the middle of posting a new event to the
@@ -1049,7 +1045,7 @@
                  * Fix for 4648733. Check both the associated java event
                  * queue and the PostEventQueue.
                  */
-                if ((peekEvent() != null) || !SunToolkit.isPostEventQueueEmpty()) {
+                if (!forceDetach && (peekEvent() != null) || !SunToolkit.isPostEventQueueEmpty()) {
                     return false;
                 }
                 dispatchThread = null;
--- a/jdk/src/share/classes/java/io/FileInputStream.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/io/FileInputStream.java	Wed Oct 26 17:59:13 2011 -0700
@@ -56,16 +56,6 @@
     private final Object closeLock = new Object();
     private volatile boolean closed = false;
 
-    private static final ThreadLocal<Boolean> runningFinalize =
-        new ThreadLocal<>();
-
-    private static boolean isRunningFinalize() {
-        Boolean val;
-        if ((val = runningFinalize.get()) != null)
-            return val.booleanValue();
-        return false;
-    }
-
     /**
      * Creates a <code>FileInputStream</code> by
      * opening a connection to an actual file,
@@ -319,10 +309,10 @@
         int useCount = fd.decrementAndGetUseCount();
 
         /*
-         * If FileDescriptor is still in use by another stream, the finalizer
+         * If FileDescriptor is still in use by another stream, we
          * will not close it.
          */
-        if ((useCount <= 0) || !isRunningFinalize()) {
+        if (useCount <= 0) {
             close0();
         }
     }
@@ -391,18 +381,7 @@
      */
     protected void finalize() throws IOException {
         if ((fd != null) &&  (fd != FileDescriptor.in)) {
-
-            /*
-             * Finalizer should not release the FileDescriptor if another
-             * stream is still using it. If the user directly invokes
-             * close() then the FileDescriptor is also released.
-             */
-            runningFinalize.set(Boolean.TRUE);
-            try {
                 close();
-            } finally {
-                runningFinalize.set(Boolean.FALSE);
-            }
         }
     }
 }
--- a/jdk/src/share/classes/java/io/FileOutputStream.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/io/FileOutputStream.java	Wed Oct 26 17:59:13 2011 -0700
@@ -63,21 +63,12 @@
     private final boolean append;
 
     /**
-     * The associated channel, initalized lazily.
+     * The associated channel, initialized lazily.
      */
     private FileChannel channel;
 
     private final Object closeLock = new Object();
     private volatile boolean closed = false;
-    private static final ThreadLocal<Boolean> runningFinalize =
-        new ThreadLocal<>();
-
-    private static boolean isRunningFinalize() {
-        Boolean val;
-        if ((val = runningFinalize.get()) != null)
-            return val.booleanValue();
-        return false;
-    }
 
     /**
      * Creates a file output stream to write to the file with the
@@ -355,10 +346,10 @@
         int useCount = fd.decrementAndGetUseCount();
 
         /*
-         * If FileDescriptor is still in use by another stream, the finalizer
+         * If FileDescriptor is still in use by another stream, we
          * will not close it.
          */
-        if ((useCount <= 0) || !isRunningFinalize()) {
+        if (useCount <= 0) {
             close0();
         }
     }
@@ -424,18 +415,7 @@
             if (fd == FileDescriptor.out || fd == FileDescriptor.err) {
                 flush();
             } else {
-
-                /*
-                 * Finalizer should not release the FileDescriptor if another
-                 * stream is still using it. If the user directly invokes
-                 * close() then the FileDescriptor is also released.
-                 */
-                runningFinalize.set(Boolean.TRUE);
-                try {
                     close();
-                } finally {
-                    runningFinalize.set(Boolean.FALSE);
-                }
             }
         }
     }
--- a/jdk/src/share/classes/java/io/RandomAccessFile.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/io/RandomAccessFile.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -590,8 +590,15 @@
          * Decrement FD use count associated with this stream.
          * The count got incremented by FileDescriptor during its construction.
          */
-        fd.decrementAndGetUseCount();
-        close0();
+        int useCount = fd.decrementAndGetUseCount();
+
+        /*
+         * If FileDescriptor is still in use by another stream, we
+         * will not close it.
+         */
+        if (useCount <= 0) {
+            close0();
+        }
     }
 
     //
--- a/jdk/src/share/classes/java/lang/Boolean.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/Boolean.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -101,7 +101,7 @@
      * @param   s   the string to be converted to a {@code Boolean}.
      */
     public Boolean(String s) {
-        this(toBoolean(s));
+        this(parseBoolean(s));
     }
 
     /**
@@ -118,7 +118,7 @@
      * @since 1.5
      */
     public static boolean parseBoolean(String s) {
-        return toBoolean(s);
+        return ((s != null) && s.equalsIgnoreCase("true"));
     }
 
     /**
@@ -159,7 +159,7 @@
      * @return  the {@code Boolean} value represented by the string.
      */
     public static Boolean valueOf(String s) {
-        return toBoolean(s) ? TRUE : FALSE;
+        return parseBoolean(s) ? TRUE : FALSE;
     }
 
     /**
@@ -229,15 +229,16 @@
      *
      * @param   name   the system property name.
      * @return  the {@code boolean} value of the system property.
+     * @throws  SecurityException for the same reasons as
+     *          {@link System#getProperty(String) System.getProperty}
      * @see     java.lang.System#getProperty(java.lang.String)
      * @see     java.lang.System#getProperty(java.lang.String, java.lang.String)
      */
     public static boolean getBoolean(String name) {
         boolean result = false;
         try {
-            result = toBoolean(System.getProperty(name));
-        } catch (IllegalArgumentException e) {
-        } catch (NullPointerException e) {
+            result = parseBoolean(System.getProperty(name));
+        } catch (IllegalArgumentException | NullPointerException e) {
         }
         return result;
     }
@@ -275,8 +276,4 @@
     public static int compare(boolean x, boolean y) {
         return (x == y) ? 0 : (x ? 1 : -1);
     }
-
-    private static boolean toBoolean(String name) {
-        return ((name != null) && name.equalsIgnoreCase("true"));
-    }
 }
--- a/jdk/src/share/classes/java/lang/Double.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/Double.java	Wed Oct 26 17:59:13 2011 -0700
@@ -276,14 +276,14 @@
          * 7.19.6.1; however, the output of this method is more
          * tightly specified.
          */
-        if (!FpUtils.isFinite(d) )
+        if (!isFinite(d) )
             // For infinity and NaN, use the decimal output.
             return Double.toString(d);
         else {
             // Initialized to maximum size of output.
             StringBuffer answer = new StringBuffer(24);
 
-            if (FpUtils.rawCopySign(1.0, d) == -1.0) // value is negative,
+            if (Math.copySign(1.0, d) == -1.0)    // value is negative,
                 answer.append("-");                  // so append sign info
 
             answer.append("0x");
@@ -322,7 +322,7 @@
                 // E_min -1).
                 answer.append("p" + (subnormal ?
                                DoubleConsts.MIN_EXPONENT:
-                               FpUtils.getExponent(d) ));
+                               Math.getExponent(d) ));
             }
             return answer.toString();
         }
@@ -548,7 +548,7 @@
      * @return  {@code true} if the value of the argument is NaN;
      *          {@code false} otherwise.
      */
-    static public boolean isNaN(double v) {
+    public static boolean isNaN(double v) {
         return (v != v);
     }
 
@@ -560,11 +560,25 @@
      * @return  {@code true} if the value of the argument is positive
      *          infinity or negative infinity; {@code false} otherwise.
      */
-    static public boolean isInfinite(double v) {
+    public static boolean isInfinite(double v) {
         return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
     }
 
     /**
+     * Returns {@code true} if the argument is a finite floating-point
+     * value; returns {@code false} otherwise (for NaN and infinity
+     * arguments).
+     *
+     * @param d the {@code double} value to be tested
+     * @return {@code true} if the argument is a finite
+     * floating-point value, {@code false} otherwise.
+     * @since 1.8
+     */
+    public static boolean isFinite(double d) {
+        return Math.abs(d) <= DoubleConsts.MAX_VALUE;
+    }
+
+    /**
      * The value of the Double.
      *
      * @serial
--- a/jdk/src/share/classes/java/lang/Float.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/Float.java	Wed Oct 26 17:59:13 2011 -0700
@@ -26,7 +26,6 @@
 package java.lang;
 
 import sun.misc.FloatingDecimal;
-import sun.misc.FpUtils;
 import sun.misc.FloatConsts;
 import sun.misc.DoubleConsts;
 
@@ -279,10 +278,10 @@
             // Adjust exponent to create subnormal double, then
             // replace subnormal double exponent with subnormal float
             // exponent
-            String s = Double.toHexString(FpUtils.scalb((double)f,
-                                                        /* -1022+126 */
-                                                        DoubleConsts.MIN_EXPONENT-
-                                                        FloatConsts.MIN_EXPONENT));
+            String s = Double.toHexString(Math.scalb((double)f,
+                                                     /* -1022+126 */
+                                                     DoubleConsts.MIN_EXPONENT-
+                                                     FloatConsts.MIN_EXPONENT));
             return s.replaceFirst("p-1022$", "p-126");
         }
         else // double string will be the same as float string
@@ -460,7 +459,7 @@
      * @return  {@code true} if the argument is NaN;
      *          {@code false} otherwise.
      */
-    static public boolean isNaN(float v) {
+    public static boolean isNaN(float v) {
         return (v != v);
     }
 
@@ -472,10 +471,25 @@
      * @return  {@code true} if the argument is positive infinity or
      *          negative infinity; {@code false} otherwise.
      */
-    static public boolean isInfinite(float v) {
+    public static boolean isInfinite(float v) {
         return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
     }
 
+
+    /**
+     * Returns {@code true} if the argument is a finite floating-point
+     * value; returns {@code false} otherwise (for NaN and infinity
+     * arguments).
+     *
+     * @param f the {@code float} value to be tested
+     * @return {@code true} if the argument is a finite
+     * floating-point value, {@code false} otherwise.
+     * @since 1.8
+     */
+     public static boolean isFinite(float f) {
+        return Math.abs(f) <= FloatConsts.MAX_VALUE;
+    }
+
     /**
      * The value of the Float.
      *
--- a/jdk/src/share/classes/java/lang/Integer.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/Integer.java	Wed Oct 26 17:59:13 2011 -0700
@@ -797,6 +797,8 @@
      *
      * @param   nm   property name.
      * @return  the {@code Integer} value of the property.
+     * @throws  SecurityException for the same reasons as
+     *          {@link System#getProperty(String) System.getProperty}
      * @see     java.lang.System#getProperty(java.lang.String)
      * @see     java.lang.System#getProperty(java.lang.String, java.lang.String)
      */
@@ -841,6 +843,8 @@
      * @param   nm   property name.
      * @param   val   default value.
      * @return  the {@code Integer} value of the property.
+     * @throws  SecurityException for the same reasons as
+     *          {@link System#getProperty(String) System.getProperty}
      * @see     java.lang.System#getProperty(java.lang.String)
      * @see     java.lang.System#getProperty(java.lang.String, java.lang.String)
      */
@@ -881,6 +885,8 @@
      * @param   nm   property name.
      * @param   val   default value.
      * @return  the {@code Integer} value of the property.
+     * @throws  SecurityException for the same reasons as
+     *          {@link System#getProperty(String) System.getProperty}
      * @see     System#getProperty(java.lang.String)
      * @see     System#getProperty(java.lang.String, java.lang.String)
      */
--- a/jdk/src/share/classes/java/lang/Long.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/Long.java	Wed Oct 26 17:59:13 2011 -0700
@@ -827,6 +827,8 @@
      *
      * @param   nm   property name.
      * @return  the {@code Long} value of the property.
+     * @throws  SecurityException for the same reasons as
+     *          {@link System#getProperty(String) System.getProperty}
      * @see     java.lang.System#getProperty(java.lang.String)
      * @see     java.lang.System#getProperty(java.lang.String, java.lang.String)
      */
@@ -870,6 +872,8 @@
      * @param   nm    property name.
      * @param   val   default value.
      * @return  the {@code Long} value of the property.
+     * @throws  SecurityException for the same reasons as
+     *          {@link System#getProperty(String) System.getProperty}
      * @see     java.lang.System#getProperty(java.lang.String)
      * @see     java.lang.System#getProperty(java.lang.String, java.lang.String)
      */
@@ -917,6 +921,8 @@
      * @param   nm   property name.
      * @param   val   default value.
      * @return  the {@code Long} value of the property.
+     * @throws  SecurityException for the same reasons as
+     *          {@link System#getProperty(String) System.getProperty}
      * @see     System#getProperty(java.lang.String)
      * @see     System#getProperty(java.lang.String, java.lang.String)
      */
--- a/jdk/src/share/classes/java/lang/Math.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/Math.java	Wed Oct 26 17:59:13 2011 -0700
@@ -26,6 +26,8 @@
 package java.lang;
 import java.util.Random;
 
+import sun.misc.FloatConsts;
+import sun.misc.DoubleConsts;
 
 /**
  * The class {@code Math} contains methods for performing basic
@@ -963,7 +965,31 @@
      * @since 1.5
      */
     public static double ulp(double d) {
-        return sun.misc.FpUtils.ulp(d);
+        int exp = getExponent(d);
+
+        switch(exp) {
+        case DoubleConsts.MAX_EXPONENT+1:       // NaN or infinity
+            return Math.abs(d);
+
+        case DoubleConsts.MIN_EXPONENT-1:       // zero or subnormal
+            return Double.MIN_VALUE;
+
+        default:
+            assert exp <= DoubleConsts.MAX_EXPONENT && exp >= DoubleConsts.MIN_EXPONENT;
+
+            // ulp(x) is usually 2^(SIGNIFICAND_WIDTH-1)*(2^ilogb(x))
+            exp = exp - (DoubleConsts.SIGNIFICAND_WIDTH-1);
+            if (exp >= DoubleConsts.MIN_EXPONENT) {
+                return powerOfTwoD(exp);
+            }
+            else {
+                // return a subnormal result; left shift integer
+                // representation of Double.MIN_VALUE appropriate
+                // number of positions
+                return Double.longBitsToDouble(1L <<
+                (exp - (DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1)) ));
+            }
+        }
     }
 
     /**
@@ -990,7 +1016,31 @@
      * @since 1.5
      */
     public static float ulp(float f) {
-        return sun.misc.FpUtils.ulp(f);
+        int exp = getExponent(f);
+
+        switch(exp) {
+        case FloatConsts.MAX_EXPONENT+1:        // NaN or infinity
+            return Math.abs(f);
+
+        case FloatConsts.MIN_EXPONENT-1:        // zero or subnormal
+            return FloatConsts.MIN_VALUE;
+
+        default:
+            assert exp <= FloatConsts.MAX_EXPONENT && exp >= FloatConsts.MIN_EXPONENT;
+
+            // ulp(x) is usually 2^(SIGNIFICAND_WIDTH-1)*(2^ilogb(x))
+            exp = exp - (FloatConsts.SIGNIFICAND_WIDTH-1);
+            if (exp >= FloatConsts.MIN_EXPONENT) {
+                return powerOfTwoF(exp);
+            }
+            else {
+                // return a subnormal result; left shift integer
+                // representation of FloatConsts.MIN_VALUE appropriate
+                // number of positions
+                return Float.intBitsToFloat(1 <<
+                (exp - (FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1)) ));
+            }
+        }
     }
 
     /**
@@ -1011,7 +1061,7 @@
      * @since 1.5
      */
     public static double signum(double d) {
-        return sun.misc.FpUtils.signum(d);
+        return (d == 0.0 || Double.isNaN(d))?d:copySign(1.0, d);
     }
 
     /**
@@ -1032,7 +1082,7 @@
      * @since 1.5
      */
     public static float signum(float f) {
-        return sun.misc.FpUtils.signum(f);
+        return (f == 0.0f || Float.isNaN(f))?f:copySign(1.0f, f);
     }
 
     /**
@@ -1252,7 +1302,11 @@
      * @since 1.6
      */
     public static double copySign(double magnitude, double sign) {
-        return sun.misc.FpUtils.rawCopySign(magnitude, sign);
+        return Double.longBitsToDouble((Double.doubleToRawLongBits(sign) &
+                                        (DoubleConsts.SIGN_BIT_MASK)) |
+                                       (Double.doubleToRawLongBits(magnitude) &
+                                        (DoubleConsts.EXP_BIT_MASK |
+                                         DoubleConsts.SIGNIF_BIT_MASK)));
     }
 
     /**
@@ -1271,7 +1325,11 @@
      * @since 1.6
      */
     public static float copySign(float magnitude, float sign) {
-        return sun.misc.FpUtils.rawCopySign(magnitude, sign);
+        return Float.intBitsToFloat((Float.floatToRawIntBits(sign) &
+                                     (FloatConsts.SIGN_BIT_MASK)) |
+                                    (Float.floatToRawIntBits(magnitude) &
+                                     (FloatConsts.EXP_BIT_MASK |
+                                      FloatConsts.SIGNIF_BIT_MASK)));
     }
 
     /**
@@ -1289,7 +1347,13 @@
      * @since 1.6
      */
     public static int getExponent(float f) {
-        return sun.misc.FpUtils.getExponent(f);
+        /*
+         * Bitwise convert f to integer, mask out exponent bits, shift
+         * to the right and then subtract out float's bias adjust to
+         * get true exponent value
+         */
+        return ((Float.floatToRawIntBits(f) & FloatConsts.EXP_BIT_MASK) >>
+                (FloatConsts.SIGNIFICAND_WIDTH - 1)) - FloatConsts.EXP_BIAS;
     }
 
     /**
@@ -1307,7 +1371,13 @@
      * @since 1.6
      */
     public static int getExponent(double d) {
-        return sun.misc.FpUtils.getExponent(d);
+        /*
+         * Bitwise convert d to long, mask out exponent bits, shift
+         * to the right and then subtract out double's bias adjust to
+         * get true exponent value.
+         */
+        return (int)(((Double.doubleToRawLongBits(d) & DoubleConsts.EXP_BIT_MASK) >>
+                      (DoubleConsts.SIGNIFICAND_WIDTH - 1)) - DoubleConsts.EXP_BIAS);
     }
 
     /**
@@ -1351,7 +1421,63 @@
      * @since 1.6
      */
     public static double nextAfter(double start, double direction) {
-        return sun.misc.FpUtils.nextAfter(start, direction);
+        /*
+         * The cases:
+         *
+         * nextAfter(+infinity, 0)  == MAX_VALUE
+         * nextAfter(+infinity, +infinity)  == +infinity
+         * nextAfter(-infinity, 0)  == -MAX_VALUE
+         * nextAfter(-infinity, -infinity)  == -infinity
+         *
+         * are naturally handled without any additional testing
+         */
+
+        // First check for NaN values
+        if (Double.isNaN(start) || Double.isNaN(direction)) {
+            // return a NaN derived from the input NaN(s)
+            return start + direction;
+        } else if (start == direction) {
+            return direction;
+        } else {        // start > direction or start < direction
+            // Add +0.0 to get rid of a -0.0 (+0.0 + -0.0 => +0.0)
+            // then bitwise convert start to integer.
+            long transducer = Double.doubleToRawLongBits(start + 0.0d);
+
+            /*
+             * IEEE 754 floating-point numbers are lexicographically
+             * ordered if treated as signed- magnitude integers .
+             * Since Java's integers are two's complement,
+             * incrementing" the two's complement representation of a
+             * logically negative floating-point value *decrements*
+             * the signed-magnitude representation. Therefore, when
+             * the integer representation of a floating-point values
+             * is less than zero, the adjustment to the representation
+             * is in the opposite direction than would be expected at
+             * first .
+             */
+            if (direction > start) { // Calculate next greater value
+                transducer = transducer + (transducer >= 0L ? 1L:-1L);
+            } else  { // Calculate next lesser value
+                assert direction < start;
+                if (transducer > 0L)
+                    --transducer;
+                else
+                    if (transducer < 0L )
+                        ++transducer;
+                    /*
+                     * transducer==0, the result is -MIN_VALUE
+                     *
+                     * The transition from zero (implicitly
+                     * positive) to the smallest negative
+                     * signed magnitude value must be done
+                     * explicitly.
+                     */
+                    else
+                        transducer = DoubleConsts.SIGN_BIT_MASK | 1L;
+            }
+
+            return Double.longBitsToDouble(transducer);
+        }
     }
 
     /**
@@ -1394,7 +1520,63 @@
      * @since 1.6
      */
     public static float nextAfter(float start, double direction) {
-        return sun.misc.FpUtils.nextAfter(start, direction);
+        /*
+         * The cases:
+         *
+         * nextAfter(+infinity, 0)  == MAX_VALUE
+         * nextAfter(+infinity, +infinity)  == +infinity
+         * nextAfter(-infinity, 0)  == -MAX_VALUE
+         * nextAfter(-infinity, -infinity)  == -infinity
+         *
+         * are naturally handled without any additional testing
+         */
+
+        // First check for NaN values
+        if (Float.isNaN(start) || Double.isNaN(direction)) {
+            // return a NaN derived from the input NaN(s)
+            return start + (float)direction;
+        } else if (start == direction) {
+            return (float)direction;
+        } else {        // start > direction or start < direction
+            // Add +0.0 to get rid of a -0.0 (+0.0 + -0.0 => +0.0)
+            // then bitwise convert start to integer.
+            int transducer = Float.floatToRawIntBits(start + 0.0f);
+
+            /*
+             * IEEE 754 floating-point numbers are lexicographically
+             * ordered if treated as signed- magnitude integers .
+             * Since Java's integers are two's complement,
+             * incrementing" the two's complement representation of a
+             * logically negative floating-point value *decrements*
+             * the signed-magnitude representation. Therefore, when
+             * the integer representation of a floating-point values
+             * is less than zero, the adjustment to the representation
+             * is in the opposite direction than would be expected at
+             * first.
+             */
+            if (direction > start) {// Calculate next greater value
+                transducer = transducer + (transducer >= 0 ? 1:-1);
+            } else  { // Calculate next lesser value
+                assert direction < start;
+                if (transducer > 0)
+                    --transducer;
+                else
+                    if (transducer < 0 )
+                        ++transducer;
+                    /*
+                     * transducer==0, the result is -MIN_VALUE
+                     *
+                     * The transition from zero (implicitly
+                     * positive) to the smallest negative
+                     * signed magnitude value must be done
+                     * explicitly.
+                     */
+                    else
+                        transducer = FloatConsts.SIGN_BIT_MASK | 1;
+            }
+
+            return Float.intBitsToFloat(transducer);
+        }
     }
 
     /**
@@ -1423,7 +1605,13 @@
      * @since 1.6
      */
     public static double nextUp(double d) {
-        return sun.misc.FpUtils.nextUp(d);
+        if( Double.isNaN(d) || d == Double.POSITIVE_INFINITY)
+            return d;
+        else {
+            d += 0.0d;
+            return Double.longBitsToDouble(Double.doubleToRawLongBits(d) +
+                                           ((d >= 0.0d)?+1L:-1L));
+        }
     }
 
     /**
@@ -1452,9 +1640,88 @@
      * @since 1.6
      */
     public static float nextUp(float f) {
-        return sun.misc.FpUtils.nextUp(f);
+        if( Float.isNaN(f) || f == FloatConsts.POSITIVE_INFINITY)
+            return f;
+        else {
+            f += 0.0f;
+            return Float.intBitsToFloat(Float.floatToRawIntBits(f) +
+                                        ((f >= 0.0f)?+1:-1));
+        }
     }
 
+    /**
+     * Returns the floating-point value adjacent to {@code d} in
+     * the direction of negative infinity.  This method is
+     * semantically equivalent to {@code nextAfter(d,
+     * Double.NEGATIVE_INFINITY)}; however, a
+     * {@code nextDown} implementation may run faster than its
+     * equivalent {@code nextAfter} call.
+     *
+     * <p>Special Cases:
+     * <ul>
+     * <li> If the argument is NaN, the result is NaN.
+     *
+     * <li> If the argument is negative infinity, the result is
+     * negative infinity.
+     *
+     * <li> If the argument is zero, the result is
+     * {@code -Double.MIN_VALUE}
+     *
+     * </ul>
+     *
+     * @param d  starting floating-point value
+     * @return The adjacent floating-point value closer to negative
+     * infinity.
+     * @since 1.8
+     */
+    public static double nextDown(double d) {
+        if (Double.isNaN(d) || d == Double.NEGATIVE_INFINITY)
+            return d;
+        else {
+            if (d == 0.0)
+                return -Double.MIN_VALUE;
+            else
+                return Double.longBitsToDouble(Double.doubleToRawLongBits(d) +
+                                               ((d > 0.0d)?-1L:+1L));
+        }
+    }
+
+    /**
+     * Returns the floating-point value adjacent to {@code f} in
+     * the direction of negative infinity.  This method is
+     * semantically equivalent to {@code nextAfter(f,
+     * Float.NEGATIVE_INFINITY)}; however, a
+     * {@code nextDown} implementation may run faster than its
+     * equivalent {@code nextAfter} call.
+     *
+     * <p>Special Cases:
+     * <ul>
+     * <li> If the argument is NaN, the result is NaN.
+     *
+     * <li> If the argument is negative infinity, the result is
+     * negative infinity.
+     *
+     * <li> If the argument is zero, the result is
+     * {@code -Float.MIN_VALUE}
+     *
+     * </ul>
+     *
+     * @param f  starting floating-point value
+     * @return The adjacent floating-point value closer to negative
+     * infinity.
+     * @since 1.8
+     */
+    public static float nextDown(float f) {
+        if (Float.isNaN(f) || f == Float.NEGATIVE_INFINITY)
+            return f;
+        else {
+            if (f == 0.0f)
+                return -Float.MIN_VALUE;
+            else
+                return Float.intBitsToFloat(Float.floatToRawIntBits(f) +
+                                            ((f > 0.0f)?-1:+1));
+        }
+    }
 
     /**
      * Return {@code d} &times;
@@ -1487,7 +1754,80 @@
      * @since 1.6
      */
     public static double scalb(double d, int scaleFactor) {
-        return sun.misc.FpUtils.scalb(d, scaleFactor);
+        /*
+         * This method does not need to be declared strictfp to
+         * compute the same correct result on all platforms.  When
+         * scaling up, it does not matter what order the
+         * multiply-store operations are done; the result will be
+         * finite or overflow regardless of the operation ordering.
+         * However, to get the correct result when scaling down, a
+         * particular ordering must be used.
+         *
+         * When scaling down, the multiply-store operations are
+         * sequenced so that it is not possible for two consecutive
+         * multiply-stores to return subnormal results.  If one
+         * multiply-store result is subnormal, the next multiply will
+         * round it away to zero.  This is done by first multiplying
+         * by 2 ^ (scaleFactor % n) and then multiplying several
+         * times by by 2^n as needed where n is the exponent of number
+         * that is a covenient power of two.  In this way, at most one
+         * real rounding error occurs.  If the double value set is
+         * being used exclusively, the rounding will occur on a
+         * multiply.  If the double-extended-exponent value set is
+         * being used, the products will (perhaps) be exact but the
+         * stores to d are guaranteed to round to the double value
+         * set.
+         *
+         * It is _not_ a valid implementation to first multiply d by
+         * 2^MIN_EXPONENT and then by 2 ^ (scaleFactor %
+         * MIN_EXPONENT) since even in a strictfp program double
+         * rounding on underflow could occur; e.g. if the scaleFactor
+         * argument was (MIN_EXPONENT - n) and the exponent of d was a
+         * little less than -(MIN_EXPONENT - n), meaning the final
+         * result would be subnormal.
+         *
+         * Since exact reproducibility of this method can be achieved
+         * without any undue performance burden, there is no
+         * compelling reason to allow double rounding on underflow in
+         * scalb.
+         */
+
+        // magnitude of a power of two so large that scaling a finite
+        // nonzero value by it would be guaranteed to over or
+        // underflow; due to rounding, scaling down takes takes an
+        // additional power of two which is reflected here
+        final int MAX_SCALE = DoubleConsts.MAX_EXPONENT + -DoubleConsts.MIN_EXPONENT +
+                              DoubleConsts.SIGNIFICAND_WIDTH + 1;
+        int exp_adjust = 0;
+        int scale_increment = 0;
+        double exp_delta = Double.NaN;
+
+        // Make sure scaling factor is in a reasonable range
+
+        if(scaleFactor < 0) {
+            scaleFactor = Math.max(scaleFactor, -MAX_SCALE);
+            scale_increment = -512;
+            exp_delta = twoToTheDoubleScaleDown;
+        }
+        else {
+            scaleFactor = Math.min(scaleFactor, MAX_SCALE);
+            scale_increment = 512;
+            exp_delta = twoToTheDoubleScaleUp;
+        }
+
+        // Calculate (scaleFactor % +/-512), 512 = 2^9, using
+        // technique from "Hacker's Delight" section 10-2.
+        int t = (scaleFactor >> 9-1) >>> 32 - 9;
+        exp_adjust = ((scaleFactor + t) & (512 -1)) - t;
+
+        d *= powerOfTwoD(exp_adjust);
+        scaleFactor -= exp_adjust;
+
+        while(scaleFactor != 0) {
+            d *= exp_delta;
+            scaleFactor -= scale_increment;
+        }
+        return d;
     }
 
     /**
@@ -1521,6 +1861,49 @@
      * @since 1.6
      */
     public static float scalb(float f, int scaleFactor) {
-        return sun.misc.FpUtils.scalb(f, scaleFactor);
+        // magnitude of a power of two so large that scaling a finite
+        // nonzero value by it would be guaranteed to over or
+        // underflow; due to rounding, scaling down takes takes an
+        // additional power of two which is reflected here
+        final int MAX_SCALE = FloatConsts.MAX_EXPONENT + -FloatConsts.MIN_EXPONENT +
+                              FloatConsts.SIGNIFICAND_WIDTH + 1;
+
+        // Make sure scaling factor is in a reasonable range
+        scaleFactor = Math.max(Math.min(scaleFactor, MAX_SCALE), -MAX_SCALE);
+
+        /*
+         * Since + MAX_SCALE for float fits well within the double
+         * exponent range and + float -> double conversion is exact
+         * the multiplication below will be exact. Therefore, the
+         * rounding that occurs when the double product is cast to
+         * float will be the correctly rounded float result.  Since
+         * all operations other than the final multiply will be exact,
+         * it is not necessary to declare this method strictfp.
+         */
+        return (float)((double)f*powerOfTwoD(scaleFactor));
+    }
+
+    // Constants used in scalb
+    static double twoToTheDoubleScaleUp = powerOfTwoD(512);
+    static double twoToTheDoubleScaleDown = powerOfTwoD(-512);
+
+    /**
+     * Returns a floating-point power of two in the normal range.
+     */
+    static double powerOfTwoD(int n) {
+        assert(n >= DoubleConsts.MIN_EXPONENT && n <= DoubleConsts.MAX_EXPONENT);
+        return Double.longBitsToDouble((((long)n + (long)DoubleConsts.EXP_BIAS) <<
+                                        (DoubleConsts.SIGNIFICAND_WIDTH-1))
+                                       & DoubleConsts.EXP_BIT_MASK);
+    }
+
+    /**
+     * Returns a floating-point power of two in the normal range.
+     */
+    public static float powerOfTwoF(int n) {
+        assert(n >= FloatConsts.MIN_EXPONENT && n <= FloatConsts.MAX_EXPONENT);
+        return Float.intBitsToFloat(((n + FloatConsts.EXP_BIAS) <<
+                                     (FloatConsts.SIGNIFICAND_WIDTH-1))
+                                    & FloatConsts.EXP_BIT_MASK);
     }
 }
--- a/jdk/src/share/classes/java/lang/SafeVarargs.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/SafeVarargs.java	Wed Oct 26 17:59:13 2011 -0700
@@ -82,6 +82,7 @@
  *
  * </ul>
  *
+ * @since 1.7
  * @jls 4.7 Reifiable Types
  * @jls 8.4.1 Formal Parameters
  */
--- a/jdk/src/share/classes/java/lang/StrictMath.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/StrictMath.java	Wed Oct 26 17:59:13 2011 -0700
@@ -25,7 +25,6 @@
 
 package java.lang;
 import java.util.Random;
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 /**
@@ -428,7 +427,7 @@
          * 1.0, which is exact too.
          */
         double twoToThe52 = (double)(1L << 52); // 2^52
-        double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info
+        double sign = Math.copySign(1.0, a); // preserve sign info
         a = Math.abs(a);
 
         if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
@@ -955,7 +954,7 @@
      * @since 1.5
      */
     public static double ulp(double d) {
-        return sun.misc.FpUtils.ulp(d);
+        return Math.ulp(d);
     }
 
     /**
@@ -982,7 +981,7 @@
      * @since 1.5
      */
     public static float ulp(float f) {
-        return sun.misc.FpUtils.ulp(f);
+        return Math.ulp(f);
     }
 
     /**
@@ -1003,7 +1002,7 @@
      * @since 1.5
      */
     public static double signum(double d) {
-        return sun.misc.FpUtils.signum(d);
+        return Math.signum(d);
     }
 
     /**
@@ -1024,7 +1023,7 @@
      * @since 1.5
      */
     public static float signum(float f) {
-        return sun.misc.FpUtils.signum(f);
+        return Math.signum(f);
     }
 
     /**
@@ -1202,7 +1201,7 @@
      * @since 1.6
      */
     public static double copySign(double magnitude, double sign) {
-        return sun.misc.FpUtils.copySign(magnitude, sign);
+        return Math.copySign(magnitude, (Double.isNaN(sign)?1.0d:sign));
     }
 
     /**
@@ -1218,7 +1217,7 @@
      * @since 1.6
      */
     public static float copySign(float magnitude, float sign) {
-        return sun.misc.FpUtils.copySign(magnitude, sign);
+        return Math.copySign(magnitude, (Float.isNaN(sign)?1.0f:sign));
     }
     /**
      * Returns the unbiased exponent used in the representation of a
@@ -1234,7 +1233,7 @@
      * @since 1.6
      */
     public static int getExponent(float f) {
-        return sun.misc.FpUtils.getExponent(f);
+        return Math.getExponent(f);
     }
 
     /**
@@ -1251,7 +1250,7 @@
      * @since 1.6
      */
     public static int getExponent(double d) {
-        return sun.misc.FpUtils.getExponent(d);
+        return Math.getExponent(d);
     }
 
     /**
@@ -1294,7 +1293,7 @@
      * @since 1.6
      */
     public static double nextAfter(double start, double direction) {
-        return sun.misc.FpUtils.nextAfter(start, direction);
+        return Math.nextAfter(start, direction);
     }
 
     /**
@@ -1336,7 +1335,7 @@
      * @since 1.6
      */
     public static float nextAfter(float start, double direction) {
-        return sun.misc.FpUtils.nextAfter(start, direction);
+        return Math.nextAfter(start, direction);
     }
 
     /**
@@ -1365,7 +1364,7 @@
      * @since 1.6
      */
     public static double nextUp(double d) {
-        return sun.misc.FpUtils.nextUp(d);
+        return Math.nextUp(d);
     }
 
     /**
@@ -1394,9 +1393,66 @@
      * @since 1.6
      */
     public static float nextUp(float f) {
-        return sun.misc.FpUtils.nextUp(f);
+        return Math.nextUp(f);
     }
 
+    /**
+     * Returns the floating-point value adjacent to {@code d} in
+     * the direction of negative infinity.  This method is
+     * semantically equivalent to {@code nextAfter(d,
+     * Double.NEGATIVE_INFINITY)}; however, a
+     * {@code nextDown} implementation may run faster than its
+     * equivalent {@code nextAfter} call.
+     *
+     * <p>Special Cases:
+     * <ul>
+     * <li> If the argument is NaN, the result is NaN.
+     *
+     * <li> If the argument is negative infinity, the result is
+     * negative infinity.
+     *
+     * <li> If the argument is zero, the result is
+     * {@code -Double.MIN_VALUE}
+     *
+     * </ul>
+     *
+     * @param d  starting floating-point value
+     * @return The adjacent floating-point value closer to negative
+     * infinity.
+     * @since 1.8
+     */
+    public static double nextDown(double d) {
+        return Math.nextDown(d);
+    }
+
+    /**
+     * Returns the floating-point value adjacent to {@code f} in
+     * the direction of negative infinity.  This method is
+     * semantically equivalent to {@code nextAfter(f,
+     * Float.NEGATIVE_INFINITY)}; however, a
+     * {@code nextDown} implementation may run faster than its
+     * equivalent {@code nextAfter} call.
+     *
+     * <p>Special Cases:
+     * <ul>
+     * <li> If the argument is NaN, the result is NaN.
+     *
+     * <li> If the argument is negative infinity, the result is
+     * negative infinity.
+     *
+     * <li> If the argument is zero, the result is
+     * {@code -Float.MIN_VALUE}
+     *
+     * </ul>
+     *
+     * @param f  starting floating-point value
+     * @return The adjacent floating-point value closer to negative
+     * infinity.
+     * @since 1.8
+     */
+    public static float nextDown(float f) {
+        return Math.nextDown(f);
+    }
 
     /**
      * Return {@code d} &times;
@@ -1429,7 +1485,7 @@
      * @since 1.6
      */
     public static double scalb(double d, int scaleFactor) {
-        return sun.misc.FpUtils.scalb(d, scaleFactor);
+        return Math.scalb(d, scaleFactor);
     }
 
     /**
@@ -1463,6 +1519,6 @@
      * @since 1.6
      */
     public static float scalb(float f, int scaleFactor) {
-        return sun.misc.FpUtils.scalb(f, scaleFactor);
+        return Math.scalb(f, scaleFactor);
     }
 }
--- a/jdk/src/share/classes/java/lang/invoke/AdapterMethodHandle.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/invoke/AdapterMethodHandle.java	Wed Oct 26 17:59:13 2011 -0700
@@ -53,7 +53,7 @@
         // JVM might update VM-specific bits of conversion (ignore)
         MethodHandleNatives.init(this, target, convArgPos(conv));
     }
-    private AdapterMethodHandle(MethodHandle target, MethodType newType,
+    AdapterMethodHandle(MethodHandle target, MethodType newType,
                 long conv) {
         this(target, newType, conv, null);
     }
@@ -423,7 +423,7 @@
                 insertStackMove(stackMove)
                 );
     }
-    private static long makeConv(int convOp) {
+    static long makeConv(int convOp) {
         assert(convOp == OP_RETYPE_ONLY || convOp == OP_RETYPE_RAW);
         return ((long)-1 << 32) | (convOp << CONV_OP_SHIFT);   // stackMove, src, dst all zero
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/lang/invoke/CountingMethodHandle.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang.invoke;
+
+import static java.lang.invoke.MethodHandleNatives.Constants.*;
+
+/**
+ * This method handle is used to optionally provide a count of how
+ * many times it was invoked.
+ *
+ * @author never
+ */
+class CountingMethodHandle extends AdapterMethodHandle {
+    private int vmcount;
+
+    private CountingMethodHandle(MethodHandle target) {
+        super(target, target.type(), AdapterMethodHandle.makeConv(OP_RETYPE_ONLY));
+    }
+
+    /** Wrap the incoming MethodHandle in a CountingMethodHandle if they are enabled */
+    static MethodHandle wrap(MethodHandle mh) {
+        if (MethodHandleNatives.COUNT_GWT) {
+            return new CountingMethodHandle(mh);
+        }
+        return mh;
+    }
+}
--- a/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -749,8 +749,8 @@
         assert(target.type().equals(fallback.type()));
         MethodHandle tailcall = MethodHandles.exactInvoker(target.type());
         MethodHandle select = selectAlternative();
-        select = bindArgument(select, 2, fallback);
-        select = bindArgument(select, 1, target);
+        select = bindArgument(select, 2, CountingMethodHandle.wrap(fallback));
+        select = bindArgument(select, 1, CountingMethodHandle.wrap(target));
         // select(z: boolean) => (z ? target : fallback)
         MethodHandle filter = filterArgument(tailcall, 0, select);
         assert(filter.type().parameterType(0) == boolean.class);
--- a/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Wed Oct 26 17:59:13 2011 -0700
@@ -120,6 +120,8 @@
 
     static final int OP_ROT_ARGS_DOWN_LIMIT_BIAS;
 
+    static final boolean COUNT_GWT;
+
     private static native void registerNatives();
     static {
         registerNatives();
@@ -131,6 +133,7 @@
         k                           = getConstant(Constants.GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS);
         OP_ROT_ARGS_DOWN_LIMIT_BIAS = (k != 0) ? (byte)k : -1;
         HAVE_RICOCHET_FRAMES        = (CONV_OP_IMPLEMENTED_MASK & (1<<OP_COLLECT_ARGS)) != 0;
+        COUNT_GWT                   = getConstant(Constants.GC_COUNT_GWT) != 0;
         //sun.reflect.Reflection.registerMethodsToFilter(MethodHandleImpl.class, "init");
     }
 
@@ -143,7 +146,8 @@
                 GC_JVM_PUSH_LIMIT = 0,
                 GC_JVM_STACK_MOVE_UNIT = 1,
                 GC_CONV_OP_IMPLEMENTED_MASK = 2,
-                GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS = 3;
+                GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS = 3,
+                GC_COUNT_GWT = 4;
         static final int
                 ETF_HANDLE_OR_METHOD_NAME = 0, // all available data (immediate MH or method)
                 ETF_DIRECT_HANDLE         = 1, // ultimate method handle (will be a DMH, may be self)
--- a/jdk/src/share/classes/java/math/BigInteger.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/math/BigInteger.java	Wed Oct 26 17:59:13 2011 -0700
@@ -2919,6 +2919,7 @@
      * result with the opposite sign.
      *
      * @return this BigInteger converted to an {@code int}.
+     * @see #intValueExact()
      */
     public int intValue() {
         int result = 0;
@@ -2939,6 +2940,7 @@
      * result with the opposite sign.
      *
      * @return this BigInteger converted to a {@code long}.
+     * @see #longValueExact()
      */
     public long longValue() {
         long result = 0;
@@ -3382,4 +3384,84 @@
         }
         return result;
     }
+
+    /**
+     * Converts this {@code BigInteger} to a {@code long}, checking
+     * for lost information.  If the value of this {@code BigInteger}
+     * is out of the range of the {@code long} type, then an
+     * {@code ArithmeticException} is thrown.
+     *
+     * @return this {@code BigInteger} converted to a {@code long}.
+     * @throws ArithmeticException if the value of {@code this} will
+     * not exactly fit in a {@code long}.
+     * @see BigInteger#longValue
+     * @since  1.8
+     */
+    public long longValueExact() {
+        if (mag.length <= 2 && bitLength() <= 63)
+            return longValue();
+        else
+            throw new ArithmeticException("BigInteger out of long range");
+    }
+
+    /**
+     * Converts this {@code BigInteger} to an {@code int}, checking
+     * for lost information.  If the value of this {@code BigInteger}
+     * is out of the range of the {@code int} type, then an
+     * {@code ArithmeticException} is thrown.
+     *
+     * @return this {@code BigInteger} converted to an {@code int}.
+     * @throws ArithmeticException if the value of {@code this} will
+     * not exactly fit in a {@code int}.
+     * @see BigInteger#intValue
+     * @since  1.8
+     */
+    public int intValueExact() {
+        if (mag.length <= 1 && bitLength() <= 31)
+            return intValue();
+        else
+            throw new ArithmeticException("BigInteger out of int range");
+    }
+
+    /**
+     * Converts this {@code BigInteger} to a {@code short}, checking
+     * for lost information.  If the value of this {@code BigInteger}
+     * is out of the range of the {@code short} type, then an
+     * {@code ArithmeticException} is thrown.
+     *
+     * @return this {@code BigInteger} converted to a {@code short}.
+     * @throws ArithmeticException if the value of {@code this} will
+     * not exactly fit in a {@code short}.
+     * @see BigInteger#shortValue
+     * @since  1.8
+     */
+    public short shortValueExact() {
+        if (mag.length <= 1 && bitLength() <= 31) {
+            int value = intValue();
+            if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE)
+                return shortValue();
+        }
+        throw new ArithmeticException("BigInteger out of short range");
+    }
+
+    /**
+     * Converts this {@code BigInteger} to a {@code byte}, checking
+     * for lost information.  If the value of this {@code BigInteger}
+     * is out of the range of the {@code byte} type, then an
+     * {@code ArithmeticException} is thrown.
+     *
+     * @return this {@code BigInteger} converted to a {@code byte}.
+     * @throws ArithmeticException if the value of {@code this} will
+     * not exactly fit in a {@code byte}.
+     * @see BigInteger#byteValue
+     * @since  1.8
+     */
+    public byte byteValueExact() {
+        if (mag.length <= 1 && bitLength() <= 31) {
+            int value = intValue();
+            if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE)
+                return byteValue();
+        }
+        throw new ArithmeticException("BigInteger out of byte range");
+    }
 }
--- a/jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -26,8 +26,6 @@
 
 import java.io.FileDescriptor;
 import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.util.Enumeration;
 import sun.net.ResourceManager;
 
 /**
@@ -46,7 +44,7 @@
     int timeout = 0;
     boolean connected = false;
     private int trafficClass = 0;
-    private InetAddress connectedAddress = null;
+    protected InetAddress connectedAddress = null;
     private int connectedPort = -1;
 
     /* cached socket options */
@@ -66,8 +64,8 @@
      * Creates a datagram socket
      */
     protected synchronized void create() throws SocketException {
+        ResourceManager.beforeUdpCreate();
         fd = new FileDescriptor();
-        ResourceManager.beforeUdpCreate();
         try {
             datagramSocketCreate();
         } catch (SocketException ioe) {
@@ -153,11 +151,13 @@
      * Set the TTL (time-to-live) option.
      * @param TTL to be set.
      */
+    @Deprecated
     protected abstract void setTTL(byte ttl) throws IOException;
 
     /**
      * Get the TTL (time-to-live) option.
      */
+    @Deprecated
     protected abstract byte getTTL() throws IOException;
 
     /**
--- a/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -71,7 +71,7 @@
 
    /* whether this Socket is a stream (TCP) socket or not (UDP)
     */
-    private boolean stream;
+    protected boolean stream;
 
     /**
      * Load net library into runtime.
@@ -86,10 +86,11 @@
      * is a stream socket (true) or an unconnected UDP socket (false).
      */
     protected synchronized void create(boolean stream) throws IOException {
-        fd = new FileDescriptor();
         this.stream = stream;
         if (!stream) {
             ResourceManager.beforeUdpCreate();
+            // only create the fd after we know we will be able to create the socket
+            fd = new FileDescriptor();
             try {
                 socketCreate(false);
             } catch (IOException ioe) {
@@ -98,6 +99,7 @@
                 throw ioe;
             }
         } else {
+            fd = new FileDescriptor();
             socketCreate(true);
         }
         if (socket != null)
--- a/jdk/src/share/classes/java/net/ContentHandler.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/ContentHandler.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,7 +96,7 @@
      * @exception  IOException  if an I/O error occurs while reading the object.
      * @since 1.3
      */
-    public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
+    public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
         Object obj = getContent(urlc);
 
         for (int i = 0; i < classes.length; i++) {
--- a/jdk/src/share/classes/java/net/CookieManager.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/CookieManager.java	Wed Oct 26 17:59:13 2011 -0700
@@ -249,7 +249,6 @@
         return Collections.unmodifiableMap(cookieMap);
     }
 
-
     public void
         put(URI uri, Map<String, List<String>> responseHeaders)
         throws IOException
@@ -284,7 +283,7 @@
                         cookies = HttpCookie.parse(headerValue);
                     } catch (IllegalArgumentException e) {
                         // Bogus header, make an empty list and log the error
-                        cookies = java.util.Collections.EMPTY_LIST;
+                        cookies = java.util.Collections.emptyList();
                         if (logger.isLoggable(PlatformLogger.SEVERE)) {
                             logger.severe("Invalid cookie for " + uri + ": " + headerValue);
                         }
--- a/jdk/src/share/classes/java/net/DatagramSocket.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/DatagramSocket.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,7 @@
 
 package java.net;
 
-import java.io.FileDescriptor;
 import java.io.IOException;
-import java.io.InterruptedIOException;
 import java.nio.channels.DatagramChannel;
 import java.security.AccessController;
 import java.security.PrivilegedExceptionAction;
@@ -289,7 +287,7 @@
             AccessController.doPrivileged(
                 new PrivilegedExceptionAction<Void>() {
                     public Void run() throws NoSuchMethodException {
-                        Class[] cl = new Class[1];
+                        Class<?>[] cl = new Class<?>[1];
                         cl[0] = DatagramPacket.class;
                         impl.getClass().getDeclaredMethod("peekData", cl);
                         return null;
@@ -300,7 +298,7 @@
         }
     }
 
-    static Class implClass = null;
+    static Class<?> implClass = null;
 
     void createImpl() throws SocketException {
         if (impl == null) {
--- a/jdk/src/share/classes/java/net/HttpURLConnection.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/HttpURLConnection.java	Wed Oct 26 17:59:13 2011 -0700
@@ -535,6 +535,7 @@
         return responseMessage;
     }
 
+    @SuppressWarnings("deprecation")
     public long getHeaderFieldDate(String name, long Default) {
         String dateString = getHeaderField(name);
         try {
--- a/jdk/src/share/classes/java/net/InMemoryCookieStore.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/InMemoryCookieStore.java	Wed Oct 26 17:59:13 2011 -0700
@@ -91,8 +91,10 @@
                 if (cookie.getDomain() != null) {
                     addIndex(domainIndex, cookie.getDomain(), cookie);
                 }
-                // add it to uri index, too
-                addIndex(uriIndex, getEffectiveURI(uri), cookie);
+                if (uri != null) {
+                    // add it to uri index, too
+                    addIndex(uriIndex, getEffectiveURI(uri), cookie);
+                }
             }
         } finally {
             lock.unlock();
--- a/jdk/src/share/classes/java/net/Inet4Address.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/Inet4Address.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,7 @@
 
 package java.net;
 
-import java.security.AccessController;
 import java.io.ObjectStreamException;
-import sun.security.action.*;
 
 /**
  * This class represents an Internet Protocol version 4 (IPv4) address.
--- a/jdk/src/share/classes/java/net/Inet4AddressImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/Inet4AddressImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,11 +59,11 @@
           /*
            * Let's make sure we use an address of the proper family
            */
-          java.util.Enumeration it = netif.getInetAddresses();
+          java.util.Enumeration<InetAddress> it = netif.getInetAddresses();
           InetAddress inetaddr = null;
           while (!(inetaddr instanceof Inet4Address) &&
                  it.hasMoreElements())
-              inetaddr = (InetAddress) it.nextElement();
+              inetaddr = it.nextElement();
           if (inetaddr instanceof Inet4Address)
               ifaddr = inetaddr.getAddress();
       }
--- a/jdk/src/share/classes/java/net/Inet6Address.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/Inet6Address.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -383,9 +383,9 @@
         while (en.hasMoreElements()) {
             NetworkInterface ifc = en.nextElement();
             if (ifc.getName().equals (ifname)) {
-                Enumeration addresses = ifc.getInetAddresses();
+                Enumeration<InetAddress> addresses = ifc.getInetAddresses();
                 while (addresses.hasMoreElements()) {
-                    InetAddress addr = (InetAddress)addresses.nextElement();
+                    InetAddress addr = addresses.nextElement();
                     if (!(addr instanceof Inet6Address)) {
                         continue;
                     }
--- a/jdk/src/share/classes/java/net/Inet6AddressImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/Inet6AddressImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,10 +54,10 @@
              * be either an IPv6 address or an IPv4 address (case of a dual
              * stack system).
              */
-            java.util.Enumeration it = netif.getInetAddresses();
+            java.util.Enumeration<InetAddress> it = netif.getInetAddresses();
             InetAddress inetaddr = null;
             while (it.hasMoreElements()) {
-                inetaddr = (InetAddress) it.nextElement();
+                inetaddr = it.nextElement();
                 if (inetaddr.getClass().isInstance(addr)) {
                     ifaddr = inetaddr.getAddress();
                     if (inetaddr instanceof Inet6Address) {
--- a/jdk/src/share/classes/java/net/MulticastSocket.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/MulticastSocket.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 package java.net;
 
 import java.io.IOException;
-import java.io.InterruptedIOException;
 import java.util.Enumeration;
 
 /**
@@ -500,9 +499,9 @@
              */
             try {
                 NetworkInterface ni = NetworkInterface.getByInetAddress(ia);
-                Enumeration addrs = ni.getInetAddresses();
+                Enumeration<InetAddress> addrs = ni.getInetAddresses();
                 while (addrs.hasMoreElements()) {
-                    InetAddress addr = (InetAddress)(addrs.nextElement());
+                    InetAddress addr = addrs.nextElement();
                     if (addr.equals(infAddress)) {
                         return infAddress;
                     }
--- a/jdk/src/share/classes/java/net/Proxy.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/Proxy.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,7 +73,7 @@
 
     // Creates the proxy that represents a <code>DIRECT</code> connection.
     private Proxy() {
-        type = type.DIRECT;
+        type = Type.DIRECT;
         sa = null;
     }
 
--- a/jdk/src/share/classes/java/net/ProxySelector.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/ProxySelector.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@
 
     static {
         try {
-            Class c = Class.forName("sun.net.spi.DefaultProxySelector");
+            Class<?> c = Class.forName("sun.net.spi.DefaultProxySelector");
             if (c != null && ProxySelector.class.isAssignableFrom(c)) {
                 theProxySelector = (ProxySelector) c.newInstance();
             }
--- a/jdk/src/share/classes/java/net/Socket.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/Socket.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -459,13 +459,10 @@
         oldImpl = AccessController.doPrivileged
                                 (new PrivilegedAction<Boolean>() {
             public Boolean run() {
-                Class[] cl = new Class[2];
-                cl[0] = SocketAddress.class;
-                cl[1] = Integer.TYPE;
-                Class clazz = impl.getClass();
+                Class<?> clazz = impl.getClass();
                 while (true) {
                     try {
-                        clazz.getDeclaredMethod("connect", cl);
+                        clazz.getDeclaredMethod("connect", SocketAddress.class, int.class);
                         return Boolean.FALSE;
                     } catch (NoSuchMethodException e) {
                         clazz = clazz.getSuperclass();
--- a/jdk/src/share/classes/java/net/SocketPermission.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/SocketPermission.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -467,6 +467,7 @@
      * @param action the action string
      * @return the action mask
      */
+    @SuppressWarnings("fallthrough")
     private static int getMask(String action) {
 
         if (action == null) {
@@ -1231,7 +1232,7 @@
 implements Serializable
 {
     // Not serialized; see serialization section at end of class
-    private transient List perms;
+    private transient List<SocketPermission> perms;
 
     /**
      * Create an empty SocketPermissions object.
@@ -1239,7 +1240,7 @@
      */
 
     public SocketPermissionCollection() {
-        perms = new ArrayList();
+        perms = new ArrayList<SocketPermission>();
     }
 
     /**
@@ -1267,7 +1268,7 @@
         // optimization to ensure perms most likely to be tested
         // show up early (4301064)
         synchronized (this) {
-            perms.add(0, permission);
+            perms.add(0, (SocketPermission)permission);
         }
     }
 
@@ -1296,7 +1297,7 @@
             int len = perms.size();
             //System.out.println("implies "+np);
             for (int i = 0; i < len; i++) {
-                SocketPermission x = (SocketPermission) perms.get(i);
+                SocketPermission x = perms.get(i);
                 //System.out.println("  trying "+x);
                 if (((needed & x.getMask()) != 0) && x.impliesIgnoreMask(np)) {
                     effective |=  x.getMask();
@@ -1316,10 +1317,11 @@
      * @return an enumeration of all the SocketPermission objects.
      */
 
-    public Enumeration elements() {
+    @SuppressWarnings("unchecked")
+    public Enumeration<Permission> elements() {
         // Convert Iterator into Enumeration
         synchronized (this) {
-            return Collections.enumeration(perms);
+            return Collections.enumeration((List<Permission>)(List)perms);
         }
     }
 
@@ -1353,7 +1355,7 @@
         // Don't call out.defaultWriteObject()
 
         // Write out Vector
-        Vector permissions = new Vector(perms.size());
+        Vector<SocketPermission> permissions = new Vector<>(perms.size());
 
         synchronized (this) {
             permissions.addAll(perms);
@@ -1375,8 +1377,9 @@
         ObjectInputStream.GetField gfields = in.readFields();
 
         // Get the one we want
-        Vector permissions = (Vector)gfields.get("permissions", null);
-        perms = new ArrayList(permissions.size());
+        @SuppressWarnings("unchecked")
+        Vector<SocketPermission> permissions = (Vector<SocketPermission>)gfields.get("permissions", null);
+        perms = new ArrayList<SocketPermission>(permissions.size());
         perms.addAll(permissions);
     }
 }
--- a/jdk/src/share/classes/java/net/URL.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/URL.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.Hashtable;
 import java.util.StringTokenizer;
 import sun.security.util.SecurityConstants;
@@ -1113,7 +1112,7 @@
     /**
      * A table of protocol handlers.
      */
-    static Hashtable handlers = new Hashtable();
+    static Hashtable<String,URLStreamHandler> handlers = new Hashtable<>();
     private static Object streamHandlerLock = new Object();
 
     /**
@@ -1122,7 +1121,7 @@
      */
     static URLStreamHandler getURLStreamHandler(String protocol) {
 
-        URLStreamHandler handler = (URLStreamHandler)handlers.get(protocol);
+        URLStreamHandler handler = handlers.get(protocol);
         if (handler == null) {
 
             boolean checkedWithFactory = false;
@@ -1160,7 +1159,7 @@
                     try {
                         String clsName = packagePrefix + "." + protocol +
                           ".Handler";
-                        Class cls = null;
+                        Class<?> cls = null;
                         try {
                             cls = Class.forName(clsName);
                         } catch (ClassNotFoundException e) {
@@ -1185,7 +1184,7 @@
 
                 // Check again with hashtable just in case another
                 // thread created a handler since we last checked
-                handler2 = (URLStreamHandler)handlers.get(protocol);
+                handler2 = handlers.get(protocol);
 
                 if (handler2 != null) {
                     return handler2;
--- a/jdk/src/share/classes/java/net/URLClassLoader.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/URLClassLoader.java	Wed Oct 26 17:59:13 2011 -0700
@@ -25,14 +25,7 @@
 
 package java.net;
 
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.ref.*;
 import java.io.*;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandlerFactory;
-import java.util.Enumeration;
 import java.util.*;
 import java.util.jar.Manifest;
 import java.util.jar.JarFile;
@@ -352,8 +345,8 @@
     {
         try {
             return AccessController.doPrivileged(
-                new PrivilegedExceptionAction<Class>() {
-                    public Class run() throws ClassNotFoundException {
+                new PrivilegedExceptionAction<Class<?>>() {
+                    public Class<?> run() throws ClassNotFoundException {
                         String path = name.replace('.', '/').concat(".class");
                         Resource res = ucp.getResource(path, false);
                         if (res != null) {
@@ -406,7 +399,7 @@
      * Resource. The resulting Class must be resolved before it can be
      * used.
      */
-    private Class defineClass(String name, Resource res) throws IOException {
+    private Class<?> defineClass(String name, Resource res) throws IOException {
         long t0 = System.nanoTime();
         int i = name.lastIndexOf('.');
         URL url = res.getCodeSourceURL();
@@ -774,7 +767,7 @@
         super(urls, acc);
     }
 
-    public final Class loadClass(String name, boolean resolve)
+    public final Class<?> loadClass(String name, boolean resolve)
         throws ClassNotFoundException
     {
         // First check if we have permission to access the package. This
--- a/jdk/src/share/classes/java/net/URLConnection.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/net/URLConnection.java	Wed Oct 26 17:59:13 2011 -0700
@@ -595,7 +595,7 @@
      * @since 1.4
      */
     public Map<String,List<String>> getHeaderFields() {
-        return Collections.EMPTY_MAP;
+        return Collections.emptyMap();
     }
 
     /**
@@ -659,6 +659,7 @@
      *          <code>Default</code> argument is returned if the field is
      *          missing or malformed.
      */
+    @SuppressWarnings("deprecation")
     public long getHeaderFieldDate(String name, long Default) {
         String value = getHeaderField(name);
         try {
@@ -1153,7 +1154,7 @@
             throw new IllegalStateException("Already connected");
 
         if (requests == null)
-            return Collections.EMPTY_MAP;
+            return Collections.emptyMap();
 
         return requests.getHeaders(null);
     }
@@ -1236,7 +1237,7 @@
         factory = fac;
     }
 
-    private static Hashtable handlers = new Hashtable();
+    private static Hashtable<String, ContentHandler> handlers = new Hashtable<>();
 
     /**
      * Gets the Content Handler appropriate for this connection.
@@ -1250,7 +1251,7 @@
         if (contentType == null)
             throw new UnknownServiceException("no content-type");
         try {
-            handler = (ContentHandler) handlers.get(contentType);
+            handler = handlers.get(contentType);
             if (handler != null)
                 return handler;
         } catch(Exception e) {
@@ -1316,7 +1317,7 @@
 
             try {
                 String clsName = packagePrefix + "." + contentHandlerClassName;
-                Class cls = null;
+                Class<?> cls = null;
                 try {
                     cls = Class.forName(clsName);
                 } catch (ClassNotFoundException e) {
--- a/jdk/src/share/classes/java/security/Signature.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/security/Signature.java	Wed Oct 26 17:59:13 2011 -0700
@@ -899,6 +899,7 @@
      * and its original parent (Object).
      */
 
+    @SuppressWarnings("deprecation")
     private static class Delegate extends Signature {
 
         // The provider implementation (delegate)
@@ -1203,6 +1204,7 @@
     }
 
     // adapter for RSA/ECB/PKCS1Padding ciphers
+    @SuppressWarnings("deprecation")
     private static class CipherAdapter extends SignatureSpi {
 
         private final Cipher cipher;
--- a/jdk/src/share/classes/java/util/Formatter.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/util/Formatter.java	Wed Oct 26 17:59:13 2011 -0700
@@ -50,7 +50,6 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 import sun.misc.FormattedFloatingDecimal;
 
@@ -3417,24 +3416,24 @@
         // Method assumes that d > 0.
         private String hexDouble(double d, int prec) {
             // Let Double.toHexString handle simple cases
-            if(!FpUtils.isFinite(d) || d == 0.0 || prec == 0 || prec >= 13)
+            if(!Double.isFinite(d) || d == 0.0 || prec == 0 || prec >= 13)
                 // remove "0x"
                 return Double.toHexString(d).substring(2);
             else {
                 assert(prec >= 1 && prec <= 12);
 
-                int exponent  = FpUtils.getExponent(d);
+                int exponent  = Math.getExponent(d);
                 boolean subnormal
                     = (exponent == DoubleConsts.MIN_EXPONENT - 1);
 
                 // If this is subnormal input so normalize (could be faster to
                 // do as integer operation).
                 if (subnormal) {
-                    scaleUp = FpUtils.scalb(1.0, 54);
+                    scaleUp = Math.scalb(1.0, 54);
                     d *= scaleUp;
                     // Calculate the exponent.  This is not just exponent + 54
                     // since the former is not the normalized exponent.
-                    exponent = FpUtils.getExponent(d);
+                    exponent = Math.getExponent(d);
                     assert exponent >= DoubleConsts.MIN_EXPONENT &&
                         exponent <= DoubleConsts.MAX_EXPONENT: exponent;
                 }
--- a/jdk/src/share/classes/java/util/Properties.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/util/Properties.java	Wed Oct 26 17:59:13 2011 -0700
@@ -34,6 +34,7 @@
 import java.io.Writer;
 import java.io.OutputStreamWriter;
 import java.io.BufferedWriter;
+import java.lang.reflect.*;
 
 /**
  * The <code>Properties</code> class represents a persistent set of
@@ -1111,4 +1112,60 @@
     private static final char[] hexDigit = {
         '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
     };
+
+
+    private static class XMLUtils {
+        private static Method load = null;
+        private static Method save = null;
+        static {
+            try {
+                // reference sun.util.xml.Utils reflectively
+                // to allow the Properties class be compiled in
+                // the absence of XML
+                Class<?> c = Class.forName("sun.util.xml.XMLUtils", true, null);
+                load = c.getMethod("load", Properties.class, InputStream.class);
+                save = c.getMethod("save", Properties.class, OutputStream.class,
+                                   String.class, String.class);
+            } catch (ClassNotFoundException cnf) {
+                throw new AssertionError(cnf);
+            } catch (NoSuchMethodException e) {
+                throw new AssertionError(e);
+            }
+        }
+
+        static void invoke(Method m, Object... args) throws IOException {
+            try {
+                m.invoke(null, args);
+            } catch (IllegalAccessException e) {
+                throw new AssertionError(e);
+            } catch (InvocationTargetException e) {
+                Throwable t = e.getCause();
+                if (t instanceof RuntimeException)
+                    throw (RuntimeException)t;
+
+                if (t instanceof IOException) {
+                    throw (IOException)t;
+                } else {
+                    throw new AssertionError(t);
+                }
+            }
+        }
+
+        static void load(Properties props, InputStream in)
+            throws IOException, InvalidPropertiesFormatException
+        {
+            if (load == null)
+                throw new InternalError("sun.util.xml.XMLUtils not found");
+            invoke(load, props, in);
+        }
+
+        static void save(Properties props, OutputStream os, String comment,
+                         String encoding)
+            throws IOException
+        {
+            if (save == null)
+                throw new InternalError("sun.util.xml.XMLUtils not found");
+            invoke(save, props, os, comment, encoding);
+        }
+    }
 }
--- a/jdk/src/share/classes/java/util/XMLUtils.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util;
-
-import java.io.*;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
-import org.w3c.dom.*;
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.*;
-import javax.xml.transform.stream.*;
-
-/**
- * A class used to aid in Properties load and save in XML. Keeping this
- * code outside of Properties helps reduce the number of classes loaded
- * when Properties is loaded.
- *
- * @author  Michael McCloskey
- * @since   1.3
- */
-class XMLUtils {
-
-    // XML loading and saving methods for Properties
-
-    // The required DTD URI for exported properties
-    private static final String PROPS_DTD_URI =
-    "http://java.sun.com/dtd/properties.dtd";
-
-    private static final String PROPS_DTD =
-    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-    "<!-- DTD for properties -->"                +
-    "<!ELEMENT properties ( comment?, entry* ) >"+
-    "<!ATTLIST properties"                       +
-        " version CDATA #FIXED \"1.0\">"         +
-    "<!ELEMENT comment (#PCDATA) >"              +
-    "<!ELEMENT entry (#PCDATA) >"                +
-    "<!ATTLIST entry "                           +
-        " key CDATA #REQUIRED>";
-
-    /**
-     * Version number for the format of exported properties files.
-     */
-    private static final String EXTERNAL_XML_VERSION = "1.0";
-
-    static void load(Properties props, InputStream in)
-        throws IOException, InvalidPropertiesFormatException
-    {
-        Document doc = null;
-        try {
-            doc = getLoadingDoc(in);
-        } catch (SAXException saxe) {
-            throw new InvalidPropertiesFormatException(saxe);
-        }
-        Element propertiesElement = (Element)doc.getChildNodes().item(1);
-        String xmlVersion = propertiesElement.getAttribute("version");
-        if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0)
-            throw new InvalidPropertiesFormatException(
-                "Exported Properties file format version " + xmlVersion +
-                " is not supported. This java installation can read" +
-                " versions " + EXTERNAL_XML_VERSION + " or older. You" +
-                " may need to install a newer version of JDK.");
-        importProperties(props, propertiesElement);
-    }
-
-    static Document getLoadingDoc(InputStream in)
-        throws SAXException, IOException
-    {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        dbf.setIgnoringElementContentWhitespace(true);
-        dbf.setValidating(true);
-        dbf.setCoalescing(true);
-        dbf.setIgnoringComments(true);
-        try {
-            DocumentBuilder db = dbf.newDocumentBuilder();
-            db.setEntityResolver(new Resolver());
-            db.setErrorHandler(new EH());
-            InputSource is = new InputSource(in);
-            return db.parse(is);
-        } catch (ParserConfigurationException x) {
-            throw new Error(x);
-        }
-    }
-
-    static void importProperties(Properties props, Element propertiesElement) {
-        NodeList entries = propertiesElement.getChildNodes();
-        int numEntries = entries.getLength();
-        int start = numEntries > 0 &&
-            entries.item(0).getNodeName().equals("comment") ? 1 : 0;
-        for (int i=start; i<numEntries; i++) {
-            Element entry = (Element)entries.item(i);
-            if (entry.hasAttribute("key")) {
-                Node n = entry.getFirstChild();
-                String val = (n == null) ? "" : n.getNodeValue();
-                props.setProperty(entry.getAttribute("key"), val);
-            }
-        }
-    }
-
-    static void save(Properties props, OutputStream os, String comment,
-                     String encoding)
-        throws IOException
-    {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        DocumentBuilder db = null;
-        try {
-            db = dbf.newDocumentBuilder();
-        } catch (ParserConfigurationException pce) {
-            assert(false);
-        }
-        Document doc = db.newDocument();
-        Element properties =  (Element)
-            doc.appendChild(doc.createElement("properties"));
-
-        if (comment != null) {
-            Element comments = (Element)properties.appendChild(
-                doc.createElement("comment"));
-            comments.appendChild(doc.createTextNode(comment));
-        }
-
-        synchronized (props) {
-            for (String key : props.stringPropertyNames()) {
-                Element entry = (Element)properties.appendChild(
-                    doc.createElement("entry"));
-                entry.setAttribute("key", key);
-                entry.appendChild(doc.createTextNode(props.getProperty(key)));
-            }
-        }
-        emitDocument(doc, os, encoding);
-    }
-
-    static void emitDocument(Document doc, OutputStream os, String encoding)
-        throws IOException
-    {
-        TransformerFactory tf = TransformerFactory.newInstance();
-        Transformer t = null;
-        try {
-            t = tf.newTransformer();
-            t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, PROPS_DTD_URI);
-            t.setOutputProperty(OutputKeys.INDENT, "yes");
-            t.setOutputProperty(OutputKeys.METHOD, "xml");
-            t.setOutputProperty(OutputKeys.ENCODING, encoding);
-        } catch (TransformerConfigurationException tce) {
-            assert(false);
-        }
-        DOMSource doms = new DOMSource(doc);
-        StreamResult sr = new StreamResult(os);
-        try {
-            t.transform(doms, sr);
-        } catch (TransformerException te) {
-            IOException ioe = new IOException();
-            ioe.initCause(te);
-            throw ioe;
-        }
-    }
-
-    private static class Resolver implements EntityResolver {
-        public InputSource resolveEntity(String pid, String sid)
-            throws SAXException
-        {
-            if (sid.equals(PROPS_DTD_URI)) {
-                InputSource is;
-                is = new InputSource(new StringReader(PROPS_DTD));
-                is.setSystemId(PROPS_DTD_URI);
-                return is;
-            }
-            throw new SAXException("Invalid system identifier: " + sid);
-        }
-    }
-
-    private static class EH implements ErrorHandler {
-        public void error(SAXParseException x) throws SAXException {
-            throw x;
-        }
-        public void fatalError(SAXParseException x) throws SAXException {
-            throw x;
-        }
-        public void warning(SAXParseException x) throws SAXException {
-            throw x;
-        }
-    }
-
-}
--- a/jdk/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java	Wed Oct 26 17:59:13 2011 -0700
@@ -330,7 +330,7 @@
                 remove(task))
                 task.cancel(false);
             else
-                prestartCoreThread();
+                ensurePrestart();
         }
     }
 
@@ -346,7 +346,7 @@
             if (!canRunInCurrentRunState(true) && remove(task))
                 task.cancel(false);
             else
-                prestartCoreThread();
+                ensurePrestart();
         }
     }
 
--- a/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1546,6 +1546,18 @@
     }
 
     /**
+     * Same as prestartCoreThread except arranges that at least one
+     * thread is started even if corePoolSize is 0.
+     */
+    void ensurePrestart() {
+        int wc = workerCountOf(ctl.get());
+        if (wc < corePoolSize)
+            addWorker(null, true);
+        else if (wc == 0)
+            addWorker(null, false);
+    }
+
+    /**
      * Starts all core threads, causing them to idly wait for work. This
      * overrides the default policy of starting core threads only when
      * new tasks are executed.
--- a/jdk/src/share/classes/javax/net/ssl/SSLServerSocketFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/net/ssl/SSLServerSocketFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,7 +87,7 @@
             if (clsName != null) {
                 log("setting up default SSLServerSocketFactory");
                 try {
-                    Class cls = null;
+                    Class<?> cls = null;
                     try {
                         cls = Class.forName(clsName);
                     } catch (ClassNotFoundException e) {
--- a/jdk/src/share/classes/javax/net/ssl/SSLSocketFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/net/ssl/SSLSocketFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@
             if (clsName != null) {
                 log("setting up default SSLSocketFactory");
                 try {
-                    Class cls = null;
+                    Class<?> cls = null;
                     try {
                         cls = Class.forName(clsName);
                     } catch (ClassNotFoundException e) {
--- a/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java	Wed Oct 26 17:59:13 2011 -0700
@@ -117,7 +117,7 @@
      *          The set contains elements of type,
      *          <code>PrivateCredentialPermission.CredOwner</code>.
      */
-    private Set principals;  // ignored - kept around for compatibility
+    private Set<Principal> principals;  // ignored - kept around for compatibility
     private transient CredOwner[] credOwners;
 
     /**
--- a/jdk/src/share/classes/javax/security/auth/Subject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/auth/Subject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1291,6 +1291,7 @@
             oos.writeFields();
         }
 
+        @SuppressWarnings("unchecked")
         private void readObject(ObjectInputStream ois)
             throws IOException, ClassNotFoundException
         {
@@ -1329,6 +1330,7 @@
             }
         }
 
+        @SuppressWarnings("unchecked")     /*To suppress warning from line 1374*/
         private void populateSet() {
             final Iterator<?> iterator;
             switch(which) {
--- a/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/auth/SubjectDomainCombiner.java	Wed Oct 26 17:59:13 2011 -0700
@@ -56,6 +56,7 @@
         sun.security.util.Debug.getInstance("combiner",
                                         "\t[SubjectDomainCombiner]");
 
+    @SuppressWarnings("deprecation")
     // Note: check only at classloading time, not dynamically during combine()
     private static final boolean useJavaxPolicy =
         javax.security.auth.Policy.isCustomPolicySet(debug);
@@ -300,6 +301,7 @@
         if (!allowCaching) {
             java.security.AccessController.doPrivileged
                 (new PrivilegedAction<Void>() {
+                    @SuppressWarnings("deprecation")
                     public Void run() {
                         // Call refresh only caching is disallowed
                         javax.security.auth.Policy.getPolicy().refresh();
@@ -308,6 +310,7 @@
                 });
         }
 
+
         int cLen = (currentDomains == null ? 0 : currentDomains.length);
         int aLen = (assignedDomains == null ? 0 : assignedDomains.length);
 
@@ -348,13 +351,13 @@
                     // get the original perms
                     Permissions perms = new Permissions();
                     PermissionCollection coll = pd.getPermissions();
-                    java.util.Enumeration e;
+                    java.util.Enumeration<Permission> e;
                     if (coll != null) {
                         synchronized (coll) {
                             e = coll.elements();
                             while (e.hasMoreElements()) {
                                 Permission newPerm =
-                                        (Permission)e.nextElement();
+                                        e.nextElement();
                                  perms.add(newPerm);
                             }
                         }
@@ -367,6 +370,7 @@
                     PermissionCollection newPerms =
                         java.security.AccessController.doPrivileged
                         (new PrivilegedAction<PermissionCollection>() {
+                        @SuppressWarnings("deprecation")
                         public PermissionCollection run() {
                           return
                           javax.security.auth.Policy.getPolicy().getPermissions
@@ -379,7 +383,7 @@
                     synchronized (newPerms) {
                         e = newPerms.elements();
                         while (e.hasMoreElements()) {
-                            Permission newPerm = (Permission)e.nextElement();
+                            Permission newPerm = e.nextElement();
                             if (!perms.implies(newPerm)) {
                                 perms.add(newPerm);
                                 if (debug != null)
--- a/jdk/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/DelegationPermission.java	Wed Oct 26 17:59:13 2011 -0700
@@ -375,6 +375,7 @@
     /*
      * Reads in a Vector of DelegationPermissions and saves them in the perms field.
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException,
     ClassNotFoundException {
         // Don't call defaultReadObject()
--- a/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java	Wed Oct 26 17:59:13 2011 -0700
@@ -583,6 +583,7 @@
     /*
      * Reads in a Vector of ServicePermissions and saves them in the perms field.
      */
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream in) throws IOException,
     ClassNotFoundException {
         // Don't call defaultReadObject()
--- a/jdk/src/share/classes/javax/security/auth/login/LoginContext.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/auth/login/LoginContext.java	Wed Oct 26 17:59:13 2011 -0700
@@ -214,14 +214,14 @@
     private boolean subjectProvided = false;
     private boolean loginSucceeded = false;
     private CallbackHandler callbackHandler;
-    private Map state = new HashMap();
+    private Map<String,?> state = new HashMap<String,Object>();
 
     private Configuration config;
     private boolean configProvided = false;
     private AccessControlContext creatorAcc = null;
     private ModuleInfo[] moduleStack;
     private ClassLoader contextClassLoader = null;
-    private static final Class[] PARAMS = { };
+    private static final Class<?>[] PARAMS = { };
 
     // state saved in the event a user-specified asynchronous exception
     // was specified and thrown
@@ -306,7 +306,7 @@
                         (DEFAULT_HANDLER);
                     if (defaultHandler == null || defaultHandler.length() == 0)
                         return null;
-                    Class c = Class.forName(defaultHandler,
+                    Class<?> c = Class.forName(defaultHandler,
                                         true,
                                         finalLoader);
                     return (CallbackHandler)c.newInstance();
@@ -743,12 +743,12 @@
                 } else {
 
                     // instantiate the LoginModule
-                    Class c = Class.forName
+                    Class<?> c = Class.forName
                                 (moduleStack[i].entry.getLoginModuleName(),
                                 true,
                                 contextClassLoader);
 
-                    Constructor constructor = c.getConstructor(PARAMS);
+                    Constructor<?> constructor = c.getConstructor(PARAMS);
                     Object[] args = { };
 
                     // allow any object to be a LoginModule
--- a/jdk/src/share/classes/javax/security/auth/x500/X500Principal.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/auth/x500/X500Principal.java	Wed Oct 26 17:59:13 2011 -0700
@@ -118,7 +118,7 @@
      *                  is improperly specified
      */
     public X500Principal(String name) {
-        this(name, (Map<String, String>) Collections.EMPTY_MAP);
+        this(name, Collections.<String, String>emptyMap());
     }
 
     /**
--- a/jdk/src/share/classes/javax/security/cert/CertificateEncodingException.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/cert/CertificateEncodingException.java	Wed Oct 26 17:59:13 2011 -0700
@@ -41,6 +41,7 @@
  */
 public class CertificateEncodingException extends CertificateException {
 
+    private static final long serialVersionUID = -8187642723048403470L;
     /**
      * Constructs a CertificateEncodingException with no detail message. A
      * detail message is a String that describes this particular
--- a/jdk/src/share/classes/javax/security/cert/CertificateException.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/cert/CertificateException.java	Wed Oct 26 17:59:13 2011 -0700
@@ -41,6 +41,7 @@
  */
 public class CertificateException extends Exception {
 
+    private static final long serialVersionUID = -5757213374030785290L;
     /**
      * Constructs a certificate exception with no detail message. A detail
      * message is a String that describes this particular exception.
--- a/jdk/src/share/classes/javax/security/cert/CertificateExpiredException.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/cert/CertificateExpiredException.java	Wed Oct 26 17:59:13 2011 -0700
@@ -43,6 +43,7 @@
  */
 public class CertificateExpiredException extends CertificateException {
 
+    private static final long serialVersionUID = 5091601212177261883L;
     /**
      * Constructs a CertificateExpiredException with no detail message. A
      * detail message is a String that describes this particular
--- a/jdk/src/share/classes/javax/security/cert/CertificateNotYetValidException.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/cert/CertificateNotYetValidException.java	Wed Oct 26 17:59:13 2011 -0700
@@ -43,6 +43,7 @@
  */
 public class CertificateNotYetValidException extends CertificateException {
 
+    private static final long serialVersionUID = -8976172474266822818L;
     /**
      * Constructs a CertificateNotYetValidException with no detail message. A
      * detail message is a String that describes this particular
--- a/jdk/src/share/classes/javax/security/cert/CertificateParsingException.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/cert/CertificateParsingException.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,8 @@
  */
 public class CertificateParsingException extends CertificateException {
 
+    private static final long serialVersionUID = -8449352422951136229L;
+
     /**
      * Constructs a CertificateParsingException with no detail message. A
      * detail message is a String that describes this particular
--- a/jdk/src/share/classes/javax/security/cert/X509Certificate.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/cert/X509Certificate.java	Wed Oct 26 17:59:13 2011 -0700
@@ -219,11 +219,11 @@
             className = "com.sun.security.cert.internal.x509.X509V1CertImpl";
         }
         try {
-            Class[] params = null;
+            Class<?>[] params = null;
             if (value instanceof InputStream) {
-                params = new Class[] { InputStream.class };
+                params = new Class<?>[] { InputStream.class };
             } else if (value instanceof byte[]) {
-                params = new Class[] { value.getClass() };
+                params = new Class<?>[] { value.getClass() };
             } else
                 throw new CertificateException("Unsupported argument type");
             Class<?> certClass = Class.forName(className);
--- a/jdk/src/share/classes/javax/security/sasl/Sasl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/security/sasl/Sasl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -395,7 +395,7 @@
              * will be thrown.
              */
             ClassLoader cl = p.getClass().getClassLoader();
-            Class implClass;
+            Class<?> implClass;
             implClass = Class.forName(className, true, cl);
             return implClass.newInstance();
         } catch (ClassNotFoundException e) {
@@ -576,7 +576,7 @@
             classes.clear();
 
             // Check the keys for each provider.
-            for (Enumeration e = providers[i].keys(); e.hasMoreElements(); ) {
+            for (Enumeration<Object> e = providers[i].keys(); e.hasMoreElements(); ) {
                 String currentKey = (String)e.nextElement();
                 if (currentKey.startsWith(serviceName)) {
                     // We should skip the currentKey if it contains a
--- a/jdk/src/share/classes/javax/smartcardio/TerminalFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/smartcardio/TerminalFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -113,7 +113,7 @@
                 type = "PC/SC";
                 Provider sun = Security.getProvider("SunPCSC");
                 if (sun == null) {
-                    Class clazz = Class.forName("sun.security.smartcardio.SunPCSC");
+                    Class<?> clazz = Class.forName("sun.security.smartcardio.SunPCSC");
                     sun = (Provider)clazz.newInstance();
                 }
                 factory = TerminalFactory.getInstance(type, null, sun);
@@ -131,6 +131,8 @@
     }
 
     private static final class NoneProvider extends Provider {
+
+        private static final long serialVersionUID = 2745808869881593918L;
         final static Provider INSTANCE = new NoneProvider();
         private NoneProvider() {
             super("None", 1.0d, "none");
--- a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java	Wed Oct 26 17:59:13 2011 -0700
@@ -24,20 +24,17 @@
  */
 package javax.swing;
 
-import java.applet.Applet;
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.image.*;
 import java.lang.reflect.*;
 import java.lang.ref.WeakReference;
-import java.security.AccessController;
 import java.util.*;
 
 import com.sun.java.swing.SwingUtilities3;
 
 import sun.awt.SubRegionShowable;
 import sun.java2d.SunGraphics2D;
-import sun.security.action.GetPropertyAction;
 import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
 import sun.awt.SunToolkit;
 import sun.util.logging.PlatformLogger;
@@ -120,10 +117,6 @@
      */
     private JComponent rootJ;
     /**
-     * Parent Applet/Window for the current paint/copyArea
-     */
-    private Container root;
-    /**
      * Location of component being painted relative to root.
      */
     private int xOffset;
@@ -278,7 +271,9 @@
     public boolean paint(JComponent paintingComponent,
                          JComponent bufferComponent, Graphics g,
                          int x, int y, int w, int h) {
-        if (prepare(paintingComponent, true, x, y, w, h)) {
+        Container root = fetchRoot(paintingComponent);
+
+        if (prepare(paintingComponent, root, true, x, y, w, h)) {
             if ((g instanceof SunGraphics2D) &&
                     ((SunGraphics2D)g).getDestination() == root) {
                 // BufferStrategy may have already constrained the Graphics. To
@@ -319,7 +314,9 @@
         //
         // If the buffer isn't in sync there is no point in doing a copyArea,
         // it has garbage.
-        if (prepare(c, false, 0, 0, 0, 0) && bufferInfo.isInSync()) {
+        Container root = fetchRoot(c);
+
+        if (prepare(c, root, false, 0, 0, 0, 0) && bufferInfo.isInSync()) {
             if (clip) {
                 Rectangle cBounds = c.getVisibleRect();
                 int relX = xOffset + x;
@@ -500,14 +497,14 @@
      *
      * @return true if should use buffering per window in painting.
      */
-    private boolean prepare(JComponent c, boolean isPaint, int x, int y,
+    private boolean prepare(JComponent c, Container root, boolean isPaint, int x, int y,
                             int w, int h) {
         if (bsg != null) {
             bsg.dispose();
             bsg = null;
         }
         bufferStrategy = null;
-        if (fetchRoot(c)) {
+        if (root != null) {
             boolean contentsLost = false;
             BufferInfo bufferInfo = getBufferInfo(root);
             if (bufferInfo == null) {
@@ -567,10 +564,10 @@
         return false;
     }
 
-    private boolean fetchRoot(JComponent c) {
+    private Container fetchRoot(JComponent c) {
         boolean encounteredHW = false;
         rootJ = c;
-        root = c;
+        Container root = c;
         xOffset = yOffset = 0;
         while (root != null &&
                (!(root instanceof Window) &&
@@ -597,7 +594,7 @@
                         // heavyweights.  If we didn't do this when we
                         // went to show the descendants of the nested hw
                         // you would see nothing, so, we bail out here.
-                        return false;
+                        return null;
                     }
                 }
             }
@@ -613,11 +610,11 @@
                 // bit tricky with Swing. This gives a good approximation
                 // of the various ways to turn on double buffering for
                 // components.
-                return true;
+                return root;
             }
         }
         // Don't do true double buffering.
-        return false;
+        return null;
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/SwingUtilities.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/swing/SwingUtilities.java	Wed Oct 26 17:59:13 2011 -0700
@@ -792,7 +792,7 @@
      * @return true if the left mouse button was active
      */
     public static boolean isLeftMouseButton(MouseEvent anEvent) {
-         return ((anEvent.getModifiers() & InputEvent.BUTTON1_MASK) != 0);
+         return (anEvent.getButton() == MouseEvent.BUTTON1);
     }
 
     /**
@@ -802,7 +802,7 @@
      * @return true if the middle mouse button was active
      */
     public static boolean isMiddleMouseButton(MouseEvent anEvent) {
-        return ((anEvent.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK);
+        return (anEvent.getButton() == MouseEvent.BUTTON2);
     }
 
     /**
@@ -812,7 +812,7 @@
      * @return true if the right mouse button was active
      */
     public static boolean isRightMouseButton(MouseEvent anEvent) {
-        return ((anEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK);
+        return (anEvent.getButton() == MouseEvent.BUTTON3);
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/doc-files/properties.html	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/doc-files/properties.html	Wed Oct 26 17:59:13 2011 -0700
@@ -1,6 +1,5 @@
 <html>
 <head>
-<link href="style.css" rel="stylesheet" type="text/css" />
 </head>
 <body>
 <h1 id="primaryColors">Primary Colors</h1>
--- a/jdk/src/share/classes/org/ietf/jgss/Oid.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/org/ietf/jgss/Oid.java	Wed Oct 26 17:59:13 2011 -0700
@@ -157,7 +157,7 @@
             return (true);
 
         if (other instanceof Oid)
-            return this.oid.equals(((Oid) other).oid);
+            return this.oid.equals((Object)((Oid) other).oid);
         else if (other instanceof ObjectIdentifier)
             return this.oid.equals(other);
         else
--- a/jdk/src/share/classes/sun/misc/FloatingDecimal.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/misc/FloatingDecimal.java	Wed Oct 26 17:59:13 2011 -0700
@@ -25,7 +25,6 @@
 
 package sun.misc;
 
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 import sun.misc.FloatConsts;
 import java.util.regex.*;
@@ -2297,9 +2296,9 @@
                     significand++;
                 }
 
-                FloatingDecimal fd = new FloatingDecimal(FpUtils.rawCopySign(
-                                                                 Double.longBitsToDouble(significand),
-                                                                 sign));
+                FloatingDecimal fd = new FloatingDecimal(Math.copySign(
+                                                              Double.longBitsToDouble(significand),
+                                                              sign));
 
                 /*
                  * Set roundingDir variable field of fd properly so
--- a/jdk/src/share/classes/sun/misc/FormattedFloatingDecimal.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/misc/FormattedFloatingDecimal.java	Wed Oct 26 17:59:13 2011 -0700
@@ -25,7 +25,6 @@
 
 package sun.misc;
 
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 import sun.misc.FloatConsts;
 import java.util.regex.*;
--- a/jdk/src/share/classes/sun/misc/FpUtils.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/misc/FpUtils.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -125,10 +125,6 @@
      */
     private FpUtils() {}
 
-    // Constants used in scalb
-    static double twoToTheDoubleScaleUp = powerOfTwoD(512);
-    static double twoToTheDoubleScaleDown = powerOfTwoD(-512);
-
     // Helper Methods
 
     // The following helper methods are used in the implementation of
@@ -137,49 +133,22 @@
 
     /**
      * Returns unbiased exponent of a {@code double}.
+     * @deprecated Use Math.getExponent.
      */
+    @Deprecated
     public static int getExponent(double d){
-        /*
-         * Bitwise convert d to long, mask out exponent bits, shift
-         * to the right and then subtract out double's bias adjust to
-         * get true exponent value.
-         */
-        return (int)(((Double.doubleToRawLongBits(d) & DoubleConsts.EXP_BIT_MASK) >>
-                      (DoubleConsts.SIGNIFICAND_WIDTH - 1)) - DoubleConsts.EXP_BIAS);
+        return Math.getExponent(d);
     }
 
     /**
      * Returns unbiased exponent of a {@code float}.
+     * @deprecated Use Math.getExponent.
      */
+    @Deprecated
     public static int getExponent(float f){
-        /*
-         * Bitwise convert f to integer, mask out exponent bits, shift
-         * to the right and then subtract out float's bias adjust to
-         * get true exponent value
-         */
-        return ((Float.floatToRawIntBits(f) & FloatConsts.EXP_BIT_MASK) >>
-                (FloatConsts.SIGNIFICAND_WIDTH - 1)) - FloatConsts.EXP_BIAS;
+        return Math.getExponent(f);
     }
 
-    /**
-     * Returns a floating-point power of two in the normal range.
-     */
-    static double powerOfTwoD(int n) {
-        assert(n >= DoubleConsts.MIN_EXPONENT && n <= DoubleConsts.MAX_EXPONENT);
-        return Double.longBitsToDouble((((long)n + (long)DoubleConsts.EXP_BIAS) <<
-                                        (DoubleConsts.SIGNIFICAND_WIDTH-1))
-                                       & DoubleConsts.EXP_BIT_MASK);
-    }
-
-    /**
-     * Returns a floating-point power of two in the normal range.
-     */
-    static float powerOfTwoF(int n) {
-        assert(n >= FloatConsts.MIN_EXPONENT && n <= FloatConsts.MAX_EXPONENT);
-        return Float.intBitsToFloat(((n + FloatConsts.EXP_BIAS) <<
-                                     (FloatConsts.SIGNIFICAND_WIDTH-1))
-                                    & FloatConsts.EXP_BIT_MASK);
-    }
 
     /**
      * Returns the first floating-point argument with the sign of the
@@ -195,13 +164,11 @@
      * @return a value with the magnitude of {@code magnitude}
      * and the sign of {@code sign}.
      * @author Joseph D. Darcy
+     * @deprecated Use Math.copySign.
      */
+    @Deprecated
     public static double rawCopySign(double magnitude, double sign) {
-        return Double.longBitsToDouble((Double.doubleToRawLongBits(sign) &
-                                        (DoubleConsts.SIGN_BIT_MASK)) |
-                                       (Double.doubleToRawLongBits(magnitude) &
-                                        (DoubleConsts.EXP_BIT_MASK |
-                                         DoubleConsts.SIGNIF_BIT_MASK)));
+        return Math.copySign(magnitude, sign);
     }
 
     /**
@@ -218,13 +185,11 @@
      * @return a value with the magnitude of {@code magnitude}
      * and the sign of {@code sign}.
      * @author Joseph D. Darcy
+     * @deprecated Use Math.copySign.
      */
+    @Deprecated
     public static float rawCopySign(float magnitude, float sign) {
-        return Float.intBitsToFloat((Float.floatToRawIntBits(sign) &
-                                     (FloatConsts.SIGN_BIT_MASK)) |
-                                    (Float.floatToRawIntBits(magnitude) &
-                                     (FloatConsts.EXP_BIT_MASK |
-                                      FloatConsts.SIGNIF_BIT_MASK)));
+        return Math.copySign(magnitude, sign);
     }
 
     /* ***************************************************************** */
@@ -237,9 +202,11 @@
      * @param d the {@code double} value to be tested
      * @return {@code true} if the argument is a finite
      * floating-point value, {@code false} otherwise.
+     * @deprecated Use Double.isFinite.
      */
+    @Deprecated
     public static boolean isFinite(double d) {
-        return Math.abs(d) <= DoubleConsts.MAX_VALUE;
+        return Double.isFinite(d);
     }
 
     /**
@@ -250,9 +217,11 @@
      * @param f the {@code float} value to be tested
      * @return {@code true} if the argument is a finite
      * floating-point value, {@code false} otherwise.
+     * @deprecated Use Float.isFinite.
      */
+     @Deprecated
      public static boolean isFinite(float f) {
-        return Math.abs(f) <= FloatConsts.MAX_VALUE;
+         return Float.isFinite(f);
     }
 
     /**
@@ -558,82 +527,11 @@
      * @param scale_factor power of 2 used to scale {@code d}
      * @return {@code d * }2<sup>{@code scale_factor}</sup>
      * @author Joseph D. Darcy
+     * @deprecated Use Math.scalb.
      */
+    @Deprecated
     public static double scalb(double d, int scale_factor) {
-        /*
-         * This method does not need to be declared strictfp to
-         * compute the same correct result on all platforms.  When
-         * scaling up, it does not matter what order the
-         * multiply-store operations are done; the result will be
-         * finite or overflow regardless of the operation ordering.
-         * However, to get the correct result when scaling down, a
-         * particular ordering must be used.
-         *
-         * When scaling down, the multiply-store operations are
-         * sequenced so that it is not possible for two consecutive
-         * multiply-stores to return subnormal results.  If one
-         * multiply-store result is subnormal, the next multiply will
-         * round it away to zero.  This is done by first multiplying
-         * by 2 ^ (scale_factor % n) and then multiplying several
-         * times by by 2^n as needed where n is the exponent of number
-         * that is a covenient power of two.  In this way, at most one
-         * real rounding error occurs.  If the double value set is
-         * being used exclusively, the rounding will occur on a
-         * multiply.  If the double-extended-exponent value set is
-         * being used, the products will (perhaps) be exact but the
-         * stores to d are guaranteed to round to the double value
-         * set.
-         *
-         * It is _not_ a valid implementation to first multiply d by
-         * 2^MIN_EXPONENT and then by 2 ^ (scale_factor %
-         * MIN_EXPONENT) since even in a strictfp program double
-         * rounding on underflow could occur; e.g. if the scale_factor
-         * argument was (MIN_EXPONENT - n) and the exponent of d was a
-         * little less than -(MIN_EXPONENT - n), meaning the final
-         * result would be subnormal.
-         *
-         * Since exact reproducibility of this method can be achieved
-         * without any undue performance burden, there is no
-         * compelling reason to allow double rounding on underflow in
-         * scalb.
-         */
-
-        // magnitude of a power of two so large that scaling a finite
-        // nonzero value by it would be guaranteed to over or
-        // underflow; due to rounding, scaling down takes takes an
-        // additional power of two which is reflected here
-        final int MAX_SCALE = DoubleConsts.MAX_EXPONENT + -DoubleConsts.MIN_EXPONENT +
-                              DoubleConsts.SIGNIFICAND_WIDTH + 1;
-        int exp_adjust = 0;
-        int scale_increment = 0;
-        double exp_delta = Double.NaN;
-
-        // Make sure scaling factor is in a reasonable range
-
-        if(scale_factor < 0) {
-            scale_factor = Math.max(scale_factor, -MAX_SCALE);
-            scale_increment = -512;
-            exp_delta = twoToTheDoubleScaleDown;
-        }
-        else {
-            scale_factor = Math.min(scale_factor, MAX_SCALE);
-            scale_increment = 512;
-            exp_delta = twoToTheDoubleScaleUp;
-        }
-
-        // Calculate (scale_factor % +/-512), 512 = 2^9, using
-        // technique from "Hacker's Delight" section 10-2.
-        int t = (scale_factor >> 9-1) >>> 32 - 9;
-        exp_adjust = ((scale_factor + t) & (512 -1)) - t;
-
-        d *= powerOfTwoD(exp_adjust);
-        scale_factor -= exp_adjust;
-
-        while(scale_factor != 0) {
-            d *= exp_delta;
-            scale_factor -= scale_increment;
-        }
-        return d;
+        return Math.scalb(d, scale_factor);
     }
 
     /**
@@ -667,28 +565,11 @@
      * @param scale_factor power of 2 used to scale {@code f}
      * @return {@code f * }2<sup>{@code scale_factor}</sup>
      * @author Joseph D. Darcy
+     * @deprecated Use Math.scalb.
      */
-     public static float scalb(float f, int scale_factor) {
-        // magnitude of a power of two so large that scaling a finite
-        // nonzero value by it would be guaranteed to over or
-        // underflow; due to rounding, scaling down takes takes an
-        // additional power of two which is reflected here
-        final int MAX_SCALE = FloatConsts.MAX_EXPONENT + -FloatConsts.MIN_EXPONENT +
-                              FloatConsts.SIGNIFICAND_WIDTH + 1;
-
-        // Make sure scaling factor is in a reasonable range
-        scale_factor = Math.max(Math.min(scale_factor, MAX_SCALE), -MAX_SCALE);
-
-        /*
-         * Since + MAX_SCALE for float fits well within the double
-         * exponent range and + float -> double conversion is exact
-         * the multiplication below will be exact. Therefore, the
-         * rounding that occurs when the double product is cast to
-         * float will be the correctly rounded float result.  Since
-         * all operations other than the final multiply will be exact,
-         * it is not necessary to declare this method strictfp.
-         */
-        return (float)((double)f*powerOfTwoD(scale_factor));
+    @Deprecated
+    public static float scalb(float f, int scale_factor) {
+        return Math.scalb(f, scale_factor);
     }
 
     /**
@@ -730,65 +611,11 @@
      * @return The floating-point number adjacent to {@code start} in the
      * direction of {@code direction}.
      * @author Joseph D. Darcy
+     * @deprecated Use Math.nextAfter
      */
+    @Deprecated
     public static double nextAfter(double start, double direction) {
-        /*
-         * The cases:
-         *
-         * nextAfter(+infinity, 0)  == MAX_VALUE
-         * nextAfter(+infinity, +infinity)  == +infinity
-         * nextAfter(-infinity, 0)  == -MAX_VALUE
-         * nextAfter(-infinity, -infinity)  == -infinity
-         *
-         * are naturally handled without any additional testing
-         */
-
-        // First check for NaN values
-        if (isNaN(start) || isNaN(direction)) {
-            // return a NaN derived from the input NaN(s)
-            return start + direction;
-        } else if (start == direction) {
-            return direction;
-        } else {        // start > direction or start < direction
-            // Add +0.0 to get rid of a -0.0 (+0.0 + -0.0 => +0.0)
-            // then bitwise convert start to integer.
-            long transducer = Double.doubleToRawLongBits(start + 0.0d);
-
-            /*
-             * IEEE 754 floating-point numbers are lexicographically
-             * ordered if treated as signed- magnitude integers .
-             * Since Java's integers are two's complement,
-             * incrementing" the two's complement representation of a
-             * logically negative floating-point value *decrements*
-             * the signed-magnitude representation. Therefore, when
-             * the integer representation of a floating-point values
-             * is less than zero, the adjustment to the representation
-             * is in the opposite direction than would be expected at
-             * first .
-             */
-            if (direction > start) { // Calculate next greater value
-                transducer = transducer + (transducer >= 0L ? 1L:-1L);
-            } else  { // Calculate next lesser value
-                assert direction < start;
-                if (transducer > 0L)
-                    --transducer;
-                else
-                    if (transducer < 0L )
-                        ++transducer;
-                    /*
-                     * transducer==0, the result is -MIN_VALUE
-                     *
-                     * The transition from zero (implicitly
-                     * positive) to the smallest negative
-                     * signed magnitude value must be done
-                     * explicitly.
-                     */
-                    else
-                        transducer = DoubleConsts.SIGN_BIT_MASK | 1L;
-            }
-
-            return Double.longBitsToDouble(transducer);
-        }
+        return Math.nextAfter(start, direction);
     }
 
     /**
@@ -830,65 +657,11 @@
      * @return The floating-point number adjacent to {@code start} in the
      * direction of {@code direction}.
      * @author Joseph D. Darcy
+     * @deprecated Use Math.nextAfter.
      */
-     public static float nextAfter(float start, double direction) {
-        /*
-         * The cases:
-         *
-         * nextAfter(+infinity, 0)  == MAX_VALUE
-         * nextAfter(+infinity, +infinity)  == +infinity
-         * nextAfter(-infinity, 0)  == -MAX_VALUE
-         * nextAfter(-infinity, -infinity)  == -infinity
-         *
-         * are naturally handled without any additional testing
-         */
-
-        // First check for NaN values
-        if (isNaN(start) || isNaN(direction)) {
-            // return a NaN derived from the input NaN(s)
-            return start + (float)direction;
-        } else if (start == direction) {
-            return (float)direction;
-        } else {        // start > direction or start < direction
-            // Add +0.0 to get rid of a -0.0 (+0.0 + -0.0 => +0.0)
-            // then bitwise convert start to integer.
-            int transducer = Float.floatToRawIntBits(start + 0.0f);
-
-            /*
-             * IEEE 754 floating-point numbers are lexicographically
-             * ordered if treated as signed- magnitude integers .
-             * Since Java's integers are two's complement,
-             * incrementing" the two's complement representation of a
-             * logically negative floating-point value *decrements*
-             * the signed-magnitude representation. Therefore, when
-             * the integer representation of a floating-point values
-             * is less than zero, the adjustment to the representation
-             * is in the opposite direction than would be expected at
-             * first.
-             */
-            if (direction > start) {// Calculate next greater value
-                transducer = transducer + (transducer >= 0 ? 1:-1);
-            } else  { // Calculate next lesser value
-                assert direction < start;
-                if (transducer > 0)
-                    --transducer;
-                else
-                    if (transducer < 0 )
-                        ++transducer;
-                    /*
-                     * transducer==0, the result is -MIN_VALUE
-                     *
-                     * The transition from zero (implicitly
-                     * positive) to the smallest negative
-                     * signed magnitude value must be done
-                     * explicitly.
-                     */
-                    else
-                        transducer = FloatConsts.SIGN_BIT_MASK | 1;
-            }
-
-            return Float.intBitsToFloat(transducer);
-        }
+    @Deprecated
+    public static float nextAfter(float start, double direction) {
+        return Math.nextAfter(start, direction);
     }
 
     /**
@@ -915,15 +688,11 @@
      * @return The adjacent floating-point value closer to positive
      * infinity.
      * @author Joseph D. Darcy
+     * @deprecated use Math.nextUp.
      */
+    @Deprecated
     public static double nextUp(double d) {
-        if( isNaN(d) || d == Double.POSITIVE_INFINITY)
-            return d;
-        else {
-            d += 0.0d;
-            return Double.longBitsToDouble(Double.doubleToRawLongBits(d) +
-                                           ((d >= 0.0d)?+1L:-1L));
-        }
+        return Math.nextUp(d);
     }
 
     /**
@@ -950,15 +719,11 @@
      * @return The adjacent floating-point value closer to positive
      * infinity.
      * @author Joseph D. Darcy
+     * @deprecated Use Math.nextUp.
      */
-     public static float nextUp(float f) {
-        if( isNaN(f) || f == FloatConsts.POSITIVE_INFINITY)
-            return f;
-        else {
-            f += 0.0f;
-            return Float.intBitsToFloat(Float.floatToRawIntBits(f) +
-                                        ((f >= 0.0f)?+1:-1));
-        }
+    @Deprecated
+    public static float nextUp(float f) {
+        return Math.nextUp(f);
     }
 
     /**
@@ -985,17 +750,11 @@
      * @return The adjacent floating-point value closer to negative
      * infinity.
      * @author Joseph D. Darcy
+     * @deprecated Use Math.nextDown.
      */
+    @Deprecated
     public static double nextDown(double d) {
-        if( isNaN(d) || d == Double.NEGATIVE_INFINITY)
-            return d;
-        else {
-            if (d == 0.0)
-                return -Double.MIN_VALUE;
-            else
-                return Double.longBitsToDouble(Double.doubleToRawLongBits(d) +
-                                               ((d > 0.0d)?-1L:+1L));
-        }
+        return Math.nextDown(d);
     }
 
     /**
@@ -1022,17 +781,11 @@
      * @return The adjacent floating-point value closer to negative
      * infinity.
      * @author Joseph D. Darcy
+     * @deprecated Use Math.nextDown.
      */
+    @Deprecated
     public static double nextDown(float f) {
-        if( isNaN(f) || f == Float.NEGATIVE_INFINITY)
-            return f;
-        else {
-            if (f == 0.0f)
-                return -Float.MIN_VALUE;
-            else
-                return Float.intBitsToFloat(Float.floatToRawIntBits(f) +
-                                            ((f > 0.0f)?-1:+1));
-        }
+        return Math.nextDown(f);
     }
 
     /**
@@ -1047,9 +800,11 @@
      * and the sign of {@code sign}.
      * @author Joseph D. Darcy
      * @since 1.5
+     * @deprecated Use StrictMath.copySign.
      */
+    @Deprecated
     public static double copySign(double magnitude, double sign) {
-        return rawCopySign(magnitude, (isNaN(sign)?1.0d:sign));
+        return StrictMath.copySign(magnitude, sign);
     }
 
     /**
@@ -1063,9 +818,11 @@
      * @return a value with the magnitude of {@code magnitude}
      * and the sign of {@code sign}.
      * @author Joseph D. Darcy
+     * @deprecated Use StrictMath.copySign.
      */
-     public static float copySign(float magnitude, float sign) {
-        return rawCopySign(magnitude, (isNaN(sign)?1.0f:sign));
+    @Deprecated
+    public static float copySign(float magnitude, float sign) {
+        return StrictMath.copySign(magnitude, sign);
     }
 
     /**
@@ -1090,33 +847,11 @@
      * @return the size of an ulp of the argument
      * @author Joseph D. Darcy
      * @since 1.5
+     * @deprecated Use Math.ulp.
      */
+    @Deprecated
     public static double ulp(double d) {
-        int exp = getExponent(d);
-
-        switch(exp) {
-        case DoubleConsts.MAX_EXPONENT+1:       // NaN or infinity
-            return Math.abs(d);
-
-        case DoubleConsts.MIN_EXPONENT-1:       // zero or subnormal
-            return Double.MIN_VALUE;
-
-        default:
-            assert exp <= DoubleConsts.MAX_EXPONENT && exp >= DoubleConsts.MIN_EXPONENT;
-
-            // ulp(x) is usually 2^(SIGNIFICAND_WIDTH-1)*(2^ilogb(x))
-            exp = exp - (DoubleConsts.SIGNIFICAND_WIDTH-1);
-            if (exp >= DoubleConsts.MIN_EXPONENT) {
-                return powerOfTwoD(exp);
-            }
-            else {
-                // return a subnormal result; left shift integer
-                // representation of Double.MIN_VALUE appropriate
-                // number of positions
-                return Double.longBitsToDouble(1L <<
-                (exp - (DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1)) ));
-            }
-        }
+        return Math.ulp(d);
     }
 
     /**
@@ -1141,33 +876,11 @@
      * @return the size of an ulp of the argument
      * @author Joseph D. Darcy
      * @since 1.5
+     * @deprecated Use Math.ulp.
      */
+     @Deprecated
      public static float ulp(float f) {
-        int exp = getExponent(f);
-
-        switch(exp) {
-        case FloatConsts.MAX_EXPONENT+1:        // NaN or infinity
-            return Math.abs(f);
-
-        case FloatConsts.MIN_EXPONENT-1:        // zero or subnormal
-            return FloatConsts.MIN_VALUE;
-
-        default:
-            assert exp <= FloatConsts.MAX_EXPONENT && exp >= FloatConsts.MIN_EXPONENT;
-
-            // ulp(x) is usually 2^(SIGNIFICAND_WIDTH-1)*(2^ilogb(x))
-            exp = exp - (FloatConsts.SIGNIFICAND_WIDTH-1);
-            if (exp >= FloatConsts.MIN_EXPONENT) {
-                return powerOfTwoF(exp);
-            }
-            else {
-                // return a subnormal result; left shift integer
-                // representation of FloatConsts.MIN_VALUE appropriate
-                // number of positions
-                return Float.intBitsToFloat(1 <<
-                (exp - (FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1)) ));
-            }
-        }
+        return Math.ulp(f);
      }
 
     /**
@@ -1186,9 +899,11 @@
      * @return the signum function of the argument
      * @author Joseph D. Darcy
      * @since 1.5
+     * @deprecated Use Math.signum.
      */
+    @Deprecated
     public static double signum(double d) {
-        return (d == 0.0 || isNaN(d))?d:copySign(1.0, d);
+        return Math.signum(d);
     }
 
     /**
@@ -1207,9 +922,10 @@
      * @return the signum function of the argument
      * @author Joseph D. Darcy
      * @since 1.5
+     * @deprecated Use Math.signum.
      */
+    @Deprecated
     public static float signum(float f) {
-        return (f == 0.0f || isNaN(f))?f:copySign(1.0f, f);
+        return Math.signum(f);
     }
-
 }
--- a/jdk/src/share/classes/sun/misc/REException.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/misc/REException.java	Wed Oct 26 17:59:13 2011 -0700
@@ -31,6 +31,9 @@
  */
 
 public class REException extends Exception {
+
+    private static final long serialVersionUID = 4656584872733646963L;
+
     REException (String s) {
         super(s);
     }
--- a/jdk/src/share/classes/sun/net/TransferProtocolClient.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/TransferProtocolClient.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,8 @@
 
 package sun.net;
 
-import java.lang.StringIndexOutOfBoundsException;
 import java.io.*;
 import java.util.Vector;
-import sun.net.NetworkClient;
 
 /**
  * This class implements that basic intefaces of transfer protocols.
@@ -44,7 +42,7 @@
 
     /** Array of strings (usually 1 entry) for the last reply
         from the server. */
-    protected Vector    serverResponse = new Vector(1);
+    protected Vector<String> serverResponse = new Vector<>(1);
 
     /** code for last reply */
     protected int       lastReplyCode;
@@ -123,11 +121,11 @@
 
     /** converts the server response into a string. */
     public String getResponseString() {
-        return (String) serverResponse.elementAt(0);
+        return serverResponse.elementAt(0);
     }
 
     /** Returns all server response strings. */
-    public Vector getResponseStrings() {
+    public Vector<String> getResponseStrings() {
         return serverResponse;
     }
 
--- a/jdk/src/share/classes/sun/net/ftp/FtpClientProvider.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/ftp/FtpClientProvider.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,16 +67,13 @@
             return false;
         }
         try {
-            Class c = Class.forName(cm, true, null);
+            Class<?> c = Class.forName(cm, true, null);
             provider = (FtpClientProvider) c.newInstance();
             return true;
-        } catch (ClassNotFoundException x) {
-            throw new ServiceConfigurationError(x.toString());
-        } catch (IllegalAccessException x) {
-            throw new ServiceConfigurationError(x.toString());
-        } catch (InstantiationException x) {
-            throw new ServiceConfigurationError(x.toString());
-        } catch (SecurityException x) {
+        } catch (ClassNotFoundException |
+                 IllegalAccessException |
+                 InstantiationException |
+                 SecurityException x) {
             throw new ServiceConfigurationError(x.toString());
         }
     }
--- a/jdk/src/share/classes/sun/net/httpserver/Request.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/httpserver/Request.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,10 @@
 
 package sun.net.httpserver;
 
-import java.util.*;
 import java.nio.*;
-import java.net.*;
 import java.io.*;
 import java.nio.channels.*;
 import com.sun.net.httpserver.*;
-import com.sun.net.httpserver.spi.*;
 
 /**
  */
@@ -47,7 +44,6 @@
     private OutputStream os;
 
     Request (InputStream rawInputStream, OutputStream rawout) throws IOException {
-        this.chan = chan;
         is = rawInputStream;
         os = rawout;
         do {
@@ -121,7 +117,7 @@
     }
 
     Headers hdrs = null;
-
+    @SuppressWarnings("fallthrough")
     Headers headers () throws IOException {
         if (hdrs != null) {
             return hdrs;
@@ -152,6 +148,7 @@
     parseloop:{
                 while ((c = is.read()) >= 0) {
                     switch (c) {
+                      /*fallthrough*/
                       case ':':
                         if (inKey && len > 0)
                             keyend = len;
--- a/jdk/src/share/classes/sun/net/httpserver/SSLStreams.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/httpserver/SSLStreams.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,13 +29,10 @@
 import java.nio.*;
 import java.io.*;
 import java.nio.channels.*;
-import java.util.*;
-import java.util.concurrent.*;
 import java.util.concurrent.locks.*;
 import javax.net.ssl.*;
 import javax.net.ssl.SSLEngineResult.*;
 import com.sun.net.httpserver.*;
-import com.sun.net.httpserver.spi.*;
 
 /**
  * given a non-blocking SocketChannel, it produces
@@ -448,6 +445,7 @@
      * on the wrapper methods being idempotent. eg. if wrapAndSend()
      * is called with no data to send then there must be no problem
      */
+    @SuppressWarnings("fallthrough")
     void doHandshake (HandshakeStatus hs_status) throws IOException {
         try {
             handshaking.lock();
--- a/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -593,8 +593,8 @@
                         rheaders.set ("Connection", "close");
                     } else if (chdr.equalsIgnoreCase ("keep-alive")) {
                         rheaders.set ("Connection", "keep-alive");
-                        int idle=(int)ServerConfig.getIdleInterval()/1000;
-                        int max=(int)ServerConfig.getMaxIdleConnections();
+                        int idle=(int)(ServerConfig.getIdleInterval()/1000);
+                        int max=ServerConfig.getMaxIdleConnections();
                         String val = "timeout="+idle+", max="+max;
                         rheaders.set ("Keep-Alive", val);
                     }
--- a/jdk/src/share/classes/sun/net/idn/UCharacterEnums.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/idn/UCharacterEnums.java	Wed Oct 26 17:59:13 2011 -0700
@@ -33,6 +33,22 @@
 //          - copy this file from icu4jsrc_3_2/src/com/ibm/icu/lang/UCharacterEnums.java
 //          - move from package com.ibm.icu.lang to package sun.net.idn
 //
+//      2011-09-06 Kurchi Subhra Hazra
+//          - Added @Deprecated tag to the following:
+//            - class UCharacterEnums
+//            - interfaces ECharacterCategory, ECharacterDirection
+//            - fields INITIAL_QUOTE_PUNCTUATION, FINAL_QUOTE_PUNCTUATION,
+//              DIRECTIONALITY_LEFT_TO_RIGHT, DIRECTIONALITY_RIGHT_TO_LEFT,
+//              DIRECTIONALITY_EUROPEAN_NUMBER, DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
+//              DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR, DIRECTIONALITY_ARABIC_NUMBER,
+//              DIRECTIONALITY_COMMON_NUMBER_SEPARATOR, DIRECTIONALITY_PARAGRAPH_SEPARATOR,
+//              DIRECTIONALITY_SEGMENT_SEPARATOR, DIRECTIONALITY_WHITESPACE,
+//              DIRECTIONALITY_OTHER_NEUTRALS, DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING,
+//              DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE, DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC,
+//              DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING, DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE,
+//              DIRECTIONALITY_POP_DIRECTIONAL_FORMAT, DIRECTIONALITY_NON_SPACING_MARK,
+//              DIRECTIONALITY_BOUNDARY_NEUTRAL, DIRECTIONALITY_UNDEFINED
+//
 
 package sun.net.idn;
 
@@ -41,6 +57,8 @@
  * @draft ICU 3.0
  * @deprecated This is a draft API and might change in a future release of ICU.
  */
+
+@Deprecated
 class UCharacterEnums {
 
     /** This is just a namespace, it is not instantiatable. */
@@ -54,6 +72,7 @@
      * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
      */
+    @Deprecated
     public static interface ECharacterCategory {
         /**
          * Unassigned character type
@@ -245,6 +264,7 @@
          * @draft ICU 2.8
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final int INITIAL_QUOTE_PUNCTUATION = 28;
 
         /**
@@ -261,6 +281,7 @@
          * @draft ICU 2.8
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final int FINAL_QUOTE_PUNCTUATION   = 29;
 
         /**
@@ -279,6 +300,8 @@
      * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
      */
+
+    @Deprecated
     public static interface ECharacterDirection {
         /**
          * Directional type L
@@ -291,6 +314,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = (byte)LEFT_TO_RIGHT;
 
         /**
@@ -304,6 +328,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = (byte)RIGHT_TO_LEFT;
 
         /**
@@ -317,6 +342,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = (byte)EUROPEAN_NUMBER;
 
         /**
@@ -330,6 +356,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = (byte)EUROPEAN_NUMBER_SEPARATOR;
 
         /**
@@ -343,6 +370,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = (byte)EUROPEAN_NUMBER_TERMINATOR;
 
         /**
@@ -356,6 +384,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_ARABIC_NUMBER = (byte)ARABIC_NUMBER;
 
         /**
@@ -369,6 +398,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = (byte)COMMON_NUMBER_SEPARATOR;
 
         /**
@@ -382,6 +412,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = (byte)BLOCK_SEPARATOR;
 
         /**
@@ -395,6 +426,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = (byte)SEGMENT_SEPARATOR;
 
         /**
@@ -408,6 +440,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_WHITESPACE = (byte)WHITE_SPACE_NEUTRAL;
 
         /**
@@ -421,6 +454,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_OTHER_NEUTRALS = (byte)OTHER_NEUTRAL;
 
         /**
@@ -434,6 +468,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = (byte)LEFT_TO_RIGHT_EMBEDDING;
 
         /**
@@ -447,6 +482,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = (byte)LEFT_TO_RIGHT_OVERRIDE;
 
         /**
@@ -460,6 +496,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = (byte)RIGHT_TO_LEFT_ARABIC;
 
         /**
@@ -473,6 +510,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = (byte)RIGHT_TO_LEFT_EMBEDDING;
 
         /**
@@ -486,6 +524,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = (byte)RIGHT_TO_LEFT_OVERRIDE;
 
         /**
@@ -499,6 +538,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = (byte)POP_DIRECTIONAL_FORMAT;
 
         /**
@@ -512,6 +552,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_NON_SPACING_MARK = (byte)DIR_NON_SPACING_MARK;
 
         /**
@@ -525,6 +566,7 @@
          * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = (byte)BOUNDARY_NEUTRAL;
 
         /**
@@ -539,6 +581,7 @@
      * @draft ICU 3.0
      * @deprecated This is a draft API and might change in a future release of ICU.
          */
+        @Deprecated
         public static final byte DIRECTIONALITY_UNDEFINED = -1;
     }
 }
--- a/jdk/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -140,7 +140,7 @@
             // create new soft reference to our thread context
             //
             thrCtxt = new ThreadContext(dirCtxt, nsList);
-            contextRef.set(new SoftReference(thrCtxt));
+            contextRef.set(new SoftReference<ThreadContext>(thrCtxt));
         }
 
         return thrCtxt.dirContext();
@@ -193,7 +193,7 @@
                 Attribute attr = ne.next();
                 String attrID = attr.getID();
 
-                for (NamingEnumeration e = attr.getAll(); e.hasMoreElements();) {
+                for (NamingEnumeration<?> e = attr.getAll(); e.hasMoreElements();) {
                     String addr = (String)e.next();
 
                     // for canoncical name records do recursive lookup
@@ -233,7 +233,7 @@
         String domain = AccessController.doPrivileged(
             new GetPropertyAction("sun.net.spi.nameservice.domain"));
         if (domain != null && domain.length() > 0) {
-            domainList = new LinkedList();
+            domainList = new LinkedList<String>();
             domainList.add(domain);
         }
 
@@ -282,7 +282,7 @@
             throw new Error(nx);
         }
 
-        ArrayList results = null;
+        ArrayList<String> results = null;
         UnknownHostException uhe = null;
 
         // If host already contains a domain name then just look it up
@@ -365,7 +365,7 @@
         InetAddress[] addrs = new InetAddress[results.size()];
         int count = 0;
         for (int i=0; i<results.size(); i++) {
-            String addrString = (String)results.get(i);
+            String addrString = results.get(i);
             byte addr[] = IPAddressUtil.textToNumericFormatV4(addrString);
             if (addr == null) {
                 addr = IPAddressUtil.textToNumericFormatV6(addrString);
--- a/jdk/src/share/classes/sun/net/www/HeaderParser.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/HeaderParser.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -192,7 +192,7 @@
         return Default;
     }
 
-    class ParserIterator implements Iterator {
+    class ParserIterator implements Iterator<String> {
         int index;
         boolean returnsValue; // or key
 
@@ -202,7 +202,7 @@
         public boolean hasNext () {
             return index<nkeys;
         }
-        public Object next () {
+        public String next () {
             return tab[index++][returnsValue?1:0];
         }
         public void remove () {
@@ -210,20 +210,20 @@
         }
     }
 
-    public Iterator keys () {
+    public Iterator<String> keys () {
         return new ParserIterator (false);
     }
 
-    public Iterator values () {
+    public Iterator<String> values () {
         return new ParserIterator (true);
     }
 
     public String toString () {
-        Iterator k = keys();
+        Iterator<String> k = keys();
         StringBuffer sbuf = new StringBuffer();
         sbuf.append ("{size="+asize+" nkeys="+nkeys+" ");
         for (int i=0; k.hasNext(); i++) {
-            String key = (String)k.next();
+            String key = k.next();
             String val = findValue (i);
             if (val != null && "".equals (val)) {
                 val = null;
--- a/jdk/src/share/classes/sun/net/www/MessageHeader.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/MessageHeader.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.ArrayList;
-import java.util.Set;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
@@ -199,7 +198,8 @@
         return filterAndAddHeaders(excludeList, null);
     }
 
-    public synchronized Map<String, List<String>> filterAndAddHeaders(String[] excludeList, Map<String, List<String>>  include) {
+    public synchronized Map<String, List<String>> filterAndAddHeaders(
+            String[] excludeList, Map<String, List<String>>  include) {
         boolean skipIt = false;
         Map<String, List<String>> m = new HashMap<String, List<String>>();
         for (int i = nkeys; --i >= 0;) {
@@ -228,15 +228,13 @@
         }
 
         if (include != null) {
-            Iterator entries = include.entrySet().iterator();
-            while (entries.hasNext()) {
-                Map.Entry entry = (Map.Entry)entries.next();
-                List l = (List)m.get(entry.getKey());
+                for (Map.Entry<String,List<String>> entry: include.entrySet()) {
+                List<String> l = m.get(entry.getKey());
                 if (l == null) {
-                    l = new ArrayList();
-                    m.put((String)entry.getKey(), l);
+                    l = new ArrayList<String>();
+                    m.put(entry.getKey(), l);
                 }
-                l.add(entry.getValue());
+                l.addAll(entry.getValue());
             }
         }
 
@@ -400,6 +398,7 @@
     }
 
     /** Parse and merge a MIME header from an input stream. */
+    @SuppressWarnings("fallthrough")
     public void mergeHeader(InputStream is) throws java.io.IOException {
         if (is == null)
             return;
@@ -421,6 +420,7 @@
                         break;
                       case '\t':
                         c = ' ';
+                      /*fall through*/
                       case ' ':
                         inKey = false;
                         break;
--- a/jdk/src/share/classes/sun/net/www/MimeTable.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/MimeTable.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,6 @@
 
 package sun.net.www;
 import java.io.*;
-import java.util.Calendar;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-import java.net.URL;
 import java.net.FileNameMap;
 import java.util.Hashtable;
 import java.util.Enumeration;
@@ -271,7 +267,7 @@
         String tempFileTemplate = (String)entries.get("temp.file.template");
         if (tempFileTemplate != null) {
             entries.remove("temp.file.template");
-            this.tempFileTemplate = tempFileTemplate;
+            MimeTable.tempFileTemplate = tempFileTemplate;
         }
 
         // now, parse the mime-type spec's
@@ -417,10 +413,10 @@
             String user = System.getProperty("user.name");
             if (user != null) {
                 tag = "; customized for " + user;
-                properties.save(os, filePreamble + tag);
+                properties.store(os, filePreamble + tag);
             }
             else {
-                properties.save(os, filePreamble);
+                properties.store(os, filePreamble);
             }
         }
         catch (IOException e) {
--- a/jdk/src/share/classes/sun/net/www/URLConnection.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/URLConnection.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,12 +26,7 @@
 package sun.net.www;
 
 import java.net.URL;
-import java.net.ContentHandler;
 import java.util.*;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.BufferedInputStream;
-import java.net.UnknownServiceException;
 
 /**
  * A class to represent an active connection to an object
@@ -99,7 +94,7 @@
     public Map<String,List<String>> getRequestProperties() {
         if (connected)
             throw new IllegalStateException("Already connected");
-        return Collections.EMPTY_MAP;
+        return Collections.emptyMap();
     }
 
     public String getHeaderField(String name) {
--- a/jdk/src/share/classes/sun/net/www/content/image/gif.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/content/image/gif.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,8 @@
 
 package sun.net.www.content.image;
 
-import java.net.URL;
-import java.net.URLConnection;
 import java.net.*;
 import sun.awt.image.*;
-import java.io.InputStream;
 import java.io.IOException;
 import java.awt.Image;
 import java.awt.Toolkit;
@@ -40,7 +37,7 @@
         return new URLImageSource(urlc);
     }
 
-    public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
+    public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
         for (int i = 0; i < classes.length; i++) {
           if (classes[i].isAssignableFrom(URLImageSource.class)) {
                 return new URLImageSource(urlc);
--- a/jdk/src/share/classes/sun/net/www/content/image/jpeg.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/content/image/jpeg.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,8 @@
 
 package sun.net.www.content.image;
 
-import java.net.URL;
-import java.net.URLConnection;
 import java.net.*;
 import sun.awt.image.*;
-import java.io.InputStream;
 import java.io.IOException;
 import java.awt.Image;
 import java.awt.Toolkit;
@@ -39,7 +36,7 @@
         return new URLImageSource(urlc);
     }
 
-    public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
+    public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
         for (int i = 0; i < classes.length; i++) {
           if (classes[i].isAssignableFrom(URLImageSource.class)) {
                 return new URLImageSource(urlc);
--- a/jdk/src/share/classes/sun/net/www/content/image/png.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/content/image/png.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,7 @@
 
 package sun.net.www.content.image;
 
-import java.net.URL;
-import java.net.URLConnection;
 import java.net.*;
-import java.io.InputStream;
 import java.io.IOException;
 import sun.awt.image.*;
 import java.awt.Image;
@@ -39,7 +36,7 @@
         return new URLImageSource(urlc);
     }
 
-    public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
+    public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
         for (int i = 0; i < classes.length; i++) {
           if (classes[i].isAssignableFrom(URLImageSource.class)) {
                 return new URLImageSource(urlc);
--- a/jdk/src/share/classes/sun/net/www/content/image/x_xbitmap.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/content/image/x_xbitmap.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
         return new URLImageSource(urlc);
     }
 
-    public Object getContent(URLConnection urlc, Class[] classes) throws java.io.IOException {
+    public Object getContent(URLConnection urlc, Class<?>[] classes) throws java.io.IOException {
         for (int i = 0; i < classes.length; i++) {
           if (classes[i].isAssignableFrom(URLImageSource.class)) {
                 return new URLImageSource(urlc);
--- a/jdk/src/share/classes/sun/net/www/content/image/x_xpixmap.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/content/image/x_xpixmap.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
         return new URLImageSource(urlc);
     }
 
-    public Object getContent(URLConnection urlc, Class[] classes) throws java.io.IOException {
+    public Object getContent(URLConnection urlc, Class<?>[] classes) throws java.io.IOException {
         for (int i = 0; i < classes.length; i++) {
           if (classes[i].isAssignableFrom(URLImageSource.class)) {
                 return new URLImageSource(urlc);
--- a/jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java	Wed Oct 26 17:59:13 2011 -0700
@@ -81,7 +81,7 @@
         // NOTE: Don't close super class
         try {
             if (expected > count) {
-                long nskip = (long) (expected - count);
+                long nskip = expected - count;
                 if (nskip <= available()) {
                     long n = 0;
                     while (n < nskip) {
--- a/jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/gopher/GopherClient.java	Wed Oct 26 17:59:13 2011 -0700
@@ -281,7 +281,7 @@
                 ps.print("</title></head>\n<body>\n<H1>");
                 ps.print(title);
                 ps.print("</h1><dl compact>\n");
-                DataInputStream ds = new DataInputStream(serverInput);
+                BufferedReader ds = new BufferedReader(new InputStreamReader(serverInput));
                 String s;
                 while ((s = ds.readLine()) != null) {
                     int len = s.length();
--- a/jdk/src/share/classes/sun/net/www/protocol/http/AuthCacheImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/AuthCacheImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,8 @@
 
 package sun.net.www.protocol.http;
 
-import java.io.IOException;
-import java.net.URL;
-import java.util.Hashtable;
 import java.util.LinkedList;
 import java.util.ListIterator;
-import java.util.Enumeration;
 import java.util.HashMap;
 
 /**
@@ -38,13 +34,13 @@
  */
 
 public class AuthCacheImpl implements AuthCache {
-    HashMap hashtable;
+    HashMap<String,LinkedList<AuthCacheValue>> hashtable;
 
     public AuthCacheImpl () {
-        hashtable = new HashMap ();
+        hashtable = new HashMap<String,LinkedList<AuthCacheValue>>();
     }
 
-    public void setMap (HashMap map) {
+    public void setMap (HashMap<String,LinkedList<AuthCacheValue>> map) {
         hashtable = map;
     }
 
@@ -52,21 +48,21 @@
     // is the path field of AuthenticationInfo
 
     public synchronized void put (String pkey, AuthCacheValue value) {
-        LinkedList list = (LinkedList) hashtable.get (pkey);
+        LinkedList<AuthCacheValue> list = hashtable.get (pkey);
         String skey = value.getPath();
         if (list == null) {
-            list = new LinkedList ();
-            hashtable.put (pkey, list);
+            list = new LinkedList<AuthCacheValue>();
+            hashtable.put(pkey, list);
         }
         // Check if the path already exists or a super-set of it exists
-        ListIterator iter = list.listIterator();
+        ListIterator<AuthCacheValue> iter = list.listIterator();
         while (iter.hasNext()) {
             AuthenticationInfo inf = (AuthenticationInfo)iter.next();
             if (inf.path == null || inf.path.startsWith (skey)) {
                 iter.remove ();
             }
         }
-        iter.add (value);
+        iter.add(value);
     }
 
     // get a value from map checking both primary
@@ -74,7 +70,7 @@
 
     public synchronized AuthCacheValue get (String pkey, String skey) {
         AuthenticationInfo result = null;
-        LinkedList list = (LinkedList) hashtable.get (pkey);
+        LinkedList<AuthCacheValue> list = hashtable.get (pkey);
         if (list == null || list.size() == 0) {
             return null;
         }
@@ -82,7 +78,7 @@
             // list should contain only one element
             return (AuthenticationInfo)list.get (0);
         }
-        ListIterator iter = list.listIterator();
+        ListIterator<AuthCacheValue> iter = list.listIterator();
         while (iter.hasNext()) {
             AuthenticationInfo inf = (AuthenticationInfo)iter.next();
             if (skey.startsWith (inf.path)) {
@@ -93,7 +89,7 @@
     }
 
     public synchronized void remove (String pkey, AuthCacheValue entry) {
-        LinkedList list = (LinkedList) hashtable.get (pkey);
+        LinkedList<AuthCacheValue> list = hashtable.get (pkey);
         if (list == null) {
             return;
         }
@@ -101,7 +97,7 @@
             list.clear();
             return;
         }
-        ListIterator iter = list.listIterator ();
+        ListIterator<AuthCacheValue> iter = list.listIterator ();
         while (iter.hasNext()) {
             AuthenticationInfo inf = (AuthenticationInfo)iter.next();
             if (entry.equals(inf)) {
--- a/jdk/src/share/classes/sun/net/www/protocol/http/AuthenticationHeader.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/AuthenticationHeader.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -122,7 +122,7 @@
         this.dontUseNegotiate = dontUseNegotiate;
         rsp = response;
         this.hdrname = hdrname;
-        schemes = new HashMap();
+        schemes = new HashMap<String,SchemeMapValue>();
         parse();
     }
 
@@ -136,7 +136,7 @@
         HeaderParser parser;
     }
 
-    HashMap schemes;
+    HashMap<String, SchemeMapValue> schemes;
 
     /* Iterate through each header line, and then within each line.
      * If multiple entries exist for a particular scheme (unlikely)
@@ -144,11 +144,11 @@
      * preferred scheme that we support will be used.
      */
     private void parse () {
-        Iterator iter = rsp.multiValueIterator (hdrname);
+        Iterator<String> iter = rsp.multiValueIterator(hdrname);
         while (iter.hasNext()) {
-            String raw = (String)iter.next();
-            HeaderParser hp = new HeaderParser (raw);
-            Iterator keys = hp.keys();
+            String raw = iter.next();
+            HeaderParser hp = new HeaderParser(raw);
+            Iterator<String> keys = hp.keys();
             int i, lastSchemeIndex;
             for (i=0, lastSchemeIndex = -1; keys.hasNext(); i++) {
                 keys.next();
@@ -164,7 +164,7 @@
             if (i > lastSchemeIndex) {
                 HeaderParser hpn = hp.subsequence (lastSchemeIndex, i);
                 String scheme = hpn.findKey(0);
-                schemes.put (scheme, new SchemeMapValue (hpn, raw));
+                schemes.put(scheme, new SchemeMapValue (hpn, raw));
             }
         }
 
@@ -172,10 +172,10 @@
          * negotiate -> kerberos -> digest -> ntlm -> basic
          */
         SchemeMapValue v = null;
-        if (authPref == null || (v=(SchemeMapValue)schemes.get (authPref)) == null) {
+        if (authPref == null || (v=schemes.get (authPref)) == null) {
 
             if(v == null && !dontUseNegotiate) {
-                SchemeMapValue tmp = (SchemeMapValue)schemes.get("negotiate");
+                SchemeMapValue tmp = schemes.get("negotiate");
                 if(tmp != null) {
                     if(hci == null || !NegotiateAuthentication.isSupported(new HttpCallerInfo(hci, "Negotiate"))) {
                         tmp = null;
@@ -185,7 +185,7 @@
             }
 
             if(v == null && !dontUseNegotiate) {
-                SchemeMapValue tmp = (SchemeMapValue)schemes.get("kerberos");
+                SchemeMapValue tmp = schemes.get("kerberos");
                 if(tmp != null) {
                     // the Kerberos scheme is only observed in MS ISA Server. In
                     // fact i think it's a Kerberos-mechnism-only Negotiate.
@@ -205,9 +205,9 @@
             }
 
             if(v == null) {
-                if ((v=(SchemeMapValue)schemes.get ("digest")) == null) {
-                    if (((v=(SchemeMapValue)schemes.get("ntlm"))==null)) {
-                        v = (SchemeMapValue)schemes.get ("basic");
+                if ((v=schemes.get ("digest")) == null) {
+                    if (((v=schemes.get("ntlm"))==null)) {
+                        v = schemes.get ("basic");
                     }
                 }
             }
--- a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Wed Oct 26 17:59:13 2011 -0700
@@ -25,6 +25,7 @@
 
 package sun.net.www.protocol.http;
 
+import java.util.Arrays;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.ProtocolException;
@@ -229,9 +230,9 @@
             bufSize4ES = 4096; // use the default
         }
 
-        allowRestrictedHeaders = ((Boolean)java.security.AccessController.doPrivileged(
+        allowRestrictedHeaders = java.security.AccessController.doPrivileged(
                 new sun.security.action.GetBooleanAction(
-                    "sun.net.http.allowRestrictedHeaders"))).booleanValue();
+                    "sun.net.http.allowRestrictedHeaders")).booleanValue();
         if (!allowRestrictedHeaders) {
             restrictedHeaderSet = new HashSet<String>(restrictedHeaders.length);
             for (int i=0; i < restrictedHeaders.length; i++) {
@@ -289,6 +290,7 @@
      * REMIND:  backwards compatibility with JDK 1.1.  Should be
      * eliminated for JDK 2.0.
      */
+    @Deprecated
     private static HttpAuthenticator defaultAuth;
 
     /* all the headers we send
@@ -750,6 +752,7 @@
     /**
      * @deprecated.  Use java.net.Authenticator.setDefault() instead.
      */
+    @Deprecated
     public static void setDefaultAuthenticator(HttpAuthenticator a) {
         defaultAuth = a;
     }
@@ -830,8 +833,7 @@
                     InetAddress a1 = InetAddress.getByName(h1);
                     InetAddress a2 = InetAddress.getByName(h2);
                     result[0] = a1.equals(a2);
-                } catch(UnknownHostException e) {
-                } catch(SecurityException e) {
+                } catch(UnknownHostException | SecurityException e) {
                 }
                 return null;
             }
@@ -1336,9 +1338,9 @@
 
                     // Read comments labeled "Failed Negotiate" for details.
                     boolean dontUseNegotiate = false;
-                    Iterator iter = responses.multiValueIterator("Proxy-Authenticate");
+                    Iterator<String> iter = responses.multiValueIterator("Proxy-Authenticate");
                     while (iter.hasNext()) {
-                        String value = ((String)iter.next()).trim();
+                        String value = iter.next().trim();
                         if (value.equalsIgnoreCase("Negotiate") ||
                                 value.equalsIgnoreCase("Kerberos")) {
                             if (!inNegotiateProxy) {
@@ -1414,9 +1416,9 @@
 
                     // Read comments labeled "Failed Negotiate" for details.
                     boolean dontUseNegotiate = false;
-                    Iterator iter = responses.multiValueIterator("WWW-Authenticate");
+                    Iterator<String> iter = responses.multiValueIterator("WWW-Authenticate");
                     while (iter.hasNext()) {
-                        String value = ((String)iter.next()).trim();
+                        String value = iter.next().trim();
                         if (value.equalsIgnoreCase("Negotiate") ||
                                 value.equalsIgnoreCase("Kerberos")) {
                             if (!inNegotiate) {
@@ -1585,9 +1587,8 @@
                                 // HttpsURLConnection instance saved in
                                 // DelegateHttpsURLConnection
                                 uconn = (URLConnection)this.getClass().getField("httpsURLConnection").get(this);
-                                } catch (IllegalAccessException iae) {
-                                    // ignored; use 'this'
-                                } catch (NoSuchFieldException nsfe) {
+                                } catch (IllegalAccessException |
+                                         NoSuchFieldException e) {
                                     // ignored; use 'this'
                                 }
                             }
@@ -1660,7 +1661,7 @@
                         public IOException run() throws Exception {
                             return (IOException)
                                 rememberedException.getClass()
-                                .getConstructor(new Class[] { String.class })
+                                .getConstructor(new Class<?>[] { String.class })
                                 .newInstance(args);
                         }
                     });
@@ -1786,9 +1787,9 @@
                 if (respCode == HTTP_PROXY_AUTH) {
                     // Read comments labeled "Failed Negotiate" for details.
                     boolean dontUseNegotiate = false;
-                    Iterator iter = responses.multiValueIterator("Proxy-Authenticate");
+                    Iterator<String> iter = responses.multiValueIterator("Proxy-Authenticate");
                     while (iter.hasNext()) {
-                        String value = ((String)iter.next()).trim();
+                        String value = iter.next().trim();
                         if (value.equalsIgnoreCase("Negotiate") ||
                                 value.equalsIgnoreCase("Kerberos")) {
                             if (!inNegotiateProxy) {
@@ -1938,6 +1939,7 @@
      * Gets the authentication for an HTTP proxy, and applies it to
      * the connection.
      */
+    @SuppressWarnings("fallthrough")
     private AuthenticationInfo getHttpProxyAuthentication (AuthenticationHeader authhdr) {
         /* get authorization from authenticator */
         AuthenticationInfo ret = null;
@@ -2004,13 +2006,13 @@
                     }
                     break;
                 case NTLM:
-                    if (NTLMAuthenticationProxy.proxy.supported) {
+                    if (NTLMAuthenticationProxy.supported) {
                         /* tryTransparentNTLMProxy will always be true the first
                          * time around, but verify that the platform supports it
                          * otherwise don't try. */
                         if (tryTransparentNTLMProxy) {
                             tryTransparentNTLMProxy =
-                                    NTLMAuthenticationProxy.proxy.supportsTransparentAuth;
+                                    NTLMAuthenticationProxy.supportsTransparentAuth;
                         }
                         a = null;
                         if (tryTransparentNTLMProxy) {
@@ -2043,6 +2045,7 @@
                     break;
                 case UNKNOWN:
                     logger.finest("Unknown/Unsupported authentication scheme: " + scheme);
+                /*fall through*/
                 default:
                     throw new AssertionError("should not reach here");
                 }
@@ -2080,6 +2083,7 @@
      * @param authHdr the AuthenticationHeader which tells what auth scheme is
      * prefered.
      */
+    @SuppressWarnings("fallthrough")
     private AuthenticationInfo getServerAuthentication (AuthenticationHeader authhdr) {
         /* get authorization from authenticator */
         AuthenticationInfo ret = null;
@@ -2150,7 +2154,7 @@
                     }
                     break;
                 case NTLM:
-                    if (NTLMAuthenticationProxy.proxy.supported) {
+                    if (NTLMAuthenticationProxy.supported) {
                         URL url1;
                         try {
                             url1 = new URL (url, "/"); /* truncate the path */
@@ -2163,13 +2167,13 @@
                          * otherwise don't try. */
                         if (tryTransparentNTLMServer) {
                             tryTransparentNTLMServer =
-                                    NTLMAuthenticationProxy.proxy.supportsTransparentAuth;
+                                    NTLMAuthenticationProxy.supportsTransparentAuth;
                             /* If the platform supports transparent authentication
                              * then check if we are in a secure environment
                              * whether, or not, we should try transparent authentication.*/
                             if (tryTransparentNTLMServer) {
                                 tryTransparentNTLMServer =
-                                        NTLMAuthenticationProxy.proxy.isTrustedSite(url);
+                                        NTLMAuthenticationProxy.isTrustedSite(url);
                             }
                         }
                         a = null;
@@ -2198,6 +2202,7 @@
                     break;
                 case UNKNOWN:
                     logger.finest("Unknown/Unsupported authentication scheme: " + scheme);
+                /*fall through*/
                 default:
                     throw new AssertionError("should not reach here");
                 }
@@ -2745,14 +2750,14 @@
          * The cookies in the requests message headers may have
          * been modified. Use the saved user cookies instead.
          */
-        Map userCookiesMap = null;
+        Map<String, List<String>> userCookiesMap = null;
         if (userCookies != null || userCookies2 != null) {
-            userCookiesMap = new HashMap();
+            userCookiesMap = new HashMap<>();
             if (userCookies != null) {
-                userCookiesMap.put("Cookie", userCookies);
+                userCookiesMap.put("Cookie", Arrays.asList(userCookies));
             }
             if (userCookies2 != null) {
-                userCookiesMap.put("Cookie2", userCookies2);
+                userCookiesMap.put("Cookie2", Arrays.asList(userCookies2));
             }
         }
         return requests.filterAndAddHeaders(EXCLUDE_HEADERS2, userCookiesMap);
--- a/jdk/src/share/classes/sun/net/www/protocol/http/Negotiator.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/Negotiator.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,8 +45,8 @@
         // Makes NegotiatorImpl, and the security classes it references, a
         // runtime dependency rather than a static one.
 
-        Class clazz;
-        Constructor c;
+        Class<?> clazz;
+        Constructor<?> c;
         try {
             clazz = Class.forName("sun.net.www.protocol.http.spnego.NegotiatorImpl", true, null);
             c = clazz.getConstructor(HttpCallerInfo.class);
--- a/jdk/src/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -221,11 +221,11 @@
      */
     public java.security.cert.Certificate[] getLocalCertificates() {
         if (cachedResponse != null) {
-            List l = ((SecureCacheResponse)cachedResponse).getLocalCertificateChain();
+            List<java.security.cert.Certificate> l = ((SecureCacheResponse)cachedResponse).getLocalCertificateChain();
             if (l == null) {
                 return null;
             } else {
-                return (java.security.cert.Certificate[])l.toArray();
+                return l.toArray(new java.security.cert.Certificate[0]);
             }
         }
         if (http == null) {
@@ -243,11 +243,11 @@
     public java.security.cert.Certificate[] getServerCertificates()
             throws SSLPeerUnverifiedException {
         if (cachedResponse != null) {
-            List l = ((SecureCacheResponse)cachedResponse).getServerCertificateChain();
+            List<java.security.cert.Certificate> l = ((SecureCacheResponse)cachedResponse).getServerCertificateChain();
             if (l == null) {
                 return null;
             } else {
-                return (java.security.cert.Certificate[])l.toArray();
+                return l.toArray(new java.security.cert.Certificate[0]);
             }
         }
 
--- a/jdk/src/share/classes/sun/net/www/protocol/https/HttpsClient.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/https/HttpsClient.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -529,7 +529,7 @@
                     new BufferedOutputStream(serverSocket.getOutputStream()),
                     false, encoding);
             } catch (UnsupportedEncodingException e) {
-                throw new InternalError(encoding+" encoding not found", e);
+                throw new InternalError(encoding+" encoding not found");
             }
 
             // check URL spoofing if it has not been checked under handshaking
@@ -623,7 +623,7 @@
      */
     @Override
     public void closeIdleConnection() {
-        HttpClient http = (HttpClient) kac.get(url, sslSocketFactory);
+        HttpClient http = kac.get(url, sslSocketFactory);
         if (http != null) {
             http.closeServer();
         }
@@ -681,8 +681,7 @@
             // return the X500Principal of the end-entity cert.
             java.security.cert.Certificate[] certs =
                         session.getPeerCertificates();
-            principal = (X500Principal)
-                ((X509Certificate)certs[0]).getSubjectX500Principal();
+            principal = ((X509Certificate)certs[0]).getSubjectX500Principal();
         }
         return principal;
     }
@@ -703,8 +702,7 @@
             java.security.cert.Certificate[] certs =
                         session.getLocalCertificates();
             if (certs != null) {
-                principal = (X500Principal)
-                    ((X509Certificate)certs[0]).getSubjectX500Principal();
+                principal = ((X509Certificate)certs[0]).getSubjectX500Principal();
             }
         }
         return principal;
--- a/jdk/src/share/classes/sun/net/www/protocol/mailto/Handler.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/net/www/protocol/mailto/Handler.java	Wed Oct 26 17:59:13 2011 -0700
@@ -139,6 +139,20 @@
         }
         if (nogood)
             throw new RuntimeException("No email address");
-        setURL(u, protocol, host, port, file, null);
+        setURLHandler(u, protocol, host, port, file, null);
+    }
+
+    /**
+     * This method is used to suppress the deprecated warning
+     *
+     * @param   u the URL to receive the result of parsing the spec
+     * @param   spec the URL string to parse
+     * @param   start the character position to start parsing at.  This is
+     *          just past the ':'.
+     * @param   limit the character position to stop parsing at.
+     */
+    @SuppressWarnings("deprecation")
+    private void setURLHandler(URL u, String protocol, String host, int port, String file, String ref) {
+        setURL(u,protocol,host,port,file,null);
     }
 }
--- a/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/ec/ECPublicKeyImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,7 @@
      * Construct a key from its components. Used by the
      * ECKeyFactory and SunPKCS11.
      */
+    @SuppressWarnings("deprecation")
     public ECPublicKeyImpl(ECPoint w, ECParameterSpec params)
             throws InvalidKeyException {
         this.w = w;
@@ -85,6 +86,7 @@
 
     // Internal API to get the encoded point. Currently used by SunPKCS11.
     // This may change/go away depending on what we do with the public API.
+    @SuppressWarnings("deprecation")
     public byte[] getEncodedPublicValue() {
         return key.clone();
     }
@@ -92,6 +94,7 @@
     /**
      * Parse the key. Called by X509Key.
      */
+    @SuppressWarnings("deprecation")
     protected void parseKeyBits() throws InvalidKeyException {
         try {
             AlgorithmParameters algParams = this.algid.getParameters();
--- a/jdk/src/share/classes/sun/security/jgss/krb5/AcceptSecContextToken.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/AcceptSecContextToken.java	Wed Oct 26 17:59:13 2011 -0700
@@ -94,7 +94,7 @@
          */
         EncryptionKey subKey = apRep.getSubKey();
         if (subKey != null) {
-            context.setKey(subKey);
+            context.setKey(Krb5Context.ACCEPTOR_SUBKEY, subKey);
             /*
             System.out.println("\n\nSub-Session key from AP-REP is: " +
                                getHexBytes(subKey.getBytes()) + "\n");
--- a/jdk/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/InitSecContextToken.java	Wed Oct 26 17:59:13 2011 -0700
@@ -74,9 +74,9 @@
 
         EncryptionKey subKey = apReq.getSubKey();
         if (subKey != null)
-            context.setKey(subKey);
+            context.setKey(Krb5Context.INITIATOR_SUBKEY, subKey);
         else
-            context.setKey(serviceTicket.getSessionKey());
+            context.setKey(Krb5Context.SESSION_KEY, serviceTicket.getSessionKey());
 
         if (!mutualRequired)
             context.resetPeerSequenceNumber(0);
@@ -117,13 +117,13 @@
 
         EncryptionKey subKey = apReq.getSubKey();
         if (subKey != null) {
-            context.setKey(subKey);
+            context.setKey(Krb5Context.INITIATOR_SUBKEY, subKey);
             /*
               System.out.println("Sub-Session key from authenticator is: " +
               getHexBytes(subKey.getBytes()) + "\n");
             */
         } else {
-            context.setKey(sessionKey);
+            context.setKey(Krb5Context.SESSION_KEY, sessionKey);
             //System.out.println("Sub-Session Key Missing in Authenticator.\n");
         }
 
--- a/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Context.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/Krb5Context.java	Wed Oct 26 17:59:13 2011 -0700
@@ -67,6 +67,10 @@
 
     private int state = STATE_NEW;
 
+    public static final int SESSION_KEY = 0;
+    public static final int INITIATOR_SUBKEY = 1;
+    public static final int ACCEPTOR_SUBKEY = 2;
+
     /*
      * Optional features that the application can set and their default
      * values.
@@ -82,6 +86,7 @@
 
     private int mySeqNumber;
     private int peerSeqNumber;
+    private int keySrc;
     private TokenTracker peerTokenTracker;
 
     private CipherHelper cipherHelper = null;
@@ -384,12 +389,17 @@
         }
     }
 
-    final void setKey(EncryptionKey key) throws GSSException {
+    final void setKey(int keySrc, EncryptionKey key) throws GSSException {
         this.key = key;
+        this.keySrc = keySrc;
         // %%% to do: should clear old cipherHelper first
         cipherHelper = new CipherHelper(key);  // Need to use new key
     }
 
+    public final int getKeySrc() {
+        return keySrc;
+    }
+
     private final EncryptionKey getKey() {
         return key;
     }
--- a/jdk/src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java	Wed Oct 26 17:59:13 2011 -0700
@@ -141,6 +141,7 @@
     // Context properties
     private boolean confState = true;
     private boolean initiator = true;
+    private boolean have_acceptor_subkey = false;
 
     /* cipher instance used by the corresponding GSSContext */
     CipherHelper cipherHelper = null;
@@ -233,7 +234,6 @@
             }
 
             if (tokenId == Krb5Token.WRAP_ID_v2) {
-                // Does non-confidential data needs a rotate?
                 rotate();
             }
 
@@ -312,8 +312,7 @@
         }
 
         // Create a new gss token header as defined in RFC 4121
-        tokenHeader = new MessageTokenHeader(tokenId,
-                                prop.getPrivacy(), true);
+        tokenHeader = new MessageTokenHeader(tokenId, prop.getPrivacy());
         // debug("\n\t Message Header = " +
         // getHexBytes(tokenHeader.getBytes(), tokenHeader.getBytes().length));
 
@@ -421,10 +420,12 @@
         int conf_flag = tokenHeaderBytes[TOKEN_FLAG_POS] &
                                 FLAG_WRAP_CONFIDENTIAL;
 
-        // clear EC in token header for checksum calculation
+        // clear EC and RRC in token header for checksum calculation
         if ((conf_flag == 0) && (tokenId == WRAP_ID_v2)) {
             tokenHeaderBytes[4] = 0;
             tokenHeaderBytes[5] = 0;
+            tokenHeaderBytes[6] = 0;
+            tokenHeaderBytes[7] = 0;
         }
         return cipherHelper.calculateChecksum(tokenHeaderBytes, data,
                                                 offset, len, key_usage);
@@ -460,6 +461,8 @@
 
         this.initiator = context.isInitiator();
 
+        this.have_acceptor_subkey = context.getKeySrc() == Krb5Context.ACCEPTOR_SUBKEY;
+
         this.cipherHelper = context.getCipherHelper(null);
         //    debug("In MessageToken.Cons");
     }
@@ -500,8 +503,7 @@
          private byte[] bytes = new byte[TOKEN_HEADER_SIZE];
 
          // Writes a new token header
-         public MessageTokenHeader(int tokenId, boolean conf,
-                boolean have_acceptor_subkey) throws GSSException {
+         public MessageTokenHeader(int tokenId, boolean conf) throws GSSException {
 
             this.tokenId = tokenId;
 
--- a/jdk/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java	Wed Oct 26 17:59:13 2011 -0700
@@ -144,15 +144,18 @@
 
     /**
      * Retrieves an array of secret keys for the client. This is used when
-     * the client supplies password but need keys to act as an acceptor
-     * (in JAAS words, isInitiator=true and storeKey=true)
+     * the client supplies password but need keys to act as an acceptor. For
+     * an initiator, it must be called after AS-REQ is performed (state is OK).
+     * For an acceptor, it can be called when this KrbAsReqBuilder object is
+     * constructed (state is INIT).
+     * @param isInitiator if the caller is an initiator
      * @return generated keys from password. PA-DATA from server might be used.
      * All "default_tkt_enctypes" keys will be generated, Never null.
      * @throws IllegalStateException if not constructed from a password
      * @throws KrbException
      */
-    public EncryptionKey[] getKeys() throws KrbException {
-        checkState(State.REQ_OK, "Cannot get keys");
+    public EncryptionKey[] getKeys(boolean isInitiator) throws KrbException {
+        checkState(isInitiator?State.REQ_OK:State.INIT, "Cannot get keys");
         if (password != null) {
             int[] eTypes = EType.getDefaults("default_tkt_enctypes");
             EncryptionKey[] result = new EncryptionKey[eTypes.length];
--- a/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1335,10 +1335,10 @@
                             return null;
                         }
 
-                        Class c = Class.forName
-                                (defaultHandler,
-                                true,
-                                Thread.currentThread().getContextClassLoader());
+                        Class<?> c = Class.forName
+                                   (defaultHandler,
+                                   true,
+                                   Thread.currentThread().getContextClassLoader());
                         return (CallbackHandler)c.newInstance();
                     }
                 });
--- a/jdk/src/share/classes/sun/security/validator/PKIXValidator.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/validator/PKIXValidator.java	Wed Oct 26 17:59:13 2011 -0700
@@ -327,6 +327,7 @@
      * Set the check date (for debugging).
      */
     private void setDate(PKIXBuilderParameters params) {
+        @SuppressWarnings("deprecation")
         Date date = validationDate;
         if (date != null) {
             params.setDate(date);
--- a/jdk/src/share/classes/sun/security/validator/SimpleValidator.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/validator/SimpleValidator.java	Wed Oct 26 17:59:13 2011 -0700
@@ -131,6 +131,7 @@
         // make sure chain includes a trusted cert
         chain = buildTrustedChain(chain);
 
+        @SuppressWarnings("deprecation")
         Date date = validationDate;
         if (date == null) {
             date = new Date();
--- a/jdk/src/share/classes/sun/security/x509/AVA.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/x509/AVA.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1071,8 +1071,17 @@
                  * to need quoting, or at least escaping.  So do leading or
                  * trailing spaces, and multiple internal spaces.
                  */
-                for (int i = 0; i < valStr.length(); i++) {
+                int length = valStr.length();
+                boolean alreadyQuoted =
+                    (length > 1 && valStr.charAt(0) == '\"'
+                     && valStr.charAt(length - 1) == '\"');
+
+                for (int i = 0; i < length; i++) {
                     char c = valStr.charAt(i);
+                    if (alreadyQuoted && (i == 0 || i == length - 1)) {
+                        sbuffer.append(c);
+                        continue;
+                    }
                     if (DerValue.isPrintableStringChar(c) ||
                         escapees.indexOf(c) >= 0) {
 
@@ -1136,7 +1145,8 @@
                 }
 
                 // Emit the string ... quote it if needed
-                if (quoteNeeded) {
+                // if string is already quoted, don't re-quote
+                if (!alreadyQuoted && quoteNeeded) {
                     retval.append("\"" + sbuffer.toString() + "\"");
                 } else {
                     retval.append(sbuffer.toString());
--- a/jdk/src/share/classes/sun/security/x509/X509CertImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/security/x509/X509CertImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1323,7 +1323,7 @@
 
                 for (Extension ex : exts.getAllExtensions()) {
                     ObjectIdentifier inCertOID = ex.getExtensionId();
-                    if (inCertOID.equals(findOID)) {
+                    if (inCertOID.equals((Object)findOID)) {
                         certExt = ex;
                         break;
                     }
--- a/jdk/src/share/classes/sun/swing/FilePane.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/swing/FilePane.java	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,7 @@
 import java.util.List;
 import java.util.concurrent.Callable;
 
+import javax.accessibility.AccessibleContext;
 import javax.swing.*;
 import javax.swing.border.*;
 import javax.swing.event.*;
@@ -82,6 +83,9 @@
     private JPanel currentViewPanel;
     private String[] viewTypeActionNames;
 
+    private String filesListAccessibleName = null;
+    private String filesDetailsAccessibleName = null;
+
     private JPopupMenu contextMenu;
     private JMenu viewMenu;
 
@@ -450,6 +454,9 @@
         gigaByteString = UIManager.getString("FileChooser.fileSizeGigaBytes", l);
         fullRowSelection = UIManager.getBoolean("FileView.fullRowSelection");
 
+        filesListAccessibleName = UIManager.getString("FileChooser.filesListAccessibleName", l);
+        filesDetailsAccessibleName = UIManager.getString("FileChooser.filesDetailsAccessibleName", l);
+
         renameErrorTitleText = UIManager.getString("FileChooser.renameErrorTitleText", l);
         renameErrorText = UIManager.getString("FileChooser.renameErrorText", l);
         renameErrorFileExistsText = UIManager.getString("FileChooser.renameErrorFileExistsText", l);
@@ -634,6 +641,9 @@
         if (listViewBorder != null) {
             scrollpane.setBorder(listViewBorder);
         }
+
+        list.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, filesListAccessibleName);
+
         p.add(scrollpane, BorderLayout.CENTER);
         return p;
     }
@@ -1228,6 +1238,8 @@
 
         detailsTableModel.fireTableStructureChanged();
 
+        detailsTable.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, filesDetailsAccessibleName);
+
         return p;
     } // createDetailsView
 
--- a/jdk/src/share/classes/sun/tools/jar/JarImageSource.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package sun.tools.jar;
-
-import sun.awt.image.URLImageSource;
-import sun.awt.image.ImageDecoder;
-import java.net.URL;
-import java.net.JarURLConnection;
-import java.util.jar.JarFile;
-import java.util.jar.JarEntry;
-import java.io.InputStream;
-import java.io.IOException;
-
-
-public class JarImageSource extends URLImageSource {
-    String mimeType;
-    String entryName = null;
-    URL url;
-
-    /**
-     * Create an image source from a Jar entry URL with the specified
-     * mime type.
-     */
-    public JarImageSource(URL u, String type) {
-        super(u);
-        url = u;
-        mimeType = type;
-    }
-
-    /**
-     * Create an image source from a Jar file/entry URL
-     * with the specified entry name and mime type.
-     */
-    public JarImageSource(URL u, String name, String type) {
-        this(u, type);
-        this.entryName = name;
-    }
-
-    protected ImageDecoder getDecoder() {
-        InputStream is = null;
-        try {
-            JarURLConnection c = (JarURLConnection)url.openConnection();
-            JarFile f = c.getJarFile();
-            JarEntry e = c.getJarEntry();
-
-            if (entryName != null && e == null) {
-                e = f.getJarEntry(entryName);
-            }
-            if (e == null || (e != null && entryName != null
-                              && (!(entryName.equals(e.getName()))))) {
-                return null;
-            }
-            is = f.getInputStream(e);
-        } catch (IOException e) {
-            return null;
-        }
-
-        ImageDecoder id = decoderForType(is, mimeType);
-        if (id == null) {
-            id = getDecoder(is);
-        }
-        return id;
-    }
-}
--- a/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java	Wed Oct 26 17:59:13 2011 -0700
@@ -40,6 +40,7 @@
 import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.spi.LocaleServiceProvider;
 
 import sun.util.logging.PlatformLogger;
@@ -57,8 +58,8 @@
      * A Map that holds singleton instances of this class.  Each instance holds a
      * set of provider implementations of a particular locale sensitive service.
      */
-    private static Map<Class, LocaleServiceProviderPool> poolOfPools =
-        new ConcurrentHashMap<Class, LocaleServiceProviderPool>();
+    private static ConcurrentMap<Class, LocaleServiceProviderPool> poolOfPools =
+        new ConcurrentHashMap<>();
 
     /**
      * A Set containing locale service providers that implement the
@@ -109,7 +110,7 @@
         if (pool == null) {
             LocaleServiceProviderPool newPool =
                 new LocaleServiceProviderPool(providerClass);
-            pool = poolOfPools.put(providerClass, newPool);
+            pool = poolOfPools.putIfAbsent(providerClass, newPool);
             if (pool == null) {
                 pool = newPool;
             }
@@ -257,10 +258,11 @@
             synchronized (LocaleServiceProviderPool.class) {
                 if (availableJRELocales == null) {
                     Locale[] allLocales = LocaleData.getAvailableLocales();
-                    availableJRELocales = new ArrayList<Locale>(allLocales.length);
+                    List<Locale> tmpList = new ArrayList<>(allLocales.length);
                     for (Locale locale : allLocales) {
-                        availableJRELocales.add(getLookupLocale(locale));
+                        tmpList.add(getLookupLocale(locale));
                     }
+                    availableJRELocales = tmpList;
                 }
             }
         }
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"Pacific Standard Time", "PST",
                                      "Pacific Daylight Time", "PDT"};
-        String RST[] = new String[] {"Eastern Standard Time", "EST",
-                                     "Central Daylight Time", "CDT"};
         String SAST[] = new String[] {"South Africa Standard Time", "SAST",
                                       "South Africa Summer Time", "SAST"};
         String SBT[] = new String[] {"Solomon Is. Time", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"Bolivia Time", "BOT",
                                              "Bolivia Summer Time", "BOST"}},
             {"America/Lima", new String[] {"Peru Time", "PET",
                                            "Peru Summer Time", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"Pazifische Normalzeit", "PST",
                                      "Pazifische Sommerzeit", "PDT"};
-        String RST[] = new String[] {"\u00d6stliche Normalzeit", "EST",
-                                     "Zentrale Sommerzeit", "CDT"};
         String SAST[] = new String[] {"S\u00fcdafrikanische Normalzeit", "SAST",
                                       "S\u00fcdafrikanische Sommerzeit", "SAST"};
         String SBT[] = new String[] {"Salomoninseln Zeit", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"Bolivianische Zeit", "BOT",
                                              "Bolivianische Sommerzeit", "BOST"}},
             {"America/Lima", new String[] {"Peruanische Zeit", "PET",
                                            "Peruanische Sommerzeit", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"Hora est\u00e1ndar del Pac\u00edfico", "PST",
                                      "Hora de verano del Pac\u00edfico", "PDT"};
-        String RST[] = new String[] {"Hora est\u00e1ndar Oriental", "EST",
-                                     "Hora de verano Central", "CDT"};
         String SAST[] = new String[] {"Hora est\u00e1ndar de Sud\u00e1frica", "SAST",
                                       "Hora de verano de Sud\u00e1frica", "SAST"};
         String SBT[] = new String[] {"Hora de las Islas Solomon", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"Hora de Bolivia", "BOT",
                                              "Hora de verano de Bolivia", "BOST"}},
             {"America/Lima", new String[] {"Hora de Per\u00fa", "PET",
                                            "Hora de verano de Per\u00fa", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"Heure normale du Pacifique", "PST",
                                      "Heure avanc\u00e9e du Pacifique", "PDT"} ;
-        String RST[] = new String[] {"Heure normale de l'Est", "EST",
-                                     "Heure avanc\u00e9e du Centre", "CDT"} ;
         String SAST[] = new String[] {"Heure normale d'Afrique du Sud", "SAST",
                                       "Heure d'\u00e9t\u00e9 d'Afrique du Sud", "SAST"} ;
         String SBT[] = new String[] {"Heure des \u00celes Salomon", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"Heure de Bolivie", "BOT",
                                              "Heure d'\u00e9t\u00e9 de Bolivie", "BOST"}},
             {"America/Lima", new String[] {"Heure du P\u00e9rou", "PET",
                                            "Heure d'\u00e9t\u00e9 du P\u00e9rou", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"Ora solare della costa occidentale USA", "PST",
                                      "Ora legale della costa occidentale USA", "PDT"};
-        String RST[] = new String[] {"Ora solare USA orientale", "EST",
-                                     "Ora legale USA centrale", "CDT"};
         String SAST[] = new String[] {"Ora solare del Sudafrica", "SAST",
                                       "Ora estiva del Sudafrica", "SAST"};
         String SBT[] = new String[] {"Ora delle Isole Salomone", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"Ora della Bolivia", "BOT",
                                              "Ora estiva della Bolivia", "BOST"}},
             {"America/Lima", new String[] {"Ora del Per\u00f9", "PET",
                                            "Ora estiva del Per\u00f9", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"\u592a\u5e73\u6d0b\u6a19\u6e96\u6642", "PST",
                                      "\u592a\u5e73\u6d0b\u590f\u6642\u9593", "PDT"};
-        String RST[] = new String[] {"\u6771\u90e8\u6a19\u6e96\u6642", "EST",
-                                     "\u4e2d\u90e8\u590f\u6642\u9593", "CDT"};
         String SAST[] = new String[] {"\u5357\u30a2\u30d5\u30ea\u30ab\u6a19\u6e96\u6642", "SAST",
                                       "\u5357\u30a2\u30d5\u30ea\u30ab\u590f\u6642\u9593", "SAST"};
         String SBT[] = new String[] {"\u30bd\u30ed\u30e2\u30f3\u8af8\u5cf6\u6642\u9593", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"\u30dc\u30ea\u30d3\u30a2\u6642\u9593", "BOT",
                                              "\u30dc\u30ea\u30d3\u30a2\u590f\u6642\u9593", "BOST"}},
             {"America/Lima", new String[] {"\u30da\u30eb\u30fc\u6642\u9593", "PET",
                                            "\u30da\u30eb\u30fc\u590f\u6642\u9593", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"\ud0dc\ud3c9\uc591 \ud45c\uc900\uc2dc", "PST",
                                      "\ud0dc\ud3c9\uc591 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "PDT"};
-        String RST[] = new String[] {"\ub3d9\ubd80 \ud45c\uc900\uc2dc", "EST",
-                                     "\uc911\ubd80 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "CDT"};
         String SAST[] = new String[] {"\ub0a8\uc544\ud504\ub9ac\uce74 \ud45c\uc900\uc2dc", "SAST",
                                       "\ub0a8\uc544\ud504\ub9ac\uce74 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "SAST"};
         String SBT[] = new String[] {"\uc194\ub85c\ubaac \uad70\ub3c4 \uc2dc\uac04", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"\ubcfc\ub9ac\ube44\uc544 \uc2dc\uac04", "BOT",
                                             "\ubcfc\ub9ac\ube44\uc544 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "BOST"}},
             {"America/Lima", new String[] {"\ud398\ub8e8 \uc2dc\uac04", "PET",
                                             "\ud398\ub8e8 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java	Wed Oct 26 17:59:13 2011 -0700
@@ -157,8 +157,6 @@
                                       "Fuso hor\u00e1rio de ver\u00e3o de Pohnpei", "PONST"};
         String PST[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o do Pac\u00edfico", "PST",
                                      "Hor\u00e1rio de luz natural do Pac\u00edfico", "PDT"};
-        String RST[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o oriental", "EST",
-                                     "Hor\u00e1rio de luz natural central", "CDT"};
         String SAST[] = new String[] {"Fuso hor\u00e1rio padr\u00e3o da \u00c1frica do Sul", "SAST",
                                       "Fuso hor\u00e1rio de ver\u00e3o da \u00c1frica do Sul", "SAST"};
         String SBT[] = new String[] {"Fuso hor\u00e1rio das Ilhas Salom\u00e3o", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"Fuso hor\u00e1rio da Bol\u00edvia", "BOT",
                                              "Fuso hor\u00e1rio de ver\u00e3o da Bol\u00edvia", "BOST"}},
             {"America/Lima", new String[] {"Fuso hor\u00e1rio do Peru", "PET",
                                            "Fuso hor\u00e1rio de ver\u00e3o do Peru", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"Stilla havet, normaltid", "PST",
                                      "Stilla havet, sommartid", "PDT"};
-        String RST[] = new String[] {"Eastern, normaltid", "EST",
-                                     "Central sommartid", "CDT"};
         String SAST[] = new String[] {"Sydafrika, normaltid", "SAST",
                                       "Sydafrika, sommartid", "SAST"};
         String SBT[] = new String[] {"Salomon\u00f6arna, normaltid", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"Bolivia, normaltid", "BOT",
                                              "Bolivia, sommartid", "BOST"}},
             {"America/Lima", new String[] {"Peru, normaltid", "PET",
                                            "Peru, sommartid", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4", "PST",
                                      "\u592a\u5e73\u6d0b\u590f\u4ee4\u65f6", "PDT"};
-        String RST[] = new String[] {"\u4e1c\u90e8\u6807\u51c6\u65f6\u95f4", "EST",
-                                     "\u4e2d\u592e\u590f\u4ee4\u65f6", "CDT"};
         String SAST[] = new String[] {"\u5357\u975e\u6807\u51c6\u65f6\u95f4", "SAST",
                                       "\u5357\u975e\u590f\u4ee4\u65f6", "SAST"};
         String SBT[] = new String[] {"\u6240\u7f57\u95e8\u7fa4\u5c9b\u65f6\u95f4", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"\u73bb\u5229\u7ef4\u4e9a\u65f6\u95f4", "BOT",
                                              "\u73bb\u5229\u7ef4\u4e9a\u590f\u4ee4\u65f6", "BOST"}},
             {"America/Lima", new String[] {"\u79d8\u9c81\u65f6\u95f4", "PET",
                                            "\u79d8\u9c81\u590f\u4ee4\u65f6", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -673,7 +674,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java	Wed Oct 26 17:59:13 2011 -0700
@@ -159,8 +159,6 @@
                                       "Pohnpei Summer Time", "PONST"};
         String PST[] = new String[] {"\u592a\u5e73\u6d0b\u6a19\u6e96\u6642\u9593", "PST",
                                      "\u592a\u5e73\u6d0b\u65e5\u5149\u7bc0\u7d04\u6642\u9593", "PDT"};
-        String RST[] = new String[] {"\u6771\u65b9\u6a19\u6e96\u6642\u9593", "EST",
-                                     "\u4e2d\u592e\u65e5\u5149\u7bc0\u7d04\u6642\u9593", "CDT"};
         String SAST[] = new String[] {"\u5357\u975e\u6a19\u6e96\u6642\u9593", "SAST",
                                       "\u5357\u975e\u590f\u4ee4\u6642\u9593", "SAST"};
         String SBT[] = new String[] {"\u6240\u7f85\u9580\u7fa4\u5cf6\u6642\u9593", "SBT",
@@ -262,6 +260,7 @@
             {"Africa/Gaborone", CAT},
             {"Africa/Harare", CAT},
             {"Africa/Johannesburg", SAST},
+            {"Africa/Juba", EAT},
             {"Africa/Kampala", EAT},
             {"Africa/Khartoum", EAT},
             {"Africa/Kigali", CAT},
@@ -378,11 +377,13 @@
             {"America/Kentucky/Louisville", EST},
             {"America/Kentucky/Monticello", EST},
             {"America/Knox_IN", CST},
+            {"America/Kralendijk", AST},
             {"America/La_Paz", new String[] {"\u73bb\u5229\u7dad\u4e9e\u6642\u9593", "BOT",
                                              "\u73bb\u5229\u7dad\u4e9e\u590f\u4ee4\u6642\u9593", "BOST"}},
             {"America/Lima", new String[] {"\u7955\u9b6f\u6642\u9593", "PET",
                                            "\u7955\u9b6f\u590f\u4ee4\u6642\u9593", "PEST"}},
             {"America/Louisville", EST},
+            {"America/Lower_Princes", AST},
             {"America/Maceio", BRT},
             {"America/Managua", CST},
             {"America/Manaus", AMT},
@@ -425,7 +426,7 @@
             {"America/Rankin_Inlet", CST},
             {"America/Recife", BRT},
             {"America/Regina", CST},
-            {"America/Resolute", RST},
+            {"America/Resolute", CST},
             {"America/Rio_Branco", AMT},
             {"America/Rosario", AGT},
             {"America/Santa_Isabel", PST},
@@ -674,7 +675,8 @@
             {"Europe/Isle_of_Man", GMTBST},
             {"Europe/Istanbul", EET},
             {"Europe/Jersey", GMTBST},
-            {"Europe/Kaliningrad", EET},
+            {"Europe/Kaliningrad", new String[] {"Kaliningrad Time", "KALT",
+                                                 "Kaliningrad Summer Time", "KALST"}},
             {"Europe/Kiev", EET},
             {"Europe/Lisbon", WET},
             {"Europe/Ljubljana", CET},
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/util/xml/XMLUtils.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.util.xml;
+
+import java.io.*;
+import java.util.*;
+import org.xml.sax.*;
+import org.xml.sax.helpers.*;
+import org.w3c.dom.*;
+import javax.xml.parsers.*;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.*;
+import javax.xml.transform.stream.*;
+
+/**
+ * A class used to aid in Properties load and save in XML. Keeping this
+ * code outside of Properties helps reduce the number of classes loaded
+ * when Properties is loaded.
+ *
+ * @author  Michael McCloskey
+ * @since   1.3
+ */
+public class XMLUtils {
+
+    // XML loading and saving methods for Properties
+
+    // The required DTD URI for exported properties
+    private static final String PROPS_DTD_URI =
+    "http://java.sun.com/dtd/properties.dtd";
+
+    private static final String PROPS_DTD =
+    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+    "<!-- DTD for properties -->"                +
+    "<!ELEMENT properties ( comment?, entry* ) >"+
+    "<!ATTLIST properties"                       +
+        " version CDATA #FIXED \"1.0\">"         +
+    "<!ELEMENT comment (#PCDATA) >"              +
+    "<!ELEMENT entry (#PCDATA) >"                +
+    "<!ATTLIST entry "                           +
+        " key CDATA #REQUIRED>";
+
+    /**
+     * Version number for the format of exported properties files.
+     */
+    private static final String EXTERNAL_XML_VERSION = "1.0";
+
+    public static void load(Properties props, InputStream in)
+        throws IOException, InvalidPropertiesFormatException
+    {
+        Document doc = null;
+        try {
+            doc = getLoadingDoc(in);
+        } catch (SAXException saxe) {
+            throw new InvalidPropertiesFormatException(saxe);
+        }
+        Element propertiesElement = (Element)doc.getChildNodes().item(1);
+        String xmlVersion = propertiesElement.getAttribute("version");
+        if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0)
+            throw new InvalidPropertiesFormatException(
+                "Exported Properties file format version " + xmlVersion +
+                " is not supported. This java installation can read" +
+                " versions " + EXTERNAL_XML_VERSION + " or older. You" +
+                " may need to install a newer version of JDK.");
+        importProperties(props, propertiesElement);
+    }
+
+    static Document getLoadingDoc(InputStream in)
+        throws SAXException, IOException
+    {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setIgnoringElementContentWhitespace(true);
+        dbf.setValidating(true);
+        dbf.setCoalescing(true);
+        dbf.setIgnoringComments(true);
+        try {
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            db.setEntityResolver(new Resolver());
+            db.setErrorHandler(new EH());
+            InputSource is = new InputSource(in);
+            return db.parse(is);
+        } catch (ParserConfigurationException x) {
+            throw new Error(x);
+        }
+    }
+
+    static void importProperties(Properties props, Element propertiesElement) {
+        NodeList entries = propertiesElement.getChildNodes();
+        int numEntries = entries.getLength();
+        int start = numEntries > 0 &&
+            entries.item(0).getNodeName().equals("comment") ? 1 : 0;
+        for (int i=start; i<numEntries; i++) {
+            Element entry = (Element)entries.item(i);
+            if (entry.hasAttribute("key")) {
+                Node n = entry.getFirstChild();
+                String val = (n == null) ? "" : n.getNodeValue();
+                props.setProperty(entry.getAttribute("key"), val);
+            }
+        }
+    }
+
+    public static void save(Properties props, OutputStream os, String comment,
+                     String encoding)
+        throws IOException
+    {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        DocumentBuilder db = null;
+        try {
+            db = dbf.newDocumentBuilder();
+        } catch (ParserConfigurationException pce) {
+            assert(false);
+        }
+        Document doc = db.newDocument();
+        Element properties =  (Element)
+            doc.appendChild(doc.createElement("properties"));
+
+        if (comment != null) {
+            Element comments = (Element)properties.appendChild(
+                doc.createElement("comment"));
+            comments.appendChild(doc.createTextNode(comment));
+        }
+
+        synchronized (props) {
+            for (String key : props.stringPropertyNames()) {
+                Element entry = (Element)properties.appendChild(
+                    doc.createElement("entry"));
+                entry.setAttribute("key", key);
+                entry.appendChild(doc.createTextNode(props.getProperty(key)));
+            }
+        }
+        emitDocument(doc, os, encoding);
+    }
+
+    static void emitDocument(Document doc, OutputStream os, String encoding)
+        throws IOException
+    {
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer t = null;
+        try {
+            t = tf.newTransformer();
+            t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, PROPS_DTD_URI);
+            t.setOutputProperty(OutputKeys.INDENT, "yes");
+            t.setOutputProperty(OutputKeys.METHOD, "xml");
+            t.setOutputProperty(OutputKeys.ENCODING, encoding);
+        } catch (TransformerConfigurationException tce) {
+            assert(false);
+        }
+        DOMSource doms = new DOMSource(doc);
+        StreamResult sr = new StreamResult(os);
+        try {
+            t.transform(doms, sr);
+        } catch (TransformerException te) {
+            IOException ioe = new IOException();
+            ioe.initCause(te);
+            throw ioe;
+        }
+    }
+
+    private static class Resolver implements EntityResolver {
+        public InputSource resolveEntity(String pid, String sid)
+            throws SAXException
+        {
+            if (sid.equals(PROPS_DTD_URI)) {
+                InputSource is;
+                is = new InputSource(new StringReader(PROPS_DTD));
+                is.setSystemId(PROPS_DTD_URI);
+                return is;
+            }
+            throw new SAXException("Invalid system identifier: " + sid);
+        }
+    }
+
+    private static class EH implements ErrorHandler {
+        public void error(SAXParseException x) throws SAXException {
+            throw x;
+        }
+        public void fatalError(SAXParseException x) throws SAXException {
+            throw x;
+        }
+        public void warning(SAXParseException x) throws SAXException {
+            throw x;
+        }
+    }
+
+}
--- a/jdk/src/solaris/bin/java_md.c	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/solaris/bin/java_md.c	Wed Oct 26 17:59:13 2011 -0700
@@ -820,7 +820,6 @@
 jboolean
 LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
 {
-    Dl_info dlinfo;
     void *libjvm;
 
     JLI_TraceLauncher("JVM path is %s\n", jvmpath);
--- a/jdk/src/solaris/classes/java/net/DefaultDatagramSocketImplFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/solaris/classes/java/net/DefaultDatagramSocketImplFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007,2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
  */
 
 class DefaultDatagramSocketImplFactory {
-    static Class prefixImplClass = null;
+    static Class<?> prefixImplClass = null;
 
     static {
         String prefix = null;
--- a/jdk/src/solaris/classes/java/net/PlainDatagramSocketImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/solaris/classes/java/net/PlainDatagramSocketImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007,2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,8 +54,10 @@
 
     protected native int getTimeToLive() throws IOException;
 
+    @Deprecated
     protected native void setTTL(byte ttl) throws IOException;
 
+    @Deprecated
     protected native byte getTTL() throws IOException;
 
     protected native void join(InetAddress inetaddr, NetworkInterface netIf)
--- a/jdk/src/solaris/classes/sun/net/dns/ResolverConfigurationImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/solaris/classes/sun/net/dns/ResolverConfigurationImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -149,7 +149,7 @@
         sl = java.security.AccessController.doPrivileged(
                  new java.security.PrivilegedAction<LinkedList<String>>() {
                     public LinkedList<String> run() {
-                        LinkedList ll;
+                        LinkedList<String> ll;
 
                         // first try search keyword (max 6 domains)
                         ll = resolvconf("search", 6, 1);
@@ -173,7 +173,7 @@
 
         String localDomain = localDomain0();
         if (localDomain != null && localDomain.length() > 0) {
-            sl = new LinkedList();
+            sl = new LinkedList<String>();
             sl.add(localDomain);
             return sl;
         }
@@ -198,7 +198,7 @@
         }
 
         // no local domain so try fallback (RPC) domain or
-        // hostname
+        // hostName
 
         sl = new LinkedList<>();
         String domain = fallbackDomain0();
@@ -216,22 +216,26 @@
         opts = new OptionsImpl();
     }
 
+    @SuppressWarnings("unchecked")
     public List<String> searchlist() {
         synchronized (lock) {
             loadConfig();
 
             // List is mutable so return a shallow copy
-            return (List)searchlist.clone();
+            return (List<String>)searchlist.clone();
         }
     }
 
+    @SuppressWarnings("unchecked")
     public List<String> nameservers() {
         synchronized (lock) {
             loadConfig();
 
             // List is mutable so return a shallow copy
-            return (List)nameservers.clone();
-         }
+
+          return (List<String>)nameservers.clone();
+
+        }
     }
 
     public Options options() {
--- a/jdk/src/solaris/native/java/net/NetworkInterface.c	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/solaris/native/java/net/NetworkInterface.c	Wed Oct 26 17:59:13 2011 -0700
@@ -139,8 +139,12 @@
 #ifdef __solaris__
 static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family);
 static int    getMacFromDevice(JNIEnv *env, const char* ifname, unsigned char* retbuf);
+
+#ifndef SIOCGLIFHWADDR
+#define SIOCGLIFHWADDR  _IOWR('i', 192, struct lifreq)
 #endif
 
+#endif
 
 /******************* Java entry points *****************************/
 
@@ -1567,6 +1571,20 @@
     struct sockaddr_in* sin;
     struct sockaddr_in ipAddr;
     int len, i;
+    struct lifreq lif;
+
+    /* First, try the new (S11) SIOCGLIFHWADDR ioctl(). If that fails
+     * try the old way.
+     */
+    memset(&lif, 0, sizeof(lif));
+    strlcpy(lif.lifr_name, ifname, sizeof(lif.lifr_name));
+
+    if (ioctl(sock, SIOCGLIFHWADDR, &lif) != -1) {
+        struct sockaddr_dl *sp;
+        sp = (struct sockaddr_dl *)&lif.lifr_addr;
+        memcpy(buf, &sp->sdl_data[0], sp->sdl_alen);
+        return sp->sdl_alen;
+    }
 
    /**
     * On Solaris we have to use DLPI, but it will only work if we have
@@ -1576,34 +1594,29 @@
     if ((len = getMacFromDevice(env, ifname, buf))  == 0) {
         /*DLPI failed - trying to do arp lookup*/
 
-       if (addr == NULL) {
-          /**
-           * No IPv4 address for that interface, so can't do an ARP lookup.
-           */
-           return -1;
-      }
+        if (addr == NULL) {
+            /**
+             * No IPv4 address for that interface, so can't do an ARP lookup.
+             */
+             return -1;
+         }
 
-      len = 6; //???
+         len = 6; //???
 
-      sin = (struct sockaddr_in *) &arpreq.arp_pa;
-      memset((char *) &arpreq, 0, sizeof(struct arpreq));
-      ipAddr.sin_port = 0;
-      ipAddr.sin_family = AF_INET;
-      memcpy(&ipAddr.sin_addr, addr, sizeof(struct in_addr));
-      memcpy(&arpreq.arp_pa, &ipAddr, sizeof(struct sockaddr_in));
-      arpreq.arp_flags= ATF_PUBL;
+         sin = (struct sockaddr_in *) &arpreq.arp_pa;
+         memset((char *) &arpreq, 0, sizeof(struct arpreq));
+         ipAddr.sin_port = 0;
+         ipAddr.sin_family = AF_INET;
+         memcpy(&ipAddr.sin_addr, addr, sizeof(struct in_addr));
+         memcpy(&arpreq.arp_pa, &ipAddr, sizeof(struct sockaddr_in));
+         arpreq.arp_flags= ATF_PUBL;
 
-      if (ioctl(sock, SIOCGARP, &arpreq) < 0) {
-          if (errno != ENXIO) {
-              // "No such device or address" means no hardware address, so it's
-              // normal don't throw an exception
-              NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "IOCTL failed");
-              return -1;
-          }
-     }
+         if (ioctl(sock, SIOCGARP, &arpreq) < 0) {
+             return -1;
+         }
 
-     memcpy(buf, &arpreq.arp_ha.sa_data[0], len );
-  }
+         memcpy(buf, &arpreq.arp_ha.sa_data[0], len );
+    }
 
     /*
      * All bytes to 0 means no hardware address.
--- a/jdk/src/solaris/native/java/util/TimeZone_md.c	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/solaris/native/java/util/TimeZone_md.c	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,13 +30,13 @@
 #include <limits.h>
 #include <errno.h>
 #include <stddef.h>
-
-#ifdef __linux__
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <string.h>
 #include <dirent.h>
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <unistd.h>
+#ifdef __solaris__
+#include <libscf.h>
 #endif
 
 #include "jvm.h"
@@ -54,17 +54,22 @@
 static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
 static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
 static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
+#else
+static const char *SYS_INIT_FILE = "/etc/default/init";
+static const char *ZONEINFO_DIR = "/usr/share/lib/zoneinfo";
+static const char *DEFAULT_ZONEINFO_FILE = "/usr/share/lib/zoneinfo/localtime";
+#endif /*__linux__*/
 
 /*
- * Returns a point to the zone ID portion of the given zoneinfo file
- * name.
+ * Returns a pointer to the zone ID portion of the given zoneinfo file
+ * name, or NULL if the given string doesn't contain "zoneinfo/".
  */
 static char *
 getZoneName(char *str)
 {
     static const char *zidir = "zoneinfo/";
 
-    char * pos = strstr((const char *)str, zidir);
+    char *pos = strstr((const char *)str, zidir);
     if (pos == NULL) {
         return NULL;
     }
@@ -74,7 +79,7 @@
 /*
  * Returns a path name created from the given 'dir' and 'name' under
  * UNIX. This function allocates memory for the pathname calling
- * malloc().
+ * malloc(). NULL is returned if malloc() fails.
  */
 static char *
 getPathName(const char *dir, const char *name) {
@@ -89,19 +94,18 @@
 
 /*
  * Scans the specified directory and its subdirectories to find a
- * zoneinfo file which has the same content as /etc/localtime given in
- * 'buf'. Returns a zone ID if found, otherwise, NULL is returned.
+ * zoneinfo file which has the same content as /etc/localtime on Linux
+ * or /usr/share/lib/zoneinfo/localtime (most likely a symbolic link)
+ * on Solaris given in 'buf'. Returns a zone ID if found, otherwise,
+ * NULL is returned.
  */
 static char *
 findZoneinfoFile(char *buf, size_t size, const char *dir)
 {
     DIR *dirp = NULL;
     struct stat statbuf;
-    union {
-        struct dirent d;
-        char b[offsetof (struct dirent, d_name) + NAME_MAX + 1];
-    } entry;
-    struct dirent *dp;
+    struct dirent *dp = NULL;
+    struct dirent *entry = NULL;
     char *pathname = NULL;
     int fd = -1;
     char *dbuf = NULL;
@@ -112,7 +116,19 @@
         return NULL;
     }
 
-    while (readdir_r(dirp, &entry.d, &dp) == 0 && dp != NULL) {
+    entry = (struct dirent *) malloc((size_t) pathconf(dir, _PC_NAME_MAX));
+    if (entry == NULL) {
+        (void) closedir(dirp);
+        return NULL;
+    }
+
+#if defined(__linux__) || (defined(__solaris__) && (defined(_POSIX_PTHREAD_SEMANTICS) || \
+                                                    defined(_LP64)))
+    while (readdir_r(dirp, entry, &dp) == 0 && dp != NULL) {
+#else
+    while ((dp = readdir_r(dirp, entry)) != NULL) {
+#endif
+
         /*
          * Skip '.' and '..' (and possibly other .* files)
          */
@@ -121,11 +137,17 @@
         }
 
         /*
-         * Skip "ROC", "posixrules", and "localtime" since Java doesn't
-         * support them.
+         * Skip "ROC", "posixrules", and "localtime".
          */
         if ((strcmp(dp->d_name, "ROC") == 0)
             || (strcmp(dp->d_name, "posixrules") == 0)
+#ifdef __solaris__
+            /*
+             * Skip the "src" and "tab" directories on Solaris.
+             */
+            || (strcmp(dp->d_name, "src") == 0)
+            || (strcmp(dp->d_name, "tab") == 0)
+#endif
             || (strcmp(dp->d_name, "localtime") == 0)) {
             continue;
         }
@@ -149,7 +171,6 @@
                 break;
             }
             if ((fd = open(pathname, O_RDONLY)) == -1) {
-                fd = 0;
                 break;
             }
             if (read(fd, dbuf, size) != (ssize_t) size) {
@@ -165,19 +186,22 @@
             free((void *) dbuf);
             dbuf = NULL;
             (void) close(fd);
-            fd = 0;
+            fd = -1;
         }
         free((void *) pathname);
         pathname = NULL;
     }
 
+    if (entry != NULL) {
+        free((void *) entry);
+    }
     if (dirp != NULL) {
         (void) closedir(dirp);
     }
     if (pathname != NULL) {
         free((void *) pathname);
     }
-    if (fd != 0) {
+    if (fd != -1) {
         (void) close(fd);
     }
     if (dbuf != NULL) {
@@ -186,8 +210,10 @@
     return tz;
 }
 
+#ifdef __linux__
+
 /*
- * Performs libc implementation specific mapping and returns a zone ID
+ * Performs Linux specific mapping and returns a zone ID
  * if found. Otherwise, NULL is returned.
  */
 static char *
@@ -408,12 +434,11 @@
 }
 #endif /* not __sparcv9 */
 
-static const char *sys_init_file = "/etc/default/init";
 
 /*
- * Performs libc implementation dependent mapping. Returns a zone ID
- * if found. Otherwise, NULL is returned.  Solaris libc looks up
- * "/etc/default/init" to get a default TZ value if TZ is not defined
+ * Performs Solaris dependent mapping. Returns a zone ID if
+ * found. Otherwise, NULL is returned.  Solaris libc looks up
+ * "/etc/default/init" to get the default TZ value if TZ is not defined
  * as an environment variable.
  */
 static char *
@@ -425,7 +450,7 @@
     /*
      * Try the TZ entry in /etc/default/init.
      */
-    if ((fp = fileopen(sys_init_file, "r")) != NULL) {
+    if ((fp = fileopen(SYS_INIT_FILE, "r")) != NULL) {
         char line[256];
         char quote = '\0';
 
@@ -473,8 +498,113 @@
     return tz;
 }
 
-#endif
-#endif
+#define TIMEZONE_FMRI   "svc:/system/timezone:default"
+#define TIMEZONE_PG     "timezone"
+#define LOCALTIME_PROP  "localtime"
+
+static void
+cleanupScf(scf_handle_t *h,
+           scf_snapshot_t *snap,
+           scf_instance_t *inst,
+           scf_propertygroup_t *pg,
+           scf_property_t *prop,
+           scf_value_t *val,
+           char *buf) {
+    if (buf != NULL) {
+        free(buf);
+    }
+    if (snap != NULL) {
+        scf_snapshot_destroy(snap);
+    }
+    if (val != NULL) {
+        scf_value_destroy(val);
+    }
+    if (prop != NULL) {
+        scf_property_destroy(prop);
+    }
+    if (pg != NULL) {
+        scf_pg_destroy(pg);
+    }
+    if (inst != NULL) {
+        scf_instance_destroy(inst);
+    }
+    if (h != NULL) {
+        scf_handle_destroy(h);
+    }
+}
+
+/*
+ * Retruns a zone ID of Solaris when the TZ value is "localtime".
+ * First, it tries scf. If scf fails, it looks for the same file as
+ * /usr/share/lib/zoneinfo/localtime under /usr/share/lib/zoneinfo/.
+ */
+static char *
+getSolarisDefaultZoneID() {
+    char *tz = NULL;
+    struct stat statbuf;
+    size_t size;
+    char *buf;
+    int fd;
+    /* scf specific variables */
+    scf_handle_t *h = NULL;
+    scf_snapshot_t *snap = NULL;
+    scf_instance_t *inst = NULL;
+    scf_propertygroup_t *pg = NULL;
+    scf_property_t *prop = NULL;
+    scf_value_t *val = NULL;
+
+    if ((h = scf_handle_create(SCF_VERSION)) != NULL
+        && scf_handle_bind(h) == 0
+        && (inst = scf_instance_create(h)) != NULL
+        && (snap = scf_snapshot_create(h)) != NULL
+        && (pg = scf_pg_create(h)) != NULL
+        && (prop = scf_property_create(h)) != NULL
+        && (val = scf_value_create(h)) != NULL
+        && scf_handle_decode_fmri(h, TIMEZONE_FMRI, NULL, NULL, inst,
+                                  NULL, NULL, SCF_DECODE_FMRI_REQUIRE_INSTANCE) == 0
+        && scf_instance_get_snapshot(inst, "running", snap) == 0
+        && scf_instance_get_pg_composed(inst, snap, TIMEZONE_PG, pg) == 0
+        && scf_pg_get_property(pg, LOCALTIME_PROP, prop) == 0
+        && scf_property_get_value(prop, val) == 0) {
+        ssize_t len;
+
+        /* Gets the length of the zone ID string */
+        len = scf_value_get_astring(val, NULL, 0);
+        if (len != -1) {
+            tz = malloc(++len); /* +1 for a null byte */
+            if (tz != NULL && scf_value_get_astring(val, tz, len) != -1) {
+                cleanupScf(h, snap, inst, pg, prop, val, NULL);
+                return tz;
+            }
+        }
+    }
+    cleanupScf(h, snap, inst, pg, prop, val, tz);
+
+    if (stat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) {
+        return NULL;
+    }
+    size = (size_t) statbuf.st_size;
+    buf = malloc(size);
+    if (buf == NULL) {
+        return NULL;
+    }
+    if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) {
+        free((void *) buf);
+        return NULL;
+    }
+
+    if (read(fd, buf, size) != (ssize_t) size) {
+        (void) close(fd);
+        free((void *) buf);
+        return NULL;
+    }
+    (void) close(fd);
+    tz = findZoneinfoFile(buf, size, ZONEINFO_DIR);
+    free((void *) buf);
+    return tz;
+}
+#endif /*__solaris__*/
+#endif /*__linux__*/
 
 /*
  * findJavaTZ_md() maps platform time zone ID to Java time zone ID
@@ -504,10 +634,21 @@
         freetz = tz;
     }
 
+    /*
+     * Remove any preceding ':'
+     */
+    if (tz != NULL && *tz == ':') {
+        tz++;
+    }
+
+#ifdef __solaris__
+    if (strcmp(tz, "localtime") == 0) {
+        tz = getSolarisDefaultZoneID();
+        freetz = tz;
+    }
+#endif
+
     if (tz != NULL) {
-        if (*tz == ':') {
-            tz++;
-        }
 #ifdef __linux__
         /*
          * Ignore "posix/" prefix.
@@ -525,24 +666,36 @@
 }
 
 /**
- * Returns a GMT-offset-based time zone ID. (e.g., "GMT-08:00")
+ * Returns a GMT-offset-based zone ID. (e.g., "GMT-08:00")
  */
 char *
 getGMTOffsetID()
 {
     time_t offset;
-    char sign, buf[16];
+    char sign, buf[32];
+#ifdef __solaris__
+    struct tm localtm;
+    time_t currenttime;
 
-    if (timezone == 0) {
+    currenttime = time(NULL);
+    if (localtime_r(&currenttime, &localtm) == NULL) {
+        return NULL;
+    }
+
+    offset = localtm.tm_isdst ? altzone : timezone;
+#else
+    offset = timezone;
+#endif /*__linux__*/
+
+    if (offset == 0) {
         return strdup("GMT");
     }
 
     /* Note that the time offset direction is opposite. */
-    if (timezone > 0) {
-        offset = timezone;
+    if (offset > 0) {
         sign = '-';
     } else {
-        offset = -timezone;
+        offset = -offset;
         sign = '+';
     }
     sprintf(buf, (const char *)"GMT%c%02d:%02d",
--- a/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -334,6 +334,7 @@
     XDestroyImage(ximage);
     SplashRemoveDecoration(splash);
     XMapWindow(splash->display, splash->window);
+    XFlush(splash->display);
 }
 
 void SplashReconfigureNow(Splash * splash) {
--- a/jdk/src/windows/classes/java/net/DefaultDatagramSocketImplFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/classes/java/net/DefaultDatagramSocketImplFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 
 class DefaultDatagramSocketImplFactory
 {
-    static Class prefixImplClass = null;
+    static Class<?> prefixImplClass = null;
 
     /* the windows version. */
     private static float version;
--- a/jdk/src/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007,2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 package java.net;
 
 import java.io.IOException;
-import java.io.FileDescriptor;
 import sun.misc.SharedSecrets;
 import sun.misc.JavaIOFileDescriptorAccess;
 
@@ -215,11 +214,12 @@
         throw new IOException("Method not implemented!");
     }
 
-
+    @Deprecated
     protected void setTTL(byte ttl) throws IOException {
         throw new IOException("Method not implemented!");
     }
 
+    @Deprecated
     protected byte getTTL() throws IOException {
         throw new IOException("Method not implemented!");
     }
--- a/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -68,7 +68,12 @@
 
     protected synchronized void create() throws SocketException {
         fd1 = new FileDescriptor();
-        super.create();
+        try {
+            super.create();
+        } catch (SocketException e) {
+            fd1 = null;
+            throw e;
+        }
     }
 
     protected synchronized void bind(int lport, InetAddress laddr)
@@ -94,10 +99,11 @@
         }
 
         if (optID == SO_BINDADDR) {
-            if (fd != null && fd1 != null) {
+            if ((fd != null && fd1 != null) && !connected) {
                 return anyLocalBoundAddr;
             }
-            return socketGetOption(optID);
+            int family = connectedAddress == null ? -1 : connectedAddress.family;
+            return socketLocalAddress(family);
         } else
             return super.getOption(optID);
     }
@@ -133,8 +139,10 @@
 
     protected native int getTimeToLive() throws IOException;
 
+    @Deprecated
     protected native void setTTL(byte ttl) throws IOException;
 
+    @Deprecated
     protected native byte getTTL() throws IOException;
 
     protected native void join(InetAddress inetaddr, NetworkInterface netIf)
@@ -154,6 +162,8 @@
 
     protected native void connect0(InetAddress address, int port) throws SocketException;
 
+    protected native Object socketLocalAddress(int family) throws SocketException;
+
     protected native void disconnect0(int family);
 
     /**
--- a/jdk/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -26,6 +26,7 @@
 
 import java.io.IOException;
 import java.io.FileDescriptor;
+import sun.net.ResourceManager;
 
 /*
  * This class defines the plain SocketImpl that is used for all
@@ -81,7 +82,12 @@
      */
     protected synchronized void create(boolean stream) throws IOException {
         fd1 = new FileDescriptor();
-        super.create(stream);
+        try {
+            super.create(stream);
+        } catch (IOException e) {
+            fd1 = null;
+            throw e;
+        }
     }
 
      /**
@@ -120,6 +126,9 @@
     protected void close() throws IOException {
         synchronized(fdLock) {
             if (fd != null || fd1 != null) {
+                if (!stream) {
+                    ResourceManager.afterUdpClose();
+                }
                 if (fdUseCount == 0) {
                     if (closePending) {
                         return;
--- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Wed Oct 26 17:59:13 2011 -0700
@@ -615,6 +615,14 @@
         _dispose();
     }
 
+    public void disposeLater() {
+        postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), new Runnable() {
+            public void run() {
+                dispose();
+            }
+        }));
+    }
+
     public synchronized void setForeground(Color c) {
         foreground = c;
         _setForeground(c.getRGB());
--- a/jdk/src/windows/classes/sun/net/dns/ResolverConfigurationImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/classes/sun/net/dns/ResolverConfigurationImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -57,8 +57,8 @@
     private static String os_nameservers;
 
     // Cached lists
-    private static LinkedList searchlist;
-    private static LinkedList nameservers;
+    private static LinkedList<String> searchlist;
+    private static LinkedList<String> nameservers;
 
     // Parse string that consists of token delimited by space or commas
     // and return LinkedHashMap
@@ -111,21 +111,23 @@
         opts = new OptionsImpl();
     }
 
+    @SuppressWarnings("unchecked") // clone()
     public List<String> searchlist() {
         synchronized (lock) {
             loadConfig();
 
             // List is mutable so return a shallow copy
-            return (List)searchlist.clone();
+            return (List<String>)searchlist.clone();
         }
     }
 
+    @SuppressWarnings("unchecked") // clone()
     public List<String> nameservers() {
         synchronized (lock) {
             loadConfig();
 
             // List is mutable so return a shallow copy
-            return (List)nameservers.clone();
+            return (List<String>)nameservers.clone();
          }
     }
 
--- a/jdk/src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -148,7 +148,7 @@
 
     private Permission getPermission(JarFile jarFile) {
         try {
-            URLConnection uc = (URLConnection)getConnection(jarFile);
+            URLConnection uc = getConnection(jarFile);
             if (uc != null)
                 return uc.getPermission();
         } catch (IOException ioe) {
--- a/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c	Wed Oct 26 17:59:13 2011 -0700
@@ -2181,30 +2181,6 @@
         return getMulticastInterface(env, this, fd, fd1, opt);
     }
 
-    if (opt == java_net_SocketOptions_SO_BINDADDR) {
-        /* find out local IP address */
-        SOCKETADDRESS him;
-        int len = 0;
-        int port;
-        jobject iaObj;
-
-        len = sizeof (struct sockaddr_in);
-
-        if (fd == -1) {
-            fd = fd1; /* must be IPv6 only */
-            len = sizeof (struct SOCKADDR_IN6);
-        }
-
-        if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                           "Error getting socket name");
-            return NULL;
-        }
-        iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
-
-        return iaObj;
-    }
-
     /*
      * Map the Java level socket option to the platform specific
      * level and option name.
@@ -2253,6 +2229,61 @@
 }
 
 /*
+ * Returns local address of the socket.
+ *
+ * Class:     java_net_TwoStacksPlainDatagramSocketImpl
+ * Method:    socketLocalAddress
+ * Signature: (I)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL
+Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress(JNIEnv *env, jobject this,
+                                                      jint family) {
+
+    int fd=-1, fd1=-1;
+    SOCKETADDRESS him;
+    int len = 0;
+    int port;
+    jobject iaObj;
+    int ipv6_supported = ipv6_available();
+
+    fd = getFD(env, this);
+    if (ipv6_supported) {
+        fd1 = getFD1(env, this);
+    }
+
+    if (fd < 0 && fd1 < 0) {
+        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
+                        "Socket closed");
+        return NULL;
+    }
+
+    /* find out local IP address */
+
+    len = sizeof (struct sockaddr_in);
+
+    /* family==-1 when socket is not connected */
+    if ((family == IPv6) || (family == -1 && fd == -1)) {
+        fd = fd1; /* must be IPv6 only */
+        len = sizeof (struct SOCKADDR_IN6);
+    }
+
+    if (fd == -1) {
+        JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
+                        "Socket closed");
+        return NULL;
+    }
+
+    if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
+        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                       "Error getting socket name");
+        return NULL;
+    }
+    iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
+
+    return iaObj;
+}
+
+/*
  * Class:     java_net_TwoStacksPlainDatagramSocketImpl
  * Method:    setTimeToLive
  * Signature: (I)V
--- a/jdk/src/windows/native/sun/windows/awt_Component.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -183,6 +183,7 @@
 jmethodID AwtComponent::getLocationOnScreenMID;
 jmethodID AwtComponent::replaceSurfaceDataMID;
 jmethodID AwtComponent::replaceSurfaceDataLaterMID;
+jmethodID AwtComponent::disposeLaterMID;
 
 HKL    AwtComponent::m_hkl = ::GetKeyboardLayout(0);
 LANGID AwtComponent::m_idLang = LOWORD(::GetKeyboardLayout(0));
@@ -246,6 +247,7 @@
     m_hCursorCache = NULL;
 
     m_bSubclassed = FALSE;
+    m_bPauseDestroy = FALSE;
 
     m_MessagesProcessing = 0;
     m_wheelRotationAmount = 0;
@@ -319,6 +321,12 @@
         m_brushBackground = NULL;
     }
 
+    if (m_bPauseDestroy) {
+        // AwtComponent::WmNcDestroy could be released now
+        m_bPauseDestroy = FALSE;
+        m_hwnd = NULL;
+    }
+
     // The component instance is deleted using AwtObject::Dispose() method
     AwtObject::Dispose();
 }
@@ -1377,6 +1385,7 @@
       case WM_CREATE: mr = WmCreate(); break;
       case WM_CLOSE:      mr = WmClose(); break;
       case WM_DESTROY:    mr = WmDestroy(); break;
+      case WM_NCDESTROY:  mr = WmNcDestroy(); break;
 
       case WM_ERASEBKGND:
           mr = WmEraseBkgnd((HDC)wParam, *(BOOL*)&retValue); break;
@@ -1965,10 +1974,24 @@
  */
 MsgRouting AwtComponent::WmDestroy()
 {
-    // fix for 6259348: we should enter the SyncCall critical section before
-    // disposing the native object, that is value 1 of lParam is intended for
-    if(m_peerObject != NULL) { // is not being terminating
-        AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)m_peerObject, (LPARAM)1);
+    return mrConsume;
+}
+
+/*
+ * This message should only be received when a window is destroyed by
+ * Windows, and not Java. It is sent only after child windows were destroyed.
+ */
+MsgRouting AwtComponent::WmNcDestroy()
+{
+    if (m_peerObject != NULL) { // is not being terminating
+        // Stay in this handler until AwtComponent::Dispose is called.
+        m_bPauseDestroy = TRUE;
+
+        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+        // Post invocation event for WObjectPeer.dispose to EDT
+        env->CallVoidMethod(m_peerObject, AwtComponent::disposeLaterMID);
+        // Wait until AwtComponent::Dispose is called
+        AwtToolkit::GetInstance().PumpToDestroy(this);
     }
 
     return mrConsume;
@@ -6300,6 +6323,7 @@
         env->GetMethodID(peerCls, "replaceSurfaceData", "()V");
     AwtComponent::replaceSurfaceDataLaterMID =
         env->GetMethodID(peerCls, "replaceSurfaceDataLater", "()V");
+    AwtComponent::disposeLaterMID = env->GetMethodID(peerCls, "disposeLater", "()V");
 
     DASSERT(AwtComponent::xID);
     DASSERT(AwtComponent::yID);
@@ -6318,6 +6342,8 @@
     DASSERT(AwtComponent::getLocationOnScreenMID);
     DASSERT(AwtComponent::replaceSurfaceDataMID);
     DASSERT(AwtComponent::replaceSurfaceDataLaterMID);
+    DASSERT(AwtComponent::disposeLaterMID);
+
 
     CATCH_BAD_ALLOC;
 }
--- a/jdk/src/windows/native/sun/windows/awt_Component.h	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Component.h	Wed Oct 26 17:59:13 2011 -0700
@@ -119,6 +119,7 @@
     static jmethodID getLocationOnScreenMID;
     static jmethodID replaceSurfaceDataMID;
     static jmethodID replaceSurfaceDataLaterMID;
+    static jmethodID disposeLaterMID;
 
     static const UINT WmAwtIsComponent;
     static jint * masks; //InputEvent mask array
@@ -490,6 +491,7 @@
     virtual MsgRouting WmCreate() {return mrDoDefault;}
     virtual MsgRouting WmClose() {return mrDoDefault;}
     virtual MsgRouting WmDestroy();
+    virtual MsgRouting WmNcDestroy();
 
     virtual MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite)
     {
@@ -711,6 +713,10 @@
         return m_MessagesProcessing == 0;
     }
 
+    BOOL IsDestroyPaused() const {
+        return m_bPauseDestroy;
+    }
+
 protected:
     static AwtComponent* GetComponentImpl(HWND hWnd);
 
@@ -752,6 +758,7 @@
     UINT m_mouseButtonClickAllowed;
 
     BOOL m_bSubclassed;
+    BOOL m_bPauseDestroy;
 
     COLORREF m_colorForeground;
     COLORREF m_colorBackground;
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Wed Oct 26 17:59:13 2011 -0700
@@ -733,26 +733,13 @@
           return 0;
       }
       case WM_AWT_DISPOSE: {
-          BOOL canDispose = TRUE;
-          CriticalSection &syncCS = AwtToolkit::GetInstance().GetSyncCS();
-          int shouldEnterCriticalSection = (int)lParam;
-          if (shouldEnterCriticalSection == 1) {
-              canDispose = syncCS.TryEnter();
-          }
-          if (canDispose) {
-              if(wParam != NULL) {
-                  jobject self = (jobject)wParam;
-                  AwtObject *o = (AwtObject *) JNI_GET_PDATA(self);
-                  env->DeleteGlobalRef(self);
-                  if(o != NULL && theAwtObjectList.Remove(o)) {
-                      o->Dispose();
-                  }
-                  if (shouldEnterCriticalSection) {
-                      syncCS.Leave();
-                  }
+          if(wParam != NULL) {
+              jobject self = (jobject)wParam;
+              AwtObject *o = (AwtObject *) JNI_GET_PDATA(self);
+              env->DeleteGlobalRef(self);
+              if(o != NULL && theAwtObjectList.Remove(o)) {
+                  o->Dispose();
               }
-          } else {
-              AwtToolkit::GetInstance().PostMessage(WM_AWT_DISPOSE, wParam, lParam);
           }
           return 0;
       }
@@ -1340,25 +1327,46 @@
 
     while (!m_breakMessageLoop && (*lpPeekMessageFunc)(msg)) {
         foundOne = TRUE;
-        if (msg.message == WM_QUIT) {
-            m_breakMessageLoop = TRUE;
-            m_messageLoopResult = static_cast<UINT>(msg.wParam);
-            if (m_messageLoopResult == EXIT_ALL_ENCLOSING_LOOPS)
-                ::PostQuitMessage(static_cast<int>(msg.wParam));  // make sure all loops exit
-            break;
-        }
-        else if (msg.message != WM_NULL) {
-            /*
-             * The AWT in standalone mode (that is, dynamically loaded from the
-             * Java VM) doesn't have any translation tables to worry about, so
-             * TranslateAccelerator isn't called.
-             */
-
-            ::TranslateMessage(&msg);
-            ::DispatchMessage(&msg);
+        ProcessMsg(msg);
+    }
+    return foundOne;
+}
+
+void AwtToolkit::PumpToDestroy(class AwtComponent* p)
+{
+    MSG  msg;
+
+    DASSERT(AwtToolkit::PrimaryIdleFunc != NULL);
+    DASSERT(AwtToolkit::CommonPeekMessageFunc != NULL);
+
+    while (p->IsDestroyPaused() && !m_breakMessageLoop) {
+
+        PrimaryIdleFunc();
+
+        while (p->IsDestroyPaused() && !m_breakMessageLoop && CommonPeekMessageFunc(msg)) {
+            ProcessMsg(msg);
         }
     }
-    return foundOne;
+}
+
+void AwtToolkit::ProcessMsg(MSG& msg)
+{
+    if (msg.message == WM_QUIT) {
+        m_breakMessageLoop = TRUE;
+        m_messageLoopResult = static_cast<UINT>(msg.wParam);
+        if (m_messageLoopResult == EXIT_ALL_ENCLOSING_LOOPS)
+            ::PostQuitMessage(static_cast<int>(msg.wParam));  // make sure all loops exit
+    }
+    else if (msg.message != WM_NULL) {
+        /*
+        * The AWT in standalone mode (that is, dynamically loaded from the
+        * Java VM) doesn't have any translation tables to worry about, so
+        * TranslateAccelerator isn't called.
+        */
+
+        ::TranslateMessage(&msg);
+        ::DispatchMessage(&msg);
+    }
 }
 
 VOID CALLBACK
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Wed Oct 26 17:59:13 2011 -0700
@@ -305,6 +305,8 @@
 
     UINT MessageLoop(IDLEPROC lpIdleFunc, PEEKMESSAGEPROC lpPeekMessageFunc);
     BOOL PumpWaitingMessages(PEEKMESSAGEPROC lpPeekMessageFunc);
+    void PumpToDestroy(class AwtComponent* p);
+    void ProcessMsg(MSG& msg);
     BOOL PreProcessMsg(MSG& msg);
     BOOL PreProcessMouseMsg(class AwtComponent* p, MSG& msg);
     BOOL PreProcessKeyMsg(class AwtComponent* p, MSG& msg);
--- a/jdk/test/Makefile	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/Makefile	Wed Oct 26 17:59:13 2011 -0700
@@ -342,7 +342,7 @@
 
 # Expect JT_HOME to be set for jtreg tests. (home for jtreg)
 ifndef JT_HOME
-  JT_HOME = $(SLASH_JAVA)/re/jtreg/4.0/promoted/latest/binaries/jtreg
+  JT_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg
   ifdef JPRT_JTREG_HOME
     JT_HOME = $(JPRT_JTREG_HOME)
   endif
@@ -353,19 +353,23 @@
   TESTDIRS = demo
 endif
 
-# Samevm settings (default is false)
-ifndef USE_JTREG_SAMEVM
-  USE_JTREG_SAMEVM=false
+# Agentvm settings (default is false)
+ifndef USE_JTREG_AGENTVM
+  USE_JTREG_AGENTVM=false
 endif
-# With samevm, you cannot use -javaoptions?
-ifeq ($(USE_JTREG_SAMEVM),true)
-  JTREG_SAMEVM_OPTION = -samevm
-  EXTRA_JTREG_OPTIONS += $(JTREG_SAMEVM_OPTION) $(JAVA_ARGS) $(JAVA_ARGS:%=-vmoption:%)
+# With agentvm, you cannot use -javaoptions?
+ifeq ($(USE_JTREG_AGENTVM),true)
+  JTREG_AGENTVM_OPTION = -agentvm
+  EXTRA_JTREG_OPTIONS += $(JTREG_AGENTVM_OPTION) $(JAVA_ARGS) $(JAVA_ARGS:%=-vmoption:%)
   JTREG_TEST_OPTIONS = $(JAVA_VM_ARGS:%=-vmoption:%)
 else
   JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%)
 endif
 
+ifdef CONCURRENCY
+  EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
+endif
+
 # Some tests annoy me and fail frequently
 PROBLEM_LIST=ProblemList.txt
 PROBLEM_LISTS=$(PROBLEM_LIST) $(wildcard closed/$(PROBLEM_LIST))
@@ -400,14 +404,14 @@
 define TestDirs
 $(foreach i,$1,$(wildcard ${i})) $(foreach i,$1,$(wildcard closed/${i}))
 endef
-# Running batches of tests with or without samevm
-define RunSamevmBatch
-$(ECHO) "Running tests in samevm mode: $?"
-$(MAKE) TEST_DEPENDENCIES="$?" TESTDIRS="$?" USE_JTREG_SAMEVM=true  UNIQUE_DIR=$@ jtreg_tests
+# Running batches of tests with or without agentvm
+define RunAgentvmBatch
+$(ECHO) "Running tests in agentvm mode: $?"
+$(MAKE) TEST_DEPENDENCIES="$?" TESTDIRS="$?" USE_JTREG_AGENTVM=true  UNIQUE_DIR=$@ jtreg_tests
 endef
 define RunOthervmBatch
 $(ECHO) "Running tests in othervm mode: $?"
-$(MAKE) TEST_DEPENDENCIES="$?" TESTDIRS="$?" USE_JTREG_SAMEVM=false UNIQUE_DIR=$@ jtreg_tests
+$(MAKE) TEST_DEPENDENCIES="$?" TESTDIRS="$?" USE_JTREG_AGENTVM=false UNIQUE_DIR=$@ jtreg_tests
 endef
 define SummaryInfo
 $(ECHO) "########################################################"
@@ -421,22 +425,22 @@
 JDK_ALL_TARGETS =
 
 # Stable othervm testruns (minus items from PROBLEM_LIST)
-#   Using samevm has problems, and doesn't help performance as much as others.
+#   Using agentvm has problems, and doesn't help performance as much as others.
 JDK_ALL_TARGETS += jdk_awt
 jdk_awt: $(call TestDirs, com/sun/awt java/awt sun/awt \
          javax/imageio javax/print sun/pisces)
 	$(call RunOthervmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_beans1
 jdk_beans1: $(call TestDirs, \
             java/beans/beancontext java/beans/PropertyChangeSupport \
             java/beans/Introspector java/beans/Performance \
             java/beans/VetoableChangeSupport java/beans/Statement)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # Stable othervm testruns (minus items from PROBLEM_LIST)
-#   Using samevm has serious problems with these tests
+#   Using agentvm has serious problems with these tests
 JDK_ALL_TARGETS += jdk_beans2
 jdk_beans2: $(call TestDirs, \
             java/beans/Beans java/beans/EventHandler java/beans/XMLDecoder \
@@ -444,7 +448,7 @@
 	$(call RunOthervmBatch)
 
 # Stable othervm testruns (minus items from PROBLEM_LIST)
-#   Using samevm has serious problems with these tests
+#   Using agentvm has serious problems with these tests
 JDK_ALL_TARGETS += jdk_beans3
 jdk_beans3: $(call TestDirs, java/beans/XMLEncoder)
 	$(call RunOthervmBatch)
@@ -453,24 +457,24 @@
 jdk_beans: jdk_beans1 jdk_beans2 jdk_beans3
 	@$(SummaryInfo)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_io
 jdk_io: $(call TestDirs, java/io)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_lang
 jdk_lang: $(call TestDirs, java/lang)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # Stable othervm testruns (minus items from PROBLEM_LIST)
-#   Using samevm has serious problems with these tests
+#   Using agentvm has serious problems with these tests
 JDK_ALL_TARGETS += jdk_management1
 jdk_management1: $(call TestDirs, javax/management)
 	$(call RunOthervmBatch)
 
 # Stable othervm testruns (minus items from PROBLEM_LIST)
-#   Using samevm has serious problems with these tests
+#   Using agentvm has serious problems with these tests
 JDK_ALL_TARGETS += jdk_management2
 jdk_management2: $(call TestDirs, com/sun/jmx com/sun/management sun/management)
 	$(call RunOthervmBatch)
@@ -479,114 +483,114 @@
 jdk_management: jdk_management1 jdk_management2
 	@$(SummaryInfo)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_math
 jdk_math: $(call TestDirs, java/math)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_misc
 jdk_misc: $(call TestDirs, \
           demo/jvmti demo/zipfs javax/naming javax/script \
           javax/smartcardio com/sun/jndi com/sun/xml sun/misc)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_net
 jdk_net: $(call TestDirs, com/sun/net java/net sun/net)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_nio1
 jdk_nio1: $(call TestDirs, java/nio/file)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_nio2
 jdk_nio2: $(call TestDirs, java/nio/Buffer java/nio/ByteOrder \
           java/nio/channels java/nio/MappedByteBuffer)
 	$(call SharedLibraryPermissions,java/nio/channels)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_nio3
 jdk_nio3: $(call TestDirs, sun/nio)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # All nio tests
 jdk_nio: jdk_nio1 jdk_nio2 jdk_nio3
 	@$(SummaryInfo)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 jdk_sctp: $(call TestDirs, com/sun/nio/sctp)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # Stable othervm testruns (minus items from PROBLEM_LIST)
-#   Using samevm has serious problems with these tests
+#   Using agentvm has serious problems with these tests
 JDK_ALL_TARGETS += jdk_rmi
 jdk_rmi: $(call TestDirs, java/rmi javax/rmi sun/rmi)
 	$(call RunOthervmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_security1
 jdk_security1: $(call TestDirs, java/security)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_security2
 jdk_security2: $(call TestDirs, javax/crypto javax/xml/crypto com/sun/crypto)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_security3
 jdk_security3: $(call TestDirs, com/sun/security lib/security javax/security \
         sun/security com/sun/org/apache/xml/internal/security)
 	$(call SharedLibraryPermissions,sun/security)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # All security tests
 jdk_security: jdk_security1 jdk_security2 jdk_security3
 	@$(SummaryInfo)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_sound
 jdk_sound: $(call TestDirs, javax/sound)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # Stable othervm testruns (minus items from PROBLEM_LIST)
-#   Using samevm has problems, and doesn't help performance as much as others.
+#   Using agentvm has problems, and doesn't help performance as much as others.
 JDK_ALL_TARGETS += jdk_swing
 jdk_swing: $(call TestDirs, javax/swing sun/java2d \
            demo/jfc com/sun/java/swing)
 	$(call RunOthervmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_text
 jdk_text: $(call TestDirs, java/text sun/text)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_tools1
 jdk_tools1: $(call TestDirs, com/sun/jdi)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # Stable othervm testruns (minus items from PROBLEM_LIST)
-#   Using samevm has serious problems with these tests
+#   Using agentvm has serious problems with these tests
 JDK_ALL_TARGETS += jdk_tools2
 jdk_tools2: $(call TestDirs, \
             com/sun/tools sun/jvmstat sun/tools tools vm \
             com/sun/servicetag com/sun/tracing)
 	$(call SharedLibraryPermissions,tools/launcher)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # All tools tests
 jdk_tools: jdk_tools1 jdk_tools2
 	@$(SummaryInfo)
 
-# Stable samevm testruns (minus items from PROBLEM_LIST)
+# Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_util
 jdk_util: $(call TestDirs, java/util sun/util)
-	$(call RunSamevmBatch)
+	$(call RunAgentvmBatch)
 
 # ------------------------------------------------------------------
 
@@ -603,7 +607,7 @@
 
 # Default JTREG to run (win32 script works for everybody)
 JTREG = $(JT_HOME)/win32/bin/jtreg
-# Add any extra options (samevm etc.)
+# Add any extra options (agentvm etc.)
 JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 # Only run automatic tests
 JTREG_BASIC_OPTIONS += -a
--- a/jdk/test/ProblemList.txt	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/ProblemList.txt	Wed Oct 26 17:59:13 2011 -0700
@@ -43,11 +43,11 @@
 #
 # List items  are testnames followed by labels, all MUST BE commented
 #   as to why they are here and use a label:
-#     generic-all	Problems on all platforms
-#     generic-ARCH	Where ARCH is one of: sparc, sparcv9, x64, i586, etc.
-#     OSNAME-all	Where OSNAME is one of: solaris, linux, windows
-#     OSNAME-ARCH	Specific on to one OSNAME and ARCH, e.g. solaris-x64
-#     OSNAME-REV	Specific on to one OSNAME and REV, e.g. solaris-5.8
+#     generic-all       Problems on all platforms
+#     generic-ARCH      Where ARCH is one of: sparc, sparcv9, x64, i586, etc.
+#     OSNAME-all        Where OSNAME is one of: solaris, linux, windows
+#     OSNAME-ARCH       Specific on to one OSNAME and ARCH, e.g. solaris-x64
+#     OSNAME-REV        Specific on to one OSNAME and REV, e.g. solaris-5.8
 #
 # More than one label is allowed but must be on the same line.
 #
@@ -123,38 +123,38 @@
 java/awt/event/MouseEvent/AcceptExtraButton/AcceptExtraButton.java generic-all
 
 # Causes hang in samevm mode??? Solaris 11 i586
-java/awt/FullScreen/SetFSWindow/FSFrame.java			generic-all
+java/awt/FullScreen/SetFSWindow/FSFrame.java                    generic-all
 
 # Fails on solaris 11 i586, -client, in othervm mode not sure why
-java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java	generic-all
+java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java     generic-all
 java/awt/Focus/CloseDialogActivateOwnerTest/CloseDialogActivateOwnerTest.java generic-all
-java/awt/FontClass/FontAccess.java				generic-all
-java/awt/Mixing/HWDisappear.java				generic-all
-java/awt/Mixing/MixingInHwPanel.java				generic-all
-java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.html	generic-all
+java/awt/FontClass/FontAccess.java                              generic-all
+java/awt/Mixing/HWDisappear.java                                generic-all
+java/awt/Mixing/MixingInHwPanel.java                            generic-all
+java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.html       generic-all
 java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java generic-all
-java/awt/Toolkit/SecurityTest/SecurityTest2.java		generic-all
-java/awt/image/mlib/MlibOpsTest.java				generic-all
+java/awt/Toolkit/SecurityTest/SecurityTest2.java                generic-all
+java/awt/image/mlib/MlibOpsTest.java                            generic-all
 
 # Fails on windows, othervm mode, various errors
-java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java	generic-all
-java/awt/Focus/OwnedWindowFocusIMECrashTest/OwnedWindowFocusIMECrashTest.java	generic-all
-java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java	generic-all
-java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Standard.java	generic-all
-java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html			generic-all
-java/awt/font/Threads/FontThread.java				generic-all
-java/awt/print/PrinterJob/PrtException.java			generic-all
+java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java        generic-all
+java/awt/Focus/OwnedWindowFocusIMECrashTest/OwnedWindowFocusIMECrashTest.java   generic-all
+java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java        generic-all
+java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Standard.java      generic-all
+java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html                 generic-all
+java/awt/font/Threads/FontThread.java                           generic-all
+java/awt/print/PrinterJob/PrtException.java                     generic-all
 
 # Fails with windows X64, othervm, -server
-com/sun/awt/Translucency/WindowOpacity.java			generic-all
-java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java		generic-all
-java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html	generic-all
+com/sun/awt/Translucency/WindowOpacity.java                     generic-all
+java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java             generic-all
+java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html generic-all
 java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html generic-all
 java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java generic-all
-java/awt/Frame/LayoutOnMaximizeTest/LayoutOnMaximizeTest.java	generic-all
-java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java	generic-all
-java/awt/Mixing/MixingOnShrinkingHWButton.java			generic-all
-java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java	generic-all
+java/awt/Frame/LayoutOnMaximizeTest/LayoutOnMaximizeTest.java   generic-all
+java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java    generic-all
+java/awt/Mixing/MixingOnShrinkingHWButton.java                  generic-all
+java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java      generic-all
 
 ############################################################################
 
@@ -166,30 +166,30 @@
 #  So a large batch of beans tests are currently run with othervm mode.
 
 # Filed 6986807
-java/beans/Introspector/TestTypeResolver.java   		generic-all
+java/beans/Introspector/TestTypeResolver.java                   generic-all
 
 # Filed 6986813
-java/beans/Introspector/memory/Test4508780.java			generic-all
+java/beans/Introspector/memory/Test4508780.java                 generic-all
 
 # Linux, some kind of problems with X11 display
-java/beans/PropertyChangeSupport/Test4682386.java		generic-all
-java/beans/PropertyChangeSupport/TestSynchronization.java	generic-all
-java/beans/Statement/Test4653179.java				generic-all
+java/beans/PropertyChangeSupport/Test4682386.java               generic-all
+java/beans/PropertyChangeSupport/TestSynchronization.java       generic-all
+java/beans/Statement/Test4653179.java                           generic-all
 
 # Runs REALLY slow on Solaris sparc for some reason, both -client and -server
-java/beans/XMLEncoder/Test4625418.java				solaris-sparc
+java/beans/XMLEncoder/Test4625418.java                          solaris-sparc
 
 # Problems with samevm and setting security manager (speculation partially)
-java/beans/Introspector/4168475/Test4168475.java		generic-all
-java/beans/Introspector/4520754/Test4520754.java		generic-all
-java/beans/Introspector/6380849/TestBeanInfo.java		generic-all
-java/beans/Introspector/Test4144543.java			generic-all
+java/beans/Introspector/4168475/Test4168475.java                generic-all
+java/beans/Introspector/4520754/Test4520754.java                generic-all
+java/beans/Introspector/6380849/TestBeanInfo.java               generic-all
+java/beans/Introspector/Test4144543.java                        generic-all
 
 # Failed to call method solaris-sparc???
-java/beans/EventHandler/Test6788531.java		 	generic-all
+java/beans/EventHandler/Test6788531.java                        generic-all
 
 # Jar or class not found???
-java/beans/XMLEncoder/6329581/Test6329581.java		 	generic-all
+java/beans/XMLEncoder/6329581/Test6329581.java                  generic-all
 
 ############################################################################
 
@@ -199,26 +199,26 @@
 java/lang/invoke/InvokeDynamicPrintArgs.java                    generic-all
 
 # 7079093
-java/lang/instrument/ManifestTest.sh				windows-all
+java/lang/instrument/ManifestTest.sh                            windows-all
 
 ############################################################################
 
 # jdk_management
 
 # 6944188
-java/lang/management/ThreadMXBean/ThreadStateTest.java		generic-all
+java/lang/management/ThreadMXBean/ThreadStateTest.java          generic-all
 
 # 7067973
 java/lang/management/MemoryMXBean/CollectionUsageThreshold.java generic-all
 
 # Failing, bug was filed: 6959636
-javax/management/loading/LibraryLoader/LibraryLoaderTest.java	generic-all
+javax/management/loading/LibraryLoader/LibraryLoaderTest.java   generic-all
 
 # Access denied messages on windows/mks, filed 6954450
-sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh	windows-all
+sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh      windows-all
 
 # Fails on linux: KO: StringMonitor notification missed or not emitted
-javax/management/monitor/NonComparableAttributeValueTest.java	generic-all
+javax/management/monitor/NonComparableAttributeValueTest.java   generic-all
 
 # Port conflict? Fails with communication error
 sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.sh generic-all
@@ -229,10 +229,10 @@
 javax/management/remote/mandatory/connection/ReconnectTest.java generic-all
 
 # Solaris 10 sparc, NPE from org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke
-javax/management/remote/mandatory/threads/ExecutorTest.java 	generic-all
+javax/management/remote/mandatory/threads/ExecutorTest.java     generic-all
 
 # Linux 32bit Fedora 9, IllegalStateException
-javax/management/monitor/RuntimeExceptionTest.java		generic-all
+javax/management/monitor/RuntimeExceptionTest.java              generic-all
 
 # Problems with rmi connection, othervm
 javax/management/remote/mandatory/subjectDelegation/SubjectDelegation2Test.java generic-all
@@ -241,16 +241,16 @@
 sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.sh generic-all
 
 # Fails with port already in use
-sun/management/jmxremote/bootstrap/RmiRegistrySslTest.sh	generic-all
+sun/management/jmxremote/bootstrap/RmiRegistrySslTest.sh        generic-all
 
 # Windows, connection can't last that long
-javax/management/eventService/LeaseTest.java			generic-all
+javax/management/eventService/LeaseTest.java                    generic-all
 
 # Linux othervm, X64, java.lang.Exception: Failed: ratio=102.4027795593753
-javax/management/remote/mandatory/notif/ListenerScaleTest.java	generic-all
+javax/management/remote/mandatory/notif/ListenerScaleTest.java  generic-all
 
 # Windows run seems to have triggered a hotspot gc error (see 6801625)
-com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.sh		generic-all
+com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.sh          generic-all
 
 # rmi problem? othervm, java.lang.reflect.UndeclaredThrowableException
 javax/management/remote/mandatory/subjectDelegation/SubjectDelegation3Test.java generic-all
@@ -259,30 +259,30 @@
 javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java generic-all
 
 # Times out on solaris sparc, with othervm
-javax/management/eventService/AddRemoveListenerTest.java	generic-all
+javax/management/eventService/AddRemoveListenerTest.java        generic-all
 
 # Linux i586 and x64 -server, timed out waiting for threads to expire? othervm
-javax/management/eventService/EventClientThreadTest.java	generic-all
+javax/management/eventService/EventClientThreadTest.java        generic-all
 
 # Linux i586 -server, Expected to receive 20, but got 21, othervm
 #   Fails on Linux X64 -server 20!=21
-javax/management/eventService/FetchingTest.java			generic-all
+javax/management/eventService/FetchingTest.java                 generic-all
 
 # NPE on windows 2000 i586 -client and -server
-javax/management/eventService/CustomForwarderTest.java	 	windows-all
+javax/management/eventService/CustomForwarderTest.java          windows-all
 
 # Windows i586 failure, callback did not complete
-javax/management/eventService/LeaseManagerDeadlockTest.java 	windows-all
+javax/management/eventService/LeaseManagerDeadlockTest.java     windows-all
 
 # Port already in use
-sun/management/jmxremote/bootstrap/LocalManagementTest.sh 	generic-all
+sun/management/jmxremote/bootstrap/LocalManagementTest.sh       generic-all
 
 # Failed to initialize connector (also overflowing jtreg io buffers)
-sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh	 	generic-all
-sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh 	generic-all
+sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh          generic-all
+sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh       generic-all
 
 # Windows X64, java.lang.IllegalStateException
-javax/management/monitor/AttributeArbitraryDataTypeTest.java	generic-all
+javax/management/monitor/AttributeArbitraryDataTypeTest.java    generic-all
 
 ############################################################################
 
@@ -293,92 +293,89 @@
 # jdk_misc
 
 # Need to be marked othervm, or changed to be samevm safe
-com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java	generic-all
+com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java generic-all
 
 # Need to be marked othervm, or changed to be samevm safe
 com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all
 
 # Solaris sparc and others, exception in initializer
-javax/imageio/CachePremissionsTest/CachePermissionsTest.java 	generic-all
+javax/imageio/CachePremissionsTest/CachePermissionsTest.java    generic-all
 
 # Leaves file rgba_* open, fails with windows samevm
-javax/imageio/plugins/png/PngOutputTypeTest.java		generic-all
+javax/imageio/plugins/png/PngOutputTypeTest.java                generic-all
 
 # Suspect test.png file is left open, windows samevm problems
-javax/imageio/plugins/png/ITXtTest.java				generic-all
+javax/imageio/plugins/png/ITXtTest.java                         generic-all
 
 # Solaris sparc and others, failed to compile testcase
-javax/imageio/metadata/DOML3Node.java			 	generic-all
+javax/imageio/metadata/DOML3Node.java                           generic-all
 
 # One of these tests is leaving file IMGP1001.JPG open, windows samevm
-javax/imageio/plugins/jpeg/ConcurrentReadingTest.java		generic-all
-javax/imageio/plugins/jpeg/ReadingInterruptionTest.java		generic-all
+javax/imageio/plugins/jpeg/ConcurrentReadingTest.java           generic-all
+javax/imageio/plugins/jpeg/ReadingInterruptionTest.java         generic-all
 
 # One of these files is missing a close on writer_* files, windows samevm
-javax/imageio/plugins/jpeg/ConcurrentWritingTest.java		generic-all
-javax/imageio/plugins/jpeg/WritingInterruptionTest.java		generic-all
+javax/imageio/plugins/jpeg/ConcurrentWritingTest.java           generic-all
+javax/imageio/plugins/jpeg/WritingInterruptionTest.java         generic-all
 
 # Leaving file test.jpg open, windows samevm
-javax/imageio/plugins/jpeg/ReadAsGrayTest.java			generic-all
+javax/imageio/plugins/jpeg/ReadAsGrayTest.java                  generic-all
 
 # Missing close on file wbmp*, windows samevm
-javax/imageio/plugins/wbmp/CanDecodeTest.java			generic-all
+javax/imageio/plugins/wbmp/CanDecodeTest.java                   generic-all
 
 # Failures on OpenSolaris, cannot read input files? samevm issues?
-javax/imageio/metadata/BooleanAttributes.java			generic-all
-javax/imageio/plugins/bmp/BMPSubsamplingTest.java		generic-all
-javax/imageio/plugins/bmp/TopDownTest.java			generic-all
-javax/imageio/plugins/gif/EncodeSubImageTest.java		generic-all
-javax/imageio/plugins/gif/GifTransparencyTest.java		generic-all
-javax/imageio/plugins/png/GrayPngTest.java			generic-all
-javax/imageio/plugins/png/ItxtUtf8Test.java			generic-all
-javax/imageio/plugins/png/MergeStdCommentTest.java		generic-all
-javax/imageio/plugins/png/ShortHistogramTest.java		generic-all
-javax/imageio/plugins/shared/BitDepth.java			generic-all
+javax/imageio/metadata/BooleanAttributes.java                   generic-all
+javax/imageio/plugins/bmp/BMPSubsamplingTest.java               generic-all
+javax/imageio/plugins/bmp/TopDownTest.java                      generic-all
+javax/imageio/plugins/gif/EncodeSubImageTest.java               generic-all
+javax/imageio/plugins/gif/GifTransparencyTest.java              generic-all
+javax/imageio/plugins/png/GrayPngTest.java                      generic-all
+javax/imageio/plugins/png/ItxtUtf8Test.java                     generic-all
+javax/imageio/plugins/png/MergeStdCommentTest.java              generic-all
+javax/imageio/plugins/png/ShortHistogramTest.java               generic-all
+javax/imageio/plugins/shared/BitDepth.java                      generic-all
 
 # Exclude all javax/print tests, even if they passed, they may need samevm work
 
 # Times out on solaris-sparc, sparcv9, x64 -server, some on i586 -client
-javax/print/attribute/autosense/PrintAutoSenseData.java 	generic-all
-javax/print/attribute/Chroma.java			 	generic-all
-javax/print/attribute/CollateAttr.java			 	generic-all
-javax/print/attribute/PSCopiesFlavorTest.java		 	generic-all
-javax/print/LookupServices.java 			 	generic-all
-javax/print/TestRaceCond.java				 	generic-all
+javax/print/attribute/autosense/PrintAutoSenseData.java         generic-all
+javax/print/attribute/Chroma.java                               generic-all
+javax/print/attribute/CollateAttr.java                          generic-all
+javax/print/attribute/PSCopiesFlavorTest.java                   generic-all
+javax/print/LookupServices.java                                 generic-all
+javax/print/TestRaceCond.java                                   generic-all
 
 # These tests really require a printer (might all be windows only tests?)
-javax/print/CheckDupFlavor.java					generic-all
-javax/print/PrintSE/PrintSE.sh					generic-all
-javax/print/attribute/ChromaticityValues.java			generic-all
-javax/print/attribute/GetCopiesSupported.java			generic-all
-javax/print/attribute/SidesPageRangesTest.java			generic-all
-javax/print/attribute/SupportedPrintableAreas.java		generic-all
+javax/print/CheckDupFlavor.java                                 generic-all
+javax/print/PrintSE/PrintSE.sh                                  generic-all
+javax/print/attribute/ChromaticityValues.java                   generic-all
+javax/print/attribute/GetCopiesSupported.java                   generic-all
+javax/print/attribute/SidesPageRangesTest.java                  generic-all
+javax/print/attribute/SupportedPrintableAreas.java              generic-all
 javax/print/attribute/AttributeTest.java                        generic-all
 
 # Only print test left, excluding just because all print tests have been
-javax/print/attribute/MediaMappingsTest.java 			generic-all
+javax/print/attribute/MediaMappingsTest.java                    generic-all
 
 # Filed 7058852
-javax/sound/sampled/FileWriter/AlawEncoderSync.java		generic-all
+javax/sound/sampled/FileWriter/AlawEncoderSync.java             generic-all
 
 ############################################################################
 
 # jdk_net
 
 # Filed 7052625
-com/sun/net/httpserver/bugs/6725892/Test.java			generic-all
+com/sun/net/httpserver/bugs/6725892/Test.java                   generic-all
 
 # Filed 7036666
-com/sun/net/httpserver/Test9a.java				generic-all
+com/sun/net/httpserver/Test9a.java                              generic-all
 
 # 7079145 java/net/ipv6tests/UdpTest.java hang at IPv6 only data exchange
 java/net/ipv6tests/UdpTest.java                                 linux-all
 
-# 7079012
-java/net/NetworkInterface/NetParamsTest.java			solaris-all
-
 # 7081476
-java/net/InetSocketAddress/B6469803.java			generic-all
+java/net/InetSocketAddress/B6469803.java                        generic-all
 
 ############################################################################
 
@@ -388,10 +385,10 @@
 java/io/File/MaxPathLength.java                                 windows-all
 
 # 6671616
-java/io/File/BlockIsDirectory.java				solaris-all
+java/io/File/BlockIsDirectory.java                              solaris-all
 
 # 7076644
-java/io/File/Basic.java						windows-all
+java/io/File/Basic.java                                         windows-all
 
 ############################################################################
 
@@ -401,14 +398,14 @@
 java/nio/channels/Selector/Wakeup.java                          windows-all
 
 # 7076700
-java/nio/channels/SocketChannel/AdaptSocket.java		generic-all
+java/nio/channels/SocketChannel/AdaptSocket.java                generic-all
 
 ############################################################################
 
 # jdk_rmi
 
 # Port already in use, fails on sparc, othervm
-java/rmi/reliability/benchmark/runRmiBench.sh			generic-all
+java/rmi/reliability/benchmark/runRmiBench.sh                   generic-all
 
 # Already in use port issues? othervm solaris
 java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java generic-all
@@ -418,21 +415,21 @@
 java/rmi/transport/dgcDeadLock/TestImpl_Stub.java                       generic-all
 
 # Address already in use, othervm mode, solaris
-java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java	generic-all
-java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java	generic-all
+java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java        generic-all
+java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java  generic-all
 
 # Registry already running on port, solaris
-java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java	generic-all
+java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java      generic-all
 
 # Fails on Linux 32 and 64bit -server?, impl not garbage collected???
-java/rmi/transport/pinLastArguments/PinLastArguments.java	generic-all
+java/rmi/transport/pinLastArguments/PinLastArguments.java       generic-all
 
 # Times out on solaris sparc
-java/rmi/server/RemoteServer/AddrInUse.java			generic-all
+java/rmi/server/RemoteServer/AddrInUse.java                     generic-all
 
 # Connection error on Windows i586 -server
 #  Also connection errors in othervm on Solaris 10 sparc, same port???
-sun/rmi/transport/tcp/DeadCachedConnection.java 	 	generic-all
+sun/rmi/transport/tcp/DeadCachedConnection.java                 generic-all
 
 # Connection errors in othervm on Solaris 10 sparc, same port???
 java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java generic-all
@@ -478,20 +475,20 @@
 # jdk_security
 
 # Failing on Solaris i586, 3/9/2010, not a -samevm issue (jdk_security3)
-sun/security/pkcs11/Secmod/AddPrivateKey.java			solaris-i586
-sun/security/pkcs11/ec/ReadCertificates.java			solaris-i586
-sun/security/pkcs11/ec/ReadPKCS12.java				solaris-i586
-sun/security/pkcs11/ec/TestCurves.java				solaris-i586
-sun/security/pkcs11/ec/TestECDSA.java				solaris-i586
-#sun/security/pkcs11/ec/TestECGenSpec.java			solaris-i586
-#sun/security/pkcs11/ec/TestKeyFactory.java			solaris-i586
-sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java		solaris-i586
+sun/security/pkcs11/Secmod/AddPrivateKey.java                   solaris-i586
+sun/security/pkcs11/ec/ReadCertificates.java                    solaris-i586
+sun/security/pkcs11/ec/ReadPKCS12.java                          solaris-i586
+sun/security/pkcs11/ec/TestCurves.java                          solaris-i586
+sun/security/pkcs11/ec/TestECDSA.java                           solaris-i586
+#sun/security/pkcs11/ec/TestECGenSpec.java                      solaris-i586
+#sun/security/pkcs11/ec/TestKeyFactory.java                     solaris-i586
+sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java            solaris-i586
 
 # Directly references PKCS11 class
 sun/security/pkcs11/Provider/Absolute.java                      windows-x64
 
 # Fails on Fedora 9/Ubuntu 10.04 64bit, PKCS11Exception: CKR_DEVICE_ERROR
-sun/security/pkcs11/KeyAgreement/TestDH.java			generic-all
+sun/security/pkcs11/KeyAgreement/TestDH.java                    generic-all
 
 # Run too slow on Solaris 10 sparc
 sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java solaris-sparc
@@ -508,14 +505,14 @@
 
 # Times out on windows X64, othervm mode
 #    Solaris sparc and sparcv9 -server, timeout
-sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java	generic-all
+sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java generic-all
 
 # Various failures on Linux Fedora 9 X64, othervm mode
 sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/TestAllSuites.java generic-all
-sun/security/ssl/sanity/ciphersuites/CheckCipherSuites.java	generic-all
+sun/security/ssl/sanity/ciphersuites/CheckCipherSuites.java     generic-all
 
 # Various failures on Linux Fedora 9 X64, othervm mode
-sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java	generic-all
+sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java       generic-all
 
 # 7079203 sun/security/tools/keytool/printssl.sh fails on solaris with timeout
 sun/security/tools/keytool/printssl.sh                          solaris-all
@@ -524,7 +521,7 @@
 sun/security/tools/jarsigner/ec.sh                             solaris-all
 
 # 7081817
-sun/security/provider/certpath/X509CertPath/IllegalCertiticates.java 	generic-all
+sun/security/provider/certpath/X509CertPath/IllegalCertiticates.java    generic-all
 
 # 7041639, Solaris DSA keypair generation bug (Note: jdk_util also affected)
 java/security/KeyPairGenerator/SolarisShortDSA.java             solaris-all
@@ -541,57 +538,57 @@
 # jdk_swing (not using samevm)
 
 # Fails on solaris 11 i586, with othervm
-javax/swing/JFileChooser/6570445/bug6570445.java		generic-all
-javax/swing/JFileChooser/6738668/bug6738668.java		generic-all
-javax/swing/JPopupMenu/6675802/bug6675802.java			generic-all
-javax/swing/system/6799345/TestShutdown.java			generic-all
+javax/swing/JFileChooser/6570445/bug6570445.java                generic-all
+javax/swing/JFileChooser/6738668/bug6738668.java                generic-all
+javax/swing/JPopupMenu/6675802/bug6675802.java                  generic-all
+javax/swing/system/6799345/TestShutdown.java                    generic-all
 
 ############################################################################
 
 # jdk_text
 
 # Linux x64 occasional errors, no details
-java/text/Bidi/Bug6665028.java				 	linux-x64
+java/text/Bidi/Bug6665028.java                                  linux-x64
 
 ############################################################################
 
 # jdk_tools
 
 # Filed 6952105
-com/sun/jdi/SuspendThreadTest.java				generic-all
+com/sun/jdi/SuspendThreadTest.java                              generic-all
 
 # Filed 6653793
-com/sun/jdi/RedefineCrossEvent.java				generic-all
+com/sun/jdi/RedefineCrossEvent.java                             generic-all
 
 # Filed 6987312
-com/sun/jdi/DoubleAgentTest.java				generic-all
+com/sun/jdi/DoubleAgentTest.java                                generic-all
 
 # Filed 7020857
-com/sun/jdi/FieldWatchpoints.java				generic-all
+com/sun/jdi/FieldWatchpoints.java                               generic-all
 
 # Filed 6402201
-com/sun/jdi/ProcessAttachTest.sh				generic-all
+com/sun/jdi/ProcessAttachTest.sh                                generic-all
 
 # Filed 6986875
-sun/tools/jps/jps-Vvml.sh					generic-all
+sun/tools/jps/jps-Vvml.sh                                       generic-all
 
 # Filed 6979016
-sun/tools/jconsole/ResourceCheckTest.sh				generic-all
+sun/tools/jconsole/ResourceCheckTest.sh                         generic-all
 
 ############################################################################
 
 # jdk_util
 
 # Filed 7027061
-java/util/Locale/Bug6989440.java				windows-all
+java/util/Locale/Bug6989440.java                                windows-all
 
 # Filed 6933803
-java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java	generic-all
+java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java  generic-all
 
 # Filed 7022325
 # Fails with assertion error on windows
 #   11 separate stacktraces created... file reuse problem?
-java/util/zip/ZipFile/ReadLongZipFileName.java			generic-all
+java/util/zip/ZipFile/ReadLongZipFileName.java                  generic-all
 
 # Filed 6772009
 java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
--- a/jdk/test/com/sun/jdi/sde/MangleStepTest.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/com/sun/jdi/sde/MangleStepTest.java	Wed Oct 26 17:59:13 2011 -0700
@@ -10,11 +10,11 @@
  *  @run build TestScaffold VMConnection TargetListener TargetAdapter InstallSDE
  *  @run compile MangleStepTest.java
  *  @run compile -g  onion/pickle/Mangle.java
- *  @run main MangleStepTest unset
- *  @run main MangleStepTest Java
- *  @run main MangleStepTest XYZ
- *  @run main MangleStepTest Rats
- *  @run main MangleStepTest bogus
+ *  @run main/othervm MangleStepTest unset
+ *  @run main/othervm MangleStepTest Java
+ *  @run main/othervm MangleStepTest XYZ
+ *  @run main/othervm MangleStepTest Rats
+ *  @run main/othervm MangleStepTest bogus
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/jndi/ldap/LdapsReadTimeoutTest.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7094377
+ * @summary Com.sun.jndi.ldap.read.timeout doesn't work with ldaps.
+ */
+
+import java.net.Socket;
+import java.net.ServerSocket;
+import java.io.*;
+import javax.naming.*;
+import javax.naming.directory.*;
+import java.util.Hashtable;
+
+public class LdapsReadTimeoutTest {
+
+    public static void main(String[] args) throws Exception {
+        boolean passed = false;
+
+        // create the server
+        try (Server server = Server.create()) {
+            // Set up the environment for creating the initial context
+            Hashtable<String,Object> env = new Hashtable<>(11);
+            env.put(Context.INITIAL_CONTEXT_FACTORY,
+                "com.sun.jndi.ldap.LdapCtxFactory");
+            env.put("com.sun.jndi.ldap.connect.timeout", "1000");
+            env.put("com.sun.jndi.ldap.read.timeout", "1000");
+            env.put(Context.PROVIDER_URL, "ldaps://localhost:" + server.port());
+
+
+            // Create initial context
+            DirContext ctx = new InitialDirContext(env);
+            try {
+                System.out.println("LDAP Client: Connected to the Server");
+
+                SearchControls scl = new SearchControls();
+                scl.setSearchScope(SearchControls.SUBTREE_SCOPE);
+                System.out.println("Performing Search");
+                NamingEnumeration<SearchResult> answer =
+                    ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl);
+            } finally {
+                // Close the context when we're done
+                ctx.close();
+            }
+        } catch (NamingException e) {
+            passed = true;
+            e.printStackTrace();
+        }
+
+        if (!passed) {
+            throw new Exception("Read timeout test failed," +
+                         " read timeout exception not thrown");
+        }
+        System.out.println("The test PASSED");
+    }
+
+    static class Server implements Runnable, Closeable {
+        private final ServerSocket ss;
+        private Socket sref;
+
+        private Server(ServerSocket ss) {
+            this.ss = ss;
+        }
+
+        static Server create() throws IOException {
+            Server server = new Server(new ServerSocket(0));
+            new Thread(server).start();
+            return server;
+        }
+
+        int port() {
+            return ss.getLocalPort();
+        }
+
+        public void run() {
+            try (Socket s = ss.accept()) {
+                sref = s;
+                System.out.println("Server: Connection accepted");
+                BufferedInputStream bis =
+                    new BufferedInputStream(s.getInputStream());
+                byte[] buf = new byte[100];
+                int n;
+                do {
+                    n = bis.read(buf);
+                } while (n > 0);
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+
+        public void close() throws IOException {
+            ss.close();
+            sref.close();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/etc/FileDescriptorSharing.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,336 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6322678 7082769
+ * @summary FileInputStream/FileOutputStream/RandomAccessFile allow file descriptor
+ *          to be closed while still in use.
+ * @run main/othervm FileDescriptorSharing
+ */
+
+import java.io.*;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.util.concurrent.CountDownLatch;
+
+public class FileDescriptorSharing {
+
+    final static int numFiles = 10;
+    volatile static boolean fail;
+
+    public static void main(String[] args) throws Exception {
+        TestFinalizer();
+        TestMultipleFD();
+        TestIsValid();
+        MultiThreadedFD();
+    }
+
+    /**
+     * We shouldn't discard a file descriptor until all streams have
+     * finished with it
+     */
+    private static void TestFinalizer() throws Exception {
+        FileDescriptor fd = null;
+        File tempFile = new File("TestFinalizer1.txt");
+        tempFile.deleteOnExit();
+        try (Writer writer = new FileWriter(tempFile)) {
+            for (int i=0; i<5; i++) {
+                writer.write("test file content test file content");
+            }
+        }
+
+        FileInputStream fis1 = new FileInputStream(tempFile);
+        fd = fis1.getFD();
+        // Create a new FIS based on the existing FD (so the two FIS's share the same native fd)
+        try (FileInputStream fis2 = new FileInputStream(fd)) {
+            // allow fis1 to be gc'ed
+            fis1 = null;
+            int ret = 0;
+            while(ret >= 0) {
+                // encourage gc
+                System.gc();
+                // read from fis2 - when fis1 is gc'ed and finalizer is run, read will fail
+                System.out.print(".");
+                ret = fis2.read();
+            }
+        }
+
+        // variation of above. Use RandomAccessFile to obtain a filedescriptor
+        File testFinalizerFile = new File("TestFinalizer");
+        RandomAccessFile raf = new RandomAccessFile(testFinalizerFile, "rw");
+        raf.writeBytes("test file content test file content");
+        raf.seek(0L);
+        fd = raf.getFD();
+        try (FileInputStream fis3 = new FileInputStream(fd)) {
+            // allow raf to be gc'ed
+            raf = null;
+            int ret = 0;
+            while (ret >= 0) {
+                // encourage gc
+                System.gc();
+                /*
+                 * read from fis3 - when raf is gc'ed and finalizer is run,
+                 * fd should still be valid.
+                 */
+                System.out.print(".");
+                ret = fis3.read();
+            }
+            if(!fd.valid()) {
+                throw new RuntimeException("TestFinalizer() : FileDescriptor should be valid");
+            }
+        } finally {
+            testFinalizerFile.delete();
+        }
+    }
+
+    /**
+     * Exercise FileDispatcher close()/preClose()
+     */
+    private static void TestMultipleFD() throws Exception {
+        RandomAccessFile raf = null;
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        FileChannel fc = null;
+        FileLock fileLock = null;
+
+        File test1 = new File("test1");
+        try {
+            raf = new RandomAccessFile(test1, "rw");
+            fos = new FileOutputStream(raf.getFD());
+            fis = new FileInputStream(raf.getFD());
+            fc = raf.getChannel();
+            fileLock = fc.lock();
+            raf.setLength(0L);
+            fos.flush();
+            fos.write("TEST".getBytes());
+        } finally {
+            if (fileLock != null) fileLock.release();
+            if (fis != null) fis.close();
+            if (fos != null) fos.close();
+            if (raf != null) raf.close();
+            test1.delete();
+        }
+
+        /*
+         * Close out in different order to ensure FD is not
+         * closed out too early
+         */
+        File test2 = new File("test2");
+        try {
+            raf = new RandomAccessFile(test2, "rw");
+            fos = new FileOutputStream(raf.getFD());
+            fis = new FileInputStream(raf.getFD());
+            fc = raf.getChannel();
+            fileLock = fc.lock();
+            raf.setLength(0L);
+            fos.flush();
+            fos.write("TEST".getBytes());
+        } finally {
+            if (fileLock != null) fileLock.release();
+            if (raf != null) raf.close();
+            if (fos != null) fos.close();
+            if (fis != null) fis.close();
+            test2.delete();
+        }
+
+        // one more time, fos first this time
+        File test3 = new File("test3");
+        try {
+            raf = new RandomAccessFile(test3, "rw");
+            fos = new FileOutputStream(raf.getFD());
+            fis = new FileInputStream(raf.getFD());
+            fc = raf.getChannel();
+            fileLock = fc.lock();
+            raf.setLength(0L);
+            fos.flush();
+            fos.write("TEST".getBytes());
+        } finally {
+            if (fileLock != null) fileLock.release();
+            if (fos != null) fos.close();
+            if (raf != null) raf.close();
+            if (fis != null) fis.close();
+            test3.delete();
+        }
+    }
+
+    /**
+     * Similar to TestMultipleFD() but this time we
+     * just get and use FileDescriptor.valid() for testing.
+     */
+    private static void TestIsValid() throws Exception {
+        FileDescriptor fd = null;
+        RandomAccessFile raf = null;
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        FileChannel fc = null;
+
+        File test1 = new File("test1");
+        try {
+            raf = new RandomAccessFile(test1, "rw");
+            fd = raf.getFD();
+            fos = new FileOutputStream(fd);
+            fis = new FileInputStream(fd);
+        } finally {
+            try {
+                if (fis != null) fis.close();
+                if (fos != null) fos.close();
+                if (!fd.valid()) {
+                    throw new RuntimeException("FileDescriptor should be valid");
+                }
+                if (raf != null) raf.close();
+                if (fd.valid()) {
+                    throw new RuntimeException("close() called and FileDescriptor still valid");
+                }
+            } finally {
+                if (raf != null) raf.close();
+                test1.delete();
+            }
+        }
+
+        /*
+         * Close out in different order to ensure FD is not
+         * closed out too early
+         */
+        File test2 = new File("test2");
+        try {
+            raf = new RandomAccessFile(test2, "rw");
+            fd = raf.getFD();
+            fos = new FileOutputStream(fd);
+            fis = new FileInputStream(fd);
+        } finally {
+            try {
+                if (raf != null) raf.close();
+                if (fos != null) fos.close();
+                if (!fd.valid()) {
+                    throw new RuntimeException("FileDescriptor should be valid");
+                }
+                if (fis != null) fis.close();
+                if (fd.valid()) {
+                    throw new RuntimeException("close() called and FileDescriptor still valid");
+                }
+            } finally {
+                test2.delete();
+            }
+        }
+
+        // one more time, fos first this time
+        File test3 = new File("test3");
+        try {
+            raf = new RandomAccessFile(test3, "rw");
+            fd = raf.getFD();
+            fos = new FileOutputStream(fd);
+            fis = new FileInputStream(fd);
+        } finally {
+            try {
+                if (fos != null) fos.close();
+                if (raf != null) raf.close();
+                if (!fd.valid()) {
+                    throw new RuntimeException("FileDescriptor should be valid");
+                }
+                if (fis != null) fis.close();
+                if (fd.valid()) {
+                    throw new RuntimeException("close() called and FileDescriptor still valid");
+                }
+            } finally {
+                test3.delete();
+            }
+        }
+    }
+
+    /**
+     * Test concurrent access to the same fd.useCount field
+     */
+    private static void MultiThreadedFD() throws Exception {
+        RandomAccessFile raf = null;
+        FileDescriptor fd = null;
+        int numThreads = 2;
+        CountDownLatch done = new CountDownLatch(numThreads);
+        OpenClose[] fileOpenClose = new OpenClose[numThreads];
+        File MultipleThreadedFD = new File("MultipleThreadedFD");
+        try {
+            raf = new RandomAccessFile(MultipleThreadedFD, "rw");
+            fd = raf.getFD();
+            for(int count=0;count<numThreads;count++) {
+                fileOpenClose[count] = new OpenClose(fd, done);
+                fileOpenClose[count].start();
+            }
+            done.await();
+        } finally {
+            try {
+                if(raf != null) raf.close();
+                // fd should now no longer be valid
+                if(fd.valid()) {
+                    throw new RuntimeException("FileDescriptor should not be valid");
+                }
+                // OpenClose thread tests failed
+                if(fail) {
+                    throw new RuntimeException("OpenClose thread tests failed.");
+                }
+            } finally {
+                MultipleThreadedFD.delete();
+            }
+        }
+    }
+
+    /**
+     * A thread which will open and close a number of FileInputStreams and
+     * FileOutputStreams referencing the same native file descriptor.
+     */
+    private static class OpenClose extends Thread {
+        private FileDescriptor fd = null;
+        private CountDownLatch done;
+        FileInputStream[] fisArray = new FileInputStream[numFiles];
+        FileOutputStream[] fosArray = new FileOutputStream[numFiles];
+
+        OpenClose(FileDescriptor filedescriptor, CountDownLatch done) {
+            this.fd = filedescriptor;
+            this.done = done;
+        }
+
+        public void run() {
+             try {
+                 for(int i=0;i<numFiles;i++) {
+                     fisArray[i] = new FileInputStream(fd);
+                     fosArray[i] = new FileOutputStream(fd);
+                 }
+
+                 // Now close out
+                 for(int i=0;i<numFiles;i++) {
+                     if(fisArray[i] != null) fisArray[i].close();
+                     if(fosArray[i] != null) fosArray[i].close();
+                 }
+
+             } catch(IOException ioe) {
+                 System.out.println("OpenClose encountered IO issue :" + ioe);
+                 fail = true;
+             } finally {
+                 if (!fd.valid()) { // fd should still be valid given RAF reference
+                     System.out.println("OpenClose: FileDescriptor should be valid");
+                     fail = true;
+                 }
+                 done.countDown();
+             }
+         }
+    }
+}
--- a/jdk/test/java/lang/Double/ParseHexFloatingPoint.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Double/ParseHexFloatingPoint.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 
 
 import java.util.regex.*;
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 public class ParseHexFloatingPoint {
@@ -227,7 +226,7 @@
             new PairSD("0x1.000000000000001p-1075",     Double.MIN_VALUE),
 
             // More subnormal rounding tests
-            new PairSD("0x0.fffffffffffff7fffffp-1022", FpUtils.nextDown(DoubleConsts.MIN_NORMAL)),
+            new PairSD("0x0.fffffffffffff7fffffp-1022", Math.nextDown(DoubleConsts.MIN_NORMAL)),
             new PairSD("0x0.fffffffffffff8p-1022",      DoubleConsts.MIN_NORMAL),
             new PairSD("0x0.fffffffffffff800000001p-1022",DoubleConsts.MIN_NORMAL),
             new PairSD("0x0.fffffffffffff80000000000000001p-1022",DoubleConsts.MIN_NORMAL),
@@ -242,10 +241,10 @@
             new PairSD("0x1.fffffffffffff8p1023",       infinityD),
             new PairSD("0x1.fffffffffffff8000001p1023", infinityD),
 
-            new PairSD("0x1.ffffffffffffep1023",        FpUtils.nextDown(Double.MAX_VALUE)),
-            new PairSD("0x1.ffffffffffffe0000p1023",    FpUtils.nextDown(Double.MAX_VALUE)),
-            new PairSD("0x1.ffffffffffffe8p1023",       FpUtils.nextDown(Double.MAX_VALUE)),
-            new PairSD("0x1.ffffffffffffe7p1023",       FpUtils.nextDown(Double.MAX_VALUE)),
+            new PairSD("0x1.ffffffffffffep1023",        Math.nextDown(Double.MAX_VALUE)),
+            new PairSD("0x1.ffffffffffffe0000p1023",    Math.nextDown(Double.MAX_VALUE)),
+            new PairSD("0x1.ffffffffffffe8p1023",       Math.nextDown(Double.MAX_VALUE)),
+            new PairSD("0x1.ffffffffffffe7p1023",       Math.nextDown(Double.MAX_VALUE)),
             new PairSD("0x1.ffffffffffffeffffffp1023",  Double.MAX_VALUE),
             new PairSD("0x1.ffffffffffffe8000001p1023", Double.MAX_VALUE),
         };
@@ -284,8 +283,8 @@
         };
 
         double [] answers = {
-            FpUtils.nextDown(FpUtils.nextDown(2.0)),
-            FpUtils.nextDown(2.0),
+            Math.nextDown(Math.nextDown(2.0)),
+            Math.nextDown(2.0),
             2.0
         };
 
--- a/jdk/test/java/lang/Double/ToHexString.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Double/ToHexString.java	Wed Oct 26 17:59:13 2011 -0700
@@ -29,7 +29,6 @@
  */
 
 import java.util.regex.*;
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 public class ToHexString {
--- a/jdk/test/java/lang/Math/CeilAndFloorTests.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/CeilAndFloorTests.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
  * @summary Check for correct implementation of Math.ceil and Math.floor
  */
 
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 public class CeilAndFloorTests {
@@ -69,7 +68,7 @@
 
         for(int i = Double.MIN_EXPONENT; i <= Double.MAX_EXPONENT; i++) {
             double powerOfTwo   = Math.scalb(1.0, i);
-            double neighborDown = FpUtils.nextDown(powerOfTwo);
+            double neighborDown = Math.nextDown(powerOfTwo);
             double neighborUp   = Math.nextUp(powerOfTwo);
 
             if (i < 0) {
@@ -114,7 +113,7 @@
 
         for(int i = -(0x10000); i <= 0x10000; i++) {
             double d = (double) i;
-            double neighborDown = FpUtils.nextDown(d);
+            double neighborDown = Math.nextDown(d);
             double neighborUp   = Math.nextUp(d);
 
             failures += testCeilCase( d, d);
@@ -140,8 +139,8 @@
         double [][] testCases = {
             { Double.MIN_VALUE,                           1.0},
             {-Double.MIN_VALUE,                          -0.0},
-            { FpUtils.nextDown(DoubleConsts.MIN_NORMAL),  1.0},
-            {-FpUtils.nextDown(DoubleConsts.MIN_NORMAL), -0.0},
+            { Math.nextDown(DoubleConsts.MIN_NORMAL),     1.0},
+            {-Math.nextDown(DoubleConsts.MIN_NORMAL),    -0.0},
             { DoubleConsts.MIN_NORMAL,                    1.0},
             {-DoubleConsts.MIN_NORMAL,                   -0.0},
 
@@ -157,8 +156,8 @@
             { 2.5,                                        3.0},
             {-2.5,                                       -2.0},
 
-            { FpUtils.nextDown(1.0),                      1.0},
-            { FpUtils.nextDown(-1.0),                    -1.0},
+            { Math.nextDown(1.0),                         1.0},
+            { Math.nextDown(-1.0),                       -1.0},
 
             { Math.nextUp(1.0),                           2.0},
             { Math.nextUp(-1.0),                         -0.0},
@@ -166,17 +165,17 @@
             { 0x1.0p51,                                 0x1.0p51},
             {-0x1.0p51,                                -0x1.0p51},
 
-            { FpUtils.nextDown(0x1.0p51),               0x1.0p51},
+            { Math.nextDown(0x1.0p51),                  0x1.0p51},
             {-Math.nextUp(0x1.0p51),                   -0x1.0p51},
 
             { Math.nextUp(0x1.0p51),                    0x1.0p51+1},
-            {-FpUtils.nextDown(0x1.0p51),              -0x1.0p51+1},
+            {-Math.nextDown(0x1.0p51),                 -0x1.0p51+1},
 
-            { FpUtils.nextDown(0x1.0p52),               0x1.0p52},
+            { Math.nextDown(0x1.0p52),                  0x1.0p52},
             {-Math.nextUp(0x1.0p52),                   -0x1.0p52-1.0},
 
             { Math.nextUp(0x1.0p52),                    0x1.0p52+1.0},
-            {-FpUtils.nextDown(0x1.0p52),              -0x1.0p52+1.0},
+            {-Math.nextDown(0x1.0p52),                 -0x1.0p52+1.0},
         };
 
         for(double[] testCase : testCases) {
--- a/jdk/test/java/lang/Math/CubeRootTests.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/CubeRootTests.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 public class CubeRootTests {
@@ -95,14 +94,14 @@
 
         // Test cbrt(2^(3n)) = 2^n.
         for(int i = 18; i <= DoubleConsts.MAX_EXPONENT/3; i++) {
-            failures += testCubeRootCase(FpUtils.scalb(1.0, 3*i),
-                                         FpUtils.scalb(1.0, i) );
+            failures += testCubeRootCase(Math.scalb(1.0, 3*i),
+                                         Math.scalb(1.0, i) );
         }
 
         // Test cbrt(2^(-3n)) = 2^-n.
-        for(int i = -1; i >= FpUtils.ilogb(Double.MIN_VALUE)/3; i--) {
-            failures += testCubeRootCase(FpUtils.scalb(1.0, 3*i),
-                                         FpUtils.scalb(1.0, i) );
+        for(int i = -1; i >= DoubleConsts.MIN_SUB_EXPONENT/3; i--) {
+            failures += testCubeRootCase(Math.scalb(1.0, 3*i),
+                                         Math.scalb(1.0, i) );
         }
 
         // Test random perfect cubes.  Create double values with
@@ -110,10 +109,10 @@
         // significant bits in the significand set; 17*3 = 51, which
         // is less than the number of bits in a double's significand.
         long exponentBits1 =
-            Double.doubleToLongBits(FpUtils.scalb(1.0, 55)) &
+            Double.doubleToLongBits(Math.scalb(1.0, 55)) &
             DoubleConsts.EXP_BIT_MASK;
         long exponentBits2=
-            Double.doubleToLongBits(FpUtils.scalb(1.0, -55)) &
+            Double.doubleToLongBits(Math.scalb(1.0, -55)) &
             DoubleConsts.EXP_BIT_MASK;
         for(int i = 0; i < 100; i++) {
             // Take 16 bits since the 17th bit is implicit in the
@@ -177,16 +176,16 @@
 
             err = d - StrictMath.pow(y1, 3);
             if (err != 0.0) {
-                if(FpUtils.isNaN(err)) {
+                if(Double.isNaN(err)) {
                     failures++;
                     System.err.println("Encountered unexpected NaN value: d = " + d +
                                        "\tcbrt(d) = " + y1);
                 } else {
                     if (err < 0.0) {
-                        err_adjacent = StrictMath.pow(FpUtils.nextUp(y1), 3) - d;
+                        err_adjacent = StrictMath.pow(Math.nextUp(y1), 3) - d;
                     }
                     else  { // (err > 0.0)
-                        err_adjacent = StrictMath.pow(FpUtils.nextAfter(y1,0.0), 3) - d;
+                        err_adjacent = StrictMath.pow(Math.nextAfter(y1,0.0), 3) - d;
                     }
 
                     if (Math.abs(err) > Math.abs(err_adjacent)) {
@@ -200,16 +199,16 @@
 
             err = d - StrictMath.pow(y2, 3);
             if (err != 0.0) {
-                if(FpUtils.isNaN(err)) {
+                if(Double.isNaN(err)) {
                     failures++;
                     System.err.println("Encountered unexpected NaN value: d = " + d +
                                        "\tcbrt(d) = " + y2);
                 } else {
                     if (err < 0.0) {
-                        err_adjacent = StrictMath.pow(FpUtils.nextUp(y2), 3) - d;
+                        err_adjacent = StrictMath.pow(Math.nextUp(y2), 3) - d;
                     }
                     else  { // (err > 0.0)
-                        err_adjacent = StrictMath.pow(FpUtils.nextAfter(y2,0.0), 3) - d;
+                        err_adjacent = StrictMath.pow(Math.nextAfter(y2,0.0), 3) - d;
                     }
 
                     if (Math.abs(err) > Math.abs(err_adjacent)) {
@@ -242,13 +241,13 @@
 
             // Test near cbrt(2^(3n)) = 2^n.
             for(int i = 18; i <= DoubleConsts.MAX_EXPONENT/3; i++) {
-                double pc = FpUtils.scalb(1.0, 3*i);
+                double pc = Math.scalb(1.0, 3*i);
 
                 pcNeighbors[2] = pc;
-                pcNeighbors[1] = FpUtils.nextDown(pc);
-                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
-                pcNeighbors[3] = FpUtils.nextUp(pc);
-                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+                pcNeighbors[1] = Math.nextDown(pc);
+                pcNeighbors[0] = Math.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = Math.nextUp(pc);
+                pcNeighbors[4] = Math.nextUp(pcNeighbors[3]);
 
                 for(int j = 0; j < pcNeighbors.length; j++) {
                     pcNeighborsCbrt[j] =           Math.cbrt(pcNeighbors[j]);
@@ -280,14 +279,14 @@
             }
 
             // Test near cbrt(2^(-3n)) = 2^-n.
-            for(int i = -1; i >= FpUtils.ilogb(Double.MIN_VALUE)/3; i--) {
-                double pc = FpUtils.scalb(1.0, 3*i);
+            for(int i = -1; i >= DoubleConsts.MIN_SUB_EXPONENT/3; i--) {
+                double pc = Math.scalb(1.0, 3*i);
 
                 pcNeighbors[2] = pc;
-                pcNeighbors[1] = FpUtils.nextDown(pc);
-                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
-                pcNeighbors[3] = FpUtils.nextUp(pc);
-                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+                pcNeighbors[1] = Math.nextDown(pc);
+                pcNeighbors[0] = Math.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = Math.nextUp(pc);
+                pcNeighbors[4] = Math.nextUp(pcNeighbors[3]);
 
                 for(int j = 0; j < pcNeighbors.length; j++) {
                     pcNeighborsCbrt[j] =           Math.cbrt(pcNeighbors[j]);
--- a/jdk/test/java/lang/Math/Expm1Tests.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/Expm1Tests.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
  */
 
 import sun.misc.DoubleConsts;
-import sun.misc.FpUtils;
 
 /*
  * The Taylor expansion of expxm1(x) = exp(x) -1 is
@@ -82,7 +81,7 @@
 
         // For |x| < 2^-54 expm1(x) ~= x
         for(int i = DoubleConsts.MIN_SUB_EXPONENT; i <= -54; i++) {
-            double d = FpUtils.scalb(2, i);
+            double d = Math.scalb(2, i);
             failures += testExpm1Case(d, d);
             failures += testExpm1Case(-d, -d);
         }
@@ -101,7 +100,7 @@
 
         // For x > 710, expm1(x) should be infinity
         for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
-            double d = FpUtils.scalb(2, i);
+            double d = Math.scalb(2, i);
             failures += testExpm1Case(d, infinityD);
         }
 
@@ -118,7 +117,7 @@
         }
 
         for(int i = 7; i <= DoubleConsts.MAX_EXPONENT; i++) {
-            double d = -FpUtils.scalb(2, i);
+            double d = -Math.scalb(2, i);
             failures += testExpm1CaseWithUlpDiff(d, -1.0, 1, reachedLimit);
         }
 
@@ -143,10 +142,10 @@
                 double pc = StrictMath.log(2)*i;
 
                 pcNeighbors[2] = pc;
-                pcNeighbors[1] = FpUtils.nextDown(pc);
-                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
-                pcNeighbors[3] = FpUtils.nextUp(pc);
-                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+                pcNeighbors[1] = Math.nextDown(pc);
+                pcNeighbors[0] = Math.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = Math.nextUp(pc);
+                pcNeighbors[4] = Math.nextUp(pcNeighbors[3]);
 
                 for(int j = 0; j < pcNeighbors.length; j++) {
                     pcNeighborsExpm1[j]       =       Math.expm1(pcNeighbors[j]);
--- a/jdk/test/java/lang/Math/HyperbolicTests.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/HyperbolicTests.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
  */
 
 import sun.misc.DoubleConsts;
-import sun.misc.FpUtils;
 
 public class HyperbolicTests {
     private HyperbolicTests(){}
@@ -266,7 +265,7 @@
         // double significand.
 
         for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
-            double d = FpUtils.scalb(2.0, i);
+            double d = Math.scalb(2.0, i);
 
             // Result and expected are the same.
             failures += testSinhCaseWithUlpDiff(d, d, 2.5);
@@ -280,7 +279,7 @@
         long trans22 = Double.doubleToLongBits(22.0);
         // (approximately) largest value such that exp shouldn't
         // overflow
-        long transExpOvfl = Double.doubleToLongBits(FpUtils.nextDown(709.7827128933841));
+        long transExpOvfl = Double.doubleToLongBits(Math.nextDown(709.7827128933841));
 
         for(long i = trans22;
             i < transExpOvfl;
@@ -344,7 +343,7 @@
         // sinh(x) overflows for values greater than 710; in
         // particular, it overflows for all 2^i, i > 10.
         for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
-            double d = FpUtils.scalb(2.0, i);
+            double d = Math.scalb(2.0, i);
 
             // Result and expected are the same.
             failures += testSinhCaseWithUlpDiff(d,
@@ -625,7 +624,7 @@
         // rounded.
 
         for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
-            double d = FpUtils.scalb(2.0, i);
+            double d = Math.scalb(2.0, i);
 
             // Result and expected are the same.
             failures += testCoshCaseWithUlpDiff(d, 1.0, 2.5);
@@ -639,7 +638,7 @@
         long trans22 = Double.doubleToLongBits(22.0);
         // (approximately) largest value such that exp shouldn't
         // overflow
-        long transExpOvfl = Double.doubleToLongBits(FpUtils.nextDown(709.7827128933841));
+        long transExpOvfl = Double.doubleToLongBits(Math.nextDown(709.7827128933841));
 
         for(long i = trans22;
             i < transExpOvfl;
@@ -703,7 +702,7 @@
         // cosh(x) overflows for values greater than 710; in
         // particular, it overflows for all 2^i, i > 10.
         for(int i = 10; i <= DoubleConsts.MAX_EXPONENT; i++) {
-            double d = FpUtils.scalb(2.0, i);
+            double d = Math.scalb(2.0, i);
 
             // Result and expected are the same.
             failures += testCoshCaseWithUlpDiff(d,
@@ -984,7 +983,7 @@
         // double significand.
 
         for(int i = DoubleConsts.MIN_SUB_EXPONENT; i < -27; i++) {
-            double d = FpUtils.scalb(2.0, i);
+            double d = Math.scalb(2.0, i);
 
             // Result and expected are the same.
             failures += testTanhCaseWithUlpDiff(d, d, 2.5);
@@ -998,7 +997,7 @@
         }
 
         for(int i = 5; i <= DoubleConsts.MAX_EXPONENT; i++) {
-            double d = FpUtils.scalb(2.0, i);
+            double d = Math.scalb(2.0, i);
 
             failures += testTanhCaseWithUlpDiff(d, 1.0, 2.5);
         }
--- a/jdk/test/java/lang/Math/HypotTests.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/HypotTests.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -90,7 +90,7 @@
         for(int i = DoubleConsts.MIN_SUB_EXPONENT;
             i <= DoubleConsts.MAX_EXPONENT;
             i++) {
-            double input = FpUtils.scalb(2, i);
+            double input = Math.scalb(2, i);
             failures += testHypotCase(input, 0.0, input);
         }
 
@@ -126,7 +126,7 @@
         for(int i = 0; i < 1000; i++) {
             double d = rand.nextDouble();
             // Scale d to have an exponent equal to MAX_EXPONENT -15
-            d = FpUtils.scalb(d, DoubleConsts.MAX_EXPONENT
+            d = Math.scalb(d, DoubleConsts.MAX_EXPONENT
                                  -15 - FpUtils.ilogb(d));
             for(int j = 0; j <= 13; j += 1) {
                 failures += testHypotCase(3*d, 4*d, 5*d, 2.5);
@@ -153,13 +153,13 @@
 
 
             for(int i = -18; i <= 18; i++) {
-                double pc = FpUtils.scalb(1.0, i);
+                double pc = Math.scalb(1.0, i);
 
                 pcNeighbors[2] = pc;
-                pcNeighbors[1] = FpUtils.nextDown(pc);
-                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
-                pcNeighbors[3] = FpUtils.nextUp(pc);
-                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+                pcNeighbors[1] = Math.nextDown(pc);
+                pcNeighbors[0] = Math.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = Math.nextUp(pc);
+                pcNeighbors[4] = Math.nextUp(pcNeighbors[3]);
 
                 for(int j = 0; j < pcNeighbors.length; j++) {
                     pcNeighborsHypot[j]       =       Math.hypot(2.0, pcNeighbors[j]);
--- a/jdk/test/java/lang/Math/IeeeRecommendedTests.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/IeeeRecommendedTests.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -177,7 +177,7 @@
             }
 
             if (i > FloatConsts.MIN_EXPONENT) {
-                float po2minus = FpUtils.nextAfter(po2,
+                float po2minus = Math.nextAfter(po2,
                                                  Float.NEGATIVE_INFINITY);
                 failures += testGetExponentCase(po2minus, i-1);
             }
@@ -205,7 +205,7 @@
             // Test largest value in next smaller binade
             if (i >= 3) {// (i == 1) would test 0.0;
                          // (i == 2) would just retest MIN_VALUE
-                testGetExponentCase(FpUtils.nextAfter(top, 0.0f),
+                testGetExponentCase(Math.nextAfter(top, 0.0f),
                                     FloatConsts.MIN_EXPONENT - 1);
 
                 if( i >= 10) {
@@ -284,7 +284,7 @@
             }
 
             if (i > DoubleConsts.MIN_EXPONENT) {
-                double po2minus = FpUtils.nextAfter(po2,
+                double po2minus = Math.nextAfter(po2,
                                                     Double.NEGATIVE_INFINITY);
                 failures += testGetExponentCase(po2minus, i-1);
             }
@@ -312,7 +312,7 @@
             // Test largest value in next smaller binade
             if (i >= 3) {// (i == 1) would test 0.0;
                          // (i == 2) would just retest MIN_VALUE
-                testGetExponentCase(FpUtils.nextAfter(top, 0.0),
+                testGetExponentCase(Math.nextAfter(top, 0.0),
                                     DoubleConsts.MIN_EXPONENT - 1);
 
                 if( i >= 10) {
@@ -623,8 +623,11 @@
         };
 
         for(int i = 0; i < testCases.length; i++) {
-            failures+=Tests.test("FpUtils.nextDown(float)",
-                                 testCases[i][0], FpUtils.nextDown(testCases[i][0]), testCases[i][1]);
+            failures+=Tests.test("Math.nextDown(float)",
+                                 testCases[i][0], Math.nextDown(testCases[i][0]), testCases[i][1]);
+
+            failures+=Tests.test("StrictMath.nextDown(float)",
+                                 testCases[i][0], StrictMath.nextDown(testCases[i][0]), testCases[i][1]);
         }
 
         return failures;
@@ -659,8 +662,11 @@
         };
 
         for(int i = 0; i < testCases.length; i++) {
-            failures+=Tests.test("FpUtils.nextDown(double)",
-                                 testCases[i][0], FpUtils.nextDown(testCases[i][0]), testCases[i][1]);
+            failures+=Tests.test("Math.nextDown(double)",
+                                 testCases[i][0], Math.nextDown(testCases[i][0]), testCases[i][1]);
+
+            failures+=Tests.test("StrictMath.nextDown(double)",
+                                 testCases[i][0], StrictMath.nextDown(testCases[i][0]), testCases[i][1]);
         }
 
         return failures;
@@ -706,8 +712,8 @@
                                  FpUtils.isNaN(testCases[i]), (i ==0));
 
             // isFinite
-            failures+=Tests.test("FpUtils.isFinite(float)", testCases[i],
-                                 FpUtils.isFinite(testCases[i]), (i >= 3));
+            failures+=Tests.test("Float.isFinite(float)", testCases[i],
+                                 Float.isFinite(testCases[i]), (i >= 3));
 
             // isInfinite
             failures+=Tests.test("FpUtils.isInfinite(float)", testCases[i],
@@ -756,8 +762,8 @@
                                  FpUtils.isNaN(testCases[i]), (i ==0));
 
             // isFinite
-            failures+=Tests.test("FpUtils.isFinite(double)", testCases[i],
-                                 FpUtils.isFinite(testCases[i]), (i >= 3));
+            failures+=Tests.test("Double.isFinite(double)", testCases[i],
+                                 Double.isFinite(testCases[i]), (i >= 3));
 
             // isInfinite
             failures+=Tests.test("FpUtils.isInfinite(double)", testCases[i],
@@ -1061,7 +1067,7 @@
                     float value = someTestCases[i];
                     failures+=testScalbCase(value,
                                             scaleFactor,
-                                            FpUtils.copySign( (scaleFactor>0?infinityF:0.0f), value) );
+                                            Math.copySign( (scaleFactor>0?infinityF:0.0f), value) );
                 }
             }
         }
@@ -1095,7 +1101,7 @@
                 failures+=testScalbCase(value,
                                         scaleFactor,
                                         (FpUtils.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ?
-                                        FpUtils.copySign(infinityF, value) : // overflow
+                                        Math.copySign(infinityF, value) : // overflow
                                         // calculate right answer
                                         twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
                 scale*=2.0f;
@@ -1268,7 +1274,7 @@
                     double value = someTestCases[i];
                     failures+=testScalbCase(value,
                                             scaleFactor,
-                                            FpUtils.copySign( (scaleFactor>0?infinityD:0.0), value) );
+                                            Math.copySign( (scaleFactor>0?infinityD:0.0), value) );
                 }
             }
         }
@@ -1302,7 +1308,7 @@
                 failures+=testScalbCase(value,
                                         scaleFactor,
                                         (FpUtils.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ?
-                                        FpUtils.copySign(infinityD, value) : // overflow
+                                        Math.copySign(infinityD, value) : // overflow
                                         // calculate right answer
                                         twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
                 scale*=2.0;
@@ -1423,7 +1429,7 @@
 
             // Create power of two
             float po2 = powerOfTwoF(i);
-            expected = FpUtils.scalb(1.0f, i - (FloatConsts.SIGNIFICAND_WIDTH-1));
+            expected = Math.scalb(1.0f, i - (FloatConsts.SIGNIFICAND_WIDTH-1));
 
             failures += testUlpCase(po2, expected);
 
@@ -1443,7 +1449,7 @@
             }
 
             if (i > FloatConsts.MIN_EXPONENT) {
-                float po2minus = FpUtils.nextAfter(po2,
+                float po2minus = Math.nextAfter(po2,
                                                    Float.NEGATIVE_INFINITY);
                 failures += testUlpCase(po2minus, expected/2.0f);
             }
@@ -1470,7 +1476,7 @@
             // Test largest value in next smaller binade
             if (i >= 3) {// (i == 1) would test 0.0;
                          // (i == 2) would just retest MIN_VALUE
-                testUlpCase(FpUtils.nextAfter(top, 0.0f),
+                testUlpCase(Math.nextAfter(top, 0.0f),
                             Float.MIN_VALUE);
 
                 if( i >= 10) {
@@ -1528,7 +1534,7 @@
 
             // Create power of two
             double po2 = powerOfTwoD(i);
-            expected = FpUtils.scalb(1.0, i - (DoubleConsts.SIGNIFICAND_WIDTH-1));
+            expected = Math.scalb(1.0, i - (DoubleConsts.SIGNIFICAND_WIDTH-1));
 
             failures += testUlpCase(po2, expected);
 
@@ -1548,7 +1554,7 @@
             }
 
             if (i > DoubleConsts.MIN_EXPONENT) {
-                double po2minus = FpUtils.nextAfter(po2,
+                double po2minus = Math.nextAfter(po2,
                                                     Double.NEGATIVE_INFINITY);
                 failures += testUlpCase(po2minus, expected/2.0f);
             }
@@ -1575,7 +1581,7 @@
             // Test largest value in next smaller binade
             if (i >= 3) {// (i == 1) would test 0.0;
                          // (i == 2) would just retest MIN_VALUE
-                testUlpCase(FpUtils.nextAfter(top, 0.0f),
+                testUlpCase(Math.nextAfter(top, 0.0f),
                             Double.MIN_VALUE);
 
                 if( i >= 10) {
--- a/jdk/test/java/lang/Math/Log10Tests.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/Log10Tests.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
  * @author Joseph D. Darcy
  */
 
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 public class Log10Tests {
@@ -98,13 +97,13 @@
         // within a few ulps of log(x)/log(10)
         for(int i = 0; i < 10000; i++) {
             double input = Double.longBitsToDouble(rand.nextLong());
-            if(! FpUtils.isFinite(input))
+            if(! Double.isFinite(input))
                 continue; // avoid testing NaN and infinite values
             else {
                 input = Math.abs(input);
 
                 double expected = StrictMath.log(input)/LN_10;
-                if( ! FpUtils.isFinite(expected))
+                if( ! Double.isFinite(expected))
                     continue; // if log(input) overflowed, try again
                 else {
                     double result;
@@ -153,16 +152,16 @@
             for(int i = 0; i < half; i++) {
                 if (i == 0) {
                     input[half] = 1.0;
-                    up   = FpUtils.nextUp(1.0);
-                    down = FpUtils.nextDown(1.0);
+                    up   = Math.nextUp(1.0);
+                    down = Math.nextDown(1.0);
                 } else {
                     input[half + i] = up;
                     input[half - i] = down;
-                    up   = FpUtils.nextUp(up);
-                    down = FpUtils.nextDown(down);
+                    up   = Math.nextUp(up);
+                    down = Math.nextDown(down);
                 }
             }
-            input[0] = FpUtils.nextDown(input[1]);
+            input[0] = Math.nextDown(input[1]);
 
             for(int i = 0; i < neighbors.length; i++) {
                 neighbors[i] =          Math.log10(input[i]);
--- a/jdk/test/java/lang/Math/Log1pTests.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/Log1pTests.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,14 +88,14 @@
 
         // For |x| < 2^-54 log1p(x) ~= x
         for(int i = DoubleConsts.MIN_SUB_EXPONENT; i <= -54; i++) {
-            double d = FpUtils.scalb(2, i);
+            double d = Math.scalb(2, i);
             failures += testLog1pCase(d, d);
             failures += testLog1pCase(-d, -d);
         }
 
         // For x > 2^53 log1p(x) ~= log(x)
         for(int i = 53; i <= DoubleConsts.MAX_EXPONENT; i++) {
-            double d = FpUtils.scalb(2, i);
+            double d = Math.scalb(2, i);
             failures += testLog1pCaseWithUlpDiff(d, StrictMath.log(d), 2.001);
         }
 
@@ -105,7 +105,7 @@
         for(int i = 0; i < 1000; i++) {
             double d = rand.nextDouble();
 
-            d = FpUtils.scalb(d, -53 - FpUtils.ilogb(d));
+            d = Math.scalb(d, -53 - FpUtils.ilogb(d));
 
             for(int j = -53; j <= 52; j++) {
                 failures += testLog1pCaseWithUlpDiff(d, hp15cLogp(d), 5);
@@ -135,10 +135,10 @@
                 double pc = StrictMath.pow(Math.E, i) - 1;
 
                 pcNeighbors[2] = pc;
-                pcNeighbors[1] = FpUtils.nextDown(pc);
-                pcNeighbors[0] = FpUtils.nextDown(pcNeighbors[1]);
-                pcNeighbors[3] = FpUtils.nextUp(pc);
-                pcNeighbors[4] = FpUtils.nextUp(pcNeighbors[3]);
+                pcNeighbors[1] = Math.nextDown(pc);
+                pcNeighbors[0] = Math.nextDown(pcNeighbors[1]);
+                pcNeighbors[3] = Math.nextUp(pc);
+                pcNeighbors[4] = Math.nextUp(pcNeighbors[3]);
 
                 for(int j = 0; j < pcNeighbors.length; j++) {
                     pcNeighborsLog1p[j]       =       Math.log1p(pcNeighbors[j]);
@@ -202,5 +202,4 @@
             throw new RuntimeException();
         }
     }
-
 }
--- a/jdk/test/java/lang/Math/Rint.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/lang/Math/Rint.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,8 @@
  * @test
  * @bug 4101566 4831589
  * @summary Check for correct implementation of Math.rint(double)
- *
  */
 
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 public class Rint {
@@ -48,28 +46,28 @@
 
     public static void main(String args[]) {
         int failures = 0;
-        double twoToThe52 = FpUtils.scalb(1.0, 52); // 2^52
+        double twoToThe52 = Math.scalb(1.0, 52); // 2^52
 
         double [][] testCases = {
             {0.0,                               0.0},
             {Double.MIN_VALUE,                  0.0},
-            {FpUtils.nextDown(DoubleConsts.MIN_NORMAL), 0.0},
+            {Math.nextDown(DoubleConsts.MIN_NORMAL), 0.0},
             {DoubleConsts.MIN_NORMAL,           0.0},
 
             {0.2,                               0.0},
 
-            {FpUtils.nextDown(0.5),             0.0},
-            {                 0.5,              0.0},
-            {  FpUtils.nextUp(0.5),             1.0},
+            {Math.nextDown(0.5),             0.0},
+            {              0.5,              0.0},
+            {  Math.nextUp(0.5),             1.0},
 
             {0.7,                               1.0},
-            {FpUtils.nextDown(1.0),             1.0},
-            {                 1.0,              1.0},
-            {  FpUtils.nextUp(1.0),             1.0},
+            {Math.nextDown(1.0),             1.0},
+            {              1.0,              1.0},
+            {  Math.nextUp(1.0),             1.0},
 
-            {FpUtils.nextDown(1.5),             1.0},
-            {                 1.5,              2.0},
-            {  FpUtils.nextUp(1.5),             2.0},
+            {Math.nextDown(1.5),             1.0},
+            {              1.5,              2.0},
+            {  Math.nextUp(1.5),             2.0},
 
             {4.2,                               4.0},
             {4.5,                               4.0},
@@ -81,19 +79,19 @@
 
             {150000.75,                         150001.0},
             {300000.5,                          300000.0},
-            {FpUtils.nextUp(300000.5),          300001.0},
-            {FpUtils.nextDown(300000.75),       300001.0},
+            {Math.nextUp(300000.5),          300001.0},
+            {Math.nextDown(300000.75),       300001.0},
             {300000.75,                         300001.0},
-            {FpUtils.nextUp(300000.75),         300001.0},
+            {Math.nextUp(300000.75),         300001.0},
             {300000.99,                         300001.0},
             {262144.75,                         262145.0}, //(2^18 ) + 0.75
             {499998.75,                         499999.0},
             {524287.75,                         524288.0}, //(2^19 -1) + 0.75
             {524288.75,                         524289.0},
 
-            {FpUtils.nextDown(twoToThe52),      twoToThe52},
+            {Math.nextDown(twoToThe52),      twoToThe52},
             {twoToThe52,                        twoToThe52},
-            {FpUtils.nextUp(twoToThe52),        FpUtils.nextUp(twoToThe52)},
+            {Math.nextUp(twoToThe52),        Math.nextUp(twoToThe52)},
 
             {Double.MAX_VALUE,          Double.MAX_VALUE},
             {Double.POSITIVE_INFINITY,  Double.POSITIVE_INFINITY},
@@ -118,5 +116,4 @@
             throw new RuntimeException();
         }
     }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/math/BigInteger/TestValueExact.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6371401
+ * @summary Tests of fooValueExact methods
+ * @author Joseph D. Darcy
+ */
+import java.math.BigInteger;
+
+public class TestValueExact {
+    public static void main(String... args) {
+        int errors = 0;
+
+        errors += testLongValueExact();
+        errors += testIntValueExact();
+        errors += testShortValueExact();
+        errors += testByteValueExact();
+
+        if (errors > 0)
+            throw new RuntimeException();
+    }
+
+    private static int testLongValueExact() {
+        int errors = 0;
+        BigInteger[] inRange = {
+            BigInteger.valueOf(Long.MIN_VALUE),
+            BigInteger.ZERO,
+            BigInteger.valueOf(Long.MAX_VALUE)
+        };
+
+        BigInteger[] outOfRange = {
+            BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.ONE),
+            BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE)
+        };
+
+        for (BigInteger bi : inRange) {
+            if (bi.longValueExact() != bi.longValue()) {
+                System.err.println("Mismatching int conversion for " + bi);
+                errors++;
+            }
+        }
+
+        for (BigInteger bi : outOfRange) {
+            try {
+                long value = bi.longValueExact();
+                System.err.println("Failed to get expected exception on " +
+                                   bi + " got " + value);
+                errors++;
+            } catch(ArithmeticException ae) {
+                ; // Expected
+            }
+        }
+        return errors;
+    }
+
+    private static int testIntValueExact() {
+        int errors = 0;
+        BigInteger[] inRange = {
+            BigInteger.valueOf(Integer.MIN_VALUE),
+            BigInteger.ZERO,
+            BigInteger.ONE,
+            BigInteger.TEN,
+            BigInteger.valueOf(Integer.MAX_VALUE)
+        };
+
+        BigInteger[] outOfRange = {
+            BigInteger.valueOf((long)Integer.MIN_VALUE - 1),
+            BigInteger.valueOf((long)Integer.MAX_VALUE + 1)
+        };
+
+        for (BigInteger bi : inRange) {
+            if (bi.intValueExact() != bi.intValue()) {
+                System.err.println("Mismatching int conversion for " + bi);
+                errors++;
+            }
+        }
+
+        for (BigInteger bi : outOfRange) {
+            try {
+                int value = bi.intValueExact();
+                System.err.println("Failed to get expected exception on " +
+                                   bi + " got " + value);
+                errors++;
+            } catch(ArithmeticException ae) {
+                ; // Expected
+            }
+        }
+        return errors;
+    }
+
+    private static int testShortValueExact() {
+        int errors = 0;
+        BigInteger[] inRange = {
+            BigInteger.valueOf(Short.MIN_VALUE),
+            BigInteger.ZERO,
+            BigInteger.ONE,
+            BigInteger.TEN,
+            BigInteger.valueOf(Short.MAX_VALUE)
+        };
+
+        BigInteger[] outOfRange = {
+            BigInteger.valueOf((long)Integer.MIN_VALUE - 1),
+            BigInteger.valueOf((long)Integer.MIN_VALUE),
+            BigInteger.valueOf(   (int)Short.MIN_VALUE - 1),
+            BigInteger.valueOf(   (int)Short.MAX_VALUE + 1),
+            BigInteger.valueOf((long)Integer.MAX_VALUE),
+            BigInteger.valueOf((long)Integer.MAX_VALUE + 1)
+        };
+
+        for (BigInteger bi : inRange) {
+            if (bi.shortValueExact() != bi.shortValue()) {
+                System.err.println("Mismatching short  conversion for " + bi);
+                errors++;
+            }
+        }
+
+        for (BigInteger bi : outOfRange) {
+            try {
+                int value = bi.shortValueExact();
+                System.err.println("Failed to get expected exception on " +
+                                   bi + " got " + value);
+                errors++;
+            } catch(ArithmeticException ae) {
+                ; // Expected
+            }
+        }
+        return errors;
+    }
+
+    private static int testByteValueExact() {
+        int errors = 0;
+        BigInteger[] inRange = {
+            BigInteger.valueOf(Byte.MIN_VALUE),
+            BigInteger.valueOf(0),
+            BigInteger.ONE,
+            BigInteger.TEN,
+            BigInteger.valueOf(Byte.MAX_VALUE)
+        };
+
+        BigInteger[] outOfRange = {
+            BigInteger.valueOf((long)Integer.MIN_VALUE - 1),
+            BigInteger.valueOf((long)Integer.MIN_VALUE),
+            BigInteger.valueOf(   (int)Short.MIN_VALUE - 1),
+            BigInteger.valueOf(   (int)Short.MIN_VALUE),
+            BigInteger.valueOf(    (int)Byte.MIN_VALUE - 1),
+            BigInteger.valueOf(    (int)Byte.MAX_VALUE + 1),
+            BigInteger.valueOf(   (int)Short.MAX_VALUE + 1),
+            BigInteger.valueOf(   (int)Short.MAX_VALUE),
+            BigInteger.valueOf((long)Integer.MAX_VALUE),
+            BigInteger.valueOf((long)Integer.MAX_VALUE + 1)
+        };
+
+        for (BigInteger bi : inRange) {
+            if (bi.byteValueExact() != bi.byteValue()) {
+                System.err.println("Mismatching byte conversion for " + bi);
+                errors++;
+            }
+        }
+
+        for (BigInteger bi : outOfRange) {
+            try {
+                int value = bi.byteValueExact();
+                System.err.println("Failed to get expected exception on " +
+                                   bi + " got " + value);
+                errors++;
+            } catch(ArithmeticException ae) {
+                ; // Expected
+            }
+        }
+        return errors;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/CookieHandler/NullUriCookieTest.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6953455
+ * @summary CookieStore.add() cannot handle null URI parameter
+ */
+
+import java.net.CookieManager;
+import java.net.CookieStore;
+import java.net.HttpCookie;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+public class NullUriCookieTest {
+    static boolean fail = false;
+
+    public static void main(String[] args) throws Exception {
+        checkCookieNullUri();
+    }
+
+    static void checkCookieNullUri() throws Exception {
+        //get a cookie store implementation and add a cookie to the store with null URI
+        CookieStore cookieStore = (new CookieManager()).getCookieStore();
+        HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
+        cookie.setDomain("foo.com");
+        cookieStore.add(null, cookie);
+
+        //Retrieve added cookie
+        URI uri = new URI("http://foo.com");
+        List<HttpCookie> addedCookieList = cookieStore.get(uri);
+
+        //Verify CookieStore behaves well
+        if (addedCookieList.size() != 1) {
+           fail = true;
+        }
+        checkFail("Abnormal size of cookie jar");
+
+        for (HttpCookie chip : addedCookieList) {
+            if (!chip.equals(cookie)) {
+                 fail = true;
+            }
+        }
+        checkFail("Cookie not retrieved from Cookie Jar");
+        boolean ret = cookieStore.remove(null,cookie);
+        if (!ret) {
+            fail = true;
+        }
+        checkFail("Abnormal removal behaviour from Cookie Jar");
+    }
+
+    static void checkFail(String exp) {
+        if (fail) {
+            throw new RuntimeException(exp);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/DatagramSocket/ChangingAddress.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7084030
+ * @summary Tests that DatagramSocket.getLocalAddress returns the right local
+ *          address after connect/disconnect.
+ */
+import java.net.*;
+
+public class ChangingAddress {
+
+    static void check(DatagramSocket ds, InetAddress expected) {
+        InetAddress actual = ds.getLocalAddress();
+        if (!expected.equals(actual)) {
+            throw new RuntimeException("Expected:"+expected+" Actual"+
+                                       actual);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        InetAddress lh = InetAddress.getLocalHost();
+        SocketAddress remote = new InetSocketAddress(lh, 1234);
+        InetAddress wildcard = InetAddress.getByAddress
+                               ("localhost", new byte[]{0,0,0,0});
+        try (DatagramSocket ds = new DatagramSocket()) {
+            check(ds, wildcard);
+
+            ds.connect(remote);
+            check(ds, lh);
+
+            ds.disconnect();
+            check(ds, wildcard);
+       }
+    }
+}
--- a/jdk/test/java/net/URLConnection/Redirect307Test.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/net/URLConnection/Redirect307Test.java	Wed Oct 26 17:59:13 2011 -0700
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 4380568
+ * @bug 4380568 7095949
  * @summary  HttpURLConnection does not support 307 redirects
  */
 import java.io.*;
@@ -31,10 +31,9 @@
 
 class RedirServer extends Thread {
 
-    ServerSocket s;
-    Socket   s1;
-    InputStream  is;
-    OutputStream os;
+    static final int TIMEOUT = 10 * 1000;
+
+    ServerSocket ss;
     int port;
 
     String reply1Part1 = "HTTP/1.1 307 Temporary Redirect\r\n" +
@@ -46,10 +45,10 @@
         "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
         "<html>Hello</html>";
 
-    RedirServer (ServerSocket y) {
-        s = y;
-        port = s.getLocalPort();
-        System.out.println("Server created listening on " + port);
+    RedirServer (ServerSocket ss) throws IOException {
+        this.ss = ss;
+        this.ss.setSoTimeout(TIMEOUT);
+        port = this.ss.getLocalPort();
     }
 
     String reply2 = "HTTP/1.1 200 Ok\r\n" +
@@ -59,74 +58,63 @@
         "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
         "World";
 
+    static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' };
+
+    // Read until the end of a HTTP request
+    void readOneRequest(InputStream is) throws IOException {
+        int requestEndCount = 0, r;
+        while ((r = is.read()) != -1) {
+            if (r == requestEnd[requestEndCount]) {
+                requestEndCount++;
+                if (requestEndCount == 4) {
+                    break;
+                }
+            } else {
+                requestEndCount = 0;
+            }
+        }
+    }
+
     public void run () {
         try {
-            s1 = s.accept ();
-            is = s1.getInputStream ();
-            os = s1.getOutputStream ();
-            is.read ();
-            String reply = reply1Part1 + port + reply1Part2;
-            os.write (reply.getBytes());
-            os.close();
+            try (Socket s = ss.accept()) {
+                s.setSoTimeout(TIMEOUT);
+                readOneRequest(s.getInputStream());
+                String reply = reply1Part1 + port + reply1Part2;
+                s.getOutputStream().write(reply.getBytes());
+            }
+
             /* wait for redirected connection */
-            s.setSoTimeout (5000);
-            s1 = s.accept ();
-            is = s1.getInputStream ();
-            os = s1.getOutputStream ();
-            is.read();
-            os.write (reply2.getBytes());
-            os.close();
-        }
-        catch (Exception e) {
-            /* Just need thread to terminate */
-            System.out.println("Server: caught " + e);
+            try (Socket s = ss.accept()) {
+                s.setSoTimeout(TIMEOUT);
+                readOneRequest(s.getInputStream());
+                s.getOutputStream().write(reply2.getBytes());
+            }
+        } catch (Exception e) {
             e.printStackTrace();
         } finally {
-            try { s.close(); } catch (IOException unused) {}
+            try { ss.close(); } catch (IOException unused) {}
         }
     }
 };
 
-
 public class Redirect307Test {
-
-    public static final int DELAY = 10;
-
     public static void main(String[] args) throws Exception {
-        int port;
-        RedirServer server;
-        ServerSocket sock;
+        ServerSocket sock = new ServerSocket(0);
+        int port = sock.getLocalPort();
+        RedirServer server = new RedirServer(sock);
+        server.start();
 
-        try {
-            sock = new ServerSocket (0);
-            port = sock.getLocalPort ();
-        }
-        catch (Exception e) {
-            System.out.println ("Exception: " + e);
-            return;
-        }
-
-        server = new RedirServer(sock);
-        server.start ();
+        URL url = new URL("http://localhost:" + port);
+        URLConnection conURL =  url.openConnection();
+        conURL.setDoInput(true);
+        conURL.setAllowUserInteraction(false);
+        conURL.setUseCaches(false);
 
-        try  {
-
-            String s = "http://localhost:" + port;
-            URL url = new URL(s);
-            URLConnection conURL =  url.openConnection();
-
-            conURL.setDoInput(true);
-            conURL.setAllowUserInteraction(false);
-            conURL.setUseCaches(false);
-
-            InputStream in = conURL.getInputStream();
+        try (InputStream in = conURL.getInputStream()) {
             if ((in.read() != (int)'W') || (in.read()!=(int)'o')) {
                 throw new RuntimeException ("Unexpected string read");
             }
         }
-        catch(IOException e) {
-            e.printStackTrace();
-            throw new RuntimeException ("Exception caught + " + e);
-        }
     }
 }
--- a/jdk/test/java/net/URLConnection/RedirectLimit.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/net/URLConnection/RedirectLimit.java	Wed Oct 26 17:59:13 2011 -0700
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 4458085
+ * @bug 4458085 7095949
  * @summary  Redirects Limited to 5
  */
 
@@ -57,29 +57,43 @@
     final ServerSocket ss;
     final int port;
 
-    RedirLimitServer(ServerSocket ss) {
+    RedirLimitServer(ServerSocket ss) throws IOException {
         this.ss = ss;
-        port = ss.getLocalPort();
+        port = this.ss.getLocalPort();
+        this.ss.setSoTimeout(TIMEOUT);
+    }
+
+    static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' };
+
+    // Read until the end of a HTTP request
+    void readOneRequest(InputStream is) throws IOException {
+        int requestEndCount = 0, r;
+        while ((r = is.read()) != -1) {
+            if (r == requestEnd[requestEndCount]) {
+                requestEndCount++;
+                if (requestEndCount == 4) {
+                    break;
+                }
+            } else {
+                requestEndCount = 0;
+            }
+        }
     }
 
     public void run() {
         try {
-            ss.setSoTimeout(TIMEOUT);
             for (int i=0; i<NUM_REDIRECTS; i++) {
                 try (Socket s = ss.accept()) {
                     s.setSoTimeout(TIMEOUT);
-                    InputStream is = s.getInputStream();
-                    OutputStream os = s.getOutputStream();
-                    is.read();
+                    readOneRequest(s.getInputStream());
                     String reply = reply1 + port + "/redirect" + i + reply2;
-                    os.write(reply.getBytes());
+                    s.getOutputStream().write(reply.getBytes());
                 }
             }
             try (Socket s = ss.accept()) {
-                InputStream is = s.getInputStream();
-                OutputStream os = s.getOutputStream();
-                is.read();
-                os.write(reply3.getBytes());
+                s.setSoTimeout(TIMEOUT);
+                readOneRequest(s.getInputStream());
+                s.getOutputStream().write(reply3.getBytes());
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -96,21 +110,17 @@
         RedirLimitServer server = new RedirLimitServer(ss);
         server.start();
 
-        InputStream in = null;
-        try {
-            URL url = new URL("http://localhost:" + port);
-            URLConnection conURL =  url.openConnection();
+        URL url = new URL("http://localhost:" + port);
+        URLConnection conURL =  url.openConnection();
 
-            conURL.setDoInput(true);
-            conURL.setAllowUserInteraction(false);
-            conURL.setUseCaches(false);
+        conURL.setDoInput(true);
+        conURL.setAllowUserInteraction(false);
+        conURL.setUseCaches(false);
 
-            in = conURL.getInputStream();
+        try (InputStream in = conURL.getInputStream()) {
             if ((in.read() != (int)'W') || (in.read()!=(int)'o')) {
                 throw new RuntimeException("Unexpected string read");
             }
-        } finally {
-            if ( in != null ) { in.close(); }
         }
     }
 }
--- a/jdk/test/java/util/Formatter/Basic-X.java.template	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/Basic-X.java.template	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
 import java.text.DateFormatSymbols;
 import java.util.*;
 #if[double]
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 #end[double]
 
@@ -1301,9 +1300,9 @@
         test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL);
         test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL);
         test("%.11a", "0x1.00000000000p-1022",
-             FpUtils.nextDown(DoubleConsts.MIN_NORMAL));
+             Math.nextDown(DoubleConsts.MIN_NORMAL));
         test("%.1a", "0x1.0p-1022",
-             FpUtils.nextDown(DoubleConsts.MIN_NORMAL));
+             Math.nextDown(DoubleConsts.MIN_NORMAL));
         test("%.11a", "0x1.ffffffffffep-1023",
              Double.parseDouble("0x0.fffffffffffp-1022"));
         test("%.1a", "0x1.0p-1022",
--- a/jdk/test/java/util/Formatter/BasicBigDecimal.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicBigDecimal.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicBigInteger.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicBigInteger.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicBoolean.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicBoolean.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicBooleanObject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicBooleanObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicByte.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicByte.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicByteObject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicByteObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicChar.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicChar.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicCharObject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicCharObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicDateTime.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicDateTime.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 import static java.util.SimpleTimeZone.*;
--- a/jdk/test/java/util/Formatter/BasicDouble.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicDouble.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
 import java.text.DateFormatSymbols;
 import java.util.*;
 
-import sun.misc.FpUtils;
 import sun.misc.DoubleConsts;
 
 
@@ -1301,9 +1300,9 @@
         test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL);
         test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL);
         test("%.11a", "0x1.00000000000p-1022",
-             FpUtils.nextDown(DoubleConsts.MIN_NORMAL));
+             Math.nextDown(DoubleConsts.MIN_NORMAL));
         test("%.1a", "0x1.0p-1022",
-             FpUtils.nextDown(DoubleConsts.MIN_NORMAL));
+             Math.nextDown(DoubleConsts.MIN_NORMAL));
         test("%.11a", "0x1.ffffffffffep-1023",
              Double.parseDouble("0x0.fffffffffffp-1022"));
         test("%.1a", "0x1.0p-1022",
--- a/jdk/test/java/util/Formatter/BasicDoubleObject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicDoubleObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicFloat.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicFloat.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicFloatObject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicFloatObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicInt.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicInt.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicIntObject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicIntObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicLong.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicLong.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicLongObject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicLongObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicShort.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicShort.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Formatter/BasicShortObject.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Formatter/BasicShortObject.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 
 
 
-
 import static java.util.Calendar.*;
 
 
--- a/jdk/test/java/util/Locale/Bug6989440.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/Locale/Bug6989440.java	Wed Oct 26 17:59:13 2011 -0700
@@ -37,26 +37,49 @@
 import sun.util.LocaleServiceProviderPool;
 
 public class Bug6989440 {
-    public static void main(String[] args) {
-        TestThread t1 = new TestThread(LocaleNameProvider.class);
-        TestThread t2 = new TestThread(TimeZoneNameProvider.class);
-        TestThread t3 = new TestThread(DateFormatProvider.class);
+    static volatile boolean failed;  // false
+    static final int THREADS = 50;
 
-        t1.start();
-        t2.start();
-        t3.start();
+    public static void main(String[] args) throws Exception {
+        Thread[] threads = new Thread[THREADS];
+        for (int i=0; i<threads.length; i++)
+            threads[i] = new TestThread();
+        for (int i=0; i<threads.length; i++)
+            threads[i].start();
+        for (int i=0; i<threads.length; i++)
+            threads[i].join();
+
+        if (failed)
+            throw new RuntimeException("Failed: check output");
     }
 
     static class TestThread extends Thread {
         private Class<? extends LocaleServiceProvider> cls;
+        private static int count;
 
         public TestThread(Class<? extends LocaleServiceProvider> providerClass) {
             cls = providerClass;
         }
 
+        public TestThread() {
+            int which = count++ % 3;
+            switch (which) {
+                case 0 : cls = LocaleNameProvider.class; break;
+                case 1 : cls = TimeZoneNameProvider.class; break;
+                case 2 : cls = DateFormatProvider.class; break;
+                default : throw new AssertionError("Should not reach here");
+            }
+        }
+
         public void run() {
-            LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls);
-            pool.getAvailableLocales();
+            try {
+                LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls);
+                pool.getAvailableLocales();
+            } catch (Exception e) {
+                System.out.println(e);
+                e.printStackTrace();
+                failed = true;
+            }
         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7091003
+ * @summary ScheduledExecutorService never executes Runnable
+ *          with corePoolSize of zero
+ * @author Chris Hegarty
+ */
+
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Verify that tasks can be run even with a core pool size of 0.
+ */
+public class ZeroCorePoolSize {
+
+    volatile boolean taskRun;
+
+    void test(String[] args) throws Throwable {
+
+        ScheduledThreadPoolExecutor pool = new ScheduledThreadPoolExecutor(0);
+        Runnable task = new Runnable() {
+            public void run() {
+                taskRun = true;
+            }
+        };
+        check(pool.getCorePoolSize() == 0);
+
+        pool.schedule(task, 1, TimeUnit.SECONDS);
+
+        pool.shutdown();
+        check(pool.awaitTermination(20L, TimeUnit.SECONDS));
+        check(pool.getCorePoolSize() == 0);
+        check(taskRun);
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    volatile int passed = 0, failed = 0;
+    void pass() {passed++;}
+    void fail() {failed++; Thread.dumpStack();}
+    void fail(String msg) {System.err.println(msg); fail();}
+    void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    void check(boolean cond) {if (cond) pass(); else fail();}
+    void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        new ZeroCorePoolSize().instanceMain(args);}
+    void instanceMain(String[] args) throws Throwable {
+        try {test(args);} catch (Throwable t) {unexpected(t);}
+        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+        if (failed > 0) throw new AssertionError("Some tests failed");}
+    abstract class F {abstract void f() throws Throwable;}
+    void THROWS(Class<? extends Throwable> k, F... fs) {
+        for (F f : fs)
+            try {f.f(); fail("Expected " + k.getName() + " not thrown");}
+            catch (Throwable t) {
+                if (k.isAssignableFrom(t.getClass())) pass();
+                else unexpected(t);}}
+}
--- a/jdk/test/java/util/logging/ParentLoggersTest.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/java/util/logging/ParentLoggersTest.java	Wed Oct 26 17:59:13 2011 -0700
@@ -6,7 +6,7 @@
  * @author  ss45998
  *
  * @build ParentLoggersTest
- * @run main ParentLoggersTest
+ * @run main/othervm ParentLoggersTest
  */
 
 /*
--- a/jdk/test/javax/security/auth/Subject/Synch.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/javax/security/auth/Subject/Synch.java	Wed Oct 26 17:59:13 2011 -0700
@@ -35,15 +35,15 @@
 import javax.security.auth.x500.X500Principal;
 
 public class Synch {
+    static volatile boolean finished = false;
     public static void main(String[] args) {
         Subject subject = new Subject();
         final Set principals = subject.getPrincipals();
         principals.add(new X500Principal("CN=Alice"));
         new Thread() {
-            { setDaemon(true); }
             public void run() {
                 Principal last = new X500Principal("CN=Bob");
-                for (int i = 0; true; i++) {
+                for (int i = 0; !finished; i++) {
                     Principal next = new X500Principal("CN=Bob" + i);
                     principals.add(next);
                     principals.remove(last);
@@ -70,5 +70,6 @@
                     }
                 });
         }
+        finished = true;
     }
 }
--- a/jdk/test/javax/security/auth/Subject/Synch2.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/javax/security/auth/Subject/Synch2.java	Wed Oct 26 17:59:13 2011 -0700
@@ -35,6 +35,7 @@
 import javax.security.auth.x500.X500Principal;
 
 public class Synch2 {
+    static volatile boolean finished = false;
     public static void main(String[] args) {
         System.setSecurityManager(new SecurityManager());
         Subject subject = new Subject();
@@ -44,12 +45,11 @@
         credentials.add("Dummy credential");
         new Thread() {
             {
-                setDaemon(true);
                 start();
             }
             public void run() {
                 X500Principal p = new X500Principal("CN=Bob");
-                while (true) {
+                while (!finished) {
                     principals.add(p);
                     principals.remove(p);
                 }
@@ -62,5 +62,6 @@
                 }
             }
         }
+        finished = true;
     }
 }
--- a/jdk/test/javax/security/auth/Subject/Synch3.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/javax/security/auth/Subject/Synch3.java	Wed Oct 26 17:59:13 2011 -0700
@@ -33,18 +33,18 @@
 import javax.security.auth.x500.X500Principal;
 
 public class Synch3 {
+    static volatile boolean finished = false;
     public static void main(String[] args) {
         Subject subject = new Subject();
         final Set principals = subject.getPrincipals();
         principals.add(new X500Principal("CN=Alice"));
         new Thread() {
             {
-                setDaemon(true);
                 start();
             }
             public void run() {
                 X500Principal p = new X500Principal("CN=Bob");
-                while (true) {
+                while (!finished) {
                     principals.add(p);
                     principals.remove(p);
                 }
@@ -53,5 +53,6 @@
         for (int i = 0; i < 1000; i++) {
             subject.getPrincipals(X500Principal.class);
         }
+        finished = true;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JColorChooser/Test6827032.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6827032
+ * @summary Color chooser with drag enabled shouldn't throw NPE
+ * @author Peter Zhelezniakov
+ * @library ../regtesthelpers
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import javax.swing.plaf.nimbus.NimbusLookAndFeel;
+
+
+public class Test6827032 {
+
+    private static volatile Point point;
+    private static JColorChooser cc;
+
+    public static void main(String[] args) throws Exception {
+        UIManager.setLookAndFeel(new NimbusLookAndFeel());
+
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
+                point = previewPanel.getLocationOnScreen();
+            }
+        });
+
+        point.translate(5, 5);
+
+        robot.mouseMove(point.x, point.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame(Test6827032.class.getName());
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        cc = new JColorChooser();
+        cc.setDragEnabled(true);
+        frame.add(cc);
+        frame.pack();
+        frame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/SwingUtilities/7088744/bug7088744.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7088744
+   @summary SwingUtilities.isMiddleMouseButton does not work with ALT/Meta keys
+   @author Pavel Porvatov
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+public class bug7088744 {
+    private static volatile JLabel label;
+
+    private static volatile Point point;
+
+    private static final int MOUSE_CLICKED = 1;
+    private static final int MOUSE_PRESSED = 2;
+    private static final int MOUSE_RELEASED = 3;
+
+    // Pair with (EventType, Mouse Button)
+    private static final int[][] BUTTON_EVENTS_SEQUENCE = {
+            {MOUSE_PRESSED, 1},
+            {MOUSE_PRESSED, 2},
+            {MOUSE_PRESSED, 3},
+            {MOUSE_RELEASED, 1},
+            {MOUSE_CLICKED, 1},
+            {MOUSE_RELEASED, 2},
+            {MOUSE_CLICKED, 2},
+            {MOUSE_RELEASED, 3},
+            {MOUSE_CLICKED, 3}
+    };
+
+    private static int eventCount;
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                Component source = new JLabel();
+
+                MouseEvent mouseEventNoButtons = new MouseEvent(source, 0, System.currentTimeMillis(),
+                        Event.ALT_MASK | Event.META_MASK | InputEvent.ALT_DOWN_MASK | InputEvent.META_DOWN_MASK,
+                        0, 0, 0, false, MouseEvent.NOBUTTON);
+
+                // isLeftMouseButton
+                if (SwingUtilities.isLeftMouseButton(mouseEventNoButtons)) {
+                    throw new RuntimeException("SwingUtilities.isLeftMouseButton fails 1");
+                }
+
+                if (!SwingUtilities.isLeftMouseButton(new MouseEvent(source, 0, System.currentTimeMillis(),
+                        InputEvent.BUTTON1_MASK, 0, 0, 1, false, MouseEvent.BUTTON1))) {
+                    throw new RuntimeException("SwingUtilities.isLeftMouseButton fails 2");
+                }
+
+                if (!SwingUtilities.isLeftMouseButton(new MouseEvent(source, 0, System.currentTimeMillis(),
+                        InputEvent.BUTTON1_DOWN_MASK, 0, 0, 1, false, MouseEvent.BUTTON1))) {
+                    throw new RuntimeException("SwingUtilities.isLeftMouseButton fails 3");
+                }
+
+                // isMiddleMouseButton
+                if (SwingUtilities.isMiddleMouseButton(mouseEventNoButtons)) {
+                    throw new RuntimeException("SwingUtilities.isMiddleMouseButton fails 1");
+                }
+
+                if (!SwingUtilities.isMiddleMouseButton(new MouseEvent(source, 0, System.currentTimeMillis(),
+                        InputEvent.BUTTON2_MASK, 0, 0, 1, false, MouseEvent.BUTTON2))) {
+                    throw new RuntimeException("SwingUtilities.isMiddleMouseButton fails 2");
+                }
+
+                if (!SwingUtilities.isMiddleMouseButton(new MouseEvent(source, 0, System.currentTimeMillis(),
+                        InputEvent.BUTTON2_DOWN_MASK, 0, 0, 1, false, MouseEvent.BUTTON2))) {
+                    throw new RuntimeException("SwingUtilities.isMiddleMouseButton fails 3");
+                }
+
+                // isRightMouseButton
+                if (SwingUtilities.isRightMouseButton(mouseEventNoButtons)) {
+                    throw new RuntimeException("SwingUtilities.isRightMouseButton fails 1");
+                }
+
+                if (!SwingUtilities.isRightMouseButton(new MouseEvent(source, 0, System.currentTimeMillis(),
+                        InputEvent.BUTTON3_MASK, 0, 0, 1, false, MouseEvent.BUTTON3))) {
+                    throw new RuntimeException("SwingUtilities.isRightMouseButton fails 2");
+                }
+
+                if (!SwingUtilities.isRightMouseButton(new MouseEvent(source, 0, System.currentTimeMillis(),
+                        InputEvent.BUTTON3_DOWN_MASK, 0, 0, 1, false, MouseEvent.BUTTON3))) {
+                    throw new RuntimeException("SwingUtilities.isRightMouseButton fails 3");
+                }
+            }
+        });
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                JFrame frame = new JFrame();
+
+                label = new JLabel("A label");
+
+                label.addMouseListener(new MouseAdapter() {
+                    public void mouseClicked(MouseEvent e) {
+                        processEvent(MOUSE_CLICKED, e);
+                    }
+
+                    public void mousePressed(MouseEvent e) {
+                        processEvent(MOUSE_PRESSED, e);
+                    }
+
+                    public void mouseReleased(MouseEvent e) {
+                        processEvent(MOUSE_RELEASED, e);
+                    }
+                });
+                frame.add(label);
+                frame.setSize(200, 100);
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                frame.setVisible(true);
+            }
+        });
+
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        toolkit.realSync();
+
+        // On Linux platforms realSync doesn't guaranties setSize completion
+        Thread.sleep(1000);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                point = label.getLocationOnScreen();
+            }
+        });
+
+        Robot robot = new Robot();
+
+        robot.setAutoDelay(100);
+        robot.mouseMove(point.x, point.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mousePress(InputEvent.BUTTON2_MASK);
+        robot.mousePress(InputEvent.BUTTON3_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON2_MASK);
+        robot.mouseRelease(InputEvent.BUTTON3_MASK);
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                if (eventCount != BUTTON_EVENTS_SEQUENCE.length) {
+                    throw new RuntimeException("Not all events received");
+                }
+
+            }
+        });
+
+        System.out.println("Test passed");
+    }
+
+    private static void processEvent(int eventType, MouseEvent e) {
+        if (eventCount >= BUTTON_EVENTS_SEQUENCE.length) {
+            throw new RuntimeException("Unexpected event " + e);
+        }
+
+        int[] arr = BUTTON_EVENTS_SEQUENCE[eventCount];
+
+        if (arr[0] != eventType) {
+            throw new RuntimeException("Unexpected eventType " + eventType + "on step " + eventCount);
+        }
+
+        boolean result;
+
+        switch (arr[1]) {
+            case 1:
+                result = SwingUtilities.isLeftMouseButton(e);
+
+                break;
+
+            case 2:
+                result = SwingUtilities.isMiddleMouseButton(e);
+
+                break;
+
+            case 3:
+                result = SwingUtilities.isRightMouseButton(e);
+
+                break;
+
+            default:
+                throw new RuntimeException("Incorrect arr[1] on step " + eventCount);
+        }
+
+        if (!result) {
+            throw new RuntimeException("Test failed on step " + eventCount);
+        }
+
+        eventCount++;
+    }
+}
--- a/jdk/test/javax/swing/regtesthelpers/Util.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java	Wed Oct 26 17:59:13 2011 -0700
@@ -116,4 +116,28 @@
 
         System.out.println("Got OOME");
     }
+
+    /**
+     * Find a sub component by class name.
+     * Always run this method on the EDT thread
+     */
+    public static Component findSubComponent(Component parent, String className) {
+        String parentClassName = parent.getClass().getName();
+
+        if (parentClassName.contains(className)) {
+            return parent;
+        }
+
+        if (parent instanceof Container) {
+            for (Component child : ((Container) parent).getComponents()) {
+                Component subComponent = findSubComponent(child, className);
+
+                if (subComponent != null) {
+                    return subComponent;
+                }
+            }
+        }
+
+        return null;
+    }
 }
--- a/jdk/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/jvmstat/perfdata/PrologSanity/PrologSizeSanityCheck.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 4990825
+ * @run main/othervm -XX:+UsePerfData  PrologSizeSanityCheck
  * @summary prolog size and overflow sanity checks
  */
 
--- a/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java	Wed Oct 26 17:59:13 2011 -0700
@@ -154,7 +154,7 @@
     /* run javac <args> */
     static void compile(String... args) {
         debug("Running: javac " + Arrays.toString(args));
-        com.sun.tools.javac.main.Main compiler = new com.sun.tools.javac.main.Main("javac");
+        com.sun.tools.javac.Main compiler = new com.sun.tools.javac.Main();
         if (compiler.compile(args) != 0) {
              throw new RuntimeException("javac failed: args=" + Arrays.toString(args));
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/auto/AcceptorSubKey.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7077646
+ * @summary gssapi wrap for CFX per-message tokens always set FLAG_ACCEPTOR_SUBKEY
+ * @compile -XDignore.symbol.file AcceptorSubKey.java
+ * @run main/othervm AcceptorSubKey
+ */
+
+import java.util.Arrays;
+import sun.security.jgss.GSSUtil;
+
+// The basic krb5 test skeleton you can copy from
+public class AcceptorSubKey {
+
+    public static void main(String[] args) throws Exception {
+
+        new OneKDC(null).writeJAASConf();
+
+        Context c, s;
+        c = Context.fromJAAS("client");
+        s = Context.fromJAAS("server");
+
+        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);
+        s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);
+
+        Context.handshake(c, s);
+
+        byte[] msg = "i say high --".getBytes();
+        byte[] wrapped = s.wrap(msg, false);
+
+        // FLAG_ACCEPTOR_SUBKEY is 4
+        int flagOn = wrapped[2] & 4;
+        if (flagOn != 0) {
+            throw new Exception("Java GSS should not have set acceptor subkey");
+        }
+
+        s.dispose();
+        c.dispose();
+    }
+}
--- a/jdk/test/sun/security/krb5/auto/Context.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/security/krb5/auto/Context.java	Wed Oct 26 17:59:13 2011 -0700
@@ -375,6 +375,89 @@
         }
     }
 
+    public byte[] wrap(byte[] t, final boolean privacy)
+            throws Exception {
+        return doAs(new Action() {
+            @Override
+            public byte[] run(Context me, byte[] input) throws Exception {
+                System.out.printf("wrap %s privacy from %s: ", privacy?"with":"without", me.name);
+                MessageProp p1 = new MessageProp(0, privacy);
+                byte[] out;
+                if (usingStream) {
+                    ByteArrayOutputStream os = new ByteArrayOutputStream();
+                    me.x.wrap(new ByteArrayInputStream(input), os, p1);
+                    out = os.toByteArray();
+                } else {
+                    out = me.x.wrap(input, 0, input.length, p1);
+                }
+                System.out.println(printProp(p1));
+                return out;
+            }
+        }, t);
+    }
+
+    public byte[] unwrap(byte[] t, final boolean privacy)
+            throws Exception {
+        return doAs(new Action() {
+            @Override
+            public byte[] run(Context me, byte[] input) throws Exception {
+                System.out.printf("unwrap %s privacy from %s: ", privacy?"with":"without", me.name);
+                MessageProp p1 = new MessageProp(0, privacy);
+                byte[] bytes;
+                if (usingStream) {
+                    ByteArrayOutputStream os = new ByteArrayOutputStream();
+                    me.x.unwrap(new ByteArrayInputStream(input), os, p1);
+                    bytes = os.toByteArray();
+                } else {
+                    bytes = me.x.unwrap(input, 0, input.length, p1);
+                }
+                System.out.println(printProp(p1));
+                return bytes;
+            }
+        }, t);
+    }
+
+    public byte[] getMic(byte[] t) throws Exception {
+        return doAs(new Action() {
+            @Override
+            public byte[] run(Context me, byte[] input) throws Exception {
+                MessageProp p1 = new MessageProp(0, true);
+                byte[] bytes;
+                p1 = new MessageProp(0, true);
+                System.out.printf("getMic from %s: ", me.name);
+                if (usingStream) {
+                    ByteArrayOutputStream os = new ByteArrayOutputStream();
+                    me.x.getMIC(new ByteArrayInputStream(input), os, p1);
+                    bytes = os.toByteArray();
+                } else {
+                    bytes = me.x.getMIC(input, 0, input.length, p1);
+                }
+                System.out.println(printProp(p1));
+                return bytes;
+            }
+        }, t);
+    }
+
+    public void verifyMic(byte[] t, final byte[] msg) throws Exception {
+        doAs(new Action() {
+            @Override
+            public byte[] run(Context me, byte[] input) throws Exception {
+                MessageProp p1 = new MessageProp(0, true);
+                System.out.printf("verifyMic from %s: ", me.name);
+                if (usingStream) {
+                    me.x.verifyMIC(new ByteArrayInputStream(input),
+                            new ByteArrayInputStream(msg), p1);
+                } else {
+                    me.x.verifyMIC(input, 0, input.length,
+                            msg, 0, msg.length,
+                            p1);
+                }
+                System.out.println(printProp(p1));
+                return null;
+            }
+        }, t);
+    }
+
     /**
      * Transmits a message from one Context to another. The sender wraps the
      * message and sends it to the receiver. The receiver unwraps it, creates
@@ -390,73 +473,13 @@
         final byte[] messageBytes = message.getBytes();
         System.out.printf("-------------------- TRANSMIT from %s to %s------------------------\n",
                 s1.name, s2.name);
-
-        byte[] t = s1.doAs(new Action() {
-            @Override
-            public byte[] run(Context me, byte[] dummy) throws Exception {
-                System.out.println("wrap");
-                MessageProp p1 = new MessageProp(0, true);
-                byte[] out;
-                if (usingStream) {
-                    ByteArrayOutputStream os = new ByteArrayOutputStream();
-                    me.x.wrap(new ByteArrayInputStream(messageBytes), os, p1);
-                    out = os.toByteArray();
-                } else {
-                    out = me.x.wrap(messageBytes, 0, messageBytes.length, p1);
-                }
-                System.out.println(printProp(p1));
-                return out;
-            }
-        }, null);
-
-        t = s2.doAs(new Action() {
-            @Override
-            public byte[] run(Context me, byte[] input) throws Exception {
-                MessageProp p1 = new MessageProp(0, true);
-                byte[] bytes;
-                if (usingStream) {
-                    ByteArrayOutputStream os = new ByteArrayOutputStream();
-                    me.x.unwrap(new ByteArrayInputStream(input), os, p1);
-                    bytes = os.toByteArray();
-                } else {
-                    bytes = me.x.unwrap(input, 0, input.length, p1);
-                }
-                if (!Arrays.equals(messageBytes, bytes))
-                    throw new Exception("wrap/unwrap mismatch");
-                System.out.println("unwrap");
-                System.out.println(printProp(p1));
-                p1 = new MessageProp(0, true);
-                System.out.println("getMIC");
-                if (usingStream) {
-                    ByteArrayOutputStream os = new ByteArrayOutputStream();
-                    me.x.getMIC(new ByteArrayInputStream(messageBytes), os, p1);
-                    bytes = os.toByteArray();
-                } else {
-                    bytes = me.x.getMIC(messageBytes, 0, messageBytes.length, p1);
-                }
-                System.out.println(printProp(p1));
-                return bytes;
-            }
-        }, t);
-
-        // Re-unwrap should make p2.isDuplicateToken() returns true
-        s1.doAs(new Action() {
-            @Override
-            public byte[] run(Context me, byte[] input) throws Exception {
-                MessageProp p1 = new MessageProp(0, true);
-                System.out.println("verifyMIC");
-                if (usingStream) {
-                    me.x.verifyMIC(new ByteArrayInputStream(input),
-                            new ByteArrayInputStream(messageBytes), p1);
-                } else {
-                    me.x.verifyMIC(input, 0, input.length,
-                            messageBytes, 0, messageBytes.length,
-                            p1);
-                }
-                System.out.println(printProp(p1));
-                return null;
-            }
-        }, t);
+        byte[] wrapped = s1.wrap(messageBytes, true);
+        byte[] unwrapped = s2.unwrap(wrapped, true);
+        if (!Arrays.equals(messageBytes, unwrapped)) {
+            throw new Exception("wrap/unwrap mismatch");
+        }
+        byte[] mic = s2.getMic(unwrapped);
+        s1.verifyMic(mic, messageBytes);
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/auto/NoInitNoKeytab.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7089889
+ * @summary Krb5LoginModule.login() throws an exception if used without a keytab
+ * @compile -XDignore.symbol.file NoInitNoKeytab.java
+ * @run main/othervm NoInitNoKeytab
+ */
+
+import java.io.FileOutputStream;
+import sun.security.jgss.GSSUtil;
+
+// The basic krb5 test skeleton you can copy from
+public class NoInitNoKeytab {
+
+    public static void main(String[] args) throws Exception {
+
+        new OneKDC(null).writeJAASConf();
+        try (FileOutputStream fos =
+                new FileOutputStream(OneKDC.JAAS_CONF, true)) {
+            fos.write((
+                "noinit {\n" +
+                "    com.sun.security.auth.module.Krb5LoginModule required\n" +
+                "    principal=\"" + OneKDC.USER + "\"\n" +
+                "    useKeyTab=false\n" +
+                "    isInitiator=false\n" +
+                "    storeKey=true;\n};\n").getBytes());
+        }
+        Context c, s;
+        c = Context.fromJAAS("client");
+        s = Context.fromJAAS("noinit");
+
+        c.startAsClient(OneKDC.USER, GSSUtil.GSS_SPNEGO_MECH_OID);
+        s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);
+
+        Context.handshake(c, s);
+
+        Context.transmit("i say high --", c, s);
+        Context.transmit("   you say low", s, c);
+
+        s.dispose();
+        c.dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/auto/RRC.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7077640
+ * @summary gss wrap for cfx doesn't handle rrc != 0
+ * @compile -XDignore.symbol.file RRC.java
+ * @run main/othervm RRC
+ */
+
+import java.util.Arrays;
+import sun.security.jgss.GSSUtil;
+
+// The basic krb5 test skeleton you can copy from
+public class RRC {
+
+    public static void main(String[] args) throws Exception {
+
+        new OneKDC(null).writeJAASConf();
+
+        Context c, s;
+        c = Context.fromJAAS("client");
+        s = Context.fromJAAS("server");
+
+        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_SPNEGO_MECH_OID);
+        s.startAsServer(GSSUtil.GSS_SPNEGO_MECH_OID);
+
+        Context.handshake(c, s);
+
+        byte[] msg = "i say high --".getBytes();
+        byte[] wrapped = c.wrap(msg, false);
+
+        // Simulate RRC equals to EC
+        int rrc = wrapped[5];
+        byte[] rotated = new byte[wrapped.length];
+        System.arraycopy(wrapped, 0, rotated, 0, 16);
+        System.arraycopy(wrapped, wrapped.length-rrc, rotated, 16, rrc);
+        System.arraycopy(wrapped, 16, rotated, 16+rrc, wrapped.length-16-rrc);
+        rotated[7] = (byte)rrc;
+
+        byte[] unwrapped = s.unwrap(rotated, false);
+        if (!Arrays.equals(msg, unwrapped)) {
+            throw new Exception("Failure");
+        }
+
+        s.dispose();
+        c.dispose();
+    }
+}
--- a/jdk/test/sun/tools/common/ApplicationSetup.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/common/ApplicationSetup.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 {
   appOutput="${TESTCLASSES}/Application.out"
 
-  ${JAVA} -classpath "${TESTCLASSES}" "$@" > "$appOutput" 2>&1 &
+  ${JAVA} -XX:+UsePerfData -classpath "${TESTCLASSES}" "$@" > "$appOutput" 2>&1 &
   appJavaPid="$!"
   appOtherPid=
   appPidList="$appJavaPid"
@@ -131,7 +131,7 @@
 #
 stopApplication()
 {
-  $JAVA -classpath "${TESTCLASSES}" ShutdownSimpleApplication $1
+  $JAVA -XX:+UsePerfData -classpath "${TESTCLASSES}" ShutdownSimpleApplication $1
 }
 
 
--- a/jdk/test/sun/tools/jinfo/Basic.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jinfo/Basic.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -46,39 +46,39 @@
 
 if [ $isWindows = false ]; then
     # -sysprops option
-    ${JINFO} -sysprops $appJavaPid
+    ${JINFO} -J-XX:+UsePerfData -sysprops $appJavaPid
     if [ $? != 0 ]; then failed=1; fi
 
     # -flags option
-    ${JINFO} -flags $appJavaPid
+    ${JINFO} -J-XX:+UsePerfData -flags $appJavaPid
     if [ $? != 0 ]; then failed=1; fi
 
     # no option
-    ${JINFO} $appJavaPid
+    ${JINFO} -J-XX:+UsePerfData $appJavaPid
     if [ $? != 0 ]; then failed=1; fi
 
 fi
 
 
 # -flag option
-${JINFO} -flag +PrintGC $appJavaPid
+${JINFO} -J-XX:+UsePerfData -flag +PrintGC $appJavaPid
 if [ $? != 0 ]; then failed=1; fi 
 
-${JINFO} -flag -PrintGC $appJavaPid
+${JINFO} -J-XX:+UsePerfData -flag -PrintGC $appJavaPid
 if [ $? != 0 ]; then failed=1; fi
 
-${JINFO} -flag PrintGC $appJavaPid
+${JINFO} -J-XX:+UsePerfData -flag PrintGC $appJavaPid
 if [ $? != 0 ]; then failed=1; fi
 
 if $isSolaris; then
 
-    ${JINFO} -flag +ExtendedDTraceProbes $appJavaPid
+    ${JINFO} -J-XX:+UsePerfData -flag +ExtendedDTraceProbes $appJavaPid
     if [ $? != 0 ]; then failed=1; fi
 
-    ${JINFO} -flag -ExtendedDTraceProbes $appJavaPid
+    ${JINFO} -J-XX:+UsePerfData -flag -ExtendedDTraceProbes $appJavaPid
     if [ $? != 0 ]; then failed=1; fi
 
-    ${JINFO} -flag ExtendedDTraceProbes $appJavaPid
+    ${JINFO} -J-XX:+UsePerfData -flag ExtendedDTraceProbes $appJavaPid
     if [ $? != 0 ]; then failed=1; fi
 
 fi
--- a/jdk/test/sun/tools/jmap/Basic.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jmap/Basic.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -45,15 +45,15 @@
 failed=0
 
 # -histo[:live] option
-${JMAP} -histo $appJavaPid
+${JMAP} -J-XX:+UsePerfData -histo $appJavaPid
 if [ $? != 0 ]; then failed=1; fi
 
-${JMAP} -histo:live $appJavaPid
+${JMAP} -J-XX:+UsePerfData -histo:live $appJavaPid
 if [ $? != 0 ]; then failed=1; fi
 
 # -dump option
 DUMPFILE="java_pid${appJavaPid}.hprof"
-${JMAP} -dump:format=b,file=${DUMPFILE} $appJavaPid
+${JMAP} -J-XX:+UsePerfData -dump:format=b,file=${DUMPFILE} $appJavaPid
 if [ $? != 0 ]; then failed=1; fi
 
 # check that heap dump is parsable
@@ -64,7 +64,7 @@
 rm ${DUMPFILE}
 
 # -dump:live option
-${JMAP} -dump:live,format=b,file=${DUMPFILE} $appJavaPid
+${JMAP} -J-XX:+UsePerfData -dump:live,format=b,file=${DUMPFILE} $appJavaPid
 if [ $? != 0 ]; then failed=1; fi
 
 # check that heap dump is parsable
--- a/jdk/test/sun/tools/jps/jps-Defaults.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-Defaults.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} 2>&1 | awk -f ${TESTSRC}/jps_Output1.awk
+${JPS} -J-XX:+UsePerfData 2>&1 | awk -f ${TESTSRC}/jps_Output1.awk
--- a/jdk/test/sun/tools/jps/jps-V_2.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-V_2.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011,Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -J-XX:Flags=${TESTSRC}/vmflags -V | awk -f ${TESTSRC}/jps-V_Output2.awk
+${JPS} -J-XX:+UsePerfData -J-XX:Flags=${TESTSRC}/vmflags -V | awk -f ${TESTSRC}/jps-V_Output2.awk
--- a/jdk/test/sun/tools/jps/jps-Vm_2.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-Vm_2.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -J-XX:Flags=${TESTSRC}/vmflags -Vm | awk -f ${TESTSRC}/jps-Vm_Output2.awk
+${JPS} -J-XX:+UsePerfData -J-XX:Flags=${TESTSRC}/vmflags -Vm | awk -f ${TESTSRC}/jps-Vm_Output2.awk
--- a/jdk/test/sun/tools/jps/jps-Vvm.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-Vvm.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -J-XX:Flags=${TESTSRC}/vmflags -Vvm | awk -f ${TESTSRC}/jps-Vvm_Output1.awk
+${JPS} -J-XX:+UsePerfData -J-XX:Flags=${TESTSRC}/vmflags -Vvm | awk -f ${TESTSRC}/jps-Vvm_Output1.awk
--- a/jdk/test/sun/tools/jps/jps-Vvml.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-Vvml.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -J-XX:Flags=${TESTSRC}/vmflags -Vvml | awk -f ${TESTSRC}/jps-Vvml_Output1.awk
+${JPS} -J-XX:+UsePerfData -J-XX:Flags=${TESTSRC}/vmflags -Vvml | awk -f ${TESTSRC}/jps-Vvml_Output1.awk
--- a/jdk/test/sun/tools/jps/jps-Vvml_2.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-Vvml_2.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,10 @@
 # any args to Sleeper.main() or any jvm flags or options, as we
 # need to inspect jps output for the no args condition.
 #
+# Note: this test can not pass on a VM with UsePerfData disabled by default,
+# and we can not set -XX:+UsePerfData as that invalidates the test premise of
+# there being no jvm flags
+
 ${JAVA} -cp ${TESTCLASSES} Sleeper &
 SLEEPER_PID=$!
 
--- a/jdk/test/sun/tools/jps/jps-help.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-help.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 JPS="${TESTJAVA}/bin/jps"
 
 rm -f jps.out 2>/dev/null
-${JPS} -? > jps.out 2>&1
+${JPS} -J-XX:+UsePerfData -? > jps.out 2>&1
 
 diff -w jps.out ${TESTSRC}/usage.out
 if [ $? != 0 ]
@@ -44,7 +44,7 @@
 fi
 
 rm -f jps.out 2>/dev/null
-${JPS} -help > jps.out 2>&1
+${JPS} -J-XX:+UsePerfData -help > jps.out 2>&1
 
 diff -w jps.out ${TESTSRC}/usage.out
 if [ $? != 0 ]
--- a/jdk/test/sun/tools/jps/jps-l_1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-l_1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -l 2>&1 | awk -f ${TESTSRC}/jps-l_Output1.awk
+${JPS} -J-XX:+UsePerfData -l 2>&1 | awk -f ${TESTSRC}/jps-l_Output1.awk
--- a/jdk/test/sun/tools/jps/jps-l_2.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-l_2.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -l | awk -f ${TESTSRC}/jps-l_Output2.awk
+${JPS} -J-XX:+UsePerfData -l | awk -f ${TESTSRC}/jps-l_Output2.awk
--- a/jdk/test/sun/tools/jps/jps-lm.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-lm.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -lm | awk -f ${TESTSRC}/jps-lm_Output1.awk
+${JPS} -J-XX:+UsePerfData -lm | awk -f ${TESTSRC}/jps-lm_Output1.awk
--- a/jdk/test/sun/tools/jps/jps-m.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-m.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -m | awk -f ${TESTSRC}/jps-m_Output1.awk
+${JPS} -J-XX:+UsePerfData -m | awk -f ${TESTSRC}/jps-m_Output1.awk
--- a/jdk/test/sun/tools/jps/jps-m_2.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-m_2.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -46,10 +46,10 @@
 # any args to Sleeper.main(), as we need to inspect jps output
 # for the no args condition.
 #
-${JAVA} -cp ${TESTCLASSES} Sleeper &
+${JAVA} -XX:+UsePerfData -cp ${TESTCLASSES} Sleeper &
 SLEEPER_PID=$!
 
-${JPS} -m | awk -f ${TESTSRC}/jps-m_Output2.awk
+${JPS} -J-XX:+UsePerfData -m | awk -f ${TESTSRC}/jps-m_Output2.awk
 RC=$?
 
 cleanup
--- a/jdk/test/sun/tools/jps/jps-q.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-q.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -q | awk -f ${TESTSRC}/jps-q_Output1.awk
+${JPS} -J-XX:+UsePerfData -q | awk -f ${TESTSRC}/jps-q_Output1.awk
--- a/jdk/test/sun/tools/jps/jps-v_1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-v_1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -J-XX:+UseParallelGC -v | awk -f ${TESTSRC}/jps-v_Output1.awk
+${JPS} -J-XX:+UsePerfData -J-XX:+UseParallelGC -v | awk -f ${TESTSRC}/jps-v_Output1.awk
--- a/jdk/test/sun/tools/jps/jps-vm_1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jps/jps-vm_1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JPS="${TESTJAVA}/bin/jps"
 
-${JPS} -J-XX:+UseParallelGC -vm | awk -f ${TESTSRC}/jps-vm_Output1.awk
+${JPS} -J-XX:+UsePerfData -J-XX:+UseParallelGC -vm | awk -f ${TESTSRC}/jps-vm_Output1.awk
--- a/jdk/test/sun/tools/jstack/Basic.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstack/Basic.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -45,11 +45,11 @@
 failed=0
 
 # normal
-$JSTACK $appJavaPid 2>&1
+$JSTACK -J-XX:+UsePerfData $appJavaPid 2>&1
 if [ $? != 0 ]; then failed=1; fi
 
 # long
-$JSTACK -l $appJavaPid 2>&1
+$JSTACK -J-XX:+UsePerfData -l $appJavaPid 2>&1
 if [ $? != 0 ]; then failed=1; fi
 
 set -e
--- a/jdk/test/sun/tools/jstat/jstatClassOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatClassOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -class 0 2>&1 | awk -f ${TESTSRC}/classOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -class 0 2>&1 | awk -f ${TESTSRC}/classOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatClassloadOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatClassloadOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -classload -J-Djstat.showUnsupported=true 0 2>&1 | awk -f ${TESTSRC}/classloadOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -classload -J-Djstat.showUnsupported=true 0 2>&1 | awk -f ${TESTSRC}/classloadOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatCompilerOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatCompilerOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -compiler 0 2>&1 | awk -f ${TESTSRC}/compilerOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -compiler 0 2>&1 | awk -f ${TESTSRC}/compilerOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatFileURITest1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatFileURITest1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -40,12 +40,12 @@
     # characters into forward slash characters in an effort to convert
     # TESTSRC into a canonical form useable as URI path.
     cp ${TESTSRC}/hsperfdata_3433 .
-    ${JSTAT} -gcutil file:/`pwd`/hsperfdata_3433 2>&1 | awk -f ${TESTSRC}/fileURITest1.awk
+    ${JSTAT} -J-XX:+UsePerfData -gcutil file:/`pwd`/hsperfdata_3433 2>&1 | awk -f ${TESTSRC}/fileURITest1.awk
     RC=$?
     rm -f hsperfdata_3433 2>&1 > /dev/null
     ;;
 *)
-    ${JSTAT} -gcutil file:${TESTSRC}/hsperfdata_3433 2>&1 | awk -f ${TESTSRC}/fileURITest1.awk
+    ${JSTAT} -J-XX:+UsePerfData -gcutil file:${TESTSRC}/hsperfdata_3433 2>&1 | awk -f ${TESTSRC}/fileURITest1.awk
     RC=$?
     ;;
 esac
--- a/jdk/test/sun/tools/jstat/jstatGcCapacityOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatGcCapacityOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gccapacity 0 2>&1 | awk -f ${TESTSRC}/gcCapacityOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gccapacity 0 2>&1 | awk -f ${TESTSRC}/gcCapacityOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatGcCauseOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatGcCauseOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -37,4 +37,4 @@
 # class machine, ergonomics will automatically use UseParallelGC.
 # The UseParallelGC collector does not currently update the gc cause counters.
 
-${JSTAT} -J-XX:+UseSerialGC -gccause 0 2>&1 | awk -f ${TESTSRC}/gcCauseOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -J-XX:+UseSerialGC -gccause 0 2>&1 | awk -f ${TESTSRC}/gcCauseOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatGcNewCapacityOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatGcNewCapacityOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcnewcapacity 0 2>&1 | awk -f ${TESTSRC}/gcNewCapacityOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gcnewcapacity 0 2>&1 | awk -f ${TESTSRC}/gcNewCapacityOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatGcNewOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatGcNewOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcnew 0 2>&1 | awk -f ${TESTSRC}/gcNewOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gcnew 0 2>&1 | awk -f ${TESTSRC}/gcNewOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatGcOldCapacityOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatGcOldCapacityOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcoldcapacity 0 2>&1 | awk -f ${TESTSRC}/gcOldCapacityOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gcoldcapacity 0 2>&1 | awk -f ${TESTSRC}/gcOldCapacityOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatGcOldOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatGcOldOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcold 0 2>&1 | awk -f ${TESTSRC}/gcOldOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gcold 0 2>&1 | awk -f ${TESTSRC}/gcOldOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatGcOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatGcOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gc 0 2>&1 | awk -f ${TESTSRC}/gcOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gc 0 2>&1 | awk -f ${TESTSRC}/gcOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatGcPermCapacityOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatGcPermCapacityOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcpermcapacity 0 2>&1 | awk -f ${TESTSRC}/gcPermCapacityOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gcpermcapacity 0 2>&1 | awk -f ${TESTSRC}/gcPermCapacityOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatHelp.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatHelp.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 JSTAT="${TESTJAVA}/bin/jstat"
 
 rm -f jstat.out 2>/dev/null
-${JSTAT} -? > jstat.out 2>&1
+${JSTAT} -J-XX:+UsePerfData -? > jstat.out 2>&1
 
 diff -w jstat.out ${TESTSRC}/usage.out
 if [ $? != 0 ]
@@ -43,7 +43,7 @@
 fi
 
 rm -f jstat.out 2>/dev/null
-${JSTAT} -help > jstat.out 2>&1
+${JSTAT} -J-XX:+UsePerfData -help > jstat.out 2>&1
 
 diff -w jstat.out ${TESTSRC}/usage.out
 if [ $? != 0 ]
--- a/jdk/test/sun/tools/jstat/jstatLineCounts1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatLineCounts1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcutil 0 250 5 2>&1 | awk -f ${TESTSRC}/lineCounts1.awk
+${JSTAT} -J-XX:+UsePerfData -gcutil 0 250 5 2>&1 | awk -f ${TESTSRC}/lineCounts1.awk
--- a/jdk/test/sun/tools/jstat/jstatLineCounts2.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatLineCounts2.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcutil 0 2>&1 | awk -f ${TESTSRC}/lineCounts2.awk
+${JSTAT} -J-XX:+UsePerfData -gcutil 0 2>&1 | awk -f ${TESTSRC}/lineCounts2.awk
--- a/jdk/test/sun/tools/jstat/jstatLineCounts3.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatLineCounts3.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcutil -h 10 0 250 10 2>&1 | awk -f ${TESTSRC}/lineCounts3.awk
+${JSTAT} -J-XX:+UsePerfData -gcutil -h 10 0 250 10 2>&1 | awk -f ${TESTSRC}/lineCounts3.awk
--- a/jdk/test/sun/tools/jstat/jstatLineCounts4.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatLineCounts4.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcutil -h 10 0 250 11 2>&1 | awk -f ${TESTSRC}/lineCounts4.awk
+${JSTAT} -J-XX:+UsePerfData -gcutil -h 10 0 250 11 2>&1 | awk -f ${TESTSRC}/lineCounts4.awk
--- a/jdk/test/sun/tools/jstat/jstatOptions1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatOptions1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,8 @@
 JSTAT="${TESTJAVA}/bin/jstat"
 
 rm -f jstat.out1 jstat.out2 2>/dev/null
-${JSTAT} -options > jstat.out1 2>&1
-${JSTAT} -options -J-Djstat.showUnsupported=true > jstat.out2 2>&1
+${JSTAT} -J-XX:+UsePerfData -options > jstat.out1 2>&1
+${JSTAT} -J-XX:+UsePerfData -options -J-Djstat.showUnsupported=true > jstat.out2 2>&1
 
 diff -w jstat.out1 ${TESTSRC}/options1.out
 diff -w jstat.out2 ${TESTSRC}/options2.out
--- a/jdk/test/sun/tools/jstat/jstatPrintCompilationOutput1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatPrintCompilationOutput1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -35,4 +35,4 @@
 
 # run with -Xcomp as jstat may complete too quickly to assure
 # that compilation occurs.
-${JSTAT} -J-Xcomp -printcompilation 0 2>&1 | awk -f ${TESTSRC}/printCompilationOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -J-Xcomp -printcompilation 0 2>&1 | awk -f ${TESTSRC}/printCompilationOutput1.awk
--- a/jdk/test/sun/tools/jstat/jstatSnap1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatSnap1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -snap 0 2>&1 | awk -f ${TESTSRC}/snap1.awk
+${JSTAT} -J-XX:+UsePerfData -snap 0 2>&1 | awk -f ${TESTSRC}/snap1.awk
--- a/jdk/test/sun/tools/jstat/jstatSnap2.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatSnap2.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -J-Djstat.showUnsupported=true -snap 0 2>&1 | awk -f ${TESTSRC}/snap2.awk
+${JSTAT} -J-XX:+UsePerfData -J-Djstat.showUnsupported=true -snap 0 2>&1 | awk -f ${TESTSRC}/snap2.awk
--- a/jdk/test/sun/tools/jstat/jstatTimeStamp1.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstat/jstatTimeStamp1.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,4 +33,4 @@
 
 JSTAT="${TESTJAVA}/bin/jstat"
 
-${JSTAT} -gcutil -t 0 2>&1 | awk -f ${TESTSRC}/timeStamp1.awk
+${JSTAT} -J-XX:+UsePerfData -gcutil -t 0 2>&1 | awk -f ${TESTSRC}/timeStamp1.awk
--- a/jdk/test/sun/tools/jstatd/jstatdDefaults.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstatd/jstatdDefaults.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -45,13 +45,13 @@
 
 JSTATD_OUT="jstatd_$$.out"
 
-${JSTATD} -J-Djava.security.policy=${TESTSRC}/all.policy 2>&1 > ${JSTATD_OUT} &
+${JSTATD} -J-XX:+UsePerfData -J-Djava.security.policy=${TESTSRC}/all.policy 2>&1 > ${JSTATD_OUT} &
 JSTATD_PID=$!
 
 echo "jstatd started as pid ${JSTATD_PID}"
 sleep 3
 
-${JPS} ${HOSTNAME} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
+${JPS} -J-XX:+UsePerfData ${HOSTNAME} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
 
 if [ $? -ne 0 ]
 then
@@ -60,7 +60,7 @@
     exit 1
 fi
 
-${JSTAT} -gcutil ${JSTATD_PID}@${HOSTNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gcutil ${JSTATD_PID}@${HOSTNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
 RC=$?
 
 if [ ${RC} -ne 0 ]
--- a/jdk/test/sun/tools/jstatd/jstatdExternalRegistry.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstatd/jstatdExternalRegistry.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -53,19 +53,19 @@
 RMIREGISTRY_OUT="rmiregistry_$$.out"
 JSTATD_OUT="jstatd_$$.out"
 
-${RMIREGISTRY} ${PORT} > ${RMIREGISTRY_OUT} 2>&1 &
+${RMIREGISTRY} -J-XX:+UsePerfData ${PORT} > ${RMIREGISTRY_OUT} 2>&1 &
 RMIREGISTRY_PID=$!
 
 echo "rmiregistry started on port ${PORT} as pid ${RMIREGISTRY_PID}"
 sleep 3
 
-${JSTATD} -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT} > ${JSTATD_OUT} 2>&1 &
+${JSTATD} -J-XX:+UsePerfData -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT} > ${JSTATD_OUT} 2>&1 &
 JSTATD_PID=$!
 
 echo "jstatd started as pid ${JSTATD_PID}"
 sleep 3
 
-${JPS} ${HOSTNAME}:${PORT} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
+${JPS} -J-XX:+UsePerfData ${HOSTNAME}:${PORT} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
 
 if [ $? -ne 0 ]
 then
@@ -73,7 +73,7 @@
     exit 1
 fi
 
-${JSTAT} -gcutil ${JSTATD_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gcutil ${JSTATD_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
 RC=$?
 
 if [ ${RC} -ne 0 ]
--- a/jdk/test/sun/tools/jstatd/jstatdPort.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstatd/jstatdPort.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -50,13 +50,13 @@
 
 JSTATD_OUT="jstatd_$$.out"
 
-${JSTATD} -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT} 2>&1 > ${JSTATD_OUT} &
+${JSTATD} -J-XX:+UsePerfData -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT} 2>&1 > ${JSTATD_OUT} &
 JSTATD_PID=$!
 
 echo "jstatd started as pid ${JSTATD_PID} on port ${PORT}"
 sleep 3
 
-${JPS} ${HOSTNAME}:${PORT} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
+${JPS} -J-XX:+UsePerfData ${HOSTNAME}:${PORT} 2>&1 | tee jps.out | awk -f ${TESTSRC}/jpsOutput1.awk
 
 if [ $? -ne 0 ]
 then
@@ -65,7 +65,7 @@
     exit 1
 fi
 
-${JSTAT} -gcutil ${JSTATD_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+${JSTAT} -J-XX:+UsePerfData -gcutil ${JSTATD_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
 RC=$?
 
 if [ ${RC} -ne 0 ]
--- a/jdk/test/sun/tools/jstatd/jstatdServerName.sh	Mon Oct 24 09:58:47 2011 -0700
+++ b/jdk/test/sun/tools/jstatd/jstatdServerName.sh	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -54,20 +54,20 @@
 JSTATD_1_OUT="jstatd_$$_1.out"
 JSTATD_2_OUT="jstatd_$$_2.out"
 
-${JSTATD} -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT_1} 2>&1 > ${JSTATD_1_OUT} &
+${JSTATD} -J-XX:+UsePerfData -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT_1} 2>&1 > ${JSTATD_1_OUT} &
 JSTATD_1_PID=$!
 
 echo "first jstatd started as pid ${JSTATD_1_PID} on port ${PORT_1} with default server name"
 sleep 3
 
-${JSTATD} -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT_2} -n ${SERVERNAME} 2>&1 > ${JSTATD_2_OUT} &
+${JSTATD} -J-XX:+UsePerfData -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT_2} -n ${SERVERNAME} 2>&1 > ${JSTATD_2_OUT} &
 JSTATD_2_PID=$!
 
 echo "second jstatd started as pid ${JSTATD_2_PID} on port ${PORT_2} with name ${SERVERNAME}"
 sleep 3
 
-echo "running: ${JPS} ${HOSTNAME}:${PORT_1}"
-${JPS} ${HOSTNAME}:${PORT_1} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
+echo "running: ${JPS} -J-XX:+UsePerfData ${HOSTNAME}:${PORT_1}"
+${JPS} -J-XX:+UsePerfData ${HOSTNAME}:${PORT_1} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
 
 if [ $? -ne 0 ]
 then
@@ -76,8 +76,8 @@
     exit 1
 fi
 
-echo "running: ${JPS} ${HOSTNAME}:${PORT_2}/${SERVERNAME}"
-${JPS} ${HOSTNAME}:${PORT_2}/${SERVERNAME} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
+echo "running: ${JPS} -J-XX:+UsePerfData ${HOSTNAME}:${PORT_2}/${SERVERNAME}"
+${JPS} -J-XX:+UsePerfData ${HOSTNAME}:${PORT_2}/${SERVERNAME} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
 
 if [ $? -ne 0 ]
 then
@@ -86,8 +86,8 @@
     exit 1
 fi
 
-echo "running: ${JSTAT} -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_1} 250 5"
-${JSTAT} -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_1} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+echo "running: ${JSTAT} -J-XX:+UsePerfData -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_1} 250 5"
+${JSTAT} -J-XX:+UsePerfData -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_1} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
 RC=$?
 
 if [ ${RC} -ne 0 ]
@@ -95,8 +95,8 @@
     echo "jstat output differs from expected output"
 fi
 
-echo "running: ${JSTAT} -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5"
-${JSTAT} -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+echo "running: ${JSTAT} -J-XX:+UsePerfData -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5"
+${JSTAT} -J-XX:+UsePerfData -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
 RC=$?
 
 if [ ${RC} -ne 0 ]
--- a/langtools/.hgtags	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/.hgtags	Wed Oct 26 17:59:13 2011 -0700
@@ -127,3 +127,8 @@
 f497fac86cf9ada4801ecaf49eb0d2307a2b61c8 jdk8-b03
 5df63fd8fa64741e829281ee6febe9954932841b jdk8-b04
 5304c2a17d4b001e365a8f0163082dc375f1abab jdk8-b05
+d2422276f9dabc848b7a079025719826d2f9a30f jdk8-b06
+116980ecec5cc7d52736f09cf332321e0773265f jdk8-b07
+e8acc2d6c32f0c8321e642e1a86672a2e196a056 jdk8-b08
+b7a7e47c8d3daf7822abf7c37e5179ccbbf53008 jdk8-b09
+f6c783e18bdf4d46a0ab273868afebbf32600ff7 jdk8-b10
--- a/langtools/src/share/classes/com/sun/tools/javac/Launcher.java	Mon Oct 24 09:58:47 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac;
-
-import java.io.File;
-import java.util.prefs.Preferences;
-import javax.swing.JFileChooser;
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-
-/**
- * <b>Unsupported</b> entry point for starting javac from an IDE.
- *
- * <p><b>Note:</b> this class is not available in the JDK.  It is not
- * compiled by default and will not be in tools.jar.  It is designed
- * to be useful when editing the compiler sources in an IDE (as part
- * of a <em>project</em>).  Simply ensure that this class is added to
- * the project and make it the main class of the project.</p>
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own
- * risk.  This code and its internal interfaces are subject to change
- * or deletion without notice.</b></p>
- *
- * @author Peter von der Ah&eacute;
- * @since 1.6
- */
-class Launcher {
-    public static void main(String... args) {
-        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
-        JFileChooser fileChooser;
-        Preferences prefs = Preferences.userNodeForPackage(Launcher.class);
-        if (args.length > 0)
-            fileChooser = new JFileChooser(args[0]);
-        else {
-            String fileName = prefs.get("recent.file", null);
-            fileChooser = new JFileChooser();
-            if (fileName != null) {
-                fileChooser = new JFileChooser();
-                fileChooser.setSelectedFile(new File(fileName));
-            }
-        }
-        if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
-            String fileName = fileChooser.getSelectedFile().getPath();
-            prefs.put("recent.file", fileName);
-            javac.run(System.in, null, null, "-d", "/tmp", fileName);
-        }
-    }
-}
--- a/langtools/src/share/classes/com/sun/tools/javac/Main.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/Main.java	Wed Oct 26 17:59:13 2011 -0700
@@ -73,7 +73,7 @@
     public static int compile(String[] args) {
         com.sun.tools.javac.main.Main compiler =
             new com.sun.tools.javac.main.Main("javac");
-        return compiler.compile(args);
+        return compiler.compile(args).exitCode;
     }
 
 
@@ -91,6 +91,6 @@
     public static int compile(String[] args, PrintWriter out) {
         com.sun.tools.javac.main.Main compiler =
             new com.sun.tools.javac.main.Main("javac", out);
-        return compiler.compile(args);
+        return compiler.compile(args).exitCode;
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Wed Oct 26 17:59:13 2011 -0700
@@ -78,7 +78,7 @@
     private AtomicBoolean used = new AtomicBoolean();
     private Iterable<? extends Processor> processors;
 
-    private Integer result = null;
+    private Main.Result result = null;
 
     JavacTaskImpl(Main compilerMain,
                 String[] args,
@@ -131,7 +131,7 @@
             compilerMain.setAPIMode(true);
             result = compilerMain.compile(args, context, fileObjects, processors);
             cleanup();
-            return result == 0;
+            return result.isOK();
         } else {
             throw new IllegalStateException("multiple calls to method 'call'");
         }
@@ -274,6 +274,9 @@
     public Iterable<? extends TypeElement> enter(Iterable<? extends CompilationUnitTree> trees)
         throws IOException
     {
+        if (trees == null && notYetEntered != null && notYetEntered.isEmpty())
+            return List.nil();
+
         prepareCompiler();
 
         ListBuffer<JCCompilationUnit> roots = null;
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Wed Oct 26 17:59:13 2011 -0700
@@ -65,6 +65,7 @@
 import com.sun.tools.javac.tree.TreeCopier;
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.tree.TreeMaker;
+import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.List;
@@ -263,9 +264,10 @@
         if (!(path.getLeaf() instanceof JCTree))  // implicit null-check
             throw new IllegalArgumentException();
 
-        // if we're being invoked via from a JSR199 client, we need to make sure
-        // all the classes have been entered; if we're being invoked from JSR269,
-        // then the classes will already have been entered.
+        // if we're being invoked from a Tree API client via parse/enter/analyze,
+        // we need to make sure all the classes have been entered;
+        // if we're being invoked from JSR 199 or JSR 269, then the classes
+        // will already have been entered.
         if (javacTaskImpl != null) {
             try {
                 javacTaskImpl.enter(null);
@@ -313,10 +315,19 @@
                     break;
                 case BLOCK: {
 //                    System.err.println("BLOCK: ");
-                    if (method != null)
-                        env = memberEnter.getMethodEnv(method, env);
-                    JCTree body = copier.copy((JCTree)tree, (JCTree) path.getLeaf());
-                    env = attribStatToTree(body, env, copier.leafCopy);
+                    if (method != null) {
+                        try {
+                            Assert.check(method.body == tree);
+                            method.body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf());
+                            env = memberEnter.getMethodEnv(method, env);
+                            env = attribStatToTree(method.body, env, copier.leafCopy);
+                        } finally {
+                            method.body = (JCBlock) tree;
+                        }
+                    } else {
+                        JCBlock body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf());
+                        env = attribStatToTree(body, env, copier.leafCopy);
+                    }
                     return env;
                 }
                 default:
@@ -329,7 +340,7 @@
                     }
             }
         }
-        return field != null ? memberEnter.getInitEnv(field, env) : env;
+        return (field != null) ? memberEnter.getInitEnv(field, env) : env;
     }
 
     private Env<AttrContext> attribStatToTree(JCTree stat, Env<AttrContext>env, JCTree tree) {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java	Wed Oct 26 17:59:13 2011 -0700
@@ -103,6 +103,8 @@
         VAL("kindname.value"),
         METHOD("kindname.method"),
         CLASS("kindname.class"),
+        STATIC_INIT("kindname.static.init"),
+        INSTANCE_INIT("kindname.instance.init"),
         PACKAGE("kindname.package");
 
         private String name;
@@ -170,9 +172,11 @@
             return KindName.CONSTRUCTOR;
 
         case METHOD:
+            return KindName.METHOD;
         case STATIC_INIT:
+            return KindName.STATIC_INIT;
         case INSTANCE_INIT:
-            return KindName.METHOD;
+            return KindName.INSTANCE_INIT;
 
         default:
             if (sym.kind == VAL)
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Printer.java	Wed Oct 26 17:59:13 2011 -0700
@@ -311,7 +311,7 @@
 
     @Override
     public String visitMethodSymbol(MethodSymbol s, Locale locale) {
-        if ((s.flags() & BLOCK) != 0) {
+        if (s.isStaticOrInstanceInit()) {
             return s.owner.name.toString();
         } else {
             String ms = (s.name == s.name.table.names.init)
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Oct 26 17:59:13 2011 -0700
@@ -149,7 +149,8 @@
      * the default package; otherwise, the owner symbol is returned
      */
     public Symbol location() {
-        if (owner.name == null || (owner.name.isEmpty() && owner.kind != PCK && owner.kind != TYP)) {
+        if (owner.name == null || (owner.name.isEmpty() &&
+                (owner.flags() & BLOCK) == 0 && owner.kind != PCK && owner.kind != TYP)) {
             return null;
         }
         return owner;
@@ -725,6 +726,11 @@
          */
         public JavaFileObject classfile;
 
+        /** the list of translated local classes (used for generating
+         * InnerClasses attribute)
+         */
+        public List<ClassSymbol> trans_local;
+
         /** the constant pool of the class
          */
         public Pool pool;
@@ -1299,10 +1305,17 @@
                 return ElementKind.CONSTRUCTOR;
             else if (name == name.table.names.clinit)
                 return ElementKind.STATIC_INIT;
+            else if ((flags() & BLOCK) != 0)
+                return isStatic() ? ElementKind.STATIC_INIT : ElementKind.INSTANCE_INIT;
             else
                 return ElementKind.METHOD;
         }
 
+        public boolean isStaticOrInstanceInit() {
+            return getKind() == ElementKind.STATIC_INIT ||
+                    getKind() == ElementKind.INSTANCE_INIT;
+        }
+
         public Attribute getDefaultValue() {
             return defaultValue;
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Oct 26 17:59:13 2011 -0700
@@ -508,8 +508,13 @@
             @Override
             public Boolean visitUndetVar(UndetVar t, Type s) {
                 //todo: test against origin needed? or replace with substitution?
-                if (t == s || t.qtype == s || s.tag == ERROR || s.tag == UNKNOWN)
+                if (t == s || t.qtype == s || s.tag == ERROR || s.tag == UNKNOWN) {
                     return true;
+                } else if (s.tag == BOT) {
+                    //if 's' is 'null' there's no instantiated type U for which
+                    //U <: s (but 'null' itself, which is not a valid type)
+                    return false;
+                }
 
                 if (t.inst != null)
                     return isSubtypeNoCapture(t.inst, s); // TODO: ", warn"?
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Oct 26 17:59:13 2011 -0700
@@ -306,7 +306,16 @@
      */
     void duplicateError(DiagnosticPosition pos, Symbol sym) {
         if (!sym.type.isErroneous()) {
-            log.error(pos, "already.defined", sym, sym.location());
+            Symbol location = sym.location();
+            if (location.kind == MTH &&
+                    ((MethodSymbol)location).isStaticOrInstanceInit()) {
+                log.error(pos, "already.defined.in.clinit", kindName(sym), sym,
+                        kindName(sym.location()), kindName(sym.location().enclClass()),
+                        sym.location().enclClass());
+            } else {
+                log.error(pos, "already.defined", kindName(sym), sym,
+                        kindName(sym.location()), sym.location());
+            }
         }
     }
 
@@ -1160,12 +1169,17 @@
             if (lint.isEnabled(LintCategory.RAW) &&
                 tree.type.tag == CLASS &&
                 !TreeInfo.isDiamond(tree) &&
-                !env.enclClass.name.isEmpty() &&  //anonymous or intersection
+                !withinAnonConstr(env) &&
                 tree.type.isRaw()) {
                 log.warning(LintCategory.RAW,
                         tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type);
             }
         }
+
+        boolean withinAnonConstr(Env<AttrContext> env) {
+            return env.enclClass.name.isEmpty() &&
+                    env.enclMethod != null && env.enclMethod.name == names.init;
+        }
     }
 
 /* *************************************************************************
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Oct 26 17:59:13 2011 -0700
@@ -269,21 +269,18 @@
             // VGJ: sort of inlined maximizeInst() below.  Adding
             // bounds can cause lobounds that are above hibounds.
             List<Type> hibounds = Type.filter(that.hibounds, errorFilter);
+            Type hb = null;
             if (hibounds.isEmpty())
-                return;
-            Type hb = null;
-            if (hibounds.tail.isEmpty())
+                hb = syms.objectType;
+            else if (hibounds.tail.isEmpty())
                 hb = hibounds.head;
-            else for (List<Type> bs = hibounds;
-                      bs.nonEmpty() && hb == null;
-                      bs = bs.tail) {
-                if (isSubClass(bs.head, hibounds))
-                    hb = types.fromUnknownFun.apply(bs.head);
-            }
+            else
+                hb = types.glb(hibounds);
             if (hb == null ||
-                !types.isSubtypeUnchecked(hb, hibounds, warn) ||
-                !types.isSubtypeUnchecked(that.inst, hb, warn))
-                throw ambiguousNoInstanceException;
+                hb.isErroneous())
+                throw ambiguousNoInstanceException
+                        .setMessage("incompatible.upper.bounds",
+                                    that.qtype, hibounds);
         }
     }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Oct 26 17:59:13 2011 -0700
@@ -2271,6 +2271,14 @@
         tree.extending = translate(tree.extending);
         tree.implementing = translate(tree.implementing);
 
+        if (currentClass.isLocal()) {
+            ClassSymbol encl = currentClass.owner.enclClass();
+            if (encl.trans_local == null) {
+                encl.trans_local = List.nil();
+            }
+            encl.trans_local = encl.trans_local.prepend(currentClass);
+        }
+
         // Recursively translate members, taking into account that new members
         // might be created during the translation and prepended to the member
         // list `tree.defs'.
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Oct 26 17:59:13 2011 -0700
@@ -863,10 +863,10 @@
         }
         if (c.type.tag != CLASS) return; // arrays
         if (pool != null && // pool might be null if called from xClassName
-            c.owner.kind != PCK &&
+            c.owner.enclClass() != null &&
             (innerClasses == null || !innerClasses.contains(c))) {
 //          log.errWriter.println("enter inner " + c);//DEBUG
-            if (c.owner.kind == TYP) enterInner((ClassSymbol)c.owner);
+            enterInner(c.owner.enclClass());
             pool.put(c);
             pool.put(c.name);
             if (innerClasses == null) {
@@ -1505,6 +1505,13 @@
             default : Assert.error();
             }
         }
+
+        if (c.trans_local != null) {
+            for (ClassSymbol local : c.trans_local) {
+                enterInner(local);
+            }
+        }
+
         databuf.appendChar(fieldsCount);
         writeFields(c.members().elems);
         databuf.appendChar(methodsCount);
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Oct 26 17:59:13 2011 -0700
@@ -488,6 +488,10 @@
      */
     public Todo todo;
 
+    /** A list of items to be closed when the compilation is complete.
+     */
+    public List<Closeable> closeables = List.nil();
+
     /** Ordered list of compiler phases for each compilation unit. */
     public enum CompileState {
         PARSE(1),
@@ -1581,6 +1585,19 @@
             if (names != null && disposeNames)
                 names.dispose();
             names = null;
+
+            for (Closeable c: closeables) {
+                try {
+                    c.close();
+                } catch (IOException e) {
+                    // When javac uses JDK 7 as a baseline, this code would be
+                    // better written to set any/all exceptions from all the
+                    // Closeables as suppressed exceptions on the FatalError
+                    // that is thrown.
+                    JCDiagnostic msg = diagFactory.fragment("fatal.err.cant.close");
+                    throw new FatalError(msg, e);
+                }
+            }
         }
     }
 
@@ -1615,6 +1632,8 @@
         keepComments = prev.keepComments;
         start_msec = prev.start_msec;
         hasBeenUsed = true;
+        closeables = prev.closeables;
+        prev.closeables = List.nil();
     }
 
     public static void enableLogging() {
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Wed Oct 26 17:59:13 2011 -0700
@@ -76,12 +76,23 @@
 
     /** Result codes.
      */
-    static final int
-        EXIT_OK = 0,        // Compilation completed with no errors.
-        EXIT_ERROR = 1,     // Completed but reported errors.
-        EXIT_CMDERR = 2,    // Bad command-line arguments
-        EXIT_SYSERR = 3,    // System error or resource exhaustion.
-        EXIT_ABNORMAL = 4;  // Compiler terminated abnormally
+    public enum Result {
+        OK(0),        // Compilation completed with no errors.
+        ERROR(1),     // Completed but reported errors.
+        CMDERR(2),    // Bad command-line arguments
+        SYSERR(3),    // System error or resource exhaustion.
+        ABNORMAL(4);  // Compiler terminated abnormally
+
+        Result(int exitCode) {
+            this.exitCode = exitCode;
+        }
+
+        public boolean isOK() {
+            return (exitCode == 0);
+        }
+
+        public final int exitCode;
+    }
 
     private Option[] recognizedOptions = RecognizedOptions.getJavaCompilerOptions(new OptionHelper() {
 
@@ -318,10 +329,10 @@
     /** Programmatic interface for main function.
      * @param args    The command line parameters.
      */
-    public int compile(String[] args) {
+    public Result compile(String[] args) {
         Context context = new Context();
         JavacFileManager.preRegister(context); // can't create it until Log has been set up
-        int result = compile(args, context);
+        Result result = compile(args, context);
         if (fileManager instanceof JavacFileManager) {
             // A fresh context was created above, so jfm must be a JavacFileManager
             ((JavacFileManager)fileManager).close();
@@ -329,14 +340,14 @@
         return result;
     }
 
-    public int compile(String[] args, Context context) {
+    public Result compile(String[] args, Context context) {
         return compile(args, context, List.<JavaFileObject>nil(), null);
     }
 
     /** Programmatic interface for main function.
      * @param args    The command line parameters.
      */
-    public int compile(String[] args,
+    public Result compile(String[] args,
                        Context context,
                        List<JavaFileObject> fileObjects,
                        Iterable<? extends Processor> processors)
@@ -355,7 +366,7 @@
         try {
             if (args.length == 0 && fileObjects.isEmpty()) {
                 help();
-                return EXIT_CMDERR;
+                return Result.CMDERR;
             }
 
             Collection<File> files;
@@ -363,26 +374,26 @@
                 files = processArgs(CommandLine.parse(args));
                 if (files == null) {
                     // null signals an error in options, abort
-                    return EXIT_CMDERR;
+                    return Result.CMDERR;
                 } else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) {
                     // it is allowed to compile nothing if just asking for help or version info
                     if (options.isSet(HELP)
                         || options.isSet(X)
                         || options.isSet(VERSION)
                         || options.isSet(FULLVERSION))
-                        return EXIT_OK;
+                        return Result.OK;
                     if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
                         error("err.no.source.files.classes");
                     } else {
                         error("err.no.source.files");
                     }
-                    return EXIT_CMDERR;
+                    return Result.CMDERR;
                 }
             } catch (java.io.FileNotFoundException e) {
                 Log.printLines(out, ownName + ": " +
                                getLocalizedString("err.file.not.found",
                                                   e.getMessage()));
-                return EXIT_SYSERR;
+                return Result.SYSERR;
             }
 
             boolean forceStdOut = options.isSet("stdout");
@@ -402,7 +413,7 @@
             fileManager = context.get(JavaFileManager.class);
 
             comp = JavaCompiler.instance(context);
-            if (comp == null) return EXIT_SYSERR;
+            if (comp == null) return Result.SYSERR;
 
             Log log = Log.instance(context);
 
@@ -423,32 +434,32 @@
             if (log.expectDiagKeys != null) {
                 if (log.expectDiagKeys.isEmpty()) {
                     Log.printLines(log.noticeWriter, "all expected diagnostics found");
-                    return EXIT_OK;
+                    return Result.OK;
                 } else {
                     Log.printLines(log.noticeWriter, "expected diagnostic keys not found: " + log.expectDiagKeys);
-                    return EXIT_ERROR;
+                    return Result.ERROR;
                 }
             }
 
             if (comp.errorCount() != 0)
-                return EXIT_ERROR;
+                return Result.ERROR;
         } catch (IOException ex) {
             ioMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (OutOfMemoryError ex) {
             resourceMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (StackOverflowError ex) {
             resourceMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (FatalError ex) {
             feMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (AnnotationProcessingError ex) {
             if (apiMode)
                 throw new RuntimeException(ex.getCause());
             apMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (ClientCodeException ex) {
             // as specified by javax.tools.JavaCompiler#getTask
             // and javax.tools.JavaCompiler.CompilationTask#call
@@ -462,7 +473,7 @@
             if (comp == null || comp.errorCount() == 0 ||
                 options == null || options.isSet("dev"))
                 bugMessage(ex);
-            return EXIT_ABNORMAL;
+            return Result.ABNORMAL;
         } finally {
             if (comp != null) {
                 try {
@@ -474,7 +485,7 @@
             filenames = null;
             options = null;
         }
-        return EXIT_OK;
+        return Result.OK;
     }
 
     /** Print a message reporting an internal error.
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -455,9 +455,24 @@
         // TODO: Only support reading resources in selected output
         // locations?  Only allow reading of non-source, non-class
         // files from the supported input locations?
-        FileObject fileObject = fileManager.getFileForInput(location,
+
+        // In the following, getFileForInput is the "obvious" method
+        // to use, but it does not have the "obvious" semantics for
+        // SOURCE_OUTPUT and CLASS_OUTPUT. Conversely, getFileForOutput
+        // does not have the correct semantics for any "path" location
+        // with more than one component. So, for now, we use a hybrid
+        // invocation.
+        FileObject fileObject;
+        if (location.isOutputLocation()) {
+            fileObject = fileManager.getFileForOutput(location,
+                    pkg.toString(),
+                    relativeName.toString(),
+                    null);
+        } else {
+            fileObject = fileManager.getFileForInput(location,
                     pkg.toString(),
                     relativeName.toString());
+        }
         if (fileObject == null) {
             String name = (pkg.length() == 0)
                     ? relativeName.toString() : (pkg + "/" + relativeName);
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Oct 26 17:59:13 2011 -0700
@@ -225,6 +225,11 @@
                     ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH)
                     : fileManager.getClassLoader(CLASS_PATH);
 
+                if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
+                    JavaCompiler compiler = JavaCompiler.instance(context);
+                    compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader);
+                }
+
                 /*
                  * If the "-processor" option is used, search the appropriate
                  * path for the named class.  Otherwise, use a service
@@ -1211,14 +1216,6 @@
         if (discoveredProcs != null) // Make calling close idempotent
             discoveredProcs.close();
         discoveredProcs = null;
-        if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
-            try {
-                ((Closeable) processorClassLoader).close();
-            } catch (IOException e) {
-                JCDiagnostic msg = diags.fragment("fatal.err.cant.close.loader");
-                throw new FatalError(msg, e);
-            }
-        }
     }
 
     private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -68,9 +68,13 @@
 compiler.err.already.annotated=\
     {0} {1} has already been annotated
 
-# 0: symbol, 1: symbol
+# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol
 compiler.err.already.defined=\
-    {0} is already defined in {1}
+    {0} {1} is already defined in {2} {3}
+
+# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol kind, 4: symbol
+compiler.err.already.defined.in.clinit=\
+    {0} {1} is already defined in {2} of {3} {4}
 
 # 0: string
 compiler.err.already.defined.single.import=\
@@ -891,8 +895,8 @@
 compiler.misc.fatal.err.cant.locate.ctor=\
     Fatal Error: Unable to find constructor for {0}
 
-compiler.misc.fatal.err.cant.close.loader=\
-    Fatal Error: Cannot close class loader for annotation processors
+compiler.misc.fatal.err.cant.close=\
+    Fatal Error: Cannot close compiler resources
 
 #####
 
@@ -1598,6 +1602,10 @@
 compiler.misc.no.unique.minimal.instance.exists=\
     no unique minimal instance exists for type variable {0} with lower bounds {1}
 
+# 0: type, 1: list of type
+compiler.misc.incompatible.upper.bounds=\
+    inference variable {0} has incompatible upper bounds {1}
+
 # 0: list of type, 1: type, 2: type
 compiler.misc.infer.no.conforming.instance.exists=\
     no instance(s) of type variable(s) {0} exist so that {1} conforms to {2}
@@ -1753,6 +1761,12 @@
 compiler.misc.kindname.package=\
     package
 
+compiler.misc.kindname.static.init=\
+    static initializer
+
+compiler.misc.kindname.instance.init=\
+    instance initializer
+
 #####
 
 compiler.misc.no.args=\
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Oct 26 17:59:13 2011 -0700
@@ -436,7 +436,6 @@
         public PackageSymbol packge;
         public ImportScope namedImportScope;
         public StarImportScope starImportScope;
-        public long flags;
         public Position.LineMap lineMap = null;
         public Map<JCTree, String> docComments = null;
         public Map<JCTree, Integer> endPositions = null;
@@ -1176,6 +1175,21 @@
         public int getTag() {
             return EXEC;
         }
+
+        /** Convert a expression-statement tree to a pretty-printed string. */
+        @Override
+        public String toString() {
+            StringWriter s = new StringWriter();
+            try {
+                new Pretty(s, false).printStat(this);
+            }
+            catch (IOException e) {
+                // should never happen, because StringWriter is defined
+                // never to throw any IOExceptions
+                throw new AssertionError(e);
+            }
+            return s.toString();
+        }
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Oct 26 17:59:13 2011 -0700
@@ -412,7 +412,7 @@
         @Override
         public String visitMethodSymbol(MethodSymbol s, Locale locale) {
             String ownerName = visit(s.owner, locale);
-            if ((s.flags() & BLOCK) != 0) {
+            if (s.isStaticOrInstanceInit()) {
                return ownerName;
             } else {
                 String ms = (s.name == s.name.table.names.init)
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -257,24 +257,15 @@
         for (String p: excludedPackages)
             includedPackages.put(p, false);
 
-        if (docenv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)) {
-            searchSubPackages(subPackages,
-                    includedPackages,
-                    packages, packageFiles,
-                    StandardLocation.SOURCE_PATH,
-                    EnumSet.of(JavaFileObject.Kind.SOURCE));
-            searchSubPackages(subPackages,
-                    includedPackages,
-                    packages, packageFiles,
-                    StandardLocation.CLASS_PATH,
-                    EnumSet.of(JavaFileObject.Kind.CLASS));
-        } else {
-            searchSubPackages(subPackages,
-                    includedPackages,
-                    packages, packageFiles,
-                    StandardLocation.CLASS_PATH,
-                    EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS));
-        }
+        StandardLocation path = docenv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
+                ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
+
+        searchSubPackages(subPackages,
+                includedPackages,
+                packages, packageFiles,
+                path,
+                EnumSet.of(JavaFileObject.Kind.SOURCE));
+
         return packageFiles;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7003595/T7003595.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7003595
+ * @summary IncompatibleClassChangeError with unreferenced local class with subclass
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.InnerClasses_attribute;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.javac.api.JavacTool;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.ArrayList;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+
+public class T7003595 {
+
+    /** global decls ***/
+
+    // Create a single file manager and reuse it for each compile to save time.
+    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+
+    //statistics
+    static int checkCount = 0;
+
+    enum ClassKind {
+        NESTED("static class #N { #B }", "$", true),
+        INNER("class #N { #B }", "$", false),
+        LOCAL_REF("void test() { class #N { #B }; new #N(); }", "$1", false),
+        LOCAL_NOREF("void test() { class #N { #B }; }", "$1", false),
+        ANON("void test() { new Object() { #B }; }", "$1", false),
+        NONE("", "", false);
+
+        String memberInnerStr;
+        String sep;
+        boolean staticAllowed;
+
+        private ClassKind(String memberInnerStr, String sep, boolean staticAllowed) {
+            this.memberInnerStr = memberInnerStr;
+            this.sep = sep;
+            this.staticAllowed = staticAllowed;
+        }
+
+        String getSource(String className, String outerName, String nested) {
+            return memberInnerStr.replaceAll("#O", outerName).
+                    replaceAll("#N", className).replaceAll("#B", nested);
+        }
+
+        static String getClassfileName(String[] names, ClassKind[] outerKinds, int pos) {
+            System.out.println(" pos = " + pos + " kind = " + outerKinds[pos] + " sep = " + outerKinds[pos].sep);
+            String name = outerKinds[pos] != ANON ?
+                    names[pos] : "";
+            if (pos == 0) {
+                return "Test" + outerKinds[pos].sep + name;
+            } else {
+                String outerStr = getClassfileName(names, outerKinds, pos - 1);
+                return outerStr + outerKinds[pos].sep + name;
+            }
+        }
+
+        boolean isAllowed(ClassKind nestedKind) {
+            return nestedKind != NESTED ||
+                    staticAllowed;
+        }
+    }
+
+    enum LocalInnerClass {
+        LOCAL_REF("class L {}; new L();", "Test$1L"),
+        LOCAL_NOREF("class L {};", "Test$1L"),
+        ANON("new Object() {};", "Test$1"),
+        NONE("", "");
+
+        String localInnerStr;
+        String canonicalInnerStr;
+
+        private LocalInnerClass(String localInnerStr, String canonicalInnerStr) {
+            this.localInnerStr = localInnerStr;
+            this.canonicalInnerStr = canonicalInnerStr;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (ClassKind ck1 : ClassKind.values()) {
+            String cname1 = "C1";
+            for (ClassKind ck2 : ClassKind.values()) {
+                if (!ck1.isAllowed(ck2)) continue;
+                String cname2 = "C2";
+                for (ClassKind ck3 : ClassKind.values()) {
+                    if (!ck2.isAllowed(ck3)) continue;
+                    String cname3 = "C3";
+                    new T7003595(new ClassKind[] {ck1, ck2, ck3}, new String[] { cname1, cname2, cname3 }).compileAndCheck();
+                }
+            }
+        }
+
+        System.out.println("Total checks made: " + checkCount);
+    }
+
+    /** instance decls **/
+
+    ClassKind[] cks;
+    String[] cnames;
+
+    T7003595(ClassKind[] cks, String[] cnames) {
+        this.cks = cks;
+        this.cnames = cnames;
+    }
+
+    void compileAndCheck() throws Exception {
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavaSource source = new JavaSource();
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, null,
+                null, null, Arrays.asList(source));
+        ct.call();
+        verifyBytecode(source);
+    }
+
+    void verifyBytecode(JavaSource source) {
+        for (int i = 0; i < 3 ; i ++) {
+            if (cks[i] == ClassKind.NONE) break;
+            checkCount++;
+            String filename = cks[i].getClassfileName(cnames, cks, i);
+            File compiledTest = new File(filename + ".class");
+            try {
+                ClassFile cf = ClassFile.read(compiledTest);
+                if (cf == null) {
+                    throw new Error("Classfile not found: " + filename);
+                }
+
+                InnerClasses_attribute innerClasses = (InnerClasses_attribute)cf.getAttribute(Attribute.InnerClasses);
+
+                ArrayList<String> foundInnerSig = new ArrayList<>();
+                if (innerClasses != null) {
+                    for (InnerClasses_attribute.Info info : innerClasses.classes) {
+                        String foundSig = info.getInnerClassInfo(cf.constant_pool).getName();
+                        foundInnerSig.add(foundSig);
+                    }
+                }
+
+                ArrayList<String> expectedInnerSig = new ArrayList<>();
+                //add inner class (if any)
+                if (i < 2 && cks[i + 1] != ClassKind.NONE) {
+                    expectedInnerSig.add(cks[i + 1].getClassfileName(cnames, cks, i + 1));
+                }
+                //add inner classes
+                for (int j = 0 ; j != i + 1 && j < 3; j++) {
+                    expectedInnerSig.add(cks[j].getClassfileName(cnames, cks, j));
+                }
+
+                if (expectedInnerSig.size() != foundInnerSig.size()) {
+                    throw new Error("InnerClasses attribute for " + cnames[i] + " has wrong size\n" +
+                                    "expected " + expectedInnerSig.size() + "\n" +
+                                    "found " + innerClasses.number_of_classes + "\n" +
+                                    source);
+                }
+
+                for (String foundSig : foundInnerSig) {
+                    if (!expectedInnerSig.contains(foundSig)) {
+                        throw new Error("InnerClasses attribute for " + cnames[i] + " has unexpected signature: " +
+                                foundSig + "\n" + source + "\n" + expectedInnerSig);
+                    }
+                }
+
+                for (String expectedSig : expectedInnerSig) {
+                    if (!foundInnerSig.contains(expectedSig)) {
+                        throw new Error("InnerClasses attribute for " + cnames[i] + " does not contain expected signature: " +
+                                    expectedSig + "\n" + source);
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new Error("error reading " + compiledTest +": " + e);
+            }
+        }
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        static final String source_template = "class Test { #C }";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            String c3 = cks[2].getSource(cnames[2], cnames[1], "");
+            String c2 = cks[1].getSource(cnames[1], cnames[0], c3);
+            String c1 = cks[0].getSource(cnames[0], "Test", c2);
+            source = source_template.replace("#C", c1);
+        }
+
+        @Override
+        public String toString() {
+            return source;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7003595/T7003595b.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7003595
+ * @summary IncompatibleClassChangeError with unreferenced local class with subclass
+ */
+
+public class T7003595b {
+    public static void main(String... args) throws Exception {
+        class A {}
+        class B extends A {}
+        B.class.getSuperclass().getDeclaringClass();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7086595/T7086595.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,32 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7086595
+ * @summary Error message bug: name of initializer is 'null'
+ * @compile/fail/ref=T7086595.out -XDrawDiagnostics T7086595.java
+ */
+
+class T7086595 {
+
+    String s = "x";
+    String s = nonExistent;
+
+    int foo() {
+        String s = "x";
+        String s = nonExistent;
+    }
+
+    static int bar() {
+        String s = "x";
+        String s = nonExistent;
+    }
+
+    {
+        String s = "x";
+        String s = nonExistent;
+    }
+
+    static {
+        String s = "x";
+        String s = nonExistent;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7086595/T7086595.out	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,11 @@
+T7086595.java:11:12: compiler.err.already.defined: kindname.variable, s, kindname.class, T7086595
+T7086595.java:11:16: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null)
+T7086595.java:15:16: compiler.err.already.defined: kindname.variable, s, kindname.method, foo()
+T7086595.java:15:20: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null)
+T7086595.java:20:16: compiler.err.already.defined: kindname.variable, s, kindname.method, bar()
+T7086595.java:20:20: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null)
+T7086595.java:25:16: compiler.err.already.defined.in.clinit: kindname.variable, s, kindname.instance.init, kindname.class, T7086595
+T7086595.java:25:20: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null)
+T7086595.java:30:16: compiler.err.already.defined.in.clinit: kindname.variable, s, kindname.static.init, kindname.class, T7086595
+T7086595.java:30:20: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, T7086595, null)
+10 errors
--- a/langtools/test/tools/javac/Diagnostics/6860795/T6860795.out	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/Diagnostics/6860795/T6860795.out	Wed Oct 26 17:59:13 2011 -0700
@@ -1,2 +1,2 @@
-T6860795.java:10:27: compiler.err.already.defined: x, foo
+T6860795.java:10:27: compiler.err.already.defined: kindname.variable, x, kindname.method, foo
 1 error
--- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out	Wed Oct 26 17:59:13 2011 -0700
@@ -1,3 +1,3 @@
-T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String>
+T6862608a.java:19:33: compiler.err.cant.apply.symbol.1: kindname.method, compound, java.lang.Iterable<? extends java.util.Comparator<? super T>>, java.util.List<java.util.Comparator<?>>, kindname.class, T6862608a, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super T>>)
 - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, <T>compound(java.lang.Iterable<? extends java.util.Comparator<? super T>>))}
 1 error
--- a/langtools/test/tools/javac/LocalClasses_2.out	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/LocalClasses_2.out	Wed Oct 26 17:59:13 2011 -0700
@@ -1,2 +1,2 @@
-LocalClasses_2.java:15:13: compiler.err.already.defined: Local, foo()
+LocalClasses_2.java:15:13: compiler.err.already.defined: kindname.class, Local, kindname.method, foo()
 1 error
--- a/langtools/test/tools/javac/NestedInnerClassNames.out	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/NestedInnerClassNames.out	Wed Oct 26 17:59:13 2011 -0700
@@ -1,18 +1,18 @@
-NestedInnerClassNames.java:16:5: compiler.err.already.defined: NestedInnerClassNames, compiler.misc.unnamed.package
-NestedInnerClassNames.java:23:9: compiler.err.already.defined: NestedInnerClassNames.foo, NestedInnerClassNames
-NestedInnerClassNames.java:34:9: compiler.err.already.defined: NestedInnerClassNames, compiler.misc.unnamed.package
-NestedInnerClassNames.java:45:9: compiler.err.already.defined: NestedInnerClassNames.baz, NestedInnerClassNames
-NestedInnerClassNames.java:46:13: compiler.err.already.defined: NestedInnerClassNames.baz.baz, NestedInnerClassNames.baz
-NestedInnerClassNames.java:59:9: compiler.err.already.defined: NestedInnerClassNames.foo$bar, NestedInnerClassNames
-NestedInnerClassNames.java:76:13: compiler.err.already.defined: NestedInnerClassNames.$bar, NestedInnerClassNames
-NestedInnerClassNames.java:90:13: compiler.err.already.defined: NestedInnerClassNames.bar$bar.bar, NestedInnerClassNames.bar$bar
+NestedInnerClassNames.java:16:5: compiler.err.already.defined: kindname.class, NestedInnerClassNames, kindname.package, compiler.misc.unnamed.package
+NestedInnerClassNames.java:23:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames.foo, kindname.class, NestedInnerClassNames
+NestedInnerClassNames.java:34:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames, kindname.package, compiler.misc.unnamed.package
+NestedInnerClassNames.java:45:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames.baz, kindname.class, NestedInnerClassNames
+NestedInnerClassNames.java:46:13: compiler.err.already.defined: kindname.class, NestedInnerClassNames.baz.baz, kindname.class, NestedInnerClassNames.baz
+NestedInnerClassNames.java:59:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames.foo$bar, kindname.class, NestedInnerClassNames
+NestedInnerClassNames.java:76:13: compiler.err.already.defined: kindname.class, NestedInnerClassNames.$bar, kindname.class, NestedInnerClassNames
+NestedInnerClassNames.java:90:13: compiler.err.already.defined: kindname.class, NestedInnerClassNames.bar$bar.bar, kindname.class, NestedInnerClassNames.bar$bar
 NestedInnerClassNames.java:109:5: compiler.err.duplicate.class: NestedInnerClassNames.foo.foo
-NestedInnerClassNames.java:19:9: compiler.err.already.defined: NestedInnerClassNames, compiler.misc.unnamed.package
-NestedInnerClassNames.java:28:13: compiler.err.already.defined: foo, m2()
-NestedInnerClassNames.java:40:13: compiler.err.already.defined: NestedInnerClassNames, compiler.misc.unnamed.package
-NestedInnerClassNames.java:52:13: compiler.err.already.defined: baz, m4()
-NestedInnerClassNames.java:53:17: compiler.err.already.defined: baz.baz, baz
-NestedInnerClassNames.java:67:13: compiler.err.already.defined: foo$bar, m5()
-NestedInnerClassNames.java:83:17: compiler.err.already.defined: $bar, m6()
-NestedInnerClassNames.java:97:17: compiler.err.already.defined: bar$bar.bar, bar$bar
+NestedInnerClassNames.java:19:9: compiler.err.already.defined: kindname.class, NestedInnerClassNames, kindname.package, compiler.misc.unnamed.package
+NestedInnerClassNames.java:28:13: compiler.err.already.defined: kindname.class, foo, kindname.method, m2()
+NestedInnerClassNames.java:40:13: compiler.err.already.defined: kindname.class, NestedInnerClassNames, kindname.package, compiler.misc.unnamed.package
+NestedInnerClassNames.java:52:13: compiler.err.already.defined: kindname.class, baz, kindname.method, m4()
+NestedInnerClassNames.java:53:17: compiler.err.already.defined: kindname.class, baz.baz, kindname.class, baz
+NestedInnerClassNames.java:67:13: compiler.err.already.defined: kindname.class, foo$bar, kindname.method, m5()
+NestedInnerClassNames.java:83:17: compiler.err.already.defined: kindname.class, $bar, kindname.method, m6()
+NestedInnerClassNames.java:97:17: compiler.err.already.defined: kindname.class, bar$bar.bar, kindname.class, bar$bar
 17 errors
--- a/langtools/test/tools/javac/TryWithResources/BadTwr.out	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/TryWithResources/BadTwr.out	Wed Oct 26 17:59:13 2011 -0700
@@ -1,5 +1,5 @@
-BadTwr.java:13:46: compiler.err.already.defined: r1, main(java.lang.String...)
-BadTwr.java:18:20: compiler.err.already.defined: args, main(java.lang.String...)
+BadTwr.java:13:46: compiler.err.already.defined: kindname.variable, r1, kindname.method, main(java.lang.String...)
+BadTwr.java:18:20: compiler.err.already.defined: kindname.variable, args, kindname.method, main(java.lang.String...)
 BadTwr.java:21:13: compiler.err.cant.assign.val.to.final.var: thatsIt
-BadTwr.java:26:24: compiler.err.already.defined: name, main(java.lang.String...)
+BadTwr.java:26:24: compiler.err.already.defined: kindname.variable, name, kindname.method, main(java.lang.String...)
 4 errors
--- a/langtools/test/tools/javac/TryWithResources/DuplicateResourceDecl.out	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/TryWithResources/DuplicateResourceDecl.out	Wed Oct 26 17:59:13 2011 -0700
@@ -1,2 +1,2 @@
-DuplicateResourceDecl.java:12:56: compiler.err.already.defined: c, main(java.lang.String[])
+DuplicateResourceDecl.java:12:56: compiler.err.already.defined: kindname.variable, c, kindname.method, main(java.lang.String[])
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/TestGetScope.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7090249
+ * @summary IllegalStateException from Trees.getScope when called from JSR 199
+ */
+
+import com.sun.source.tree.IdentifierTree;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+
+@SupportedAnnotationTypes("*")
+public class TestGetScope extends AbstractProcessor {
+    public static void main(String... args) {
+        new TestGetScope().run();
+    }
+
+    public void run() {
+        File srcDir = new File(System.getProperty("test.src"));
+        File thisFile = new File(srcDir, getClass().getName() + ".java");
+
+        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+
+        List<String> opts = Arrays.asList("-proc:only", "-doe");
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
+        JavacTask t = (JavacTask) c.getTask(null, fm, null, opts, null, files);
+        t.setProcessors(Collections.singleton(this));
+        boolean ok = t.call();
+        if (!ok)
+            throw new Error("compilation failed");
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        Trees trees = Trees.instance(processingEnv);
+        if (round++ == 0) {
+            for (Element e: roundEnv.getRootElements()) {
+                TreePath p = trees.getPath(e);
+                new Scanner().scan(p, trees);
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    int round;
+
+    static class Scanner extends TreePathScanner<Void,Trees> {
+        @Override
+        public Void visitIdentifier(IdentifierTree t, Trees trees) {
+            System.err.println("visitIdentifier: " + t);
+            trees.getScope(getCurrentPath());
+            return null;
+        }
+    }
+}
--- a/langtools/test/tools/javac/diags/ArgTypeCompilerFactory.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/diags/ArgTypeCompilerFactory.java	Wed Oct 26 17:59:13 2011 -0700
@@ -146,9 +146,9 @@
             JavacFileManager.preRegister(c); // can't create it until Log has been set up
             ArgTypeJavaCompiler.preRegister(c);
             ArgTypeMessages.preRegister(c);
-            int result = main.compile(args.toArray(new String[args.size()]), c);
+            Main.Result result = main.compile(args.toArray(new String[args.size()]), c);
 
-            return (result == 0);
+            return result.isOK();
         }
     }
 
@@ -172,10 +172,10 @@
             JavacFileManager.preRegister(c); // can't create it until Log has been set up
             ArgTypeJavaCompiler.preRegister(c);
             ArgTypeMessages.preRegister(c);
-            com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", out);
-            int rc = m.compile(args.toArray(new String[args.size()]), c);
+            Main m = new Main("javac", out);
+            Main.Result result = m.compile(args.toArray(new String[args.size()]), c);
 
-            return (rc == 0);
+            return result.isOK();
         }
 
     }
--- a/langtools/test/tools/javac/diags/Example.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/diags/Example.java	Wed Oct 26 17:59:13 2011 -0700
@@ -41,6 +41,7 @@
 
 import com.sun.tools.javac.api.ClientCodeWrapper;
 import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.Main;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JavacMessages;
 import com.sun.tools.javac.util.JCDiagnostic;
@@ -515,14 +516,14 @@
             Context c = new Context();
             JavacFileManager.preRegister(c); // can't create it until Log has been set up
             MessageTracker.preRegister(c, keys);
-            com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", pw);
-            int rc = m.compile(args.toArray(new String[args.size()]), c);
+            Main m = new Main("javac", pw);
+            Main.Result rc = m.compile(args.toArray(new String[args.size()]), c);
 
             if (keys != null) {
                 pw.close();
             }
 
-            return (rc == 0);
+            return rc.isOK();
         }
 
         static class MessageTracker extends JavacMessages {
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Wed Oct 26 17:59:13 2011 -0700
@@ -60,7 +60,7 @@
 compiler.misc.fatal.err.cant.locate.ctor                # Resolve, from Lower
 compiler.misc.fatal.err.cant.locate.field               # Resolve, from Lower
 compiler.misc.fatal.err.cant.locate.meth                # Resolve, from Lower
-compiler.misc.fatal.err.cant.close.loader               # JavacProcessingEnvironment
+compiler.misc.fatal.err.cant.close	                # JavaCompiler
 compiler.misc.file.does.not.contain.package
 compiler.misc.illegal.start.of.class.file
 compiler.misc.kindname.annotation
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/AlreadyDefinedClinit.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.already.defined.in.clinit
+
+class AlreadyDefinedClinit {
+    static {
+        int i;
+        int i;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleUpperBounds.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//key: compiler.err.cant.apply.symbols
+//key: compiler.misc.inapplicable.method
+//key: compiler.misc.arg.length.mismatch
+//key: compiler.misc.incompatible.upper.bounds
+
+import java.util.List;
+
+class IncompatibleUpperBounds {
+    <S> void m(List<? super S> s1, List<? super S> s2) { }
+    void m(Object o) {}
+
+    void test(List<Integer> li, List<String> ls) {
+        m(li, ls);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/KindnameInstanceInit.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.already.defined.in.clinit
+// key: compiler.misc.kindname.instance.init
+// key: compiler.misc.kindname.class
+// key: compiler.misc.kindname.variable
+// key: compiler.misc.count.error
+// key: compiler.err.error
+// run: backdoor
+
+class KindnameInstanceInit {
+    {
+        int i;
+        int i;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/KindnameStaticInit.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.already.defined.in.clinit
+// key: compiler.misc.kindname.static.init
+// key: compiler.misc.kindname.class
+// key: compiler.misc.kindname.variable
+// key: compiler.misc.count.error
+// key: compiler.err.error
+// run: backdoor
+
+class KindnameStaticInit {
+    static {
+        int i;
+        int i;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/file/T7068437.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7068437
+ * @summary Filer.getResource(SOURCE_OUTPUT, ...) no longer works in JDK 7 w/o -s
+ */
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Filer;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedOptions;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+public class T7068437 {
+    public static void main(String[] args) throws Exception {
+        new T7068437().run();
+    }
+
+    void run() throws Exception {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        System.err.println("using " + compiler.getClass()
+                + " from " + compiler.getClass().getProtectionDomain().getCodeSource());
+
+        CompilationTask task = compiler.getTask(null, null, null,
+                Collections.singleton("-proc:only"),
+                Collections.singleton("java.lang.Object"),
+                null);
+        task.setProcessors(Collections.singleton(new Proc()));
+        check("compilation", task.call());
+
+        task = compiler.getTask(null, null, null,
+                Arrays.asList("-proc:only", "-AexpectFile"),
+                Collections.singleton("java.lang.Object"),
+                null);
+        task.setProcessors(Collections.singleton(new Proc()));
+        check("compilation", task.call());
+    }
+
+    void check(String msg, boolean ok) {
+        System.err.println(msg + ": " + (ok ? "ok" : "failed"));
+        if (!ok)
+            throw new AssertionError(msg);
+    }
+
+    @SupportedAnnotationTypes("*")
+    @SupportedOptions("expectFile")
+    private static class Proc extends AbstractProcessor {
+        int count;
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (roundEnv.processingOver() || count++ > 0) {
+                return false;
+            }
+
+            Filer filer = processingEnv.getFiler();
+            Messager messager = processingEnv.getMessager();
+            Map<String, String> options = processingEnv.getOptions();
+                System.err.println(options);
+            boolean expectFile = options.containsKey("expectFile");
+
+            System.err.println("running Proc: expectFile=" + expectFile);
+
+            boolean found;
+            try {
+                messager.printMessage(Kind.NOTE, "found previous content of length " +
+                        filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length());
+                found = true;
+            } catch (FileNotFoundException x) {
+                messager.printMessage(Kind.NOTE, "not previously there");
+                found = false;
+            } catch (IOException x) {
+                messager.printMessage(Kind.ERROR, "while reading: " + x);
+                found = false;
+            }
+
+            if (expectFile && !found) {
+                messager.printMessage(Kind.ERROR, "expected file but file not found");
+            }
+
+            try {
+                Writer w = filer.createSourceFile("p.C").openWriter();
+                w.write("/* hello! */ package p; class C {}");
+                w.close();
+                messager.printMessage(Kind.NOTE, "wrote new content");
+            } catch (IOException x) {
+                messager.printMessage(Kind.ERROR, "while writing: " + x);
+            }
+
+            return true;
+        }
+
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+    }
+}
--- a/langtools/test/tools/javac/generics/6910550/T6910550d.out	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/generics/6910550/T6910550d.out	Wed Oct 26 17:59:13 2011 -0700
@@ -1,2 +1,2 @@
-T6910550d.java:12:14: compiler.err.already.defined: <X>m(X), T6910550d
+T6910550d.java:12:14: compiler.err.already.defined: kindname.method, <X>m(X), kindname.class, T6910550d
 1 error
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out	Wed Oct 26 17:59:13 2011 -0700
@@ -1,2 +1,2 @@
-T6638712a.java:16:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String>
+T6638712a.java:16:33: compiler.err.cant.apply.symbol.1: kindname.method, compound, java.lang.Iterable<? extends java.util.Comparator<? super T>>, java.util.List<java.util.Comparator<?>>, kindname.class, T6638712a, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super T>>)
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/7086586/T7086586.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,19 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7086586
+ * @summary Inference producing null type argument
+ * @compile/fail/ref=T7086586.out -XDrawDiagnostics T7086586.java
+ */
+import java.util.List;
+
+class T7086586 {
+
+    <T> List<T> m(List<? super T> dummy) { return null; }
+
+    void test(List<?> l) {
+        String s = m(l).get(0);
+        Number n = m(l).get(0);
+        Exception e = m(l).get(0);
+        m(l).nonExistentMethod();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/7086586/T7086586.out	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,5 @@
+T7086586.java:14:20: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)
+T7086586.java:15:20: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)
+T7086586.java:16:23: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)
+T7086586.java:17:9: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>)
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/7086586/T7086586b.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7086586
+ *
+ * @summary Inference producing null type argument
+ */
+import java.util.List;
+
+public class T7086586b {
+
+    int assertionCount = 0;
+
+    void assertTrue(boolean cond) {
+        if (!cond) {
+            throw new AssertionError();
+        }
+        assertionCount++;
+    }
+
+    <T> void m(List<? super T> dummy) { assertTrue(false); }
+    <T> void m(Object dummy) { assertTrue(true); }
+
+    void test(List<?> l) {
+        m(l);
+        assertTrue(assertionCount == 1);
+    }
+
+    public static void main(String[] args) {
+        new T7086586b().test(null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/7086601/T7086601a.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,34 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7086601
+ * @summary Error message bug: cause for method mismatch is 'null'
+ * @compile/fail/ref=T7086601a.out -XDrawDiagnostics T7086601a.java
+ */
+
+class T7086601 {
+    static <S> void m1(Iterable<? super S> s1, Iterable<? super S> s2) { }
+    static void m1(Object o) {}
+
+    static <S> void m2(Iterable<? super S> s1, Iterable<? super S> s2, Iterable<? super S> s3) { }
+    static void m2(Object o) {}
+
+    @SafeVarargs
+    static <S> void m3(Iterable<? super S>... ss) { }
+    static void m3(Object o) {}
+
+    static void test1(Iterable<String> is, Iterable<Integer> ii) {
+        m1(is, ii);
+    }
+
+    static void test2(Iterable<String> is, Iterable<Integer> ii, Iterable<Double> id) {
+        m2(is, ii, id);
+    }
+
+    static void test3(Iterable<String> is, Iterable<Integer> ii) {
+        m3(is, ii);
+    }
+
+    static void test4(Iterable<String> is, Iterable<Integer> ii, Iterable<Double> id) {
+        m3(is, ii, id);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/7086601/T7086601a.out	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,5 @@
+T7086601a.java:20:9: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m1(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String))}
+T7086601a.java:24:9: compiler.err.cant.apply.symbols: kindname.method, m2, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m2(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m2(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String))}
+T7086601a.java:28:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String))}
+T7086601a.java:32:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String))}
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/7086601/T7086601b.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7086601
+ * @summary Error message bug: cause for method mismatch is 'null'
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.ArrayList;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+
+public class T7086601b {
+
+    static int checkCount = 0;
+
+    enum TypeKind {
+        STRING("String", false),
+        INTEGER("Integer", false),
+        NUMBER("Number", false),
+        SERIALIZABLE("java.io.Serializable", true),
+        CLONEABLE("Cloneable", true),
+        X("X", false),
+        Y("Y", false),
+        Z("Z", false);
+
+        String typeStr;
+        boolean isInterface;
+
+        private TypeKind(String typeStr, boolean isInterface) {
+            this.typeStr = typeStr;
+            this.isInterface = isInterface;
+        }
+
+        boolean isSubtypeof(TypeKind other) {
+            return (this == INTEGER && other == NUMBER ||
+                    this == Z && other == Y ||
+                    this == other);
+        }
+    }
+
+    enum MethodCallKind {
+        ARITY_ONE("m(a1);", 1),
+        ARITY_TWO("m(a1, a2);", 2),
+        ARITY_THREE("m(a1, a2, a3);", 3);
+
+        String invokeString;
+        int arity;
+
+        private MethodCallKind(String invokeString, int arity) {
+            this.invokeString = invokeString;
+            this.arity = arity;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (TypeKind a1 : TypeKind.values()) {
+            for (TypeKind a2 : TypeKind.values()) {
+                for (TypeKind a3 : TypeKind.values()) {
+                    for (MethodCallKind mck : MethodCallKind.values()) {
+                        new T7086601b(a1, a2, a3, mck).run(comp, fm);
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    TypeKind a1;
+    TypeKind a2;
+    TypeKind a3;
+    MethodCallKind mck;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    T7086601b(TypeKind a1, TypeKind a2, TypeKind a3, MethodCallKind mck) {
+        this.a1 = a1;
+        this.a2 = a2;
+        this.a3 = a3;
+        this.mck = mck;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        final String bodyTemplate = "import java.util.List;\n"+
+                              "class Test {\n" +
+                              "   <Z> void m(List<? super Z> l1) { }\n" +
+                              "   <Z> void m(List<? super Z> l1, List<? super Z> l2) { }\n" +
+                              "   <Z> void m(List<? super Z> l1, List<? super Z> l2, List<? super Z> l3) { }\n" +
+                              "   <X,Y,Z extends Y> void test(List<#A1> a1, List<#A2> a2, List<#A3> a3) { #MC } }";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = bodyTemplate.replace("#A1", a1.typeStr)
+                             .replace("#A2", a2.typeStr).replace("#A3", a3.typeStr)
+                             .replace("#MC", mck.invokeString);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+
+        boolean errorExpected = false;
+
+        if (mck.arity > 1) {
+            TypeKind[] argtypes = { a1, a2, a3 };
+            ArrayList<TypeKind> classes = new ArrayList<>();
+            for (int i = 0 ; i < mck.arity ; i ++ ) {
+                if (!argtypes[i].isInterface) {
+                    classes.add(argtypes[i]);
+                }
+            }
+            boolean glb_exists = true;
+            for (TypeKind arg_i : classes) {
+                glb_exists = true;
+                for (TypeKind arg_j : classes) {
+                    if (!arg_i.isSubtypeof(arg_j)) {
+                        glb_exists = false;
+                        break;
+                    }
+                }
+                if (glb_exists) break;
+            }
+            errorExpected = !glb_exists;
+        }
+
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- a/langtools/test/tools/javac/lib/CompileFail.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/lib/CompileFail.java	Wed Oct 26 17:59:13 2011 -0700
@@ -23,6 +23,7 @@
 
 import java.io.*;
 import java.util.*;
+import com.sun.tools.javac.main.Main;
 
 /*
  * Utility class to emulate jtreg @compile/fail, but also checking the specific
@@ -58,32 +59,7 @@
     }
 
     static int getReturnCode(String name) {
-        switch (name) {
-            case "OK":
-                return EXIT_OK;
-
-            case "ERROR":
-                return EXIT_ERROR;
-
-            case "CMDERR":
-                return EXIT_CMDERR;
-
-            case "SYSERR":
-                return EXIT_SYSERR;
-
-            case "ABNORMAL":
-                return EXIT_ABNORMAL;
-
-            default:
-                throw new IllegalArgumentException(name);
-        }
+        return Main.Result.valueOf(name).exitCode;
     }
 
-    // The following is cut-n-paste from com.sun.tools.javac.main.Main
-    static final int
-        EXIT_OK = 0,        // Compilation completed with no errors.
-        EXIT_ERROR = 1,     // Completed but reported errors.
-        EXIT_CMDERR = 2,    // Bad command-line arguments
-        EXIT_SYSERR = 3,    // System error or resource exhaustion.
-        EXIT_ABNORMAL = 4;  // Compiler terminated abnormally
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7092965
+ * @summary javac should not close processorClassLoader before end of compilation
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.api.ClientCodeWrapper.Trusted;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Context;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+/*
+ * The test compiles an annotation processor and a helper class into a
+ * custom classes directory.
+ *
+ * It then uses them while compiling a dummy file, with the custom classes
+ * directory on the processor path, thus guaranteeing that references to
+ * these class are satisfied by the processor class loader.
+ *
+ * The annotation processor uses the javac TaskListener to run code
+ * after annotation processing has completed, to verify that the classloader
+ * is not closed until the end of the compilation.
+ */
+
+@Trusted // avoids use of ClientCodeWrapper
+public class TestClose implements TaskListener {
+    public static final String annoProc =
+        "import java.util.*;\n" +
+        "import javax.annotation.processing.*;\n" +
+        "import javax.lang.model.*;\n" +
+        "import javax.lang.model.element.*;\n" +
+        "import com.sun.source.util.*;\n" +
+        "import com.sun.tools.javac.processing.*;\n" +
+        "import com.sun.tools.javac.util.*;\n" +
+        "@SupportedAnnotationTypes(\"*\")\n" +
+        "public class AnnoProc extends AbstractProcessor {\n" +
+        "    @Override\n" +
+        "    public SourceVersion getSupportedSourceVersion() {\n" +
+        "        return SourceVersion.latest();\n" +
+        "    }\n" +
+        "    @Override\n" +
+        "    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {\n" +
+        "        System.out.println(\"in AnnoProc.process\");\n" +
+        "        final ClassLoader cl = getClass().getClassLoader();\n" +
+        "        if (roundEnv.processingOver()) {\n" +
+        "            TestClose.add(processingEnv, new Runnable() {\n" +
+        "                public void run() {\n" +
+        "                    System.out.println(getClass().getName() + \": run()\");\n" +
+        "                    try {\n" +
+        "                    cl.loadClass(\"Callback\")\n" +
+        "                        .asSubclass(Runnable.class)\n" +
+        "                        .newInstance()\n" +
+        "                        .run();\n" +
+        "                    } catch (ReflectiveOperationException e) {\n" +
+        "                        throw new Error(e);\n" +
+        "                    }\n" +
+        "                }\n" +
+        "            });\n" +
+        "        }\n" +
+        "        return true;\n" +
+        "    }\n" +
+        "}\n";
+
+    public static final String callback =
+        "public class Callback implements Runnable {\n" +
+        "    public void run() {\n" +
+        "        System.out.println(getClass().getName() + \": run()\");\n" +
+        "    }\n" +
+        "}";
+
+    public static void main(String... args) throws Exception {
+        new TestClose().run();
+    }
+
+    void run() throws IOException {
+        JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+
+        File classes = new File("classes");
+        classes.mkdirs();
+        File extraClasses = new File("extraClasses");
+        extraClasses.mkdirs();
+
+        System.out.println("compiling classes to extraClasses");
+        {   // setup class in extraClasses
+            fm.setLocation(StandardLocation.CLASS_OUTPUT,
+                    Collections.singleton(extraClasses));
+            List<? extends JavaFileObject> files = Arrays.asList(
+                    new MemFile("AnnoProc.java", annoProc),
+                    new MemFile("Callback.java", callback));
+            JavacTask task = tool.getTask(null, fm, null, null, null, files);
+            check(task.call());
+        }
+
+        System.out.println("compiling dummy to classes with anno processor");
+        {   // use that class in a TaskListener after processing has completed
+            PrintStream prev = System.out;
+            String out;
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            try (PrintStream ps = new PrintStream(baos)) {
+                System.setOut(ps);
+                File testClasses = new File(System.getProperty("test.classes"));
+                fm.setLocation(StandardLocation.CLASS_OUTPUT,
+                        Collections.singleton(classes));
+                fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
+                        Arrays.asList(extraClasses, testClasses));
+                List<? extends JavaFileObject> files = Arrays.asList(
+                        new MemFile("my://dummy", "class Dummy { }"));
+                List<String> options = Arrays.asList("-processor", "AnnoProc");
+                JavacTask task = tool.getTask(null, fm, null, options, null, files);
+                task.setTaskListener(this);
+                check(task.call());
+            } finally {
+                System.setOut(prev);
+                out = baos.toString();
+                if (!out.isEmpty())
+                    System.out.println(out);
+            }
+            check(out.contains("AnnoProc$1: run()"));
+            check(out.contains("Callback: run()"));
+        }
+    }
+
+    @Override
+    public void started(TaskEvent e) {
+        System.out.println("Started: " + e);
+    }
+
+    @Override
+    public void finished(TaskEvent e) {
+        System.out.println("Finished: " + e);
+        if (e.getKind() == TaskEvent.Kind.ANALYZE) {
+            for (Runnable r: runnables) {
+                System.out.println("running " + r);
+                r.run();
+            }
+        }
+    }
+
+    void check(boolean b) {
+        if (!b)
+            throw new AssertionError();
+    }
+
+
+    public static void add(ProcessingEnvironment env, Runnable r) {
+        try {
+            Context c = ((JavacProcessingEnvironment) env).getContext();
+            Object o = c.get(TaskListener.class);
+            // The TaskListener is an instanceof TestClose, but when using the
+            // default class loaders. the taskListener uses a different
+            // instance of Class<TestClose> than the anno processor.
+            // If you try to evaluate
+            //      TestClose tc = (TestClose) (o).
+            // you get the following somewhat confusing error:
+            //   java.lang.ClassCastException: TestClose cannot be cast to TestClose
+            // The workaround is to access the fields of TestClose with reflection.
+            Field f = o.getClass().getField("runnables");
+            @SuppressWarnings("unchecked")
+            List<Runnable> runnables = (List<Runnable>) f.get(o);
+            runnables.add(r);
+        } catch (Throwable t) {
+            System.err.println(t);
+        }
+    }
+
+    public List<Runnable> runnables = new ArrayList<>();
+
+    class MemFile extends SimpleJavaFileObject {
+        public final String text;
+
+        MemFile(String name, String text) {
+            super(URI.create(name), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+
+        @Override
+        public String getName() {
+            return uri.toString();
+        }
+
+        @Override
+        public String getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7092965
+ * @summary javac should not close processorClassLoader before end of compilation
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+@SupportedAnnotationTypes("*")
+public class TestClose2 extends AbstractProcessor implements TaskListener {
+
+    public static void main(String... args) throws Exception {
+        new TestClose2().run();
+    }
+
+    void run() throws IOException {
+        File testSrc = new File(System.getProperty("test.src"));
+        File testClasses = new File(System.getProperty("test.classes"));
+
+        JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
+        final ClassLoader cl = getClass().getClassLoader();
+        Context c = new Context();
+        StandardJavaFileManager fm = new JavacFileManager(c, true, null) {
+            @Override
+            protected ClassLoader getClassLoader(URL[] urls) {
+                return new URLClassLoader(urls, cl) {
+                    @Override
+                    public void close() throws IOException {
+                        System.err.println(getClass().getName() + " closing");
+                        TestClose2.this.closedCount++;
+                        TestClose2.this.closedIsLast = true;
+                        super.close();
+                    }
+                };
+            }
+        };
+
+        fm.setLocation(StandardLocation.CLASS_OUTPUT,
+                Collections.singleton(new File(".")));
+        fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
+                Collections.singleton(testClasses));
+        Iterable<? extends JavaFileObject> files =
+                fm.getJavaFileObjects(new File(testSrc, TestClose2.class.getName() + ".java"));
+        List<String> options = Arrays.asList(
+                "-processor", TestClose2.class.getName());
+
+        JavacTask task = tool.getTask(null, fm, null, options, null, files);
+        task.setTaskListener(this);
+
+        if (!task.call())
+            throw new Error("compilation failed");
+
+        if (closedCount == 0)
+            throw new Error("no closing message");
+        else if (closedCount > 1)
+            throw new Error(closedCount + " closed messages");
+
+        if (!closedIsLast)
+            throw new Error("closing message not last");
+    }
+
+    // AbstractProcessor methods
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        Messager messager = processingEnv.getMessager();
+        messager.printMessage(Diagnostic.Kind.NOTE, "processing");
+        return true;
+    }
+
+    // TaskListener methods
+
+    @Override
+    public void started(TaskEvent e) {
+        System.err.println("Started: " + e);
+        closedIsLast = false;
+    }
+
+    @Override
+    public void finished(TaskEvent e) {
+        System.err.println("Finished: " + e);
+        closedIsLast = false;
+    }
+
+    //
+
+    int closedCount = 0;
+    boolean closedIsLast = false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/tree/TestToString.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7080267
+ * @summary Call to toString() from an ExpressionStatementTree doesn't take in
+ *      consideration the ";" at the end
+ */
+
+import com.sun.source.tree.BlockTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.StatementTree;
+import com.sun.source.tree.Tree;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreeScanner;
+import com.sun.tools.javac.api.JavacTool;
+
+public class TestToString {
+    String[] statements = {
+        "i = i + 1;",
+        "i++;",
+        "m();",
+        ";",
+        "if (i == 0) return;",
+        "while (i > 0) i--;",
+        "{ }",
+        "{ i++; }",
+        "class C { }"
+    };
+
+    public static void main(String... args) throws Exception {
+        new TestToString().run();
+    }
+
+    void run() throws Exception {
+        for (String s: statements) {
+            test(s);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void test(String stmt) throws IOException {
+        System.err.println("Test: " + stmt);
+        List<String> options = Collections.<String>emptyList();
+        List<? extends JavaFileObject> files = Arrays.asList(new JavaSource(stmt));
+        JavacTask t = tool.getTask(null, fm, null, options, null, files);
+        checkEqual(scan(t.parse()), stmt);
+    }
+
+    String scan(Iterable<? extends CompilationUnitTree> trees) {
+        class Scanner extends TreeScanner<Void,StringBuilder> {
+            String scan(Iterable<? extends Tree> trees) {
+                StringBuilder sb = new StringBuilder();
+                scan(trees, sb);
+                return sb.toString();
+            }
+            @Override
+            public Void scan(Tree tree, StringBuilder sb) {
+                if (print && tree instanceof StatementTree) {
+                    sb.append(PREFIX);
+                    sb.append(tree);
+                    sb.append(SUFFIX);
+                    return null;
+                } else {
+                    return super.scan(tree, sb);
+                }
+            }
+            @Override
+            public Void visitBlock(BlockTree tree, StringBuilder sb) {
+                print = true;
+                try {
+                    return super.visitBlock(tree, sb);
+                } finally {
+                    print = false;
+                }
+            }
+            boolean print = false;
+        }
+        return new Scanner().scan(trees);
+    }
+
+    void checkEqual(String found, String expect) {
+        boolean match = (found == null) ? (expect == null) :
+            expect.equals(found
+                .replaceAll("^\\Q" + PREFIX + "\\E\\s*", "")
+                .replaceAll("\\s*\\Q" + SUFFIX + "\\E$", "")
+                .replaceAll("\\s+", " "));
+
+        if (!match)
+            error("Mismatch: expected: " + expect + " found: " + found);
+    }
+
+
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    static final String PREFIX = "#<";
+    static final String SUFFIX = "#>";
+
+    JavacTool tool = JavacTool.create();
+    StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+    int errors = 0;
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        String source =
+                "class Test {\n" +
+                "    int i;\n" +
+                "    void m() {\n" +
+                "        #S\n" +
+                "    }\n" +
+                "}";
+
+        public JavaSource(String stmt) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = source.replace("#S", stmt);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
--- a/langtools/test/tools/javac/util/context/T7021650.java	Mon Oct 24 09:58:47 2011 -0700
+++ b/langtools/test/tools/javac/util/context/T7021650.java	Wed Oct 26 17:59:13 2011 -0700
@@ -101,13 +101,13 @@
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         Main m = new Main("javac", pw);
-        int rc = m.compile(args, context);
+        Main.Result res = m.compile(args, context);
         pw.close();
         String out = sw.toString();
         if (!out.isEmpty())
             System.err.println(out);
-        if (rc != 0)
-            throw new Exception("compilation failed unexpectedly: rc=" + rc);
+        if (!res.isOK())
+            throw new Exception("compilation failed unexpectedly: result=" + res);
     }
 
     void checkEqual(String label, int found, int expect) throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/7090499/T7090499.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,37 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7094099
+ * @summary -Xlint:rawtypes
+ * @compile/fail/ref=T7090499.out -XDrawDiagnostics -Xlint:rawtypes T7090499.java
+ */
+
+
+class T7090499<E> {
+
+    static class B<X> {}
+
+    class A<X> {
+        class X {}
+        class Z<Y> {}
+    }
+
+    T7090499 t = new T7090499() { //raw warning (2)
+
+        A.X x1;//raw warning
+        A.Z z1;//raw warning
+
+        T7090499.B<Integer> b1;//ok
+        T7090499.B b2;//raw warning
+
+        A<String>.X x2;//ok
+        A<String>.Z<Integer> z2;//ok
+        A<B>.Z<A<B>> z3;//raw warning (2)
+
+        void test(Object arg1, B arg2) {//raw warning
+            boolean b = arg1 instanceof A;//ok
+            Object a = (A)arg1;//ok
+            A a2 = new A() {};//raw warning (2)
+            a2.new Z() {};//raw warning
+        }
+    };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/7090499/T7090499.out	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,17 @@
+T7090499.java:18:5: compiler.warn.raw.class.use: T7090499, T7090499<E>
+T7090499.java:18:22: compiler.warn.raw.class.use: T7090499, T7090499<E>
+T7090499.java:20:10: compiler.warn.raw.class.use: T7090499.A.X, T7090499<E>.A<X>.X
+T7090499.java:21:10: compiler.warn.raw.class.use: T7090499.A.Z, T7090499<E>.A<X>.Z<Y>
+T7090499.java:24:17: compiler.warn.raw.class.use: T7090499.B, T7090499.B<X>
+T7090499.java:26:10: compiler.err.improperly.formed.type.inner.raw.param
+T7090499.java:27:10: compiler.err.improperly.formed.type.inner.raw.param
+T7090499.java:28:18: compiler.warn.raw.class.use: T7090499.B, T7090499.B<X>
+T7090499.java:28:17: compiler.err.improperly.formed.type.inner.raw.param
+T7090499.java:28:11: compiler.warn.raw.class.use: T7090499.B, T7090499.B<X>
+T7090499.java:28:10: compiler.err.improperly.formed.type.inner.raw.param
+T7090499.java:30:32: compiler.warn.raw.class.use: T7090499.B, T7090499.B<X>
+T7090499.java:33:13: compiler.warn.raw.class.use: T7090499.A, T7090499<E>.A<X>
+T7090499.java:33:24: compiler.warn.raw.class.use: T7090499.A, T7090499<E>.A<X>
+T7090499.java:34:20: compiler.warn.raw.class.use: T7090499.A.Z, T7090499<E>.A<X>.Z<Y>
+4 errors
+11 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/parser/7091528/T7091528.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug     7091528
+ * @summary javadoc attempts to parse .class files
+ * @compile p/C1.java p/q/C2.java
+ * @run main T7091528
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+public class T7091528 {
+    public static void main(String... args) {
+        new T7091528().run();
+    }
+
+    void run() {
+        File testSrc = new File(System.getProperty("test.src"));
+        File testClasses = new File(System.getProperty("test.classes"));
+        String[] args = {
+            "-d", ".",
+            "-sourcepath", testClasses + File.pathSeparator + testSrc,
+            "-subpackages",
+            "p"
+        };
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        String doclet = com.sun.tools.doclets.standard.Standard.class.getName();
+        int rc = com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw, doclet, args);
+        pw.close();
+
+        String out = sw.toString();
+        if (!out.isEmpty()) {
+            System.err.println(out);
+        }
+
+        if (rc != 0)
+            System.err.println("javadoc failed: exit code = " + rc);
+
+        if (out.matches("(?s).*p/[^ ]+\\.class.*"))
+            throw new Error("reading .class files");
+
+        if (!new File("index.html").exists())
+            throw new Error("index.html not found");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/parser/7091528/p/C1.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+/** This is class C1. */
+public class C1 { }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/parser/7091528/p/q/C2.java	Wed Oct 26 17:59:13 2011 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p.q;
+
+/** This is class p.q.C2. */
+public class C2 { }
+
--- a/make/jprt.properties	Mon Oct 24 09:58:47 2011 -0700
+++ b/make/jprt.properties	Wed Oct 26 17:59:13 2011 -0700
@@ -295,6 +295,15 @@
     windows_i586_5.1-product-c1-jdk_security3, 			\
     windows_x64_5.2-product-c2-jdk_security3, 			\
     								\
+    solaris_sparc_5.10-product-c1-jdk_sound, 			\
+    solaris_sparcv9_5.10-product-c2-jdk_sound, 			\
+    solaris_i586_5.10-product-c1-jdk_sound, 			\
+    solaris_x64_5.10-product-c2-jdk_sound, 			\
+    linux_i586_2.6-product-{c1|c2}-jdk_sound, 			\
+    linux_x64_2.6-product-c2-jdk_sound, 			\
+    windows_i586_5.1-product-c1-jdk_sound, 			\
+    windows_x64_5.2-product-c2-jdk_sound, 			\
+    								\
     solaris_sparc_5.10-product-c1-jdk_swing, 			\
     solaris_sparcv9_5.10-product-c2-jdk_swing, 			\
     solaris_i586_5.10-product-c1-jdk_swing, 			\