Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::compiler::BlockBuilder Class Reference

#include <block_builder.h>

Inheritance diagram for dart::compiler::BlockBuilder:
dart::ValueObject

Public Member Functions

 BlockBuilder (FlowGraph *flow_graph, BlockEntryInstr *entry, bool with_frame=true)
 
DefinitionAddToInitialDefinitions (Definition *def)
 
template<typename T >
TAddDefinition (T *def)
 
template<typename T >
TAddInstruction (T *instr)
 
const Functionfunction () const
 
DartReturnInstrAddReturn (Value *value)
 
DartReturnInstrAddReturn (Value *value, Representation representation)
 
DefinitionAddParameter (intptr_t index)
 
DefinitionAddParameter (intptr_t index, Representation representation, Location location=Location())
 
TokenPosition TokenPos () const
 
const InstructionSourceSource () const
 
DefinitionAddNullDefinition ()
 
DefinitionAddUnboxInstr (Representation rep, Value *value, bool is_checked)
 
DefinitionAddUnboxInstr (Representation rep, Definition *boxed, bool is_checked)
 
BranchInstrAddBranch (ComparisonInstr *comp, TargetEntryInstr *true_successor, TargetEntryInstr *false_successor)
 
void AddPhi (PhiInstr *phi)
 
Instructionlast () const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 19 of file block_builder.h.

Constructor & Destructor Documentation

◆ BlockBuilder()

dart::compiler::BlockBuilder::BlockBuilder ( FlowGraph flow_graph,
BlockEntryInstr entry,
bool  with_frame = true 
)
inline

Definition at line 21 of file block_builder.h.

24 : flow_graph_(flow_graph),
25 source_(InstructionSource(flow_graph_->function().token_pos(),
26 flow_graph->inlining_id())),
27 entry_(entry),
28 current_(entry),
29 dummy_env_(new Environment(0, 0, 0, flow_graph->function(), nullptr)),
30 with_frame_(with_frame) {
31 // Some graph transformations use environments from block entries.
32 entry->SetEnvironment(dummy_env_);
33 }
const Function & function() const
Definition: flow_graph.h:130
TokenPosition token_pos() const
Definition: object.h:3446

Member Function Documentation

◆ AddBranch()

BranchInstr * dart::compiler::BlockBuilder::AddBranch ( ComparisonInstr comp,
TargetEntryInstr true_successor,
TargetEntryInstr false_successor 
)
inline

Definition at line 136 of file block_builder.h.

138 {
139 auto branch =
140 new BranchInstr(comp, CompilerState::Current().GetNextDeoptId());
141 // Some graph transformations use environments from branches.
142 branch->SetEnvironment(dummy_env_);
143 current_->AppendInstruction(branch);
144 current_ = nullptr;
145
146 *branch->true_successor_address() = true_successor;
147 *branch->false_successor_address() = false_successor;
148
149 return branch;
150 }
static CompilerState & Current()
Instruction * AppendInstruction(Instruction *tail)
Definition: il.cc:1341

◆ AddDefinition()

template<typename T >
T * dart::compiler::BlockBuilder::AddDefinition ( T def)
inline

Definition at line 43 of file block_builder.h.

43 {
44 flow_graph_->AllocateSSAIndex(def);
45 AddInstruction(def);
46 return def;
47 }
void AllocateSSAIndex(Definition *def)
Definition: flow_graph.h:274

◆ AddInstruction()

template<typename T >
T * dart::compiler::BlockBuilder::AddInstruction ( T instr)
inline

Definition at line 50 of file block_builder.h.

50 {
51 if (instr->ComputeCanDeoptimize() ||
52 instr->ComputeCanDeoptimizeAfterCall() ||
53 instr->CanBecomeDeoptimizationTarget()) {
54 // All instructions that can deoptimize must have an environment attached
55 // to them.
56 instr->SetEnvironment(dummy_env_);
57 }
58 current_ = current_->AppendInstruction(instr);
59 return instr;
60 }

◆ AddNullDefinition()

Definition * dart::compiler::BlockBuilder::AddNullDefinition ( )
inline

Definition at line 99 of file block_builder.h.

99 {
100 return flow_graph_->GetConstant(Object::ZoneHandle());
101 }
ConstantInstr * GetConstant(const Object &object, Representation representation=kTagged)
Definition: flow_graph.cc:187
static Object & ZoneHandle()
Definition: object.h:419

◆ AddParameter() [1/2]

Definition * dart::compiler::BlockBuilder::AddParameter ( intptr_t  index)
inline

Definition at line 79 of file block_builder.h.

79 {
80 const auto [location, representation] =
81 flow_graph_->GetDirectParameterInfoAt(index);
82 return AddParameter(index, representation,
83 with_frame_ ? location : location.ToEntrySpRelative());
84 }
const std::pair< Location, Representation > & GetDirectParameterInfoAt(intptr_t i)
Definition: flow_graph.h:571
Definition * AddParameter(intptr_t index)
Definition: block_builder.h:79

◆ AddParameter() [2/2]

Definition * dart::compiler::BlockBuilder::AddParameter ( intptr_t  index,
Representation  representation,
Location  location = Location() 
)
inline

Definition at line 86 of file block_builder.h.

88 {
89 auto normal_entry = flow_graph_->graph_entry()->normal_entry();
91 new ParameterInstr(normal_entry,
92 /*env_index=*/index,
93 /*param_index=*/index, location, representation));
94 }
GraphEntryInstr * graph_entry() const
Definition: flow_graph.h:268
FunctionEntryInstr * normal_entry() const
Definition: il.h:2001
Definition * AddToInitialDefinitions(Definition *def)
Definition: block_builder.h:35

◆ AddPhi()

void dart::compiler::BlockBuilder::AddPhi ( PhiInstr phi)
inline

Definition at line 152 of file block_builder.h.

152 {
153 flow_graph_->AllocateSSAIndex(phi);
154 phi->mark_alive();
155 entry_->AsJoinEntry()->InsertPhi(phi);
156 }

◆ AddReturn() [1/2]

DartReturnInstr * dart::compiler::BlockBuilder::AddReturn ( Value value)
inline

Definition at line 64 of file block_builder.h.

64 {
65 const auto& function = flow_graph_->function();
66 const auto representation = FlowGraph::ReturnRepresentationOf(function);
67 return AddReturn(value, representation);
68 }
static Representation ReturnRepresentationOf(const Function &function)
Definition: flow_graph.cc:125
DartReturnInstr * AddReturn(Value *value)
Definition: block_builder.h:64
const Function & function() const
Definition: block_builder.h:62
uint8_t value

◆ AddReturn() [2/2]

DartReturnInstr * dart::compiler::BlockBuilder::AddReturn ( Value value,
Representation  representation 
)
inline

Definition at line 70 of file block_builder.h.

70 {
71 DartReturnInstr* instr = new DartReturnInstr(
72 Source(), value, CompilerState::Current().GetNextDeoptId(),
73 representation);
74 AddInstruction(instr);
75 entry_->set_last_instruction(instr);
76 return instr;
77 }
void set_last_instruction(Instruction *instr)
Definition: il.h:1687
const InstructionSource & Source() const
Definition: block_builder.h:97

◆ AddToInitialDefinitions()

Definition * dart::compiler::BlockBuilder::AddToInitialDefinitions ( Definition def)
inline

Definition at line 35 of file block_builder.h.

35 {
36 flow_graph_->AllocateSSAIndex(def);
37 auto normal_entry = flow_graph_->graph_entry()->normal_entry();
38 flow_graph_->AddToInitialDefinitions(normal_entry, def);
39 return def;
40 }
void AddToInitialDefinitions(BlockEntryWithInitialDefs *entry, Definition *defn)
Definition: flow_graph.cc:263

◆ AddUnboxInstr() [1/2]

Definition * dart::compiler::BlockBuilder::AddUnboxInstr ( Representation  rep,
Definition boxed,
bool  is_checked 
)
inline

Definition at line 130 of file block_builder.h.

132 {
133 return AddUnboxInstr(rep, new Value(boxed), is_checked);
134 }
Definition * AddUnboxInstr(Representation rep, Value *value, bool is_checked)

◆ AddUnboxInstr() [2/2]

Definition * dart::compiler::BlockBuilder::AddUnboxInstr ( Representation  rep,
Value value,
bool  is_checked 
)
inline

Definition at line 103 of file block_builder.h.

103 {
104 // Unbox floats by first unboxing a double then converting it to a float.
105 auto const unbox_rep = rep == kUnboxedFloat
106 ? kUnboxedDouble
108 Definition* unboxed_value =
110 if (rep != unbox_rep && unboxed_value->IsUnboxInteger()) {
113 // Mark unboxing of small unboxed integer representations as truncating.
114 unboxed_value->AsUnboxInteger()->mark_truncating();
115 }
116 if (is_checked) {
117 // The type of |value| has already been checked and it is safe to
118 // adjust reaching type. This is done manually because there is no type
119 // propagation when building intrinsics.
120 unboxed_value->AsUnbox()->value()->SetReachingType(
121 new CompileType(CompileType::FromUnboxedRepresentation(rep)));
122 }
123 if (rep == kUnboxedFloat) {
124 unboxed_value = AddDefinition(
125 new DoubleToFloatInstr(new Value(unboxed_value), DeoptId::kNone));
126 }
127 return unboxed_value;
128 }
static CompileType FromUnboxedRepresentation(Representation rep)
static constexpr intptr_t kNone
Definition: deopt_id.h:27
static UnboxInstr * Create(Representation to, Value *value, intptr_t deopt_id, SpeculativeMode speculative_mode=kGuardInputs)
Definition: il.cc:4043
#define ASSERT(E)
static constexpr Representation NativeRepresentation(Representation rep)
Definition: il.h:8504
static constexpr size_t ValueSize(Representation rep)
Definition: locations.h:112

◆ function()

const Function & dart::compiler::BlockBuilder::function ( ) const
inline

Definition at line 62 of file block_builder.h.

62{ return flow_graph_->function(); }

◆ last()

Instruction * dart::compiler::BlockBuilder::last ( ) const
inline

Definition at line 158 of file block_builder.h.

158{ return current_; }

◆ Source()

const InstructionSource & dart::compiler::BlockBuilder::Source ( ) const
inline

Definition at line 97 of file block_builder.h.

97{ return source_; }

◆ TokenPos()

TokenPosition dart::compiler::BlockBuilder::TokenPos ( ) const
inline

Definition at line 96 of file block_builder.h.

96{ return source_.token_pos; }
const TokenPosition token_pos

The documentation for this class was generated from the following file: