changeset 9138:cf3c89ef00f7

Merge.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 16 Apr 2013 13:33:04 +0200
parents f5c6a9b0262f (current diff) b2c5cdd6d8a1 (diff)
children 5cabfd00241e
files
diffstat 15 files changed, 56 insertions(+), 115 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java	Tue Apr 16 13:22:12 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java	Tue Apr 16 13:33:04 2013 +0200
@@ -57,10 +57,7 @@
 
         @Override
         public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + receiverType.hashCode();
-            return result;
+            return 31 + receiverType.hashCode();
         }
 
         @Override
@@ -195,10 +192,7 @@
 
         @Override
         public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + method.hashCode();
-            return result;
+            return 31 + method.hashCode();
         }
 
         @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Apr 16 13:22:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Apr 16 13:33:04 2013 +0200
@@ -169,6 +169,8 @@
 
     HotSpotResolvedJavaField[] getInstanceFields(HotSpotResolvedObjectType klass);
 
+    boolean hasFinalizableSubclass(HotSpotResolvedObjectType klass);
+
     /**
      * Gets the compiled code size for a method.
      * 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Apr 16 13:22:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Apr 16 13:33:04 2013 +0200
@@ -106,6 +106,9 @@
     public native boolean isTypeInitialized(HotSpotResolvedObjectType klass);
 
     @Override
+    public native boolean hasFinalizableSubclass(HotSpotResolvedObjectType klass);
+
+    @Override
     public native void initializeType(HotSpotResolvedObjectType klass);
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java	Tue Apr 16 13:22:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java	Tue Apr 16 13:33:04 2013 +0200
@@ -76,7 +76,6 @@
      * @param name the {@linkplain JavaType#getName() name} of the type
      * @param simpleName a simple, unqualified name for the type
      * @param javaMirror the {@link Class} mirror
-     * @param hasFinalizableSubclass specifies if the type has a finalizable subtype
      * @param sizeOrSpecies the size of an instance of the type, or
      *            {@link HotSpotResolvedObjectType#INTERFACE_SPECIES_VALUE} or
      *            {@link HotSpotResolvedObjectType#ARRAY_SPECIES_VALUE}
@@ -84,7 +83,7 @@
      *         instantiated by this call in the case of another thread racing to create the same
      *         type
      */
-    ResolvedJavaType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, boolean hasFinalizableSubclass, int sizeOrSpecies);
+    ResolvedJavaType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies);
 
     Constant createConstant(Kind kind, long value);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Apr 16 13:22:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Apr 16 13:33:04 2013 +0200
@@ -683,8 +683,8 @@
     }
 
     @Override
-    public HotSpotResolvedObjectType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, boolean hasFinalizableSubclass, int sizeOrSpecies) {
-        HotSpotResolvedObjectType type = new HotSpotResolvedObjectType(metaspaceKlass, name, simpleName, javaMirror, hasFinalizableSubclass, sizeOrSpecies);
+    public HotSpotResolvedObjectType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies) {
+        HotSpotResolvedObjectType type = new HotSpotResolvedObjectType(metaspaceKlass, name, simpleName, javaMirror, sizeOrSpecies);
 
         long offset = HotSpotGraalRuntime.getInstance().getConfig().graalMirrorInClassOffset;
         if (!unsafe.compareAndSwapObject(javaMirror, offset, null, type)) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Tue Apr 16 13:22:12 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Tue Apr 16 13:33:04 2013 +0200
@@ -23,7 +23,7 @@
 package com.oracle.graal.hotspot.meta;
 
 import static com.oracle.graal.api.meta.MetaUtil.*;
-import static com.oracle.graal.graph.FieldIntrospection.*;
+import static com.oracle.graal.graph.UnsafeAccess.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static java.lang.reflect.Modifier.*;
 
@@ -63,7 +63,6 @@
 
     private final Class<?> javaMirror; // this could be read directly from 'metaspaceKlass'...
     private final String simpleName;
-    private final boolean hasFinalizableSubclass;
 
     /**
      * The instance size (in bytes) for an instance type,
@@ -120,17 +119,15 @@
     }
 
     /**
-     * @param hasFinalizableSubclass
      * @param sizeOrSpecies the size of an instance of the type, or
      *            {@link HotSpotResolvedObjectType#INTERFACE_SPECIES_VALUE} or
      *            {@link HotSpotResolvedObjectType#ARRAY_SPECIES_VALUE}
      */
-    public HotSpotResolvedObjectType(long metaspaceKlass, String name, String simpleName, Class javaMirror, boolean hasFinalizableSubclass, int sizeOrSpecies) {
+    public HotSpotResolvedObjectType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies) {
         super(name);
         this.metaspaceKlass = metaspaceKlass;
         this.javaMirror = javaMirror;
         this.simpleName = simpleName;
-        this.hasFinalizableSubclass = hasFinalizableSubclass;
         this.sizeOrSpecies = sizeOrSpecies;
         assert name.charAt(0) != '[' || sizeOrSpecies == ARRAY_SPECIES_VALUE : name + " " + Long.toHexString(sizeOrSpecies);
         assert javaMirror.isArray() == isArray();
@@ -260,7 +257,8 @@
 
     @Override
     public boolean hasFinalizableSubclass() {
-        return hasFinalizableSubclass;
+        assert !isArray();
+        return HotSpotGraalRuntime.getInstance().getCompilerToVM().hasFinalizableSubclass(this);
     }
 
     @Override
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java	Tue Apr 16 13:22:12 2013 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java	Tue Apr 16 13:33:04 2013 +0200
@@ -27,6 +27,7 @@
 import java.util.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.CompilationResult.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.debug.*;
@@ -99,11 +100,23 @@
             }
         }
 
-        Debug.metric("TargetMethods").increment();
-        Debug.metric("CodeBytesEmitted").add(compilationResult.getTargetCodeSize());
-        Debug.metric("SafepointsEmitted").add(compilationResult.getInfopoints().size());
-        Debug.metric("DataPatches").add(compilationResult.getDataReferences().size());
-        Debug.metric("ExceptionHandlersEmitted").add(compilationResult.getExceptionHandlers().size());
+        if (Debug.isMeterEnabled()) {
+            List<DataPatch> ldp = compilationResult.getDataReferences();
+            DebugMetric[] dms = new DebugMetric[Kind.values().length];
+            for (int i = 0; i < dms.length; i++) {
+                dms[i] = Debug.metric("DataPatches-" + Kind.values()[i].toString());
+            }
+
+            for (DataPatch dp : ldp) {
+                dms[dp.constant.getKind().ordinal()].add(1);
+            }
+
+            Debug.metric("TargetMethods").increment();
+            Debug.metric("CodeBytesEmitted").add(compilationResult.getTargetCodeSize());
+            Debug.metric("SafepointsEmitted").add(compilationResult.getInfopoints().size());
+            Debug.metric("DataPatches").add(ldp.size());
+            Debug.metric("ExceptionHandlersEmitted").add(compilationResult.getExceptionHandlers().size());
+        }
         Debug.log("Finished target method %s, isStub %b", name, isStub);
         return compilationResult;
     }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java	Tue Apr 16 13:22:12 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java	Tue Apr 16 13:33:04 2013 +0200
@@ -91,11 +91,14 @@
     /**
      * Gets the specific replacer object used to replace the usage of an instanceof node with the
      * result of an instantiated instanceof snippet.
+     * 
+     * @param nUsages
+     * @param tool
      */
     protected InstanceOfUsageReplacer createReplacer(FloatingNode instanceOf, LoweringTool tool, int nUsages, Instantiation instantiation, Node usage, final StructuredGraph graph) {
         InstanceOfUsageReplacer replacer;
         if (usage instanceof IfNode) {
-            replacer = new IfUsageReplacer(instantiation, ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph), instanceOf, (IfNode) usage, nUsages == 1, tool);
+            replacer = new IfUsageReplacer(instantiation, ConstantNode.forInt(1, graph), ConstantNode.forInt(0, graph), instanceOf, (IfNode) usage);
         } else {
             assert usage instanceof ConditionalNode : "unexpected usage of " + instanceOf + ": " + usage;
             ConditionalNode c = (ConditionalNode) usage;
@@ -190,14 +193,10 @@
      */
     public static class IfUsageReplacer extends InstanceOfUsageReplacer {
 
-        private final boolean solitaryUsage;
         private final IfNode usage;
-        private final boolean sameBlock;
 
-        public IfUsageReplacer(Instantiation instantiation, ValueNode trueValue, ValueNode falseValue, FloatingNode instanceOf, IfNode usage, boolean solitaryUsage, LoweringTool tool) {
+        public IfUsageReplacer(Instantiation instantiation, ValueNode trueValue, ValueNode falseValue, FloatingNode instanceOf, IfNode usage) {
             super(instantiation, instanceOf, trueValue, falseValue);
-            this.sameBlock = tool.getBlockFor(usage) == tool.getBlockFor(instanceOf);
-            this.solitaryUsage = solitaryUsage;
             this.usage = usage;
         }
 
@@ -206,84 +205,13 @@
             usage.replaceFirstInput(instanceOf, instantiation.asCondition(trueValue));
         }
 
-        private boolean usageFollowsInstantiation() {
-            return instantiation.result != null && instantiation.result.merge().next() == usage;
-        }
-
         @Override
         public void replace(ValueNode oldNode, ValueNode newNode) {
             assert newNode instanceof PhiNode;
             assert oldNode == instanceOf;
-            if (sameBlock && solitaryUsage && usageFollowsInstantiation()) {
-                removeIntermediateMaterialization(newNode);
-            } else {
-                newNode.inferStamp();
-                instantiation.initialize((PhiNode) newNode, trueValue, falseValue);
-                usage.replaceFirstInput(oldNode, instantiation.asCondition(trueValue));
-            }
-        }
-
-        /**
-         * Directly wires the incoming edges of the merge at the end of the snippet to the outgoing
-         * edges of the IfNode that uses the materialized result.
-         */
-        private void removeIntermediateMaterialization(ValueNode newNode) {
-            IfNode ifNode = usage;
-            PhiNode phi = (PhiNode) newNode;
-            MergeNode merge = phi.merge();
-            assert merge.stateAfter() == null;
-
-            List<EndNode> mergePredecessors = merge.cfgPredecessors().snapshot();
-            assert phi.valueCount() == mergePredecessors.size();
-
-            List<EndNode> falseEnds = new ArrayList<>(mergePredecessors.size());
-            List<EndNode> trueEnds = new ArrayList<>(mergePredecessors.size());
-
-            int endIndex = 0;
-            for (EndNode end : mergePredecessors) {
-                ValueNode endValue = phi.valueAt(endIndex++);
-                if (endValue == trueValue) {
-                    trueEnds.add(end);
-                } else {
-                    assert endValue == falseValue;
-                    falseEnds.add(end);
-                }
-            }
-
-            BeginNode trueSuccessor = ifNode.trueSuccessor();
-            BeginNode falseSuccessor = ifNode.falseSuccessor();
-            ifNode.setTrueSuccessor(null);
-            ifNode.setFalseSuccessor(null);
-
-            connectEnds(merge, trueEnds, trueSuccessor);
-            connectEnds(merge, falseEnds, falseSuccessor);
-
-            GraphUtil.killCFG(merge);
-            GraphUtil.killCFG(ifNode);
-
-            assert !merge.isAlive() : merge;
-            assert !phi.isAlive() : phi;
-        }
-
-        private static void connectEnds(MergeNode merge, List<EndNode> ends, BeginNode successor) {
-            if (ends.size() == 0) {
-                // InstanceOf has been lowered to always true or always false - this successor is
-                // therefore unreachable.
-                GraphUtil.killCFG(successor);
-            } else if (ends.size() == 1) {
-                EndNode end = ends.get(0);
-                ((FixedWithNextNode) end.predecessor()).setNext(successor);
-                merge.removeEnd(end);
-                GraphUtil.killCFG(end);
-            } else {
-                assert ends.size() > 1;
-                MergeNode newMerge = merge.graph().add(new MergeNode());
-
-                for (EndNode end : ends) {
-                    newMerge.addForwardEnd(end);
-                }
-                newMerge.setNext(successor);
-            }
+            newNode.inferStamp();
+            instantiation.initialize((PhiNode) newNode, trueValue, falseValue);
+            usage.replaceFirstInput(oldNode, instantiation.asCondition(trueValue));
         }
     }
 
--- a/make/build-graal.xml	Tue Apr 16 13:22:12 2013 +0200
+++ b/make/build-graal.xml	Tue Apr 16 13:33:04 2013 +0200
@@ -31,7 +31,7 @@
   <target depends="jar" name="main"/>
   <target depends="cleanclasses" name="compile">
     <mkdir dir="${classes.dir}"/>
-    <javac debug="on" destdir="${classes.dir}" includeantruntime="false">
+    <javac debug="on" destdir="${classes.dir}" encoding="UTF-8" includeantruntime="false">
       <src path="${src.dir}/com.oracle.graal.api.runtime"/>
       <src path="${src.dir}/com.oracle.graal.api.meta"/>
       <src path="${src.dir}/com.oracle.graal.api.code"/>
--- a/mx/commands.py	Tue Apr 16 13:22:12 2013 +0200
+++ b/mx/commands.py	Tue Apr 16 13:33:04 2013 +0200
@@ -364,7 +364,8 @@
                 pass
     else:
         if not exists(jdk):
-            mx.abort('The ' + build + ' VM has not been created - run "mx build ' + build + '"')
+            vmOption = ' --vm ' + vmToCheck if vmToCheck else ''
+            mx.abort('The ' + build + ' VM has not been created - run "mx' + vmOption + ' build ' + build + '"')
             
     _installGraalJarInJdks(mx.distribution('GRAAL'))
     
@@ -502,7 +503,7 @@
 
     out.open('target', {'name' : 'compile', 'depends' : 'cleanclasses'})
     out.element('mkdir', {'dir' : '${classes.dir}'})
-    out.open('javac', {'destdir' : '${classes.dir}', 'debug' : 'on', 'includeantruntime' : 'false', })
+    out.open('javac', {'destdir' : '${classes.dir}', 'debug' : 'on', 'includeantruntime' : 'false', 'encoding' : 'UTF-8'})
     for p in mx.sorted_deps(mx.distribution('GRAAL').deps):
         out.element('src', {'path' : '${src.dir}/' + p.name})
     out.element('compilerarg', {'value' : '-XDignore.symbol.file'})
--- a/src/share/vm/classfile/vmSymbols.hpp	Tue Apr 16 13:22:12 2013 +0200
+++ b/src/share/vm/classfile/vmSymbols.hpp	Tue Apr 16 13:33:04 2013 +0200
@@ -360,7 +360,7 @@
   template(createUnresolvedJavaType_name,         "createUnresolvedJavaType")                                                         \
   template(createUnresolvedJavaType_signature,    "(Ljava/lang/String;)Lcom/oracle/graal/api/meta/JavaType;")                         \
   template(createResolvedJavaType_name,           "createResolvedJavaType")                                                           \
-  template(createResolvedJavaType_signature,      "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/Class;ZI)Lcom/oracle/graal/api/meta/ResolvedJavaType;") \
+  template(createResolvedJavaType_signature,      "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/Class;I)Lcom/oracle/graal/api/meta/ResolvedJavaType;") \
   template(createPrimitiveJavaType_name,          "createPrimitiveJavaType")                                                          \
   template(createPrimitiveJavaType_signature,     "(I)Lcom/oracle/graal/api/meta/JavaType;")                                          \
   template(createLocalImpl_name,                  "createLocalImpl")                                                                  \
--- a/src/share/vm/graal/graalCompiler.cpp	Tue Apr 16 13:22:12 2013 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp	Tue Apr 16 13:33:04 2013 +0200
@@ -293,9 +293,6 @@
     name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NULL);
   }
 
-  // TODO replace this with the correct value
-  bool hasFinalizableSubclass = false;
-
   int sizeOrSpecies;
   if (klass->is_interface()) {
     sizeOrSpecies = (int) 0x80000000; // see HotSpotResolvedObjectType.INTERFACE_SPECIES_VALUE
@@ -308,7 +305,7 @@
     }
   }
 
-  return VMToCompiler::createResolvedJavaType(klass(), name, simpleName, java_class, hasFinalizableSubclass, sizeOrSpecies, CHECK_NULL);
+  return VMToCompiler::createResolvedJavaType(klass(), name, simpleName, java_class, sizeOrSpecies, CHECK_NULL);
 }
 
 BasicType GraalCompiler::kindToBasicType(jchar ch) {
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Tue Apr 16 13:22:12 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Tue Apr 16 13:33:04 2013 +0200
@@ -550,6 +550,12 @@
   return InstanceKlass::cast(klass)->is_initialized();
 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");
+  return Dependencies::find_finalizable_subclass(klass) != NULL;
+C2V_END
+
 C2V_VMENTRY(void, initializeType, (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");
@@ -1131,6 +1137,7 @@
   {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"isTypeInitialized",             CC"("HS_RESOLVED_TYPE")Z",                                        FN_PTR(isTypeInitialized)},
+  {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)},
   {CC"getResolvedType",               CC"("CLASS")"RESOLVED_TYPE,                                       FN_PTR(getResolvedType)},
--- a/src/share/vm/graal/graalVMToCompiler.cpp	Tue Apr 16 13:22:12 2013 +0200
+++ b/src/share/vm/graal/graalVMToCompiler.cpp	Tue Apr 16 13:33:04 2013 +0200
@@ -208,7 +208,7 @@
   return (oop) result.get_jobject();
 }
 
-oop VMToCompiler::createResolvedJavaType(Klass* klass, Handle name, Handle simpleName, Handle java_mirror, jboolean hasFinalizableSubclass, jint sizeOrSpecies, TRAPS) {
+oop VMToCompiler::createResolvedJavaType(Klass* klass, Handle name, Handle simpleName, Handle java_mirror, jint sizeOrSpecies, TRAPS) {
   assert(!name.is_null(), "just checking");
   assert(!simpleName.is_null(), "just checking");
   JavaValue result(T_OBJECT);
@@ -218,7 +218,6 @@
   args.push_oop(name);
   args.push_oop(simpleName);
   args.push_oop(java_mirror);
-  args.push_int(hasFinalizableSubclass);
   args.push_int(sizeOrSpecies);
   JavaCalls::call_interface(&result, vmToCompilerKlass(), vmSymbols::createResolvedJavaType_name(), vmSymbols::createResolvedJavaType_signature(), &args, THREAD);
   check_pending_exception("Error while calling createResolvedJavaType");
--- a/src/share/vm/graal/graalVMToCompiler.hpp	Tue Apr 16 13:22:12 2013 +0200
+++ b/src/share/vm/graal/graalVMToCompiler.hpp	Tue Apr 16 13:33:04 2013 +0200
@@ -77,8 +77,8 @@
   // public abstract JavaType createUnresolvedJavaType(String name);
   static oop createUnresolvedJavaType(Handle name, TRAPS);
 
-  // public abstract ResolvedJavaType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, boolean hasFinalizableSubclass, int sizeOrSpecies);
-  static oop createResolvedJavaType(Klass* klass, Handle name, Handle simpleName, Handle java_mirror, jboolean hasFinalizableSubclass, jint sizeOrSpecies, TRAPS);
+  // public abstract ResolvedJavaType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies);
+  static oop createResolvedJavaType(Klass* klass, Handle name, Handle simpleName, Handle java_mirror, jint sizeOrSpecies, TRAPS);
 
   // public abstract JavaType createPrimitiveJavaType(int basicType);
   static oop createPrimitiveJavaType(int basicType, TRAPS);