# HG changeset patch # User Doug Simon # Date 1376942283 -7200 # Node ID 70e8575d526437cc96622e2698f996356dd9ea28 # Parent b332bfd012a42f0682659b699b61fe3ea9e1f919 more javadoc for debug framework diff -r b332bfd012a4 -r 70e8575d5264 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java --- 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 { 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; } diff -r b332bfd012a4 -r 70e8575d5264 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java --- 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 topLevelMaps = new ArrayList<>(); @@ -102,9 +105,9 @@ } public void normalize() { - if (this.hasChildren()) { + if (hasChildren()) { Map 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(); } } diff -r b332bfd012a4 -r 70e8575d5264 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/KeyRegistry.java --- 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 keyMap = new HashMap<>(); private static List 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 getDebugValues() { return Collections.unmodifiableList(debugValues); }