changeset 13238:b429ec5c46d6

Merge.
author Doug Simon <doug.simon@oracle.com>
date Tue, 03 Dec 2013 18:19:56 +0100
parents bc1b0ff498f4 (current diff) 3f34b8f91cc5 (diff)
children bb35fc7e0d68
files graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java src/share/vm/graal/graalCompilerToVM.cpp
diffstat 11 files changed, 57 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ValueUtil.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ValueUtil.java	Tue Dec 03 18:19:56 2013 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.api.code;
 
+import java.util.*;
+
 import com.oracle.graal.api.meta.*;
 
 /**
@@ -127,11 +129,39 @@
         return sameRegister(v1, v2) && sameRegister(v1, v3);
     }
 
-    public static boolean differentRegisters(Value v1, Value v2) {
-        return !isRegister(v1) || !isRegister(v2) || !asRegister(v1).equals(asRegister(v2));
+    /**
+     * Checks if all the provided values are different physical registers. The parameters can be
+     * either {@link Register registers}, {@link Value values} or arrays of them. All values that
+     * are not {@link RegisterValue registers} are ignored.
+     */
+    public static boolean differentRegisters(Object... values) {
+        List<Register> registers = collectRegisters(values, new ArrayList<Register>());
+        for (int i = 1; i < registers.size(); i++) {
+            Register r1 = registers.get(i);
+            for (int j = 0; j < i; j++) {
+                Register r2 = registers.get(j);
+                if (r1.equals(r2)) {
+                    return false;
+                }
+            }
+        }
+        return true;
     }
 
-    public static boolean differentRegisters(Value v1, Value v2, Value v3) {
-        return differentRegisters(v1, v2) && differentRegisters(v1, v3) && differentRegisters(v2, v3);
+    private static List<Register> collectRegisters(Object[] values, List<Register> registers) {
+        for (Object o : values) {
+            if (o instanceof Register) {
+                registers.add((Register) o);
+            } else if (o instanceof Value) {
+                if (isRegister((Value) o)) {
+                    registers.add(asRegister((Value) o));
+                }
+            } else if (o instanceof Object[]) {
+                collectRegisters((Object[]) o, registers);
+            } else {
+                throw new IllegalArgumentException("Not a Register or Value: " + o);
+            }
+        }
+        return registers;
     }
 }
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Tue Dec 03 18:19:56 2013 +0100
@@ -885,7 +885,7 @@
     protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
         long maxOffset = linkage.getMaxCallTargetOffset();
         if (maxOffset != (int) maxOffset) {
-            append(new AMD64Call.DirectFarForeignCallOp(this, linkage, result, arguments, temps, info));
+            append(new AMD64Call.DirectFarForeignCallOp(linkage, result, arguments, temps, info));
         } else {
             append(new AMD64Call.DirectNearForeignCallOp(linkage, result, arguments, temps, info));
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Dec 03 18:19:56 2013 +0100
@@ -720,6 +720,7 @@
     @HotSpotVMField(name = "Array<Klass*>::_data", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayBaseOffset;
 
     @HotSpotVMField(name = "InstanceKlass::_init_state", get = HotSpotVMField.Type.OFFSET) @Stable public int klassStateOffset;
+    @HotSpotVMConstant(name = "InstanceKlass::linked") @Stable public int klassStateLinked;
     @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int klassStateFullyInitialized;
     @HotSpotVMField(name = "InstanceKlass::_constants", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassConstantsOffset;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Dec 03 18:19:56 2013 +0100
@@ -207,8 +207,6 @@
 
     JavaMethod resolveMethod(HotSpotResolvedObjectType klass, String name, String signature);
 
-    boolean isTypeInitialized(HotSpotResolvedObjectType klass);
-
     void initializeType(HotSpotResolvedObjectType klass);
 
     ResolvedJavaType getResolvedType(Class<?> javaClass);
@@ -273,8 +271,6 @@
 
     void invalidateInstalledCode(HotSpotInstalledCode hotspotInstalledCode);
 
-    boolean isTypeLinked(HotSpotResolvedObjectType hotSpotResolvedObjectType);
-
     /**
      * Collects the current values of all Graal benchmark counters, summed up over all threads.
      */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Dec 03 18:19:56 2013 +0100
@@ -97,11 +97,6 @@
     public native JavaMethod resolveMethod(HotSpotResolvedObjectType klass, String name, String signature);
 
     @Override
-    public native boolean isTypeInitialized(HotSpotResolvedObjectType klass);
-
-    public native boolean isTypeLinked(HotSpotResolvedObjectType hotSpotResolvedObjectType);
-
-    @Override
     public native boolean hasFinalizableSubclass(HotSpotResolvedObjectType klass);
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Tue Dec 03 18:19:56 2013 +0100
@@ -139,7 +139,7 @@
         if (codeSize == 0) {
             return null;
         }
-        if (code == null && runtime().getCompilerToVM().isTypeLinked(holder)) {
+        if (code == null && holder.isLinked()) {
             code = runtime().getCompilerToVM().initializeBytecode(metaspaceMethod, new byte[codeSize]);
             assert code.length == codeSize : "expected: " + codeSize + ", actual: " + code.length;
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Tue Dec 03 18:19:56 2013 +0100
@@ -82,8 +82,6 @@
     private HotSpotResolvedJavaField[] instanceFields;
     private ResolvedJavaType[] interfaces;
     private ConstantPool constantPool;
-    private boolean isInitialized;
-    private boolean isLinked;
     private ResolvedJavaType arrayOfType;
 
     /**
@@ -286,27 +284,24 @@
 
     @Override
     public boolean isInitialized() {
-        if (!isInitialized) {
-            isInitialized = runtime().getCompilerToVM().isTypeInitialized(this);
-        }
-        return isInitialized;
+        HotSpotVMConfig config = runtime().getConfig();
+        byte state = unsafe.getByte(metaspaceKlass + config.klassStateOffset);
+        return state == config.klassStateFullyInitialized;
     }
 
     @Override
     public boolean isLinked() {
-        if (!isLinked) {
-            isLinked = runtime().getCompilerToVM().isTypeLinked(this);
-        }
-        return isLinked;
+        HotSpotVMConfig config = runtime().getConfig();
+        byte state = unsafe.getByte(metaspaceKlass + config.klassStateOffset);
+        return state >= config.klassStateLinked;
     }
 
     @Override
     public void initialize() {
-        if (!isInitialized) {
+        if (!isInitialized()) {
             runtime().getCompilerToVM().initializeType(this);
-            assert runtime().getCompilerToVM().isTypeInitialized(this);
+            assert isInitialized();
         }
-        isInitialized = true;
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java	Tue Dec 03 18:19:56 2013 +0100
@@ -25,13 +25,13 @@
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
+import com.oracle.graal.amd64.*;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag;
 import com.oracle.graal.asm.amd64.*;
-import com.oracle.graal.asm.amd64.AMD64Assembler.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.nodes.spi.*;
 
 public class AMD64Call {
 
@@ -135,9 +135,14 @@
 
         @Temp({REG}) protected AllocatableValue callTemp;
 
-        public DirectFarForeignCallOp(LIRGeneratorTool gen, ForeignCallLinkage callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
+        public DirectFarForeignCallOp(ForeignCallLinkage callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
             super(callTarget, result, parameters, temps, state);
-            callTemp = gen.newVariable(Kind.Long);
+            /*
+             * The register allocator does not support virtual registers that are used at the call
+             * site, so use a fixed register.
+             */
+            callTemp = AMD64.rax.asValue(Kind.Long);
+            assert ValueUtil.differentRegisters(parameters, callTemp);
         }
 
         @Override
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Tue Dec 03 18:19:56 2013 +0100
@@ -96,6 +96,7 @@
             if (n instanceof PhiNode || n instanceof ProxyNode) {
                 ValueNode node = (ValueNode) n;
                 if (node.kind() == Kind.Object) {
+                    assert !(node.stamp() instanceof IllegalStamp) : "We assume all Phi and Proxy stamps are legal before the analysis";
                     node.setStamp(StampFactory.illegal(node.kind()));
                 }
             }
@@ -129,9 +130,9 @@
 
     private static boolean checkNoIllegalStamp(StructuredGraph graph) {
         for (Node n : graph.getNodes()) {
-            if (n instanceof ValueNode) {
+            if (n instanceof PhiNode || n instanceof ProxyNode) {
                 ValueNode node = (ValueNode) n;
-                assert !(node.stamp() instanceof IllegalStamp);
+                assert !(node.stamp() instanceof IllegalStamp) : "Stamp is illegal after analysis. This is not necessarily an error, but a condition that we want to investigate (and then maybe relax or remove the assertion).";
             }
         }
         return true;
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ImplicitCast.java	Tue Dec 03 18:06:21 2013 +0100
+++ b/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ImplicitCast.java	Tue Dec 03 18:19:56 2013 +0100
@@ -26,10 +26,6 @@
 
 import java.lang.annotation.*;
 
-/**
- * EXPERIMENTAL Filter feature. May change or disappear without notice. This feature is not
- * functional yet.
- */
 @Retention(RetentionPolicy.CLASS)
 @Target({ElementType.METHOD})
 public @interface ImplicitCast {
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Tue Dec 03 18:06:21 2013 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Tue Dec 03 18:19:56 2013 +0100
@@ -544,20 +544,6 @@
   return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD));
 C2V_END
 
-// TODO move to Java
-C2V_VMENTRY(jboolean, isTypeInitialized,(JNIEnv *, jobject, jobject hotspot_klass))
-  Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
-  assert(klass != NULL, "method must not be called for primitive types");
-  return InstanceKlass::cast(klass)->is_initialized();
-C2V_END
-
-// TODO move to Java
-C2V_VMENTRY(jboolean, isTypeLinked,(JNIEnv *, jobject, jobject hotspot_klass))
-  Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
-  assert(klass != NULL, "method must not be called for primitive types");
-  return InstanceKlass::cast(klass)->is_linked();
-C2V_END
-
 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject hotspot_klass))
   Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(hotspot_klass));
   assert(klass != NULL, "method must not be called for primitive types");
@@ -1116,8 +1102,6 @@
   {CC"resolveMethod",                 CC"("HS_RESOLVED_TYPE STRING STRING")"METHOD,                     FN_PTR(resolveMethod)},
   {CC"getInstanceFields",             CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_FIELD,                       FN_PTR(getInstanceFields)},
   {CC"getMethods",                    CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_METHOD,                      FN_PTR(getMethods)},
-  {CC"isTypeInitialized",             CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(isTypeInitialized)},
-  {CC"isTypeLinked",                  CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(isTypeLinked)},
   {CC"hasFinalizableSubclass",        CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(hasFinalizableSubclass)},
   {CC"initializeType",                CC"("HS_RESOLVED_TYPE")V",                                        FN_PTR(initializeType)},
   {CC"getMaxCallTargetOffset",        CC"(J)J",                                                         FN_PTR(getMaxCallTargetOffset)},