[wasm] Fix inconsistency in HasRunningCompileJob predicate.

This changes the predicate in question to only check for async compile
jobs belonging to a given Isolate, having an engine-wide predicate is
not desirable for draining message queues.

R=clemensh@chromium.org
BUG=v8:7424

Change-Id: If990378400cc4484d413c4d7771ec6deb6bfd244
Reviewed-on: https://chromium-review.googlesource.com/1158565
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54844}
This commit is contained in:
Michael Starzinger 2018-08-01 14:36:38 +02:00 committed by Commit Bot
parent 8332c0ff11
commit a05410336d
3 changed files with 14 additions and 5 deletions

View File

@ -3041,9 +3041,9 @@ void Shell::CompleteMessageLoop(Isolate* isolate) {
DCHECK_GT(isolate_status_.count(isolate), 0);
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::wasm::WasmEngine* wasm_engine = i_isolate->wasm_engine();
bool should_wait =
(options.wait_for_wasm && wasm_engine->HasRunningCompileJob()) ||
isolate_status_[isolate];
bool should_wait = (options.wait_for_wasm &&
wasm_engine->HasRunningCompileJob(i_isolate)) ||
isolate_status_[isolate];
return should_wait ? platform::MessageLoopBehavior::kWaitForWork
: platform::MessageLoopBehavior::kDoNotWait;
};

View File

@ -230,6 +230,14 @@ std::unique_ptr<AsyncCompileJob> WasmEngine::RemoveCompileJob(
return result;
}
bool WasmEngine::HasRunningCompileJob(Isolate* isolate) {
base::LockGuard<base::Mutex> guard(&mutex_);
for (auto& entry : jobs_) {
if (entry.first->isolate() == isolate) return true;
}
return false;
}
void WasmEngine::AbortCompileJobsOnIsolate(Isolate* isolate) {
// Iterate over a copy of {jobs_}, because {job->Abort} modifies {jobs_}.
std::vector<AsyncCompileJob*> isolate_jobs;

View File

@ -116,8 +116,9 @@ class V8_EXPORT_PRIVATE WasmEngine {
// Remove {job} from the list of active compile jobs.
std::unique_ptr<AsyncCompileJob> RemoveCompileJob(AsyncCompileJob* job);
// Returns true if at lease one AsyncCompileJob is currently running.
bool HasRunningCompileJob() const { return !jobs_.empty(); }
// Returns true if at least one AsyncCompileJob that belongs to the given
// Isolate is currently running.
bool HasRunningCompileJob(Isolate* isolate);
// Cancel all AsyncCompileJobs that belong to the given Isolate. Their
// deletion is delayed until all tasks accessing the AsyncCompileJob finish