diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit/BitSet.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit/BitSet.cpp')
-rw-r--r-- | js/src/jit/BitSet.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/js/src/jit/BitSet.cpp b/js/src/jit/BitSet.cpp new file mode 100644 index 000000000..6171a1b17 --- /dev/null +++ b/js/src/jit/BitSet.cpp @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sts=4 et sw=4 tw=99: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "jit/BitSet.h" + +using namespace js; +using namespace js::jit; + +bool +BitSet::init(TempAllocator& alloc) +{ + size_t sizeRequired = numWords() * sizeof(*bits_); + + bits_ = (uint32_t*)alloc.allocate(sizeRequired); + if (!bits_) + return false; + + memset(bits_, 0, sizeRequired); + + return true; +} + +bool +BitSet::empty() const +{ + MOZ_ASSERT(bits_); + const uint32_t* bits = bits_; + for (unsigned int i = 0, e = numWords(); i < e; i++) { + if (bits[i]) + return false; + } + return true; +} + +void +BitSet::insertAll(const BitSet& other) +{ + MOZ_ASSERT(bits_); + MOZ_ASSERT(other.numBits_ == numBits_); + MOZ_ASSERT(other.bits_); + + uint32_t* bits = bits_; + const uint32_t* otherBits = other.bits_; + for (unsigned int i = 0, e = numWords(); i < e; i++) + bits[i] |= otherBits[i]; +} + +void +BitSet::removeAll(const BitSet& other) +{ + MOZ_ASSERT(bits_); + MOZ_ASSERT(other.numBits_ == numBits_); + MOZ_ASSERT(other.bits_); + + uint32_t* bits = bits_; + const uint32_t* otherBits = other.bits_; + for (unsigned int i = 0, e = numWords(); i < e; i++) + bits[i] &= ~otherBits[i]; +} + +void +BitSet::intersect(const BitSet& other) +{ + MOZ_ASSERT(bits_); + MOZ_ASSERT(other.numBits_ == numBits_); + MOZ_ASSERT(other.bits_); + + uint32_t* bits = bits_; + const uint32_t* otherBits = other.bits_; + for (unsigned int i = 0, e = numWords(); i < e; i++) + bits[i] &= otherBits[i]; +} + +// returns true if the intersection caused the contents of the set to change. +bool +BitSet::fixedPointIntersect(const BitSet& other) +{ + MOZ_ASSERT(bits_); + MOZ_ASSERT(other.numBits_ == numBits_); + MOZ_ASSERT(other.bits_); + + bool changed = false; + + uint32_t* bits = bits_; + const uint32_t* otherBits = other.bits_; + for (unsigned int i = 0, e = numWords(); i < e; i++) { + uint32_t old = bits[i]; + bits[i] &= otherBits[i]; + + if (!changed && old != bits[i]) + changed = true; + } + return changed; +} + +void +BitSet::complement() +{ + MOZ_ASSERT(bits_); + uint32_t* bits = bits_; + for (unsigned int i = 0, e = numWords(); i < e; i++) + bits[i] = ~bits[i]; +} + +void +BitSet::clear() +{ + MOZ_ASSERT(bits_); + uint32_t* bits = bits_; + for (unsigned int i = 0, e = numWords(); i < e; i++) + bits[i] = 0; +} |