| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 #define V8_DATAFLOW_H_ | 29 #define V8_DATAFLOW_H_ |
| 30 | 30 |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 | 32 |
| 33 #include "ast.h" | 33 #include "ast.h" |
| 34 #include "compiler.h" | 34 #include "compiler.h" |
| 35 | 35 |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 class BitVector { | 39 class BitVector BASE_EMBEDDED { |
| 40 public: | 40 public: |
| 41 explicit BitVector(int length) : length_(length) { | 41 explicit BitVector(int length) |
| 42 : length_(length), bits_(Vector<uint32_t>::New(1 + length / 32)) { |
| 42 ASSERT(length > 0); | 43 ASSERT(length > 0); |
| 43 bits_ = Vector<uint32_t>::New(1 + length / 32); | |
| 44 for (int i = 0; i < bits_.length(); i++) { | 44 for (int i = 0; i < bits_.length(); i++) { |
| 45 bits_[i] = 0; | 45 bits_[i] = 0; |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 BitVector(const BitVector& other) |
| 50 : length_(other.length()), |
| 51 bits_(Vector<uint32_t>::New(1 + other.length() / 32)) { |
| 52 CopyFrom(other); |
| 53 } |
| 54 |
| 49 ~BitVector() { bits_.Dispose(); } | 55 ~BitVector() { bits_.Dispose(); } |
| 50 | 56 |
| 57 BitVector& operator=(const BitVector& rhs) { |
| 58 if (this != &rhs) CopyFrom(rhs); |
| 59 return *this; |
| 60 } |
| 61 |
| 51 void CopyFrom(const BitVector& other) { | 62 void CopyFrom(const BitVector& other) { |
| 52 ASSERT(other.length() == length()); | 63 ASSERT(other.length() == length()); |
| 53 for (int i = 0; i < bits_.length(); i++) { | 64 for (int i = 0; i < bits_.length(); i++) { |
| 54 bits_[i] = other.bits_[i]; | 65 bits_[i] = other.bits_[i]; |
| 55 } | 66 } |
| 56 } | 67 } |
| 57 | 68 |
| 58 bool Contains(int i) { | 69 bool Contains(int i) { |
| 59 ASSERT(i >= 0 && i < length()); | 70 ASSERT(i >= 0 && i < length()); |
| 60 uint32_t block = bits_[i / 32]; | 71 uint32_t block = bits_[i / 32]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 78 } | 89 } |
| 79 } | 90 } |
| 80 | 91 |
| 81 void Intersect(const BitVector& other) { | 92 void Intersect(const BitVector& other) { |
| 82 ASSERT(other.length() == length()); | 93 ASSERT(other.length() == length()); |
| 83 for (int i = 0; i < bits_.length(); i++) { | 94 for (int i = 0; i < bits_.length(); i++) { |
| 84 bits_[i] &= other.bits_[i]; | 95 bits_[i] &= other.bits_[i]; |
| 85 } | 96 } |
| 86 } | 97 } |
| 87 | 98 |
| 99 void Clear() { |
| 100 for (int i = 0; i < bits_.length(); i++) { |
| 101 bits_[i] = 0; |
| 102 } |
| 103 } |
| 104 |
| 105 bool IsEmpty() { |
| 106 for (int i = 0; i < bits_.length(); i++) { |
| 107 if (bits_[i] != 0) return false; |
| 108 } |
| 109 return true; |
| 110 } |
| 111 |
| 88 int length() const { return length_; } | 112 int length() const { return length_; } |
| 89 | 113 |
| 90 private: | 114 private: |
| 91 int length_; | 115 int length_; |
| 92 Vector<uint32_t> bits_; | 116 Vector<uint32_t> bits_; |
| 93 | 117 |
| 94 DISALLOW_COPY_AND_ASSIGN(BitVector); | |
| 95 }; | 118 }; |
| 96 | 119 |
| 97 | 120 |
| 98 // Forward declarations of Node types. | 121 // Forward declarations of Node types. |
| 99 class Node; | 122 class Node; |
| 100 class BranchNode; | 123 class BranchNode; |
| 101 class JoinNode; | 124 class JoinNode; |
| 102 | 125 |
| 103 // Flow graphs have a single entry and single exit. The empty flowgraph is | 126 // Flow graphs have a single entry and single exit. The empty flowgraph is |
| 104 // represented by both entry and exit being NULL. | 127 // represented by both entry and exit being NULL. |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 VarUseMap live_vars_; | 485 VarUseMap live_vars_; |
| 463 | 486 |
| 464 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); | 487 DISALLOW_COPY_AND_ASSIGN(LivenessAnalyzer); |
| 465 }; | 488 }; |
| 466 | 489 |
| 467 | 490 |
| 468 } } // namespace v8::internal | 491 } } // namespace v8::internal |
| 469 | 492 |
| 470 | 493 |
| 471 #endif // V8_DATAFLOW_H_ | 494 #endif // V8_DATAFLOW_H_ |
| OLD | NEW |