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 bool EntryHook::InjectArrayParamsHook(lir::CodeIr* code_ir, lir::Bytecode* bytecode) { in InjectArrayParamsHook() argument
162 ir::Builder builder(code_ir->dex_ir); in InjectArrayParamsHook()
163 const auto ir_method = code_ir->ir_method; in InjectArrayParamsHook()
175 alloc_regs.Apply(code_ir); in InjectArrayParamsHook()
196 auto const_size_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
198 const_size_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_size_reg)); in InjectArrayParamsHook()
199 const_size_op->operands.push_back(code_ir->Alloc<lir::Const32>(param_types.size() + !is_static)); in InjectArrayParamsHook()
200 code_ir->instructions.InsertBefore(bytecode, const_size_op); in InjectArrayParamsHook()
204 auto allocate_array_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
206 allocate_array_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_reg)); in InjectArrayParamsHook()
207 allocate_array_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_size_reg)); in InjectArrayParamsHook()
209 code_ir->Alloc<lir::Type>(obj_array_type, obj_array_type->orig_index)); in InjectArrayParamsHook()
210 code_ir->instructions.InsertBefore(bytecode, allocate_array_op); in InjectArrayParamsHook()
229 BoxValue(bytecode, code_ir, type, current_reg, boxing_reg); in InjectArrayParamsHook()
237 auto index_const_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
239 index_const_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_index_reg)); in InjectArrayParamsHook()
240 index_const_op->operands.push_back(code_ir->Alloc<lir::Const32>(i++)); in InjectArrayParamsHook()
241 code_ir->instructions.InsertBefore(bytecode, index_const_op); in InjectArrayParamsHook()
243 auto aput_op = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
245 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(src_reg)); in InjectArrayParamsHook()
246 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_reg)); in InjectArrayParamsHook()
247 aput_op->operands.push_back(code_ir->Alloc<lir::VReg>(array_index_reg)); in InjectArrayParamsHook()
248 code_ir->instructions.InsertBefore(bytecode, aput_op); in InjectArrayParamsHook()
261 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in InjectArrayParamsHook()
262 auto args = code_ir->Alloc<lir::VRegRange>(array_reg, 1); in InjectArrayParamsHook()
263 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in InjectArrayParamsHook()
267 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in InjectArrayParamsHook()
271 bool ExitHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
272 ir::Builder builder(code_ir->dex_ir); in Apply()
273 const auto ir_method = code_ir->ir_method; in Apply()
296 auto hook_method = code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
299 for (auto instr : code_ir->instructions) { in Apply()
339 auto args = code_ir->Alloc<lir::VRegRange>(reg, reg_count); in Apply()
340 auto hook_invoke = code_ir->Alloc<lir::Bytecode>(); in Apply()
344 code_ir->instructions.InsertBefore(bytecode, hook_invoke); in Apply()
354 auto move_result = code_ir->Alloc<lir::Bytecode>(); in Apply()
357 code_ir->instructions.InsertBefore(bytecode, move_result); in Apply()
360 auto check_cast = code_ir->Alloc<lir::Bytecode>(); in Apply()
362 check_cast->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in Apply()
364 code_ir->Alloc<lir::Type>(declared_return_type, declared_return_type->orig_index)); in Apply()
365 code_ir->instructions.InsertBefore(bytecode, check_cast); in Apply()
373 bool DetourHook::Apply(lir::CodeIr* code_ir) { in Apply() argument
374 ir::Builder builder(code_ir->dex_ir); in Apply()
377 for (auto instr : code_ir->instructions) { in Apply()
414 code_ir->Alloc<lir::Method>(ir_method_decl, ir_method_decl->orig_index); in Apply()
505 void AllocateScratchRegs::RegsRenumbering(lir::CodeIr* code_ir) { in RegsRenumbering() argument
508 16 - static_cast<int>(code_ir->ir_method->code->registers)); in RegsRenumbering()
517 for (auto instr : code_ir->instructions) { in RegsRenumbering()
522 Allocate(code_ir, 0, delta); in RegsRenumbering()
533 void AllocateScratchRegs::ShiftParams(lir::CodeIr* code_ir) { in ShiftParams() argument
534 const auto ir_method = code_ir->ir_method; in ShiftParams()
550 Allocate(code_ir, ir_method->code->registers, left_to_allocate_); in ShiftParams()
558 auto first_instr = code_ir->instructions.begin(); in ShiftParams()
561 auto move = code_ir->Alloc<lir::Bytecode>(); in ShiftParams()
565 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg - shift)); in ShiftParams()
566 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in ShiftParams()
571 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg - shift)); in ShiftParams()
572 move->operands.push_back(code_ir->Alloc<lir::VReg>(reg)); in ShiftParams()
577 move->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg - shift)); in ShiftParams()
578 move->operands.push_back(code_ir->Alloc<lir::VRegPair>(reg)); in ShiftParams()
584 code_ir->instructions.insert(first_instr, move); in ShiftParams()
589 void AllocateScratchRegs::Allocate(lir::CodeIr* code_ir, dex::u4 first_reg, int count) { in Allocate() argument
591 code_ir->ir_method->code->registers += count; in Allocate()
605 bool AllocateScratchRegs::Apply(lir::CodeIr* code_ir) { in Apply() argument
606 const auto code = code_ir->ir_method->code; in Apply()
615 Allocate(code_ir, code->registers, left_to_allocate_); in Apply()
621 RegsRenumbering(code_ir); in Apply()
627 ShiftParams(code_ir); in Apply()
643 lir::CodeIr code_ir(ir_method, dex_ir_); in InstrumentMethod() local
645 if (!transformation->Apply(&code_ir)) { in InstrumentMethod()
650 code_ir.Assemble(); in InstrumentMethod()