| 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 26 matching lines...) Expand all Loading... |
| 37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
| 38 #include "platform/heap/Heap.h" | 38 #include "platform/heap/Heap.h" |
| 39 #include "platform/heap/MarkingVisitor.h" | 39 #include "platform/heap/MarkingVisitor.h" |
| 40 #include "platform/heap/SafePoint.h" | 40 #include "platform/heap/SafePoint.h" |
| 41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebMemoryAllocatorDump.h" | 42 #include "public/platform/WebMemoryAllocatorDump.h" |
| 43 #include "public/platform/WebProcessMemoryDump.h" | 43 #include "public/platform/WebProcessMemoryDump.h" |
| 44 #include "public/platform/WebScheduler.h" | 44 #include "public/platform/WebScheduler.h" |
| 45 #include "public/platform/WebThread.h" | 45 #include "public/platform/WebThread.h" |
| 46 #include "public/platform/WebTraceLocation.h" | 46 #include "public/platform/WebTraceLocation.h" |
| 47 #include "wtf/CurrentTime.h" |
| 47 #include "wtf/DataLog.h" | 48 #include "wtf/DataLog.h" |
| 48 #include "wtf/Partitions.h" | 49 #include "wtf/Partitions.h" |
| 49 #include "wtf/ThreadingPrimitives.h" | 50 #include "wtf/ThreadingPrimitives.h" |
| 50 | 51 |
| 51 #if OS(WIN) | 52 #if OS(WIN) |
| 52 #include <stddef.h> | 53 #include <stddef.h> |
| 53 #include <windows.h> | 54 #include <windows.h> |
| 54 #include <winnt.h> | 55 #include <winnt.h> |
| 55 #elif defined(__GLIBC__) | 56 #elif defined(__GLIBC__) |
| 56 extern "C" void* __libc_stack_end; // NOLINT | 57 extern "C" void* __libc_stack_end; // NOLINT |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 746 |
| 746 void ThreadState::performIdleGC(double deadlineSeconds) | 747 void ThreadState::performIdleGC(double deadlineSeconds) |
| 747 { | 748 { |
| 748 ASSERT(checkThread()); | 749 ASSERT(checkThread()); |
| 749 ASSERT(isMainThread()); | 750 ASSERT(isMainThread()); |
| 750 ASSERT(Platform::current()->currentThread()->scheduler()); | 751 ASSERT(Platform::current()->currentThread()->scheduler()); |
| 751 | 752 |
| 752 if (gcState() != IdleGCScheduled) | 753 if (gcState() != IdleGCScheduled) |
| 753 return; | 754 return; |
| 754 | 755 |
| 755 double idleDeltaInSeconds = deadlineSeconds - Platform::current()->monotonic
allyIncreasingTimeSeconds(); | 756 double idleDeltaInSeconds = deadlineSeconds - monotonicallyIncreasingTime(); |
| 756 TRACE_EVENT2("blink_gc", "ThreadState::performIdleGC", "idleDeltaInSeconds",
idleDeltaInSeconds, "estimatedMarkingTime", Heap::estimatedMarkingTime()); | 757 TRACE_EVENT2("blink_gc", "ThreadState::performIdleGC", "idleDeltaInSeconds",
idleDeltaInSeconds, "estimatedMarkingTime", Heap::estimatedMarkingTime()); |
| 757 if (idleDeltaInSeconds <= Heap::estimatedMarkingTime() && !Platform::current
()->currentThread()->scheduler()->canExceedIdleDeadlineIfRequired()) { | 758 if (idleDeltaInSeconds <= Heap::estimatedMarkingTime() && !Platform::current
()->currentThread()->scheduler()->canExceedIdleDeadlineIfRequired()) { |
| 758 // If marking is estimated to take longer than the deadline and we can't | 759 // If marking is estimated to take longer than the deadline and we can't |
| 759 // exceed the deadline, then reschedule for the next idle period. | 760 // exceed the deadline, then reschedule for the next idle period. |
| 760 scheduleIdleGC(); | 761 scheduleIdleGC(); |
| 761 return; | 762 return; |
| 762 } | 763 } |
| 763 | 764 |
| 764 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep
, BlinkGC::IdleGC); | 765 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep
, BlinkGC::IdleGC); |
| 765 } | 766 } |
| 766 | 767 |
| 767 void ThreadState::performIdleLazySweep(double deadlineSeconds) | 768 void ThreadState::performIdleLazySweep(double deadlineSeconds) |
| 768 { | 769 { |
| 769 ASSERT(checkThread()); | 770 ASSERT(checkThread()); |
| 770 ASSERT(isMainThread()); | 771 ASSERT(isMainThread()); |
| 771 | 772 |
| 772 // If we are not in a sweeping phase, there is nothing to do here. | 773 // If we are not in a sweeping phase, there is nothing to do here. |
| 773 if (!isSweepingInProgress()) | 774 if (!isSweepingInProgress()) |
| 774 return; | 775 return; |
| 775 | 776 |
| 776 // This check is here to prevent performIdleLazySweep() from being called | 777 // This check is here to prevent performIdleLazySweep() from being called |
| 777 // recursively. I'm not sure if it can happen but it would be safer to have | 778 // recursively. I'm not sure if it can happen but it would be safer to have |
| 778 // the check just in case. | 779 // the check just in case. |
| 779 if (sweepForbidden()) | 780 if (sweepForbidden()) |
| 780 return; | 781 return; |
| 781 | 782 |
| 782 TRACE_EVENT1("blink_gc", "ThreadState::performIdleLazySweep", "idleDeltaInSe
conds", deadlineSeconds - Platform::current()->monotonicallyIncreasingTimeSecond
s()); | 783 TRACE_EVENT1("blink_gc", "ThreadState::performIdleLazySweep", "idleDeltaInSe
conds", deadlineSeconds - monotonicallyIncreasingTime()); |
| 783 | 784 |
| 784 bool sweepCompleted = true; | 785 bool sweepCompleted = true; |
| 785 SweepForbiddenScope scope(this); | 786 SweepForbiddenScope scope(this); |
| 786 { | 787 { |
| 787 double startTime = WTF::currentTimeMS(); | 788 double startTime = WTF::currentTimeMS(); |
| 788 ScriptForbiddenIfMainThreadScope scriptForbiddenScope; | 789 ScriptForbiddenIfMainThreadScope scriptForbiddenScope; |
| 789 | 790 |
| 790 for (int i = 0; i < BlinkGC::NumberOfHeaps; i++) { | 791 for (int i = 0; i < BlinkGC::NumberOfHeaps; i++) { |
| 791 // lazySweepWithDeadline() won't check the deadline until it sweeps | 792 // lazySweepWithDeadline() won't check the deadline until it sweeps |
| 792 // 10 pages. So we give a small slack for safety. | 793 // 10 pages. So we give a small slack for safety. |
| 793 double slack = 0.001; | 794 double slack = 0.001; |
| 794 double remainingBudget = deadlineSeconds - slack - Platform::current
()->monotonicallyIncreasingTimeSeconds(); | 795 double remainingBudget = deadlineSeconds - slack - monotonicallyIncr
easingTime(); |
| 795 if (remainingBudget <= 0 || !m_heaps[i]->lazySweepWithDeadline(deadl
ineSeconds)) { | 796 if (remainingBudget <= 0 || !m_heaps[i]->lazySweepWithDeadline(deadl
ineSeconds)) { |
| 796 // We couldn't finish the sweeping within the deadline. | 797 // We couldn't finish the sweeping within the deadline. |
| 797 // We request another idle task for the remaining sweeping. | 798 // We request another idle task for the remaining sweeping. |
| 798 scheduleIdleLazySweep(); | 799 scheduleIdleLazySweep(); |
| 799 sweepCompleted = false; | 800 sweepCompleted = false; |
| 800 break; | 801 break; |
| 801 } | 802 } |
| 802 } | 803 } |
| 803 | 804 |
| 804 accumulateSweepingTime(WTF::currentTimeMS() - startTime); | 805 accumulateSweepingTime(WTF::currentTimeMS() - startTime); |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 threadDump->addScalar("dead_count", "objects", totalDeadCount); | 1516 threadDump->addScalar("dead_count", "objects", totalDeadCount); |
| 1516 threadDump->addScalar("live_size", "bytes", totalLiveSize); | 1517 threadDump->addScalar("live_size", "bytes", totalLiveSize); |
| 1517 threadDump->addScalar("dead_size", "bytes", totalDeadSize); | 1518 threadDump->addScalar("dead_size", "bytes", totalDeadSize); |
| 1518 | 1519 |
| 1519 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); | 1520 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); |
| 1520 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); | 1521 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); |
| 1521 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); | 1522 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); |
| 1522 } | 1523 } |
| 1523 | 1524 |
| 1524 } // namespace blink | 1525 } // namespace blink |
| OLD | NEW |