@@ -422,7 +422,6 @@ base::LazyMutex Shell::workers_mutex_;
422422bool Shell::allow_new_workers_ = true ;
423423i::List<Worker*> Shell::workers_;
424424std::vector<ExternalizedContents> Shell::externalized_contents_;
425- std::map<v8::Isolate*, bool > Shell::isolate_status;
426425
427426Global<Context> Shell::evaluation_context_;
428427ArrayBuffer::Allocator* Shell::array_buffer_allocator;
@@ -1346,18 +1345,6 @@ void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
13461345 const_cast <v8::FunctionCallbackInfo<v8::Value>*>(&args));
13471346}
13481347
1349- void Shell::WaitUntilDone (const v8::FunctionCallbackInfo<v8::Value>& args) {
1350- if (isolate_status.count (args.GetIsolate ()) == 0 ) {
1351- isolate_status.insert (std::make_pair (args.GetIsolate (), true ));
1352- } else {
1353- isolate_status[args.GetIsolate ()] = true ;
1354- }
1355- }
1356-
1357- void Shell::NotifyDone (const v8::FunctionCallbackInfo<v8::Value>& args) {
1358- DCHECK_EQ (isolate_status.count (args.GetIsolate ()), 1 );
1359- isolate_status[args.GetIsolate ()] = false ;
1360- }
13611348
13621349void Shell::Version (const v8::FunctionCallbackInfo<v8::Value>& args) {
13631350 args.GetReturnValue ().Set (
@@ -1595,19 +1582,6 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
15951582 .ToLocalChecked (),
15961583 FunctionTemplate::New (isolate, Quit));
15971584 }
1598- Local<ObjectTemplate> test_template = ObjectTemplate::New (isolate);
1599- global_template->Set (
1600- String::NewFromUtf8 (isolate, " testRunner" , NewStringType::kNormal )
1601- .ToLocalChecked (),
1602- test_template);
1603- test_template->Set (
1604- String::NewFromUtf8 (isolate, " notifyDone" , NewStringType::kNormal )
1605- .ToLocalChecked (),
1606- FunctionTemplate::New (isolate, NotifyDone));
1607- test_template->Set (
1608- String::NewFromUtf8 (isolate, " waitUntilDone" , NewStringType::kNormal )
1609- .ToLocalChecked (),
1610- FunctionTemplate::New (isolate, WaitUntilDone));
16111585 global_template->Set (
16121586 String::NewFromUtf8 (isolate, " version" , NewStringType::kNormal )
16131587 .ToLocalChecked (),
@@ -2292,8 +2266,6 @@ void SourceGroup::ExecuteInThread() {
22922266 create_params.host_import_module_dynamically_callback_ =
22932267 Shell::HostImportModuleDynamically;
22942268 Isolate* isolate = Isolate::New (create_params);
2295-
2296- v8::platform::EnsureEventLoopInitialized (g_platform, isolate);
22972269 D8Console console (isolate);
22982270 debug::SetConsoleDelegate (isolate, &console);
22992271 for (int i = 0 ; i < Shell::options.stress_runs ; ++i) {
@@ -2314,7 +2286,6 @@ void SourceGroup::ExecuteInThread() {
23142286 DisposeModuleEmbedderData (context);
23152287 }
23162288 Shell::CollectGarbage (isolate);
2317- Shell::CompleteMessageLoop (isolate);
23182289 }
23192290 done_semaphore_.Signal ();
23202291 }
@@ -2675,7 +2646,6 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
26752646 options.isolate_sources [i].StartExecuteInThread ();
26762647 }
26772648 {
2678- v8::platform::EnsureEventLoopInitialized (g_platform, isolate);
26792649 if (options.lcov_file ) {
26802650 debug::Coverage::SelectMode (isolate, debug::Coverage::kPreciseCount );
26812651 }
@@ -2698,7 +2668,6 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
26982668 WriteLcovData (isolate, options.lcov_file );
26992669 }
27002670 CollectGarbage (isolate);
2701- CompleteMessageLoop (isolate);
27022671 for (int i = 1 ; i < options.num_isolates ; ++i) {
27032672 if (last_run) {
27042673 options.isolate_sources [i].JoinThread ();
@@ -2726,28 +2695,24 @@ void Shell::CollectGarbage(Isolate* isolate) {
27262695 }
27272696}
27282697
2729- void Shell::CompleteMessageLoop (Isolate* isolate) {
2730- while (v8::platform::PumpMessageLoop (
2731- g_platform, isolate,
2732- Shell::isolate_status[isolate]
2733- ? platform::MessageLoopBehavior::kWaitForWork
2734- : platform::MessageLoopBehavior::kDoNotWait )) {
2735- isolate->RunMicrotasks ();
2736- }
2737- v8::platform::RunIdleTasks (g_platform, isolate,
2738- 50.0 / base::Time::kMillisecondsPerSecond );
2739- }
2740-
27412698void Shell::EmptyMessageQueues (Isolate* isolate) {
27422699 if (i::FLAG_verify_predictable) return ;
2743- // Pump the message loop until it is empty.
2744- while (v8::platform::PumpMessageLoop (
2745- g_platform, isolate, platform::MessageLoopBehavior::kDoNotWait )) {
2746- isolate->RunMicrotasks ();
2747- }
2748- // Run the idle tasks.
2749- v8::platform::RunIdleTasks (g_platform, isolate,
2750- 50.0 / base::Time::kMillisecondsPerSecond );
2700+ while (true ) {
2701+ // Pump the message loop until it is empty.
2702+ while (v8::platform::PumpMessageLoop (g_platform, isolate)) {
2703+ isolate->RunMicrotasks ();
2704+ }
2705+ // Run the idle tasks.
2706+ v8::platform::RunIdleTasks (g_platform, isolate,
2707+ 50.0 / base::Time::kMillisecondsPerSecond );
2708+ // If there are still outstanding waiters, sleep a little (to wait for
2709+ // background tasks) and then try everything again.
2710+ if (reinterpret_cast <i::Isolate*>(isolate)->GetWaitCountForTesting () > 0 ) {
2711+ base::OS::Sleep (base::TimeDelta::FromMilliseconds (1 ));
2712+ } else {
2713+ break ;
2714+ }
2715+ }
27512716}
27522717
27532718class Serializer : public ValueSerializer ::Delegate {
0 commit comments