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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 if (threadState()->isMainThread()) | 602 if (threadState()->isMainThread()) |
603 ScriptForbiddenScope::enter(); | 603 ScriptForbiddenScope::enter(); |
604 | 604 |
605 Address result = lazySweepPages(allocationSize, gcInfoIndex); | 605 Address result = lazySweepPages(allocationSize, gcInfoIndex); |
606 | 606 |
607 if (threadState()->isMainThread()) | 607 if (threadState()->isMainThread()) |
608 ScriptForbiddenScope::exit(); | 608 ScriptForbiddenScope::exit(); |
609 return result; | 609 return result; |
610 } | 610 } |
611 | 611 |
612 void BaseHeap::sweepUnsweptPage() | |
613 { | |
614 BasePage* page = m_firstUnsweptPage; | |
615 if (page->isEmpty()) { | |
616 page->unlink(&m_firstUnsweptPage); | |
617 page->removeFromHeap(); | |
618 } else { | |
619 // Sweep a page and move the page from m_firstUnsweptPages to | |
620 // m_firstPages. | |
621 page->sweep(); | |
622 page->unlink(&m_firstUnsweptPage); | |
623 page->link(&m_firstPage); | |
624 page->markAsSwept(); | |
625 } | |
626 } | |
627 | |
628 bool BaseHeap::lazySweepWithDeadline(double deadlineSeconds) | |
629 { | |
630 RELEASE_ASSERT(threadState()->isSweepingInProgress()); | |
631 ASSERT(threadState()->sweepForbidden()); | |
632 | |
633 int pageCount = 1; | |
634 while (m_firstUnsweptPage) { | |
635 sweepUnsweptPage(); | |
636 // Check the deadline every time we sweep 10 page. | |
637 if (pageCount % 10 == 0) { | |
kouhei (in TOK)
2015/03/31 11:42:07
Why 10?
haraken
2015/03/31 12:46:58
I thought it might be heavy to call Platform::curr
Sami
2015/03/31 12:52:00
Might want to make this a named constant too. Also
rmcilroy
2015/03/31 13:01:30
+1
haraken
2015/03/31 13:07:45
Will fix.
| |
638 if (deadlineSeconds <= Platform::current()->monotonicallyIncreasingT ime()) { | |
639 return false; | |
640 } | |
641 } | |
642 pageCount++; | |
643 } | |
644 return true; | |
645 } | |
646 | |
612 void BaseHeap::completeSweep() | 647 void BaseHeap::completeSweep() |
613 { | 648 { |
614 RELEASE_ASSERT(threadState()->isSweepingInProgress()); | 649 RELEASE_ASSERT(threadState()->isSweepingInProgress()); |
615 ASSERT(threadState()->sweepForbidden()); | 650 ASSERT(threadState()->sweepForbidden()); |
616 | 651 |
617 if (threadState()->isMainThread()) | |
618 ScriptForbiddenScope::enter(); | |
619 | |
620 while (m_firstUnsweptPage) { | 652 while (m_firstUnsweptPage) { |
kouhei (in TOK)
2015/03/31 11:42:07
Nit: Unneeded {}
haraken
2015/03/31 12:46:58
Nit: The coding style guide is updated and it's up
| |
621 BasePage* page = m_firstUnsweptPage; | 653 sweepUnsweptPage(); |
622 if (page->isEmpty()) { | |
623 page->unlink(&m_firstUnsweptPage); | |
624 page->removeFromHeap(); | |
625 } else { | |
626 // Sweep a page and move the page from m_firstUnsweptPages to | |
627 // m_firstPages. | |
628 page->sweep(); | |
629 page->unlink(&m_firstUnsweptPage); | |
630 page->link(&m_firstPage); | |
631 page->markAsSwept(); | |
632 } | |
633 } | 654 } |
634 | |
635 if (threadState()->isMainThread()) | |
636 ScriptForbiddenScope::exit(); | |
637 } | 655 } |
638 | 656 |
639 NormalPageHeap::NormalPageHeap(ThreadState* state, int index) | 657 NormalPageHeap::NormalPageHeap(ThreadState* state, int index) |
640 : BaseHeap(state, index) | 658 : BaseHeap(state, index) |
641 , m_currentAllocationPoint(nullptr) | 659 , m_currentAllocationPoint(nullptr) |
642 , m_remainingAllocationSize(0) | 660 , m_remainingAllocationSize(0) |
643 , m_lastRemainingAllocationSize(0) | 661 , m_lastRemainingAllocationSize(0) |
644 , m_promptlyFreedSize(0) | 662 , m_promptlyFreedSize(0) |
645 #if ENABLE(GC_PROFILING) | 663 #if ENABLE(GC_PROFILING) |
646 , m_cumulativeAllocationSize(0) | 664 , m_cumulativeAllocationSize(0) |
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2845 size_t Heap::s_allocatedObjectSize = 0; | 2863 size_t Heap::s_allocatedObjectSize = 0; |
2846 size_t Heap::s_allocatedSpace = 0; | 2864 size_t Heap::s_allocatedSpace = 0; |
2847 size_t Heap::s_markedObjectSize = 0; | 2865 size_t Heap::s_markedObjectSize = 0; |
2848 | 2866 |
2849 size_t Heap::s_externallyAllocatedBytes = 0; | 2867 size_t Heap::s_externallyAllocatedBytes = 0; |
2850 size_t Heap::s_externallyAllocatedBytesAlive = 0; | 2868 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
2851 unsigned Heap::s_requestedUrgentGC = false; | 2869 unsigned Heap::s_requestedUrgentGC = false; |
2852 double Heap::s_markingTimeInLastGC = 0.0; | 2870 double Heap::s_markingTimeInLastGC = 0.0; |
2853 | 2871 |
2854 } // namespace blink | 2872 } // namespace blink |
OLD | NEW |