summaryrefslogtreecommitdiff
path: root/compiler/optimizing/builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/builder.h')
-rw-r--r--compiler/optimizing/builder.h47
1 files changed, 41 insertions, 6 deletions
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index 73c2f50958..cc5f6a04dc 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -21,6 +21,7 @@
#include "dex_file-inl.h"
#include "driver/compiler_driver.h"
#include "driver/dex_compilation_unit.h"
+#include "optimizing_compiler_stats.h"
#include "primitive.h"
#include "utils/arena_object.h"
#include "utils/growable_array.h"
@@ -35,8 +36,10 @@ class HGraphBuilder : public ValueObject {
public:
HGraphBuilder(ArenaAllocator* arena,
DexCompilationUnit* dex_compilation_unit,
+ const DexCompilationUnit* const outer_compilation_unit,
const DexFile* dex_file,
- CompilerDriver* driver)
+ CompilerDriver* driver,
+ OptimizingCompilerStats* compiler_stats)
: arena_(arena),
branch_targets_(arena, 0),
locals_(arena, 0),
@@ -49,9 +52,11 @@ class HGraphBuilder : public ValueObject {
dex_file_(dex_file),
dex_compilation_unit_(dex_compilation_unit),
compiler_driver_(driver),
+ outer_compilation_unit_(outer_compilation_unit),
return_type_(Primitive::GetType(dex_compilation_unit_->GetShorty()[0])),
code_start_(nullptr),
- latest_result_(nullptr) {}
+ latest_result_(nullptr),
+ compilation_stats_(compiler_stats) {}
// Only for unit testing.
HGraphBuilder(ArenaAllocator* arena, Primitive::Type return_type = Primitive::kPrimInt)
@@ -67,11 +72,13 @@ class HGraphBuilder : public ValueObject {
dex_file_(nullptr),
dex_compilation_unit_(nullptr),
compiler_driver_(nullptr),
+ outer_compilation_unit_(nullptr),
return_type_(return_type),
code_start_(nullptr),
- latest_result_(nullptr) {}
+ latest_result_(nullptr),
+ compilation_stats_(nullptr) {}
- HGraph* BuildGraph(const DexFile::CodeItem& code);
+ HGraph* BuildGraph(const DexFile::CodeItem& code, int start_instruction_id = 0);
private:
// Analyzes the dex instruction and adds HInstruction to the graph
@@ -205,16 +212,30 @@ class HGraphBuilder : public ValueObject {
uint32_t dex_pc);
// Builds an instruction sequence for a packed switch statement.
- bool BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc);
+ void BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc);
// Builds an instruction sequence for a sparse switch statement.
- bool BuildSparseSwitch(const Instruction& instruction, uint32_t dex_pc);
+ void BuildSparseSwitch(const Instruction& instruction, uint32_t dex_pc);
void BuildSwitchCaseHelper(const Instruction& instruction, size_t index,
bool is_last_case, const SwitchTable& table,
HInstruction* value, int32_t case_value_int,
int32_t target_offset, uint32_t dex_pc);
+ bool SkipCompilation(size_t number_of_dex_instructions,
+ size_t number_of_blocks,
+ size_t number_of_branches);
+
+ void MaybeRecordStat(MethodCompilationStat compilation_stat);
+
+ // Returns whether `type_index` points to the outer-most compiling method's class.
+ bool IsCompilingClass(uint16_t type_index) const {
+ uint32_t referrer_index = outer_compilation_unit_->GetDexMethodIndex();
+ const DexFile::MethodId& method_id =
+ outer_compilation_unit_->GetDexFile()->GetMethodId(referrer_index);
+ return method_id.class_idx_ == type_index;
+ }
+
ArenaAllocator* const arena_;
// A list of the size of the dex code holding block information for
@@ -232,9 +253,21 @@ class HGraphBuilder : public ValueObject {
HIntConstant* constant0_;
HIntConstant* constant1_;
+ // The dex file where the method being compiled is.
const DexFile* const dex_file_;
+
+ // The compilation unit of the current method being compiled. Note that
+ // it can be an inlined method.
DexCompilationUnit* const dex_compilation_unit_;
+
CompilerDriver* const compiler_driver_;
+
+ // The compilation unit of the outermost method being compiled. That is the
+ // method being compiled (and not inlined), and potentially inlining other
+ // methods.
+ const DexCompilationUnit* const outer_compilation_unit_;
+
+ // The return type of the method being compiled.
const Primitive::Type return_type_;
// The pointer in the dex file where the instructions of the code item
@@ -245,6 +278,8 @@ class HGraphBuilder : public ValueObject {
// used by move-result instructions.
HInstruction* latest_result_;
+ OptimizingCompilerStats* compilation_stats_;
+
DISALLOW_COPY_AND_ASSIGN(HGraphBuilder);
};