Source code

Revision control

Other Tools

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
*
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
#include "mozilla/Attributes.h"
24
25
namespace js {
26
namespace wasm {
27
28
class Code;
29
class CodeRange;
30
class CodeSegment;
31
32
// These methods return the wasm::CodeSegment (resp. wasm::Code) containing
33
// the given pc, if any exist in the process. These methods do not take a lock,
34
// and thus are safe to use in a profiling context.
35
36
const CodeSegment* LookupCodeSegment(const void* pc,
37
const CodeRange** codeRange = nullptr);
38
39
const Code* LookupCode(const void* pc, const CodeRange** codeRange = nullptr);
40
41
// Return whether the given PC is in any type of wasm code (module or builtin).
42
43
bool InCompiledCode(void* pc);
44
45
// A bool member that can be used as a very fast lookup to know if there is any
46
// code segment at all.
47
48
extern mozilla::Atomic<bool> CodeExists;
49
50
// These methods allow to (un)register CodeSegments so they can be looked up
51
// via pc in the methods described above.
52
53
bool RegisterCodeSegment(const CodeSegment* cs);
54
55
void UnregisterCodeSegment(const CodeSegment* cs);
56
57
// Whether this process is configured to use huge memory or not.
58
59
bool IsHugeMemoryEnabled();
60
61
MOZ_MUST_USE bool DisableHugeMemory();
62
63
// Called once before/after the last VM execution which could execute or compile
64
// wasm.
65
66
bool Init();
67
68
void ShutDown();
69
70
} // namespace wasm
71
} // namespace js
72
73
#endif // wasm_process_h