LCOV - code coverage report
Current view: top level - src/wasm - signature-map.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2017-10-20 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2016 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_WASM_SIGNATURE_MAP_H_
       6             : #define V8_WASM_SIGNATURE_MAP_H_
       7             : 
       8             : #include <map>
       9             : 
      10             : #include "src/signature.h"
      11             : #include "src/wasm/wasm-opcodes.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : namespace wasm {
      16             : 
      17             : // A signature map canonicalizes signatures into a range of indices so that
      18             : // two different {FunctionSig} instances with the same contents map to the
      19             : // same index.
      20             : class V8_EXPORT_PRIVATE SignatureMap {
      21             :  public:
      22             :   // Allow default construction and move construction (because we have vectors
      23             :   // of objects containing SignatureMaps), but disallow copy or assign. It's
      24             :   // too easy to get security bugs by accidentally updating a copy of the map.
      25      648003 :   MOVE_ONLY_WITH_DEFAULT_CONSTRUCTORS(SignatureMap);
      26             : 
      27             :   // Gets the index for a signature, assigning a new index if necessary.
      28             :   uint32_t FindOrInsert(FunctionSig* sig);
      29             : 
      30             :   // Gets the index for a signature, returning {-1} if not found.
      31             :   int32_t Find(FunctionSig* sig) const;
      32             : 
      33             :   // Disallows further insertions to this signature map.
      34      291921 :   void Freeze() { frozen_ = true; }
      35             : 
      36             :  private:
      37             :   // TODO(wasm): use a hashmap instead of an ordered map?
      38             :   struct CompareFunctionSigs {
      39             :     bool operator()(FunctionSig* a, FunctionSig* b) const;
      40             :   };
      41             :   uint32_t next_ = 0;
      42             :   bool frozen_ = false;
      43             :   std::map<FunctionSig*, uint32_t, CompareFunctionSigs> map_;
      44             : };
      45             : 
      46             : }  // namespace wasm
      47             : }  // namespace internal
      48             : }  // namespace v8
      49             : 
      50             : #endif  // V8_WASM_SIGNATURE_MAP_H_

Generated by: LCOV version 1.10