OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds); | 2578 g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds); |
2579 } | 2579 } |
2580 if (options.invoke_weak_callbacks) { | 2580 if (options.invoke_weak_callbacks) { |
2581 // By sending a low memory notifications, we will try hard to collect all | 2581 // By sending a low memory notifications, we will try hard to collect all |
2582 // garbage and will therefore also invoke all weak callbacks of actually | 2582 // garbage and will therefore also invoke all weak callbacks of actually |
2583 // unreachable persistent handles. | 2583 // unreachable persistent handles. |
2584 isolate->LowMemoryNotification(); | 2584 isolate->LowMemoryNotification(); |
2585 } | 2585 } |
2586 } | 2586 } |
2587 | 2587 |
2588 | |
2589 void Shell::EmptyMessageQueues(Isolate* isolate) { | 2588 void Shell::EmptyMessageQueues(Isolate* isolate) { |
2590 if (!i::FLAG_verify_predictable) { | 2589 if (i::FLAG_verify_predictable) return; |
2591 while (v8::platform::PumpMessageLoop(g_platform, isolate)) continue; | 2590 while (true) { |
| 2591 // Pump the message loop until it is empty. |
| 2592 while (v8::platform::PumpMessageLoop(g_platform, isolate)) { |
| 2593 isolate->RunMicrotasks(); |
| 2594 } |
| 2595 // Run the idle tasks. |
2592 v8::platform::RunIdleTasks(g_platform, isolate, | 2596 v8::platform::RunIdleTasks(g_platform, isolate, |
2593 50.0 / base::Time::kMillisecondsPerSecond); | 2597 50.0 / base::Time::kMillisecondsPerSecond); |
| 2598 // If there are still outstanding waiters, sleep a little (to wait for |
| 2599 // background tasks) and then try everything again. |
| 2600 if (reinterpret_cast<i::Isolate*>(isolate)->GetWaitCountForTesting() > 0) { |
| 2601 base::OS::Sleep(base::TimeDelta::FromMilliseconds(1)); |
| 2602 } else { |
| 2603 break; |
| 2604 } |
2594 } | 2605 } |
2595 } | 2606 } |
2596 | 2607 |
2597 class Serializer : public ValueSerializer::Delegate { | 2608 class Serializer : public ValueSerializer::Delegate { |
2598 public: | 2609 public: |
2599 explicit Serializer(Isolate* isolate) | 2610 explicit Serializer(Isolate* isolate) |
2600 : isolate_(isolate), | 2611 : isolate_(isolate), |
2601 serializer_(isolate, this), | 2612 serializer_(isolate, this), |
2602 current_memory_usage_(0) {} | 2613 current_memory_usage_(0) {} |
2603 | 2614 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3043 } | 3054 } |
3044 | 3055 |
3045 } // namespace v8 | 3056 } // namespace v8 |
3046 | 3057 |
3047 | 3058 |
3048 #ifndef GOOGLE3 | 3059 #ifndef GOOGLE3 |
3049 int main(int argc, char* argv[]) { | 3060 int main(int argc, char* argv[]) { |
3050 return v8::Shell::Main(argc, argv); | 3061 return v8::Shell::Main(argc, argv); |
3051 } | 3062 } |
3052 #endif | 3063 #endif |
OLD | NEW |