Line data Source code
1 : // Copyright 2017 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/wasm/compilation-manager.h"
6 : #include "src/base/template-utils.h"
7 :
8 : #include "src/objects-inl.h"
9 :
10 : namespace v8 {
11 : namespace internal {
12 : namespace wasm {
13 :
14 413 : AsyncCompileJob* CompilationManager::CreateAsyncCompileJob(
15 : Isolate* isolate, std::unique_ptr<byte[]> bytes_copy, size_t length,
16 : Handle<Context> context, Handle<JSPromise> promise) {
17 : std::shared_ptr<AsyncCompileJob> job(new AsyncCompileJob(
18 1239 : isolate, std::move(bytes_copy), length, context, promise));
19 826 : jobs_.insert({job.get(), job});
20 826 : return job.get();
21 : }
22 :
23 63 : void CompilationManager::StartAsyncCompileJob(
24 : Isolate* isolate, std::unique_ptr<byte[]> bytes_copy, size_t length,
25 : Handle<Context> context, Handle<JSPromise> promise) {
26 : AsyncCompileJob* job = CreateAsyncCompileJob(isolate, std::move(bytes_copy),
27 126 : length, context, promise);
28 63 : job->Start();
29 63 : }
30 :
31 350 : std::shared_ptr<StreamingDecoder> CompilationManager::StartStreamingCompilation(
32 : Isolate* isolate, Handle<Context> context, Handle<JSPromise> promise) {
33 : AsyncCompileJob* job = CreateAsyncCompileJob(
34 700 : isolate, std::unique_ptr<byte[]>(nullptr), 0, context, promise);
35 350 : return job->CreateStreamingDecoder();
36 : }
37 :
38 412 : std::shared_ptr<AsyncCompileJob> CompilationManager::RemoveJob(
39 : AsyncCompileJob* job) {
40 : auto item = jobs_.find(job);
41 : DCHECK(item != jobs_.end());
42 : std::shared_ptr<AsyncCompileJob> result = std::move(item->second);
43 : jobs_.erase(item);
44 412 : return result;
45 : }
46 :
47 106730 : void CompilationManager::TearDown() { jobs_.clear(); }
48 :
49 : } // namespace wasm
50 : } // namespace internal
51 : } // namespace v8
|