Lines Matching refs:dex
26 static dex::u2 Pack_Z_8(dex::u4 a) { in Pack_Z_8()
27 dex::u2 fa = (a & 0xff); in Pack_Z_8()
33 static dex::u2 Pack_8_8(dex::u4 a, dex::u4 b) { in Pack_8_8()
34 dex::u2 fa = (a & 0xff); in Pack_8_8()
36 dex::u2 fb = (b & 0xff); in Pack_8_8()
42 static dex::u2 Pack_4_4_8(dex::u4 a, dex::u4 b, dex::u4 c) { in Pack_4_4_8()
43 dex::u2 fa = (a & 0xf); in Pack_4_4_8()
45 dex::u2 fb = (b & 0xf); in Pack_4_4_8()
47 dex::u2 fc = (c & 0xff); in Pack_4_4_8()
53 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()
54 dex::u2 fa = (a & 0xf); in Pack_4_4_4_4()
56 dex::u2 fb = (b & 0xf); in Pack_4_4_4_4()
58 dex::u2 fc = (c & 0xf); in Pack_4_4_4_4()
60 dex::u2 fd = (d & 0xf); in Pack_4_4_4_4()
66 static dex::u2 Pack_16(dex::u4 a) { in Pack_16()
67 dex::u2 fa = (a & 0xffff); in Pack_16()
73 static dex::u4 Trim_S0(dex::u4 value) { in Trim_S0()
74 dex::u4 trim = value & 0xf; in Trim_S0()
75 SLICER_CHECK(dex::u4(dex::s4(trim << 28) >> 28) == value); in Trim_S0()
80 static dex::u4 Trim_S1(dex::u4 value) { in Trim_S1()
81 dex::u4 trim = value & 0xff; in Trim_S1()
82 SLICER_CHECK(dex::u4(dex::s4(trim << 24) >> 24) == value); in Trim_S1()
87 static dex::u4 Trim_S2(dex::u4 value) { in Trim_S2()
88 dex::u4 trim = value & 0xffff; in Trim_S2()
89 SLICER_CHECK(dex::u4(dex::s4(trim << 16) >> 16) == value); in Trim_S2()
95 static dex::u4 GetRegA(const Bytecode* bytecode, int index) { in GetRegA()
96 auto verify_flags = dex::GetVerifyFlagsFromOpcode(bytecode->opcode); in GetRegA()
97 return (verify_flags & dex::kVerifyRegAWide) != 0 in GetRegA()
104 static dex::u4 GetRegB(const Bytecode* bytecode, int index) { in GetRegB()
105 auto verify_flags = dex::GetVerifyFlagsFromOpcode(bytecode->opcode); in GetRegB()
106 return (verify_flags & dex::kVerifyRegBWide) != 0 in GetRegB()
113 static dex::u4 GetRegC(const Bytecode* bytecode, int index) { in GetRegC()
114 auto verify_flags = dex::GetVerifyFlagsFromOpcode(bytecode->opcode); in GetRegC()
115 return (verify_flags & dex::kVerifyRegCWide) != 0 in GetRegC()
127 dex::Opcode opcode = bytecode->opcode; in Visit()
132 if (opcode == dex::OP_GOTO) { in Visit()
133 opcode = dex::OP_GOTO_16; in Visit()
137 auto format = dex::GetFormatFromOpcode(opcode); in Visit()
140 case dex::k10x: // op in Visit()
143 bytecode_.Push<dex::u2>(Pack_Z_8(opcode)); in Visit()
146 case dex::k12x: // op vA, vB in Visit()
149 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
150 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
151 bytecode_.Push<dex::u2>(Pack_4_4_8(vB, vA, opcode)); in Visit()
154 case dex::k22x: // op vAA, vBBBB in Visit()
157 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
158 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
159 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
160 bytecode_.Push<dex::u2>(Pack_16(vB)); in Visit()
163 case dex::k32x: // op vAAAA, vBBBB in Visit()
166 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
167 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
168 bytecode_.Push<dex::u2>(Pack_Z_8(opcode)); in Visit()
169 bytecode_.Push<dex::u2>(Pack_16(vA)); in Visit()
170 bytecode_.Push<dex::u2>(Pack_16(vB)); in Visit()
173 case dex::k11n: // op vA, #+B in Visit()
176 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
177 dex::u4 B = Trim_S0(bytecode->CastOperand<Const32>(1)->u.u4_value); in Visit()
178 bytecode_.Push<dex::u2>(Pack_4_4_8(B, vA, opcode)); in Visit()
181 case dex::k21s: // op vAA, #+BBBB in Visit()
184 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
185 dex::u4 B = Trim_S2(bytecode->CastOperand<Const32>(1)->u.u4_value); in Visit()
186 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
187 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
190 case dex::k11x: // op vAA in Visit()
193 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
194 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
197 case dex::k31i: // op vAA, #+BBBBBBBB in Visit()
200 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
201 dex::u4 B = bytecode->CastOperand<Const32>(1)->u.u4_value; in Visit()
202 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
203 bytecode_.Push<dex::u2>(Pack_16(B & 0xffff)); in Visit()
204 bytecode_.Push<dex::u2>(Pack_16(B >> 16)); in Visit()
207 case dex::k20t: // op +AAAA in Visit()
211 dex::u4 A = 0; in Visit()
220 bytecode_.Push<dex::u2>(Pack_Z_8(opcode)); in Visit()
221 bytecode_.Push<dex::u2>(Pack_16(A & 0xffff)); in Visit()
224 case dex::k30t: // op +AAAAAAAA in Visit()
228 dex::u4 A = 0; in Visit()
236 bytecode_.Push<dex::u2>(Pack_Z_8(opcode)); in Visit()
237 bytecode_.Push<dex::u2>(Pack_16(A & 0xffff)); in Visit()
238 bytecode_.Push<dex::u2>(Pack_16(A >> 16)); in Visit()
241 case dex::k21t: // op vAA, +BBBB in Visit()
244 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
246 dex::u4 B = 0; in Visit()
255 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
256 bytecode_.Push<dex::u2>(Pack_16(B & 0xffff)); in Visit()
259 case dex::k22t: // op vA, vB, +CCCC in Visit()
262 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
263 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
265 dex::u4 C = 0; in Visit()
274 bytecode_.Push<dex::u2>(Pack_4_4_8(vB, vA, opcode)); in Visit()
275 bytecode_.Push<dex::u2>(Pack_16(C & 0xffff)); in Visit()
278 case dex::k31t: // op vAA, +BBBBBBBB in Visit()
281 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
283 dex::u4 B = 0; in Visit()
291 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
292 bytecode_.Push<dex::u2>(Pack_16(B & 0xffff)); in Visit()
293 bytecode_.Push<dex::u2>(Pack_16(B >> 16)); in Visit()
296 case dex::k23x: // op vAA, vBB, vCC in Visit()
299 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
300 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
301 dex::u4 vC = GetRegC(bytecode, 2); in Visit()
302 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
303 bytecode_.Push<dex::u2>(Pack_8_8(vC, vB)); in Visit()
306 case dex::k22b: // op vAA, vBB, #+CC in Visit()
309 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
310 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
311 dex::u4 C = Trim_S1(bytecode->CastOperand<Const32>(2)->u.u4_value); in Visit()
312 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
313 bytecode_.Push<dex::u2>(Pack_8_8(C, vB)); in Visit()
316 case dex::k22s: // op vA, vB, #+CCCC in Visit()
319 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
320 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
321 dex::u4 C = Trim_S2(bytecode->CastOperand<Const32>(2)->u.u4_value); in Visit()
322 bytecode_.Push<dex::u2>(Pack_4_4_8(vB, vA, opcode)); in Visit()
323 bytecode_.Push<dex::u2>(Pack_16(C)); in Visit()
326 case dex::k22c: // op vA, vB, thing@CCCC in Visit()
329 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
330 dex::u4 vB = GetRegB(bytecode, 1); in Visit()
331 dex::u4 C = bytecode->CastOperand<IndexedOperand>(2)->index; in Visit()
332 bytecode_.Push<dex::u2>(Pack_4_4_8(vB, vA, opcode)); in Visit()
333 bytecode_.Push<dex::u2>(Pack_16(C)); in Visit()
336 case dex::k21c: // op vAA, thing@BBBB in Visit()
339 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
340 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
341 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
342 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
345 case dex::k31c: // op vAA, string@BBBBBBBB in Visit()
348 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
349 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
350 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
351 bytecode_.Push<dex::u2>(Pack_16(B & 0xffff)); in Visit()
352 bytecode_.Push<dex::u2>(Pack_16(B >> 16)); in Visit()
355 case dex::k35c: // op {vC,vD,vE,vF,vG}, thing@BBBB in Visit()
359 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
360 dex::u4 A = regs.size(); in Visit()
361 dex::u4 C = (A > 0) ? regs[0] : 0; in Visit()
362 dex::u4 D = (A > 1) ? regs[1] : 0; in Visit()
363 dex::u4 E = (A > 2) ? regs[2] : 0; in Visit()
364 dex::u4 F = (A > 3) ? regs[3] : 0; in Visit()
365 dex::u4 G = (A > 4) ? regs[4] : 0; in Visit()
366 bytecode_.Push<dex::u2>(Pack_4_4_8(A, G, opcode)); in Visit()
367 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
368 bytecode_.Push<dex::u2>(Pack_4_4_4_4(F, E, D, C)); in Visit()
371 if ((dex::GetFlagsFromOpcode(opcode) & dex::kInvoke) != 0) { in Visit()
376 case dex::k3rc: // op {vCCCC .. v(CCCC+AA-1)}, thing@BBBB in Visit()
380 dex::u4 A = vreg_range->count; in Visit()
381 dex::u4 B = bytecode->CastOperand<IndexedOperand>(1)->index; in Visit()
382 dex::u4 C = vreg_range->base_reg; in Visit()
383 bytecode_.Push<dex::u2>(Pack_8_8(A, opcode)); in Visit()
384 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
385 bytecode_.Push<dex::u2>(Pack_16(C)); in Visit()
388 if ((dex::GetFlagsFromOpcode(opcode) & dex::kInvoke) != 0) { in Visit()
393 case dex::k51l: // op vAA, #+BBBBBBBBBBBBBBBB in Visit()
396 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
397 dex::u8 B = bytecode->CastOperand<Const64>(1)->u.u8_value; in Visit()
398 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
399 bytecode_.Push<dex::u2>(Pack_16((B >> 0) & 0xffff)); in Visit()
400 bytecode_.Push<dex::u2>(Pack_16((B >> 16) & 0xffff)); in Visit()
401 bytecode_.Push<dex::u2>(Pack_16((B >> 32) & 0xffff)); in Visit()
402 bytecode_.Push<dex::u2>(Pack_16((B >> 48) & 0xffff)); in Visit()
405 case dex::k21h: // op vAA, #+BBBB0000[00000000] in Visit()
408 case dex::OP_CONST_HIGH16: { in Visit()
409 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
410 dex::u4 B = bytecode->CastOperand<Const32>(1)->u.u4_value >> 16; in Visit()
411 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
412 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
415 case dex::OP_CONST_WIDE_HIGH16: { in Visit()
416 dex::u4 vA = GetRegA(bytecode, 0); in Visit()
417 dex::u4 B = bytecode->CastOperand<Const64>(1)->u.u8_value >> 48; in Visit()
418 bytecode_.Push<dex::u2>(Pack_8_8(vA, opcode)); in Visit()
419 bytecode_.Push<dex::u2>(Pack_16(B)); in Visit()
447 bytecode_.Push<dex::u2>(dex::kPackedSwitchSignature); in Visit()
448 bytecode_.Push<dex::u2>(Pack_16(packed_switch->targets.size())); in Visit()
449 bytecode_.Push<dex::s4>(packed_switch->first_key); in Visit()
451 bytecode_.Push<dex::u4>(0); in Visit()
471 bytecode_.Push<dex::u2>(dex::kSparseSwitchSignature); in Visit()
472 bytecode_.Push<dex::u2>(Pack_16(sparse_switch->switch_cases.size())); in Visit()
474 bytecode_.Push<dex::s4>(switch_case.key); in Visit()
477 bytecode_.Push<dex::u4>(0); in Visit()
499 bytecode_.Push<dex::u2>(dex::OP_NOP); in Visit()
528 dex::u2* const begin = bytecode_.ptr<dex::u2>(0); in FixupSwitchOffsets()
529 dex::u2* const end = begin + bytecode_.size() / 2; in FixupSwitchOffsets()
530 dex::u2* ptr = begin; in FixupSwitchOffsets()
532 const auto opcode = dex::OpcodeFromBytecode(*ptr); in FixupSwitchOffsets()
534 if (opcode == dex::OP_PACKED_SWITCH) { in FixupSwitchOffsets()
535 auto dex_instr = dex::DecodeInstruction(ptr); in FixupSwitchOffsets()
536 FixupPackedSwitch(offset, offset + dex::s4(dex_instr.vB)); in FixupSwitchOffsets()
537 } else if (opcode == dex::OP_SPARSE_SWITCH) { in FixupSwitchOffsets()
538 auto dex_instr = dex::DecodeInstruction(ptr); in FixupSwitchOffsets()
539 FixupSparseSwitch(offset, offset + dex::s4(dex_instr.vB)); in FixupSwitchOffsets()
541 auto isize = dex::GetWidthFromBytecode(ptr); in FixupSwitchOffsets()
548 void BytecodeEncoder::FixupPackedSwitch(dex::u4 base_offset, in FixupPackedSwitch()
549 dex::u4 payload_offset) { in FixupPackedSwitch()
553 auto payload = bytecode_.ptr<dex::PackedSwitchPayload>(payload_offset * 2); in FixupPackedSwitch()
554 SLICER_CHECK(payload->ident == dex::kPackedSwitchSignature); in FixupPackedSwitch()
555 SLICER_CHECK(reinterpret_cast<dex::u1*>(payload->targets + payload->size) <= in FixupPackedSwitch()
565 void BytecodeEncoder::FixupSparseSwitch(dex::u4 base_offset, in FixupSparseSwitch()
566 dex::u4 payload_offset) { in FixupSparseSwitch()
570 auto payload = bytecode_.ptr<dex::SparseSwitchPayload>(payload_offset * 2); in FixupSparseSwitch()
571 SLICER_CHECK(payload->ident == dex::kSparseSwitchSignature); in FixupSparseSwitch()
573 dex::s4* const targets = payload->data + payload->size; in FixupSparseSwitch()
574 SLICER_CHECK(reinterpret_cast<dex::u1*>(targets + payload->size) <= in FixupSparseSwitch()
586 dex::u4 label_offset = fixup.label->offset; in FixupLabels()
589 dex::u4 rel_offset = label_offset - fixup.offset; in FixupLabels()
591 dex::u2* instr = bytecode_.ptr<dex::u2>(fixup.offset * 2); in FixupLabels()
630 ir_code->instructions = slicer::ArrayView<const dex::u2>( in Encode()
631 bytecode_.ptr<dex::u2>(0), bytecode_.size() / 2); in Encode()