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 : #ifndef V8_WASM_COMPILATION_MANAGER_H_
6 : #define V8_WASM_COMPILATION_MANAGER_H_
7 :
8 : #include <vector>
9 :
10 : #include "src/handles.h"
11 : #include "src/isolate.h"
12 : #include "src/wasm/module-compiler.h"
13 :
14 : namespace v8 {
15 : namespace internal {
16 : namespace wasm {
17 :
18 : // The CompilationManager manages a list of active WebAssembly compile jobs. The
19 : // manager owns the memory of the compile jobs and can trigger the abortion of
20 : // compile jobs. If the isolate tears down, the CompilationManager makes sure
21 : // that all compile jobs finish executing before the isolate becomes
22 : // unavailable.
23 54999 : class CompilationManager {
24 : public:
25 : void StartAsyncCompileJob(Isolate* isolate,
26 : std::unique_ptr<byte[]> bytes_copy, size_t length,
27 : Handle<Context> context, Handle<JSPromise> promise);
28 :
29 : std::shared_ptr<StreamingDecoder> StartStreamingCompilation(
30 : Isolate* isolate, Handle<Context> context, Handle<JSPromise> promise);
31 :
32 : // Removes {job} from the list of active compile jobs.
33 : std::shared_ptr<AsyncCompileJob> RemoveJob(AsyncCompileJob* job);
34 :
35 : void TearDown();
36 :
37 : private:
38 : AsyncCompileJob* CreateAsyncCompileJob(Isolate* isolate,
39 : std::unique_ptr<byte[]> bytes_copy,
40 : size_t length, Handle<Context> context,
41 : Handle<JSPromise> promise);
42 :
43 : // We use an AsyncCompileJob as the key for itself so that we can delete the
44 : // job from the map when it is finished.
45 : std::unordered_map<AsyncCompileJob*, std::shared_ptr<AsyncCompileJob>> jobs_;
46 : };
47 :
48 : } // namespace wasm
49 : } // namespace internal
50 : } // namespace v8
51 :
52 : #endif // V8_WASM_COMPILATION_MANAGER_H_
|