From ecc4366670e12b4812ef1653f7c8d52234ca1b1f Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Thu, 13 Aug 2015 13:33:12 +0100 Subject: Add OptimizingCompilerStats to the CodeGenerator class. Just refactoring, not yet used, but will be used by the incoming patch series and future CodeGen specific stats. Change-Id: I7d20489907b82678120518a77bdab9c4cc58f937 Signed-off-by: Serban Constantinescu --- compiler/optimizing/code_generator.cc | 34 +++++++++++++++++++--------- compiler/optimizing/code_generator.h | 12 ++++++++-- compiler/optimizing/code_generator_arm.cc | 6 +++-- compiler/optimizing/code_generator_arm.h | 3 ++- compiler/optimizing/code_generator_arm64.cc | 6 +++-- compiler/optimizing/code_generator_arm64.h | 3 ++- compiler/optimizing/code_generator_mips64.cc | 6 +++-- compiler/optimizing/code_generator_mips64.h | 3 ++- compiler/optimizing/code_generator_x86.cc | 8 ++++--- compiler/optimizing/code_generator_x86.h | 3 ++- compiler/optimizing/code_generator_x86_64.cc | 6 +++-- compiler/optimizing/code_generator_x86_64.h | 3 ++- 12 files changed, 64 insertions(+), 29 deletions(-) (limited to 'compiler') diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index 503187bd3d..e8304e5cca 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -531,24 +531,33 @@ void CodeGenerator::AllocateLocations(HInstruction* instruction) { } } +void CodeGenerator::MaybeRecordStat(MethodCompilationStat compilation_stat, size_t count) const { + if (stats_ != nullptr) { + stats_->RecordStat(compilation_stat, count); + } +} + CodeGenerator* CodeGenerator::Create(HGraph* graph, InstructionSet instruction_set, const InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options) { + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats) { switch (instruction_set) { #ifdef ART_ENABLE_CODEGEN_arm case kArm: case kThumb2: { return new arm::CodeGeneratorARM(graph, - *isa_features.AsArmInstructionSetFeatures(), - compiler_options); + *isa_features.AsArmInstructionSetFeatures(), + compiler_options, + stats); } #endif #ifdef ART_ENABLE_CODEGEN_arm64 case kArm64: { return new arm64::CodeGeneratorARM64(graph, - *isa_features.AsArm64InstructionSetFeatures(), - compiler_options); + *isa_features.AsArm64InstructionSetFeatures(), + compiler_options, + stats); } #endif #ifdef ART_ENABLE_CODEGEN_mips @@ -561,22 +570,25 @@ CodeGenerator* CodeGenerator::Create(HGraph* graph, #ifdef ART_ENABLE_CODEGEN_mips64 case kMips64: { return new mips64::CodeGeneratorMIPS64(graph, - *isa_features.AsMips64InstructionSetFeatures(), - compiler_options); + *isa_features.AsMips64InstructionSetFeatures(), + compiler_options, + stats); } #endif #ifdef ART_ENABLE_CODEGEN_x86 case kX86: { return new x86::CodeGeneratorX86(graph, - *isa_features.AsX86InstructionSetFeatures(), - compiler_options); + *isa_features.AsX86InstructionSetFeatures(), + compiler_options, + stats); } #endif #ifdef ART_ENABLE_CODEGEN_x86_64 case kX86_64: { return new x86_64::CodeGeneratorX86_64(graph, - *isa_features.AsX86_64InstructionSetFeatures(), - compiler_options); + *isa_features.AsX86_64InstructionSetFeatures(), + compiler_options, + stats); } #endif default: diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 938369b58c..f94556408f 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -26,6 +26,7 @@ #include "locations.h" #include "memory_region.h" #include "nodes.h" +#include "optimizing_compiler_stats.h" #include "stack_map_stream.h" namespace art { @@ -143,7 +144,8 @@ class CodeGenerator { static CodeGenerator* Create(HGraph* graph, InstructionSet instruction_set, const InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options); + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats = nullptr); virtual ~CodeGenerator() {} HGraph* GetGraph() const { return graph_; } @@ -208,6 +210,8 @@ class CodeGenerator { const CompilerOptions& GetCompilerOptions() const { return compiler_options_; } + void MaybeRecordStat(MethodCompilationStat compilation_stat, size_t count = 1) const; + // Saves the register in the stack. Returns the size taken on stack. virtual size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) = 0; // Restores the register from the stack. Returns the size taken on stack. @@ -375,7 +379,8 @@ class CodeGenerator { size_t number_of_register_pairs, uint32_t core_callee_save_mask, uint32_t fpu_callee_save_mask, - const CompilerOptions& compiler_options) + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats) : frame_size_(0), core_spill_mask_(0), fpu_spill_mask_(0), @@ -392,6 +397,7 @@ class CodeGenerator { block_order_(nullptr), is_baseline_(false), disasm_info_(nullptr), + stats_(stats), graph_(graph), compiler_options_(compiler_options), slow_paths_(graph->GetArena(), 8), @@ -485,6 +491,8 @@ class CodeGenerator { void BlockIfInRegister(Location location, bool is_out = false) const; void EmitEnvironment(HEnvironment* environment, SlowPathCode* slow_path); + OptimizingCompilerStats* stats_; + HGraph* const graph_; const CompilerOptions& compiler_options_; diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index 62026f31ab..3b9413f87c 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -397,7 +397,8 @@ size_t CodeGeneratorARM::RestoreFloatingPointRegister(size_t stack_index, uint32 CodeGeneratorARM::CodeGeneratorARM(HGraph* graph, const ArmInstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options) + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats) : CodeGenerator(graph, kNumberOfCoreRegisters, kNumberOfSRegisters, @@ -406,7 +407,8 @@ CodeGeneratorARM::CodeGeneratorARM(HGraph* graph, arraysize(kCoreCalleeSaves)), ComputeRegisterMask(reinterpret_cast(kFpuCalleeSaves), arraysize(kFpuCalleeSaves)), - compiler_options), + compiler_options, + stats), block_labels_(graph->GetArena(), 0), location_builder_(graph, this), instruction_visitor_(graph, this), diff --git a/compiler/optimizing/code_generator_arm.h b/compiler/optimizing/code_generator_arm.h index 9528cca36f..9c14067e8b 100644 --- a/compiler/optimizing/code_generator_arm.h +++ b/compiler/optimizing/code_generator_arm.h @@ -231,7 +231,8 @@ class CodeGeneratorARM : public CodeGenerator { public: CodeGeneratorARM(HGraph* graph, const ArmInstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options); + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats = nullptr); virtual ~CodeGeneratorARM() {} void GenerateFrameEntry() OVERRIDE; diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 25b3ea2f5f..348c5c8945 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -510,14 +510,16 @@ Location InvokeDexCallingConventionVisitorARM64::GetMethodLocation() const { CodeGeneratorARM64::CodeGeneratorARM64(HGraph* graph, const Arm64InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options) + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats) : CodeGenerator(graph, kNumberOfAllocatableRegisters, kNumberOfAllocatableFPRegisters, kNumberOfAllocatableRegisterPairs, callee_saved_core_registers.list(), callee_saved_fp_registers.list(), - compiler_options), + compiler_options, + stats), block_labels_(nullptr), location_builder_(graph, this), instruction_visitor_(graph, this), diff --git a/compiler/optimizing/code_generator_arm64.h b/compiler/optimizing/code_generator_arm64.h index 18070fc6b6..1fa6e8233b 100644 --- a/compiler/optimizing/code_generator_arm64.h +++ b/compiler/optimizing/code_generator_arm64.h @@ -248,7 +248,8 @@ class CodeGeneratorARM64 : public CodeGenerator { public: CodeGeneratorARM64(HGraph* graph, const Arm64InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options); + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats = nullptr); virtual ~CodeGeneratorARM64() {} void GenerateFrameEntry() OVERRIDE; diff --git a/compiler/optimizing/code_generator_mips64.cc b/compiler/optimizing/code_generator_mips64.cc index 093d786dfe..75fd0eb871 100644 --- a/compiler/optimizing/code_generator_mips64.cc +++ b/compiler/optimizing/code_generator_mips64.cc @@ -419,7 +419,8 @@ class DeoptimizationSlowPathMIPS64 : public SlowPathCodeMIPS64 { CodeGeneratorMIPS64::CodeGeneratorMIPS64(HGraph* graph, const Mips64InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options) + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats) : CodeGenerator(graph, kNumberOfGpuRegisters, kNumberOfFpuRegisters, @@ -428,7 +429,8 @@ CodeGeneratorMIPS64::CodeGeneratorMIPS64(HGraph* graph, arraysize(kCoreCalleeSaves)), ComputeRegisterMask(reinterpret_cast(kFpuCalleeSaves), arraysize(kFpuCalleeSaves)), - compiler_options), + compiler_options, + stats), block_labels_(graph->GetArena(), 0), location_builder_(graph, this), instruction_visitor_(graph, this), diff --git a/compiler/optimizing/code_generator_mips64.h b/compiler/optimizing/code_generator_mips64.h index ae7c568c82..6d4fac311f 100644 --- a/compiler/optimizing/code_generator_mips64.h +++ b/compiler/optimizing/code_generator_mips64.h @@ -220,7 +220,8 @@ class CodeGeneratorMIPS64 : public CodeGenerator { public: CodeGeneratorMIPS64(HGraph* graph, const Mips64InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options); + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats = nullptr); virtual ~CodeGeneratorMIPS64() {} void GenerateFrameEntry() OVERRIDE; diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index 72c690de9a..3421fae25c 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -429,7 +429,8 @@ void CodeGeneratorX86::InvokeRuntime(Address entry_point, CodeGeneratorX86::CodeGeneratorX86(HGraph* graph, const X86InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options) + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats) : CodeGenerator(graph, kNumberOfCpuRegisters, kNumberOfXmmRegisters, @@ -437,8 +438,9 @@ CodeGeneratorX86::CodeGeneratorX86(HGraph* graph, ComputeRegisterMask(reinterpret_cast(kCoreCalleeSaves), arraysize(kCoreCalleeSaves)) | (1 << kFakeReturnRegister), - 0, - compiler_options), + 0, + compiler_options, + stats), block_labels_(graph->GetArena(), 0), location_builder_(graph, this), instruction_visitor_(graph, this), diff --git a/compiler/optimizing/code_generator_x86.h b/compiler/optimizing/code_generator_x86.h index 17787a82df..033693e501 100644 --- a/compiler/optimizing/code_generator_x86.h +++ b/compiler/optimizing/code_generator_x86.h @@ -220,7 +220,8 @@ class CodeGeneratorX86 : public CodeGenerator { public: CodeGeneratorX86(HGraph* graph, const X86InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options); + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats = nullptr); virtual ~CodeGeneratorX86() {} void GenerateFrameEntry() OVERRIDE; diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 820ec781bb..0ea95e8460 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -559,7 +559,8 @@ static constexpr int kNumberOfCpuRegisterPairs = 0; static constexpr Register kFakeReturnRegister = Register(kLastCpuRegister + 1); CodeGeneratorX86_64::CodeGeneratorX86_64(HGraph* graph, const X86_64InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options) + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats) : CodeGenerator(graph, kNumberOfCpuRegisters, kNumberOfFloatRegisters, @@ -569,7 +570,8 @@ CodeGeneratorX86_64::CodeGeneratorX86_64(HGraph* graph, | (1 << kFakeReturnRegister), ComputeRegisterMask(reinterpret_cast(kFpuCalleeSaves), arraysize(kFpuCalleeSaves)), - compiler_options), + compiler_options, + stats), block_labels_(graph->GetArena(), 0), location_builder_(graph, this), instruction_visitor_(graph, this), diff --git a/compiler/optimizing/code_generator_x86_64.h b/compiler/optimizing/code_generator_x86_64.h index 21357be0a5..8ee0a7a82b 100644 --- a/compiler/optimizing/code_generator_x86_64.h +++ b/compiler/optimizing/code_generator_x86_64.h @@ -220,7 +220,8 @@ class CodeGeneratorX86_64 : public CodeGenerator { public: CodeGeneratorX86_64(HGraph* graph, const X86_64InstructionSetFeatures& isa_features, - const CompilerOptions& compiler_options); + const CompilerOptions& compiler_options, + OptimizingCompilerStats* stats = nullptr); virtual ~CodeGeneratorX86_64() {} void GenerateFrameEntry() OVERRIDE; -- cgit v1.2.3-59-g8ed1b