changeset 10481:29e9a5d18c70

Clean up.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 23 Jun 2013 20:50:18 +0200
parents aa685bff0926
children 3e34b0318de6
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java
diffstat 4 files changed, 38 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Sun Jun 23 15:49:09 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Sun Jun 23 20:50:18 2013 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.hotspot.replacements;
 
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
+import static com.oracle.graal.phases.GraalOptions.*;
 import static com.oracle.graal.replacements.SnippetTemplate.*;
 
 import com.oracle.graal.api.code.*;
@@ -40,14 +41,20 @@
 
 public class WriteBarrierSnippets implements Snippets {
 
+    private static final SnippetCounter.Group countersWriteBarriers = SnippetCounters.getValue() ? new SnippetCounter.Group("WriteBarriers") : null;
+    private static final SnippetCounter serialFieldWriteBarrierCounter = new SnippetCounter(countersWriteBarriers, "serialFieldWriteBarrier", "Number of Serial Field Write Barriers");
+    private static final SnippetCounter serialArrayWriteBarrierCounter = new SnippetCounter(countersWriteBarriers, "serialArrayWriteBarrier", "Number of Serial Array Write Barriers");
+
     @Snippet
     public static void serialArrayWriteBarrier(Object obj, Object location, @ConstantParameter boolean usePrecise) {
         Object object = FixedValueAnchorNode.getObject(obj);
         Pointer oop;
         if (usePrecise) {
             oop = Word.fromArray(object, location);
+            serialArrayWriteBarrierCounter.inc();
         } else {
             oop = Word.fromObject(object);
+            serialFieldWriteBarrierCounter.inc();
         }
         Word base = (Word) oop.unsignedShiftRight(cardTableShift());
         long startAddress = cardTableStart();
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java	Sun Jun 23 15:49:09 2013 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java	Sun Jun 23 20:50:18 2013 +0200
@@ -34,12 +34,10 @@
 
     private static final long serialVersionUID = -3583286416638228207L;
 
-    @Component({ REG, OperandFlag.ILLEGAL })
-    protected AllocatableValue base;
+    @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue base;
     protected final int displacement;
 
-    public SPARCAddressValue(PlatformKind kind, AllocatableValue baseRegister,
-            int finalDisp) {
+    public SPARCAddressValue(PlatformKind kind, AllocatableValue baseRegister, int finalDisp) {
         super(kind);
         this.base = baseRegister;
         this.displacement = finalDisp;
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Sun Jun 23 15:49:09 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Sun Jun 23 20:50:18 2013 +0200
@@ -209,13 +209,15 @@
 
             setNodeProperty(node, "name", node.getClass().getSimpleName().replaceFirst("Node$", ""));
             NodeInfo nodeInfo = node.getClass().getAnnotation(NodeInfo.class);
-            if (nodeInfo != null && !nodeInfo.shortName().isEmpty()) {
-                setNodeProperty(node, "shortName", nodeInfo.shortName());
+            if (nodeInfo != null) {
+                setNodeProperty(node, "kind", nodeInfo.kind());
+                if (!nodeInfo.shortName().isEmpty()) {
+                    setNodeProperty(node, "shortName", nodeInfo.shortName());
+                }
             }
-            setNodeProperty(node, "nodeType", (Node.class.isAssignableFrom(node.getClass()) ? Node.class.getSimpleName() : "other"));
-            setNodeProperty(node, "nodeClass", node.getClass().getSimpleName());
-            copyDebugProperties(node); // TODO: may overwrite property "name"? (currently allowed)
+            setNodeProperty(node, "class", node.getClass().getSimpleName());
             readNodeProperties((Node) node);
+            copyDebugProperties(node);
         }
     }
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Sun Jun 23 15:49:09 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Sun Jun 23 20:50:18 2013 +0200
@@ -57,6 +57,10 @@
     public @interface Child {
     }
 
+    protected Node() {
+        CompilerAsserts.neverPartOfCompilation();
+    }
+
     /**
      * Assigns a link to a guest language source section to this node.
      * 
@@ -86,6 +90,18 @@
     }
 
     /**
+     * Retrieves the guest language source code section that is currently assigned to this node.
+     * 
+     * @return the assigned source code section
+     */
+    public final SourceSection getEncapsulatingSourceSection() {
+        if (sourceSection == null && getParent() != null) {
+            return getParent().getEncapsulatingSourceSection();
+        }
+        return sourceSection;
+    }
+
+    /**
      * Method that updates the link to the parent in the array of specified new child nodes to this
      * node.
      * 
@@ -109,6 +125,9 @@
      */
     protected final <T extends Node> T adoptChild(T newChild) {
         if (newChild != null) {
+            if (newChild == this) {
+                throw new IllegalStateException("The parent of a node can never be the node itself.");
+            }
             ((Node) newChild).parent = this;
         }
         return newChild;
@@ -144,7 +163,9 @@
      */
     @SuppressWarnings({"unchecked"})
     public final <T extends Node> T replace(T newNode, String reason) {
-        assert this.getParent() != null;
+        if (this.getParent() == null) {
+            throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent.");
+        }
         if (sourceSection != null) {
             // Pass on the source section to the new node.
             newNode.assignSourceSection(sourceSection);