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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/SConscript » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_DATAFLOW_H_ 28 #ifndef V8_DATAFLOW_H_
29 #define V8_DATAFLOW_H_ 29 #define V8_DATAFLOW_H_
30 30
31 #include "v8.h"
32
31 #include "ast.h" 33 #include "ast.h"
32 #include "compiler.h" 34 #include "compiler.h"
33 35
34 namespace v8 { 36 namespace v8 {
35 namespace internal { 37 namespace internal {
36 38
39 class BitVector {
40 public:
41 explicit BitVector(int length) : length_(length) {
42 ASSERT(length > 0);
43 bits_ = Vector<uint32_t>::New(1 + length / 32);
44 for (int i = 0; i < bits_.length(); i++) {
45 bits_[i] = 0;
46 }
47 }
48
49 ~BitVector() { bits_.Dispose(); }
50
51 void CopyFrom(const BitVector& other) {
52 ASSERT(other.length() == length());
53 for (int i = 0; i < bits_.length(); i++) {
54 bits_[i] = other.bits_[i];
55 }
56 }
57
58 bool Contains(int i) {
59 ASSERT(i >= 0 && i < length());
60 uint32_t block = bits_[i / 32];
61 return (block & (1U << (i % 32))) != 0;
62 }
63
64 void Add(int i) {
65 ASSERT(i >= 0 && i < length());
66 bits_[i / 32] |= (1U << (i % 32));
67 }
68
69 void Remove(int i) {
70 ASSERT(i >= 0 && i < length());
71 bits_[i / 32] &= ~(1U << (i % 32));
72 }
73
74 void Union(const BitVector& other) {
75 ASSERT(other.length() == length());
76 for (int i = 0; i < bits_.length(); i++) {
77 bits_[i] |= other.bits_[i];
78 }
79 }
80
81 void Intersect(const BitVector& other) {
82 ASSERT(other.length() == length());
83 for (int i = 0; i < bits_.length(); i++) {
84 bits_[i] &= other.bits_[i];
85 }
86 }
87
88 int length() const { return length_; }
89
90 private:
91 int length_;
92 Vector<uint32_t> bits_;
93
94 DISALLOW_COPY_AND_ASSIGN(BitVector);
95 };
96
97
37 // This class is used to number all expressions in the AST according to 98 // This class is used to number all expressions in the AST according to
38 // their evaluation order (post-order left-to-right traversal). 99 // their evaluation order (post-order left-to-right traversal).
39 class AstLabeler: public AstVisitor { 100 class AstLabeler: public AstVisitor {
40 public: 101 public:
41 AstLabeler() : next_number_(0) {} 102 AstLabeler() : next_number_(0) {}
42 103
43 void Label(CompilationInfo* info); 104 void Label(CompilationInfo* info);
44 105
45 private: 106 private:
46 CompilationInfo* info() { return info_; } 107 CompilationInfo* info() { return info_; }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 VarUseMap live_vars_; 169 VarUseMap live_vars_;
109 170
110 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); 171 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer);
111 }; 172 };
112 173
113 174
114 } } // namespace v8::internal 175 } } // namespace v8::internal
115 176
116 177
117 #endif // V8_DATAFLOW_H_ 178 #endif // V8_DATAFLOW_H_
OLDNEW
« 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