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 // It might be heavy to call Platform::current()->monotonicallyIncreasin gTime() | |
637 // per page (i.e., 128 KB sweep or one LargeObject sweep), so we check | |
638 // the deadline per 10 pages. | |
639 if (pageCount % 10 == 0) { | |
640 if (deadlineSeconds <= Platform::current()->monotonicallyIncreasingT ime()) { | |
rmcilroy
2015/03/31 13:01:30
Could we add some slack here (e.g., deadlineSecond
haraken
2015/03/31 13:07:45
That is a hard question to answer since the time t
rmcilroy
2015/03/31 13:19:26
Right I thought this might be the case.
| |
641 return false; | |
642 } | |
643 } | |
644 pageCount++; | |
645 } | |
646 return true; | |
647 } | |
648 | |
612 void BaseHeap::completeSweep() | 649 void BaseHeap::completeSweep() |
613 { | 650 { |
614 RELEASE_ASSERT(threadState()->isSweepingInProgress()); | 651 RELEASE_ASSERT(threadState()->isSweepingInProgress()); |
615 ASSERT(threadState()->sweepForbidden()); | 652 ASSERT(threadState()->sweepForbidden()); |
616 | 653 |
617 if (threadState()->isMainThread()) | |
618 ScriptForbiddenScope::enter(); | |
619 | |
620 while (m_firstUnsweptPage) { | 654 while (m_firstUnsweptPage) { |
621 BasePage* page = m_firstUnsweptPage; | 655 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 } | 656 } |
634 | |
635 if (threadState()->isMainThread()) | |
636 ScriptForbiddenScope::exit(); | |
637 } | 657 } |
638 | 658 |
639 NormalPageHeap::NormalPageHeap(ThreadState* state, int index) | 659 NormalPageHeap::NormalPageHeap(ThreadState* state, int index) |
640 : BaseHeap(state, index) | 660 : BaseHeap(state, index) |
641 , m_currentAllocationPoint(nullptr) | 661 , m_currentAllocationPoint(nullptr) |
642 , m_remainingAllocationSize(0) | 662 , m_remainingAllocationSize(0) |
643 , m_lastRemainingAllocationSize(0) | 663 , m_lastRemainingAllocationSize(0) |
644 , m_promptlyFreedSize(0) | 664 , m_promptlyFreedSize(0) |
645 #if ENABLE(GC_PROFILING) | 665 #if ENABLE(GC_PROFILING) |
646 , m_cumulativeAllocationSize(0) | 666 , m_cumulativeAllocationSize(0) |
(...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2848 size_t Heap::s_allocatedObjectSize = 0; | 2868 size_t Heap::s_allocatedObjectSize = 0; |
2849 size_t Heap::s_allocatedSpace = 0; | 2869 size_t Heap::s_allocatedSpace = 0; |
2850 size_t Heap::s_markedObjectSize = 0; | 2870 size_t Heap::s_markedObjectSize = 0; |
2851 | 2871 |
2852 size_t Heap::s_externallyAllocatedBytes = 0; | 2872 size_t Heap::s_externallyAllocatedBytes = 0; |
2853 size_t Heap::s_externallyAllocatedBytesAlive = 0; | 2873 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
2854 unsigned Heap::s_requestedUrgentGC = false; | 2874 unsigned Heap::s_requestedUrgentGC = false; |
2855 double Heap::s_markingTimeInLastGC = 0.0; | 2875 double Heap::s_markingTimeInLastGC = 0.0; |
2856 | 2876 |
2857 } // namespace blink | 2877 } // namespace blink |
OLD | NEW |