blob: 5ada93f684252889e8e38c4d4466aad87da3a8c7 [file] [log] [blame]
Nicolas Geoffray818f2102014-02-18 16:43:35 +00001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_OPTIMIZING_BUILDER_H_
18#define ART_COMPILER_OPTIMIZING_BUILDER_H_
19
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010020#include "base/arena_containers.h"
Mathieu Chartierb666f482015-02-18 14:33:14 -080021#include "base/arena_object.h"
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +000022#include "dex_file.h"
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010023#include "dex_file-inl.h"
Nicolas Geoffraye5038322014-07-04 09:41:32 +010024#include "driver/compiler_driver.h"
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000025#include "driver/dex_compilation_unit.h"
Calin Juravle48c2b032014-12-09 18:11:36 +000026#include "optimizing_compiler_stats.h"
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +010027#include "primitive.h"
Dave Allison20dfc792014-06-16 20:44:29 -070028#include "nodes.h"
Nicolas Geoffray818f2102014-02-18 16:43:35 +000029
30namespace art {
31
Nicolas Geoffray818f2102014-02-18 16:43:35 +000032class Instruction;
Andreas Gampee4d4d322014-12-04 09:09:57 -080033class SwitchTable;
Nicolas Geoffray818f2102014-02-18 16:43:35 +000034
35class HGraphBuilder : public ValueObject {
36 public:
David Brazdil5e8b1372015-01-23 14:39:08 +000037 HGraphBuilder(HGraph* graph,
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010038 DexCompilationUnit* dex_compilation_unit,
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000039 const DexCompilationUnit* const outer_compilation_unit,
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010040 const DexFile* dex_file,
Calin Juravle48c2b032014-12-09 18:11:36 +000041 CompilerDriver* driver,
Nicolas Geoffray9523a3e2015-07-17 11:51:28 +000042 OptimizingCompilerStats* compiler_stats,
Mathieu Chartier736b5602015-09-02 14:54:11 -070043 const uint8_t* interpreter_metadata,
44 Handle<mirror::DexCache> dex_cache)
David Brazdil5e8b1372015-01-23 14:39:08 +000045 : arena_(graph->GetArena()),
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010046 branch_targets_(graph->GetArena()->Adapter(kArenaAllocGraphBuilder)),
47 locals_(graph->GetArena()->Adapter(kArenaAllocGraphBuilder)),
Nicolas Geoffray818f2102014-02-18 16:43:35 +000048 entry_block_(nullptr),
49 exit_block_(nullptr),
50 current_block_(nullptr),
David Brazdil5e8b1372015-01-23 14:39:08 +000051 graph_(graph),
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000052 dex_file_(dex_file),
Nicolas Geoffraye5038322014-07-04 09:41:32 +010053 dex_compilation_unit_(dex_compilation_unit),
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010054 compiler_driver_(driver),
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000055 outer_compilation_unit_(outer_compilation_unit),
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +010056 return_type_(Primitive::GetType(dex_compilation_unit_->GetShorty()[0])),
57 code_start_(nullptr),
Calin Juravle48c2b032014-12-09 18:11:36 +000058 latest_result_(nullptr),
Nicolas Geoffray2e7cd752015-07-10 11:38:52 +010059 can_use_baseline_for_string_init_(true),
Nicolas Geoffray9523a3e2015-07-17 11:51:28 +000060 compilation_stats_(compiler_stats),
Mathieu Chartier736b5602015-09-02 14:54:11 -070061 interpreter_metadata_(interpreter_metadata),
62 dex_cache_(dex_cache) {}
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010063
64 // Only for unit testing.
David Brazdil5e8b1372015-01-23 14:39:08 +000065 HGraphBuilder(HGraph* graph, Primitive::Type return_type = Primitive::kPrimInt)
66 : arena_(graph->GetArena()),
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010067 branch_targets_(graph->GetArena()->Adapter(kArenaAllocGraphBuilder)),
68 locals_(graph->GetArena()->Adapter(kArenaAllocGraphBuilder)),
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010069 entry_block_(nullptr),
70 exit_block_(nullptr),
71 current_block_(nullptr),
David Brazdil5e8b1372015-01-23 14:39:08 +000072 graph_(graph),
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +010073 dex_file_(nullptr),
74 dex_compilation_unit_(nullptr),
75 compiler_driver_(nullptr),
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000076 outer_compilation_unit_(nullptr),
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +010077 return_type_(return_type),
78 code_start_(nullptr),
Calin Juravle48c2b032014-12-09 18:11:36 +000079 latest_result_(nullptr),
Nicolas Geoffray2e7cd752015-07-10 11:38:52 +010080 can_use_baseline_for_string_init_(true),
Sebastien Hertzaa50d3a2015-08-25 15:25:41 +020081 compilation_stats_(nullptr),
Mathieu Chartier736b5602015-09-02 14:54:11 -070082 interpreter_metadata_(nullptr),
83 dex_cache_(NullHandle<mirror::DexCache>()) {}
Nicolas Geoffray818f2102014-02-18 16:43:35 +000084
David Brazdil5e8b1372015-01-23 14:39:08 +000085 bool BuildGraph(const DexFile::CodeItem& code);
Nicolas Geoffray818f2102014-02-18 16:43:35 +000086
Nicolas Geoffray2e7cd752015-07-10 11:38:52 +010087 bool CanUseBaselineForStringInit() const {
88 return can_use_baseline_for_string_init_;
89 }
90
Andreas Gampe7c3952f2015-02-19 18:21:24 -080091 static constexpr const char* kBuilderPassName = "builder";
92
Mark Mendellfe57faa2015-09-18 09:26:15 -040093 // The number of entries in a packed switch before we use a jump table.
94 static constexpr uint16_t kSmallSwitchThreshold = 5;
95
Nicolas Geoffray818f2102014-02-18 16:43:35 +000096 private:
97 // Analyzes the dex instruction and adds HInstruction to the graph
98 // to execute that instruction. Returns whether the instruction can
99 // be handled.
Calin Juravle225ff812014-11-13 16:46:39 +0000100 bool AnalyzeDexInstruction(const Instruction& instruction, uint32_t dex_pc);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000101
102 // Finds all instructions that start a new block, and populates branch_targets_ with
103 // the newly created blocks.
Nicolas Geoffray43a539f2014-12-02 10:19:51 +0000104 // As a side effect, also compute the number of dex instructions, blocks, and
105 // branches.
Calin Juravle702d2602015-04-30 19:28:21 +0100106 // Returns true if all the branches fall inside the method code, false otherwise.
107 // (In normal cases this should always return true but someone can artificially
108 // create a code unit in which branches fall-through out of it).
109 bool ComputeBranchTargets(const uint16_t* start,
Nicolas Geoffray43a539f2014-12-02 10:19:51 +0000110 const uint16_t* end,
Nicolas Geoffray43a539f2014-12-02 10:19:51 +0000111 size_t* number_of_branches);
David Brazdilfc6a86a2015-06-26 10:33:45 +0000112 void MaybeUpdateCurrentBlock(size_t dex_pc);
113 HBasicBlock* FindBlockStartingAt(int32_t dex_pc) const;
114 HBasicBlock* FindOrCreateBlockStartingAt(int32_t dex_pc);
David Brazdil56e1acc2015-06-30 15:41:36 +0100115
David Brazdil49bace12015-07-01 15:28:26 +0100116 // Adds new blocks to `branch_targets_` starting at the limits of TryItems and
117 // their exception handlers.
David Brazdilfc6a86a2015-06-26 10:33:45 +0000118 void CreateBlocksForTryCatch(const DexFile::CodeItem& code_item);
David Brazdil49bace12015-07-01 15:28:26 +0100119
120 // Splits edges which cross the boundaries of TryItems, inserts TryBoundary
121 // instructions and links them to the corresponding catch blocks.
David Brazdilfc6a86a2015-06-26 10:33:45 +0000122 void InsertTryBoundaryBlocks(const DexFile::CodeItem& code_item);
David Brazdil49bace12015-07-01 15:28:26 +0100123
David Brazdild7558da2015-09-22 13:04:14 +0100124 // Iterates over the exception handlers of `try_item`, finds the corresponding
125 // catch blocks and makes them successors of `try_boundary`. The order of
126 // successors matches the order in which runtime exception delivery searches
127 // for a handler.
128 void LinkToCatchBlocks(HTryBoundary* try_boundary,
129 const DexFile::CodeItem& code_item,
130 const DexFile::TryItem* try_item);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000131
Nicolas Geoffray9523a3e2015-07-17 11:51:28 +0000132 bool CanDecodeQuickenedInfo() const;
133 uint16_t LookupQuickenedInfo(uint32_t dex_pc);
134
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100135 void InitializeLocals(uint16_t count);
Vladimir Marko2aaa4b52015-09-17 17:03:26 +0100136 HLocal* GetLocalAt(uint32_t register_index) const;
137 void UpdateLocal(uint32_t register_index, HInstruction* instruction, uint32_t dex_pc) const;
138 HInstruction* LoadLocal(uint32_t register_index, Primitive::Type type, uint32_t dex_pc) const;
David Brazdil852eaff2015-02-02 15:23:05 +0000139 void PotentiallyAddSuspendCheck(HBasicBlock* target, uint32_t dex_pc);
Nicolas Geoffray52e832b2014-11-06 15:15:31 +0000140 void InitializeParameters(uint16_t number_of_parameters);
Mingyao Yangfb8464a2015-11-02 10:56:59 -0800141
142 // Returns whether the current method needs access check for the type.
143 // Output parameter finalizable is set to whether the type is finalizable.
144 bool NeedsAccessCheck(uint32_t type_index, /*out*/bool* finalizable) const;
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100145
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100146 template<typename T>
Yevgeny Rouban3ecfd652015-09-07 17:57:00 +0600147 void Unop_12x(const Instruction& instruction, Primitive::Type type, uint32_t dex_pc);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100148
149 template<typename T>
Calin Juravled6fb6cf2014-11-11 19:07:44 +0000150 void Binop_23x(const Instruction& instruction, Primitive::Type type, uint32_t dex_pc);
151
152 template<typename T>
Yevgeny Rouban3ecfd652015-09-07 17:57:00 +0600153 void Binop_23x_shift(const Instruction& instruction, Primitive::Type type, uint32_t dex_pc);
Calin Juravle9aec02f2014-11-18 23:06:35 +0000154
Alexey Frunze4dda3372015-06-01 18:31:49 -0700155 void Binop_23x_cmp(const Instruction& instruction,
156 Primitive::Type type,
Mark Mendellc4701932015-04-10 13:18:51 -0400157 ComparisonBias bias,
Alexey Frunze4dda3372015-06-01 18:31:49 -0700158 uint32_t dex_pc);
Calin Juravleddb7df22014-11-25 20:56:51 +0000159
Calin Juravle9aec02f2014-11-18 23:06:35 +0000160 template<typename T>
Calin Juravled6fb6cf2014-11-11 19:07:44 +0000161 void Binop_12x(const Instruction& instruction, Primitive::Type type, uint32_t dex_pc);
162
163 template<typename T>
Yevgeny Rouban3ecfd652015-09-07 17:57:00 +0600164 void Binop_12x_shift(const Instruction& instruction, Primitive::Type type, uint32_t dex_pc);
Calin Juravle9aec02f2014-11-18 23:06:35 +0000165
166 template<typename T>
Yevgeny Rouban3ecfd652015-09-07 17:57:00 +0600167 void Binop_22b(const Instruction& instruction, bool reverse, uint32_t dex_pc);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100168
169 template<typename T>
Yevgeny Rouban3ecfd652015-09-07 17:57:00 +0600170 void Binop_22s(const Instruction& instruction, bool reverse, uint32_t dex_pc);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100171
Calin Juravle225ff812014-11-13 16:46:39 +0000172 template<typename T> void If_21t(const Instruction& instruction, uint32_t dex_pc);
173 template<typename T> void If_22t(const Instruction& instruction, uint32_t dex_pc);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100174
Roland Levillaindff1f282014-11-05 14:15:05 +0000175 void Conversion_12x(const Instruction& instruction,
176 Primitive::Type input_type,
Roland Levillain624279f2014-12-04 11:54:28 +0000177 Primitive::Type result_type,
178 uint32_t dex_pc);
Roland Levillaindff1f282014-11-05 14:15:05 +0000179
Calin Juravlebacfec32014-11-14 15:54:36 +0000180 void BuildCheckedDivRem(uint16_t out_reg,
181 uint16_t first_reg,
182 int64_t second_reg_or_constant,
183 uint32_t dex_pc,
184 Primitive::Type type,
185 bool second_is_lit,
186 bool is_div);
Calin Juravled0d48522014-11-04 16:40:20 +0000187
Yevgeny Rouban3ecfd652015-09-07 17:57:00 +0600188 void BuildReturn(const Instruction& instruction, Primitive::Type type, uint32_t dex_pc);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100189
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100190 // Builds an instance field access node and returns whether the instruction is supported.
Calin Juravle225ff812014-11-13 16:46:39 +0000191 bool BuildInstanceFieldAccess(const Instruction& instruction, uint32_t dex_pc, bool is_put);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100192
Calin Juravle07380a22015-09-17 14:15:12 +0100193 void BuildUnresolvedStaticFieldAccess(const Instruction& instruction,
194 uint32_t dex_pc,
195 bool is_put,
196 Primitive::Type field_type);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100197 // Builds a static field access node and returns whether the instruction is supported.
Calin Juravle225ff812014-11-13 16:46:39 +0000198 bool BuildStaticFieldAccess(const Instruction& instruction, uint32_t dex_pc, bool is_put);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100199
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100200 void BuildArrayAccess(const Instruction& instruction,
Calin Juravle225ff812014-11-13 16:46:39 +0000201 uint32_t dex_pc,
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100202 bool is_get,
203 Primitive::Type anticipated_type);
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100204
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100205 // Builds an invocation node and returns whether the instruction is supported.
206 bool BuildInvoke(const Instruction& instruction,
Calin Juravle225ff812014-11-13 16:46:39 +0000207 uint32_t dex_pc,
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100208 uint32_t method_idx,
209 uint32_t number_of_vreg_arguments,
210 bool is_range,
211 uint32_t* args,
212 uint32_t register_index);
213
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100214 // Builds a new array node and the instructions that fill it.
Calin Juravle225ff812014-11-13 16:46:39 +0000215 void BuildFilledNewArray(uint32_t dex_pc,
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100216 uint32_t type_index,
217 uint32_t number_of_vreg_arguments,
218 bool is_range,
219 uint32_t* args,
220 uint32_t register_index);
221
Calin Juravle225ff812014-11-13 16:46:39 +0000222 void BuildFillArrayData(const Instruction& instruction, uint32_t dex_pc);
Calin Juravled0d48522014-11-04 16:40:20 +0000223
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100224 // Fills the given object with data as specified in the fill-array-data
225 // instruction. Currently only used for non-reference and non-floating point
226 // arrays.
227 template <typename T>
228 void BuildFillArrayData(HInstruction* object,
229 const T* data,
230 uint32_t element_count,
231 Primitive::Type anticipated_type,
Calin Juravle225ff812014-11-13 16:46:39 +0000232 uint32_t dex_pc);
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100233
234 // Fills the given object with data as specified in the fill-array-data
235 // instruction. The data must be for long and double arrays.
236 void BuildFillWideArrayData(HInstruction* object,
Nicolas Geoffray8d6ae522014-10-23 18:32:13 +0100237 const int64_t* data,
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100238 uint32_t element_count,
Calin Juravle225ff812014-11-13 16:46:39 +0000239 uint32_t dex_pc);
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100240
Nicolas Geoffray57a88d42014-11-10 15:09:21 +0000241 // Builds a `HInstanceOf`, or a `HCheckCast` instruction.
Calin Juravle98893e12015-10-02 21:05:03 +0100242 void BuildTypeCheck(const Instruction& instruction,
Nicolas Geoffray57a88d42014-11-10 15:09:21 +0000243 uint8_t destination,
244 uint8_t reference,
245 uint16_t type_index,
Calin Juravle225ff812014-11-13 16:46:39 +0000246 uint32_t dex_pc);
Nicolas Geoffray57a88d42014-11-10 15:09:21 +0000247
Andreas Gampee4d4d322014-12-04 09:09:57 -0800248 // Builds an instruction sequence for a packed switch statement.
Calin Juravle48c2b032014-12-09 18:11:36 +0000249 void BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc);
Andreas Gamped881df52014-11-24 23:28:39 -0800250
Mark Mendellfe57faa2015-09-18 09:26:15 -0400251 // Build a switch instruction from a packed switch statement.
252 void BuildSwitchJumpTable(const SwitchTable& table,
253 const Instruction& instruction,
254 HInstruction* value,
255 uint32_t dex_pc);
256
Andreas Gampee4d4d322014-12-04 09:09:57 -0800257 // Builds an instruction sequence for a sparse switch statement.
Calin Juravle48c2b032014-12-09 18:11:36 +0000258 void BuildSparseSwitch(const Instruction& instruction, uint32_t dex_pc);
Andreas Gampee4d4d322014-12-04 09:09:57 -0800259
260 void BuildSwitchCaseHelper(const Instruction& instruction, size_t index,
261 bool is_last_case, const SwitchTable& table,
262 HInstruction* value, int32_t case_value_int,
263 int32_t target_offset, uint32_t dex_pc);
264
David Brazdil1b498722015-03-31 11:37:18 +0100265 bool SkipCompilation(const DexFile::CodeItem& code_item, size_t number_of_branches);
Calin Juravle48c2b032014-12-09 18:11:36 +0000266
267 void MaybeRecordStat(MethodCompilationStat compilation_stat);
268
Nicolas Geoffray30451742015-06-19 13:32:41 +0100269 // Returns the outer-most compiling method's class.
Nicolas Geoffray9437b782015-03-25 10:08:51 +0000270 mirror::Class* GetOutermostCompilingClass() const;
271
Nicolas Geoffray30451742015-06-19 13:32:41 +0100272 // Returns the class whose method is being compiled.
273 mirror::Class* GetCompilingClass() const;
274
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000275 // Returns whether `type_index` points to the outer-most compiling method's class.
Nicolas Geoffray9437b782015-03-25 10:08:51 +0000276 bool IsOutermostCompilingClass(uint16_t type_index) const;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000277
Nicolas Geoffray2e7cd752015-07-10 11:38:52 +0100278 void PotentiallySimplifyFakeString(uint16_t original_dex_register,
279 uint32_t dex_pc,
280 HInvoke* invoke);
281
Calin Juravle5d01db12015-08-25 15:02:42 +0100282 bool SetupInvokeArguments(HInvoke* invoke,
283 uint32_t number_of_vreg_arguments,
284 uint32_t* args,
285 uint32_t register_index,
286 bool is_range,
287 const char* descriptor,
288 size_t start_index,
289 size_t* argument_index);
290
291 bool HandleInvoke(HInvoke* invoke,
292 uint32_t number_of_vreg_arguments,
293 uint32_t* args,
294 uint32_t register_index,
295 bool is_range,
296 const char* descriptor,
297 HClinitCheck* clinit_check);
298
299 bool HandleStringInit(HInvoke* invoke,
300 uint32_t number_of_vreg_arguments,
301 uint32_t* args,
302 uint32_t register_index,
303 bool is_range,
304 const char* descriptor);
Calin Juravle68ad6492015-08-18 17:08:12 +0100305
306 HClinitCheck* ProcessClinitCheckForInvoke(
307 uint32_t dex_pc,
308 uint32_t method_idx,
309 HInvokeStaticOrDirect::ClinitCheckRequirement* clinit_check_requirement);
310
Nicolas Geoffray729645a2015-11-19 13:29:02 +0000311 // Build a HNewInstance instruction.
312 bool BuildNewInstance(uint16_t type_index, uint32_t dex_pc);
313
Nicolas Geoffrayd9dc6f42015-11-24 14:06:57 +0000314 // Return whether the compiler can assume `cls` is initialized.
315 bool IsInitialized(Handle<mirror::Class> cls) const
Nicolas Geoffray729645a2015-11-19 13:29:02 +0000316 SHARED_REQUIRES(Locks::mutator_lock_);
317
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000318 ArenaAllocator* const arena_;
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000319
320 // A list of the size of the dex code holding block information for
321 // the method. If an entry contains a block, then the dex instruction
322 // starting at that entry is the first instruction of a new block.
Vladimir Marko2aaa4b52015-09-17 17:03:26 +0100323 ArenaVector<HBasicBlock*> branch_targets_;
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000324
Vladimir Marko2aaa4b52015-09-17 17:03:26 +0100325 ArenaVector<HLocal*> locals_;
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000326
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000327 HBasicBlock* entry_block_;
328 HBasicBlock* exit_block_;
329 HBasicBlock* current_block_;
David Brazdil5e8b1372015-01-23 14:39:08 +0000330 HGraph* const graph_;
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000331
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000332 // The dex file where the method being compiled is.
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000333 const DexFile* const dex_file_;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000334
335 // The compilation unit of the current method being compiled. Note that
336 // it can be an inlined method.
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100337 DexCompilationUnit* const dex_compilation_unit_;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000338
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100339 CompilerDriver* const compiler_driver_;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000340
341 // The compilation unit of the outermost method being compiled. That is the
342 // method being compiled (and not inlined), and potentially inlining other
343 // methods.
344 const DexCompilationUnit* const outer_compilation_unit_;
345
346 // The return type of the method being compiled.
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100347 const Primitive::Type return_type_;
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000348
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100349 // The pointer in the dex file where the instructions of the code item
350 // being currently compiled start.
351 const uint16_t* code_start_;
352
353 // The last invoke or fill-new-array being built. Only to be
354 // used by move-result instructions.
355 HInstruction* latest_result_;
356
Nicolas Geoffray2e7cd752015-07-10 11:38:52 +0100357 // We need to know whether we have built a graph that has calls to StringFactory
358 // and hasn't gone through the verifier. If the following flag is `false`, then
359 // we cannot compile with baseline.
360 bool can_use_baseline_for_string_init_;
361
Calin Juravle48c2b032014-12-09 18:11:36 +0000362 OptimizingCompilerStats* compilation_stats_;
363
Nicolas Geoffray9523a3e2015-07-17 11:51:28 +0000364 const uint8_t* interpreter_metadata_;
365
Mathieu Chartier736b5602015-09-02 14:54:11 -0700366 // Dex cache for dex_file_.
367 Handle<mirror::DexCache> dex_cache_;
368
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000369 DISALLOW_COPY_AND_ASSIGN(HGraphBuilder);
370};
371
372} // namespace art
373
374#endif // ART_COMPILER_OPTIMIZING_BUILDER_H_