| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 AnimationClock::notifyTaskStart(); | 75 AnimationClock::notifyTaskStart(); |
| 76 } | 76 } |
| 77 virtual void didProcessTask() override | 77 virtual void didProcessTask() override |
| 78 { | 78 { |
| 79 Microtask::performCheckpoint(); | 79 Microtask::performCheckpoint(); |
| 80 V8GCController::reportDOMMemoryUsageToV8(mainThreadIsolate()); | 80 V8GCController::reportDOMMemoryUsageToV8(mainThreadIsolate()); |
| 81 V8Initializer::reportRejectedPromises(); | 81 V8Initializer::reportRejectedPromises(); |
| 82 } | 82 } |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 void partitionAlmostFullHandler() |
| 86 { |
| 87 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 88 if (isolate) |
| 89 isolate->LowMemoryNotification(); |
| 90 } |
| 91 |
| 85 } // namespace | 92 } // namespace |
| 86 | 93 |
| 87 static WebThread::TaskObserver* s_endOfTaskRunner = 0; | 94 static WebThread::TaskObserver* s_endOfTaskRunner = 0; |
| 88 static WebThread::TaskObserver* s_pendingGCRunner = 0; | 95 static WebThread::TaskObserver* s_pendingGCRunner = 0; |
| 89 static ThreadState::Interruptor* s_messageLoopInterruptor = 0; | 96 static ThreadState::Interruptor* s_messageLoopInterruptor = 0; |
| 90 static ThreadState::Interruptor* s_isolateInterruptor = 0; | 97 static ThreadState::Interruptor* s_isolateInterruptor = 0; |
| 91 | 98 |
| 92 // Make sure we are not re-initialized in the same address space. | 99 // Make sure we are not re-initialized in the same address space. |
| 93 // Doing so may cause hard to reproduce crashes. | 100 // Doing so may cause hard to reproduce crashes. |
| 94 static bool s_webKitInitialized = false; | 101 static bool s_webKitInitialized = false; |
| 95 | 102 |
| 96 void initialize(Platform* platform) | 103 void initialize(Platform* platform) |
| 97 { | 104 { |
| 98 initializeWithoutV8(platform); | 105 initializeWithoutV8(platform); |
| 99 | 106 |
| 100 V8Initializer::initializeMainThreadIfNeeded(); | 107 V8Initializer::initializeMainThreadIfNeeded(); |
| 101 | 108 |
| 102 s_isolateInterruptor = new V8IsolateInterruptor(V8PerIsolateData::mainThread
Isolate()); | 109 s_isolateInterruptor = new V8IsolateInterruptor(V8PerIsolateData::mainThread
Isolate()); |
| 103 ThreadState::current()->addInterruptor(s_isolateInterruptor); | 110 ThreadState::current()->addInterruptor(s_isolateInterruptor); |
| 104 ThreadState::current()->registerTraceDOMWrappers(V8PerIsolateData::mainThrea
dIsolate(), V8GCController::traceDOMWrappers); | 111 ThreadState::current()->registerTraceDOMWrappers(V8PerIsolateData::mainThrea
dIsolate(), V8GCController::traceDOMWrappers); |
| 105 | 112 |
| 106 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. | 113 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. |
| 107 if (WebThread* currentThread = platform->currentThread()) { | 114 if (WebThread* currentThread = platform->currentThread()) { |
| 108 ASSERT(!s_endOfTaskRunner); | 115 ASSERT(!s_endOfTaskRunner); |
| 109 s_endOfTaskRunner = new EndOfTaskRunner; | 116 s_endOfTaskRunner = new EndOfTaskRunner; |
| 110 currentThread->addTaskObserver(s_endOfTaskRunner); | 117 currentThread->addTaskObserver(s_endOfTaskRunner); |
| 111 } | 118 } |
| 119 |
| 120 partitionSetFreeUpMemoryCallback(partitionAlmostFullHandler); |
| 112 } | 121 } |
| 113 | 122 |
| 114 v8::Isolate* mainThreadIsolate() | 123 v8::Isolate* mainThreadIsolate() |
| 115 { | 124 { |
| 116 return V8PerIsolateData::mainThreadIsolate(); | 125 return V8PerIsolateData::mainThreadIsolate(); |
| 117 } | 126 } |
| 118 | 127 |
| 119 static double currentTimeFunction() | 128 static double currentTimeFunction() |
| 120 { | 129 { |
| 121 return Platform::current()->currentTime(); | 130 return Platform::current()->currentTime(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 ASSERT(s_pendingGCRunner); | 207 ASSERT(s_pendingGCRunner); |
| 199 delete s_pendingGCRunner; | 208 delete s_pendingGCRunner; |
| 200 s_pendingGCRunner = 0; | 209 s_pendingGCRunner = 0; |
| 201 | 210 |
| 202 ASSERT(s_messageLoopInterruptor); | 211 ASSERT(s_messageLoopInterruptor); |
| 203 ThreadState::current()->removeInterruptor(s_messageLoopInterruptor); | 212 ThreadState::current()->removeInterruptor(s_messageLoopInterruptor); |
| 204 delete s_messageLoopInterruptor; | 213 delete s_messageLoopInterruptor; |
| 205 s_messageLoopInterruptor = 0; | 214 s_messageLoopInterruptor = 0; |
| 206 } | 215 } |
| 207 | 216 |
| 217 partitionSetFreeUpMemoryCallback(nullptr); |
| 218 |
| 208 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); | 219 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| 209 V8PerIsolateData::willBeDestroyed(isolate); | 220 V8PerIsolateData::willBeDestroyed(isolate); |
| 210 | 221 |
| 211 // Make sure we stop WorkerThreads before the main thread's ThreadState | 222 // Make sure we stop WorkerThreads before the main thread's ThreadState |
| 212 // and later shutdown steps starts freeing up resources needed during | 223 // and later shutdown steps starts freeing up resources needed during |
| 213 // worker termination. | 224 // worker termination. |
| 214 WorkerThread::terminateAndWaitForAllWorkers(); | 225 WorkerThread::terminateAndWaitForAllWorkers(); |
| 215 | 226 |
| 216 // Detach the main thread before starting the shutdown sequence | 227 // Detach the main thread before starting the shutdown sequence |
| 217 // so that the main thread won't get involved in a GC during the shutdown. | 228 // so that the main thread won't get involved in a GC during the shutdown. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 channel->state = WTFLogChannelOn; | 272 channel->state = WTFLogChannelOn; |
| 262 #endif // !LOG_DISABLED | 273 #endif // !LOG_DISABLED |
| 263 } | 274 } |
| 264 | 275 |
| 265 void resetPluginCache(bool reloadPages) | 276 void resetPluginCache(bool reloadPages) |
| 266 { | 277 { |
| 267 Page::refreshPlugins(reloadPages); | 278 Page::refreshPlugins(reloadPages); |
| 268 } | 279 } |
| 269 | 280 |
| 270 } // namespace blink | 281 } // namespace blink |
| OLD | NEW |