165 // If node has same-sized siblings check those too.
166 const Node* n2 = n->_next;
167 while (n2 != nullptr) {
168 verify_node_pointer(n2);
169 tree_assert_invalid_node(n2 != n, n2); // catch simple circles
170 tree_assert_invalid_node(n2->_word_size == n->_word_size, n2);
171 counter.add(n2->_word_size);
172 n2 = n2->_next;
173 }
174 }
175 }
176
177 // At the end, check that counters match
178 // (which also verifies that we visited every node, or at least
179 // as many nodes as are in this tree)
180 _counter.check(counter);
181
182 #undef assrt0n
183 }
184
185 void BlockTree::zap_range(MetaWord* p, size_t word_size) {
186 memset(p, 0xF3, word_size * sizeof(MetaWord));
187 }
188
189 void BlockTree::print_tree(outputStream* st) const {
190
191 // Note: we do not print the tree indented, since I found that printing it
192 // as a quasi list is much clearer to the eye.
193 // We print the tree depth-first, with stacked nodes below normal ones
194 // (normal "real" nodes are marked with a leading '+')
195 if (_root != nullptr) {
196
197 ResourceMark rm;
198 GrowableArray<walkinfo> stack;
199
200 walkinfo info;
201 info.n = _root;
202 info.depth = 0;
203
204 stack.push(info);
205 while (stack.length() > 0) {
206 info = stack.pop();
209 // Print node.
210 st->print("%4d + ", info.depth);
211 if (os::is_readable_pointer(n)) {
212 st->print_cr(NODE_FORMAT, NODE_FORMAT_ARGS(n));
213 } else {
214 st->print_cr("@" PTR_FORMAT ": unreadable (skipping subtree)", p2i(n));
215 continue; // don't print this subtree
216 }
217
218 // Print same-sized-nodes stacked under this node
219 for (Node* n2 = n->_next; n2 != nullptr; n2 = n2->_next) {
220 st->print_raw(" ");
221 if (os::is_readable_pointer(n2)) {
222 st->print_cr(NODE_FORMAT, NODE_FORMAT_ARGS(n2));
223 } else {
224 st->print_cr("@" PTR_FORMAT ": unreadable (skipping rest of chain).", p2i(n2));
225 break; // stop printing this chain.
226 }
227 }
228
229 // Handle children.
230 if (n->_right != nullptr) {
231 walkinfo info2;
232 info2.n = n->_right;
233 info2.depth = info.depth + 1;
234 stack.push(info2);
235 }
236 if (n->_left != nullptr) {
237 walkinfo info2;
238 info2.n = n->_left;
239 info2.depth = info.depth + 1;
240 stack.push(info2);
241 }
242 }
243
244 } else {
245 st->print_cr("<no nodes>");
246 }
247 }
248
|
165 // If node has same-sized siblings check those too.
166 const Node* n2 = n->_next;
167 while (n2 != nullptr) {
168 verify_node_pointer(n2);
169 tree_assert_invalid_node(n2 != n, n2); // catch simple circles
170 tree_assert_invalid_node(n2->_word_size == n->_word_size, n2);
171 counter.add(n2->_word_size);
172 n2 = n2->_next;
173 }
174 }
175 }
176
177 // At the end, check that counters match
178 // (which also verifies that we visited every node, or at least
179 // as many nodes as are in this tree)
180 _counter.check(counter);
181
182 #undef assrt0n
183 }
184
185 void BlockTree::zap_block(MetaBlock bl) {
186 memset(bl.base(), 0xF3, bl.word_size() * sizeof(MetaWord));
187 }
188
189 void BlockTree::print_tree(outputStream* st) const {
190
191 // Note: we do not print the tree indented, since I found that printing it
192 // as a quasi list is much clearer to the eye.
193 // We print the tree depth-first, with stacked nodes below normal ones
194 // (normal "real" nodes are marked with a leading '+')
195 if (_root != nullptr) {
196
197 ResourceMark rm;
198 GrowableArray<walkinfo> stack;
199
200 walkinfo info;
201 info.n = _root;
202 info.depth = 0;
203
204 stack.push(info);
205 while (stack.length() > 0) {
206 info = stack.pop();
209 // Print node.
210 st->print("%4d + ", info.depth);
211 if (os::is_readable_pointer(n)) {
212 st->print_cr(NODE_FORMAT, NODE_FORMAT_ARGS(n));
213 } else {
214 st->print_cr("@" PTR_FORMAT ": unreadable (skipping subtree)", p2i(n));
215 continue; // don't print this subtree
216 }
217
218 // Print same-sized-nodes stacked under this node
219 for (Node* n2 = n->_next; n2 != nullptr; n2 = n2->_next) {
220 st->print_raw(" ");
221 if (os::is_readable_pointer(n2)) {
222 st->print_cr(NODE_FORMAT, NODE_FORMAT_ARGS(n2));
223 } else {
224 st->print_cr("@" PTR_FORMAT ": unreadable (skipping rest of chain).", p2i(n2));
225 break; // stop printing this chain.
226 }
227 }
228
229 // Handle simple circularities
230 if (n == n->_right || n == n->_left || n == n->_next) {
231 st->print_cr("@" PTR_FORMAT ": circularity detected.", p2i(n));
232 return; // stop printing
233 }
234
235 // Handle children.
236 if (n->_right != nullptr) {
237 walkinfo info2;
238 info2.n = n->_right;
239 info2.depth = info.depth + 1;
240 stack.push(info2);
241 }
242 if (n->_left != nullptr) {
243 walkinfo info2;
244 info2.n = n->_left;
245 info2.depth = info.depth + 1;
246 stack.push(info2);
247 }
248 }
249
250 } else {
251 st->print_cr("<no nodes>");
252 }
253 }
254
|