blob: d06a346bc37942caec2e96383caaa2367ae8edd2 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Carl Shapiro12eb78e2011-06-24 14:51:06 -070016
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070017#include "dex_instruction.h"
Carl Shapiro12eb78e2011-06-24 14:51:06 -070018
Ian Rogersd81871c2011-10-03 13:57:23 -070019#include "dex_file.h"
20#include <iomanip>
21
Carl Shapiro12eb78e2011-06-24 14:51:06 -070022namespace art {
23
Carl Shapiroe4c1ce42011-07-09 02:31:57 -070024const char* const Instruction::kInstructionNames[] = {
jeffhaoba5ebb92011-08-25 17:24:37 -070025#define INSTRUCTION_NAME(o, c, pname, f, r, i, a, v) pname,
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070026#include "dex_instruction_list.h"
Carl Shapiroe4c1ce42011-07-09 02:31:57 -070027 DEX_INSTRUCTION_LIST(INSTRUCTION_NAME)
28#undef DEX_INSTRUCTION_LIST
29#undef INSTRUCTION_NAME
30};
31
Elliott Hughesadb8c672012-03-06 16:49:32 -080032Instruction::Format const Instruction::kInstructionFormats[] = {
jeffhaoba5ebb92011-08-25 17:24:37 -070033#define INSTRUCTION_FORMAT(o, c, p, format, r, i, a, v) format,
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070034#include "dex_instruction_list.h"
Carl Shapiroe4c1ce42011-07-09 02:31:57 -070035 DEX_INSTRUCTION_LIST(INSTRUCTION_FORMAT)
36#undef DEX_INSTRUCTION_LIST
37#undef INSTRUCTION_FORMAT
38};
39
40int const Instruction::kInstructionFlags[] = {
jeffhaoba5ebb92011-08-25 17:24:37 -070041#define INSTRUCTION_FLAGS(o, c, p, f, r, i, flags, v) flags,
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070042#include "dex_instruction_list.h"
Carl Shapiroe4c1ce42011-07-09 02:31:57 -070043 DEX_INSTRUCTION_LIST(INSTRUCTION_FLAGS)
44#undef DEX_INSTRUCTION_LIST
45#undef INSTRUCTION_FLAGS
46};
47
jeffhaoba5ebb92011-08-25 17:24:37 -070048int const Instruction::kInstructionVerifyFlags[] = {
49#define INSTRUCTION_VERIFY_FLAGS(o, c, p, f, r, i, a, vflags) vflags,
50#include "dex_instruction_list.h"
51 DEX_INSTRUCTION_LIST(INSTRUCTION_VERIFY_FLAGS)
52#undef DEX_INSTRUCTION_LIST
53#undef INSTRUCTION_VERIFY_FLAGS
54};
55
56/*
57 * Handy macros for helping decode instructions.
58 */
59#define FETCH(_offset) (insns[(_offset)])
60#define FETCH_u4(_offset) (fetch_u4_impl((_offset), insns))
61#define INST_A(_insn) (((uint16_t)(_insn) >> 8) & 0x0f)
62#define INST_B(_insn) ((uint16_t)(_insn) >> 12)
63#define INST_AA(_insn) ((_insn) >> 8)
64
65/* Helper for FETCH_u4, above. */
66static inline uint32_t fetch_u4_impl(uint32_t offset, const uint16_t* insns) {
67 return insns[offset] | ((uint32_t) insns[offset+1] << 16);
68}
69
70void Instruction::Decode(uint32_t &vA, uint32_t &vB, uint64_t &vB_wide, uint32_t &vC, uint32_t arg[]) const {
71 const uint16_t* insns = reinterpret_cast<const uint16_t*>(this);
72 uint16_t insn = *insns;
73 int opcode = insn & 0xFF;
74
Elliott Hughesadb8c672012-03-06 16:49:32 -080075 switch (FormatOf(Opcode())) {
jeffhaoba5ebb92011-08-25 17:24:37 -070076 case k10x: // op
77 /* nothing to do; copy the AA bits out for the verifier */
78 vA = INST_AA(insn);
79 break;
80 case k12x: // op vA, vB
81 vA = INST_A(insn);
82 vB = INST_B(insn);
83 break;
84 case k11n: // op vA, #+B
85 vA = INST_A(insn);
86 vB = (int32_t) (INST_B(insn) << 28) >> 28; // sign extend 4-bit value
87 break;
88 case k11x: // op vAA
89 vA = INST_AA(insn);
90 break;
91 case k10t: // op +AA
92 vA = (int8_t) INST_AA(insn); // sign-extend 8-bit value
93 break;
94 case k20t: // op +AAAA
95 vA = (int16_t) FETCH(1); // sign-extend 16-bit value
96 break;
97 case k21c: // op vAA, thing@BBBB
98 case k22x: // op vAA, vBBBB
99 vA = INST_AA(insn);
100 vB = FETCH(1);
101 break;
102 case k21s: // op vAA, #+BBBB
103 case k21t: // op vAA, +BBBB
104 vA = INST_AA(insn);
105 vB = (int16_t) FETCH(1); // sign-extend 16-bit value
106 break;
107 case k21h: // op vAA, #+BBBB0000[00000000]
108 vA = INST_AA(insn);
109 /*
110 * The value should be treated as right-zero-extended, but we don't
111 * actually do that here. Among other things, we don't know if it's
112 * the top bits of a 32- or 64-bit value.
113 */
114 vB = FETCH(1);
115 break;
116 case k23x: // op vAA, vBB, vCC
117 vA = INST_AA(insn);
118 vB = FETCH(1) & 0xff;
119 vC = FETCH(1) >> 8;
120 break;
121 case k22b: // op vAA, vBB, #+CC
122 vA = INST_AA(insn);
123 vB = FETCH(1) & 0xff;
124 vC = (int8_t) (FETCH(1) >> 8); // sign-extend 8-bit value
125 break;
126 case k22s: // op vA, vB, #+CCCC
127 case k22t: // op vA, vB, +CCCC
128 vA = INST_A(insn);
129 vB = INST_B(insn);
130 vC = (int16_t) FETCH(1); // sign-extend 16-bit value
131 break;
132 case k22c: // op vA, vB, thing@CCCC
133 vA = INST_A(insn);
134 vB = INST_B(insn);
135 vC = FETCH(1);
136 break;
137 case k30t: // op +AAAAAAAA
138 vA = FETCH_u4(1); // signed 32-bit value
139 break;
140 case k31t: // op vAA, +BBBBBBBB
141 case k31c: // op vAA, string@BBBBBBBB
142 vA = INST_AA(insn);
143 vB = FETCH_u4(1); // 32-bit value
144 break;
145 case k32x: // op vAAAA, vBBBB
146 vA = FETCH(1);
147 vB = FETCH(2);
148 break;
149 case k31i: // op vAA, #+BBBBBBBB
150 vA = INST_AA(insn);
151 vB = FETCH_u4(1); // signed 32-bit value
152 break;
153 case k35c: // op {vC, vD, vE, vF, vG}, thing@BBBB
154 {
155 /*
156 * Note that the fields mentioned in the spec don't appear in
157 * their "usual" positions here compared to most formats. This
158 * was done so that the field names for the argument count and
159 * reference index match between this format and the corresponding
160 * range formats (3rc and friends).
161 *
162 * Bottom line: The argument count is always in vA, and the
163 * method constant (or equivalent) is always in vB.
164 */
165 uint16_t regList;
166 int count;
167
168 vA = INST_B(insn); // This is labeled A in the spec.
169 vB = FETCH(1);
170 regList = FETCH(2);
171
172 count = vA;
173
174 /*
175 * Copy the argument registers into the arg[] array, and
176 * also copy the first argument (if any) into vC. (The
177 * DecodedInstruction structure doesn't have separate
178 * fields for {vD, vE, vF, vG}, so there's no need to make
179 * copies of those.) Note that cases 5..2 fall through.
180 */
181 switch (count) {
182 case 5: arg[4] = INST_A(insn);
183 case 4: arg[3] = (regList >> 12) & 0x0f;
184 case 3: arg[2] = (regList >> 8) & 0x0f;
185 case 2: arg[1] = (regList >> 4) & 0x0f;
186 case 1: vC = arg[0] = regList & 0x0f; break;
187 case 0: break; // Valid, but no need to do anything.
188 default:
189 LOG(ERROR) << "Invalid arg count in 35c (" << count << ")";
190 return;
191 }
192 }
193 break;
194 case k3rc: // op {vCCCC .. v(CCCC+AA-1)}, meth@BBBB
195 vA = INST_AA(insn);
196 vB = FETCH(1);
197 vC = FETCH(2);
198 break;
199 case k51l: // op vAA, #+BBBBBBBBBBBBBBBB
200 vA = INST_AA(insn);
201 vB_wide = FETCH_u4(1) | ((uint64_t) FETCH_u4(3) << 32);
202 break;
203 default:
Elliott Hughesadb8c672012-03-06 16:49:32 -0800204 LOG(ERROR) << "Can't decode unexpected format " << static_cast<int>(FormatOf(Opcode())) << " (op=" << opcode << ")";
jeffhaoba5ebb92011-08-25 17:24:37 -0700205 return;
206 }
207}
208
Ian Rogersd81871c2011-10-03 13:57:23 -0700209size_t Instruction::SizeInCodeUnits() const {
Carl Shapiro12eb78e2011-06-24 14:51:06 -0700210 const uint16_t* insns = reinterpret_cast<const uint16_t*>(this);
Elliott Hughesadb8c672012-03-06 16:49:32 -0800211 if (*insns == Instruction::kPackedSwitchSignature) {
jeffhaoba5ebb92011-08-25 17:24:37 -0700212 return (4 + insns[1] * 2);
Elliott Hughesadb8c672012-03-06 16:49:32 -0800213 } else if (*insns == Instruction::kSparseSwitchSignature) {
jeffhaoba5ebb92011-08-25 17:24:37 -0700214 return (2 + insns[1] * 4);
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700215 } else if (*insns == kArrayDataSignature) {
216 uint16_t element_size = insns[1];
217 uint32_t length = insns[2] | (((uint32_t)insns[3]) << 16);
218 // The plus 1 is to round up for odd size and width.
jeffhaoba5ebb92011-08-25 17:24:37 -0700219 return (4 + (element_size * length + 1) / 2);
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700220 } else {
Elliott Hughesadb8c672012-03-06 16:49:32 -0800221 switch (FormatOf(Opcode())) {
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700222 case k10x:
223 case k12x:
224 case k11n:
225 case k11x:
226 case k10t:
jeffhaoba5ebb92011-08-25 17:24:37 -0700227 return 1;
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700228 case k20t:
229 case k22x:
230 case k21t:
231 case k21s:
232 case k21h:
233 case k21c:
234 case k23x:
235 case k22b:
236 case k22t:
237 case k22s:
238 case k22c:
jeffhaoba5ebb92011-08-25 17:24:37 -0700239 return 2;
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700240 case k32x:
241 case k30t:
242 case k31t:
243 case k31i:
244 case k31c:
245 case k35c:
246 case k3rc:
jeffhaoba5ebb92011-08-25 17:24:37 -0700247 return 3;
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700248 case k51l:
jeffhaoba5ebb92011-08-25 17:24:37 -0700249 return 5;
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700250 default:
251 LOG(FATAL) << "Unreachable";
252 }
253 }
jeffhaoba5ebb92011-08-25 17:24:37 -0700254 return 0;
Carl Shapiro12eb78e2011-06-24 14:51:06 -0700255}
256
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700257Instruction::Code Instruction::Opcode() const {
Carl Shapiro12eb78e2011-06-24 14:51:06 -0700258 const uint16_t* insns = reinterpret_cast<const uint16_t*>(this);
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700259 int opcode = *insns & 0xFF;
260 return static_cast<Code>(opcode);
Carl Shapiro12eb78e2011-06-24 14:51:06 -0700261}
262
Carl Shapiroe4c1ce42011-07-09 02:31:57 -0700263const Instruction* Instruction::Next() const {
Ian Rogersd81871c2011-10-03 13:57:23 -0700264 size_t current_size_in_bytes = SizeInCodeUnits() * sizeof(uint16_t);
Carl Shapiro12eb78e2011-06-24 14:51:06 -0700265 const uint8_t* ptr = reinterpret_cast<const uint8_t*>(this);
Ian Rogersd81871c2011-10-03 13:57:23 -0700266 return reinterpret_cast<const Instruction*>(ptr + current_size_in_bytes);
267}
268
Ian Rogers2c8a8572011-10-24 17:11:36 -0700269std::string Instruction::DumpHex(size_t code_units) const {
Ian Rogersd81871c2011-10-03 13:57:23 -0700270 size_t inst_length = SizeInCodeUnits();
271 if (inst_length > code_units) {
272 inst_length = code_units;
273 }
Ian Rogers2c8a8572011-10-24 17:11:36 -0700274 std::ostringstream os;
Ian Rogersd81871c2011-10-03 13:57:23 -0700275 const uint16_t* insn = reinterpret_cast<const uint16_t*>(this);
276 for (size_t i = 0; i < inst_length; i++) {
Ian Rogers2c8a8572011-10-24 17:11:36 -0700277 os << StringPrintf("0x%04x", insn[i]) << " ";
Ian Rogersd81871c2011-10-03 13:57:23 -0700278 }
279 for (size_t i = inst_length; i < code_units; i++) {
280 os << " ";
281 }
Ian Rogers2c8a8572011-10-24 17:11:36 -0700282 return os.str();
Ian Rogersd81871c2011-10-03 13:57:23 -0700283}
284
Ian Rogers2c8a8572011-10-24 17:11:36 -0700285std::string Instruction::DumpString(const DexFile* file) const {
Ian Rogersd81871c2011-10-03 13:57:23 -0700286 DecodedInstruction insn(this);
Ian Rogers2c8a8572011-10-24 17:11:36 -0700287 std::ostringstream os;
Elliott Hughesadb8c672012-03-06 16:49:32 -0800288 const char* opcode = kInstructionNames[insn.opcode];
289 switch (FormatOf(Opcode())) {
Elliott Hughese3c845c2012-02-28 17:23:01 -0800290 case k10x: os << opcode; break;
Elliott Hughesadb8c672012-03-06 16:49:32 -0800291 case k12x: os << StringPrintf("%s v%d, v%d", opcode, insn.vA, insn.vB); break;
292 case k11n: os << StringPrintf("%s v%d, #%+d", opcode, insn.vA, insn.vB); break;
293 case k11x: os << StringPrintf("%s v%d", opcode, insn.vA); break;
294 case k10t: os << StringPrintf("%s %+d", opcode, insn.vA); break;
Elliott Hughesadb8c672012-03-06 16:49:32 -0800295 case k20t: os << StringPrintf("%s %+d", opcode, insn.vA); break;
296 case k22x: os << StringPrintf("%s v%d, v%d", opcode, insn.vA, insn.vB); break;
297 case k21t: os << StringPrintf("%s v%d, %+d", opcode, insn.vA, insn.vB); break;
298 case k21s: os << StringPrintf("%s v%d, #%+d", opcode, insn.vA, insn.vB); break;
Elliott Hughes1b3d6ca2012-04-25 13:00:14 -0700299 case k21h: {
300 // op vAA, #+BBBB0000[00000000]
301 if (insn.opcode == CONST_HIGH16) {
302 uint32_t value = insn.vB << 16;
303 os << StringPrintf("%s v%d, #int %+d // 0x%x", opcode, insn.vA, value, value);
304 } else {
305 uint64_t value = static_cast<uint64_t>(insn.vB) << 48;
306 os << StringPrintf("%s v%d, #long %+lld // 0x%llx", opcode, insn.vA, value, value);
307 }
308 }
309 break;
Ian Rogers90334e52012-06-06 20:22:20 -0700310 case k21c: {
311 switch (insn.opcode) {
312 case CHECK_CAST:
313 if (file != NULL) {
314 os << StringPrintf("check-cast v%d, %s // type@%d", insn.vA,
315 file->StringByTypeIdx(insn.vB), insn.vB);
316 break;
317 } // else fall-through
318 case CONST_CLASS:
319 if (file != NULL) {
320 os << StringPrintf("const-class v%d, %s // type@%d", insn.vA,
321 file->StringByTypeIdx(insn.vB), insn.vB);
322 break;
323 } // else fall-through
324 case CONST_STRING:
325 if (file != NULL) {
326 os << StringPrintf("const-string v%d, \"%s\" // string@%d", insn.vA,
327 file->StringDataByIdx(insn.vB), insn.vB);
328 break;
329 } // else fall-through
330 case NEW_INSTANCE:
331 if (file != NULL) {
332 os << StringPrintf("new-instance v%d, %s // type@%d", insn.vA,
333 file->StringByTypeIdx(insn.vB), insn.vB);
334 break;
335 } // else fall-through
336 case SGET:
337 case SGET_WIDE:
338 case SGET_OBJECT:
339 case SGET_BOOLEAN:
340 case SGET_BYTE:
341 case SGET_CHAR:
342 case SGET_SHORT:
343 if (file != NULL) {
344 const DexFile::FieldId& field_id = file->GetFieldId(insn.vB);
345 os << StringPrintf("%s v%d, (%s) %s.%s // field@%d", opcode, insn.vA,
346 file->GetFieldTypeDescriptor(field_id),
347 file->GetFieldDeclaringClassDescriptor(field_id),
348 file->GetFieldName(field_id), insn.vB);
349 break;
350 } // else fall-through
351 case SPUT:
352 case SPUT_WIDE:
353 case SPUT_OBJECT:
354 case SPUT_BOOLEAN:
355 case SPUT_BYTE:
356 case SPUT_CHAR:
357 case SPUT_SHORT:
358 if (file != NULL) {
359 const DexFile::FieldId& field_id = file->GetFieldId(insn.vB);
360 os << StringPrintf("%s (%s) %s.%s, v%d // field@%d", opcode,
361 file->GetFieldTypeDescriptor(field_id),
362 file->GetFieldDeclaringClassDescriptor(field_id),
363 file->GetFieldName(field_id), insn.vA, insn.vB);
364 break;
365 } // else fall-through
366 default:
367 os << StringPrintf("%s v%d, thing@%d", opcode, insn.vA, insn.vB);
368 break;
369 }
370 break;
371 }
Elliott Hughesadb8c672012-03-06 16:49:32 -0800372 case k23x: os << StringPrintf("%s v%d, v%d, v%d", opcode, insn.vA, insn.vB, insn.vC); break;
373 case k22b: os << StringPrintf("%s v%d, v%d, #%+d", opcode, insn.vA, insn.vB, insn.vC); break;
374 case k22t: os << StringPrintf("%s v%d, v%d, %+d", opcode, insn.vA, insn.vB, insn.vC); break;
375 case k22s: os << StringPrintf("%s v%d, v%d, #%+d", opcode, insn.vA, insn.vB, insn.vC); break;
Ian Rogers90334e52012-06-06 20:22:20 -0700376 case k22c: {
377 switch (insn.opcode) {
378 case IGET:
379 case IGET_WIDE:
380 case IGET_OBJECT:
381 case IGET_BOOLEAN:
382 case IGET_BYTE:
383 case IGET_CHAR:
384 case IGET_SHORT:
385 if (file != NULL) {
386 const DexFile::FieldId& field_id = file->GetFieldId(insn.vC);
387 os << StringPrintf("%s v%d, v%d, (%s) %s.%s // field@%d", opcode, insn.vA, insn.vB,
388 file->GetFieldTypeDescriptor(field_id),
389 file->GetFieldDeclaringClassDescriptor(field_id),
390 file->GetFieldName(field_id), insn.vC);
391 break;
392 } // else fall-through
393 case IPUT:
394 case IPUT_WIDE:
395 case IPUT_OBJECT:
396 case IPUT_BOOLEAN:
397 case IPUT_BYTE:
398 case IPUT_CHAR:
399 case IPUT_SHORT:
400 if (file != NULL) {
401 const DexFile::FieldId& field_id = file->GetFieldId(insn.vC);
402 os << StringPrintf("%s v%d, (%s) %s.%s, v%d // field@%d", opcode, insn.vA,
403 file->GetFieldTypeDescriptor(field_id),
404 file->GetFieldDeclaringClassDescriptor(field_id),
405 file->GetFieldName(field_id), insn.vB, insn.vC);
406 break;
407 } // else fall-through
408 case INSTANCE_OF:
409 if (file != NULL) {
410 os << StringPrintf("instance-of v%d, v%d, %s // type@%d", insn.vA, insn.vB,
411 file->StringByTypeIdx(insn.vC), insn.vC);
412 break;
413 } // else fall-through
414 default:
415 os << StringPrintf("%s v%d, v%d, thing@%d", opcode, insn.vA, insn.vB, insn.vC);
416 break;
417 }
418 break;
419 }
Elliott Hughesadb8c672012-03-06 16:49:32 -0800420 case k32x: os << StringPrintf("%s v%d, v%d", opcode, insn.vA, insn.vB); break;
421 case k30t: os << StringPrintf("%s %+d", opcode, insn.vA); break;
422 case k31t: os << StringPrintf("%s v%d, %+d", opcode, insn.vA, insn.vB); break;
423 case k31i: os << StringPrintf("%s v%d, #%+d", opcode, insn.vA, insn.vB); break;
424 case k31c: os << StringPrintf("%s v%d, thing@%d", opcode, insn.vA, insn.vB); break;
Ian Rogersd81871c2011-10-03 13:57:23 -0700425 case k35c: {
Elliott Hughesadb8c672012-03-06 16:49:32 -0800426 switch (insn.opcode) {
Ian Rogersd81871c2011-10-03 13:57:23 -0700427 case INVOKE_VIRTUAL:
428 case INVOKE_SUPER:
429 case INVOKE_DIRECT:
430 case INVOKE_STATIC:
431 case INVOKE_INTERFACE:
432 if (file != NULL) {
Elliott Hughese3c845c2012-02-28 17:23:01 -0800433 os << opcode << " {";
Elliott Hughesadb8c672012-03-06 16:49:32 -0800434 for (size_t i = 0; i < insn.vA; ++i) {
Elliott Hughese3c845c2012-02-28 17:23:01 -0800435 if (i != 0) {
436 os << ", ";
437 }
Elliott Hughesadb8c672012-03-06 16:49:32 -0800438 os << "v" << insn.arg[i];
Elliott Hughese3c845c2012-02-28 17:23:01 -0800439 }
Ian Rogers4c5dd5a2012-09-07 11:27:28 -0700440 os << "}, " << PrettyMethod(insn.vB, *file) << " // method@" << insn.vB;
Ian Rogersd81871c2011-10-03 13:57:23 -0700441 break;
442 } // else fall-through
443 default:
Elliott Hughesadb8c672012-03-06 16:49:32 -0800444 os << opcode << " {v" << insn.arg[0] << ", v" << insn.arg[1] << ", v" << insn.arg[2]
445 << ", v" << insn.arg[3] << ", v" << insn.arg[4] << "}, thing@" << insn.vB;
Ian Rogersd81871c2011-10-03 13:57:23 -0700446 break;
447 }
448 break;
449 }
Ian Rogers4c5dd5a2012-09-07 11:27:28 -0700450 case k3rc: {
451 switch (insn.opcode) {
452 case INVOKE_VIRTUAL_RANGE:
453 case INVOKE_SUPER_RANGE:
454 case INVOKE_DIRECT_RANGE:
455 case INVOKE_STATIC_RANGE:
456 case INVOKE_INTERFACE_RANGE:
457 if (file != NULL) {
458 os << StringPrintf("%s, {v%d .. v%d}, ", opcode, insn.vC, (insn.vC + insn.vA - 1))
459 << PrettyMethod(insn.vB, *file) << " // method@" << insn.vB;
460 break;
461 } // else fall-through
462 default:
463 os << StringPrintf("%s, {v%d .. v%d}, thing@%d", opcode, insn.vC, (insn.vC + insn.vA - 1),
464 insn.vB);
465 break;
466 }
467 break;
468 }
Elliott Hughesadb8c672012-03-06 16:49:32 -0800469 case k51l: os << StringPrintf("%s v%d, #%+d", opcode, insn.vA, insn.vB); break;
Ian Rogers2c8a8572011-10-24 17:11:36 -0700470 default: os << " unknown format (" << DumpHex(5) << ")"; break;
Ian Rogersd81871c2011-10-03 13:57:23 -0700471 }
Ian Rogers2c8a8572011-10-24 17:11:36 -0700472 return os.str();
Carl Shapiro12eb78e2011-06-24 14:51:06 -0700473}
474
Elliott Hughesadb8c672012-03-06 16:49:32 -0800475DecodedInstruction::DecodedInstruction(const Instruction* inst) {
476 inst->Decode(vA, vB, vB_wide, vC, arg);
477 opcode = inst->Opcode();
478}
479
Carl Shapiro12eb78e2011-06-24 14:51:06 -0700480} // namespace art