-Wunreachable-code \
-Wredundant-decls \
-Wshadow \
+ -Wunused \
-fvisibility=protected \
$(art_default_gc_type_cflags)
class BoundsCheckElimination : public HOptimization {
public:
- explicit BoundsCheckElimination(HGraph* graph) : HOptimization(graph, true, "BCE") {}
+ explicit BoundsCheckElimination(HGraph* graph)
+ : HOptimization(graph, true, kBoundsCheckEliminiationPassName) {}
void Run() OVERRIDE;
+ static constexpr const char* kBoundsCheckEliminiationPassName = "BCE";
+
private:
DISALLOW_COPY_AND_ASSIGN(BoundsCheckElimination);
};
bool BuildGraph(const DexFile::CodeItem& code);
+ static constexpr const char* kBuilderPassName = "builder";
+
private:
// Analyzes the dex instruction and adds HInstruction to the graph
// to execute that instruction. Returns whether the instruction can
#include "graph_visualizer.h"
#include "code_generator.h"
+#include "licm.h"
#include "nodes.h"
#include "optimization.h"
+#include "register_allocator.h"
#include "ssa_liveness_analysis.h"
namespace art {
output_ << " " << phi->GetRegNumber();
}
+ bool IsPass(const char* name) {
+ return strcmp(pass_name_, name) == 0;
+ }
+
void PrintInstruction(HInstruction* instruction) {
output_ << instruction->DebugName();
instruction->Accept(this);
}
output_ << "])";
}
- if (pass_name_ == kLivenessPassName
+ if (IsPass(SsaLivenessAnalysis::kLivenessPassName)
&& is_after_pass_
&& instruction->GetLifetimePosition() != kNoLifetime) {
output_ << " (liveness: " << instruction->GetLifetimePosition();
interval.Dump(output_);
}
output_ << ")";
- } else if (pass_name_ == kRegisterAllocatorPassName && is_after_pass_) {
+ } else if (IsPass(RegisterAllocator::kRegisterAllocatorPassName) && is_after_pass_) {
LocationSummary* locations = instruction->GetLocations();
if (locations != nullptr) {
output_ << " ( ";
}
}
output_ << " (liveness: " << instruction->GetLifetimePosition() << ")";
- } else if (pass_name_ == kLoopInvariantCodeMotionPassName) {
+ } else if (IsPass(LICM::kLoopInvariantCodeMotionPassName)) {
output_ << " ( loop_header:";
HLoopInformation* info = instruction->GetBlock()->GetLoopInformation();
if (info == nullptr) {
class GVNOptimization : public HOptimization {
public:
GVNOptimization(HGraph* graph, const SideEffectsAnalysis& side_effects)
- : HOptimization(graph, true, "GVN"), side_effects_(side_effects) {}
+ : HOptimization(graph, true, kGlobalValueNumberingPassName), side_effects_(side_effects) {}
void Run() OVERRIDE;
+ static constexpr const char* kGlobalValueNumberingPassName = "GVN";
+
private:
const SideEffectsAnalysis& side_effects_;
CompilerDriver* compiler_driver,
OptimizingCompilerStats* stats,
size_t depth = 0)
- : HOptimization(outer_graph, true, "inliner", stats),
+ : HOptimization(outer_graph, true, kInlinerPassName, stats),
outer_compilation_unit_(outer_compilation_unit),
compiler_driver_(compiler_driver),
depth_(depth) {}
void Run() OVERRIDE;
+ static constexpr const char* kInlinerPassName = "inliner";
+
private:
bool TryInline(HInvoke* invoke_instruction, uint32_t method_index, InvokeType invoke_type) const;
public:
InstructionSimplifier(HGraph* graph,
OptimizingCompilerStats* stats = nullptr,
- const char* name = "instruction_simplifier")
+ const char* name = kInstructionSimplifierPassName)
: HOptimization(graph, true, name, stats) {}
+ static constexpr const char* kInstructionSimplifierPassName = "instruction_simplifier";
+
void Run() OVERRIDE;
};
class IntrinsicsRecognizer : public HOptimization {
public:
IntrinsicsRecognizer(HGraph* graph, const DexFile* dex_file, CompilerDriver* driver)
- : HOptimization(graph, true, "intrinsics_recognition"),
+ : HOptimization(graph, true, kIntrinsicsRecognizerPassName),
dex_file_(dex_file), driver_(driver) {}
void Run() OVERRIDE;
+ static constexpr const char* kIntrinsicsRecognizerPassName = "intrinsics_recognition";
+
private:
const DexFile* dex_file_;
CompilerDriver* driver_;
void Run() OVERRIDE;
+ static constexpr const char* kLoopInvariantCodeMotionPassName = "licm";
+
private:
const SideEffectsAnalysis& side_effects_;
namespace art {
-static const char* kBuilderPassName = "builder";
-static const char* kSsaBuilderPassName = "ssa_builder";
-static const char* kLivenessPassName = "liveness";
-static const char* kRegisterAllocatorPassName = "register";
-static const char* kLoopInvariantCodeMotionPassName = "licm";
-
/**
* Abstraction to implement an optimization pass.
*/
*/
class CodeVectorAllocator FINAL : public CodeAllocator {
public:
- CodeVectorAllocator() {}
+ CodeVectorAllocator() : size_(0) {}
virtual uint8_t* Allocate(size_t size) {
size_ = size;
PrepareForRegisterAllocation(graph).Run();
SsaLivenessAnalysis liveness(*graph, codegen);
{
- PassInfo pass_info(kLivenessPassName, pass_info_printer);
+ PassInfo pass_info(SsaLivenessAnalysis::kLivenessPassName, pass_info_printer);
liveness.Analyze();
}
{
- PassInfo pass_info(kRegisterAllocatorPassName, pass_info_printer);
+ PassInfo pass_info(RegisterAllocator::kRegisterAllocatorPassName, pass_info_printer);
RegisterAllocator(graph->GetArena(), codegen, liveness).AllocateRegisters();
}
VLOG(compiler) << "Building " << method_name;
{
- PassInfo pass_info(kBuilderPassName, &pass_info_printer);
+ PassInfo pass_info(HGraphBuilder::kBuilderPassName, &pass_info_printer);
if (!builder.BuildGraph(*code_item)) {
CHECK(!shouldCompile) << "Could not build graph in optimizing compiler";
return nullptr;
VLOG(compiler) << "Optimizing " << method_name;
{
- PassInfo pass_info(kSsaBuilderPassName, &pass_info_printer);
+ PassInfo pass_info(SsaBuilder::kSsaBuilderPassName, &pass_info_printer);
if (!graph->TryBuildingSsa()) {
// We could not transform the graph to SSA, bailout.
LOG(INFO) << "Skipping compilation of " << method_name << ": it contains a non natural loop";
const DexFile& dex_file,
const DexCompilationUnit& dex_compilation_unit,
StackHandleScopeCollection* handles)
- : HOptimization(graph, true, "reference_type_propagation"),
+ : HOptimization(graph, true, kReferenceTypePropagationPassName),
dex_file_(dex_file),
dex_compilation_unit_(dex_compilation_unit),
handles_(handles),
void Run() OVERRIDE;
+ static constexpr const char* kReferenceTypePropagationPassName = "reference_type_propagation";
+
private:
void VisitNewInstance(HNewInstance* new_instance);
void VisitLoadClass(HLoadClass* load_class);
+ double_spill_slots_.Size();
}
+ static constexpr const char* kRegisterAllocatorPassName = "register";
+
private:
// Main methods of the allocator.
void LinearScan();
class SideEffectsAnalysis : public HOptimization {
public:
explicit SideEffectsAnalysis(HGraph* graph)
- : HOptimization(graph, true, "SideEffects"),
+ : HOptimization(graph, true, kSideEffectsAnalysisPassName),
graph_(graph),
block_effects_(graph->GetArena(), graph->GetBlocks().Size(), SideEffects::None()),
loop_effects_(graph->GetArena(), graph->GetBlocks().Size(), SideEffects::None()) {}
bool HasRun() const { return has_run_; }
+ static constexpr const char* kSideEffectsAnalysisPassName = "SideEffects";
+
private:
void UpdateLoopEffects(HLoopInformation* info, SideEffects effects);
static HInstruction* GetReferenceTypeEquivalent(HInstruction* instruction);
+ static constexpr const char* kSsaBuilderPassName = "ssa_builder";
+
private:
// Locals for the current block being visited.
HEnvironment* current_locals_;
return number_of_ssa_values_;
}
+ static constexpr const char* kLivenessPassName = "liveness";
+
private:
// Linearize the graph so that:
// (1): a block is always after its dominator,
class SsaDeadPhiElimination : public HOptimization {
public:
explicit SsaDeadPhiElimination(HGraph* graph)
- : HOptimization(graph, true, "dead_phi_elimination"),
+ : HOptimization(graph, true, kSsaDeadPhiEliminationPassName),
worklist_(graph->GetArena(), kDefaultWorklistSize) {}
void Run() OVERRIDE;
void MarkDeadPhis();
void EliminateDeadPhis();
+ static constexpr const char* kSsaDeadPhiEliminationPassName = "dead_phi_elimination";
+
private:
GrowableArray<HPhi*> worklist_;
class SsaRedundantPhiElimination : public HOptimization {
public:
explicit SsaRedundantPhiElimination(HGraph* graph)
- : HOptimization(graph, true, "redundant_phi_elimination"),
+ : HOptimization(graph, true, kSsaRedundantPhiEliminationPassName),
worklist_(graph->GetArena(), kDefaultWorklistSize) {}
void Run() OVERRIDE;
+ static constexpr const char* kSsaRedundantPhiEliminationPassName = "redundant_phi_elimination";
+
private:
GrowableArray<HPhi*> worklist_;
"memory"); // clobber all
// TODO: Should we clobber the other registers?
#else
+ UNUSED(arg0, arg1, arg2, code, referrer);
LOG(WARNING) << "Was asked to invoke for an architecture I do not understand.";
result = 0;
#endif
"memory"); // clobber all
// TODO: Should we clobber the other registers?
#else
+ UNUSED(arg0, arg1, arg2, code, referrer, hidden);
LOG(WARNING) << "Was asked to invoke for an architecture I do not understand.";
result = 0;
#endif
// Test done.
#else
+ UNUSED(test);
LOG(INFO) << "Skipping unlock_object as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping unlock_object as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(values[i], static_cast<uint8_t>(res)) << "Iteration " << i;
}
#else
+ UNUSED(f, self, referrer, test);
LOG(INFO) << "Skipping set_boolean_static as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set_boolean_static as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(values[i], static_cast<int8_t>(res)) << "Iteration " << i;
}
#else
+ UNUSED(f, self, referrer, test);
LOG(INFO) << "Skipping set_byte_static as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set_byte_static as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(res, static_cast<uint8_t>(res2));
}
#else
+ UNUSED(obj, f, self, referrer, test);
LOG(INFO) << "Skipping set_boolean_instance as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set_boolean_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(res, static_cast<int8_t>(res2));
}
#else
+ UNUSED(obj, f, self, referrer, test);
LOG(INFO) << "Skipping set_byte_instance as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set_byte_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(values[i], static_cast<uint16_t>(res)) << "Iteration " << i;
}
#else
+ UNUSED(f, self, referrer, test);
LOG(INFO) << "Skipping set_char_static as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set_char_static as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(static_cast<int16_t>(res), values[i]) << "Iteration " << i;
}
#else
+ UNUSED(f, self, referrer, test);
LOG(INFO) << "Skipping set_short_static as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set_short_static as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(res, static_cast<uint16_t>(res2));
}
#else
+ UNUSED(obj, f, self, referrer, test);
LOG(INFO) << "Skipping set_char_instance as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set_char_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(res, static_cast<int16_t>(res2));
}
#else
+ UNUSED(obj, f, self, referrer, test);
LOG(INFO) << "Skipping set_short_instance as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set_short_instance as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(res, values[i]) << "Iteration " << i;
}
#else
+ UNUSED(f, self, referrer, test);
LOG(INFO) << "Skipping set32static as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set32static as I don't know how to do that on " << kRuntimeISA << std::endl;
EXPECT_EQ(res, static_cast<int32_t>(res2));
}
#else
+ UNUSED(obj, f, self, referrer, test);
LOG(INFO) << "Skipping set32instance as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping set32instance as I don't know how to do that on " << kRuntimeISA << std::endl;
set_and_check_static((*f)->GetDexFieldIndex(), nullptr, self, referrer, test);
#else
+ UNUSED(f, self, referrer, test);
LOG(INFO) << "Skipping setObjstatic as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping setObjstatic as I don't know how to do that on " << kRuntimeISA << std::endl;
set_and_check_instance(f, obj->Get(), nullptr, self, referrer, test);
#else
+ UNUSED(obj, f, self, referrer, test);
LOG(INFO) << "Skipping setObjinstance as I don't know how to do that on " << kRuntimeISA;
// Force-print to std::cout so it's also outside the logcat.
std::cout << "Skipping setObjinstance as I don't know how to do that on " << kRuntimeISA << std::endl;
#elif defined(__i386__) || defined(__x86_64__)
struct ucontext *uc = reinterpret_cast<struct ucontext*>(context);
uc->CTX_EIP += 3;
+#else
+ UNUSED(context);
#endif
}