Lines Matching refs:dex
29 static dex::u2 Pack_Z_8(dex::u4 a) { in Pack_Z_8()
30 dex::u2 fa = (a & 0xff); in Pack_Z_8()
36 static dex::u2 Pack_8_8(dex::u4 a, dex::u4 b) { in Pack_8_8()
37 dex::u2 fa = (a & 0xff); in Pack_8_8()
39 dex::u2 fb = (b & 0xff); in Pack_8_8()
45 static dex::u2 Pack_4_4_8(dex::u4 a, dex::u4 b, dex::u4 c) { in Pack_4_4_8()
46 dex::u2 fa = (a & 0xf); in Pack_4_4_8()
48 dex::u2 fb = (b & 0xf); in Pack_4_4_8()
50 dex::u2 fc = (c & 0xff); in Pack_4_4_8()
56 static dex::u2 Pack_4_4_4_4(dex::u4 a, dex::u4 b, dex::u4 c, dex::u4 d) { in Pack_4_4_4_4()
57 dex::u2 fa = (a & 0xf); in Pack_4_4_4_4()
59 dex::u2 fb = (b & 0xf); in Pack_4_4_4_4()
61 dex::u2 fc = (c & 0xf); in Pack_4_4_4_4()
63 dex::u2 fd = (d & 0xf); in Pack_4_4_4_4()
69 static dex::u2 Pack_16(dex::u4 a) { in Pack_16()
70 dex::u2 fa = (a & 0xffff); in Pack_16()
76 static dex::u4 Trim_S0(dex::u4 value) { in Trim_S0()
77 dex::u4 trim = value & 0xf; in Trim_S0()
78 SLICER_CHECK_EQ(dex::u4(dex::s4(trim << 28) >> 28), value); in Trim_S0()
83 static dex::u4 Trim_S1(dex::u4 value) { in Trim_S1()
84 dex::u4 trim = value & 0xff; in Trim_S1()
85 SLICER_CHECK_EQ(dex::u4(dex::s4(trim << 24) >> 24), value); in Trim_S1()
90 static dex::u4 Trim_S2(dex::u4 value) { in Trim_S2()
91 dex::u4 trim = value & 0xffff; in Trim_S2()
92 SLICER_CHECK_EQ(dex::u4(dex::s4(trim << 16) >> 16), value); in Trim_S2()
98 static dex::u4 GetRegA(const Bytecode* bytecode, int index) { in GetRegA()
99 auto verify_flags = dex::GetVerifyFlagsFromOpcode(bytecode->opcode); in GetRegA()
100 return (verify_flags & dex::kVerifyRegAWide) != 0 in GetRegA()
107 static dex::u4 GetRegB(const Bytecode* bytecode, int index) { in GetRegB()
108 auto verify_flags = dex::GetVerifyFlagsFromOpcode(bytecode->opcode); in GetRegB()
109 return (verify_flags & dex::kVerifyRegBWide) != 0 in GetRegB()
116 static dex::u4 GetRegC(const Bytecode* bytecode, int index) { in GetRegC()
117 auto verify_flags = dex::GetVerifyFlagsFromOpcode(bytecode->opcode); in GetRegC()
118 return (verify_flags & dex::kVerifyRegCWide) != 0 in GetRegC()
130 dex::Opcode opcode = bytecode->opcode; in Visit()
135 if (opcode == dex::OP_GOTO) { in Visit()
136 opcode = dex::OP_GOTO_16; in Visit()
140 auto format = dex::GetFormatFromOpcode(opcode); in Visit()
143 case dex::k10x: // op in Visit()
146 bytecode_.Push<dex::u2>(Pack_Z_8(opcode)); in Visit()
149 case dex::k12x: // op vA, vB in Visit()
152 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
153 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
154 bytecode_.Push<dex::u2>(Pack_4_4_8(vB, vA, opcode)); in Visit()
157 case dex::k22x: // op vAA, vBBBB in Visit()
160 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
161 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
162 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
163 bytecode_.Push<dex::u2>(Pack_16(vB)); in Visit()
166 case dex::k32x: // op vAAAA, vBBBB in Visit()
169 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
170 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
171 bytecode_.Push<dex::u2>(Pack_Z_8(opcode)); in Visit()
172 bytecode_.Push<dex::u2>(Pack_16(vA)); in Visit()
173 bytecode_.Push<dex::u2>(Pack_16(vB)); in Visit()
176 case dex::k11n: // op vA, #+B in Visit()
179 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
180 dex::u4 B = Trim_S0(bytecode->CastOperand<Const32>(1)->u.u4_value); in Visit()
181 bytecode_.Push<dex::u2>(Pack_4_4_8(B, vA, opcode)); in Visit()
184 case dex::k21s: // op vAA, #+BBBB in Visit()
187 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
188 dex::u4 B = Trim_S2(bytecode->CastOperand<Const32>(1)->u.u4_value); in Visit()
189 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
190 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
193 case dex::k11x: // op vAA in Visit()
196 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
197 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
200 case dex::k31i: // op vAA, #+BBBBBBBB in Visit()
203 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
204 dex::u4 B = bytecode->CastOperand<Const32>(1)->u.u4_value; in Visit()
205 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
206 bytecode_.Push<dex::u2>(Pack_16(B & 0xffff)); in Visit()
207 bytecode_.Push<dex::u2>(Pack_16(B >> 16)); in Visit()
210 case dex::k20t: // op +AAAA in Visit()
214 dex::u4 A = 0; in Visit()
223 bytecode_.Push<dex::u2>(Pack_Z_8(opcode)); in Visit()
224 bytecode_.Push<dex::u2>(Pack_16(A & 0xffff)); in Visit()
227 case dex::k30t: // op +AAAAAAAA in Visit()
231 dex::u4 A = 0; in Visit()
239 bytecode_.Push<dex::u2>(Pack_Z_8(opcode)); in Visit()
240 bytecode_.Push<dex::u2>(Pack_16(A & 0xffff)); in Visit()
241 bytecode_.Push<dex::u2>(Pack_16(A >> 16)); in Visit()
244 case dex::k21t: // op vAA, +BBBB in Visit()
247 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
249 dex::u4 B = 0; in Visit()
258 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
259 bytecode_.Push<dex::u2>(Pack_16(B & 0xffff)); in Visit()
262 case dex::k22t: // op vA, vB, +CCCC in Visit()
265 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
266 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
268 dex::u4 C = 0; in Visit()
277 bytecode_.Push<dex::u2>(Pack_4_4_8(vB, vA, opcode)); in Visit()
278 bytecode_.Push<dex::u2>(Pack_16(C & 0xffff)); in Visit()
281 case dex::k31t: // op vAA, +BBBBBBBB in Visit()
284 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
286 dex::u4 B = 0; in Visit()
294 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
295 bytecode_.Push<dex::u2>(Pack_16(B & 0xffff)); in Visit()
296 bytecode_.Push<dex::u2>(Pack_16(B >> 16)); in Visit()
299 case dex::k23x: // op vAA, vBB, vCC in Visit()
302 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
303 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
304 dex::u4 vC = GetRegC(bytecode, 2); in Visit()
305 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
306 bytecode_.Push<dex::u2>(Pack_8_8(vC, vB)); in Visit()
309 case dex::k22b: // op vAA, vBB, #+CC in Visit()
312 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
313 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
314 dex::u4 C = Trim_S1(bytecode->CastOperand<Const32>(2)->u.u4_value); in Visit()
315 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
316 bytecode_.Push<dex::u2>(Pack_8_8(C, vB)); in Visit()
319 case dex::k22s: // op vA, vB, #+CCCC in Visit()
322 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
323 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
324 dex::u4 C = Trim_S2(bytecode->CastOperand<Const32>(2)->u.u4_value); in Visit()
325 bytecode_.Push<dex::u2>(Pack_4_4_8(vB, vA, opcode)); in Visit()
326 bytecode_.Push<dex::u2>(Pack_16(C)); in Visit()
329 case dex::k22c: // op vA, vB, thing@CCCC in Visit()
332 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
333 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
334 dex::u4 C = bytecode->CastOperand<IndexedOperand>(2)->index; in Visit()
335 bytecode_.Push<dex::u2>(Pack_4_4_8(vB, vA, opcode)); in Visit()
336 bytecode_.Push<dex::u2>(Pack_16(C)); in Visit()
339 case dex::k21c: // op vAA, thing@BBBB in Visit()
342 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
343 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
344 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
345 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
348 case dex::k31c: // op vAA, string@BBBBBBBB in Visit()
351 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
352 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
353 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
354 bytecode_.Push<dex::u2>(Pack_16(B & 0xffff)); in Visit()
355 bytecode_.Push<dex::u2>(Pack_16(B >> 16)); in Visit()
358 case dex::k35c: // op {vC,vD,vE,vF,vG}, thing@BBBB in Visit()
362 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
363 dex::u4 A = regs.size(); in Visit()
364 dex::u4 C = (A > 0) ? regs[0] : 0; in Visit()
365 dex::u4 D = (A > 1) ? regs[1] : 0; in Visit()
366 dex::u4 E = (A > 2) ? regs[2] : 0; in Visit()
367 dex::u4 F = (A > 3) ? regs[3] : 0; in Visit()
368 dex::u4 G = (A > 4) ? regs[4] : 0; in Visit()
369 bytecode_.Push<dex::u2>(Pack_4_4_8(A, G, opcode)); in Visit()
370 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
371 bytecode_.Push<dex::u2>(Pack_4_4_4_4(F, E, D, C)); in Visit()
374 if ((dex::GetFlagsFromOpcode(opcode) & dex::kInvoke) != 0) { in Visit()
379 case dex::k3rc: // op {vCCCC .. v(CCCC+AA-1)}, thing@BBBB in Visit()
383 dex::u4 A = vreg_range->count; in Visit()
384 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
385 dex::u4 C = vreg_range->base_reg; in Visit()
386 bytecode_.Push<dex::u2>(Pack_8_8(A, opcode)); in Visit()
387 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
388 bytecode_.Push<dex::u2>(Pack_16(C)); in Visit()
391 if ((dex::GetFlagsFromOpcode(opcode) & dex::kInvoke) != 0) { in Visit()
396 case dex::k51l: // op vAA, #+BBBBBBBBBBBBBBBB in Visit()
399 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
400 dex::u8 B = bytecode->CastOperand<Const64>(1)->u.u8_value; in Visit()
401 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
402 bytecode_.Push<dex::u2>(Pack_16((B >> 0) & 0xffff)); in Visit()
403 bytecode_.Push<dex::u2>(Pack_16((B >> 16) & 0xffff)); in Visit()
404 bytecode_.Push<dex::u2>(Pack_16((B >> 32) & 0xffff)); in Visit()
405 bytecode_.Push<dex::u2>(Pack_16((B >> 48) & 0xffff)); in Visit()
408 case dex::k45cc: // op {vC, vD, vE, vF, vG}, thing@BBBB, other@HHHH in Visit()
412 dex::u4 A = regs.size(); in Visit()
413 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
414 dex::u4 H = bytecode->CastOperand<IndexedOperand>(2)->index; in Visit()
415 dex::u4 C = (A > 0) ? regs[0] : 0; in Visit()
416 dex::u4 D = (A > 1) ? regs[1] : 0; in Visit()
417 dex::u4 E = (A > 2) ? regs[2] : 0; in Visit()
418 dex::u4 F = (A > 3) ? regs[3] : 0; in Visit()
419 dex::u4 G = (A > 4) ? regs[4] : 0; in Visit()
420 bytecode_.Push<dex::u2>(Pack_4_4_8(A, G, opcode)); in Visit()
421 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
422 bytecode_.Push<dex::u2>(Pack_4_4_4_4(F, E, D, C)); in Visit()
423 bytecode_.Push<dex::u2>(Pack_16(H)); in Visit()
426 if ((dex::GetFlagsFromOpcode(opcode) & dex::kInvoke) != 0) { in Visit()
431 case dex::k4rcc: // op {vCCCC .. v(CCCC+AA-1)}, thing@BBBB, other@HHHH in Visit()
435 dex::u4 A = vreg_range->count; in Visit()
436 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
437 dex::u4 C = vreg_range->base_reg; in Visit()
438 dex::u4 H = bytecode->CastOperand<IndexedOperand>(2)->index; in Visit()
439 bytecode_.Push<dex::u2>(Pack_8_8(A, opcode)); in Visit()
440 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
441 bytecode_.Push<dex::u2>(Pack_16(C)); in Visit()
442 bytecode_.Push<dex::u2>(Pack_16(H)); in Visit()
445 if ((dex::GetFlagsFromOpcode(opcode) & dex::kInvoke) != 0) { in Visit()
450 case dex::k21h: // op vAA, #+BBBB0000[00000000] in Visit()
453 case dex::OP_CONST_HIGH16: { in Visit()
454 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
455 dex::u4 B = bytecode->CastOperand<Const32>(1)->u.u4_value >> 16; in Visit()
456 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
457 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
460 case dex::OP_CONST_WIDE_HIGH16: { in Visit()
461 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
462 dex::u4 B = bytecode->CastOperand<Const64>(1)->u.u8_value >> 48; in Visit()
463 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
464 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
498 bytecode_.Push<dex::u2>(dex::kPackedSwitchSignature); in Visit()
499 bytecode_.Push<dex::u2>(Pack_16(packed_switch->targets.size())); in Visit()
500 bytecode_.Push<dex::s4>(packed_switch->first_key); in Visit()
502 bytecode_.Push<dex::u4>(0); in Visit()
522 bytecode_.Push<dex::u2>(dex::kSparseSwitchSignature); in Visit()
523 bytecode_.Push<dex::u2>(Pack_16(sparse_switch->switch_cases.size())); in Visit()
525 bytecode_.Push<dex::s4>(switch_case.key); in Visit()
528 bytecode_.Push<dex::u4>(0); in Visit()
550 bytecode_.Push<dex::u2>(dex::OP_NOP); in Visit()
579 dex::u2* const begin = bytecode_.ptr<dex::u2>(0); in FixupSwitchOffsets()
580 dex::u2* const end = begin + bytecode_.size() / 2; in FixupSwitchOffsets()
581 dex::u2* ptr = begin; in FixupSwitchOffsets()
583 const auto opcode = dex::OpcodeFromBytecode(*ptr); in FixupSwitchOffsets()
585 if (opcode == dex::OP_PACKED_SWITCH) { in FixupSwitchOffsets()
586 auto dex_instr = dex::DecodeInstruction(ptr); in FixupSwitchOffsets()
587 FixupPackedSwitch(offset, offset + dex::s4(dex_instr.vB)); in FixupSwitchOffsets()
588 } else if (opcode == dex::OP_SPARSE_SWITCH) { in FixupSwitchOffsets()
589 auto dex_instr = dex::DecodeInstruction(ptr); in FixupSwitchOffsets()
590 FixupSparseSwitch(offset, offset + dex::s4(dex_instr.vB)); in FixupSwitchOffsets()
592 auto isize = dex::GetWidthFromBytecode(ptr); in FixupSwitchOffsets()
599 void BytecodeEncoder::FixupPackedSwitch(dex::u4 base_offset, in FixupPackedSwitch()
600 dex::u4 payload_offset) { in FixupPackedSwitch()
604 auto payload = bytecode_.ptr<dex::PackedSwitchPayload>(payload_offset * 2); in FixupPackedSwitch()
605 SLICER_CHECK_EQ(payload->ident, dex::kPackedSwitchSignature); in FixupPackedSwitch()
606 SLICER_CHECK(reinterpret_cast<dex::u1*>(payload->targets + payload->size) <= in FixupPackedSwitch()
616 void BytecodeEncoder::FixupSparseSwitch(dex::u4 base_offset, in FixupSparseSwitch()
617 dex::u4 payload_offset) { in FixupSparseSwitch()
621 auto payload = bytecode_.ptr<dex::SparseSwitchPayload>(payload_offset * 2); in FixupSparseSwitch()
622 SLICER_CHECK_EQ(payload->ident, dex::kSparseSwitchSignature); in FixupSparseSwitch()
624 dex::s4* const targets = payload->data + payload->size; in FixupSparseSwitch()
625 SLICER_CHECK(reinterpret_cast<dex::u1*>(targets + payload->size) <= in FixupSparseSwitch()
637 dex::u4 label_offset = fixup.label->offset; in FixupLabels()
640 dex::u4 rel_offset = label_offset - fixup.offset; in FixupLabels()
642 dex::u2* instr = bytecode_.ptr<dex::u2>(fixup.offset * 2); in FixupLabels()
681 ir_code->instructions = slicer::ArrayView<const dex::u2>( in Encode()
682 bytecode_.ptr<dex::u2>(0), bytecode_.size() / 2); in Encode()