Chromium Code Reviews| Index: runtime/vm/flow_graph_type_propagator.h |
| diff --git a/runtime/vm/flow_graph_type_propagator.h b/runtime/vm/flow_graph_type_propagator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8275bd3f6602b9f15219a716f6cf144161a4370e |
| --- /dev/null |
| +++ b/runtime/vm/flow_graph_type_propagator.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +#ifndef VM_FLOW_GRAPH_TYPE_PROPAGATOR_H_ |
| +#define VM_FLOW_GRAPH_TYPE_PROPAGATOR_H_ |
| + |
| +#include "vm/intermediate_language.h" |
| +#include "vm/flow_graph.h" |
|
srdjan
2013/02/11 20:54:31
Order alphabetically
Vyacheslav Egorov (Google)
2013/02/18 14:05:22
Done.
|
| + |
| +namespace dart { |
| + |
|
regis
2013/02/11 19:51:49
We use a single blank line after namespace. Do not
Vyacheslav Egorov (Google)
2013/02/18 14:05:22
Done.
|
| + |
| +class FlowGraphTypePropagator : public FlowGraphVisitor { |
| + public: |
| + explicit FlowGraphTypePropagator(FlowGraph* flow_graph); |
| + |
| + void Propagate(); |
| + |
| + private: |
| + void PropagateRecursive(BlockEntryInstr* block); |
| + |
| + void VisitValue(Value* value); |
| + |
| + virtual void VisitJoinEntry(JoinEntryInstr* instr); |
| + virtual void VisitCheckSmi(CheckSmiInstr* instr); |
| + virtual void VisitCheckClass(CheckClassInstr* instr); |
| + |
| + // Current reaching type of the definition. Valid only during dominator tree |
| + // traversal. |
| + CompileType* TypeOf(Definition* def); |
| + |
| + // Mark definition as having given compile type in all dominated instructions. |
| + void SetTypeOf(Definition* def, CompileType* type); |
| + |
| + // Mark definition as having given class id in all dominated instructions. |
| + void SetCid(Definition* value, intptr_t cid); |
| + |
| + void AddToWorklist(Definition* defn); |
| + Definition* RemoveLastFromWorklist(); |
| + |
| + FlowGraph* flow_graph_; |
| + |
| + // Mapping between SSA values and their current reaching types. Valid |
| + // only during dominator tree traversal. |
| + GrowableArray<CompileType*> types_; |
| + |
| + // Worklist for fixpoint computation. |
| + GrowableArray<Definition*> worklist_; |
| + BitVector* in_worklist_; |
| + |
| + // RollbackEntry is used to track and rollback changed in the types_ array |
| + // done during dominator tree traversal. |
| + struct RollbackEntry { |
| + public: |
| + RollbackEntry() { |
| + // Do nothing. Only needed for container. |
|
srdjan
2013/02/11 20:54:31
intialize the fields nonetheless.
Vyacheslav Egorov (Google)
2013/02/18 14:05:22
Done.
|
| + } |
| + |
| + RollbackEntry(intptr_t index, CompileType* type) |
| + : index_(index), type_(type) { |
| + } |
| + |
| + intptr_t index() const { return index_; } |
| + CompileType* type() const { return type_; } |
| + |
| + private: |
| + intptr_t index_; |
| + CompileType* type_; |
| + }; |
| + |
| + GrowableArray<RollbackEntry> rollback_; |
| +}; |
| + |
|
regis
2013/02/11 19:51:49
ditto before namespace.
Vyacheslav Egorov (Google)
2013/02/18 14:05:22
Done.
|
| + |
| +} // namespace dart |
| + |
| +#endif // VM_FLOW_GRAPH_TYPE_PROPAGATOR_H_ |