changeset 22485:77f91e4981dd

Merged
author Christian Wirth <christian.wirth@oracle.com>
date Wed, 19 Aug 2015 15:30:42 +0200
parents 9836ba56a6d0 (current diff) aacbf2e9aa42 (diff)
children af21ee97d1db
files mx.graal/suite.py
diffstat 10 files changed, 73 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java	Wed Aug 19 15:29:06 2015 +0200
+++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java	Wed Aug 19 15:30:42 2015 +0200
@@ -25,7 +25,6 @@
 import java.util.*;
 
 import jdk.internal.jvmci.service.*;
-import sun.reflect.*;
 
 /**
  * Access point for {@linkplain #getRuntime() retrieving} the single {@link GraalRuntime} instance.
@@ -56,7 +55,6 @@
      *
      * @throws UnsupportedOperationException if the capability is not available
      */
-    @CallerSensitive
     public static <T> T getRequiredCapability(Class<T> clazz) {
         T t = getRuntime().getCapability(clazz);
         if (t == null) {
--- a/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64MacroAssembler.java	Wed Aug 19 15:29:06 2015 +0200
+++ b/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64MacroAssembler.java	Wed Aug 19 15:30:42 2015 +0200
@@ -318,25 +318,4 @@
         movdbl(dest, tmp);
         addq(AMD64.rsp, target.getSizeInBytes(Kind.Double));
     }
-
-    /**
-     * Emit code to save a given set of callee save registers in the {@linkplain CalleeSaveLayout
-     * CSA} within the frame.
-     *
-     * @param csl the description of the CSA
-     * @param frameToCSA offset from the frame pointer to the CSA
-     */
-    public final void save(CalleeSaveLayout csl, int frameToCSA) {
-        for (Register r : csl.registers) {
-            int offset = csl.offsetOf(r);
-            movq(new AMD64Address(frameRegister, frameToCSA + offset), r);
-        }
-    }
-
-    public final void restore(CalleeSaveLayout csl, int frameToCSA) {
-        for (Register r : csl.registers) {
-            int offset = csl.offsetOf(r);
-            movq(r, new AMD64Address(frameRegister, frameToCSA + offset));
-        }
-    }
 }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java	Wed Aug 19 15:29:06 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java	Wed Aug 19 15:30:42 2015 +0200
@@ -225,6 +225,7 @@
             new VerifyUsageWithEquals(ArithmeticOpTable.Op.class).apply(graph, context);
         }
         new VerifyDebugUsage().apply(graph, context);
+        new VerifyCallerSensitiveMethods().apply(graph, context);
     }
 
     private static boolean matches(String[] filters, String s) {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Wed Aug 19 15:29:06 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Wed Aug 19 15:30:42 2015 +0200
@@ -175,12 +175,7 @@
                         asm.movl(new AMD64Address(rsp, i * intSize), 0xC1C1C1C1);
                     }
                 }
-                CalleeSaveLayout csl = frameMap.getRegisterConfig().getCalleeSaveLayout();
-                if (csl != null && csl.size != 0) {
-                    int frameToCSA = frameMap.offsetToCalleeSaveArea();
-                    assert frameToCSA >= 0;
-                    asm.save(csl, frameToCSA);
-                }
+                assert frameMap.getRegisterConfig().getCalleeSaveRegisters() == null;
             }
         }
 
@@ -188,13 +183,7 @@
         public void leave(CompilationResultBuilder crb) {
             if (!omitFrame) {
                 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm;
-                CalleeSaveLayout csl = crb.frameMap.getRegisterConfig().getCalleeSaveLayout();
-
-                if (csl != null && csl.size != 0) {
-                    // saved all registers, restore all registers
-                    int frameToCSA = crb.frameMap.offsetToCalleeSaveArea();
-                    asm.restore(csl, frameToCSA);
-                }
+                assert crb.frameMap.getRegisterConfig().getCalleeSaveRegisters() == null;
 
                 int frameSize = crb.frameMap.frameSize();
                 asm.incrementq(rsp, frameSize);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Wed Aug 19 15:29:06 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Wed Aug 19 15:30:42 2015 +0200
@@ -104,7 +104,7 @@
     @SuppressWarnings("unused")
     private static Value[] createNativeABICallerSaveRegisters(HotSpotVMConfig config, RegisterConfig regConfig) {
         Set<Register> callerSavedRegisters = new HashSet<>();
-        Collections.addAll(callerSavedRegisters, regConfig.getCalleeSaveLayout().registers);
+        Collections.addAll(callerSavedRegisters, regConfig.getCalleeSaveRegisters());
         Collections.addAll(callerSavedRegisters, SPARC.fpuRegisters);
         callerSavedRegisters.add(SPARC.g1);
         callerSavedRegisters.add(SPARC.g4);
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Wed Aug 19 15:29:06 2015 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Wed Aug 19 15:30:42 2015 +0200
@@ -77,7 +77,7 @@
     public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig, ReferenceMapBuilderFactory referenceMapFactory) {
         super(codeCache, registerConfig, referenceMapFactory);
         // (negative) offset relative to sp + total frame size
-        initialSpillSize = returnAddressSize() + calleeSaveAreaSize();
+        initialSpillSize = returnAddressSize();
         spillSize = initialSpillSize;
     }
 
@@ -97,11 +97,6 @@
     }
 
     @Override
-    public int offsetToCalleeSaveArea() {
-        return frameSize() - calleeSaveAreaSize();
-    }
-
-    @Override
     protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) {
         return StackSlot.get(kind, -spillSize + additionalOffset, true);
     }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java	Wed Aug 19 15:29:06 2015 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java	Wed Aug 19 15:30:42 2015 +0200
@@ -89,12 +89,7 @@
 
     @Override
     public int currentFrameSize() {
-        return alignFrameSize(calleeSaveAreaSize() + outgoingSize + spillSize);
-    }
-
-    @Override
-    protected int calleeSaveAreaSize() {
-        return SPARC.REGISTER_SAFE_AREA_SIZE;
+        return alignFrameSize(SPARC.REGISTER_SAFE_AREA_SIZE + outgoingSize + spillSize);
     }
 
     @Override
@@ -103,11 +98,6 @@
     }
 
     @Override
-    public int offsetToCalleeSaveArea() {
-        return 0;
-    }
-
-    @Override
     protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) {
         return StackSlot.get(kind, -spillSize + additionalOffset, true);
     }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMap.java	Wed Aug 19 15:29:06 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/FrameMap.java	Wed Aug 19 15:30:42 2015 +0200
@@ -120,11 +120,6 @@
         return getTarget().arch.getReturnAddressSize();
     }
 
-    protected int calleeSaveAreaSize() {
-        CalleeSaveLayout csl = getRegisterConfig().getCalleeSaveLayout();
-        return csl != null ? csl.size : 0;
-    }
-
     /**
      * Determines if an offset to an incoming stack argument was ever returned by
      * {@link #offsetForStackSlot(StackSlot)}.
@@ -205,14 +200,6 @@
     }
 
     /**
-     * Gets the offset from the stack pointer to the stack area where callee-saved registers are
-     * stored.
-     *
-     * @return The offset to the callee save area (in bytes).
-     */
-    public abstract int offsetToCalleeSaveArea();
-
-    /**
      * Informs the frame map that the compiled code calls a particular method, which may need stack
      * space for outgoing arguments.
      *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyCallerSensitiveMethods.java	Wed Aug 19 15:30:42 2015 +0200
@@ -0,0 +1,66 @@
+/*
+ * 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.phases.verify;
+
+import jdk.internal.jvmci.meta.*;
+import sun.reflect.*;
+
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.tiers.*;
+
+/**
+ * Verifies a method is annotated with {@link CallerSensitive} iff it calls
+ * {@link Reflection#getCallerClass()}.
+ */
+public class VerifyCallerSensitiveMethods extends VerifyPhase<PhaseContext> {
+
+    @Override
+    protected boolean verify(StructuredGraph graph, PhaseContext context) {
+        Invoke invoke = callsReflectionGetCallerClass(graph, context);
+        if (invoke != null) {
+            if (graph.method().getAnnotation(CallerSensitive.class) == null) {
+                StackTraceElement e = graph.method().asStackTraceElement(invoke.bci());
+                throw new VerificationError(String.format("%s: method that calls Reflection.getCallerClass() must be annotated with @CallerSensitive", e));
+            }
+
+        } else if (graph.method().getAnnotation(CallerSensitive.class) != null) {
+            throw new VerificationError(String.format("%s: method annotated with @CallerSensitive does not call Reflection.getCallerClass()", graph.method().format("%H.%n(%p)")));
+        }
+        return true;
+    }
+
+    private static Invoke callsReflectionGetCallerClass(StructuredGraph graph, PhaseContext context) {
+        for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
+            ResolvedJavaMethod callee = t.targetMethod();
+            ResolvedJavaType reflectionType = context.getMetaAccess().lookupJavaType(Reflection.class);
+            if (callee.getDeclaringClass().equals(reflectionType)) {
+                if (callee.getName().equals("getCallerClass")) {
+                    return t.invoke();
+                }
+            }
+        }
+        return null;
+    }
+}
--- a/mx.graal/suite.py	Wed Aug 19 15:29:06 2015 +0200
+++ b/mx.graal/suite.py	Wed Aug 19 15:30:42 2015 +0200
@@ -6,7 +6,7 @@
     "suites": [
             {
                "name" : "jvmci",
-               "version" : "a1b0a76567c79145782f810db06e53b0eb60fec8",
+               "version" : "0a0c0111ecda34c4d8ac6b74745c201613ae6519",
                "urls" : [
                     {"url" : "http://lafo.ssw.uni-linz.ac.at/hg/graal-jvmci-8", "kind" : "hg"},
                     {"url" : "http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots", "kind" : "binary"},