| OLD | NEW |
| 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 class ValueSet { | 5 class ValueSet { |
| 6 int size = 0; | 6 int size = 0; |
| 7 List<HInstruction> table; | 7 List<HInstruction> table; |
| 8 ValueSetNode collisions; | 8 ValueSetNode collisions; |
| 9 ValueSet() : table = new List<HInstruction>(8); | 9 ValueSet() : table = new List<HInstruction>(8); |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 HInstruction lookup(HInstruction instruction) { | 33 HInstruction lookup(HInstruction instruction) { |
| 34 int hashCode = instruction.gvnHashCode(); | 34 int hashCode = instruction.gvnHashCode(); |
| 35 int index = hashCode % table.length; | 35 int index = hashCode % table.length; |
| 36 // Look in the hash table. | 36 // Look in the hash table. |
| 37 HInstruction probe = table[index]; | 37 HInstruction probe = table[index]; |
| 38 if (probe != null && probe.gvnEquals(instruction)) return probe; | 38 if (probe != null && probe.gvnEquals(instruction)) return probe; |
| 39 // Look in the collisions list. | 39 // Look in the collisions list. |
| 40 for (ValueSetNode node = collisions; node != null; node = node.next) { | 40 for (ValueSetNode node = collisions; node != null; node = node.next) { |
| 41 if (node.hashCode() == hashCode) { | 41 if (node.hashCode == hashCode) { |
| 42 HInstruction cached = node.value; | 42 HInstruction cached = node.value; |
| 43 if (cached.gvnEquals(instruction)) return cached; | 43 if (cached.gvnEquals(instruction)) return cached; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 return null; | 46 return null; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void kill(int flags) { | 49 void kill(int flags) { |
| 50 if (flags == 0) return; | 50 if (flags == 0) return; |
| 51 int depends = HInstruction.computeDependsOnFlags(flags); | 51 int depends = HInstruction.computeDependsOnFlags(flags); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Make sure we preserved all elements and that no resizing | 142 // Make sure we preserved all elements and that no resizing |
| 143 // happened as part of this resizing. | 143 // happened as part of this resizing. |
| 144 assert(size == oldSize); | 144 assert(size == oldSize); |
| 145 assert(table.length == capacity); | 145 assert(table.length == capacity); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 class ValueSetNode { | 149 class ValueSetNode { |
| 150 final HInstruction value; | 150 final HInstruction value; |
| 151 final int hash; | 151 final int hash; |
| 152 int hashCode() => hash; | 152 int get hashCode => hash; |
| 153 ValueSetNode next; | 153 ValueSetNode next; |
| 154 ValueSetNode(this.value, this.hash, this.next); | 154 ValueSetNode(this.value, this.hash, this.next); |
| 155 } | 155 } |
| OLD | NEW |