1522 bool Metadebug::test_metadata_failure() {
1523 if (MetadataAllocationFailALot &&
1524 Threads::is_vm_complete()) {
1525 if (_allocation_fail_alot_count > 0) {
1526 _allocation_fail_alot_count--;
1527 } else {
1528 if (TraceMetadataChunkAllocation && Verbose) {
1529 gclog_or_tty->print_cr("Metadata allocation failing for "
1530 "MetadataAllocationFailALot");
1531 }
1532 init_allocation_fail_alot_count();
1533 return true;
1534 }
1535 }
1536 return false;
1537 }
1538 #endif
1539
1540 // ChunkManager methods
1541
1542 // Verification of _free_chunks_total and _free_chunks_count does not
1543 // work with the CMS collector because its use of additional locks
1544 // complicate the mutex deadlock detection but it can still be useful
1545 // for detecting errors in the chunk accounting with other collectors.
1546
1547 size_t ChunkManager::free_chunks_total() {
1548 #ifdef ASSERT
1549 if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) {
1550 MutexLockerEx cl(SpaceManager::expand_lock(),
1551 Mutex::_no_safepoint_check_flag);
1552 slow_locked_verify_free_chunks_total();
1553 }
1554 #endif
1555 return _free_chunks_total;
1556 }
1557
1558 size_t ChunkManager::free_chunks_total_in_bytes() {
1559 return free_chunks_total() * BytesPerWord;
1560 }
1561
1562 size_t ChunkManager::free_chunks_count() {
1563 #ifdef ASSERT
1564 if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) {
1565 MutexLockerEx cl(SpaceManager::expand_lock(),
1566 Mutex::_no_safepoint_check_flag);
1567 // This lock is only needed in debug because the verification
1568 // of the _free_chunks_totals walks the list of free chunks
1569 slow_locked_verify_free_chunks_count();
1570 }
1571 #endif
1572 return _free_chunks_count;
1573 }
1574
|
1522 bool Metadebug::test_metadata_failure() {
1523 if (MetadataAllocationFailALot &&
1524 Threads::is_vm_complete()) {
1525 if (_allocation_fail_alot_count > 0) {
1526 _allocation_fail_alot_count--;
1527 } else {
1528 if (TraceMetadataChunkAllocation && Verbose) {
1529 gclog_or_tty->print_cr("Metadata allocation failing for "
1530 "MetadataAllocationFailALot");
1531 }
1532 init_allocation_fail_alot_count();
1533 return true;
1534 }
1535 }
1536 return false;
1537 }
1538 #endif
1539
1540 // ChunkManager methods
1541
1542 size_t ChunkManager::free_chunks_total() {
1543 return _free_chunks_total;
1544 }
1545
1546 size_t ChunkManager::free_chunks_total_in_bytes() {
1547 return free_chunks_total() * BytesPerWord;
1548 }
1549
1550 size_t ChunkManager::free_chunks_count() {
1551 #ifdef ASSERT
1552 if (!UseConcMarkSweepGC && !SpaceManager::expand_lock()->is_locked()) {
1553 MutexLockerEx cl(SpaceManager::expand_lock(),
1554 Mutex::_no_safepoint_check_flag);
1555 // This lock is only needed in debug because the verification
1556 // of the _free_chunks_totals walks the list of free chunks
1557 slow_locked_verify_free_chunks_count();
1558 }
1559 #endif
1560 return _free_chunks_count;
1561 }
1562
|