1.1 --- a/src/share/classes/com/sun/tools/javac/code/Scope.java Mon Feb 07 18:09:46 2011 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Scope.java Mon Feb 07 18:10:13 2011 +0000 1.3 @@ -72,49 +72,10 @@ 1.4 */ 1.5 int nelems = 0; 1.6 1.7 - /** A timestamp - useful to quickly check whether a scope has changed or not 1.8 - */ 1.9 - public ScopeCounter scopeCounter; 1.10 - 1.11 - static ScopeCounter dummyCounter = new ScopeCounter() { 1.12 - @Override 1.13 - public void inc() { 1.14 - //do nothing 1.15 - } 1.16 - }; 1.17 - 1.18 /** A list of scopes to be notified if items are to be removed from this scope. 1.19 */ 1.20 List<Scope> listeners = List.nil(); 1.21 1.22 - public static class ScopeCounter { 1.23 - protected static final Context.Key<ScopeCounter> scopeCounterKey = 1.24 - new Context.Key<ScopeCounter>(); 1.25 - 1.26 - public static ScopeCounter instance(Context context) { 1.27 - ScopeCounter instance = context.get(scopeCounterKey); 1.28 - if (instance == null) 1.29 - instance = new ScopeCounter(context); 1.30 - return instance; 1.31 - } 1.32 - 1.33 - protected ScopeCounter(Context context) { 1.34 - context.put(scopeCounterKey, this); 1.35 - } 1.36 - 1.37 - private ScopeCounter() {}; 1.38 - 1.39 - private long val = 0; 1.40 - 1.41 - public void inc() { 1.42 - val++; 1.43 - } 1.44 - 1.45 - public long val() { 1.46 - return val; 1.47 - } 1.48 - } 1.49 - 1.50 /** Use as a "not-found" result for lookup. 1.51 * Also used to mark deleted entries in the table. 1.52 */ 1.53 @@ -126,35 +87,30 @@ 1.54 1.55 /** A value for the empty scope. 1.56 */ 1.57 - public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter); 1.58 + public static final Scope emptyScope = new Scope(null, null, new Entry[]{}); 1.59 1.60 /** Construct a new scope, within scope next, with given owner, using 1.61 * given table. The table's length must be an exponent of 2. 1.62 */ 1.63 - private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) { 1.64 + private Scope(Scope next, Symbol owner, Entry[] table) { 1.65 this.next = next; 1.66 Assert.check(emptyScope == null || owner != null); 1.67 this.owner = owner; 1.68 this.table = table; 1.69 this.hashMask = table.length - 1; 1.70 - this.scopeCounter = scopeCounter; 1.71 } 1.72 1.73 /** Convenience constructor used for dup and dupUnshared. */ 1.74 - private Scope(Scope next, Symbol owner, Entry[] table) { 1.75 - this(next, owner, table, next.scopeCounter); 1.76 - this.nelems = next.nelems; 1.77 + private Scope(Scope next, Symbol owner, Entry[] table, int nelems) { 1.78 + this(next, owner, table); 1.79 + this.nelems = nelems; 1.80 } 1.81 1.82 /** Construct a new scope, within scope next, with given owner, 1.83 * using a fresh table of length INITIAL_SIZE. 1.84 */ 1.85 public Scope(Symbol owner) { 1.86 - this(owner, dummyCounter); 1.87 - } 1.88 - 1.89 - protected Scope(Symbol owner, ScopeCounter scopeCounter) { 1.90 - this(null, owner, new Entry[INITIAL_SIZE], scopeCounter); 1.91 + this(null, owner, new Entry[INITIAL_SIZE]); 1.92 } 1.93 1.94 /** Construct a fresh scope within this scope, with same owner, 1.95 @@ -172,7 +128,7 @@ 1.96 * of fresh tables. 1.97 */ 1.98 public Scope dup(Symbol newOwner) { 1.99 - Scope result = new Scope(this, newOwner, this.table); 1.100 + Scope result = new Scope(this, newOwner, this.table, this.nelems); 1.101 shared++; 1.102 // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); 1.103 // new Error().printStackTrace(System.out); 1.104 @@ -184,7 +140,7 @@ 1.105 * the table of its outer scope. 1.106 */ 1.107 public Scope dupUnshared() { 1.108 - return new Scope(this, this.owner, this.table.clone()); 1.109 + return new Scope(this, this.owner, this.table.clone(), this.nelems); 1.110 } 1.111 1.112 /** Remove all entries of this scope from its table, if shared 1.113 @@ -263,7 +219,6 @@ 1.114 Entry e = makeEntry(sym, old, elems, s, origin); 1.115 table[hash] = e; 1.116 elems = e; 1.117 - scopeCounter.inc(); 1.118 } 1.119 1.120 Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) { 1.121 @@ -278,8 +233,6 @@ 1.122 Entry e = lookup(sym.name); 1.123 if (e.scope == null) return; 1.124 1.125 - scopeCounter.inc(); 1.126 - 1.127 // remove e from table and shadowed list; 1.128 int i = getIndex(sym.name); 1.129 Entry te = table[i]; 1.130 @@ -559,7 +512,7 @@ 1.131 public static final Entry[] emptyTable = new Entry[0]; 1.132 1.133 public DelegatedScope(Scope outer) { 1.134 - super(outer, outer.owner, emptyTable, outer.scopeCounter); 1.135 + super(outer, outer.owner, emptyTable); 1.136 delegatee = outer; 1.137 } 1.138 public Scope dup() { 1.139 @@ -585,22 +538,10 @@ 1.140 } 1.141 } 1.142 1.143 - /** A class scope, for which a scope counter should be provided */ 1.144 - public static class ClassScope extends Scope { 1.145 - 1.146 - ClassScope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) { 1.147 - super(next, owner, table, scopeCounter); 1.148 - } 1.149 - 1.150 - public ClassScope(Symbol owner, ScopeCounter scopeCounter) { 1.151 - super(owner, scopeCounter); 1.152 - } 1.153 - } 1.154 - 1.155 /** An error scope, for which the owner should be an error symbol. */ 1.156 public static class ErrorScope extends Scope { 1.157 ErrorScope(Scope next, Symbol errSymbol, Entry[] table) { 1.158 - super(next, /*owner=*/errSymbol, table, dummyCounter); 1.159 + super(next, /*owner=*/errSymbol, table); 1.160 } 1.161 public ErrorScope(Symbol errSymbol) { 1.162 super(errSymbol);