Print this page


Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp
          +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp
↓ open down ↓ 1827 lines elided ↑ open up ↑
1828 1828  // definition in specializedOopClosures.hpp).
1829 1829  SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(PROMOTED_OOPS_ITERATE_DEFN)
1830 1830  PROMOTED_OOPS_ITERATE_DEFN(OopsInGenClosure,_v)
1831 1831  
1832 1832  
1833 1833  void CompactibleFreeListSpace::object_iterate_since_last_GC(ObjectClosure* cl) {
1834 1834    // ugghh... how would one do this efficiently for a non-contiguous space?
1835 1835    guarantee(false, "NYI");
1836 1836  }
1837 1837  
1838      -bool CompactibleFreeListSpace::linearAllocationWouldFail() {
     1838 +bool CompactibleFreeListSpace::linearAllocationWouldFail() const {
1839 1839    return _smallLinearAllocBlock._word_size == 0;
1840 1840  }
1841 1841  
1842 1842  void CompactibleFreeListSpace::repairLinearAllocationBlocks() {
1843 1843    // Fix up linear allocation blocks to look like free blocks
1844 1844    repairLinearAllocBlock(&_smallLinearAllocBlock);
1845 1845  }
1846 1846  
1847 1847  void CompactibleFreeListSpace::repairLinearAllocBlock(LinearAllocBlock* blk) {
1848 1848    assert_locked();
↓ open down ↓ 50 lines elided ↑ open up ↑
1899 1899    } else {
1900 1900      fc = getChunkFromDictionary(blk->_refillSize);
1901 1901    }
1902 1902    if (fc != NULL) {
1903 1903      blk->_ptr  = (HeapWord*)fc;
1904 1904      blk->_word_size = fc->size();
1905 1905      fc->dontCoalesce();   // to prevent sweeper from sweeping us up
1906 1906    }
1907 1907  }
1908 1908  
     1909 +// Support for concurrent collection policy decisions.
     1910 +bool CompactibleFreeListSpace::should_concurrent_collect() const {
     1911 +  // In the future we might want to add in frgamentation stats --
     1912 +  // including erosion of the "mountain" into this decision as well.
     1913 +  return !adaptive_freelists() && linearAllocationWouldFail();
     1914 +}
     1915 +  
1909 1916  // Support for compaction
1910 1917  
1911 1918  void CompactibleFreeListSpace::prepare_for_compaction(CompactPoint* cp) {
1912 1919    SCAN_AND_FORWARD(cp,end,block_is_obj,block_size);
1913 1920    // prepare_for_compaction() uses the space between live objects
1914 1921    // so that later phase can skip dead space quickly.  So verification
1915 1922    // of the free lists doesn't work after.
1916 1923  }
1917 1924  
1918 1925  #define obj_size(q) adjustObjectSize(oop(q)->size())
↓ open down ↓ 87 lines elided ↑ open up ↑
2006 2013    for (i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
2007 2014      FreeList *fl = &_indexedFreeList[i];
2008 2015      fl->set_prevSweep(fl->count());
2009 2016      fl->set_coalBirths(0);
2010 2017      fl->set_coalDeaths(0);
2011 2018      fl->set_splitBirths(0);
2012 2019      fl->set_splitDeaths(0);
2013 2020    }
2014 2021  }
2015 2022  
2016      -void CompactibleFreeListSpace::endSweepFLCensus(int sweepCt) {
     2023 +void CompactibleFreeListSpace::endSweepFLCensus(size_t sweep_count) {
2017 2024    setFLSurplus();
2018 2025    setFLHints();
2019 2026    if (PrintGC && PrintFLSCensus > 0) {
2020      -    printFLCensus(sweepCt);
     2027 +    printFLCensus(sweep_count);
2021 2028    }
2022 2029    clearFLCensus();
2023 2030    assert_locked();
2024 2031    _dictionary->endSweepDictCensus(SplitSurplusPercent);
2025 2032  }
2026 2033  
2027 2034  bool CompactibleFreeListSpace::coalOverPopulated(size_t size) {
2028 2035    if (size < SmallForDictionary) {
2029 2036      FreeList *fl = &_indexedFreeList[size];
2030 2037      return (fl->coalDesired() < 0) ||
↓ open down ↓ 255 lines elided ↑ open up ↑
2286 2293      "else MIN_TREE_CHUNK_SIZE is wrong");
2287 2294    assert((IndexSetStride == 2 && IndexSetStart == 2) ||
2288 2295           (IndexSetStride == 1 && IndexSetStart == 1), "just checking");
2289 2296    assert((IndexSetStride != 2) || (MinChunkSize % 2 == 0),
2290 2297        "Some for-loops may be incorrectly initialized");
2291 2298    assert((IndexSetStride != 2) || (IndexSetSize % 2 == 1),
2292 2299        "For-loops that iterate over IndexSet with stride 2 may be wrong");
2293 2300  }
2294 2301  #endif
2295 2302  
2296      -void CompactibleFreeListSpace::printFLCensus(int sweepCt) const {
     2303 +void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
2297 2304    assert_lock_strong(&_freelistLock);
2298      -  ssize_t bfrSurp     = 0;
2299      -  ssize_t surplus     = 0;
2300      -  ssize_t desired     = 0;
2301      -  ssize_t prevSweep   = 0;
2302      -  ssize_t beforeSweep = 0;
2303      -  ssize_t count       = 0;
2304      -  ssize_t coalBirths  = 0;
2305      -  ssize_t coalDeaths  = 0;
2306      -  ssize_t splitBirths = 0;
2307      -  ssize_t splitDeaths = 0;
2308      -  gclog_or_tty->print("end sweep# %d\n", sweepCt);
2309      -  gclog_or_tty->print("%4s\t"    "%7s\t"      "%7s\t"      "%7s\t"      "%7s\t"
2310      -             "%7s\t"    "%7s\t"      "%7s\t"      "%7s\t"      "%7s\t"
2311      -             "%7s\t"    "\n",
2312      -             "size",    "bfrsurp",   "surplus",   "desired",   "prvSwep",
2313      -             "bfrSwep", "count",     "cBirths",   "cDeaths",   "sBirths",
2314      -             "sDeaths");
2315      -
     2305 +  FreeList total;
     2306 +  gclog_or_tty->print("end sweep# " SIZE_FORMAT "\n", sweep_count);
     2307 +  FreeList::print_labels_on(gclog_or_tty, "size");
2316 2308    size_t totalFree = 0;
2317 2309    for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
2318 2310      const FreeList *fl = &_indexedFreeList[i];
2319      -        totalFree += fl->count() * fl->size();
2320      -
2321      -    gclog_or_tty->print("%4d\t"          "%7d\t"             "%7d\t"        "%7d\t"
2322      -               "%7d\t"          "%7d\t"             "%7d\t"        "%7d\t"
2323      -               "%7d\t"          "%7d\t"             "%7d\t"        "\n",
2324      -               fl->size(),       fl->bfrSurp(),     fl->surplus(), fl->desired(),
2325      -               fl->prevSweep(),  fl->beforeSweep(), fl->count(),   fl->coalBirths(),
2326      -               fl->coalDeaths(), fl->splitBirths(), fl->splitDeaths());
2327      -    bfrSurp     += fl->bfrSurp();
2328      -    surplus     += fl->surplus();
2329      -    desired     += fl->desired();
2330      -    prevSweep   += fl->prevSweep();
2331      -    beforeSweep += fl->beforeSweep();
2332      -    count       += fl->count();
2333      -    coalBirths  += fl->coalBirths();
2334      -    coalDeaths  += fl->coalDeaths();
2335      -    splitBirths += fl->splitBirths();
2336      -    splitDeaths += fl->splitDeaths();
     2311 +    totalFree += fl->count() * fl->size();
     2312 +    if (i % (40*IndexSetStride) == 0) {
     2313 +      FreeList::print_labels_on(gclog_or_tty, "size");
     2314 +    }
     2315 +    fl->print_on(gclog_or_tty);
     2316 +    total.set_bfrSurp(    total.bfrSurp()     + fl->bfrSurp()    );
     2317 +    total.set_surplus(    total.surplus()     + fl->surplus()    );
     2318 +    total.set_desired(    total.desired()     + fl->desired()    );
     2319 +    total.set_prevSweep(  total.prevSweep()   + fl->prevSweep()  );
     2320 +    total.set_beforeSweep(total.beforeSweep() + fl->beforeSweep());
     2321 +    total.set_count(      total.count()       + fl->count()      );
     2322 +    total.set_coalBirths( total.coalBirths()  + fl->coalBirths() );
     2323 +    total.set_coalDeaths( total.coalDeaths()  + fl->coalDeaths() );
     2324 +    total.set_splitBirths(total.splitBirths() + fl->splitBirths());
     2325 +    total.set_splitDeaths(total.splitDeaths() + fl->splitDeaths());
2337 2326    }
2338      -  gclog_or_tty->print("%4s\t"
2339      -            "%7d\t"      "%7d\t"     "%7d\t"        "%7d\t"       "%7d\t"
2340      -            "%7d\t"      "%7d\t"     "%7d\t"        "%7d\t"       "%7d\t" "\n",
2341      -            "totl",
2342      -            bfrSurp,     surplus,     desired,     prevSweep,     beforeSweep,
2343      -            count,       coalBirths,  coalDeaths,  splitBirths,   splitDeaths);
2344      -  gclog_or_tty->print_cr("Total free in indexed lists %d words", totalFree);
     2327 +  total.print_on(gclog_or_tty, "TOTAL");
     2328 +  gclog_or_tty->print_cr("Total free in indexed lists "
     2329 +                         SIZE_FORMAT " words", totalFree);
2345 2330    gclog_or_tty->print("growth: %8.5f  deficit: %8.5f\n",
2346      -    (double)(splitBirths+coalBirths-splitDeaths-coalDeaths)/
2347      -            (prevSweep != 0 ? (double)prevSweep : 1.0),
2348      -    (double)(desired - count)/(desired != 0 ? (double)desired : 1.0));
     2331 +    (double)(total.splitBirths()+total.coalBirths()-total.splitDeaths()-total.coalDeaths())/
     2332 +            (total.prevSweep() != 0 ? (double)total.prevSweep() : 1.0),
     2333 +    (double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0));
2349 2334    _dictionary->printDictCensus();
2350 2335  }
2351 2336  
2352 2337  // Return the next displaced header, incrementing the pointer and
2353 2338  // recycling spool area as necessary.
2354 2339  markOop PromotionInfo::nextDisplacedHeader() {
2355 2340    assert(_spoolHead != NULL, "promotionInfo inconsistency");
2356 2341    assert(_spoolHead != _spoolTail || _firstIndex < _nextIndex,
2357 2342           "Empty spool space: no displaced header can be fetched");
2358 2343    assert(_spoolHead->bufferSize > _firstIndex, "Off by one error at head?");
↓ open down ↓ 487 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX