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() { ...@@ -8767,9 +8767,9 @@ void Isolate::LowMemoryNotification() {
int Isolate::ContextDisposedNotification(bool dependant_context) { int Isolate::ContextDisposedNotification(bool dependant_context) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
if (!dependant_context) { if (!dependant_context) {
// We left the current context, we can abort all running WebAssembly // We left the current context, we can abort all WebAssembly compilations on
// compilations. // that isolate.
isolate->wasm_engine()->AbortAllCompileJobs(); isolate->wasm_engine()->AbortCompileJobsOnIsolate(isolate);
} }
// TODO(ahaas): move other non-heap activity out of the heap call. // TODO(ahaas): move other non-heap activity out of the heap call.
return isolate->heap()->NotifyContextDisposed(dependant_context); return isolate->heap()->NotifyContextDisposed(dependant_context);
......
...@@ -81,6 +81,7 @@ class AsyncCompileJob { ...@@ -81,6 +81,7 @@ class AsyncCompileJob {
explicit AsyncCompileJob(Isolate* isolate, std::unique_ptr<byte[]> bytes_copy, explicit AsyncCompileJob(Isolate* isolate, std::unique_ptr<byte[]> bytes_copy,
size_t length, Handle<Context> context, size_t length, Handle<Context> context,
std::unique_ptr<CompilationResultResolver> resolver); std::unique_ptr<CompilationResultResolver> resolver);
~AsyncCompileJob();
void Start(); void Start();
...@@ -88,7 +89,7 @@ class AsyncCompileJob { ...@@ -88,7 +89,7 @@ class AsyncCompileJob {
void Abort(); void Abort();
~AsyncCompileJob(); Isolate* isolate() const { return isolate_; }
private: private:
class CompileTask; class CompileTask;
...@@ -134,8 +135,6 @@ class AsyncCompileJob { ...@@ -134,8 +135,6 @@ class AsyncCompileJob {
template <typename Step, typename... Args> template <typename Step, typename... Args>
void NextStep(Args&&... args); void NextStep(Args&&... args);
Isolate* isolate() { return isolate_; }
friend class AsyncStreamingProcessor; friend class AsyncStreamingProcessor;
Isolate* isolate_; Isolate* isolate_;
......
...@@ -179,14 +179,16 @@ std::unique_ptr<AsyncCompileJob> WasmEngine::RemoveCompileJob( ...@@ -179,14 +179,16 @@ std::unique_ptr<AsyncCompileJob> WasmEngine::RemoveCompileJob(
return result; return result;
} }
void WasmEngine::AbortAllCompileJobs() { void WasmEngine::AbortCompileJobsOnIsolate(Isolate* isolate) {
// Iterate over a copy of {jobs_}, because {job->Abort} modifies {jobs_}. // Iterate over a copy of {jobs_}, because {job->Abort} modifies {jobs_}.
std::vector<AsyncCompileJob*> copy; std::vector<AsyncCompileJob*> isolate_jobs;
copy.reserve(jobs_.size());
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() { void WasmEngine::TearDown() {
......
...@@ -101,11 +101,10 @@ class V8_EXPORT_PRIVATE WasmEngine { ...@@ -101,11 +101,10 @@ class V8_EXPORT_PRIVATE WasmEngine {
// Returns true if at lease one AsyncCompileJob is currently running. // Returns true if at lease one AsyncCompileJob is currently running.
bool HasRunningCompileJob() const { return !jobs_.empty(); } bool HasRunningCompileJob() const { return !jobs_.empty(); }
// Cancel all AsyncCompileJobs so that they are not processed any further, // Cancel all AsyncCompileJobs that belong to the given Isolate. Their
// but delay the deletion of their state until all tasks accessing the // deletion is delayed until all tasks accessing the AsyncCompileJob finish
// AsyncCompileJob finish their execution. This is used to clean-up the // their execution. This is used to clean-up the isolate to be reused.
// isolate to be reused. void AbortCompileJobsOnIsolate(Isolate*);
void AbortAllCompileJobs();
void TearDown(); 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