OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 : m_currentAllocationPoint(nullptr) | 541 : m_currentAllocationPoint(nullptr) |
542 , m_remainingAllocationSize(0) | 542 , m_remainingAllocationSize(0) |
543 , m_lastRemainingAllocationSize(0) | 543 , m_lastRemainingAllocationSize(0) |
544 , m_firstPage(nullptr) | 544 , m_firstPage(nullptr) |
545 , m_firstLargeObject(nullptr) | 545 , m_firstLargeObject(nullptr) |
546 , m_firstUnsweptPage(nullptr) | 546 , m_firstUnsweptPage(nullptr) |
547 , m_firstUnsweptLargeObject(nullptr) | 547 , m_firstUnsweptLargeObject(nullptr) |
548 , m_threadState(state) | 548 , m_threadState(state) |
549 , m_index(index) | 549 , m_index(index) |
550 , m_promptlyFreedSize(0) | 550 , m_promptlyFreedSize(0) |
551 #if ENABLE(GC_PROFILING) | |
552 , m_totalAllocationSize(0.0) | |
haraken
2015/02/04 07:30:00
Where is this used?
| |
553 , m_allocationCount(0) | |
haraken
2015/02/04 07:30:00
Ditto.
| |
554 , m_inlineAllocationCount(0) | |
haraken
2015/02/04 07:30:00
Ditto.
| |
555 , m_allocationPointSizeSum(0) | |
556 , m_setAllocationPointCount(0) | |
557 #endif | |
551 { | 558 { |
552 clearFreeLists(); | 559 clearFreeLists(); |
553 } | 560 } |
554 | 561 |
555 FreeList::FreeList() | 562 FreeList::FreeList() |
556 : m_biggestFreeListIndex(0) | 563 : m_biggestFreeListIndex(0) |
557 { | 564 { |
558 } | 565 } |
559 | 566 |
560 ThreadHeap::~ThreadHeap() | 567 ThreadHeap::~ThreadHeap() |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 void ThreadHeap::setAllocationPoint(Address point, size_t size) | 604 void ThreadHeap::setAllocationPoint(Address point, size_t size) |
598 { | 605 { |
599 #if ENABLE(ASSERT) | 606 #if ENABLE(ASSERT) |
600 if (point) { | 607 if (point) { |
601 ASSERT(size); | 608 ASSERT(size); |
602 BaseHeapPage* page = pageFromObject(point); | 609 BaseHeapPage* page = pageFromObject(point); |
603 ASSERT(!page->isLargeObject()); | 610 ASSERT(!page->isLargeObject()); |
604 ASSERT(size <= static_cast<HeapPage*>(page)->payloadSize()); | 611 ASSERT(size <= static_cast<HeapPage*>(page)->payloadSize()); |
605 } | 612 } |
606 #endif | 613 #endif |
614 #if ENABLE(GC_PROFILING) | |
615 m_allocationPointSizeSum += size; | |
616 ++m_setAllocationPointCount; | |
617 #endif | |
607 if (hasCurrentAllocationArea()) | 618 if (hasCurrentAllocationArea()) |
608 addToFreeList(currentAllocationPoint(), remainingAllocationSize()); | 619 addToFreeList(currentAllocationPoint(), remainingAllocationSize()); |
609 updateRemainingAllocationSize(); | 620 updateRemainingAllocationSize(); |
610 m_currentAllocationPoint = point; | 621 m_currentAllocationPoint = point; |
611 m_lastRemainingAllocationSize = m_remainingAllocationSize = size; | 622 m_lastRemainingAllocationSize = m_remainingAllocationSize = size; |
612 } | 623 } |
613 | 624 |
614 Address ThreadHeap::outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex) | 625 Address ThreadHeap::outOfLineAllocate(size_t allocationSize, size_t gcInfoIndex) |
615 { | 626 { |
616 ASSERT(allocationSize > remainingAllocationSize()); | 627 ASSERT(allocationSize > remainingAllocationSize()); |
617 ASSERT(allocationSize >= allocationGranularity); | 628 ASSERT(allocationSize >= allocationGranularity); |
618 | 629 |
630 #if ENABLE(GC_PROFILING) | |
631 m_threadState->snapshotFreeListIfNecessary(); | |
632 #endif | |
633 | |
619 // 1. If this allocation is big enough, allocate a large object. | 634 // 1. If this allocation is big enough, allocate a large object. |
620 if (allocationSize >= largeObjectSizeThreshold) | 635 if (allocationSize >= largeObjectSizeThreshold) |
621 return allocateLargeObject(allocationSize, gcInfoIndex); | 636 return allocateLargeObject(allocationSize, gcInfoIndex); |
622 | 637 |
623 // 2. Check if we should trigger a GC. | 638 // 2. Check if we should trigger a GC. |
624 updateRemainingAllocationSize(); | 639 updateRemainingAllocationSize(); |
625 threadState()->scheduleGCOrForceConservativeGCIfNeeded(); | 640 threadState()->scheduleGCOrForceConservativeGCIfNeeded(); |
626 | 641 |
627 // 3. Try to allocate from a free list. | 642 // 3. Try to allocate from a free list. |
628 Address result = allocateFromFreeList(allocationSize, gcInfoIndex); | 643 Address result = allocateFromFreeList(allocationSize, gcInfoIndex); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 m_firstUnsweptLargeObject = nullptr; | 1501 m_firstUnsweptLargeObject = nullptr; |
1487 } | 1502 } |
1488 ASSERT(!m_firstUnsweptLargeObject); | 1503 ASSERT(!m_firstUnsweptLargeObject); |
1489 } | 1504 } |
1490 | 1505 |
1491 void ThreadHeap::clearFreeLists() | 1506 void ThreadHeap::clearFreeLists() |
1492 { | 1507 { |
1493 m_freeList.clear(); | 1508 m_freeList.clear(); |
1494 } | 1509 } |
1495 | 1510 |
1511 #if ENABLE(GC_PROFILING) | |
1512 void ThreadHeap::snapshotFreeList(TracedValue& json) | |
1513 { | |
1514 json.setDouble("totalAllocationSize", m_totalAllocationSize); | |
keishi
2015/02/04 06:58:26
nit: I think this could be renamed to cummulativeA
Yuta Kitamura
2015/02/04 09:45:42
Fixed. Can you fix your dashboard code, too?
keishi
2015/02/04 11:05:39
Done.
| |
1515 json.setDouble("inlineAllocationRate", static_cast<double>(m_inlineAllocatio nCount) / m_allocationCount); | |
1516 json.setInteger("inlineAllocationCount", m_inlineAllocationCount); | |
1517 json.setInteger("allocationCount", m_allocationCount); | |
1518 if (m_setAllocationPointCount > 0) | |
1519 json.setDouble("averageAllocationPointSize", static_cast<double>(m_alloc ationPointSizeSum) / m_setAllocationPointCount); | |
keishi
2015/02/04 06:58:26
averageAllocationPointSize hasn't been a useful me
haraken
2015/02/04 07:30:00
Agreed. Also I'm not sure how helpful m_setAllocat
Yuta Kitamura
2015/02/04 09:45:42
Done, m_allocationPointSizeSum and m_setAllocation
| |
1520 m_allocationPointSizeSum = 0; | |
1521 m_setAllocationPointCount = 0; | |
1522 size_t pageCount = 0; | |
1523 size_t totalPageSize = 0; | |
1524 for (HeapPage* page = m_firstPage; page; page = page->next()) { | |
1525 ++pageCount; | |
1526 totalPageSize += page->payloadSize(); | |
1527 } | |
1528 json.setInteger("pageCount", pageCount); | |
1529 json.setInteger("totalPageSize", totalPageSize); | |
1530 size_t bucketSizes[blinkPageSizeLog2]; | |
1531 size_t bucketTotalSizes[blinkPageSizeLog2]; | |
keishi
2015/02/04 06:58:26
I'm sorry. bucketSizes and bucketTotalSizes were h
Yuta Kitamura
2015/02/04 09:45:42
Fixed, can you take another look at this version?
keishi
2015/02/04 11:05:39
Thanks, this is much better. Done.
| |
1532 size_t freeSize; | |
1533 m_freeList.countBucketSizes(bucketSizes, bucketTotalSizes, freeSize); | |
1534 json.setInteger("freeSize", freeSize); | |
1535 | |
1536 json.beginArray("bucketSizes"); | |
1537 for (size_t i = 0; i < blinkPageSizeLog2; ++i) | |
1538 json.pushInteger(bucketSizes[i]); | |
1539 json.endArray(); | |
1540 | |
1541 json.beginArray("bucketTotalSizes"); | |
1542 for (size_t i = 0; i < blinkPageSizeLog2; ++i) | |
1543 json.pushInteger(bucketTotalSizes[i]); | |
1544 json.endArray(); | |
1545 } | |
1546 #endif | |
1547 | |
1496 void FreeList::clear() | 1548 void FreeList::clear() |
1497 { | 1549 { |
1498 m_biggestFreeListIndex = 0; | 1550 m_biggestFreeListIndex = 0; |
1499 for (size_t i = 0; i < blinkPageSizeLog2; ++i) | 1551 for (size_t i = 0; i < blinkPageSizeLog2; ++i) |
1500 m_freeLists[i] = nullptr; | 1552 m_freeLists[i] = nullptr; |
1501 } | 1553 } |
1502 | 1554 |
1503 int FreeList::bucketIndexForSize(size_t size) | 1555 int FreeList::bucketIndexForSize(size_t size) |
1504 { | 1556 { |
1505 ASSERT(size > 0); | 1557 ASSERT(size > 0); |
1506 int index = -1; | 1558 int index = -1; |
1507 while (size) { | 1559 while (size) { |
1508 size >>= 1; | 1560 size >>= 1; |
1509 index++; | 1561 index++; |
1510 } | 1562 } |
1511 return index; | 1563 return index; |
1512 } | 1564 } |
1513 | 1565 |
1566 #if ENABLE(GC_PROFILING) | |
1567 void FreeList::countBucketSizes(size_t sizes[], size_t totalSizes[], size_t& fre eSize) const | |
1568 { | |
1569 freeSize = 0; | |
1570 for (size_t i = 0; i < blinkPageSizeLog2; i++) { | |
1571 sizes[i] = 0; | |
1572 totalSizes[i] = 0; | |
1573 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) { | |
1574 ++sizes[i]; | |
1575 freeSize += entry->size(); | |
1576 totalSizes[i] += entry->size(); | |
1577 } | |
1578 } | |
1579 } | |
1580 #endif | |
1581 | |
1514 HeapPage::HeapPage(PageMemory* storage, ThreadHeap* heap) | 1582 HeapPage::HeapPage(PageMemory* storage, ThreadHeap* heap) |
1515 : BaseHeapPage(storage, heap) | 1583 : BaseHeapPage(storage, heap) |
1516 , m_next(nullptr) | 1584 , m_next(nullptr) |
1517 { | 1585 { |
1518 m_objectStartBitMapComputed = false; | 1586 m_objectStartBitMapComputed = false; |
1519 ASSERT(isPageHeaderAddress(reinterpret_cast<Address>(this))); | 1587 ASSERT(isPageHeaderAddress(reinterpret_cast<Address>(this))); |
1520 } | 1588 } |
1521 | 1589 |
1522 size_t HeapPage::objectPayloadSizeForTesting() | 1590 size_t HeapPage::objectPayloadSizeForTesting() |
1523 { | 1591 { |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2714 bool Heap::s_shutdownCalled = false; | 2782 bool Heap::s_shutdownCalled = false; |
2715 bool Heap::s_lastGCWasConservative = false; | 2783 bool Heap::s_lastGCWasConservative = false; |
2716 FreePagePool* Heap::s_freePagePool; | 2784 FreePagePool* Heap::s_freePagePool; |
2717 OrphanedPagePool* Heap::s_orphanedPagePool; | 2785 OrphanedPagePool* Heap::s_orphanedPagePool; |
2718 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2786 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2719 size_t Heap::s_allocatedObjectSize = 0; | 2787 size_t Heap::s_allocatedObjectSize = 0; |
2720 size_t Heap::s_allocatedSpace = 0; | 2788 size_t Heap::s_allocatedSpace = 0; |
2721 size_t Heap::s_markedObjectSize = 0; | 2789 size_t Heap::s_markedObjectSize = 0; |
2722 | 2790 |
2723 } // namespace blink | 2791 } // namespace blink |
OLD | NEW |