LCOV - code coverage report
Current view: top level - js/src/jit - BitSet.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 27 66 40.9 %
Date: 2017-07-14 16:53:18 Functions: 4 8 50.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             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "jit/BitSet.h"
       8             : 
       9             : using namespace js;
      10             : using namespace js::jit;
      11             : 
      12             : bool
      13         427 : BitSet::init(TempAllocator& alloc)
      14             : {
      15         427 :     size_t sizeRequired = numWords() * sizeof(*bits_);
      16             : 
      17         427 :     bits_ = (uint32_t*)alloc.allocate(sizeRequired);
      18         427 :     if (!bits_)
      19           0 :         return false;
      20             : 
      21         427 :     memset(bits_, 0, sizeRequired);
      22             : 
      23         427 :     return true;
      24             : }
      25             : 
      26             : bool
      27          11 : BitSet::empty() const
      28             : {
      29          11 :     MOZ_ASSERT(bits_);
      30          11 :     const uint32_t* bits = bits_;
      31          76 :     for (unsigned int i = 0, e = numWords(); i < e; i++) {
      32          65 :         if (bits[i])
      33           0 :             return false;
      34             :     }
      35          11 :     return true;
      36             : }
      37             : 
      38             : void
      39         767 : BitSet::insertAll(const BitSet& other)
      40             : {
      41         767 :     MOZ_ASSERT(bits_);
      42         767 :     MOZ_ASSERT(other.numBits_ == numBits_);
      43         767 :     MOZ_ASSERT(other.bits_);
      44             : 
      45         767 :     uint32_t* bits = bits_;
      46         767 :     const uint32_t* otherBits = other.bits_;
      47        8407 :     for (unsigned int i = 0, e = numWords(); i < e; i++)
      48        7640 :         bits[i] |= otherBits[i];
      49         767 : }
      50             : 
      51             : void
      52           0 : BitSet::removeAll(const BitSet& other)
      53             : {
      54           0 :     MOZ_ASSERT(bits_);
      55           0 :     MOZ_ASSERT(other.numBits_ == numBits_);
      56           0 :     MOZ_ASSERT(other.bits_);
      57             : 
      58           0 :     uint32_t* bits = bits_;
      59           0 :     const uint32_t* otherBits = other.bits_;
      60           0 :     for (unsigned int i = 0, e = numWords(); i < e; i++)
      61           0 :         bits[i] &= ~otherBits[i];
      62           0 : }
      63             : 
      64             : void
      65           0 : BitSet::intersect(const BitSet& other)
      66             : {
      67           0 :     MOZ_ASSERT(bits_);
      68           0 :     MOZ_ASSERT(other.numBits_ == numBits_);
      69           0 :     MOZ_ASSERT(other.bits_);
      70             : 
      71           0 :     uint32_t* bits = bits_;
      72           0 :     const uint32_t* otherBits = other.bits_;
      73           0 :     for (unsigned int i = 0, e = numWords(); i < e; i++)
      74           0 :         bits[i] &= otherBits[i];
      75           0 : }
      76             : 
      77             : // returns true if the intersection caused the contents of the set to change.
      78             : bool
      79           0 : BitSet::fixedPointIntersect(const BitSet& other)
      80             : {
      81           0 :     MOZ_ASSERT(bits_);
      82           0 :     MOZ_ASSERT(other.numBits_ == numBits_);
      83           0 :     MOZ_ASSERT(other.bits_);
      84             : 
      85           0 :     bool changed = false;
      86             : 
      87           0 :     uint32_t* bits = bits_;
      88           0 :     const uint32_t* otherBits = other.bits_;
      89           0 :     for (unsigned int i = 0, e = numWords(); i < e; i++) {
      90           0 :         uint32_t old = bits[i];
      91           0 :         bits[i] &= otherBits[i];
      92             : 
      93           0 :         if (!changed && old != bits[i])
      94           0 :             changed = true;
      95             :     }
      96           0 :     return changed;
      97             : }
      98             : 
      99             : void
     100           0 : BitSet::complement()
     101             : {
     102           0 :     MOZ_ASSERT(bits_);
     103           0 :     uint32_t* bits = bits_;
     104           0 :     for (unsigned int i = 0, e = numWords(); i < e; i++)
     105           0 :         bits[i] = ~bits[i];
     106           0 : }
     107             : 
     108             : void
     109         161 : BitSet::clear()
     110             : {
     111         161 :     MOZ_ASSERT(bits_);
     112         161 :     uint32_t* bits = bits_;
     113         347 :     for (unsigned int i = 0, e = numWords(); i < e; i++)
     114         186 :         bits[i] = 0;
     115         161 : }

Generated by: LCOV version 1.13