Lines Matching refs:code_ir

37               lir::CodeIr* code_ir,  in BoxValue()  argument
73 ir::Builder builder(code_ir->dex_ir); in BoxValue()
83 auto boxing_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in BoxValue()
85 auto args = code_ir->Alloc<lir::VRegRange>(src_reg, 1 + is_wide); in BoxValue()
86 auto boxing_invoke = code_ir->Alloc<lir::Bytecode>(); in BoxValue()
90 code_ir->instructions.InsertBefore(bytecode, boxing_invoke); in BoxValue()
92 auto move_result = code_ir->Alloc<lir::Bytecode>(); in BoxValue()
94 move_result->operands.push_back(code_ir->Alloc<lir::VReg>(dst_reg)); in BoxValue()
95 code_ir->instructions.InsertBefore(bytecode, move_result); in BoxValue()
105 bool EntryHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
108 for (auto instr : code_ir->instructions) { in Apply()
120 return InjectArrayParamsHook(code_ir, bytecode); in Apply()
123 ir::Builder builder(code_ir->dex_ir); in Apply()
124 const auto ir_method = code_ir->ir_method; in Apply()
152 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
157 auto args = code_ir->Alloc<lir::VRegRange>(regs - args_count, args_count); in Apply()
160 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in Apply()
166 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in Apply()
170 void GenerateShiftParamsCode(lir::CodeIr* code_ir, lir::Instruction* position, dex::u4 shift) { in GenerateShiftParamsCode() argument
171 const auto ir_method = code_ir->ir_method; in GenerateShiftParamsCode()
196 auto move = code_ir->Alloc<lir::Bytecode>(); in GenerateShiftParamsCode()
200 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg - shift)); in GenerateShiftParamsCode()
201 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in GenerateShiftParamsCode()
206 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg - shift)); in GenerateShiftParamsCode()
207 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in GenerateShiftParamsCode()
212 move->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg - shift)); in GenerateShiftParamsCode()
213 move->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg)); in GenerateShiftParamsCode()
219 code_ir->instructions.InsertBefore(position, move); in GenerateShiftParamsCode()
223 bool EntryHook::InjectArrayParamsHook(lir::CodeIr* code_ir, lir::Bytecode* bytecode) { in InjectArrayParamsHook() argument
224 ir::Builder builder(code_ir->dex_ir); in InjectArrayParamsHook()
225 const auto ir_method = code_ir->ir_method; in InjectArrayParamsHook()
239 code_ir->ir_method->code->registers += regs_count - non_param_regs; in InjectArrayParamsHook()
254 auto const_size_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
256 const_size_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_size_reg)); in InjectArrayParamsHook()
257 const_size_op->operands.push_back(code_ir->Alloc<lir::Const32>( in InjectArrayParamsHook()
259 code_ir->instructions.InsertBefore(bytecode, const_size_op); in InjectArrayParamsHook()
263 auto allocate_array_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
265 allocate_array_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_reg)); in InjectArrayParamsHook()
266 allocate_array_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_size_reg)); in InjectArrayParamsHook()
268 code_ir->Alloc<lir::Type>(obj_array_type, obj_array_type->orig_index)); in InjectArrayParamsHook()
269 code_ir->instructions.InsertBefore(bytecode, allocate_array_op); in InjectArrayParamsHook()
291 auto const_str_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
293 const_str_op->operands.push_back(code_ir->Alloc<lir::VReg>(value_reg)); // dst in InjectArrayParamsHook()
296 code_ir->Alloc<lir::String>(method_label, method_label->orig_index)); // src in InjectArrayParamsHook()
297 code_ir->instructions.InsertBefore(bytecode, const_str_op); in InjectArrayParamsHook()
300 BoxValue(bytecode, code_ir, type, current_reg, value_reg); in InjectArrayParamsHook()
308 auto index_const_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
310 index_const_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_index_reg)); in InjectArrayParamsHook()
311 index_const_op->operands.push_back(code_ir->Alloc<lir::Const32>(i++)); in InjectArrayParamsHook()
312 code_ir->instructions.InsertBefore(bytecode, index_const_op); in InjectArrayParamsHook()
314 auto aput_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
316 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(src_reg)); in InjectArrayParamsHook()
317 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_reg)); in InjectArrayParamsHook()
318 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_index_reg)); in InjectArrayParamsHook()
319 code_ir->instructions.InsertBefore(bytecode, aput_op); in InjectArrayParamsHook()
336 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in InjectArrayParamsHook()
337 auto args = code_ir->Alloc<lir::VRegRange>(array_reg, 1); in InjectArrayParamsHook()
338 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
342 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in InjectArrayParamsHook()
348 auto cleanup = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
350 cleanup->operands.push_back(code_ir->Alloc<lir::VReg>(i)); in InjectArrayParamsHook()
351 cleanup->operands.push_back(code_ir->Alloc<lir::Const32>(0xFEFEFEFE)); in InjectArrayParamsHook()
352 code_ir->instructions.InsertBefore(bytecode, cleanup); in InjectArrayParamsHook()
357 GenerateShiftParamsCode(code_ir, bytecode, regs_count - non_param_regs); in InjectArrayParamsHook()
362 bool ExitHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
363 ir::Builder builder(code_ir->dex_ir); in Apply()
364 const auto ir_method = code_ir->ir_method; in Apply()
391 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
394 for (auto instr : code_ir->instructions) { in Apply()
440 alloc_regs.Apply(code_ir); in Apply()
447 auto move_op = code_ir->Alloc<lir::Bytecode>(); in Apply()
451 move_op->operands.push_back(code_ir->Alloc<lir::VReg>(reg + 1)); in Apply()
452 move_op->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in Apply()
456 move_op->operands.push_back(code_ir->Alloc<lir::VReg>(reg + 1)); in Apply()
457 move_op->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in Apply()
461 move_op->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg + 1)); in Apply()
462 move_op->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg)); in Apply()
470 code_ir->instructions.InsertBefore(bytecode, move_op); in Apply()
481 auto const_str_op = code_ir->Alloc<lir::Bytecode>(); in Apply()
483 const_str_op->operands.push_back(code_ir->Alloc<lir::VReg>(scratch_reg)); // dst in Apply()
484 …const_str_op->operands.push_back(code_ir->Alloc<lir::String>(method_label, method_label->orig_inde… in Apply()
485 code_ir->instructions.InsertBefore(bytecode, const_str_op); in Apply()
489 ? code_ir->Alloc<lir::VRegRange>(scratch_reg, reg_count + 1) in Apply()
490 : code_ir->Alloc<lir::VRegRange>(reg, reg_count); in Apply()
491 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in Apply()
495 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in Apply()
505 auto move_result = code_ir->Alloc<lir::Bytecode>(); in Apply()
508 code_ir->instructions.InsertBefore(bytecode, move_result); in Apply()
511 auto check_cast = code_ir->Alloc<lir::Bytecode>(); in Apply()
513 check_cast->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in Apply()
515 code_ir->Alloc<lir::Type>(declared_return_type, declared_return_type->orig_index)); in Apply()
516 code_ir->instructions.InsertBefore(bytecode, check_cast); in Apply()
524 bool DetourHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
525 ir::Builder builder(code_ir->dex_ir); in Apply()
528 for (auto instr : code_ir->instructions) { in Apply()
565 code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
656 void AllocateScratchRegs::RegsRenumbering(lir::CodeIr* code_ir) { in RegsRenumbering() argument
659 16 - static_cast<int>(code_ir->ir_method->code->registers)); in RegsRenumbering()
668 for (auto instr : code_ir->instructions) { in RegsRenumbering()
673 Allocate(code_ir, 0, delta); in RegsRenumbering()
684 void AllocateScratchRegs::ShiftParams(lir::CodeIr* code_ir) { in ShiftParams() argument
685 const auto ir_method = code_ir->ir_method; in ShiftParams()
689 Allocate(code_ir, ir_method->code->registers, left_to_allocate_); in ShiftParams()
693 auto first_instr = *(code_ir->instructions.begin()); in ShiftParams()
694 GenerateShiftParamsCode(code_ir, first_instr, shift); in ShiftParams()
698 void AllocateScratchRegs::Allocate(lir::CodeIr* code_ir, dex::u4 first_reg, int count) { in Allocate() argument
700 code_ir->ir_method->code->registers += count; in Allocate()
714 bool AllocateScratchRegs::Apply(lir::CodeIr* code_ir) { in Apply() argument
715 const auto code = code_ir->ir_method->code; in Apply()
724 Allocate(code_ir, code->registers, left_to_allocate_); in Apply()
730 RegsRenumbering(code_ir); in Apply()
736 ShiftParams(code_ir); in Apply()
752 lir::CodeIr code_ir(ir_method, dex_ir_); in InstrumentMethod() local
754 if (!transformation->Apply(&code_ir)) { in InstrumentMethod()
759 code_ir.Assemble(); in InstrumentMethod()