Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: third_party/WebKit/Source/platform/heap/ThreadState.cpp

Issue 1550563002: Blink Platform: Remove time functions from Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge again. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 733
733 void ThreadState::performIdleGC(double deadlineSeconds) 734 void ThreadState::performIdleGC(double deadlineSeconds)
734 { 735 {
735 ASSERT(checkThread()); 736 ASSERT(checkThread());
736 ASSERT(isMainThread()); 737 ASSERT(isMainThread());
737 ASSERT(Platform::current()->currentThread()->scheduler()); 738 ASSERT(Platform::current()->currentThread()->scheduler());
738 739
739 if (gcState() != IdleGCScheduled) 740 if (gcState() != IdleGCScheduled)
740 return; 741 return;
741 742
742 double idleDeltaInSeconds = deadlineSeconds - Platform::current()->monotonic allyIncreasingTimeSeconds(); 743 double idleDeltaInSeconds = deadlineSeconds - monotonicallyIncreasingTime();
743 TRACE_EVENT2("blink_gc", "ThreadState::performIdleGC", "idleDeltaInSeconds", idleDeltaInSeconds, "estimatedMarkingTime", Heap::estimatedMarkingTime()); 744 TRACE_EVENT2("blink_gc", "ThreadState::performIdleGC", "idleDeltaInSeconds", idleDeltaInSeconds, "estimatedMarkingTime", Heap::estimatedMarkingTime());
744 if (idleDeltaInSeconds <= Heap::estimatedMarkingTime() && !Platform::current ()->currentThread()->scheduler()->canExceedIdleDeadlineIfRequired()) { 745 if (idleDeltaInSeconds <= Heap::estimatedMarkingTime() && !Platform::current ()->currentThread()->scheduler()->canExceedIdleDeadlineIfRequired()) {
745 // If marking is estimated to take longer than the deadline and we can't 746 // If marking is estimated to take longer than the deadline and we can't
746 // exceed the deadline, then reschedule for the next idle period. 747 // exceed the deadline, then reschedule for the next idle period.
747 scheduleIdleGC(); 748 scheduleIdleGC();
748 return; 749 return;
749 } 750 }
750 751
751 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep , BlinkGC::IdleGC); 752 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithoutSweep , BlinkGC::IdleGC);
752 } 753 }
753 754
754 void ThreadState::performIdleLazySweep(double deadlineSeconds) 755 void ThreadState::performIdleLazySweep(double deadlineSeconds)
755 { 756 {
756 ASSERT(checkThread()); 757 ASSERT(checkThread());
757 ASSERT(isMainThread()); 758 ASSERT(isMainThread());
758 759
759 // If we are not in a sweeping phase, there is nothing to do here. 760 // If we are not in a sweeping phase, there is nothing to do here.
760 if (!isSweepingInProgress()) 761 if (!isSweepingInProgress())
761 return; 762 return;
762 763
763 // This check is here to prevent performIdleLazySweep() from being called 764 // This check is here to prevent performIdleLazySweep() from being called
764 // recursively. I'm not sure if it can happen but it would be safer to have 765 // recursively. I'm not sure if it can happen but it would be safer to have
765 // the check just in case. 766 // the check just in case.
766 if (sweepForbidden()) 767 if (sweepForbidden())
767 return; 768 return;
768 769
769 TRACE_EVENT1("blink_gc", "ThreadState::performIdleLazySweep", "idleDeltaInSe conds", deadlineSeconds - Platform::current()->monotonicallyIncreasingTimeSecond s()); 770 TRACE_EVENT1("blink_gc", "ThreadState::performIdleLazySweep", "idleDeltaInSe conds", deadlineSeconds - monotonicallyIncreasingTime());
770 771
771 bool sweepCompleted = true; 772 bool sweepCompleted = true;
772 SweepForbiddenScope scope(this); 773 SweepForbiddenScope scope(this);
773 { 774 {
774 double startTime = WTF::currentTimeMS(); 775 double startTime = WTF::currentTimeMS();
775 ScriptForbiddenIfMainThreadScope scriptForbiddenScope; 776 ScriptForbiddenIfMainThreadScope scriptForbiddenScope;
776 777
777 for (int i = 0; i < BlinkGC::NumberOfHeaps; i++) { 778 for (int i = 0; i < BlinkGC::NumberOfHeaps; i++) {
778 // lazySweepWithDeadline() won't check the deadline until it sweeps 779 // lazySweepWithDeadline() won't check the deadline until it sweeps
779 // 10 pages. So we give a small slack for safety. 780 // 10 pages. So we give a small slack for safety.
780 double slack = 0.001; 781 double slack = 0.001;
781 double remainingBudget = deadlineSeconds - slack - Platform::current ()->monotonicallyIncreasingTimeSeconds(); 782 double remainingBudget = deadlineSeconds - slack - monotonicallyIncr easingTime();
782 if (remainingBudget <= 0 || !m_heaps[i]->lazySweepWithDeadline(deadl ineSeconds)) { 783 if (remainingBudget <= 0 || !m_heaps[i]->lazySweepWithDeadline(deadl ineSeconds)) {
783 // We couldn't finish the sweeping within the deadline. 784 // We couldn't finish the sweeping within the deadline.
784 // We request another idle task for the remaining sweeping. 785 // We request another idle task for the remaining sweeping.
785 scheduleIdleLazySweep(); 786 scheduleIdleLazySweep();
786 sweepCompleted = false; 787 sweepCompleted = false;
787 break; 788 break;
788 } 789 }
789 } 790 }
790 791
791 accumulateSweepingTime(WTF::currentTimeMS() - startTime); 792 accumulateSweepingTime(WTF::currentTimeMS() - startTime);
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 threadDump->addScalar("dead_count", "objects", totalDeadCount); 1510 threadDump->addScalar("dead_count", "objects", totalDeadCount);
1510 threadDump->addScalar("live_size", "bytes", totalLiveSize); 1511 threadDump->addScalar("live_size", "bytes", totalLiveSize);
1511 threadDump->addScalar("dead_size", "bytes", totalDeadSize); 1512 threadDump->addScalar("dead_size", "bytes", totalDeadSize);
1512 1513
1513 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); 1514 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName);
1514 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName); 1515 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName);
1515 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid()); 1516 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid());
1516 } 1517 }
1517 1518
1518 } // namespace blink 1519 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698