Commit 63372e46 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Do not cancel all compilation on context disposal

We should only cancel asynchronous compilation jobs for the isolate
which is being recycled.

R=titzer@chromium.org

Bug: chromium:854755
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I31d6c3ccb648f5465e52f4bc47c4261894458e60
Reviewed-on: https://chromium-review.googlesource.com/1118378Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54092}
parent ad19b86d
......@@ -8767,9 +8767,9 @@ void Isolate::LowMemoryNotification() {
int Isolate::ContextDisposedNotification(bool dependant_context) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
if (!dependant_context) {
// We left the current context, we can abort all running WebAssembly
// compilations.
isolate->wasm_engine()->AbortAllCompileJobs();
// We left the current context, we can abort all WebAssembly compilations on
// that isolate.
isolate->wasm_engine()->AbortCompileJobsOnIsolate(isolate);
}
// TODO(ahaas): move other non-heap activity out of the heap call.
return isolate->heap()->NotifyContextDisposed(dependant_context);
......
......@@ -81,6 +81,7 @@ class AsyncCompileJob {
explicit AsyncCompileJob(Isolate* isolate, std::unique_ptr<byte[]> bytes_copy,
size_t length, Handle<Context> context,
std::unique_ptr<CompilationResultResolver> resolver);
~AsyncCompileJob();
void Start();
......@@ -88,7 +89,7 @@ class AsyncCompileJob {
void Abort();
~AsyncCompileJob();
Isolate* isolate() const { return isolate_; }
private:
class CompileTask;
......@@ -134,8 +135,6 @@ class AsyncCompileJob {
template <typename Step, typename... Args>
void NextStep(Args&&... args);
Isolate* isolate() { return isolate_; }
friend class AsyncStreamingProcessor;
Isolate* isolate_;
......
......@@ -179,14 +179,16 @@ std::unique_ptr<AsyncCompileJob> WasmEngine::RemoveCompileJob(
return result;
}
void WasmEngine::AbortAllCompileJobs() {
void WasmEngine::AbortCompileJobsOnIsolate(Isolate* isolate) {
// Iterate over a copy of {jobs_}, because {job->Abort} modifies {jobs_}.
std::vector<AsyncCompileJob*> copy;
copy.reserve(jobs_.size());
std::vector<AsyncCompileJob*> isolate_jobs;
for (auto& entry : jobs_) copy.push_back(entry.first);
for (auto& entry : jobs_) {
if (entry.first->isolate() != isolate) continue;
isolate_jobs.push_back(entry.first);
}
for (auto* job : copy) job->Abort();
for (auto* job : isolate_jobs) job->Abort();
}
void WasmEngine::TearDown() {
......
......@@ -101,11 +101,10 @@ class V8_EXPORT_PRIVATE WasmEngine {
// Returns true if at lease one AsyncCompileJob is currently running.
bool HasRunningCompileJob() const { return !jobs_.empty(); }
// Cancel all AsyncCompileJobs so that they are not processed any further,
// but delay the deletion of their state until all tasks accessing the
// AsyncCompileJob finish their execution. This is used to clean-up the
// isolate to be reused.
void AbortAllCompileJobs();
// Cancel all AsyncCompileJobs that belong to the given Isolate. Their
// deletion is delayed until all tasks accessing the AsyncCompileJob finish
// their execution. This is used to clean-up the isolate to be reused.
void AbortCompileJobsOnIsolate(Isolate*);
void TearDown();
......
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