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 #include "wasm/WasmContext.h"
20 
21 #include "wasm/WasmTypes.h"
22 
23 using namespace js;
24 using namespace wasm;
25 
ensureTypeContext(JSContext * cx)26 bool wasm::Context::ensureTypeContext(JSContext* cx) {
27   if (typeContext) {
28     return true;
29   }
30   // Default options should be OK here
31   FeatureOptions options;
32   typeContext = js::MakeUnique<TypeContext>(FeatureArgs::build(cx, options),
33                                             TypeDefVector());
34   return !!typeContext;
35 }
36 
sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const37 size_t wasm::Context::sizeOfExcludingThis(
38     mozilla::MallocSizeOf mallocSizeOf) const {
39   return typeContext ? typeContext->sizeOfExcludingThis(mallocSizeOf) : 0;
40 }
41