Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
type_propagator.h
Go to the documentation of this file.
1// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_COMPILER_BACKEND_TYPE_PROPAGATOR_H_
6#define RUNTIME_VM_COMPILER_BACKEND_TYPE_PROPAGATOR_H_
7
8#if defined(DART_PRECOMPILED_RUNTIME)
9#error "AOT runtime should not use compiler sources (including header files)"
10#endif // defined(DART_PRECOMPILED_RUNTIME)
11
14
15namespace dart {
16
18 public:
19 static void Propagate(FlowGraph* flow_graph);
20
21 private:
22 explicit FlowGraphTypePropagator(FlowGraph* flow_graph);
23
24 void Propagate();
25
26 void PropagateRecursive(BlockEntryInstr* block);
27
28 void RollbackTo(intptr_t rollback_point);
29
30 void VisitValue(Value* value);
31
32 virtual void VisitJoinEntry(JoinEntryInstr* instr);
33 virtual void VisitCheckSmi(CheckSmiInstr* instr);
34 virtual void VisitCheckArrayBound(CheckArrayBoundInstr* instr);
35 virtual void VisitCheckClass(CheckClassInstr* instr);
36 virtual void VisitCheckClassId(CheckClassIdInstr* instr);
37 virtual void VisitCheckNull(CheckNullInstr* instr);
38 virtual void VisitGuardFieldClass(GuardFieldClassInstr* instr);
40 virtual void VisitAssertBoolean(AssertBooleanInstr* instr);
41 virtual void VisitAssertSubtype(AssertSubtypeInstr* instr);
42 virtual void VisitInstanceCall(InstanceCallInstr* instr);
45 virtual void VisitBranch(BranchInstr* instr);
46
47 void CheckNonNullSelector(Instruction* call,
48 Definition* receiver,
49 const String& function_name);
50
51 // Current reaching type of the definition. Valid only during dominator tree
52 // traversal.
53 CompileType* TypeOf(Definition* def);
54
55 // Mark definition as having given compile type in all dominated instructions.
56 void SetTypeOf(Definition* def, CompileType* type);
57
58 // Mark definition as having given class id in all dominated instructions.
59 void SetCid(Definition* value, intptr_t cid);
60
61 // Grow type array up to new index.
62 void GrowTypes(intptr_t up_to);
63
64 // Ensures that redefinition with more accurate type is inserted after given
65 // instruction.
66 void EnsureMoreAccurateRedefinition(Instruction* prev,
67 Definition* original,
68 CompileType new_type);
69
70 void AddToWorklist(Definition* defn);
71 Definition* RemoveLastFromWorklist();
72
73 // Type assertion strengthening.
74 void StrengthenAsserts(BlockEntryInstr* block);
75 void StrengthenAssertWith(Instruction* check);
76
77 Zone* zone() const { return flow_graph_->zone(); }
78
79 FlowGraph* flow_graph_;
80 const bool is_aot_;
81
82 BitVector* visited_blocks_;
83
84 // Mapping between SSA values and their current reaching types. Valid
85 // only during dominator tree traversal.
87
88 // Worklist for fixpoint computation.
90 BitVector* in_worklist_;
91
93 ZoneGrowableArray<intptr_t>* collected_asserts_;
94
95 // RollbackEntry is used to track and rollback changed in the types_ array
96 // done during dominator tree traversal.
97 class RollbackEntry {
98 public:
99 // Default constructor needed for the container.
100 RollbackEntry() : index_(), type_() {}
101
102 RollbackEntry(intptr_t index, CompileType* type)
103 : index_(index), type_(type) {}
104
105 intptr_t index() const { return index_; }
106 CompileType* type() const { return type_; }
107
108 private:
109 intptr_t index_;
110 CompileType* type_;
111 };
112
114};
115
116} // namespace dart
117
118#endif // RUNTIME_VM_COMPILER_BACKEND_TYPE_PROPAGATOR_H_
static float prev(float f)
#define check(reporter, ref, unref, make, kill)
virtual void VisitPolymorphicInstanceCall(PolymorphicInstanceCallInstr *instr)
virtual void VisitAssertBoolean(AssertBooleanInstr *instr)
virtual void VisitCheckClassId(CheckClassIdInstr *instr)
virtual void VisitCheckNull(CheckNullInstr *instr)
virtual void VisitCheckSmi(CheckSmiInstr *instr)
static void Propagate(FlowGraph *flow_graph)
virtual void VisitAssertSubtype(AssertSubtypeInstr *instr)
virtual void VisitAssertAssignable(AssertAssignableInstr *instr)
virtual void VisitJoinEntry(JoinEntryInstr *instr)
virtual void VisitGuardFieldClass(GuardFieldClassInstr *instr)
virtual void VisitInstanceCall(InstanceCallInstr *instr)
virtual void VisitCheckArrayBound(CheckArrayBoundInstr *instr)
virtual void VisitBranch(BranchInstr *instr)
virtual void VisitCheckClass(CheckClassInstr *instr)
Zone * zone() const
Definition flow_graph.h:261
uint8_t value
const intptr_t cid
const char *const function_name