changeset 11814:22d47c2c74e9

Merge
author Andreas Woess <andreas.woess@jku.at>
date Thu, 26 Sep 2013 16:46:27 +0200
parents 14904566a4b2 (current diff) 9af8b109ec0f (diff)
children 43bc62c78f77 97d6932a309b
files
diffstat 6 files changed, 47 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java	Thu Sep 26 13:17:48 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java	Thu Sep 26 16:46:27 2013 +0200
@@ -60,12 +60,14 @@
 
     private final HashMap<List<Object>, StructuredGraph> cache = new HashMap<>();
     private final StructuredGraph markerGraph = new StructuredGraph();
+    private final ResolvedJavaType stringBuilderClass;
 
     public TruffleCache(MetaAccessProvider metaAccessProvider, GraphBuilderConfiguration config, OptimisticOptimizations optimisticOptimizations, Replacements replacements) {
         this.metaAccessProvider = metaAccessProvider;
         this.config = config;
         this.optimisticOptimizations = optimisticOptimizations;
         this.replacements = replacements;
+        this.stringBuilderClass = metaAccessProvider.lookupJavaType(StringBuilder.class);
     }
 
     @SuppressWarnings("unused")
@@ -192,7 +194,8 @@
         }
         if (inlineGraph == this.markerGraph) {
             // Can happen for recursive calls.
-            throw new IllegalStateException("Found illegal recursive call to " + methodCallTargetNode.targetMethod() + ", must annotate such calls with @CompilerDirectives.Slowpath!");
+            throw GraphUtil.approxSourceException(methodCallTargetNode, new IllegalStateException("Found illegal recursive call to " + methodCallTargetNode.targetMethod() +
+                            ", must annotate such calls with @CompilerDirectives.SlowPath!"));
         }
         Invoke invoke = methodCallTargetNode.invoke();
         InliningUtil.inline(invoke, inlineGraph, true);
@@ -214,9 +217,9 @@
         return false;
     }
 
-    private static boolean shouldInline(final MethodCallTargetNode methodCallTargetNode) {
+    private boolean shouldInline(final MethodCallTargetNode methodCallTargetNode) {
         return (methodCallTargetNode.invokeKind() == InvokeKind.Special || methodCallTargetNode.invokeKind() == InvokeKind.Static) &&
                         !Modifier.isNative(methodCallTargetNode.targetMethod().getModifiers()) && methodCallTargetNode.targetMethod().getAnnotation(ExplodeLoop.class) == null &&
-                        methodCallTargetNode.targetMethod().getAnnotation(CompilerDirectives.SlowPath.class) == null;
+                        methodCallTargetNode.targetMethod().getAnnotation(CompilerDirectives.SlowPath.class) == null && methodCallTargetNode.targetMethod().getDeclaringClass() != stringBuilderClass;
     }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java	Thu Sep 26 13:17:48 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java	Thu Sep 26 16:46:27 2013 +0200
@@ -39,6 +39,7 @@
     private final ArrayList<FrameSlotImpl> slots;
     private final HashMap<Object, FrameSlotImpl> identifierToSlotMap;
     private Assumption version;
+    private HashMap<Object, Assumption> identifierToNotInFrameAssumptionMap;
 
     public FrameDescriptor() {
         this(DefaultFrameTypeConversion.getInstance());
@@ -61,6 +62,7 @@
         slots.add(slot);
         identifierToSlotMap.put(identifier, slot);
         updateVersion();
+        invalidateNotInFrameAssumption(identifier);
         return slot;
     }
 
@@ -93,7 +95,7 @@
     }
 
     /**
-     * (db) to retrieve the list of all the identifiers associated with this frame descriptor.
+     * Retrieve the list of all the identifiers associated with this frame descriptor.
      * 
      * @return the list of all the identifiers in this frame descriptor
      */
@@ -133,4 +135,32 @@
     public FrameTypeConversion getTypeConversion() {
         return typeConversion;
     }
+
+    public Assumption getNotInFrameAssumption(Object identifier) {
+        if (identifierToSlotMap.containsKey(identifier)) {
+            throw new IllegalArgumentException("Cannot get not-in-frame assumption for existing frame slot!");
+        }
+
+        if (identifierToNotInFrameAssumptionMap == null) {
+            identifierToNotInFrameAssumptionMap = new HashMap<>();
+        } else {
+            Assumption assumption = identifierToNotInFrameAssumptionMap.get(identifier);
+            if (assumption != null) {
+                return assumption;
+            }
+        }
+        Assumption assumption = Truffle.getRuntime().createAssumption("not in frame: " + identifier);
+        identifierToNotInFrameAssumptionMap.put(identifier, assumption);
+        return assumption;
+    }
+
+    private void invalidateNotInFrameAssumption(Object identifier) {
+        if (identifierToNotInFrameAssumptionMap != null) {
+            Assumption assumption = identifierToNotInFrameAssumptionMap.get(identifier);
+            if (assumption != null) {
+                assumption.invalidate();
+                identifierToNotInFrameAssumptionMap.remove(identifier);
+            }
+        }
+    }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/AbstractAssumption.java	Thu Sep 26 13:17:48 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/AbstractAssumption.java	Thu Sep 26 16:46:27 2013 +0200
@@ -43,6 +43,6 @@
 
     @Override
     public String toString() {
-        return "Assumption: " + name;
+        return "Assumption(valid=" + isValid + "): " + name;
     }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Thu Sep 26 13:17:48 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Thu Sep 26 16:46:27 2013 +0200
@@ -292,12 +292,8 @@
 
     @SuppressWarnings("unchecked")
     public static <T extends Node> T cloneNode(T orig) {
-        Class<? extends Node> clazz = orig.getClass();
-        NodeClass nodeClass = NodeClass.get(clazz);
-        Node clone = orig.copy();
-        if (clone == null) {
-            return null;
-        }
+        final Node clone = orig.copy();
+        NodeClass nodeClass = NodeClass.get(clone.getClass());
 
         unsafe.putObject(clone, nodeClass.parentOffset, null);
 
@@ -305,10 +301,6 @@
             Node child = (Node) unsafe.getObject(orig, fieldOffset);
             if (child != null) {
                 Node clonedChild = cloneNode(child);
-                if (clonedChild == null) {
-                    return null;
-                }
-
                 unsafe.putObject(clonedChild, nodeClass.parentOffset, clone);
                 unsafe.putObject(clone, fieldOffset, clonedChild);
             }
@@ -316,16 +308,13 @@
         for (long fieldOffset : nodeClass.childrenOffsets) {
             Node[] children = (Node[]) unsafe.getObject(orig, fieldOffset);
             if (children != null) {
-                Node[] clonedChildren = children.clone();
-                Arrays.fill(clonedChildren, null);
+                Node[] clonedChildren = (Node[]) Array.newInstance(children.getClass().getComponentType(), children.length);
                 for (int i = 0; i < children.length; i++) {
-                    Node clonedChild = cloneNode(children[i]);
-                    if (clonedChild == null) {
-                        return null;
+                    if (children[i] != null) {
+                        Node clonedChild = cloneNode(children[i]);
+                        clonedChildren[i] = clonedChild;
+                        unsafe.putObject(clonedChild, nodeClass.parentOffset, clone);
                     }
-
-                    clonedChildren[i] = clonedChild;
-                    unsafe.putObject(clonedChild, nodeClass.parentOffset, clone);
                 }
                 unsafe.putObject(clone, fieldOffset, clonedChildren);
             }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/UnexpectedResultException.java	Thu Sep 26 13:17:48 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/UnexpectedResultException.java	Thu Sep 26 16:46:27 2013 +0200
@@ -35,7 +35,7 @@
     private final Object result;
 
     /**
-     * Creates the exception with the alternative result that cannot be respresented as a value of
+     * Creates the exception with the alternative result that cannot be represented as a value of
      * the return type.
      * 
      * @param result the alternative result
--- a/mxtool/mx.py	Thu Sep 26 13:17:48 2013 +0200
+++ b/mxtool/mx.py	Thu Sep 26 16:46:27 2013 +0200
@@ -2810,8 +2810,7 @@
     if exists(md):
         return wsdir
     split = os.path.split(wsdir)
-    # How to do this for Windows?
-    if split[0] == '/':
+    if split[0] == wsdir: # root directory
         return None
     else:
         return _find_eclipse_wsroot(split[0])