Index: runtime/vm/flow_graph.h |
diff --git a/runtime/vm/flow_graph.h b/runtime/vm/flow_graph.h |
index 45d64a7f8e41b1be53e2418c4eb6ddca97780b8f..cab5bbe245cd1ba70fc1508a6a64ec03727eec68 100644 |
--- a/runtime/vm/flow_graph.h |
+++ b/runtime/vm/flow_graph.h |
@@ -5,6 +5,7 @@ |
#ifndef VM_FLOW_GRAPH_H_ |
#define VM_FLOW_GRAPH_H_ |
+#include "vm/bit_vector.h" |
#include "vm/growable_array.h" |
#include "vm/hash_map.h" |
#include "vm/intermediate_language.h" |
@@ -443,6 +444,52 @@ class BlockEffects : public ZoneAllocated { |
}; |
+class DefinitionWorklist : public ValueObject { |
+ public: |
+ DefinitionWorklist(FlowGraph* flow_graph, |
+ intptr_t initial_capacity) |
+ : defs_(initial_capacity), |
+ contains_vector_( |
+ new BitVector(flow_graph->isolate(), |
+ flow_graph->current_ssa_temp_index())) { |
+ } |
+ |
+ void Add(Definition* defn) { |
+ if (!Contains(defn)) { |
+ defs_.Add(defn); |
+ contains_vector_->Add(defn->ssa_temp_index()); |
+ } |
+ } |
+ |
+ bool Contains(Definition* defn) const { |
+ return (defn->ssa_temp_index() >= 0) && |
+ contains_vector_->Contains(defn->ssa_temp_index()); |
+ } |
+ |
+ bool IsEmpty() const { |
+ return defs_.is_empty(); |
+ } |
+ |
+ Definition* RemoveLast() { |
+ Definition* defn = defs_.RemoveLast(); |
+ contains_vector_->Remove(defn->ssa_temp_index()); |
+ return defn; |
+ } |
+ |
+ const GrowableArray<Definition*>& definitions() const { return defs_; } |
+ BitVector* contains_vector() const { return contains_vector_; } |
+ |
+ void Clear() { |
+ defs_.TruncateTo(0); |
+ contains_vector_->Clear(); |
+ } |
+ |
+ private: |
+ GrowableArray<Definition*> defs_; |
+ BitVector* contains_vector_; |
+}; |
+ |
+ |
} // namespace dart |
#endif // VM_FLOW_GRAPH_H_ |