< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeBitMap.java

Print this page




 178 
 179     public <T extends Node> void markAll(Iterable<T> nodes) {
 180         for (Node node : nodes) {
 181             mark(node);
 182         }
 183     }
 184 
 185     protected Node nextMarkedNode(int fromNodeId) {
 186         assert fromNodeId >= 0;
 187         int wordIndex = fromNodeId >> SHIFT;
 188         int wordsInUse = bits.length;
 189         if (wordIndex < wordsInUse) {
 190             long word = getPartOfWord(bits[wordIndex], fromNodeId);
 191             while (true) {
 192                 while (word != 0) {
 193                     int bitIndex = Long.numberOfTrailingZeros(word);
 194                     int nodeId = wordIndex * Long.SIZE + bitIndex;
 195                     Node result = graph.getNode(nodeId);
 196                     if (result == null) {
 197                         // node was deleted -> clear the bit and continue searching
 198                         bits[wordIndex] = bits[wordIndex] & ~(1 << bitIndex);
 199                         int nextNodeId = nodeId + 1;
 200                         if ((nextNodeId & (Long.SIZE - 1)) == 0) {
 201                             // we reached the end of this word
 202                             break;
 203                         } else {
 204                             word = getPartOfWord(word, nextNodeId);
 205                         }
 206                     } else {
 207                         return result;
 208                     }
 209                 }
 210                 if (++wordIndex == wordsInUse) {
 211                     break;
 212                 }
 213                 word = bits[wordIndex];
 214             }
 215         }
 216         return null;
 217     }
 218 




 178 
 179     public <T extends Node> void markAll(Iterable<T> nodes) {
 180         for (Node node : nodes) {
 181             mark(node);
 182         }
 183     }
 184 
 185     protected Node nextMarkedNode(int fromNodeId) {
 186         assert fromNodeId >= 0;
 187         int wordIndex = fromNodeId >> SHIFT;
 188         int wordsInUse = bits.length;
 189         if (wordIndex < wordsInUse) {
 190             long word = getPartOfWord(bits[wordIndex], fromNodeId);
 191             while (true) {
 192                 while (word != 0) {
 193                     int bitIndex = Long.numberOfTrailingZeros(word);
 194                     int nodeId = wordIndex * Long.SIZE + bitIndex;
 195                     Node result = graph.getNode(nodeId);
 196                     if (result == null) {
 197                         // node was deleted -> clear the bit and continue searching
 198                         bits[wordIndex] = bits[wordIndex] & ~(1L << bitIndex);
 199                         int nextNodeId = nodeId + 1;
 200                         if ((nextNodeId & (Long.SIZE - 1)) == 0) {
 201                             // we reached the end of this word
 202                             break;
 203                         } else {
 204                             word = getPartOfWord(word, nextNodeId);
 205                         }
 206                     } else {
 207                         return result;
 208                     }
 209                 }
 210                 if (++wordIndex == wordsInUse) {
 211                     break;
 212                 }
 213                 word = bits[wordIndex];
 214             }
 215         }
 216         return null;
 217     }
 218 


< prev index next >