From bcec6fba95ee7974d3f7b81c3c02e7eb3ca3df00 Mon Sep 17 00:00:00 2001 From: Dave Allison Date: Fri, 17 Jan 2014 12:52:22 -0800 Subject: Make slow paths easier to write This adds a class LIRSlowPath that allows for deferred compilation of slow paths. Using this object you can add code that will be invoked out of line using a forward branch. The intention is to move the slow paths out of the main flow and avoid branch-over constructs that will almost always trigger. The forward branch to the slow path code will be predicted false and this will be correct most of the time. The slow path code returns to the instruction after the original branch using an unconditional branch. This is used in the following opcodes: sput, sget, const-string, check-cast, const-class. Others will follow. Bug: 10864890 Change-Id: I17130c5dc20d369bc6bbf50b8cf04343263e888e --- compiler/dex/quick/codegen_util.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'compiler/dex/quick/codegen_util.cc') diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc index 072c6faa61..5e0fed7fd9 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -1003,7 +1003,8 @@ Mir2Lir::Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena core_spill_mask_(0), fp_spill_mask_(0), first_lir_insn_(NULL), - last_lir_insn_(NULL) { + last_lir_insn_(NULL), + slow_paths_(arena, 32, kGrowableArraySlowPaths) { // Reserve pointer id 0 for NULL. size_t null_idx = WrapPointer(NULL); DCHECK_EQ(null_idx, 0U); @@ -1182,4 +1183,7 @@ LIR *Mir2Lir::OpCmpMemImmBranch(ConditionCode cond, int temp_reg, int base_reg, return branch; } +void Mir2Lir::AddSlowPath(LIRSlowPath* slowpath) { + slow_paths_.Insert(slowpath); +} } // namespace art -- cgit v1.2.3-59-g8ed1b