1.1 --- a/src/share/vm/jfr/leakprofiler/chains/bfsClosure.cpp Fri Sep 27 13:23:32 2019 +0800 1.2 +++ b/src/share/vm/jfr/leakprofiler/chains/bfsClosure.cpp Wed Oct 09 16:11:58 2019 +0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -97,7 +97,6 @@ 1.11 } 1.12 1.13 void BFSClosure::process() { 1.14 - 1.15 process_root_set(); 1.16 process_queue(); 1.17 } 1.18 @@ -136,7 +135,6 @@ 1.19 1.20 // if we are processinig initial root set, don't add to queue 1.21 if (_current_parent != NULL) { 1.22 - assert(_current_parent->distance_to_root() == _current_frontier_level, "invariant"); 1.23 _edge_queue->add(_current_parent, reference); 1.24 } 1.25 1.26 @@ -149,20 +147,8 @@ 1.27 void BFSClosure::add_chain(const oop* reference, const oop pointee) { 1.28 assert(pointee != NULL, "invariant"); 1.29 assert(NULL == pointee->mark(), "invariant"); 1.30 - 1.31 - const size_t length = _current_parent == NULL ? 1 : _current_parent->distance_to_root() + 2; 1.32 - ResourceMark rm; 1.33 - Edge* const chain = NEW_RESOURCE_ARRAY(Edge, length); 1.34 - size_t idx = 0; 1.35 - chain[idx++] = Edge(NULL, reference); 1.36 - // aggregate from breadth-first search 1.37 - const Edge* current = _current_parent; 1.38 - while (current != NULL) { 1.39 - chain[idx++] = Edge(NULL, current->reference()); 1.40 - current = current->parent(); 1.41 - } 1.42 - assert(length == idx, "invariant"); 1.43 - _edge_store->add_chain(chain, length); 1.44 + Edge leak_edge(_current_parent, reference); 1.45 + _edge_store->put_chain(&leak_edge, _current_parent == NULL ? 1 : _current_frontier_level + 2); 1.46 } 1.47 1.48 void BFSClosure::dfs_fallback() { 1.49 @@ -239,3 +225,10 @@ 1.50 closure_impl(UnifiedOop::encode(ref), pointee); 1.51 } 1.52 } 1.53 + 1.54 +void BFSClosure::do_root(const oop* ref) { 1.55 + assert(ref != NULL, "invariant"); 1.56 + if (!_edge_queue->is_full()) { 1.57 + _edge_queue->add(NULL, ref); 1.58 + } 1.59 +}