LCOV - code coverage report
Current view: top level - src/wasm - signature-map.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 23 23 100.0 %
Date: 2017-10-20 Functions: 3 3 100.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             : #include "src/wasm/signature-map.h"
       6             : 
       7             : namespace v8 {
       8             : namespace internal {
       9             : namespace wasm {
      10             : 
      11      744055 : uint32_t SignatureMap::FindOrInsert(FunctionSig* sig) {
      12      744055 :   CHECK(!frozen_);
      13             :   auto pos = map_.find(sig);
      14      744055 :   if (pos != map_.end()) {
      15       18391 :     return pos->second;
      16             :   } else {
      17      725664 :     uint32_t index = next_++;
      18      725664 :     map_[sig] = index;
      19      725664 :     return index;
      20             :   }
      21             : }
      22             : 
      23      195436 : int32_t SignatureMap::Find(FunctionSig* sig) const {
      24             :   auto pos = map_.find(sig);
      25      195436 :   if (pos != map_.end()) {
      26       37666 :     return static_cast<int32_t>(pos->second);
      27             :   } else {
      28             :     return -1;
      29             :   }
      30             : }
      31             : 
      32     2939707 : bool SignatureMap::CompareFunctionSigs::operator()(FunctionSig* a,
      33     1641464 :                                                    FunctionSig* b) const {
      34     1298243 :   if (a == b) return false;
      35     1256061 :   if (a->return_count() < b->return_count()) return true;
      36      450359 :   if (a->return_count() > b->return_count()) return false;
      37      173937 :   if (a->parameter_count() < b->parameter_count()) return true;
      38      126830 :   if (a->parameter_count() > b->parameter_count()) return false;
      39       70878 :   for (size_t r = 0; r < a->return_count(); r++) {
      40      103782 :     if (a->GetReturn(r) < b->GetReturn(r)) return true;
      41       78142 :     if (a->GetReturn(r) > b->GetReturn(r)) return false;
      42             :   }
      43       99826 :   for (size_t p = 0; p < a->parameter_count(); p++) {
      44      107684 :     if (a->GetParam(p) < b->GetParam(p)) return true;
      45      101429 :     if (a->GetParam(p) > b->GetParam(p)) return false;
      46             :   }
      47             :   return false;
      48             : }
      49             : 
      50             : }  // namespace wasm
      51             : }  // namespace internal
      52             : }  // namespace v8

Generated by: LCOV version 1.10