changeset 12462:88d451c7c484

factored out retrieving the host architecture name to handle variations in value of os.arch system property
author Doug Simon <doug.simon@oracle.com>
date Thu, 17 Oct 2013 09:25:58 +0200
parents 3e559d1db048
children 3661954321aa
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java
diffstat 1 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Wed Oct 16 22:06:58 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Thu Oct 17 09:25:58 2013 +0200
@@ -213,7 +213,7 @@
             printConfig(config);
         }
 
-        String hostArchitecture = System.getProperty("os.arch");
+        String hostArchitecture = getHostArchitecture();
         hostBackend = findFactory(hostArchitecture).createBackend(this, null);
         hostProviders = hostBackend.getProviders();
         backends.put(hostArchitecture, hostBackend);
@@ -237,12 +237,30 @@
     }
 
     /**
-     * Gets the supported GPUs. This method first looks for a comma separated list of names in the
-     * "graal.gpu.isalist" system property. If this property is not set, then the GPU native support
-     * code is queried.
+     * Gets the host architecture name for the purpose of finding the corresponding
+     * {@linkplain HotSpotBackendFactory backend}.
+     */
+    private static String getHostArchitecture() {
+        String arch = System.getProperty("os.arch");
+        switch (arch) {
+            case "x86_64":
+                // This is what Mac OS X reports;
+                arch = "amd64";
+                break;
+        }
+        return arch;
+    }
+
+    public static final String GRAAL_GPU_ISALIST_PROPERTY_NAME = "graal.gpu.isalist";
+
+    /**
+     * Gets the names of the supported GPU architectures for the purpose of finding the
+     * corresponding {@linkplain HotSpotBackendFactory backend} objects. This method first looks for
+     * a comma separated list of names in the {@value #GRAAL_GPU_ISALIST_PROPERTY_NAME} system
+     * property. If this property is not set, then the GPU native support code is queried.
      */
     private String[] getGPUArchitectures() {
-        String gpuList = System.getProperty("graal.gpu.isalist");
+        String gpuList = System.getProperty(GRAAL_GPU_ISALIST_PROPERTY_NAME);
         if (gpuList != null) {
             String[] gpus = gpuList.split(",");
             return gpus;