Compilation filter
This CL introduces a static compilation filter mechanism intended
to allow us to reduce compilation time and space requirements until
we have a profiling mechanism in place.
It supports 5 modes of filtering:
o interpret-only (compile nothing)
o deferred-compilation (compile only those methods believe to be
compute-intensive)
o space (optimized for space)
o balanced (best return on space investment)
o speed (compile everything)
A future CL will allow the default filtering mode to be set
via system property. For now, you can pass it in via command
line as follows:
dalvikvm -compiler-filter:[interpret-only|defer-compilation|
space|balanced|speed]
or dex2oat --runtime-arg -compiler-filter:[one of the above modes]
Creating a file named art/SMALL_ART will force the filter
default to interpret-only. Later on we'll move this capability
to a persistent system property.
or modify kDefaultCompilerFilter in runtime.h
It also changes the compiler driver to allow the compilers to
decline to compile a method by return NULL.
Change-Id: Ic73411818f8bb845a4a19a05b0395c50902c534f
(cherry picked from commit a024a0686c3b0fea13f362bff70d65981e5febc5)
diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h
index e9ec949..84ab259 100644
--- a/compiler/dex/mir_graph.h
+++ b/compiler/dex/mir_graph.h
@@ -25,6 +25,38 @@
namespace art {
+enum InstructionAnalysisAttributePos {
+ kUninterestingOp = 0,
+ kArithmeticOp,
+ kFPOp,
+ kSingleOp,
+ kDoubleOp,
+ kIntOp,
+ kLongOp,
+ kBranchOp,
+ kInvokeOp,
+ kArrayOp,
+ kHeavyweightOp,
+ kSimpleConstOp,
+ kMoveOp
+};
+
+#define AN_NONE (1 << kUninterestingOp)
+#define AN_MATH (1 << kArithmeticOp)
+#define AN_FP (1 << kFPOp)
+#define AN_LONG (1 << kLongOp)
+#define AN_INT (1 << kIntOp)
+#define AN_SINGLE (1 << kSingleOp)
+#define AN_DOUBLE (1 << kDoubleOp)
+#define AN_FLOATMATH (1 << kFPOp)
+#define AN_BRANCH (1 << kBranchOp)
+#define AN_INVOKE (1 << kInvokeOp)
+#define AN_ARRAYOP (1 << kArrayOp)
+#define AN_HEAVYWEIGHT (1 << kHeavyweightOp)
+#define AN_SIMPLECONST (1 << kSimpleConstOp)
+#define AN_MOVE (1 << kMoveOp)
+#define AN_COMPUTATIONAL (AN_MATH | AN_ARRAYOP | AN_MOVE | AN_SIMPLECONST)
+
enum DataFlowAttributePos {
kUA = 0,
kUB,
@@ -313,6 +345,12 @@
~MIRGraph();
/*
+ * Examine the graph to determine whether it's worthwile to spend the time compiling
+ * this method.
+ */
+ bool SkipCompilation(Runtime::CompilerFilter compiler_filter);
+
+ /*
* Parse dex method and add MIR at current insert point. Returns id (which is
* actually the index of the method in the m_units_ array).
*/
@@ -337,6 +375,10 @@
return num_blocks_;
}
+ size_t GetNumDalvikInsns() const {
+ return cu_->code_item->insns_size_in_code_units_;
+ }
+
ArenaBitVector* GetTryBlockAddr() const {
return try_block_addr_;
}
@@ -559,6 +601,7 @@
static const int oat_data_flow_attributes_[kMirOpLast];
static const char* extended_mir_op_names_[kMirOpLast - kMirOpFirst];
+ static const uint32_t analysis_attributes_[kMirOpLast];
private:
int FindCommonParent(int block1, int block2);
@@ -621,6 +664,8 @@
void DoConstantPropogation(BasicBlock* bb);
void CountChecks(BasicBlock* bb);
bool CombineBlocks(BasicBlock* bb);
+ void AnalyzeBlock(BasicBlock* bb, struct MethodStats* stats);
+ bool ComputeSkipCompilation(struct MethodStats* stats, bool skip_default);
CompilationUnit* const cu_;
GrowableArray<int>* ssa_base_vregs_;