291f8dcfd5
This CL is the first step in introducing a compilation manager for asynchronous compile jobs in WebAssembly. The compilation manager holds a list of currently active AsyncCompileJobs. With the compilation manager these compile jobs get deallocated when the isolate shuts down. Note that this CL is not enough to provide a graceful isolate shutdown. For this we have to wait for all compilation tasks to finish before we shut down, and we have to make the tasks stateless. I plan to do these changes in separate CLs. R=clemensh@chromium.org, mtrofin@chromium.org BUG=v8:6436 Change-Id: I9a6e165dd2ef6d33944ca303fed49f7940eea7a2 Reviewed-on: https://chromium-review.googlesource.com/528079 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#45858}
33 lines
925 B
C++
33 lines
925 B
C++
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "src/wasm/compilation-manager.h"
|
|
|
|
#include "src/objects-inl.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
namespace wasm {
|
|
|
|
void CompilationManager::StartAsyncCompileJob(
|
|
Isolate* isolate, std::unique_ptr<byte[]> bytes_copy, size_t length,
|
|
Handle<Context> context, Handle<JSPromise> promise) {
|
|
std::shared_ptr<AsyncCompileJob> job(new AsyncCompileJob(
|
|
isolate, std::move(bytes_copy), length, context, promise));
|
|
jobs_.insert({job.get(), job});
|
|
job->Start();
|
|
}
|
|
|
|
void CompilationManager::RemoveJob(AsyncCompileJob* job) {
|
|
size_t num_removed = jobs_.erase(job);
|
|
USE(num_removed);
|
|
DCHECK_EQ(1, num_removed);
|
|
}
|
|
|
|
void CompilationManager::TearDown() { jobs_.clear(); }
|
|
|
|
} // namespace wasm
|
|
} // namespace internal
|
|
} // namespace v8
|