Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: src/data-flow.h

Issue 660321: Implementation of a fixed-size bit vector.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/SConscript » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/data-flow.h
===================================================================
--- src/data-flow.h (revision 3989)
+++ src/data-flow.h (working copy)
@@ -28,12 +28,73 @@
#ifndef V8_DATAFLOW_H_
#define V8_DATAFLOW_H_
+#include "v8.h"
+
#include "ast.h"
#include "compiler.h"
namespace v8 {
namespace internal {
+class BitVector {
+ public:
+ explicit BitVector(int length) : length_(length) {
+ ASSERT(length > 0);
+ bits_ = Vector<uint32_t>::New(1 + length / 32);
+ for (int i = 0; i < bits_.length(); i++) {
+ bits_[i] = 0;
+ }
+ }
+
+ ~BitVector() { bits_.Dispose(); }
+
+ void CopyFrom(const BitVector& other) {
+ ASSERT(other.length() == length());
+ for (int i = 0; i < bits_.length(); i++) {
+ bits_[i] = other.bits_[i];
+ }
+ }
+
+ bool Contains(int i) {
+ ASSERT(i >= 0 && i < length());
+ uint32_t block = bits_[i / 32];
+ return (block & (1U << (i % 32))) != 0;
+ }
+
+ void Add(int i) {
+ ASSERT(i >= 0 && i < length());
+ bits_[i / 32] |= (1U << (i % 32));
+ }
+
+ void Remove(int i) {
+ ASSERT(i >= 0 && i < length());
+ bits_[i / 32] &= ~(1U << (i % 32));
+ }
+
+ void Union(const BitVector& other) {
+ ASSERT(other.length() == length());
+ for (int i = 0; i < bits_.length(); i++) {
+ bits_[i] |= other.bits_[i];
+ }
+ }
+
+ void Intersect(const BitVector& other) {
+ ASSERT(other.length() == length());
+ for (int i = 0; i < bits_.length(); i++) {
+ bits_[i] &= other.bits_[i];
+ }
+ }
+
+ int length() const { return length_; }
+
+ private:
+ int length_;
+ Vector<uint32_t> bits_;
+
+ DISALLOW_COPY_AND_ASSIGN(BitVector);
+};
+
+
// This class is used to number all expressions in the AST according to
// their evaluation order (post-order left-to-right traversal).
class AstLabeler: public AstVisitor {
« no previous file with comments | « no previous file | test/cctest/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698