diff jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java @ 23393:1d4ce2d19e52

clean up and minimize JVMCI (JDK-8156835)
author Doug Simon <doug.simon@oracle.com>
date Thu, 12 May 2016 20:57:31 +0200
parents b3a816d3b844
children c4e6710aa7e0 09a536b9233c
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java	Thu May 12 11:06:49 2016 +0200
+++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java	Thu May 12 20:57:31 2016 +0200
@@ -22,7 +22,6 @@
  */
 package jdk.vm.ci.hotspot;
 
-import static jdk.vm.ci.common.UnsafeUtil.readCString;
 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
 
@@ -37,8 +36,7 @@
 import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag;
 import jdk.vm.ci.hotspotvmconfig.HotSpotVMType;
 import jdk.vm.ci.hotspotvmconfig.HotSpotVMValue;
-
-//JaCoCo Exclude
+import sun.misc.Unsafe;
 
 /**
  * Used to access native configuration details.
@@ -116,6 +114,27 @@
     }
 
     /**
+     * Reads a {@code '\0'} terminated C string from native memory and converts it to a
+     * {@link String}.
+     *
+     * @return a Java string
+     */
+    static String readCString(Unsafe unsafe, long address) {
+        if (address == 0) {
+            return null;
+        }
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0;; i++) {
+            char c = (char) unsafe.getByte(address + i);
+            if (c == 0) {
+                break;
+            }
+            sb.append(c);
+        }
+        return sb.toString();
+    }
+
+    /**
      * Check that the initialization produces the same result as the values captured through
      * vmStructs.
      */