Debian Codegraph @

js/src/wasm/WasmProcess.h

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 *
4 * Copyright 2017 Mozilla Foundation
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #ifndef wasm_process_h
20 #define wasm_process_h
21
22 #include "mozilla/Atomics.h"
23
24 #include "wasm/WasmMemory.h"
25
26 namespace js {
27 namespace wasm {
28
29 class Code;
30 class CodeRange;
31 class CodeBlock;
32 class TagType;
33
34 extern const TagType* sWrappedJSValueTagType;
35 static constexpr uint32_t WrappedJSValueTagType_ValueOffset = 0;
36
37 // These methods return the wasm::CodeBlock (resp. wasm::Code) containing
38 // the given pc, if any exist in the process. These methods do not take a lock,
39 // and thus are safe to use in a profiling context.
40
41 const CodeBlock* LookupCodeBlock(const void* pc,
42 const CodeRange** codeRange = nullptr);
43
44 const Code* LookupCode(const void* pc, const CodeRange** codeRange = nullptr);
45
46 // Return whether the given PC is in any type of wasm code (module or builtin).
47
48 bool InCompiledCode(void* pc);
49
50 // A bool member that can be used as a very fast lookup to know if there is any
51 // code segment at all.
52
53 extern mozilla::Atomic<bool> CodeExists;
54
55 // These methods allow to (un)register CodeBlocks so they can be looked up
56 // via pc in the methods described above.
57
58 bool RegisterCodeBlock(const CodeBlock* cs);
59
60 void UnregisterCodeBlock(const CodeBlock* cs);
61
62 // Whether this process is configured to use huge memory or not. Note that this
63 // is not precise enough to tell whether a particular memory uses huge memory,
64 // there are additional conditions for that.
65
66 bool IsHugeMemoryEnabled(AddressType t);
67
68 // Called once before/after the last VM execution which could execute or compile
69 // wasm.
70
71 bool Init();
72
73 void ShutDown();
74
75 } // namespace wasm
76 } // namespace js
77
78 #endif // wasm_process_h