Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/value_set.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of ssa; 5 part of ssa;
6 6
7 class ValueSet { 7 class ValueSet {
8 int size = 0; 8 int size = 0;
9 List<HInstruction> table; 9 List<HInstruction> table;
10 ValueSetNode collisions; 10 ValueSetNode collisions;
11 ValueSet() : table = new List<HInstruction>(8); 11 ValueSet() : table = new List<HInstruction>.fixedLength(8);
12 12
13 bool get isEmpty => size == 0; 13 bool get isEmpty => size == 0;
14 int get length => size; 14 int get length => size;
15 15
16 void add(HInstruction instruction) { 16 void add(HInstruction instruction) {
17 assert(lookup(instruction) == null); 17 assert(lookup(instruction) == null);
18 int hashCode = instruction.gvnHashCode(); 18 int hashCode = instruction.gvnHashCode();
19 int capacity = table.length; 19 int capacity = table.length;
20 // Resize when half of the hash table is in use. 20 // Resize when half of the hash table is in use.
21 if (size >= capacity >> 1) { 21 if (size >= capacity >> 1) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return result; 130 return result;
131 } 131 }
132 132
133 void resize(int capacity) { 133 void resize(int capacity) {
134 var oldSize = size; 134 var oldSize = size;
135 var oldTable = table; 135 var oldTable = table;
136 var oldCollisions = collisions; 136 var oldCollisions = collisions;
137 // Reset the table with a bigger capacity. 137 // Reset the table with a bigger capacity.
138 assert(capacity > table.length); 138 assert(capacity > table.length);
139 size = 0; 139 size = 0;
140 table = new List<HInstruction>(capacity); 140 table = new List<HInstruction>.fixedLength(capacity);
141 collisions = null; 141 collisions = null;
142 // Add the old instructions to the new table. 142 // Add the old instructions to the new table.
143 copyTo(this, oldTable, oldCollisions); 143 copyTo(this, oldTable, oldCollisions);
144 // Make sure we preserved all elements and that no resizing 144 // Make sure we preserved all elements and that no resizing
145 // happened as part of this resizing. 145 // happened as part of this resizing.
146 assert(size == oldSize); 146 assert(size == oldSize);
147 assert(table.length == capacity); 147 assert(table.length == capacity);
148 } 148 }
149 } 149 }
150 150
151 class ValueSetNode { 151 class ValueSetNode {
152 final HInstruction value; 152 final HInstruction value;
153 final int hash; 153 final int hash;
154 int get hashCode => hash; 154 int get hashCode => hash;
155 ValueSetNode next; 155 ValueSetNode next;
156 ValueSetNode(this.value, this.hash, this.next); 156 ValueSetNode(this.value, this.hash, this.next);
157 } 157 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698