changeset 7375:deac35fb97a2

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 15 Jan 2013 00:51:29 +0100
parents 44012c5c6783 (current diff) 6b2c55fc9ba8 (diff)
children 27ee289ec5a7
files
diffstat 6 files changed, 83 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotSnippetInstaller.java	Tue Jan 15 00:51:29 2013 +0100
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import java.lang.reflect.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.snippets.*;
+import com.oracle.graal.snippets.*;
+
+/**
+ * Filters certain intrinsifications based on whether there is underlying hardware support for them.
+ */
+public class HotSpotSnippetInstaller extends SnippetInstaller {
+
+    private final HotSpotVMConfig config;
+
+    public HotSpotSnippetInstaller(HotSpotRuntime runtime, Assumptions assumptions, TargetDescription target) {
+        super(runtime, assumptions, target);
+        this.config = runtime.config;
+    }
+
+    @Override
+    protected void installSubstitution(Method originalMethod, Method substituteMethod) {
+        if (substituteMethod.getDeclaringClass() == IntegerSubstitutions.class) {
+            if (substituteMethod.getName().equals("bitCount")) {
+                if (!config.usePopCountInstruction) {
+                    return;
+                }
+            }
+        } else if (substituteMethod.getDeclaringClass() == AESCryptSubstitutions.class) {
+            if (!config.useAESIntrinsics) {
+                return;
+            }
+            assert config.aescryptEncryptBlockStub != 0L;
+            assert config.aescryptDecryptBlockStub != 0L;
+        }
+        super.installSubstitution(originalMethod, substituteMethod);
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Jan 15 00:51:12 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Jan 15 00:51:29 2013 +0100
@@ -40,6 +40,8 @@
     public boolean useFastLocking;
     public boolean useTLAB;
     public boolean useBiasedLocking;
+    public boolean usePopCountInstruction;
+    public boolean useAESIntrinsics;
 
     // offsets, ...
     public int vmPageSize;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Jan 15 00:51:12 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Jan 15 00:51:29 2013 +0100
@@ -142,7 +142,7 @@
                     // Snippets cannot have speculative optimizations since they have to be valid for the entire run of the VM.
                     Assumptions assumptions = new Assumptions(false);
                     VMToCompilerImpl.this.intrinsifyArrayCopy = new IntrinsifyArrayCopyPhase(runtime, assumptions);
-                    SnippetInstaller installer = new SnippetInstaller(runtime, assumptions, runtime.getGraalRuntime().getTarget());
+                    SnippetInstaller installer = new HotSpotSnippetInstaller(runtime, assumptions, runtime.getGraalRuntime().getTarget());
                     GraalIntrinsics.installIntrinsics(installer);
                     runtime.installSnippets(installer, assumptions);
                 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Tue Jan 15 00:51:12 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Tue Jan 15 00:51:29 2013 +0100
@@ -323,12 +323,7 @@
             installer.installSubstitutions(ClassSubstitutions.class);
         }
         if (GraalOptions.IntrinsifyAESCryptMethods) {
-            if (graalRuntime.getConfig().aescryptEncryptBlockStub != 0L) {
-                installer.installSubstitutions(AESCryptSubstitutions.class);
-            } else {
-                // AES not supported on this CPU
-                assert graalRuntime.getConfig().aescryptDecryptBlockStub == 0L;
-            }
+            installer.installSubstitutions(AESCryptSubstitutions.class);
         }
         if (GraalOptions.IntrinsifyArrayCopy) {
             installer.installSnippets(ArrayCopySnippets.class);
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetInstaller.java	Tue Jan 15 00:51:12 2013 +0100
+++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetInstaller.java	Tue Jan 15 00:51:29 2013 +0100
@@ -117,16 +117,26 @@
 
             String originalName = originalName(substituteMethod, methodSubstitution);
             Class[] originalParameters = originalParameters(substituteMethod, methodSubstitution);
-            ResolvedJavaMethod substitute = runtime.lookupJavaMethod(substituteMethod);
             Method originalMethod = originalMethod(classSubstitution, originalName, originalParameters);
-            ResolvedJavaMethod substituted = runtime.lookupJavaMethod(originalMethod);
-            //System.out.println("substitution: " + MetaUtil.format("%H.%n(%p)", substituted) + " --> " + MetaUtil.format("%H.%n(%p)", substitute));
-            StructuredGraph graph = makeGraph(substitute, inliningPolicy(substitute), true);
-            Object oldValue = substituted.getCompilerStorage().put(Graph.class, graph);
-            assert oldValue == null;
+            installSubstitution(originalMethod, substituteMethod);
         }
     }
 
+    /**
+     * Installs a method substitution.
+     *
+     * @param originalMethod a method being substituted
+     * @param substituteMethod the substitute method
+     */
+    protected void installSubstitution(Method originalMethod, Method substituteMethod) {
+        ResolvedJavaMethod substitute = runtime.lookupJavaMethod(substituteMethod);
+        ResolvedJavaMethod original = runtime.lookupJavaMethod(originalMethod);
+        //System.out.println("substitution: " + MetaUtil.format("%H.%n(%p)", original) + " --> " + MetaUtil.format("%H.%n(%p)", substitute));
+        StructuredGraph graph = makeGraph(substitute, inliningPolicy(substitute), true);
+        Object oldValue = original.getCompilerStorage().put(Graph.class, graph);
+        assert oldValue == null;
+    }
+
     private SnippetInliningPolicy inliningPolicy(ResolvedJavaMethod method) {
         Class<? extends SnippetInliningPolicy> policyClass = SnippetInliningPolicy.class;
         Snippet snippet = method.getAnnotation(Snippet.class);
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Tue Jan 15 00:51:12 2013 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Tue Jan 15 00:51:29 2013 +0100
@@ -609,6 +609,8 @@
   set_boolean("verifyOops", VerifyOops);
   set_boolean("useFastLocking", GraalUseFastLocking);
   set_boolean("useBiasedLocking", UseBiasedLocking);
+  set_boolean("usePopCountInstruction", UsePopCountInstruction);
+  set_boolean("useAESIntrinsics", UseAESIntrinsics);
   set_boolean("useTLAB", UseTLAB);
   set_int("codeEntryAlignment", CodeEntryAlignment);
   set_int("vmPageSize", os::vm_page_size());