LCOV - code coverage report
Current view: top level - js/src/wasm - WasmCompartment.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 9 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       3             :  *
       4             :  * Copyright 2016 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_compartment_h
      20             : #define wasm_compartment_h
      21             : 
      22             : #include "wasm/WasmJS.h"
      23             : 
      24             : namespace js {
      25             : 
      26             : class WasmActivation;
      27             : 
      28             : namespace wasm {
      29             : 
      30             : class Code;
      31             : class CodeSegment;
      32             : typedef Vector<Instance*, 0, SystemAllocPolicy> InstanceVector;
      33             : 
      34             : // wasm::Compartment lives in JSCompartment and contains the wasm-related
      35             : // per-compartment state. wasm::Compartment tracks every live instance in the
      36             : // compartment and must be notified, via registerInstance(), of any new
      37             : // WasmInstanceObject.
      38             : 
      39             : class Compartment
      40             : {
      41             :     InstanceVector instances_;
      42             :     volatile bool  mutatingInstances_;
      43             : 
      44             :     friend class js::WasmActivation;
      45             : 
      46             :     struct AutoMutateInstances {
      47             :         Compartment &c;
      48           0 :         explicit AutoMutateInstances(Compartment& c) : c(c) {
      49           0 :             MOZ_ASSERT(!c.mutatingInstances_);
      50           0 :             c.mutatingInstances_ = true;
      51           0 :         }
      52           0 :         ~AutoMutateInstances() {
      53           0 :             MOZ_ASSERT(c.mutatingInstances_);
      54           0 :             c.mutatingInstances_ = false;
      55           0 :         }
      56             :     };
      57             : 
      58             :   public:
      59             :     explicit Compartment(Zone* zone);
      60             :     ~Compartment();
      61             : 
      62             :     // Before a WasmInstanceObject can be considered fully constructed and
      63             :     // valid, it must be registered with the Compartment. If this method fails,
      64             :     // an error has been reported and the instance object must be abandoned.
      65             :     // After a successful registration, an Instance must call
      66             :     // unregisterInstance() before being destroyed.
      67             : 
      68             :     bool registerInstance(JSContext* cx, HandleWasmInstanceObject instanceObj);
      69             :     void unregisterInstance(Instance& instance);
      70             : 
      71             :     // Return a vector of all live instances in the compartment. The lifetime of
      72             :     // these Instances is determined by their owning WasmInstanceObject.
      73             :     // Note that accessing instances()[i]->object() triggers a read barrier
      74             :     // since instances() is effectively a weak list.
      75             : 
      76           0 :     const InstanceVector& instances() const { return instances_; }
      77             : 
      78             :     // This methods returns the wasm::Code containing the given pc, if any
      79             :     // exists in the compartment, and the segment for the tier in which the
      80             :     // pc was found.
      81             : 
      82             :     const Code* lookupCode(const void* pc, const CodeSegment** segment = nullptr) const;
      83             : 
      84             :     // Ensure all Instances in this JSCompartment have profiling labels created.
      85             : 
      86             :     void ensureProfilingLabels(bool profilingEnabled);
      87             : 
      88             :     // about:memory reporting
      89             : 
      90             :     void addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t* compartmentTables);
      91             : };
      92             : 
      93             : } // namespace wasm
      94             : } // namespace js
      95             : 
      96             : #endif // wasm_compartment_h

Generated by: LCOV version 1.13