changeset 17874:2c7132f3f1e6

Merge
author iignatyev
date Mon, 14 Apr 2014 22:53:29 +0400
parents ba8268c23fa2 (current diff) 270d7cb38f40 (diff)
children cb1b723cbca8
files
diffstat 32 files changed, 645 insertions(+), 681 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Fri Apr 11 00:35:23 2014 +0400
+++ b/.hgtags	Mon Apr 14 22:53:29 2014 +0400
@@ -441,3 +441,5 @@
 2627c7be4279478b880d7f643a252d185e4915ec hs25.20-b08
 e9ffa408f7af28205a7114ca78bce29846f5a8df jdk8u20-b08
 5186bc5047c1725888ed99f423bdfaa116e05abe hs25.20-b09
+4d73f1e99f97d1444e16ee5ef4634eb2129969ad jdk8u20-b09
+27a9e6a96a8ced7b7ee892d5d0f1a735b9010abb hs25.20-b10
--- a/make/hotspot_version	Fri Apr 11 00:35:23 2014 +0400
+++ b/make/hotspot_version	Mon Apr 14 22:53:29 2014 +0400
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=25
 HS_MINOR_VER=20
-HS_BUILD_NUMBER=10
+HS_BUILD_NUMBER=11
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=8
--- a/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1672,7 +1672,7 @@
   //__ flush_bundle();
   address entry = __ pc();
 
-  char *bname = NULL;
+  const char *bname = NULL;
   uint tsize = 0;
   switch(state) {
   case ftos:
--- a/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -960,7 +960,7 @@
 
   // reset handle block
   __ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), G3_scratch);
-  __ st_ptr(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
+  __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
 
 
   // handle exceptions (exception handling will handle unlocking!)
--- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -2687,7 +2687,7 @@
   if (!is_critical_native) {
     // reset handle block
     __ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), L5);
-    __ st_ptr(G0, L5, JNIHandleBlock::top_offset_in_bytes());
+    __ st(G0, L5, JNIHandleBlock::top_offset_in_bytes());
 
     __ ld_ptr(G2_thread, in_bytes(Thread::pending_exception_offset()), G3_scratch);
     check_forward_pending_exception(masm, G3_scratch);
--- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1147,7 +1147,7 @@
 
   // reset handle block
   __ ld_ptr(G2_thread, JavaThread::active_handles_offset(), G3_scratch);
-  __ st_ptr(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
+  __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
 
   // If we have an oop result store it where it will be safe for any further gc
   // until we return now that we've released the handle it might be protected by
--- a/src/cpu/x86/vm/cppInterpreter_x86.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/x86/vm/cppInterpreter_x86.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1354,7 +1354,7 @@
 
   // reset handle block
   __ movptr(t, Address(thread, JavaThread::active_handles_offset()));
-  __ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
+  __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
 
   // If result was an oop then unbox and save it in the frame
   { Label L;
--- a/src/cpu/x86/vm/globals_x86.hpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/x86/vm/globals_x86.hpp	Mon Apr 14 22:53:29 2014 +0400
@@ -162,7 +162,7 @@
           "Number of milliseconds to wait before start calculating aborts " \
           "for RTM locking")                                                \
                                                                             \
-  experimental(bool, UseRTMXendForLockBusy, false,                          \
+  experimental(bool, UseRTMXendForLockBusy, true,                           \
           "Use RTM Xend instead of Xabort when lock busy")                  \
                                                                             \
   /* assembler */                                                           \
--- a/src/cpu/x86/vm/macroAssembler_x86.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/x86/vm/macroAssembler_x86.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1488,11 +1488,10 @@
     movl(retry_on_abort_count_Reg, RTMRetryCount); // Retry on abort
     bind(L_rtm_retry);
   }
-  if (!UseRTMXendForLockBusy) {
-    movptr(tmpReg, Address(objReg, 0));
-    testptr(tmpReg, markOopDesc::monitor_value);  // inflated vs stack-locked|neutral|biased
-    jcc(Assembler::notZero, IsInflated);
-  }
+  movptr(tmpReg, Address(objReg, 0));
+  testptr(tmpReg, markOopDesc::monitor_value);  // inflated vs stack-locked|neutral|biased
+  jcc(Assembler::notZero, IsInflated);
+
   if (PrintPreciseRTMLockingStatistics || profile_rtm) {
     Label L_noincrement;
     if (RTMTotalCountIncrRate > 1) {
@@ -1512,10 +1511,7 @@
   Register abort_status_Reg = tmpReg; // status of abort is stored in RAX
   if (UseRTMXendForLockBusy) {
     xend();
-    movptr(tmpReg, Address(objReg, 0));
-    testptr(tmpReg, markOopDesc::monitor_value);  // inflated vs stack-locked|neutral|biased
-    jcc(Assembler::notZero, IsInflated);
-    movptr(abort_status_Reg, 0x1);                // Set the abort status to 1 (as xabort does)
+    movptr(abort_status_Reg, 0x2);   // Set the abort status to 2 (so we can retry)
     jmp(L_decrement_retry);
   }
   else {
--- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -2266,7 +2266,7 @@
   if (!is_critical_native) {
     // reset handle block
     __ movptr(rcx, Address(thread, JavaThread::active_handles_offset()));
-    __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
+    __ movl(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
 
     // Any exception pending?
     __ cmpptr(Address(thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD);
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -2509,7 +2509,7 @@
   if (!is_critical_native) {
     // reset handle block
     __ movptr(rcx, Address(r15_thread, JavaThread::active_handles_offset()));
-    __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
+    __ movl(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
   }
 
   // pop our frame
--- a/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1287,7 +1287,7 @@
 
   // reset handle block
   __ movptr(t, Address(thread, JavaThread::active_handles_offset()));
-  __ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
+  __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
 
   // If result was an oop then unbox and save it in the frame
   { Label L;
--- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1259,7 +1259,7 @@
 
   // reset handle block
   __ movptr(t, Address(r15_thread, JavaThread::active_handles_offset()));
-  __ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
+  __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
 
   // If result is an oop unbox and store it in frame where gc will see it
   // and result handler will pick it up
--- a/src/os/aix/vm/os_aix.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/os/aix/vm/os_aix.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -60,8 +60,8 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/statSampler.hpp"
 #include "runtime/stubRoutines.hpp"
+#include "runtime/thread.inline.hpp"
 #include "runtime/threadCritical.hpp"
-#include "runtime/thread.inline.hpp"
 #include "runtime/timer.hpp"
 #include "services/attachListener.hpp"
 #include "services/runtimeService.hpp"
@@ -70,16 +70,6 @@
 #include "utilities/events.hpp"
 #include "utilities/growableArray.hpp"
 #include "utilities/vmError.hpp"
-#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 (sorted alphabetically)
 #include <errno.h>
@@ -378,13 +368,14 @@
   assert(_page_size == SIZE_4K, "surprise!");
 
 
-  // query default data page size (default page size for C-Heap, pthread stacks and .bss).
+  // Query default data page size (default page size for C-Heap, pthread stacks and .bss).
   // Default data page size is influenced either by linker options (-bdatapsize)
   // or by environment variable LDR_CNTRL (suboption DATAPSIZE). If none is given,
   // default should be 4K.
   size_t data_page_size = SIZE_4K;
   {
     void* p = ::malloc(SIZE_16M);
+    guarantee(p != NULL, "malloc failed");
     data_page_size = os::Aix::query_pagesize(p);
     ::free(p);
   }
@@ -511,85 +502,76 @@
 
 } // end os::Aix::query_multipage_support()
 
-
-// The code for this method was initially derived from the version in os_linux.cpp
+// The code for this method was initially derived from the version in os_linux.cpp.
 void os::init_system_properties_values() {
-  // The next few definitions allow the code to be verbatim:
-#define malloc(n) (char*)NEW_C_HEAP_ARRAY(char, (n), mtInternal)
+
 #define DEFAULT_LIBPATH "/usr/lib:/lib"
 #define EXTENSIONS_DIR  "/lib/ext"
 #define ENDORSED_DIR    "/lib/endorsed"
 
+  // Buffer that fits several sprintfs.
+  // Note that the space for the trailing null is provided
+  // by the nulls included by the sizeof operator.
+  const size_t bufsize =
+    MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR), // extensions dir
+         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+  char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
+
   // 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);
-  strcpy(dll_path, buf);
-  Arguments::set_dll_dir(dll_path);
-
-  if (pslash != NULL) {
+  {
+    char *pslash;
+    os::jvm_path(buf, bufsize);
+
+    // 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 /<arch>
+      *pslash = '\0';            // Get rid of /{client|server|hotspot}.
+    }
+    Arguments::set_dll_dir(buf);
+
+    if (pslash != NULL) {
       pslash = strrchr(buf, '/');
       if (pslash != NULL) {
-        *pslash = '\0';        // get rid of /lib
+        *pslash = '\0';          // Get rid of /<arch>.
+        pslash = strrchr(buf, '/');
+        if (pslash != NULL) {
+          *pslash = '\0';        // Get rid of /lib.
+        }
       }
     }
-  }
-
-  home_path = malloc(strlen(buf) + 1);
-  strcpy(home_path, buf);
-  Arguments::set_java_home(home_path);
-
-  if (!set_boot_path('/', ':')) return;
-
-  // Where to look for native libraries
-
-  // On Aix we get the user setting of LIBPATH
+    Arguments::set_java_home(buf);
+    set_boot_path('/', ':');
+  }
+
+  // Where to look for native libraries.
+
+  // On Aix we get the user setting of LIBPATH.
   // Eventually, all the library path setting will be done here.
-  char *ld_library_path;
-
-  // Construct the invariant part of ld_library_path.
-  ld_library_path = (char *) malloc(sizeof(DEFAULT_LIBPATH));
-  sprintf(ld_library_path, DEFAULT_LIBPATH);
-
-  // Get the user setting of LIBPATH, and prepended it.
-  char *v = ::getenv("LIBPATH");
-  if (v == NULL) {
-    v = "";
-  }
-
-  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);
-
+  // Get the user setting of LIBPATH.
+  const char *v = ::getenv("LIBPATH");
+  const char *v_colon = ":";
+  if (v == NULL) { v = ""; v_colon = ""; }
+
+  // Concatenate user and invariant part of ld_library_path.
+  // That's +1 for the colon and +1 for the trailing '\0'.
+  char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char, strlen(v) + 1 + sizeof(DEFAULT_LIBPATH) + 1, mtInternal);
+  sprintf(ld_library_path, "%s%s" DEFAULT_LIBPATH, v, v_colon);
   Arguments::set_library_path(ld_library_path);
-
-  // Extensions directories
-  char* cbuf = malloc(strlen(Arguments::get_java_home()) + sizeof(EXTENSIONS_DIR));
-  sprintf(cbuf, "%s" EXTENSIONS_DIR, Arguments::get_java_home());
-  Arguments::set_ext_dirs(cbuf);
+  FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
+
+  // Extensions directories.
+  sprintf(buf, "%s" EXTENSIONS_DIR, Arguments::get_java_home());
+  Arguments::set_ext_dirs(buf);
 
   // Endorsed standards default directory.
-  cbuf = malloc(strlen(Arguments::get_java_home()) + sizeof(ENDORSED_DIR));
-  sprintf(cbuf, "%s" ENDORSED_DIR, Arguments::get_java_home());
-  Arguments::set_endorsed_dirs(cbuf);
-
-#undef malloc
+  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
+  Arguments::set_endorsed_dirs(buf);
+
+  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+
 #undef DEFAULT_LIBPATH
 #undef EXTENSIONS_DIR
 #undef ENDORSED_DIR
--- a/src/os/bsd/vm/os_bsd.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/os/bsd/vm/os_bsd.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -306,9 +306,6 @@
 #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.so.
@@ -335,199 +332,205 @@
   // 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), mtInternal)
-#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.
- */
+// 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
 
+// Base path of extensions installed on the system.
+#define SYS_EXT_DIR     "/usr/java/packages"
 #define EXTENSIONS_DIR  "/lib/ext"
 #define ENDORSED_DIR    "/lib/endorsed"
-#define REG_DIR         "/usr/java/packages"
-
-#ifdef __APPLE__
+
+#ifndef __APPLE__
+
+  // Buffer that fits several sprintfs.
+  // Note that the space for the colon and the trailing null are provided
+  // by the nulls included by the sizeof operator.
+  const size_t bufsize =
+    MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR), // extensions dir
+         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+  char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
+
+  // sysclasspath, java_home, dll_dir
+  {
+    char *pslash;
+    os::jvm_path(buf, bufsize);
+
+    // 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}.
+    }
+    Arguments::set_dll_dir(buf);
+
+    if (pslash != NULL) {
+      pslash = strrchr(buf, '/');
+      if (pslash != NULL) {
+        *pslash = '\0';          // Get rid of /<arch>.
+        pslash = strrchr(buf, '/');
+        if (pslash != NULL) {
+          *pslash = '\0';        // Get rid of /lib.
+        }
+      }
+    }
+    Arguments::set_java_home(buf);
+    set_boot_path('/', ':');
+  }
+
+  // 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.
+  {
+    // Get the user setting of LD_LIBRARY_PATH, and prepended it. It
+    // should always exist (until the legacy problem cited above is
+    // addressed).
+    const char *v = ::getenv("LD_LIBRARY_PATH");
+    const char *v_colon = ":";
+    if (v == NULL) { v = ""; v_colon = ""; }
+    // That's +1 for the colon and +1 for the trailing '\0'.
+    char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char,
+                                                     strlen(v) + 1 +
+                                                     sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1,
+                                                     mtInternal);
+    sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch);
+    Arguments::set_library_path(ld_library_path);
+    FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
+  }
+
+  // Extensions directories.
+  sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
+  Arguments::set_ext_dirs(buf);
+
+  // Endorsed standards default directory.
+  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
+  Arguments::set_endorsed_dirs(buf);
+
+  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+
+#else // __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
-
+
+  const char *user_home_dir = get_home();
+  // The null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir.
+  size_t system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) +
+    sizeof(SYS_EXTENSIONS_DIRS);
+
+  // Buffer that fits several sprintfs.
+  // Note that the space for the colon and the trailing null are provided
+  // by the nulls included by the sizeof operator.
+  const size_t bufsize =
+    MAX3((size_t)MAXPATHLEN,  // for dll_dir & friends.
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + system_ext_size, // extensions dir
+         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+  char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
+
+  // sysclasspath, java_home, dll_dir
   {
-    /* 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;
+    char *pslash;
+    os::jvm_path(buf, bufsize);
+
+    // 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}.
+    }
+    Arguments::set_dll_dir(buf);
+
+    if (pslash != NULL) {
+      pslash = strrchr(buf, '/');
+      if (pslash != NULL) {
+        *pslash = '\0';          // Get rid of /lib.
+      }
     }
-
-    /*
-     * 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);
-        }
-
-#ifdef __APPLE__
-        // Apple's Java6 has "." at the beginning of java.library.path.
-        // OpenJDK on Windows has "." at the end of java.library.path.
-        // OpenJDK on Linux and Solaris don't have "." in java.library.path
-        // at all. To ease the transition from Apple's Java6 to OpenJDK7,
-        // "." is appended to the end of java.library.path. Yes, this
-        // could cause a change in behavior, but Apple's Java6 behavior
-        // can be achieved by putting "." at the beginning of the
-        // JAVA_LIBRARY_PATH environment variable.
-        {
-            char *t = ld_library_path;
-            // that's +3 for appending ":." and the trailing '\0'
-            ld_library_path = (char *) malloc(strlen(t) + 3);
-            sprintf(ld_library_path, "%s:%s", t, ".");
-            free(t);
-        }
-#endif
-
-        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);
-    }
+    Arguments::set_java_home(buf);
+    set_boot_path('/', ':');
   }
 
-#ifdef __APPLE__
+  // 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.
+  {
+    // Get the user setting of LD_LIBRARY_PATH, and prepended it. It
+    // should always exist (until the legacy problem cited above is
+    // addressed).
+    // Prepend the default path with the JAVA_LIBRARY_PATH so that the app launcher code
+    // can specify a directory inside an app wrapper
+    const char *l = ::getenv("JAVA_LIBRARY_PATH");
+    const char *l_colon = ":";
+    if (l == NULL) { l = ""; l_colon = ""; }
+
+    const char *v = ::getenv("DYLD_LIBRARY_PATH");
+    const char *v_colon = ":";
+    if (v == NULL) { v = ""; v_colon = ""; }
+
+    // Apple's Java6 has "." at the beginning of java.library.path.
+    // OpenJDK on Windows has "." at the end of java.library.path.
+    // OpenJDK on Linux and Solaris don't have "." in java.library.path
+    // at all. To ease the transition from Apple's Java6 to OpenJDK7,
+    // "." is appended to the end of java.library.path. Yes, this
+    // could cause a change in behavior, but Apple's Java6 behavior
+    // can be achieved by putting "." at the beginning of the
+    // JAVA_LIBRARY_PATH environment variable.
+    char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char,
+                                                     strlen(v) + 1 + strlen(l) + 1 +
+                                                     system_ext_size + 3,
+                                                     mtInternal);
+    sprintf(ld_library_path, "%s%s%s%s%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS ":.",
+            v, v_colon, l, l_colon, user_home_dir);
+    Arguments::set_library_path(ld_library_path);
+    FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
+  }
+
+  // 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).
+  sprintf(buf, "%s" SYS_EXTENSIONS_DIR ":%s" EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS,
+          user_home_dir, Arguments::get_java_home());
+  Arguments::set_ext_dirs(buf);
+
+  // Endorsed standards default directory.
+  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
+  Arguments::set_endorsed_dirs(buf);
+
+  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+
 #undef SYS_EXTENSIONS_DIR
-#endif
-#undef malloc
-#undef getenv
+#undef SYS_EXTENSIONS_DIRS
+
+#endif // __APPLE__
+
+#undef SYS_EXT_DIR
 #undef EXTENSIONS_DIR
 #undef ENDORSED_DIR
-
-  // Done
-  return;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -3223,7 +3226,7 @@
     sigAct.sa_sigaction = signalHandler;
     sigAct.sa_flags = SA_SIGINFO|SA_RESTART;
   }
-#if __APPLE__
+#ifdef __APPLE__
   // Needed for main thread as XNU (Mac OS X kernel) will only deliver SIGSEGV
   // (which starts as SIGBUS) on main thread with faulting address inside "stack+guard pages"
   // if the signal handler declares it will handle it on alternate stack.
--- a/src/os/linux/vm/os_linux.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/os/linux/vm/os_linux.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -319,9 +319,6 @@
 }
 
 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.so.
@@ -348,140 +345,101 @@
   // 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), mtInternal)
-#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.
- */
+// 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.
 #if defined(AMD64) || defined(_LP64) && (defined(SPARC) || defined(PPC) || defined(S390))
 #define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
 #else
 #define DEFAULT_LIBPATH "/lib:/usr/lib"
 #endif
 
+// Base path of extensions installed on the system.
+#define SYS_EXT_DIR     "/usr/java/packages"
 #define EXTENSIONS_DIR  "/lib/ext"
 #define ENDORSED_DIR    "/lib/endorsed"
-#define REG_DIR         "/usr/java/packages"
-
+
+  // Buffer that fits several sprintfs.
+  // Note that the space for the colon and the trailing null are provided
+  // by the nulls included by the sizeof operator.
+  const size_t bufsize =
+    MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR), // extensions dir
+         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+  char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
+
+  // sysclasspath, java_home, dll_dir
   {
-    /* 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 */
+    char *pslash;
+    os::jvm_path(buf, bufsize);
+
+    // 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}.
+    }
+    Arguments::set_dll_dir(buf);
+
+    if (pslash != NULL) {
+      pslash = strrchr(buf, '/');
+      if (pslash != NULL) {
+        *pslash = '\0';          // Get rid of /<arch>.
         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> */
-                pslash = strrchr(buf, '/');
-                if (pslash != NULL)
-                    *pslash = '\0';   /* get rid of /lib */
-            }
+          *pslash = '\0';        // Get rid of /lib.
         }
-
-        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 Linux 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).
-         */
-        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);
-
-        /*
-         * Get the user setting of LD_LIBRARY_PATH, and prepended it.  It
-         * should always exist (until the legacy problem cited above is
-         * addressed).
-         */
-        char *v = getenv("LD_LIBRARY_PATH");
-        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);
-        }
-        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).
-     */
-    {
-        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());
-        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);
-    }
-  }
-
-#undef malloc
-#undef getenv
+    Arguments::set_java_home(buf);
+    set_boot_path('/', ':');
+  }
+
+  // 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 Linux 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.
+  {
+    // Get the user setting of LD_LIBRARY_PATH, and prepended it. It
+    // should always exist (until the legacy problem cited above is
+    // addressed).
+    const char *v = ::getenv("LD_LIBRARY_PATH");
+    const char *v_colon = ":";
+    if (v == NULL) { v = ""; v_colon = ""; }
+    // That's +1 for the colon and +1 for the trailing '\0'.
+    char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char,
+                                                     strlen(v) + 1 +
+                                                     sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1,
+                                                     mtInternal);
+    sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch);
+    Arguments::set_library_path(ld_library_path);
+    FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
+  }
+
+  // Extensions directories.
+  sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
+  Arguments::set_ext_dirs(buf);
+
+  // Endorsed standards default directory.
+  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
+  Arguments::set_endorsed_dirs(buf);
+
+  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+
+#undef DEFAULT_LIBPATH
+#undef SYS_EXT_DIR
 #undef EXTENSIONS_DIR
 #undef ENDORSED_DIR
-
-  // Done
-  return;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/src/os/solaris/vm/os_solaris.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/os/solaris/vm/os_solaris.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -648,9 +648,6 @@
 
 
 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.so.
@@ -677,218 +674,174 @@
   // 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), mtInternal)
-#define free(p) FREE_C_HEAP_ARRAY(char, p, mtInternal)
-#define getenv(n) ::getenv(n)
-
+// Base path of extensions installed on the system.
+#define SYS_EXT_DIR     "/usr/jdk/packages"
 #define EXTENSIONS_DIR  "/lib/ext"
 #define ENDORSED_DIR    "/lib/endorsed"
-#define COMMON_DIR      "/usr/jdk/packages"
-
+
+  char cpu_arch[12];
+  // Buffer that fits several sprintfs.
+  // Note that the space for the colon and the trailing null are provided
+  // by the nulls included by the sizeof operator.
+  const size_t bufsize =
+    MAX4((size_t)MAXPATHLEN,  // For dll_dir & friends.
+         sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch), // invariant ld_library_path
+         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR), // extensions dir
+         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
+  char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
+
+  // sysclasspath, java_home, dll_dir
   {
-    /* 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> */
-                pslash = strrchr(buf, '/');
-                if (pslash != NULL)
-                    *pslash = '\0';   /* get rid of /lib */
-            }
-        }
-
-        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;
+    char *pslash;
+    os::jvm_path(buf, bufsize);
+
+    // 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}.
     }
-
-    /*
-     * Where to look for native libraries
-     */
-    {
-      // Use dlinfo() to determine the correct java.library.path.
-      //
-      // If we're launched by the Java launcher, and the user
-      // does not set java.library.path explicitly on the commandline,
-      // the Java launcher sets LD_LIBRARY_PATH for us and unsets
-      // LD_LIBRARY_PATH_32 and LD_LIBRARY_PATH_64.  In this case
-      // dlinfo returns LD_LIBRARY_PATH + crle settings (including
-      // /usr/lib), which is exactly what we want.
-      //
-      // If the user does set java.library.path, it completely
-      // overwrites this setting, and always has.
-      //
-      // If we're not launched by the Java launcher, we may
-      // get here with any/all of the LD_LIBRARY_PATH[_32|64]
-      // settings.  Again, dlinfo does exactly what we want.
-
-      Dl_serinfo     _info, *info = &_info;
-      Dl_serpath     *path;
-      char*          library_path;
-      char           *common_path;
-      int            i;
-
-      // determine search path count and required buffer size
-      if (dlinfo(RTLD_SELF, RTLD_DI_SERINFOSIZE, (void *)info) == -1) {
-        vm_exit_during_initialization("dlinfo SERINFOSIZE request", dlerror());
-      }
-
-      // allocate new buffer and initialize
-      info = (Dl_serinfo*)malloc(_info.dls_size);
-      if (info == NULL) {
-        vm_exit_out_of_memory(_info.dls_size, OOM_MALLOC_ERROR,
-                              "init_system_properties_values info");
-      }
-      info->dls_size = _info.dls_size;
-      info->dls_cnt = _info.dls_cnt;
-
-      // obtain search path information
-      if (dlinfo(RTLD_SELF, RTLD_DI_SERINFO, (void *)info) == -1) {
-        free(info);
-        vm_exit_during_initialization("dlinfo SERINFO request", dlerror());
+    Arguments::set_dll_dir(buf);
+
+    if (pslash != NULL) {
+      pslash = strrchr(buf, '/');
+      if (pslash != NULL) {
+        *pslash = '\0';          // Get rid of /<arch>.
+        pslash = strrchr(buf, '/');
+        if (pslash != NULL) {
+          *pslash = '\0';        // Get rid of /lib.
+        }
       }
-
-      path = &info->dls_serpath[0];
-
-      // Note: Due to a legacy implementation, most of the library path
-      // is set in the launcher.  This was to accomodate linking restrictions
-      // on legacy Solaris 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/jdk/packages is added here.
-
-      // Determine the actual CPU architecture.
-      char cpu_arch[12];
-      sysinfo(SI_ARCHITECTURE, cpu_arch, sizeof(cpu_arch));
+    }
+    Arguments::set_java_home(buf);
+    set_boot_path('/', ':');
+  }
+
+  // Where to look for native libraries.
+  {
+    // Use dlinfo() to determine the correct java.library.path.
+    //
+    // If we're launched by the Java launcher, and the user
+    // does not set java.library.path explicitly on the commandline,
+    // the Java launcher sets LD_LIBRARY_PATH for us and unsets
+    // LD_LIBRARY_PATH_32 and LD_LIBRARY_PATH_64.  In this case
+    // dlinfo returns LD_LIBRARY_PATH + crle settings (including
+    // /usr/lib), which is exactly what we want.
+    //
+    // If the user does set java.library.path, it completely
+    // overwrites this setting, and always has.
+    //
+    // If we're not launched by the Java launcher, we may
+    // get here with any/all of the LD_LIBRARY_PATH[_32|64]
+    // settings.  Again, dlinfo does exactly what we want.
+
+    Dl_serinfo     info_sz, *info = &info_sz;
+    Dl_serpath     *path;
+    char           *library_path;
+    char           *common_path = buf;
+
+    // Determine search path count and required buffer size.
+    if (dlinfo(RTLD_SELF, RTLD_DI_SERINFOSIZE, (void *)info) == -1) {
+      FREE_C_HEAP_ARRAY(char, buf,  mtInternal);
+      vm_exit_during_initialization("dlinfo SERINFOSIZE request", dlerror());
+    }
+
+    // Allocate new buffer and initialize.
+    info = (Dl_serinfo*)NEW_C_HEAP_ARRAY(char, info_sz.dls_size, mtInternal);
+    info->dls_size = info_sz.dls_size;
+    info->dls_cnt = info_sz.dls_cnt;
+
+    // Obtain search path information.
+    if (dlinfo(RTLD_SELF, RTLD_DI_SERINFO, (void *)info) == -1) {
+      FREE_C_HEAP_ARRAY(char, buf,  mtInternal);
+      FREE_C_HEAP_ARRAY(char, info, mtInternal);
+      vm_exit_during_initialization("dlinfo SERINFO request", dlerror());
+    }
+
+    path = &info->dls_serpath[0];
+
+    // Note: Due to a legacy implementation, most of the library path
+    // is set in the launcher. This was to accomodate linking restrictions
+    // on legacy Solaris 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/jdk/packages is added here.
+
+    // Determine the actual CPU architecture.
+    sysinfo(SI_ARCHITECTURE, cpu_arch, sizeof(cpu_arch));
 #ifdef _LP64
-      // If we are a 64-bit vm, perform the following translations:
-      //   sparc   -> sparcv9
-      //   i386    -> amd64
-      if (strcmp(cpu_arch, "sparc") == 0)
-        strcat(cpu_arch, "v9");
-      else if (strcmp(cpu_arch, "i386") == 0)
-        strcpy(cpu_arch, "amd64");
+    // If we are a 64-bit vm, perform the following translations:
+    //   sparc   -> sparcv9
+    //   i386    -> amd64
+    if (strcmp(cpu_arch, "sparc") == 0) {
+      strcat(cpu_arch, "v9");
+    } else if (strcmp(cpu_arch, "i386") == 0) {
+      strcpy(cpu_arch, "amd64");
+    }
 #endif
 
-      // 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.
-      size_t bufsize = sizeof(COMMON_DIR) + sizeof("/lib/") + strlen(cpu_arch);
-      common_path = malloc(bufsize);
-      if (common_path == NULL) {
-        free(info);
-        vm_exit_out_of_memory(bufsize, OOM_MALLOC_ERROR,
-                              "init_system_properties_values common_path");
-      }
-      sprintf(common_path, COMMON_DIR "/lib/%s", cpu_arch);
-
-      // struct size is more than sufficient for the path components obtained
-      // through the dlinfo() call, so only add additional space for the path
-      // components explicitly added here.
-      bufsize = info->dls_size + strlen(common_path);
-      library_path = malloc(bufsize);
-      if (library_path == NULL) {
-        free(info);
-        free(common_path);
-        vm_exit_out_of_memory(bufsize, OOM_MALLOC_ERROR,
-                              "init_system_properties_values library_path");
+    // Construct the invariant part of ld_library_path.
+    sprintf(common_path, SYS_EXT_DIR "/lib/%s", cpu_arch);
+
+    // Struct size is more than sufficient for the path components obtained
+    // through the dlinfo() call, so only add additional space for the path
+    // components explicitly added here.
+    size_t library_path_size = info->dls_size + strlen(common_path);
+    library_path = (char *)NEW_C_HEAP_ARRAY(char, library_path_size, mtInternal);
+    library_path[0] = '\0';
+
+    // Construct the desired Java library path from the linker's library
+    // search path.
+    //
+    // For compatibility, it is optimal that we insert the additional path
+    // components specific to the Java VM after those components specified
+    // in LD_LIBRARY_PATH (if any) but before those added by the ld.so
+    // infrastructure.
+    if (info->dls_cnt == 0) { // Not sure this can happen, but allow for it.
+      strcpy(library_path, common_path);
+    } else {
+      int inserted = 0;
+      int i;
+      for (i = 0; i < info->dls_cnt; i++, path++) {
+        uint_t flags = path->dls_flags & LA_SER_MASK;
+        if (((flags & LA_SER_LIBPATH) == 0) && !inserted) {
+          strcat(library_path, common_path);
+          strcat(library_path, os::path_separator());
+          inserted = 1;
+        }
+        strcat(library_path, path->dls_name);
+        strcat(library_path, os::path_separator());
       }
-      library_path[0] = '\0';
-
-      // Construct the desired Java library path from the linker's library
-      // search path.
-      //
-      // For compatibility, it is optimal that we insert the additional path
-      // components specific to the Java VM after those components specified
-      // in LD_LIBRARY_PATH (if any) but before those added by the ld.so
-      // infrastructure.
-      if (info->dls_cnt == 0) { // Not sure this can happen, but allow for it
-        strcpy(library_path, common_path);
-      } else {
-        int inserted = 0;
-        for (i = 0; i < info->dls_cnt; i++, path++) {
-          uint_t flags = path->dls_flags & LA_SER_MASK;
-          if (((flags & LA_SER_LIBPATH) == 0) && !inserted) {
-            strcat(library_path, common_path);
-            strcat(library_path, os::path_separator());
-            inserted = 1;
-          }
-          strcat(library_path, path->dls_name);
-          strcat(library_path, os::path_separator());
-        }
-        // eliminate trailing path separator
-        library_path[strlen(library_path)-1] = '\0';
-      }
-
-      // happens before argument parsing - can't use a trace flag
-      // tty->print_raw("init_system_properties_values: native lib path: ");
-      // tty->print_raw_cr(library_path);
-
-      // callee copies into its own buffer
-      Arguments::set_library_path(library_path);
-
-      free(common_path);
-      free(library_path);
-      free(info);
+      // Eliminate trailing path separator.
+      library_path[strlen(library_path)-1] = '\0';
     }
 
-    /*
-     * 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).
-     */
-    {
-        char *buf = (char *) malloc(strlen(Arguments::get_java_home()) +
-            sizeof(EXTENSIONS_DIR) + sizeof(COMMON_DIR) +
-            sizeof(EXTENSIONS_DIR));
-        sprintf(buf, "%s" EXTENSIONS_DIR ":" COMMON_DIR EXTENSIONS_DIR,
-            Arguments::get_java_home());
-        Arguments::set_ext_dirs(buf);
-    }
-
-    /* Endorsed standards default directory. */
-    {
-        char * buf = malloc(strlen(Arguments::get_java_home()) + sizeof(ENDORSED_DIR));
-        sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
-        Arguments::set_endorsed_dirs(buf);
-    }
-  }
-
-#undef malloc
-#undef free
-#undef getenv
+    // happens before argument parsing - can't use a trace flag
+    // tty->print_raw("init_system_properties_values: native lib path: ");
+    // tty->print_raw_cr(library_path);
+
+    // Callee copies into its own buffer.
+    Arguments::set_library_path(library_path);
+
+    FREE_C_HEAP_ARRAY(char, library_path, mtInternal);
+    FREE_C_HEAP_ARRAY(char, info, mtInternal);
+  }
+
+  // Extensions directories.
+  sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
+  Arguments::set_ext_dirs(buf);
+
+  // Endorsed standards default directory.
+  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
+  Arguments::set_endorsed_dirs(buf);
+
+  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
+
+#undef SYS_EXT_DIR
 #undef EXTENSIONS_DIR
 #undef ENDORSED_DIR
-#undef COMMON_DIR
-
 }
 
 void os::breakpoint() {
--- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1288,7 +1288,7 @@
   print_heap_before_gc();
   trace_heap_before_gc(gc_tracer);
 
-  size_t metadata_prev_used = MetaspaceAux::allocated_used_bytes();
+  size_t metadata_prev_used = MetaspaceAux::used_bytes();
 
   verify_region_sets_optional();
 
--- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1204,7 +1204,7 @@
          (_young_list_target_length * HeapRegion::GrainBytes) - _survivor_used_bytes_before_gc;
 
   if (full) {
-    _metaspace_used_bytes_before_gc = MetaspaceAux::allocated_used_bytes();
+    _metaspace_used_bytes_before_gc = MetaspaceAux::used_bytes();
   }
 }
 
--- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -184,7 +184,7 @@
     size_t prev_used = heap->used();
 
     // Capture metadata size before collection for sizing.
-    size_t metadata_prev_used = MetaspaceAux::allocated_used_bytes();
+    size_t metadata_prev_used = MetaspaceAux::used_bytes();
 
     // For PrintGCDetails
     size_t old_gen_prev_used = old_gen->used_in_bytes();
--- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -927,7 +927,7 @@
     _heap_used      = heap->used();
     _young_gen_used = heap->young_gen()->used_in_bytes();
     _old_gen_used   = heap->old_gen()->used_in_bytes();
-    _metadata_used  = MetaspaceAux::allocated_used_bytes();
+    _metadata_used  = MetaspaceAux::used_bytes();
   };
 
   size_t heap_used() const      { return _heap_used; }
--- a/src/share/vm/gc_implementation/shared/gcHeapSummary.hpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/gc_implementation/shared/gcHeapSummary.hpp	Mon Apr 14 22:53:29 2014 +0400
@@ -62,16 +62,16 @@
 };
 
 class MetaspaceSizes : public StackObj {
-  size_t _capacity;
+  size_t _committed;
   size_t _used;
   size_t _reserved;
 
  public:
-  MetaspaceSizes() : _capacity(0), _used(0), _reserved(0) {}
-  MetaspaceSizes(size_t capacity, size_t used, size_t reserved) :
-    _capacity(capacity), _used(used), _reserved(reserved) {}
+  MetaspaceSizes() : _committed(0), _used(0), _reserved(0) {}
+  MetaspaceSizes(size_t committed, size_t used, size_t reserved) :
+    _committed(committed), _used(used), _reserved(reserved) {}
 
-  size_t capacity() const { return _capacity; }
+  size_t committed() const { return _committed; }
   size_t used() const { return _used; }
   size_t reserved() const { return _reserved; }
 };
--- a/src/share/vm/gc_implementation/shared/gcTraceSend.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/gc_implementation/shared/gcTraceSend.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -258,7 +258,7 @@
 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
   TraceStructMetaspaceSizes meta_sizes;
 
-  meta_sizes.set_capacity(sizes.capacity());
+  meta_sizes.set_committed(sizes.committed());
   meta_sizes.set_used(sizes.used());
   meta_sizes.set_reserved(sizes.reserved());
 
--- a/src/share/vm/gc_interface/collectedHeap.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/gc_interface/collectedHeap.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -85,16 +85,16 @@
 
 MetaspaceSummary CollectedHeap::create_metaspace_summary() {
   const MetaspaceSizes meta_space(
-      MetaspaceAux::allocated_capacity_bytes(),
-      MetaspaceAux::allocated_used_bytes(),
+      MetaspaceAux::committed_bytes(),
+      MetaspaceAux::used_bytes(),
       MetaspaceAux::reserved_bytes());
   const MetaspaceSizes data_space(
-      MetaspaceAux::allocated_capacity_bytes(Metaspace::NonClassType),
-      MetaspaceAux::allocated_used_bytes(Metaspace::NonClassType),
+      MetaspaceAux::committed_bytes(Metaspace::NonClassType),
+      MetaspaceAux::used_bytes(Metaspace::NonClassType),
       MetaspaceAux::reserved_bytes(Metaspace::NonClassType));
   const MetaspaceSizes class_space(
-      MetaspaceAux::allocated_capacity_bytes(Metaspace::ClassType),
-      MetaspaceAux::allocated_used_bytes(Metaspace::ClassType),
+      MetaspaceAux::committed_bytes(Metaspace::ClassType),
+      MetaspaceAux::used_bytes(Metaspace::ClassType),
       MetaspaceAux::reserved_bytes(Metaspace::ClassType));
 
   const MetaspaceChunkFreeListSummary& ms_chunk_free_list_summary =
--- a/src/share/vm/memory/genCollectedHeap.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/memory/genCollectedHeap.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -374,7 +374,7 @@
 
   ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy());
 
-  const size_t metadata_prev_used = MetaspaceAux::allocated_used_bytes();
+  const size_t metadata_prev_used = MetaspaceAux::used_bytes();
 
   print_heap_before_gc();
 
--- a/src/share/vm/memory/metaspace.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/memory/metaspace.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -1447,7 +1447,7 @@
   uint current_shrink_factor = _shrink_factor;
   _shrink_factor = 0;
 
-  const size_t used_after_gc = MetaspaceAux::allocated_capacity_bytes();
+  const size_t used_after_gc = MetaspaceAux::capacity_bytes();
   const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
 
   const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;
@@ -2537,8 +2537,8 @@
 // MetaspaceAux
 
 
-size_t MetaspaceAux::_allocated_capacity_words[] = {0, 0};
-size_t MetaspaceAux::_allocated_used_words[] = {0, 0};
+size_t MetaspaceAux::_capacity_words[] = {0, 0};
+size_t MetaspaceAux::_used_words[] = {0, 0};
 
 size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) {
   VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
@@ -2551,38 +2551,38 @@
 
 void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) {
   assert_lock_strong(SpaceManager::expand_lock());
-  assert(words <= allocated_capacity_words(mdtype),
+  assert(words <= capacity_words(mdtype),
     err_msg("About to decrement below 0: words " SIZE_FORMAT
-            " is greater than _allocated_capacity_words[%u] " SIZE_FORMAT,
-            words, mdtype, allocated_capacity_words(mdtype)));
-  _allocated_capacity_words[mdtype] -= words;
+            " is greater than _capacity_words[%u] " SIZE_FORMAT,
+            words, mdtype, capacity_words(mdtype)));
+  _capacity_words[mdtype] -= words;
 }
 
 void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) {
   assert_lock_strong(SpaceManager::expand_lock());
   // Needs to be atomic
-  _allocated_capacity_words[mdtype] += words;
+  _capacity_words[mdtype] += words;
 }
 
 void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) {
-  assert(words <= allocated_used_words(mdtype),
+  assert(words <= used_words(mdtype),
     err_msg("About to decrement below 0: words " SIZE_FORMAT
-            " is greater than _allocated_used_words[%u] " SIZE_FORMAT,
-            words, mdtype, allocated_used_words(mdtype)));
+            " is greater than _used_words[%u] " SIZE_FORMAT,
+            words, mdtype, used_words(mdtype)));
   // For CMS deallocation of the Metaspaces occurs during the
   // sweep which is a concurrent phase.  Protection by the expand_lock()
   // is not enough since allocation is on a per Metaspace basis
   // and protected by the Metaspace lock.
   jlong minus_words = (jlong) - (jlong) words;
-  Atomic::add_ptr(minus_words, &_allocated_used_words[mdtype]);
+  Atomic::add_ptr(minus_words, &_used_words[mdtype]);
 }
 
 void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) {
-  // _allocated_used_words tracks allocations for
+  // _used_words tracks allocations for
   // each piece of metadata.  Those allocations are
   // generally done concurrently by different application
   // threads so must be done atomically.
-  Atomic::add_ptr(words, &_allocated_used_words[mdtype]);
+  Atomic::add_ptr(words, &_used_words[mdtype]);
 }
 
 size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) {
@@ -2629,16 +2629,16 @@
 
 size_t MetaspaceAux::capacity_bytes_slow() {
 #ifdef PRODUCT
-  // Use allocated_capacity_bytes() in PRODUCT instead of this function.
+  // Use capacity_bytes() in PRODUCT instead of this function.
   guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT");
 #endif
   size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType);
   size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType);
-  assert(allocated_capacity_bytes() == class_capacity + non_class_capacity,
-      err_msg("bad accounting: allocated_capacity_bytes() " SIZE_FORMAT
+  assert(capacity_bytes() == class_capacity + non_class_capacity,
+      err_msg("bad accounting: capacity_bytes() " SIZE_FORMAT
         " class_capacity + non_class_capacity " SIZE_FORMAT
         " class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT,
-        allocated_capacity_bytes(), class_capacity + non_class_capacity,
+        capacity_bytes(), class_capacity + non_class_capacity,
         class_capacity, non_class_capacity));
 
   return class_capacity + non_class_capacity;
@@ -2698,14 +2698,14 @@
                         "->" SIZE_FORMAT
                         "("  SIZE_FORMAT ")",
                         prev_metadata_used,
-                        allocated_used_bytes(),
+                        used_bytes(),
                         reserved_bytes());
   } else {
     gclog_or_tty->print(" "  SIZE_FORMAT "K"
                         "->" SIZE_FORMAT "K"
                         "("  SIZE_FORMAT "K)",
                         prev_metadata_used/K,
-                        allocated_used_bytes()/K,
+                        used_bytes()/K,
                         reserved_bytes()/K);
   }
 
@@ -2721,8 +2721,8 @@
                 "capacity "  SIZE_FORMAT "K, "
                 "committed " SIZE_FORMAT "K, "
                 "reserved "  SIZE_FORMAT "K",
-                allocated_used_bytes()/K,
-                allocated_capacity_bytes()/K,
+                used_bytes()/K,
+                capacity_bytes()/K,
                 committed_bytes()/K,
                 reserved_bytes()/K);
 
@@ -2733,8 +2733,8 @@
                   "capacity "  SIZE_FORMAT "K, "
                   "committed " SIZE_FORMAT "K, "
                   "reserved "  SIZE_FORMAT "K",
-                  allocated_used_bytes(ct)/K,
-                  allocated_capacity_bytes(ct)/K,
+                  used_bytes(ct)/K,
+                  capacity_bytes(ct)/K,
                   committed_bytes(ct)/K,
                   reserved_bytes(ct)/K);
   }
@@ -2836,42 +2836,42 @@
 
 void MetaspaceAux::verify_capacity() {
 #ifdef ASSERT
-  size_t running_sum_capacity_bytes = allocated_capacity_bytes();
+  size_t running_sum_capacity_bytes = capacity_bytes();
   // For purposes of the running sum of capacity, verify against capacity
   size_t capacity_in_use_bytes = capacity_bytes_slow();
   assert(running_sum_capacity_bytes == capacity_in_use_bytes,
-    err_msg("allocated_capacity_words() * BytesPerWord " SIZE_FORMAT
+    err_msg("capacity_words() * BytesPerWord " SIZE_FORMAT
             " capacity_bytes_slow()" SIZE_FORMAT,
             running_sum_capacity_bytes, capacity_in_use_bytes));
   for (Metaspace::MetadataType i = Metaspace::ClassType;
        i < Metaspace:: MetadataTypeCount;
        i = (Metaspace::MetadataType)(i + 1)) {
     size_t capacity_in_use_bytes = capacity_bytes_slow(i);
-    assert(allocated_capacity_bytes(i) == capacity_in_use_bytes,
-      err_msg("allocated_capacity_bytes(%u) " SIZE_FORMAT
+    assert(capacity_bytes(i) == capacity_in_use_bytes,
+      err_msg("capacity_bytes(%u) " SIZE_FORMAT
               " capacity_bytes_slow(%u)" SIZE_FORMAT,
-              i, allocated_capacity_bytes(i), i, capacity_in_use_bytes));
+              i, capacity_bytes(i), i, capacity_in_use_bytes));
   }
 #endif
 }
 
 void MetaspaceAux::verify_used() {
 #ifdef ASSERT
-  size_t running_sum_used_bytes = allocated_used_bytes();
+  size_t running_sum_used_bytes = used_bytes();
   // For purposes of the running sum of used, verify against used
   size_t used_in_use_bytes = used_bytes_slow();
-  assert(allocated_used_bytes() == used_in_use_bytes,
-    err_msg("allocated_used_bytes() " SIZE_FORMAT
+  assert(used_bytes() == used_in_use_bytes,
+    err_msg("used_bytes() " SIZE_FORMAT
             " used_bytes_slow()" SIZE_FORMAT,
-            allocated_used_bytes(), used_in_use_bytes));
+            used_bytes(), used_in_use_bytes));
   for (Metaspace::MetadataType i = Metaspace::ClassType;
        i < Metaspace:: MetadataTypeCount;
        i = (Metaspace::MetadataType)(i + 1)) {
     size_t used_in_use_bytes = used_bytes_slow(i);
-    assert(allocated_used_bytes(i) == used_in_use_bytes,
-      err_msg("allocated_used_bytes(%u) " SIZE_FORMAT
+    assert(used_bytes(i) == used_in_use_bytes,
+      err_msg("used_bytes(%u) " SIZE_FORMAT
               " used_bytes_slow(%u)" SIZE_FORMAT,
-              i, allocated_used_bytes(i), i, used_in_use_bytes));
+              i, used_bytes(i), i, used_in_use_bytes));
   }
 #endif
 }
--- a/src/share/vm/memory/metaspace.hpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/memory/metaspace.hpp	Mon Apr 14 22:53:29 2014 +0400
@@ -280,11 +280,11 @@
   // allocated to a Metaspace.  This is used instead of
   // iterating over all the classloaders. One for each
   // type of Metadata
-  static size_t _allocated_capacity_words[Metaspace:: MetadataTypeCount];
-  // Running sum of space in all Metachunks that have
+  static size_t _capacity_words[Metaspace:: MetadataTypeCount];
+  // Running sum of space in all Metachunks that
   // are being used for metadata. One for each
   // type of Metadata.
-  static size_t _allocated_used_words[Metaspace:: MetadataTypeCount];
+  static size_t _used_words[Metaspace:: MetadataTypeCount];
 
  public:
   // Decrement and increment _allocated_capacity_words
@@ -308,32 +308,32 @@
   static size_t free_chunks_total_bytes();
   static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype);
 
-  static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) {
-    return _allocated_capacity_words[mdtype];
+  static size_t capacity_words(Metaspace::MetadataType mdtype) {
+    return _capacity_words[mdtype];
   }
-  static size_t allocated_capacity_words() {
-    return allocated_capacity_words(Metaspace::NonClassType) +
-           allocated_capacity_words(Metaspace::ClassType);
+  static size_t capacity_words() {
+    return capacity_words(Metaspace::NonClassType) +
+           capacity_words(Metaspace::ClassType);
   }
-  static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) {
-    return allocated_capacity_words(mdtype) * BytesPerWord;
+  static size_t capacity_bytes(Metaspace::MetadataType mdtype) {
+    return capacity_words(mdtype) * BytesPerWord;
   }
-  static size_t allocated_capacity_bytes() {
-    return allocated_capacity_words() * BytesPerWord;
+  static size_t capacity_bytes() {
+    return capacity_words() * BytesPerWord;
   }
 
-  static size_t allocated_used_words(Metaspace::MetadataType mdtype) {
-    return _allocated_used_words[mdtype];
+  static size_t used_words(Metaspace::MetadataType mdtype) {
+    return _used_words[mdtype];
   }
-  static size_t allocated_used_words() {
-    return allocated_used_words(Metaspace::NonClassType) +
-           allocated_used_words(Metaspace::ClassType);
+  static size_t used_words() {
+    return used_words(Metaspace::NonClassType) +
+           used_words(Metaspace::ClassType);
   }
-  static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) {
-    return allocated_used_words(mdtype) * BytesPerWord;
+  static size_t used_bytes(Metaspace::MetadataType mdtype) {
+    return used_words(mdtype) * BytesPerWord;
   }
-  static size_t allocated_used_bytes() {
-    return allocated_used_words() * BytesPerWord;
+  static size_t used_bytes() {
+    return used_words() * BytesPerWord;
   }
 
   static size_t free_bytes();
--- a/src/share/vm/memory/metaspaceCounters.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/memory/metaspaceCounters.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -66,7 +66,7 @@
 MetaspacePerfCounters* MetaspaceCounters::_perf_counters = NULL;
 
 size_t MetaspaceCounters::used() {
-  return MetaspaceAux::allocated_used_bytes();
+  return MetaspaceAux::used_bytes();
 }
 
 size_t MetaspaceCounters::capacity() {
@@ -98,7 +98,7 @@
 MetaspacePerfCounters* CompressedClassSpaceCounters::_perf_counters = NULL;
 
 size_t CompressedClassSpaceCounters::used() {
-  return MetaspaceAux::allocated_used_bytes(Metaspace::ClassType);
+  return MetaspaceAux::used_bytes(Metaspace::ClassType);
 }
 
 size_t CompressedClassSpaceCounters::capacity() {
--- a/src/share/vm/runtime/biasedLocking.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/runtime/biasedLocking.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -128,7 +128,7 @@
         // Walk monitors youngest to oldest
         for (int i = len - 1; i >= 0; i--) {
           MonitorInfo* mon_info = monitors->at(i);
-          if (mon_info->owner_is_scalar_replaced()) continue;
+          if (mon_info->eliminated()) continue;
           oop owner = mon_info->owner();
           if (owner != NULL) {
             info->append(mon_info);
--- a/src/share/vm/services/memoryPool.cpp	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/services/memoryPool.cpp	Mon Apr 14 22:53:29 2014 +0400
@@ -268,7 +268,7 @@
 }
 
 size_t MetaspacePool::used_in_bytes() {
-  return MetaspaceAux::allocated_used_bytes();
+  return MetaspaceAux::used_bytes();
 }
 
 size_t MetaspacePool::calculate_max_size() const {
@@ -280,7 +280,7 @@
   MemoryPool("Compressed Class Space", NonHeap, 0, CompressedClassSpaceSize, true, false) { }
 
 size_t CompressedKlassSpacePool::used_in_bytes() {
-  return MetaspaceAux::allocated_used_bytes(Metaspace::ClassType);
+  return MetaspaceAux::used_bytes(Metaspace::ClassType);
 }
 
 MemoryUsage CompressedKlassSpacePool::get_memory_usage() {
--- a/src/share/vm/trace/trace.xml	Fri Apr 11 00:35:23 2014 +0400
+++ b/src/share/vm/trace/trace.xml	Mon Apr 14 22:53:29 2014 +0400
@@ -185,7 +185,7 @@
     </event>
 
     <struct id="MetaspaceSizes">
-      <value type="BYTES64" field="capacity" label="Capacity" description="Total available memory to allocate in" />
+      <value type="BYTES64" field="committed" label="Committed" description="Committed memory for this space" />
       <value type="BYTES64" field="used" label="Used" description="Bytes allocated by objects in the space" />
       <value type="BYTES64" field="reserved" label="Reserved" description="Reserved memory for this space" />
     </struct>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/uncommontrap/TestLockEliminatedAtDeopt.java	Mon Apr 14 22:53:29 2014 +0400
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8032011
+ * @summary biased locking's revoke_bias locks monitor in compiled frame with eliminated lock
+ * @run main/othervm -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestLockEliminatedAtDeopt$A.m2 -XX:-BackgroundCompilation -XX:BiasedLockingStartupDelay=0 TestLockEliminatedAtDeopt
+ *
+ */
+
+public class TestLockEliminatedAtDeopt {
+
+    static class A {
+        void m() {
+        }
+
+        // This lock is not eliminated but biased to main thread on
+        // first call
+        synchronized void m2(boolean trap) {
+            if (trap) {
+                new B();
+            }
+        }
+    }
+
+    static class B extends A {
+        void m() {
+        }
+    }
+
+    static void m1(boolean trap) {
+        A a = new A();
+        // This lock is eliminated by c2
+        synchronized(a) {
+            a.m2(trap);
+            a.m();
+        }
+    }
+
+     public static void main(String[] args) {
+        for (int i = 0; i < 20000; i++) {
+            m1(false);
+        }
+        // Trigger uncommon trap in A.m2() (class unloaded) and
+        // deoptimization of m1() (CHA invalidated). Uncommon trap
+        // code locks monitor in m1's frame where's it's eliminated.
+        m1(true);
+    }
+}