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 2020 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_context_h 20 #define wasm_context_h 21 22 #include "mozilla/MemoryReporting.h" 23 #include "jstypes.h" 24 #include "js/UniquePtr.h" 25 26 struct JS_PUBLIC_API JSContext; 27 28 namespace js { 29 namespace wasm { 30 31 class TypeContext; 32 33 // wasm::Context lives in JSContext and contains the wasm-related per-context 34 // state. 35 36 class Context { 37 public: Context()38 Context() 39 : triedToInstallSignalHandlers(false), 40 haveSignalHandlers(false), 41 typeContext(nullptr) {} 42 43 // Used by wasm::EnsureThreadSignalHandlers(cx) to install thread signal 44 // handlers once per JSContext/thread. 45 bool triedToInstallSignalHandlers; 46 bool haveSignalHandlers; 47 48 [[nodiscard]] bool ensureTypeContext(JSContext* cx); 49 50 // The global type context. 51 UniquePtr<TypeContext> typeContext; 52 53 // about:memory reporting 54 55 size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const; 56 }; 57 58 } // namespace wasm 59 } // namespace js 60 61 #endif // wasm_context_h 62