Commit bed02764 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[d8] Wait for wasm background compilation to complete

Prevent d8 from exiting while wasm background compilation is still
going on. This prevents the need to use the testRunner to execute
webassembly tests in d8.

R=yangguo@chromium.org
CC=ahaas@chromium.org

Change-Id: I86fb7ce260fc56ee87040742f77b0ff86b8fbd53
Reviewed-on: https://chromium-review.googlesource.com/964221Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51972}
parent dfe7eb84
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "src/trap-handler/trap-handler.h" #include "src/trap-handler/trap-handler.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/v8.h" #include "src/v8.h"
#include "src/wasm/wasm-engine.h"
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h> // NOLINT #include <unistd.h> // NOLINT
...@@ -3011,13 +3012,18 @@ bool ProcessMessages(Isolate* isolate, ...@@ -3011,13 +3012,18 @@ bool ProcessMessages(Isolate* isolate,
} // anonymous namespace } // anonymous namespace
void Shell::CompleteMessageLoop(Isolate* isolate) { void Shell::CompleteMessageLoop(Isolate* isolate) {
ProcessMessages(isolate, [isolate]() { auto get_waiting_behaviour = [isolate]() {
base::LockGuard<base::Mutex> guard(isolate_status_lock_.Pointer()); base::LockGuard<base::Mutex> guard(isolate_status_lock_.Pointer());
DCHECK_GT(isolate_status_.count(isolate), 0); DCHECK_GT(isolate_status_.count(isolate), 0);
return isolate_status_[isolate] i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
? platform::MessageLoopBehavior::kWaitForWork i::wasm::CompilationManager* wasm_compilation_manager =
: platform::MessageLoopBehavior::kDoNotWait; i_isolate->wasm_engine()->compilation_manager();
}); bool should_wait = wasm_compilation_manager->HasRunningCompileJob() ||
isolate_status_[isolate];
return should_wait ? platform::MessageLoopBehavior::kWaitForWork
: platform::MessageLoopBehavior::kDoNotWait;
};
ProcessMessages(isolate, get_waiting_behaviour);
} }
bool Shell::EmptyMessageQueues(Isolate* isolate) { bool Shell::EmptyMessageQueues(Isolate* isolate) {
......
...@@ -41,6 +41,9 @@ class CompilationManager { ...@@ -41,6 +41,9 @@ class CompilationManager {
// AsyncCompileJob finish their execution. // AsyncCompileJob finish their execution.
void AbortAllJobs(); void AbortAllJobs();
// Returns true if at lease one AsyncCompileJob is currently running.
bool HasRunningCompileJob() const { return !jobs_.empty(); }
private: private:
AsyncCompileJob* CreateAsyncCompileJob(Isolate* isolate, AsyncCompileJob* CreateAsyncCompileJob(Isolate* isolate,
std::unique_ptr<byte[]> bytes_copy, std::unique_ptr<byte[]> bytes_copy,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment