diff -r 1258121876f8 -r 8e875c964f41 src/share/vm/jfr/leakprofiler/chains/bfsClosure.cpp --- a/src/share/vm/jfr/leakprofiler/chains/bfsClosure.cpp Fri Sep 27 13:23:32 2019 +0800 +++ b/src/share/vm/jfr/leakprofiler/chains/bfsClosure.cpp Wed Oct 09 16:11:58 2019 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -97,7 +97,6 @@ } void BFSClosure::process() { - process_root_set(); process_queue(); } @@ -136,7 +135,6 @@ // if we are processinig initial root set, don't add to queue if (_current_parent != NULL) { - assert(_current_parent->distance_to_root() == _current_frontier_level, "invariant"); _edge_queue->add(_current_parent, reference); } @@ -149,20 +147,8 @@ void BFSClosure::add_chain(const oop* reference, const oop pointee) { assert(pointee != NULL, "invariant"); assert(NULL == pointee->mark(), "invariant"); - - const size_t length = _current_parent == NULL ? 1 : _current_parent->distance_to_root() + 2; - ResourceMark rm; - Edge* const chain = NEW_RESOURCE_ARRAY(Edge, length); - size_t idx = 0; - chain[idx++] = Edge(NULL, reference); - // aggregate from breadth-first search - const Edge* current = _current_parent; - while (current != NULL) { - chain[idx++] = Edge(NULL, current->reference()); - current = current->parent(); - } - assert(length == idx, "invariant"); - _edge_store->add_chain(chain, length); + Edge leak_edge(_current_parent, reference); + _edge_store->put_chain(&leak_edge, _current_parent == NULL ? 1 : _current_frontier_level + 2); } void BFSClosure::dfs_fallback() { @@ -239,3 +225,10 @@ closure_impl(UnifiedOop::encode(ref), pointee); } } + +void BFSClosure::do_root(const oop* ref) { + assert(ref != NULL, "invariant"); + if (!_edge_queue->is_full()) { + _edge_queue->add(NULL, ref); + } +}