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 27 matching lines...) Expand all Loading... |
38 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
39 #include "platform/heap/Heap.h" | 39 #include "platform/heap/Heap.h" |
40 #include "platform/heap/MarkingVisitor.h" | 40 #include "platform/heap/MarkingVisitor.h" |
41 #include "platform/heap/SafePoint.h" | 41 #include "platform/heap/SafePoint.h" |
42 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
43 #include "public/platform/WebMemoryAllocatorDump.h" | 43 #include "public/platform/WebMemoryAllocatorDump.h" |
44 #include "public/platform/WebProcessMemoryDump.h" | 44 #include "public/platform/WebProcessMemoryDump.h" |
45 #include "public/platform/WebScheduler.h" | 45 #include "public/platform/WebScheduler.h" |
46 #include "public/platform/WebThread.h" | 46 #include "public/platform/WebThread.h" |
47 #include "public/platform/WebTraceLocation.h" | 47 #include "public/platform/WebTraceLocation.h" |
| 48 #include "wtf/CurrentTime.h" |
48 #include "wtf/DataLog.h" | 49 #include "wtf/DataLog.h" |
49 #include "wtf/Partitions.h" | 50 #include "wtf/Partitions.h" |
50 #include "wtf/ThreadingPrimitives.h" | 51 #include "wtf/ThreadingPrimitives.h" |
51 | 52 |
52 #if OS(WIN) | 53 #if OS(WIN) |
53 #include <stddef.h> | 54 #include <stddef.h> |
54 #include <windows.h> | 55 #include <windows.h> |
55 #include <winnt.h> | 56 #include <winnt.h> |
56 #endif | 57 #endif |
57 | 58 |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 722 |
722 void ThreadState::performIdleGC(double deadlineSeconds) | 723 void ThreadState::performIdleGC(double deadlineSeconds) |
723 { | 724 { |
724 ASSERT(checkThread()); | 725 ASSERT(checkThread()); |
725 ASSERT(isMainThread()); | 726 ASSERT(isMainThread()); |
726 ASSERT(Platform::current()->currentThread()->scheduler()); | 727 ASSERT(Platform::current()->currentThread()->scheduler()); |
727 | 728 |
728 if (gcState() != IdleGCScheduled) | 729 if (gcState() != IdleGCScheduled) |
729 return; | 730 return; |
730 | 731 |
731 double idleDeltaInSeconds = deadlineSeconds - Platform::current()->monotonic
allyIncreasingTimeSeconds(); | 732 double idleDeltaInSeconds = deadlineSeconds - monotonicallyIncreasingTime(); |
732 TRACE_EVENT2("blink_gc", "ThreadState::performIdleGC", "idleDeltaInSeconds",
idleDeltaInSeconds, "estimatedMarkingTime", Heap::estimatedMarkingTime()); | 733 TRACE_EVENT2("blink_gc", "ThreadState::performIdleGC", "idleDeltaInSeconds",
idleDeltaInSeconds, "estimatedMarkingTime", Heap::estimatedMarkingTime()); |
733 if (idleDeltaInSeconds <= Heap::estimatedMarkingTime() && !Platform::current
()->currentThread()->scheduler()->canExceedIdleDeadlineIfRequired()) { | 734 if (idleDeltaInSeconds <= Heap::estimatedMarkingTime() && !Platform::current
()->currentThread()->scheduler()->canExceedIdleDeadlineIfRequired()) { |
734 // If marking is estimated to take longer than the deadline and we can't | 735 // If marking is estimated to take longer than the deadline and we can't |
735 // exceed the deadline, then reschedule for the next idle period. | 736 // exceed the deadline, then reschedule for the next idle period. |
736 scheduleIdleGC(); | 737 scheduleIdleGC(); |
737 return; | 738 return; |
738 } | 739 } |
739 | 740 |
740 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep
, BlinkGC::IdleGC); | 741 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep
, BlinkGC::IdleGC); |
741 } | 742 } |
742 | 743 |
743 void ThreadState::performIdleLazySweep(double deadlineSeconds) | 744 void ThreadState::performIdleLazySweep(double deadlineSeconds) |
744 { | 745 { |
745 ASSERT(checkThread()); | 746 ASSERT(checkThread()); |
746 ASSERT(isMainThread()); | 747 ASSERT(isMainThread()); |
747 | 748 |
748 // If we are not in a sweeping phase, there is nothing to do here. | 749 // If we are not in a sweeping phase, there is nothing to do here. |
749 if (!isSweepingInProgress()) | 750 if (!isSweepingInProgress()) |
750 return; | 751 return; |
751 | 752 |
752 // This check is here to prevent performIdleLazySweep() from being called | 753 // This check is here to prevent performIdleLazySweep() from being called |
753 // recursively. I'm not sure if it can happen but it would be safer to have | 754 // recursively. I'm not sure if it can happen but it would be safer to have |
754 // the check just in case. | 755 // the check just in case. |
755 if (sweepForbidden()) | 756 if (sweepForbidden()) |
756 return; | 757 return; |
757 | 758 |
758 TRACE_EVENT1("blink_gc", "ThreadState::performIdleLazySweep", "idleDeltaInSe
conds", deadlineSeconds - Platform::current()->monotonicallyIncreasingTimeSecond
s()); | 759 TRACE_EVENT1("blink_gc", "ThreadState::performIdleLazySweep", "idleDeltaInSe
conds", deadlineSeconds - monotonicallyIncreasingTime()); |
759 | 760 |
760 bool sweepCompleted = true; | 761 bool sweepCompleted = true; |
761 SweepForbiddenScope scope(this); | 762 SweepForbiddenScope scope(this); |
762 { | 763 { |
763 double startTime = WTF::currentTimeMS(); | 764 double startTime = WTF::currentTimeMS(); |
764 ScriptForbiddenIfMainThreadScope scriptForbiddenScope; | 765 ScriptForbiddenIfMainThreadScope scriptForbiddenScope; |
765 | 766 |
766 for (int i = 0; i < BlinkGC::NumberOfHeaps; i++) { | 767 for (int i = 0; i < BlinkGC::NumberOfHeaps; i++) { |
767 // lazySweepWithDeadline() won't check the deadline until it sweeps | 768 // lazySweepWithDeadline() won't check the deadline until it sweeps |
768 // 10 pages. So we give a small slack for safety. | 769 // 10 pages. So we give a small slack for safety. |
769 double slack = 0.001; | 770 double slack = 0.001; |
770 double remainingBudget = deadlineSeconds - slack - Platform::current
()->monotonicallyIncreasingTimeSeconds(); | 771 double remainingBudget = deadlineSeconds - slack - monotonicallyIncr
easingTime(); |
771 if (remainingBudget <= 0 || !m_heaps[i]->lazySweepWithDeadline(deadl
ineSeconds)) { | 772 if (remainingBudget <= 0 || !m_heaps[i]->lazySweepWithDeadline(deadl
ineSeconds)) { |
772 // We couldn't finish the sweeping within the deadline. | 773 // We couldn't finish the sweeping within the deadline. |
773 // We request another idle task for the remaining sweeping. | 774 // We request another idle task for the remaining sweeping. |
774 scheduleIdleLazySweep(); | 775 scheduleIdleLazySweep(); |
775 sweepCompleted = false; | 776 sweepCompleted = false; |
776 break; | 777 break; |
777 } | 778 } |
778 } | 779 } |
779 | 780 |
780 accumulateSweepingTime(WTF::currentTimeMS() - startTime); | 781 accumulateSweepingTime(WTF::currentTimeMS() - startTime); |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 threadDump->addScalar("dead_count", "objects", totalDeadCount); | 1499 threadDump->addScalar("dead_count", "objects", totalDeadCount); |
1499 threadDump->addScalar("live_size", "bytes", totalLiveSize); | 1500 threadDump->addScalar("live_size", "bytes", totalLiveSize); |
1500 threadDump->addScalar("dead_size", "bytes", totalDeadSize); | 1501 threadDump->addScalar("dead_size", "bytes", totalDeadSize); |
1501 | 1502 |
1502 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); | 1503 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); |
1503 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); | 1504 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); |
1504 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); | 1505 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); |
1505 } | 1506 } |
1506 | 1507 |
1507 } // namespace blink | 1508 } // namespace blink |
OLD | NEW |