(original) (raw)

--- binaryTreeDictionary.cpp 2018-04-04 19:43:05.000000000 +0200 +++ compactibleFreeListSpace.cpp 2018-04-04 19:43:05.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, 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 @@ -23,24 +23,33 @@ */ #include "precompiled.hpp" -#include "gc/cms/allocationStats.hpp" +#include "gc/cms/cmsHeap.hpp" +#include "gc/cms/cmsLockVerifier.hpp" +#include "gc/cms/compactibleFreeListSpace.hpp" +#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp" +#include "gc/cms/concurrentMarkSweepThread.hpp" +#include "gc/shared/blockOffsetTable.inline.hpp" +#include "gc/shared/collectedHeap.inline.hpp" +#include "gc/shared/space.inline.hpp" #include "gc/shared/spaceDecorator.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" -#include "memory/binaryTreeDictionary.hpp" -#include "memory/freeList.hpp" -#include "memory/metachunk.hpp" +#include "memory/allocation.inline.hpp" +#include "memory/binaryTreeDictionary.inline.hpp" #include "memory/resourceArea.hpp" +#include "memory/universe.hpp" +#include "oops/access.inline.hpp" +#include "oops/compressedOops.inline.hpp" +#include "oops/oop.inline.hpp" #include "runtime/globals.hpp" -#include "utilities/macros.hpp" -#include "utilities/ostream.hpp" -#if INCLUDE_ALL_GCS -#include "gc/cms/adaptiveFreeList.hpp" -#include "gc/cms/freeChunk.hpp" -#endif // INCLUDE_ALL_GCS +#include "runtime/handles.inline.hpp" +#include "runtime/init.hpp" +#include "runtime/java.hpp" +#include "runtime/orderAccess.inline.hpp" +#include "runtime/vmThread.hpp" +#include "utilities/align.hpp" +#include "utilities/copy.hpp" - -#if INCLUDE_ALL_GCS // Specialize for AdaptiveFreeList which tries to avoid // splitting a chunk of a size that is under populated in favor of // an over populated size. The general get_better_list() just returns @@ -82,13 +91,7 @@ } return curTL; } -#endif // INCLUDE_ALL_GCS - -template -void BinaryTreeDictionary<chunk_t, freelist_t="">::dict_census_update(size_t size, bool split, bool birth){} -#if INCLUDE_ALL_GCS -template <> void AFLBinaryTreeDictionary::dict_census_update(size_t size, bool split, bool birth) { TreeList<freechunk, adaptivefreelist<freechunk=""> >* nd = find_list(size); if (nd) { @@ -116,17 +119,7 @@ // This is a birth associated with a LinAB. The chunk // for the LinAB is not in the dictionary. } -#endif // INCLUDE_ALL_GCS -template -bool BinaryTreeDictionary<chunk_t, freelist_t="">::coal_dict_over_populated(size_t size) { - // For the general type of freelists, encourage coalescing by - // returning true. - return true; -} - -#if INCLUDE_ALL_GCS -template <> bool AFLBinaryTreeDictionary::coal_dict_over_populated(size_t size) { if (FLSAlwaysCoalesceLarge) return true; @@ -135,12 +128,10 @@ return list_of_size == NULL || list_of_size->coal_desired() <= 0 || list_of_size->count() > list_of_size->coal_desired(); } -#endif // INCLUDE_ALL_GCS // For each list in the tree, calculate the desired, desired // coalesce, count before sweep, and surplus before sweep. -template -class BeginSweepClosure : public AscendTreeCensusClosure<chunk_t, freelist_t=""> { +class BeginSweepClosure : public AscendTreeCensusClosure<freechunk, adaptivefreelist<freechunk=""> > { double _percentage; float _inter_sweep_current; float _inter_sweep_estimate; @@ -155,61 +146,48 @@ _inter_sweep_estimate(inter_sweep_estimate), _intra_sweep_estimate(intra_sweep_estimate) { } - void do_list(FreeList* fl) {} - -#if INCLUDE_ALL_GCS - void do_list(AdaptiveFreeList* fl) { + void do_list(AdaptiveFreeList* fl) { double coalSurplusPercent = _percentage; fl->compute_desired(_inter_sweep_current, _inter_sweep_estimate, _intra_sweep_estimate); fl->set_coal_desired((ssize_t)((double)fl->desired() * coalSurplusPercent)); fl->set_before_sweep(fl->count()); fl->set_bfr_surp(fl->surplus()); } -#endif // INCLUDE_ALL_GCS }; -template -void BinaryTreeDictionary<chunk_t, freelist_t="">::begin_sweep_dict_census(double coalSurplusPercent, +void AFLBinaryTreeDictionary::begin_sweep_dict_census(double coalSurplusPercent, float inter_sweep_current, float inter_sweep_estimate, float intra_sweep_estimate) { - BeginSweepClosure<chunk_t, freelist_t=""> bsc(coalSurplusPercent, inter_sweep_current, - inter_sweep_estimate, - intra_sweep_estimate); + BeginSweepClosure bsc(coalSurplusPercent, inter_sweep_current, + inter_sweep_estimate, + intra_sweep_estimate); bsc.do_tree(root()); } // Calculate surpluses for the lists in the tree. -template -class setTreeSurplusClosure : public AscendTreeCensusClosure<chunk_t, freelist_t=""> { +class setTreeSurplusClosure : public AscendTreeCensusClosure<freechunk, adaptivefreelist<freechunk=""> > { double percentage; public: setTreeSurplusClosure(double v) { percentage = v; } - void do_list(FreeList* fl) {} -#if INCLUDE_ALL_GCS - void do_list(AdaptiveFreeList* fl) { + void do_list(AdaptiveFreeList* fl) { double splitSurplusPercent = percentage; fl->set_surplus(fl->count() - (ssize_t)((double)fl->desired() * splitSurplusPercent)); } -#endif // INCLUDE_ALL_GCS }; -template -void BinaryTreeDictionary<chunk_t, freelist_t="">::set_tree_surplus(double splitSurplusPercent) { - setTreeSurplusClosure<chunk_t, freelist_t=""> sts(splitSurplusPercent); +void AFLBinaryTreeDictionary::set_tree_surplus(double splitSurplusPercent) { + setTreeSurplusClosure sts(splitSurplusPercent); sts.do_tree(root()); } // Set hints for the lists in the tree. -template -class setTreeHintsClosure : public DescendTreeCensusClosure<chunk_t, freelist_t=""> { +class setTreeHintsClosure : public DescendTreeCensusClosure<freechunk, adaptivefreelist<freechunk=""> > { size_t hint; public: setTreeHintsClosure(size_t v) { hint = v; } - void do_list(FreeList* fl) {} -#if INCLUDE_ALL_GCS - void do_list(AdaptiveFreeList* fl) { + void do_list(AdaptiveFreeList* fl) { fl->set_hint(hint); assert(fl->hint() == 0 || fl->hint() > fl->size(), "Current hint is inconsistent"); @@ -217,40 +195,31 @@ hint = fl->size(); } } -#endif // INCLUDE_ALL_GCS }; -template -void BinaryTreeDictionary<chunk_t, freelist_t="">::set_tree_hints(void) { - setTreeHintsClosure<chunk_t, freelist_t=""> sth(0); +void AFLBinaryTreeDictionary::set_tree_hints(void) { + setTreeHintsClosure sth(0); sth.do_tree(root()); } // Save count before previous sweep and splits and coalesces. -template -class clearTreeCensusClosure : public AscendTreeCensusClosure<chunk_t, freelist_t=""> { - void do_list(FreeList* fl) {} - -#if INCLUDE_ALL_GCS - void do_list(AdaptiveFreeList* fl) { +class clearTreeCensusClosure : public AscendTreeCensusClosure<freechunk, adaptivefreelist<freechunk=""> > { + void do_list(AdaptiveFreeList* fl) { fl->set_prev_sweep(fl->count()); fl->set_coal_births(0); fl->set_coal_deaths(0); fl->set_split_births(0); fl->set_split_deaths(0); } -#endif // INCLUDE_ALL_GCS }; -template -void BinaryTreeDictionary<chunk_t, freelist_t="">::clear_tree_census(void) { - clearTreeCensusClosure<chunk_t, freelist_t=""> ctc; +void AFLBinaryTreeDictionary::clear_tree_census(void) { + clearTreeCensusClosure ctc; ctc.do_tree(root()); } // Do reporting and post sweep clean up. -template -void BinaryTreeDictionary<chunk_t, freelist_t="">::end_sweep_dict_census(double splitSurplusPercent) { +void AFLBinaryTreeDictionary::end_sweep_dict_census(double splitSurplusPercent) { // Does walking the tree 3 times hurt? set_tree_surplus(splitSurplusPercent); set_tree_hints(); @@ -262,57 +231,27 @@ clear_tree_census(); } -// Print summary statistics -template -void BinaryTreeDictionary<chunk_t, freelist_t="">::report_statistics(outputStream* st) const { - verify_par_locked(); - st->print_cr("Statistics for BinaryTreeDictionary:"); - st->print_cr("------------------------------------"); - size_t total_size = total_chunk_size(debug_only(NULL)); - size_t free_blocks = num_free_blocks(); - st->print_cr("Total Free Space: " SIZE_FORMAT, total_size); - st->print_cr("Max Chunk Size: " SIZE_FORMAT, max_chunk_size()); - st->print_cr("Number of Blocks: " SIZE_FORMAT, free_blocks); - if (free_blocks > 0) { - st->print_cr("Av. Block Size: " SIZE_FORMAT, total_size/free_blocks); - } - st->print_cr("Tree Height: " SIZE_FORMAT, tree_height()); -} - // Print census information - counts, births, deaths, etc. // for each list in the tree. Also print some summary // information. -template -class PrintTreeCensusClosure : public AscendTreeCensusClosure<chunk_t, freelist_t=""> { +class PrintTreeCensusClosure : public AscendTreeCensusClosure<freechunk, adaptivefreelist<freechunk=""> > { int _print_line; size_t _total_free; - FreeList_t _total; + AdaptiveFreeList _total; public: PrintTreeCensusClosure() { _print_line = 0; _total_free = 0; } - FreeList_t* total() { return &_total; } + AdaptiveFreeList* total() { return &_total; } size_t total_free() { return _total_free; } - void do_list(FreeList* fl) { - LogStreamHandle(Debug, gc, freelist, census) out; - if (++_print_line >= 40) { - FreeList_t::print_labels_on(&out, "size"); - _print_line = 0; - } - fl->print_on(&out); - _total_free += fl->count() * fl->size(); - total()->set_count(total()->count() + fl->count()); - } - -#if INCLUDE_ALL_GCS - void do_list(AdaptiveFreeList* fl) { + void do_list(AdaptiveFreeList* fl) { LogStreamHandle(Debug, gc, freelist, census) out; if (++_print_line >= 40) { - FreeList_t::print_labels_on(&out, "size"); + AdaptiveFreeList::print_labels_on(&out, "size"); _print_line = 0; } fl->print_on(&out); @@ -328,28 +267,13 @@ total()->set_split_births(total()->split_births() + fl->split_births()); total()->set_split_deaths(total()->split_deaths() + fl->split_deaths()); } -#endif // INCLUDE_ALL_GCS }; -template -void BinaryTreeDictionary<chunk_t, freelist_t="">::print_dict_census(outputStream* st) const { - - st->print("BinaryTree"); - FreeList_t::print_labels_on(st, "size"); - PrintTreeCensusClosure<chunk_t, freelist_t=""> ptc; - ptc.do_tree(root()); - - FreeList_t* total = ptc.total(); - FreeList_t::print_labels_on(st, " "); -} - -#if INCLUDE_ALL_GCS -template <> void AFLBinaryTreeDictionary::print_dict_census(outputStream* st) const { st->print_cr("BinaryTree"); AdaptiveFreeList::print_labels_on(st, "size"); - PrintTreeCensusClosure<freechunk, adaptivefreelist<freechunk=""> > ptc; + PrintTreeCensusClosure ptc; ptc.do_tree(root()); AdaptiveFreeList* total = ptc.total(); @@ -363,5 +287,4 @@ (double)(total->desired() - total->count()) /(total->desired() != 0 ? (double)total->desired() : 1.0)); } -#endif // INCLUDE_ALL_GCS</freechunk,></chunk_t,></chunk_t,></freechunk,></chunk_t,></chunk_t,></chunk_t,></chunk_t,></chunk_t,></freechunk,></chunk_t,></chunk_t,></chunk_t,></freechunk,></chunk_t,></chunk_t,></chunk_t,></freechunk,></chunk_t,></chunk_t,></chunk_t,></freechunk,></chunk_t,></chunk_t,></freechunk,></chunk_t,>