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()
96 bool EntryHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
99 for (auto instr : code_ir->instructions) { in Apply()
111 return InjectArrayParamsHook(code_ir, bytecode); in Apply()
114 ir::Builder builder(code_ir->dex_ir); in Apply()
115 const auto ir_method = code_ir->ir_method; in Apply()
143 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
148 auto args = code_ir->Alloc<lir::VRegRange>(regs - args_count, args_count); in Apply()
151 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in Apply()
157 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in Apply()
161 void GenerateShiftParamsCode(lir::CodeIr* code_ir, lir::Instruction* position, dex::u4 shift) { in GenerateShiftParamsCode() argument
162 const auto ir_method = code_ir->ir_method; in GenerateShiftParamsCode()
182 auto move = code_ir->Alloc<lir::Bytecode>(); in GenerateShiftParamsCode()
186 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg - shift)); in GenerateShiftParamsCode()
187 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in GenerateShiftParamsCode()
192 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg - shift)); in GenerateShiftParamsCode()
193 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in GenerateShiftParamsCode()
198 move->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg - shift)); in GenerateShiftParamsCode()
199 move->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg)); in GenerateShiftParamsCode()
205 code_ir->instructions.InsertBefore(position, move); in GenerateShiftParamsCode()
209 bool EntryHook::InjectArrayParamsHook(lir::CodeIr* code_ir, lir::Bytecode* bytecode) { in InjectArrayParamsHook() argument
210 ir::Builder builder(code_ir->dex_ir); in InjectArrayParamsHook()
211 const auto ir_method = code_ir->ir_method; in InjectArrayParamsHook()
230 code_ir->ir_method->code->registers += regs_count - non_param_regs; in InjectArrayParamsHook()
244 auto const_size_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
246 const_size_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_size_reg)); in InjectArrayParamsHook()
247 const_size_op->operands.push_back(code_ir->Alloc<lir::Const32>(param_types.size() + !is_static)); in InjectArrayParamsHook()
248 code_ir->instructions.InsertBefore(bytecode, const_size_op); in InjectArrayParamsHook()
252 auto allocate_array_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
254 allocate_array_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_reg)); in InjectArrayParamsHook()
255 allocate_array_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_size_reg)); in InjectArrayParamsHook()
257 code_ir->Alloc<lir::Type>(obj_array_type, obj_array_type->orig_index)); in InjectArrayParamsHook()
258 code_ir->instructions.InsertBefore(bytecode, allocate_array_op); in InjectArrayParamsHook()
277 BoxValue(bytecode, code_ir, type, current_reg, boxing_reg); in InjectArrayParamsHook()
285 auto index_const_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
287 index_const_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_index_reg)); in InjectArrayParamsHook()
288 index_const_op->operands.push_back(code_ir->Alloc<lir::Const32>(i++)); in InjectArrayParamsHook()
289 code_ir->instructions.InsertBefore(bytecode, index_const_op); in InjectArrayParamsHook()
291 auto aput_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
293 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(src_reg)); in InjectArrayParamsHook()
294 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_reg)); in InjectArrayParamsHook()
295 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_index_reg)); in InjectArrayParamsHook()
296 code_ir->instructions.InsertBefore(bytecode, aput_op); in InjectArrayParamsHook()
309 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in InjectArrayParamsHook()
310 auto args = code_ir->Alloc<lir::VRegRange>(array_reg, 1); in InjectArrayParamsHook()
311 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
315 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in InjectArrayParamsHook()
321 auto cleanup = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
323 cleanup->operands.push_back(code_ir->Alloc<lir::VReg>(i)); in InjectArrayParamsHook()
324 cleanup->operands.push_back(code_ir->Alloc<lir::Const32>(0xFEFEFEFE)); in InjectArrayParamsHook()
325 code_ir->instructions.InsertBefore(bytecode, cleanup); in InjectArrayParamsHook()
330 GenerateShiftParamsCode(code_ir, bytecode, regs_count - non_param_regs); in InjectArrayParamsHook()
335 bool ExitHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
336 ir::Builder builder(code_ir->dex_ir); in Apply()
337 const auto ir_method = code_ir->ir_method; in Apply()
360 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
363 for (auto instr : code_ir->instructions) { in Apply()
403 auto args = code_ir->Alloc<lir::VRegRange>(reg, reg_count); in Apply()
404 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in Apply()
408 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in Apply()
418 auto move_result = code_ir->Alloc<lir::Bytecode>(); in Apply()
421 code_ir->instructions.InsertBefore(bytecode, move_result); in Apply()
424 auto check_cast = code_ir->Alloc<lir::Bytecode>(); in Apply()
426 check_cast->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in Apply()
428 code_ir->Alloc<lir::Type>(declared_return_type, declared_return_type->orig_index)); in Apply()
429 code_ir->instructions.InsertBefore(bytecode, check_cast); in Apply()
437 bool DetourHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
438 ir::Builder builder(code_ir->dex_ir); in Apply()
441 for (auto instr : code_ir->instructions) { in Apply()
478 code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
569 void AllocateScratchRegs::RegsRenumbering(lir::CodeIr* code_ir) { in RegsRenumbering() argument
572 16 - static_cast<int>(code_ir->ir_method->code->registers)); in RegsRenumbering()
581 for (auto instr : code_ir->instructions) { in RegsRenumbering()
586 Allocate(code_ir, 0, delta); in RegsRenumbering()
597 void AllocateScratchRegs::ShiftParams(lir::CodeIr* code_ir) { in ShiftParams() argument
598 const auto ir_method = code_ir->ir_method; in ShiftParams()
602 Allocate(code_ir, ir_method->code->registers, left_to_allocate_); in ShiftParams()
606 auto first_instr = *(code_ir->instructions.begin()); in ShiftParams()
607 GenerateShiftParamsCode(code_ir, first_instr, shift); in ShiftParams()
611 void AllocateScratchRegs::Allocate(lir::CodeIr* code_ir, dex::u4 first_reg, int count) { in Allocate() argument
613 code_ir->ir_method->code->registers += count; in Allocate()
627 bool AllocateScratchRegs::Apply(lir::CodeIr* code_ir) { in Apply() argument
628 const auto code = code_ir->ir_method->code; in Apply()
637 Allocate(code_ir, code->registers, left_to_allocate_); in Apply()
643 RegsRenumbering(code_ir); in Apply()
649 ShiftParams(code_ir); in Apply()
665 lir::CodeIr code_ir(ir_method, dex_ir_); in InstrumentMethod() local
667 if (!transformation->Apply(&code_ir)) { in InstrumentMethod()
672 code_ir.Assemble(); in InstrumentMethod()