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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 744 } |
745 | 745 |
746 void ThreadState::performIdleGC(double deadlineSeconds) | 746 void ThreadState::performIdleGC(double deadlineSeconds) |
747 { | 747 { |
748 ASSERT(checkThread()); | 748 ASSERT(checkThread()); |
749 ASSERT(isMainThread()); | 749 ASSERT(isMainThread()); |
750 | 750 |
751 if (gcState() != IdleGCScheduled) | 751 if (gcState() != IdleGCScheduled) |
752 return; | 752 return; |
753 | 753 |
754 double idleDeltaInSeconds = deadlineSeconds - Platform::current()->monotonic
allyIncreasingTime(); | 754 double idleDeltaInSeconds = deadlineSeconds - Platform::current()->monotonic
allyIncreasingTimeSeconds(); |
755 TRACE_EVENT2("blink_gc", "ThreadState::performIdleGC", "idleDeltaInSeconds",
idleDeltaInSeconds, "estimatedMarkingTime", Heap::estimatedMarkingTime()); | 755 TRACE_EVENT2("blink_gc", "ThreadState::performIdleGC", "idleDeltaInSeconds",
idleDeltaInSeconds, "estimatedMarkingTime", Heap::estimatedMarkingTime()); |
756 if (idleDeltaInSeconds <= Heap::estimatedMarkingTime() && !Platform::current
()->currentThread()->scheduler()->canExceedIdleDeadlineIfRequired()) { | 756 if (idleDeltaInSeconds <= Heap::estimatedMarkingTime() && !Platform::current
()->currentThread()->scheduler()->canExceedIdleDeadlineIfRequired()) { |
757 // If marking is estimated to take longer than the deadline and we can't | 757 // If marking is estimated to take longer than the deadline and we can't |
758 // exceed the deadline, then reschedule for the next idle period. | 758 // exceed the deadline, then reschedule for the next idle period. |
759 scheduleIdleGC(); | 759 scheduleIdleGC(); |
760 return; | 760 return; |
761 } | 761 } |
762 | 762 |
763 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep
, BlinkGC::IdleGC); | 763 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep
, BlinkGC::IdleGC); |
764 } | 764 } |
765 | 765 |
766 void ThreadState::performIdleLazySweep(double deadlineSeconds) | 766 void ThreadState::performIdleLazySweep(double deadlineSeconds) |
767 { | 767 { |
768 ASSERT(checkThread()); | 768 ASSERT(checkThread()); |
769 ASSERT(isMainThread()); | 769 ASSERT(isMainThread()); |
770 | 770 |
771 // If we are not in a sweeping phase, there is nothing to do here. | 771 // If we are not in a sweeping phase, there is nothing to do here. |
772 if (!isSweepingInProgress()) | 772 if (!isSweepingInProgress()) |
773 return; | 773 return; |
774 | 774 |
775 // This check is here to prevent performIdleLazySweep() from being called | 775 // This check is here to prevent performIdleLazySweep() from being called |
776 // recursively. I'm not sure if it can happen but it would be safer to have | 776 // recursively. I'm not sure if it can happen but it would be safer to have |
777 // the check just in case. | 777 // the check just in case. |
778 if (sweepForbidden()) | 778 if (sweepForbidden()) |
779 return; | 779 return; |
780 | 780 |
781 TRACE_EVENT1("blink_gc", "ThreadState::performIdleLazySweep", "idleDeltaInSe
conds", deadlineSeconds - Platform::current()->monotonicallyIncreasingTime()); | 781 TRACE_EVENT1("blink_gc", "ThreadState::performIdleLazySweep", "idleDeltaInSe
conds", deadlineSeconds - Platform::current()->monotonicallyIncreasingTimeSecond
s()); |
782 | 782 |
783 bool sweepCompleted = true; | 783 bool sweepCompleted = true; |
784 SweepForbiddenScope scope(this); | 784 SweepForbiddenScope scope(this); |
785 { | 785 { |
786 double startTime = WTF::currentTimeMS(); | 786 double startTime = WTF::currentTimeMS(); |
787 if (isMainThread()) | 787 if (isMainThread()) |
788 ScriptForbiddenScope::enter(); | 788 ScriptForbiddenScope::enter(); |
789 | 789 |
790 for (int i = 0; i < BlinkGC::NumberOfHeaps; i++) { | 790 for (int i = 0; i < BlinkGC::NumberOfHeaps; i++) { |
791 // lazySweepWithDeadline() won't check the deadline until it sweeps | 791 // lazySweepWithDeadline() won't check the deadline until it sweeps |
792 // 10 pages. So we give a small slack for safety. | 792 // 10 pages. So we give a small slack for safety. |
793 double slack = 0.001; | 793 double slack = 0.001; |
794 double remainingBudget = deadlineSeconds - slack - Platform::current
()->monotonicallyIncreasingTime(); | 794 double remainingBudget = deadlineSeconds - slack - Platform::current
()->monotonicallyIncreasingTimeSeconds(); |
795 if (remainingBudget <= 0 || !m_heaps[i]->lazySweepWithDeadline(deadl
ineSeconds)) { | 795 if (remainingBudget <= 0 || !m_heaps[i]->lazySweepWithDeadline(deadl
ineSeconds)) { |
796 // We couldn't finish the sweeping within the deadline. | 796 // We couldn't finish the sweeping within the deadline. |
797 // We request another idle task for the remaining sweeping. | 797 // We request another idle task for the remaining sweeping. |
798 scheduleIdleLazySweep(); | 798 scheduleIdleLazySweep(); |
799 sweepCompleted = false; | 799 sweepCompleted = false; |
800 break; | 800 break; |
801 } | 801 } |
802 } | 802 } |
803 | 803 |
804 if (isMainThread()) | 804 if (isMainThread()) |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 threadDump->addScalar("dead_count", "objects", totalDeadCount); | 1483 threadDump->addScalar("dead_count", "objects", totalDeadCount); |
1484 threadDump->addScalar("live_size", "bytes", totalLiveSize); | 1484 threadDump->addScalar("live_size", "bytes", totalLiveSize); |
1485 threadDump->addScalar("dead_size", "bytes", totalDeadSize); | 1485 threadDump->addScalar("dead_size", "bytes", totalDeadSize); |
1486 | 1486 |
1487 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); | 1487 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); |
1488 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); | 1488 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); |
1489 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); | 1489 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); |
1490 } | 1490 } |
1491 | 1491 |
1492 } // namespace blink | 1492 } // namespace blink |
OLD | NEW |