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

Side by Side Diff: src/d8.cc

Issue 2752043002: [promises] Add %WaitForPromise runtime call to allow tests to reliably wait for promises to be fini… (Closed)
Patch Set: Strip it down to %IncrementWaitCount and %DecrementWaitCount Created 3 years, 9 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
« no previous file with comments | « no previous file | src/isolate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 .ToLocalChecked(), 1573 .ToLocalChecked(),
1574 worker_fun_template); 1574 worker_fun_template);
1575 1575
1576 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); 1576 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
1577 AddOSMethods(isolate, os_templ); 1577 AddOSMethods(isolate, os_templ);
1578 global_template->Set( 1578 global_template->Set(
1579 String::NewFromUtf8(isolate, "os", NewStringType::kNormal) 1579 String::NewFromUtf8(isolate, "os", NewStringType::kNormal)
1580 .ToLocalChecked(), 1580 .ToLocalChecked(),
1581 os_templ); 1581 os_templ);
1582 1582
1583 return global_template; 1583 return global_template;
ulan 2017/03/16 11:50:14 How about adding "increment", "decrement" function
1584 } 1584 }
1585 1585
1586 static void PrintNonErrorsMessageCallback(Local<Message> message, 1586 static void PrintNonErrorsMessageCallback(Local<Message> message,
1587 Local<Value> error) { 1587 Local<Value> error) {
1588 // Nothing to do here for errors, exceptions thrown up to the shell will be 1588 // Nothing to do here for errors, exceptions thrown up to the shell will be
1589 // reported 1589 // reported
1590 // separately by {Shell::ReportException} after they are caught. 1590 // separately by {Shell::ReportException} after they are caught.
1591 // Do print other kinds of messages. 1591 // Do print other kinds of messages.
1592 switch (message->ErrorLevel()) { 1592 switch (message->ErrorLevel()) {
1593 case v8::Isolate::kMessageWarning: 1593 case v8::Isolate::kMessageWarning:
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)->GetWaitCount() > 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
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
OLDNEW
« no previous file with comments | « no previous file | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698