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:
4 * Copyright 2017 Mozilla Foundation
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef wasm_process_h
20 #define wasm_process_h
22 #include "mozilla/Atomics.h"
24 #include "wasm/WasmMemory.h"
33 // These methods return the wasm::CodeSegment (resp. wasm::Code) containing
34 // the given pc, if any exist in the process. These methods do not take a lock,
35 // and thus are safe to use in a profiling context.
37 const CodeSegment
* LookupCodeSegment(const void* pc
,
38 const CodeRange
** codeRange
= nullptr);
40 const Code
* LookupCode(const void* pc
, const CodeRange
** codeRange
= nullptr);
42 // Return whether the given PC is in any type of wasm code (module or builtin).
44 bool InCompiledCode(void* pc
);
46 // A bool member that can be used as a very fast lookup to know if there is any
47 // code segment at all.
49 extern mozilla::Atomic
<bool> CodeExists
;
51 // These methods allow to (un)register CodeSegments so they can be looked up
52 // via pc in the methods described above.
54 bool RegisterCodeSegment(const CodeSegment
* cs
);
56 void UnregisterCodeSegment(const CodeSegment
* cs
);
58 // Whether this process is configured to use huge memory or not. Note that this
59 // is not precise enough to tell whether a particular memory uses huge memory,
60 // there are additional conditions for that.
62 bool IsHugeMemoryEnabled(IndexType t
);
64 [[nodiscard
]] bool DisableHugeMemory();
66 // Called once before/after the last VM execution which could execute or compile
76 #endif // wasm_process_h