[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/964221
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51972}
This commit is contained in:
Clemens Hammacher 2018-03-15 13:22:46 +01:00 committed by Commit Bot
parent dfe7eb84e3
commit bed027648e
2 changed files with 14 additions and 5 deletions

View File

@ -40,6 +40,7 @@
#include "src/trap-handler/trap-handler.h"
#include "src/utils.h"
#include "src/v8.h"
#include "src/wasm/wasm-engine.h"
#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h> // NOLINT
@ -3011,13 +3012,18 @@ bool ProcessMessages(Isolate* isolate,
} // anonymous namespace
void Shell::CompleteMessageLoop(Isolate* isolate) {
ProcessMessages(isolate, [isolate]() {
auto get_waiting_behaviour = [isolate]() {
base::LockGuard<base::Mutex> guard(isolate_status_lock_.Pointer());
DCHECK_GT(isolate_status_.count(isolate), 0);
return isolate_status_[isolate]
? platform::MessageLoopBehavior::kWaitForWork
: platform::MessageLoopBehavior::kDoNotWait;
});
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::wasm::CompilationManager* wasm_compilation_manager =
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) {

View File

@ -41,6 +41,9 @@ class CompilationManager {
// AsyncCompileJob finish their execution.
void AbortAllJobs();
// Returns true if at lease one AsyncCompileJob is currently running.
bool HasRunningCompileJob() const { return !jobs_.empty(); }
private:
AsyncCompileJob* CreateAsyncCompileJob(Isolate* isolate,
std::unique_ptr<byte[]> bytes_copy,