LCOV - code coverage report
Current view: top level - js/src/wasm - WasmTable.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 5 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 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_table_h
      20             : #define wasm_table_h
      21             : 
      22             : #include "gc/Policy.h"
      23             : #include "wasm/WasmCode.h"
      24             : 
      25             : namespace js {
      26             : namespace wasm {
      27             : 
      28             : // A Table is an indexable array of opaque values. Tables are first-class
      29             : // stateful objects exposed to WebAssembly. asm.js also uses Tables to represent
      30             : // its homogeneous function-pointer tables.
      31             : 
      32           0 : class Table : public ShareableBase<Table>
      33             : {
      34             :     using InstanceSet = JS::WeakCache<GCHashSet<ReadBarrieredWasmInstanceObject,
      35             :                                                 MovableCellHasher<ReadBarrieredWasmInstanceObject>,
      36             :                                                 SystemAllocPolicy>>;
      37             :     using UniqueByteArray = UniquePtr<uint8_t[], JS::FreePolicy>;
      38             : 
      39             :     ReadBarrieredWasmTableObject maybeObject_;
      40             :     InstanceSet                  observers_;
      41             :     UniqueByteArray              array_;
      42             :     const TableKind              kind_;
      43             :     uint32_t                     length_;
      44             :     const Maybe<uint32_t>        maximum_;
      45             :     const bool                   external_;
      46             : 
      47             :     template <class> friend struct js::MallocProvider;
      48             :     Table(JSContext* cx, const TableDesc& td, HandleWasmTableObject maybeObject,
      49             :           UniqueByteArray array);
      50             : 
      51             :     void tracePrivate(JSTracer* trc);
      52             :     friend class js::WasmTableObject;
      53             : 
      54             :   public:
      55             :     static RefPtr<Table> create(JSContext* cx, const TableDesc& desc,
      56             :                                 HandleWasmTableObject maybeObject);
      57             :     void trace(JSTracer* trc);
      58             : 
      59             :     bool external() const { return external_; }
      60           0 :     bool isTypedFunction() const { return kind_ == TableKind::TypedFunction; }
      61           0 :     uint32_t length() const { return length_; }
      62           0 :     Maybe<uint32_t> maximum() const { return maximum_; }
      63           0 :     uint8_t* base() const { return array_.get(); }
      64             : 
      65             :     // All table updates must go through set() or setNull().
      66             : 
      67             :     void** internalArray() const;
      68             :     ExternalTableElem* externalArray() const;
      69             :     void set(uint32_t index, void* code, Instance& instance);
      70             :     void setNull(uint32_t index);
      71             : 
      72             :     uint32_t grow(uint32_t delta, JSContext* cx);
      73             :     bool movingGrowable() const;
      74             :     bool addMovingGrowObserver(JSContext* cx, WasmInstanceObject* instance);
      75             : 
      76             :     // about:memory reporting:
      77             : 
      78             :     size_t sizeOfExcludingThis(MallocSizeOf mallocSizeOf) const;
      79             : };
      80             : 
      81             : typedef RefPtr<Table> SharedTable;
      82             : typedef Vector<SharedTable, 0, SystemAllocPolicy> SharedTableVector;
      83             : 
      84             : } // namespace wasm
      85             : } // namespace js
      86             : 
      87             : #endif // wasm_table_h

Generated by: LCOV version 1.13