Lines Matching refs:code_ir
33 lir::CodeIr* code_ir, in BoxValue() argument
69 ir::Builder builder(code_ir->dex_ir); in BoxValue()
79 auto boxing_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in BoxValue()
81 auto args = code_ir->Alloc<lir::VRegRange>(src_reg, 1 + is_wide); in BoxValue()
82 auto boxing_invoke = code_ir->Alloc<lir::Bytecode>(); in BoxValue()
86 code_ir->instructions.InsertBefore(bytecode, boxing_invoke); in BoxValue()
88 auto move_result = code_ir->Alloc<lir::Bytecode>(); in BoxValue()
90 move_result->operands.push_back(code_ir->Alloc<lir::VReg>(dst_reg)); in BoxValue()
91 code_ir->instructions.InsertBefore(bytecode, move_result); in BoxValue()
101 bool EntryHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
104 for (auto instr : code_ir->instructions) { in Apply()
116 return InjectArrayParamsHook(code_ir, bytecode); in Apply()
119 ir::Builder builder(code_ir->dex_ir); in Apply()
120 const auto ir_method = code_ir->ir_method; in Apply()
148 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
153 auto args = code_ir->Alloc<lir::VRegRange>(regs - args_count, args_count); in Apply()
156 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in Apply()
162 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in Apply()
166 void GenerateShiftParamsCode(lir::CodeIr* code_ir, lir::Instruction* position, dex::u4 shift) { in GenerateShiftParamsCode() argument
167 const auto ir_method = code_ir->ir_method; in GenerateShiftParamsCode()
187 auto move = code_ir->Alloc<lir::Bytecode>(); in GenerateShiftParamsCode()
191 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg - shift)); in GenerateShiftParamsCode()
192 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in GenerateShiftParamsCode()
197 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg - shift)); in GenerateShiftParamsCode()
198 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in GenerateShiftParamsCode()
203 move->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg - shift)); in GenerateShiftParamsCode()
204 move->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg)); in GenerateShiftParamsCode()
210 code_ir->instructions.InsertBefore(position, move); in GenerateShiftParamsCode()
214 bool EntryHook::InjectArrayParamsHook(lir::CodeIr* code_ir, lir::Bytecode* bytecode) { in InjectArrayParamsHook() argument
215 ir::Builder builder(code_ir->dex_ir); in InjectArrayParamsHook()
216 const auto ir_method = code_ir->ir_method; in InjectArrayParamsHook()
230 code_ir->ir_method->code->registers += regs_count - non_param_regs; in InjectArrayParamsHook()
245 auto const_size_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
247 const_size_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_size_reg)); in InjectArrayParamsHook()
248 const_size_op->operands.push_back(code_ir->Alloc<lir::Const32>( in InjectArrayParamsHook()
250 code_ir->instructions.InsertBefore(bytecode, const_size_op); in InjectArrayParamsHook()
254 auto allocate_array_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
256 allocate_array_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_reg)); in InjectArrayParamsHook()
257 allocate_array_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_size_reg)); in InjectArrayParamsHook()
259 code_ir->Alloc<lir::Type>(obj_array_type, obj_array_type->orig_index)); in InjectArrayParamsHook()
260 code_ir->instructions.InsertBefore(bytecode, allocate_array_op); in InjectArrayParamsHook()
282 auto const_str_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
284 const_str_op->operands.push_back(code_ir->Alloc<lir::VReg>(value_reg)); // dst in InjectArrayParamsHook()
287 code_ir->Alloc<lir::String>(method_label, method_label->orig_index)); // src in InjectArrayParamsHook()
288 code_ir->instructions.InsertBefore(bytecode, const_str_op); in InjectArrayParamsHook()
291 BoxValue(bytecode, code_ir, type, current_reg, value_reg); in InjectArrayParamsHook()
299 auto index_const_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
301 index_const_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_index_reg)); in InjectArrayParamsHook()
302 index_const_op->operands.push_back(code_ir->Alloc<lir::Const32>(i++)); in InjectArrayParamsHook()
303 code_ir->instructions.InsertBefore(bytecode, index_const_op); in InjectArrayParamsHook()
305 auto aput_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
307 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(src_reg)); in InjectArrayParamsHook()
308 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_reg)); in InjectArrayParamsHook()
309 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_index_reg)); in InjectArrayParamsHook()
310 code_ir->instructions.InsertBefore(bytecode, aput_op); in InjectArrayParamsHook()
327 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in InjectArrayParamsHook()
328 auto args = code_ir->Alloc<lir::VRegRange>(array_reg, 1); in InjectArrayParamsHook()
329 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
333 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in InjectArrayParamsHook()
339 auto cleanup = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
341 cleanup->operands.push_back(code_ir->Alloc<lir::VReg>(i)); in InjectArrayParamsHook()
342 cleanup->operands.push_back(code_ir->Alloc<lir::Const32>(0xFEFEFEFE)); in InjectArrayParamsHook()
343 code_ir->instructions.InsertBefore(bytecode, cleanup); in InjectArrayParamsHook()
348 GenerateShiftParamsCode(code_ir, bytecode, regs_count - non_param_regs); in InjectArrayParamsHook()
353 bool ExitHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
354 ir::Builder builder(code_ir->dex_ir); in Apply()
355 const auto ir_method = code_ir->ir_method; in Apply()
382 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
385 for (auto instr : code_ir->instructions) { in Apply()
431 alloc_regs.Apply(code_ir); in Apply()
438 auto move_op = code_ir->Alloc<lir::Bytecode>(); in Apply()
442 move_op->operands.push_back(code_ir->Alloc<lir::VReg>(reg + 1)); in Apply()
443 move_op->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in Apply()
447 move_op->operands.push_back(code_ir->Alloc<lir::VReg>(reg + 1)); in Apply()
448 move_op->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in Apply()
452 move_op->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg + 1)); in Apply()
453 move_op->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg)); in Apply()
458 code_ir->instructions.InsertBefore(bytecode, move_op); in Apply()
469 auto const_str_op = code_ir->Alloc<lir::Bytecode>(); in Apply()
471 const_str_op->operands.push_back(code_ir->Alloc<lir::VReg>(scratch_reg)); // dst in Apply()
472 …const_str_op->operands.push_back(code_ir->Alloc<lir::String>(method_label, method_label->orig_inde… in Apply()
473 code_ir->instructions.InsertBefore(bytecode, const_str_op); in Apply()
477 ? code_ir->Alloc<lir::VRegRange>(scratch_reg, reg_count + 1) in Apply()
478 : code_ir->Alloc<lir::VRegRange>(reg, reg_count); in Apply()
479 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in Apply()
483 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in Apply()
493 auto move_result = code_ir->Alloc<lir::Bytecode>(); in Apply()
496 code_ir->instructions.InsertBefore(bytecode, move_result); in Apply()
499 auto check_cast = code_ir->Alloc<lir::Bytecode>(); in Apply()
501 check_cast->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in Apply()
503 code_ir->Alloc<lir::Type>(declared_return_type, declared_return_type->orig_index)); in Apply()
504 code_ir->instructions.InsertBefore(bytecode, check_cast); in Apply()
512 bool DetourHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
513 ir::Builder builder(code_ir->dex_ir); in Apply()
516 for (auto instr : code_ir->instructions) { in Apply()
553 code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
644 void AllocateScratchRegs::RegsRenumbering(lir::CodeIr* code_ir) { in RegsRenumbering() argument
647 16 - static_cast<int>(code_ir->ir_method->code->registers)); in RegsRenumbering()
656 for (auto instr : code_ir->instructions) { in RegsRenumbering()
661 Allocate(code_ir, 0, delta); in RegsRenumbering()
672 void AllocateScratchRegs::ShiftParams(lir::CodeIr* code_ir) { in ShiftParams() argument
673 const auto ir_method = code_ir->ir_method; in ShiftParams()
677 Allocate(code_ir, ir_method->code->registers, left_to_allocate_); in ShiftParams()
681 auto first_instr = *(code_ir->instructions.begin()); in ShiftParams()
682 GenerateShiftParamsCode(code_ir, first_instr, shift); in ShiftParams()
686 void AllocateScratchRegs::Allocate(lir::CodeIr* code_ir, dex::u4 first_reg, int count) { in Allocate() argument
688 code_ir->ir_method->code->registers += count; in Allocate()
702 bool AllocateScratchRegs::Apply(lir::CodeIr* code_ir) { in Apply() argument
703 const auto code = code_ir->ir_method->code; in Apply()
712 Allocate(code_ir, code->registers, left_to_allocate_); in Apply()
718 RegsRenumbering(code_ir); in Apply()
724 ShiftParams(code_ir); in Apply()
740 lir::CodeIr code_ir(ir_method, dex_ir_); in InstrumentMethod() local
742 if (!transformation->Apply(&code_ir)) { in InstrumentMethod()
747 code_ir.Assemble(); in InstrumentMethod()