changeset 11364:70e8575d5264

more javadoc for debug framework
author Doug Simon <doug.simon@oracle.com>
date Mon, 19 Aug 2013 21:58:03 +0200
parents b332bfd012a4
children 5a7644d5fe20
files graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/KeyRegistry.java
diffstat 3 files changed, 33 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java	Mon Aug 19 21:57:12 2013 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java	Mon Aug 19 21:58:03 2013 +0200
@@ -22,6 +22,10 @@
  */
 package com.oracle.graal.debug.internal;
 
+/**
+ * A name and index for a value managed in a thread local value map. All access to the value is made
+ * via a {@link DebugValue} instance.
+ */
 public abstract class DebugValue implements Comparable<DebugValue> {
 
     private final String name;
@@ -44,7 +48,7 @@
 
     private void ensureInitialized() {
         if (index == -1) {
-            index = KeyRegistry.register(name, this);
+            index = KeyRegistry.register(this);
         }
     }
 
@@ -52,11 +56,17 @@
         setCurrentValue(getCurrentValue() + value);
     }
 
+    /**
+     * Gets the globally unique index for the value represented by this object.
+     */
     public int getIndex() {
         ensureInitialized();
         return index;
     }
 
+    /**
+     * Gets the globally unique name for the value represented by this object.
+     */
     public String getName() {
         return name;
     }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java	Mon Aug 19 21:57:12 2013 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java	Mon Aug 19 21:58:03 2013 +0200
@@ -24,6 +24,9 @@
 
 import java.util.*;
 
+/**
+ * A node in a tree of {@link DebugValue}s.
+ */
 public class DebugValueMap {
 
     private static List<DebugValueMap> topLevelMaps = new ArrayList<>();
@@ -102,9 +105,9 @@
     }
 
     public void normalize() {
-        if (this.hasChildren()) {
+        if (hasChildren()) {
             Map<String, DebugValueMap> occurred = new HashMap<>();
-            for (DebugValueMap map : this.children) {
+            for (DebugValueMap map : children) {
                 String mapName = map.getName();
                 if (!occurred.containsKey(mapName)) {
                     occurred.put(mapName, map);
@@ -119,7 +122,7 @@
                 // At least one duplicate was found.
                 children.clear();
                 for (DebugValueMap map : occurred.values()) {
-                    children.add(map);
+                    addChild(map);
                     map.normalize();
                 }
             }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/KeyRegistry.java	Mon Aug 19 21:57:12 2013 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/KeyRegistry.java	Mon Aug 19 21:58:03 2013 +0200
@@ -24,20 +24,33 @@
 
 import java.util.*;
 
+/**
+ * Registry for allocating a globally unique integer id to each {@link DebugValue}.
+ */
 public class KeyRegistry {
 
-    private static int keyCount;
     private static Map<String, Integer> keyMap = new HashMap<>();
     private static List<DebugValue> debugValues = new ArrayList<>();
 
-    public static synchronized int register(String name, DebugValue value) {
+    /**
+     * Ensures a given debug value is registered.
+     * 
+     * @return the globally unique id for {@code value}
+     */
+    public static synchronized int register(DebugValue value) {
+        String name = value.getName();
         if (!keyMap.containsKey(name)) {
-            keyMap.put(name, keyCount++);
+            keyMap.put(name, debugValues.size());
             debugValues.add(value);
         }
         return keyMap.get(name);
     }
 
+    /**
+     * Gets a immutable view of the registered debug values.
+     * 
+     * @return a list where {@code get(i).getIndex() == i}
+     */
     public static synchronized List<DebugValue> getDebugValues() {
         return Collections.unmodifiableList(debugValues);
     }