changeset 21414:b04f579c803f

removed unnecessary CompilerToVM.CodeInstallResult enum (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Mon, 18 May 2015 23:00:45 +0200
parents 15a46a918fc1
children c435184ca071
files graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java src/share/vm/graal/graalCompilerToVM.cpp
diffstat 7 files changed, 48 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Mon May 18 22:27:24 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Mon May 18 23:00:45 2015 +0200
@@ -37,7 +37,6 @@
 import com.oracle.graal.graphbuilderconf.*;
 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
@@ -54,8 +53,9 @@
         HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method;
         HotSpotNmethod installedCode = new HotSpotNmethod(hsMethod, compResult.getName(), true);
         HotSpotCompiledNmethod compiledNmethod = new HotSpotCompiledNmethod(hsMethod, compResult);
-        CodeInstallResult result = runtime().getCompilerToVM().installCode(compiledNmethod, installedCode, null);
-        Assert.assertEquals("Error installing method " + method + ": " + result, result, CodeInstallResult.OK);
+        int result = runtime().getCompilerToVM().installCode(compiledNmethod, installedCode, null);
+        HotSpotVMConfig config = runtime().getConfig();
+        Assert.assertEquals("Error installing method " + method + ": " + config.getCodeInstallResultDescription(result), result, config.codeInstallResultOk);
 
         // HotSpotRuntime hsRuntime = (HotSpotRuntime) getCodeCache();
         // TTY.println(hsMethod.toString());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon May 18 22:27:24 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon May 18 23:00:45 2015 +0200
@@ -1509,6 +1509,26 @@
     @HotSpotVMConstant(name = "GraalEnv::cache_full") @Stable public int codeInstallResultCacheFull;
     @HotSpotVMConstant(name = "GraalEnv::code_too_large") @Stable public int codeInstallResultCodeTooLarge;
 
+    public String getCodeInstallResultDescription(int codeInstallResult) {
+        if (codeInstallResult == codeInstallResultOk) {
+            return "ok";
+        }
+        if (codeInstallResult == codeInstallResultDependenciesFailed) {
+            return "dependencies failed";
+        }
+        if (codeInstallResult == codeInstallResultDependenciesInvalid) {
+            return "dependencies invalid";
+        }
+        if (codeInstallResult == codeInstallResultCacheFull) {
+            return "code cache is full";
+        }
+        if (codeInstallResult == codeInstallResultCodeTooLarge) {
+            return "code is too large";
+        }
+        assert false : codeInstallResult;
+        return "unknown";
+    }
+
     @HotSpotVMConstant(name = "CompilerToVM::KLASS_TAG") @Stable public int compilerToVMKlassTag;
     @HotSpotVMConstant(name = "CompilerToVM::SYMBOL_TAG") @Stable public int compilerToVMSymbolTag;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Mon May 18 22:27:24 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Mon May 18 23:00:45 2015 +0200
@@ -176,66 +176,19 @@
 
     Object lookupAppendixInPool(long metaspaceConstantPool, int cpi);
 
-    public enum CodeInstallResult {
-        OK("ok"),
-        DEPENDENCIES_FAILED("dependencies failed"),
-        DEPENDENCIES_INVALID("dependencies invalid"),
-        CACHE_FULL("code cache is full"),
-        CODE_TOO_LARGE("code is too large");
-
-        private int value;
-        private String message;
-
-        private CodeInstallResult(String name) {
-            HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig();
-            switch (name) {
-                case "ok":
-                    this.value = config.codeInstallResultOk;
-                    break;
-                case "dependencies failed":
-                    this.value = config.codeInstallResultDependenciesFailed;
-                    break;
-                case "dependencies invalid":
-                    this.value = config.codeInstallResultDependenciesInvalid;
-                    break;
-                case "code cache is full":
-                    this.value = config.codeInstallResultCacheFull;
-                    break;
-                case "code is too large":
-                    this.value = config.codeInstallResultCodeTooLarge;
-                    break;
-                default:
-                    throw new IllegalArgumentException(name);
-            }
-            this.message = name;
-        }
-
-        /**
-         * Returns the enum object for the given value.
-         */
-        public static CodeInstallResult getEnum(int value) {
-            for (CodeInstallResult e : values()) {
-                if (e.value == value) {
-                    return e;
-                }
-            }
-            throw new IllegalArgumentException(String.valueOf(value));
-        }
-
-        @Override
-        public String toString() {
-            return message;
-        }
-    }
-
     /**
      * Installs the result of a compilation into the code cache.
      *
      * @param compiledCode the result of a compilation
      * @param code the details of the installed CodeBlob are written to this object
-     * @return the outcome of the installation as a {@link CodeInstallResult}.
+     * @return the outcome of the installation which will be one of
+     *         {@link HotSpotVMConfig#codeInstallResultOk},
+     *         {@link HotSpotVMConfig#codeInstallResultCacheFull},
+     *         {@link HotSpotVMConfig#codeInstallResultCodeTooLarge},
+     *         {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or
+     *         {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}.
      */
-    CodeInstallResult installCode(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog);
+    int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog);
 
     /**
      * Notifies the VM of statistics for a completed compilation.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Mon May 18 22:27:24 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Mon May 18 23:00:45 2015 +0200
@@ -45,12 +45,8 @@
         }
     }
 
-    private native int installCode0(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog);
-
     @Override
-    public CodeInstallResult installCode(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog) {
-        return CodeInstallResult.getEnum(installCode0(compiledCode, code, speculationLog));
-    }
+    public native int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog);
 
     @Override
     public native long getMetaspaceMethod(Class<?> holder, int slot);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Mon May 18 22:27:24 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Mon May 18 23:00:45 2015 +0200
@@ -42,7 +42,6 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.bridge.*;
-import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult;
 import com.oracle.graal.printer.*;
 
 /**
@@ -226,18 +225,19 @@
             installedCode = code;
         }
         HotSpotCompiledNmethod compiledCode = new HotSpotCompiledNmethod(hotspotMethod, compResult);
-        CodeInstallResult result = runtime.getCompilerToVM().installCode(compiledCode, installedCode, log);
-        if (result != CodeInstallResult.OK) {
+        int result = runtime.getCompilerToVM().installCode(compiledCode, installedCode, log);
+        if (result != config.codeInstallResultOk) {
             String msg = compiledCode.getInstallationFailureMessage();
+            String resultDesc = config.getCodeInstallResultDescription(result);
             if (msg != null) {
-                msg = String.format("Code installation failed: %s%n%s", result, msg);
+                msg = String.format("Code installation failed: %s%n%s", resultDesc, msg);
             } else {
-                msg = String.format("Code installation failed: %s", result);
+                msg = String.format("Code installation failed: %s", resultDesc);
             }
-            if (result == CodeInstallResult.DEPENDENCIES_INVALID) {
-                throw new AssertionError(result + " " + msg);
+            if (result == config.codeInstallResultDependenciesInvalid) {
+                throw new AssertionError(resultDesc + " " + msg);
             }
-            throw new BailoutException(result != CodeInstallResult.DEPENDENCIES_FAILED, msg);
+            throw new BailoutException(result != config.codeInstallResultDependenciesFailed, msg);
         }
         return logOrDump(installedCode, compResult);
     }
@@ -256,8 +256,8 @@
         HotSpotNmethod code = new HotSpotNmethod(javaMethod, compResult.getName(), false, true);
         HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, compResult);
         CompilerToVM vm = runtime.getCompilerToVM();
-        CodeInstallResult result = vm.installCode(compiled, code, null);
-        if (result != CodeInstallResult.OK) {
+        int result = vm.installCode(compiled, code, null);
+        if (result != runtime.getConfig().codeInstallResultOk) {
             return null;
         }
         return code;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon May 18 22:27:24 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon May 18 23:00:45 2015 +0200
@@ -35,7 +35,6 @@
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.lir.asm.*;
@@ -194,9 +193,11 @@
                     HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub);
                     HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(stub, compResult);
 
-                    CodeInstallResult result = runtime().getCompilerToVM().installCode(hsCompResult, installedCode, null);
-                    if (result != CodeInstallResult.OK) {
-                        throw new GraalInternalError("Error installing stub %s: %s", Stub.this, result);
+                    HotSpotGraalRuntime runtime = runtime();
+                    int result = runtime.getCompilerToVM().installCode(hsCompResult, installedCode, null);
+                    HotSpotVMConfig config = runtime.getConfig();
+                    if (result != config.codeInstallResultOk) {
+                        throw new GraalInternalError("Error installing stub %s: %s", Stub.this, config.getCodeInstallResultDescription(result));
                     }
                     ((HotSpotCodeCacheProvider) codeCache).logOrDump(installedCode, compResult);
                     code = installedCode;
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon May 18 22:27:24 2015 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Mon May 18 23:00:45 2015 +0200
@@ -472,7 +472,7 @@
   method->set_dont_inline(true);
 C2V_END
 
-C2V_VMENTRY(jint, installCode0, (JNIEnv *jniEnv, jobject, jobject compiled_code, jobject installed_code, jobject speculation_log))
+C2V_VMENTRY(jint, installCode, (JNIEnv *jniEnv, jobject, jobject compiled_code, jobject installed_code, jobject speculation_log))
   ResourceMark rm;
   HandleMark hm;
   Handle compiled_code_handle = JNIHandles::resolve(compiled_code);
@@ -1084,7 +1084,7 @@
   {CC"getMaxCallTargetOffset",                       CC"(J)J",                                                                 FN_PTR(getMaxCallTargetOffset)},
   {CC"getMetaspaceMethod",                           CC"("CLASS"I)"METASPACE_METHOD,                                           FN_PTR(getMetaspaceMethod)},
   {CC"initializeConfiguration",                      CC"("HS_CONFIG")V",                                                       FN_PTR(initializeConfiguration)},
-  {CC"installCode0",                                 CC"("HS_COMPILED_CODE INSTALLED_CODE SPECULATION_LOG")I",                 FN_PTR(installCode0)},
+  {CC"installCode",                                  CC"("HS_COMPILED_CODE INSTALLED_CODE SPECULATION_LOG")I",                 FN_PTR(installCode)},
   {CC"notifyCompilationStatistics",                  CC"(I"HS_RESOLVED_METHOD"ZIJJ"INSTALLED_CODE")V",                         FN_PTR(notifyCompilationStatistics)},
   {CC"resetCompilationStatistics",                   CC"()V",                                                                  FN_PTR(resetCompilationStatistics)},
   {CC"disassembleCodeBlob",                          CC"(J)"STRING,                                                            FN_PTR(disassembleCodeBlob)},