Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
flow_graph_builder.h
Go to the documentation of this file.
1// Copyright (c) 2012, 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_FRONTEND_FLOW_GRAPH_BUILDER_H_
6#define RUNTIME_VM_COMPILER_FRONTEND_FLOW_GRAPH_BUILDER_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
12#include "platform/assert.h"
13#include "platform/globals.h"
14#include "vm/allocation.h"
17#include "vm/growable_array.h"
18#include "vm/raw_object.h"
19
20namespace dart {
21
22// A class to collect the exits from an inlined function during graph
23// construction so they can be plugged into the caller's flow graph.
25 public:
27 : caller_graph_(caller_graph), call_(call), exits_(4) {}
28
29 void AddExit(DartReturnInstr* exit);
30
31 void Union(const InlineExitCollector* other);
32
33 // Before replacing a call with a graph, the outer environment needs to be
34 // attached to each instruction in the callee graph and the caller graph
35 // needs to have its block and instruction ID state updated.
36 // Additionally we need to remove all unreachable exits from the list of
37 // collected exits.
38 void PrepareGraphs(FlowGraph* callee_graph);
39
40 // Inline a graph at a call site.
41 //
42 // Assumes the callee is in SSA with a correct dominator tree and use
43 // lists.
44 //
45 // After inlining the caller graph will have correctly adjusted the use
46 // lists. The block orders will need to be recomputed.
47 void ReplaceCall(BlockEntryInstr* callee_entry);
48
49 private:
50 struct Data {
51 BlockEntryInstr* exit_block;
52 DartReturnInstr* exit_return;
53 };
54
55 BlockEntryInstr* ExitBlockAt(intptr_t i) const {
56 ASSERT(exits_[i].exit_block != nullptr);
57 return exits_[i].exit_block;
58 }
59
60 Instruction* LastInstructionAt(intptr_t i) const {
61 return ReturnAt(i)->previous();
62 }
63
64 Value* ValueAt(intptr_t i) const { return ReturnAt(i)->value(); }
65
66 DartReturnInstr* ReturnAt(intptr_t i) const { return exits_[i].exit_return; }
67
68 static int LowestBlockIdFirst(const Data* a, const Data* b);
69 void SortExits();
70 void RemoveUnreachableExits(FlowGraph* callee_graph);
71
72 Definition* JoinReturns(BlockEntryInstr** exit_block,
73 Instruction** last_instruction,
74 intptr_t try_index);
75
76 Zone* zone() const { return caller_graph_->zone(); }
77
78 FlowGraph* caller_graph_;
79 Definition* call_;
80 GrowableArray<Data> exits_;
81};
82
83bool SimpleInstanceOfType(const AbstractType& type);
84uword FindDoubleConstant(double value);
85
86} // namespace dart
87
88#endif // RUNTIME_VM_COMPILER_FRONTEND_FLOW_GRAPH_BUILDER_H_
Value * value() const
Definition il.h:3468
Zone * zone() const
Definition flow_graph.h:261
InlineExitCollector(FlowGraph *caller_graph, Definition *call)
void Union(const InlineExitCollector *other)
void PrepareGraphs(FlowGraph *callee_graph)
void AddExit(DartReturnInstr *exit)
void ReplaceCall(BlockEntryInstr *callee_entry)
Instruction * previous() const
Definition il.h:1081
#define ASSERT(E)
static bool b
struct MyStruct a[10]
uword FindDoubleConstant(double value)
bool SimpleInstanceOfType(const AbstractType &type)
uintptr_t uword
Definition globals.h:501