Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 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 Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_DEX_INSTRUCTION_H_ |
| 18 | #define ART_RUNTIME_DEX_INSTRUCTION_H_ |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 19 | |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 20 | #include "base/logging.h" |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 21 | #include "base/macros.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 22 | #include "globals.h" |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 23 | |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 24 | typedef uint8_t uint4_t; |
| 25 | typedef int8_t int4_t; |
| 26 | |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 27 | namespace art { |
| 28 | |
Ian Rogers | d81871c | 2011-10-03 13:57:23 -0700 | [diff] [blame] | 29 | class DexFile; |
| 30 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 31 | enum { |
| 32 | kNumPackedOpcodes = 0x100 |
| 33 | }; |
| 34 | |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 35 | class Instruction { |
| 36 | public: |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 37 | // NOP-encoded switch-statement signatures. |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 38 | enum Signatures { |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 39 | kPackedSwitchSignature = 0x0100, |
| 40 | kSparseSwitchSignature = 0x0200, |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 41 | kArrayDataSignature = 0x0300, |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
Ian Rogers | df1ce91 | 2012-11-27 17:07:11 -0800 | [diff] [blame] | 44 | struct PACKED(4) PackedSwitchPayload { |
Logan Chien | 19c350a | 2012-05-01 19:21:32 +0800 | [diff] [blame] | 45 | const uint16_t ident; |
| 46 | const uint16_t case_count; |
| 47 | const int32_t first_key; |
| 48 | const int32_t targets[]; |
Dragos Sbirlea | 39f9927 | 2013-06-25 13:17:36 -0700 | [diff] [blame] | 49 | |
Logan Chien | 19c350a | 2012-05-01 19:21:32 +0800 | [diff] [blame] | 50 | private: |
| 51 | DISALLOW_COPY_AND_ASSIGN(PackedSwitchPayload); |
| 52 | }; |
| 53 | |
Ian Rogers | df1ce91 | 2012-11-27 17:07:11 -0800 | [diff] [blame] | 54 | struct PACKED(4) SparseSwitchPayload { |
Logan Chien | 19c350a | 2012-05-01 19:21:32 +0800 | [diff] [blame] | 55 | const uint16_t ident; |
| 56 | const uint16_t case_count; |
| 57 | const int32_t keys_and_targets[]; |
| 58 | |
| 59 | public: |
| 60 | const int32_t* GetKeys() const { |
| 61 | return keys_and_targets; |
| 62 | } |
| 63 | |
| 64 | const int32_t* GetTargets() const { |
| 65 | return keys_and_targets + case_count; |
| 66 | } |
| 67 | |
| 68 | private: |
| 69 | DISALLOW_COPY_AND_ASSIGN(SparseSwitchPayload); |
| 70 | }; |
| 71 | |
Ian Rogers | df1ce91 | 2012-11-27 17:07:11 -0800 | [diff] [blame] | 72 | struct PACKED(4) ArrayDataPayload { |
Logan Chien | 19c350a | 2012-05-01 19:21:32 +0800 | [diff] [blame] | 73 | const uint16_t ident; |
| 74 | const uint16_t element_width; |
| 75 | const uint32_t element_count; |
| 76 | const uint8_t data[]; |
Dragos Sbirlea | 39f9927 | 2013-06-25 13:17:36 -0700 | [diff] [blame] | 77 | |
Logan Chien | 19c350a | 2012-05-01 19:21:32 +0800 | [diff] [blame] | 78 | private: |
| 79 | DISALLOW_COPY_AND_ASSIGN(ArrayDataPayload); |
| 80 | }; |
| 81 | |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 82 | enum Code { // private marker to avoid generate-operator-out.py from processing. |
Narayan Kamath | bd48b34 | 2016-08-01 17:32:37 +0100 | [diff] [blame] | 83 | #define INSTRUCTION_ENUM(opcode, cname, p, f, i, a, v) cname = (opcode), |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 84 | #include "dex_instruction_list.h" |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 85 | DEX_INSTRUCTION_LIST(INSTRUCTION_ENUM) |
Carl Shapiro | d84f49c | 2011-06-29 00:27:46 -0700 | [diff] [blame] | 86 | #undef DEX_INSTRUCTION_LIST |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 87 | #undef INSTRUCTION_ENUM |
Ian Rogers | f72a11d | 2014-10-30 15:41:08 -0700 | [diff] [blame] | 88 | RSUB_INT_LIT16 = RSUB_INT, |
Brian Carlstrom | 02c8cc6 | 2013-07-18 15:54:44 -0700 | [diff] [blame] | 89 | }; |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 90 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 91 | enum Format { |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 92 | k10x, // op |
| 93 | k12x, // op vA, vB |
| 94 | k11n, // op vA, #+B |
| 95 | k11x, // op vAA |
| 96 | k10t, // op +AA |
| 97 | k20t, // op +AAAA |
| 98 | k22x, // op vAA, vBBBB |
| 99 | k21t, // op vAA, +BBBB |
| 100 | k21s, // op vAA, #+BBBB |
| 101 | k21h, // op vAA, #+BBBB00000[00000000] |
| 102 | k21c, // op vAA, thing@BBBB |
| 103 | k23x, // op vAA, vBB, vCC |
| 104 | k22b, // op vAA, vBB, #+CC |
| 105 | k22t, // op vA, vB, +CCCC |
| 106 | k22s, // op vA, vB, #+CCCC |
| 107 | k22c, // op vA, vB, thing@CCCC |
| 108 | k32x, // op vAAAA, vBBBB |
| 109 | k30t, // op +AAAAAAAA |
| 110 | k31t, // op vAA, +BBBBBBBB |
| 111 | k31i, // op vAA, #+BBBBBBBB |
| 112 | k31c, // op vAA, thing@BBBBBBBB |
| 113 | k35c, // op {vC, vD, vE, vF, vG}, thing@BBBB (B: count, A: vG) |
| 114 | k3rc, // op {vCCCC .. v(CCCC+AA-1)}, meth@BBBB |
Narayan Kamath | 8ec3bd2 | 2016-08-03 12:46:23 +0100 | [diff] [blame] | 115 | |
| 116 | // op {vC, vD, vE, vF, vG}, meth@BBBB, proto@HHHH (A: count) |
| 117 | // format: AG op BBBB FEDC HHHH |
| 118 | k45cc, |
| 119 | |
| 120 | // op {VCCCC .. v(CCCC+AA-1)}, meth@BBBB, proto@HHHH (AA: count) |
| 121 | // format: AA op BBBB CCCC HHHH |
| 122 | k4rcc, // op {VCCCC .. v(CCCC+AA-1)}, meth@BBBB, proto@HHHH (AA: count) |
| 123 | |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 124 | k51l, // op vAA, #+BBBBBBBBBBBBBBBB |
| 125 | }; |
| 126 | |
Aart Bik | b1f3753 | 2015-06-29 11:03:55 -0700 | [diff] [blame] | 127 | enum IndexType { |
| 128 | kIndexUnknown = 0, |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 129 | kIndexNone, // has no index |
| 130 | kIndexTypeRef, // type reference index |
| 131 | kIndexStringRef, // string reference index |
| 132 | kIndexMethodRef, // method reference index |
| 133 | kIndexFieldRef, // field reference index |
| 134 | kIndexFieldOffset, // field offset (for static linked fields) |
| 135 | kIndexVtableOffset, // vtable offset (for static linked methods) |
| 136 | kIndexMethodAndProtoRef, // method and a proto reference index (for invoke-polymorphic) |
| 137 | kIndexCallSiteRef, // call site reference index |
Aart Bik | b1f3753 | 2015-06-29 11:03:55 -0700 | [diff] [blame] | 138 | }; |
| 139 | |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 140 | enum Flags { |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 141 | kBranch = 0x0000001, // conditional or unconditional branch |
| 142 | kContinue = 0x0000002, // flow can continue to next statement |
| 143 | kSwitch = 0x0000004, // switch statement |
| 144 | kThrow = 0x0000008, // could cause an exception to be thrown |
| 145 | kReturn = 0x0000010, // returns, no additional statements |
| 146 | kInvoke = 0x0000020, // a flavor of invoke |
| 147 | kUnconditional = 0x0000040, // unconditional branch |
| 148 | kAdd = 0x0000080, // addition |
| 149 | kSubtract = 0x0000100, // subtract |
| 150 | kMultiply = 0x0000200, // multiply |
| 151 | kDivide = 0x0000400, // division |
| 152 | kRemainder = 0x0000800, // remainder |
| 153 | kAnd = 0x0001000, // and |
| 154 | kOr = 0x0002000, // or |
| 155 | kXor = 0x0004000, // xor |
| 156 | kShl = 0x0008000, // shl |
| 157 | kShr = 0x0010000, // shr |
| 158 | kUshr = 0x0020000, // ushr |
| 159 | kCast = 0x0040000, // cast |
| 160 | kStore = 0x0080000, // store opcode |
| 161 | kLoad = 0x0100000, // load opcode |
| 162 | kClobber = 0x0200000, // clobbers memory in a big way (not just a write) |
| 163 | kRegCFieldOrConstant = 0x0400000, // is the third virtual register a field or literal constant (vC) |
| 164 | kRegBFieldOrConstant = 0x0800000, // is the second virtual register a field or literal constant (vB) |
| 165 | kExperimental = 0x1000000, // is an experimental opcode |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 166 | }; |
| 167 | |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 168 | enum VerifyFlag { |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 169 | kVerifyNone = 0x0000000, |
| 170 | kVerifyRegA = 0x0000001, |
| 171 | kVerifyRegAWide = 0x0000002, |
| 172 | kVerifyRegB = 0x0000004, |
| 173 | kVerifyRegBField = 0x0000008, |
| 174 | kVerifyRegBMethod = 0x0000010, |
| 175 | kVerifyRegBNewInstance = 0x0000020, |
| 176 | kVerifyRegBString = 0x0000040, |
| 177 | kVerifyRegBType = 0x0000080, |
| 178 | kVerifyRegBWide = 0x0000100, |
| 179 | kVerifyRegC = 0x0000200, |
| 180 | kVerifyRegCField = 0x0000400, |
| 181 | kVerifyRegCNewArray = 0x0000800, |
| 182 | kVerifyRegCType = 0x0001000, |
| 183 | kVerifyRegCWide = 0x0002000, |
| 184 | kVerifyArrayData = 0x0004000, |
| 185 | kVerifyBranchTarget = 0x0008000, |
| 186 | kVerifySwitchTargets = 0x0010000, |
| 187 | kVerifyVarArg = 0x0020000, |
| 188 | kVerifyVarArgNonZero = 0x0040000, |
| 189 | kVerifyVarArgRange = 0x0080000, |
| 190 | kVerifyVarArgRangeNonZero = 0x0100000, |
| 191 | kVerifyRuntimeOnly = 0x0200000, |
| 192 | kVerifyError = 0x0400000, |
| 193 | kVerifyRegHPrototype = 0x0800000, |
| 194 | kVerifyRegBCallSite = 0x1000000 |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 195 | }; |
| 196 | |
Ian Rogers | 29a2648 | 2014-05-02 15:27:29 -0700 | [diff] [blame] | 197 | static constexpr uint32_t kMaxVarArgRegs = 5; |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 198 | |
Andreas Gampe | e05cc66 | 2017-05-15 10:17:30 -0700 | [diff] [blame^] | 199 | static constexpr bool kHaveExperimentalInstructions = false; |
| 200 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 201 | // Returns the size (in 2 byte code units) of this instruction. |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 202 | size_t SizeInCodeUnits() const { |
| 203 | int result = kInstructionSizeInCodeUnits[Opcode()]; |
| 204 | if (UNLIKELY(result < 0)) { |
| 205 | return SizeInCodeUnitsComplexOpcode(); |
| 206 | } else { |
| 207 | return static_cast<size_t>(result); |
| 208 | } |
| 209 | } |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 210 | |
Sebastien Hertz | 92c607f | 2013-06-04 16:18:52 +0200 | [diff] [blame] | 211 | // Reads an instruction out of the stream at the specified address. |
| 212 | static const Instruction* At(const uint16_t* code) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 213 | DCHECK(code != nullptr); |
Sebastien Hertz | 92c607f | 2013-06-04 16:18:52 +0200 | [diff] [blame] | 214 | return reinterpret_cast<const Instruction*>(code); |
| 215 | } |
| 216 | |
| 217 | // Reads an instruction out of the stream from the current address plus an offset. |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 218 | const Instruction* RelativeAt(int32_t offset) const WARN_UNUSED { |
Sebastien Hertz | 92c607f | 2013-06-04 16:18:52 +0200 | [diff] [blame] | 219 | return At(reinterpret_cast<const uint16_t*>(this) + offset); |
| 220 | } |
| 221 | |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 222 | // Returns a pointer to the next instruction in the stream. |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 223 | const Instruction* Next() const { |
Sebastien Hertz | 92c607f | 2013-06-04 16:18:52 +0200 | [diff] [blame] | 224 | return RelativeAt(SizeInCodeUnits()); |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 225 | } |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 226 | |
Jeff Hao | 9cec247 | 2013-05-14 18:17:06 -0700 | [diff] [blame] | 227 | // Returns a pointer to the instruction after this 1xx instruction in the stream. |
| 228 | const Instruction* Next_1xx() const { |
| 229 | DCHECK(FormatOf(Opcode()) >= k10x && FormatOf(Opcode()) <= k10t); |
Sebastien Hertz | 92c607f | 2013-06-04 16:18:52 +0200 | [diff] [blame] | 230 | return RelativeAt(1); |
Jeff Hao | 9cec247 | 2013-05-14 18:17:06 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | // Returns a pointer to the instruction after this 2xx instruction in the stream. |
| 234 | const Instruction* Next_2xx() const { |
Narayan Kamath | 14832ef | 2016-08-05 11:44:32 +0100 | [diff] [blame] | 235 | DCHECK(FormatOf(Opcode()) >= k20t && FormatOf(Opcode()) <= k22c); |
Sebastien Hertz | 92c607f | 2013-06-04 16:18:52 +0200 | [diff] [blame] | 236 | return RelativeAt(2); |
Jeff Hao | 9cec247 | 2013-05-14 18:17:06 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | // Returns a pointer to the instruction after this 3xx instruction in the stream. |
| 240 | const Instruction* Next_3xx() const { |
| 241 | DCHECK(FormatOf(Opcode()) >= k32x && FormatOf(Opcode()) <= k3rc); |
Sebastien Hertz | 92c607f | 2013-06-04 16:18:52 +0200 | [diff] [blame] | 242 | return RelativeAt(3); |
Jeff Hao | 9cec247 | 2013-05-14 18:17:06 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Narayan Kamath | 8ec3bd2 | 2016-08-03 12:46:23 +0100 | [diff] [blame] | 245 | // Returns a pointer to the instruction after this 4xx instruction in the stream. |
| 246 | const Instruction* Next_4xx() const { |
| 247 | DCHECK(FormatOf(Opcode()) >= k45cc && FormatOf(Opcode()) <= k4rcc); |
| 248 | return RelativeAt(4); |
| 249 | } |
| 250 | |
Jeff Hao | 9cec247 | 2013-05-14 18:17:06 -0700 | [diff] [blame] | 251 | // Returns a pointer to the instruction after this 51l instruction in the stream. |
Sebastien Hertz | 92c607f | 2013-06-04 16:18:52 +0200 | [diff] [blame] | 252 | const Instruction* Next_51l() const { |
| 253 | DCHECK(FormatOf(Opcode()) == k51l); |
| 254 | return RelativeAt(5); |
| 255 | } |
Jeff Hao | 9cec247 | 2013-05-14 18:17:06 -0700 | [diff] [blame] | 256 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 257 | // Returns the name of this instruction's opcode. |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 258 | const char* Name() const { |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 259 | return Instruction::Name(Opcode()); |
| 260 | } |
| 261 | |
| 262 | // Returns the name of the given opcode. |
| 263 | static const char* Name(Code opcode) { |
| 264 | return kInstructionNames[opcode]; |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 265 | } |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 266 | |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 267 | // VRegA |
Dragos Sbirlea | 8cc5162 | 2013-06-21 09:20:34 -0700 | [diff] [blame] | 268 | bool HasVRegA() const; |
Mathieu Chartier | de40d47 | 2015-10-15 17:47:48 -0700 | [diff] [blame] | 269 | ALWAYS_INLINE int32_t VRegA() const; |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 270 | |
| 271 | int8_t VRegA_10t() const { |
| 272 | return VRegA_10t(Fetch16(0)); |
| 273 | } |
| 274 | uint8_t VRegA_10x() const { |
| 275 | return VRegA_10x(Fetch16(0)); |
| 276 | } |
| 277 | uint4_t VRegA_11n() const { |
| 278 | return VRegA_11n(Fetch16(0)); |
| 279 | } |
| 280 | uint8_t VRegA_11x() const { |
| 281 | return VRegA_11x(Fetch16(0)); |
| 282 | } |
| 283 | uint4_t VRegA_12x() const { |
| 284 | return VRegA_12x(Fetch16(0)); |
| 285 | } |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 286 | int16_t VRegA_20t() const; |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 287 | uint8_t VRegA_21c() const { |
| 288 | return VRegA_21c(Fetch16(0)); |
| 289 | } |
| 290 | uint8_t VRegA_21h() const { |
| 291 | return VRegA_21h(Fetch16(0)); |
| 292 | } |
| 293 | uint8_t VRegA_21s() const { |
| 294 | return VRegA_21s(Fetch16(0)); |
| 295 | } |
| 296 | uint8_t VRegA_21t() const { |
| 297 | return VRegA_21t(Fetch16(0)); |
| 298 | } |
| 299 | uint8_t VRegA_22b() const { |
| 300 | return VRegA_22b(Fetch16(0)); |
| 301 | } |
| 302 | uint4_t VRegA_22c() const { |
| 303 | return VRegA_22c(Fetch16(0)); |
| 304 | } |
| 305 | uint4_t VRegA_22s() const { |
| 306 | return VRegA_22s(Fetch16(0)); |
| 307 | } |
| 308 | uint4_t VRegA_22t() const { |
| 309 | return VRegA_22t(Fetch16(0)); |
| 310 | } |
| 311 | uint8_t VRegA_22x() const { |
| 312 | return VRegA_22x(Fetch16(0)); |
| 313 | } |
| 314 | uint8_t VRegA_23x() const { |
| 315 | return VRegA_23x(Fetch16(0)); |
| 316 | } |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 317 | int32_t VRegA_30t() const; |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 318 | uint8_t VRegA_31c() const { |
| 319 | return VRegA_31c(Fetch16(0)); |
| 320 | } |
| 321 | uint8_t VRegA_31i() const { |
| 322 | return VRegA_31i(Fetch16(0)); |
| 323 | } |
| 324 | uint8_t VRegA_31t() const { |
| 325 | return VRegA_31t(Fetch16(0)); |
| 326 | } |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 327 | uint16_t VRegA_32x() const; |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 328 | uint4_t VRegA_35c() const { |
| 329 | return VRegA_35c(Fetch16(0)); |
| 330 | } |
| 331 | uint8_t VRegA_3rc() const { |
| 332 | return VRegA_3rc(Fetch16(0)); |
| 333 | } |
| 334 | uint8_t VRegA_51l() const { |
| 335 | return VRegA_51l(Fetch16(0)); |
| 336 | } |
Narayan Kamath | 8ec3bd2 | 2016-08-03 12:46:23 +0100 | [diff] [blame] | 337 | uint4_t VRegA_45cc() const { |
| 338 | return VRegA_45cc(Fetch16(0)); |
| 339 | } |
| 340 | uint8_t VRegA_4rcc() const { |
| 341 | return VRegA_4rcc(Fetch16(0)); |
| 342 | } |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 343 | |
| 344 | // The following methods return the vA operand for various instruction formats. The "inst_data" |
| 345 | // parameter holds the first 16 bits of instruction which the returned value is decoded from. |
| 346 | int8_t VRegA_10t(uint16_t inst_data) const; |
| 347 | uint8_t VRegA_10x(uint16_t inst_data) const; |
| 348 | uint4_t VRegA_11n(uint16_t inst_data) const; |
| 349 | uint8_t VRegA_11x(uint16_t inst_data) const; |
| 350 | uint4_t VRegA_12x(uint16_t inst_data) const; |
| 351 | uint8_t VRegA_21c(uint16_t inst_data) const; |
| 352 | uint8_t VRegA_21h(uint16_t inst_data) const; |
| 353 | uint8_t VRegA_21s(uint16_t inst_data) const; |
| 354 | uint8_t VRegA_21t(uint16_t inst_data) const; |
| 355 | uint8_t VRegA_22b(uint16_t inst_data) const; |
| 356 | uint4_t VRegA_22c(uint16_t inst_data) const; |
| 357 | uint4_t VRegA_22s(uint16_t inst_data) const; |
| 358 | uint4_t VRegA_22t(uint16_t inst_data) const; |
| 359 | uint8_t VRegA_22x(uint16_t inst_data) const; |
| 360 | uint8_t VRegA_23x(uint16_t inst_data) const; |
| 361 | uint8_t VRegA_31c(uint16_t inst_data) const; |
| 362 | uint8_t VRegA_31i(uint16_t inst_data) const; |
| 363 | uint8_t VRegA_31t(uint16_t inst_data) const; |
| 364 | uint4_t VRegA_35c(uint16_t inst_data) const; |
| 365 | uint8_t VRegA_3rc(uint16_t inst_data) const; |
| 366 | uint8_t VRegA_51l(uint16_t inst_data) const; |
Narayan Kamath | 8ec3bd2 | 2016-08-03 12:46:23 +0100 | [diff] [blame] | 367 | uint4_t VRegA_45cc(uint16_t inst_data) const; |
| 368 | uint8_t VRegA_4rcc(uint16_t inst_data) const; |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 369 | |
| 370 | // VRegB |
Dragos Sbirlea | 8cc5162 | 2013-06-21 09:20:34 -0700 | [diff] [blame] | 371 | bool HasVRegB() const; |
Dragos Sbirlea | 39f9927 | 2013-06-25 13:17:36 -0700 | [diff] [blame] | 372 | int32_t VRegB() const; |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 373 | |
Ian Rogers | 29a2648 | 2014-05-02 15:27:29 -0700 | [diff] [blame] | 374 | bool HasWideVRegB() const; |
| 375 | uint64_t WideVRegB() const; |
| 376 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 377 | int4_t VRegB_11n() const { |
| 378 | return VRegB_11n(Fetch16(0)); |
| 379 | } |
| 380 | uint4_t VRegB_12x() const { |
| 381 | return VRegB_12x(Fetch16(0)); |
| 382 | } |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 383 | uint16_t VRegB_21c() const; |
| 384 | uint16_t VRegB_21h() const; |
| 385 | int16_t VRegB_21s() const; |
| 386 | int16_t VRegB_21t() const; |
| 387 | uint8_t VRegB_22b() const; |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 388 | uint4_t VRegB_22c() const { |
| 389 | return VRegB_22c(Fetch16(0)); |
| 390 | } |
| 391 | uint4_t VRegB_22s() const { |
| 392 | return VRegB_22s(Fetch16(0)); |
| 393 | } |
| 394 | uint4_t VRegB_22t() const { |
| 395 | return VRegB_22t(Fetch16(0)); |
| 396 | } |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 397 | uint16_t VRegB_22x() const; |
| 398 | uint8_t VRegB_23x() const; |
| 399 | uint32_t VRegB_31c() const; |
| 400 | int32_t VRegB_31i() const; |
| 401 | int32_t VRegB_31t() const; |
| 402 | uint16_t VRegB_32x() const; |
| 403 | uint16_t VRegB_35c() const; |
| 404 | uint16_t VRegB_3rc() const; |
Dragos Sbirlea | 39f9927 | 2013-06-25 13:17:36 -0700 | [diff] [blame] | 405 | uint64_t VRegB_51l() const; // vB_wide |
Narayan Kamath | 8ec3bd2 | 2016-08-03 12:46:23 +0100 | [diff] [blame] | 406 | uint16_t VRegB_45cc() const; |
| 407 | uint16_t VRegB_4rcc() const; |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 408 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 409 | // The following methods return the vB operand for all instruction formats where it is encoded in |
| 410 | // the first 16 bits of instruction. The "inst_data" parameter holds these 16 bits. The returned |
| 411 | // value is decoded from it. |
| 412 | int4_t VRegB_11n(uint16_t inst_data) const; |
| 413 | uint4_t VRegB_12x(uint16_t inst_data) const; |
| 414 | uint4_t VRegB_22c(uint16_t inst_data) const; |
| 415 | uint4_t VRegB_22s(uint16_t inst_data) const; |
| 416 | uint4_t VRegB_22t(uint16_t inst_data) const; |
| 417 | |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 418 | // VRegC |
Dragos Sbirlea | 8cc5162 | 2013-06-21 09:20:34 -0700 | [diff] [blame] | 419 | bool HasVRegC() const; |
Dragos Sbirlea | 39f9927 | 2013-06-25 13:17:36 -0700 | [diff] [blame] | 420 | int32_t VRegC() const; |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 421 | |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 422 | int8_t VRegC_22b() const; |
| 423 | uint16_t VRegC_22c() const; |
| 424 | int16_t VRegC_22s() const; |
| 425 | int16_t VRegC_22t() const; |
| 426 | uint8_t VRegC_23x() const; |
| 427 | uint4_t VRegC_35c() const; |
| 428 | uint16_t VRegC_3rc() const; |
Narayan Kamath | 8ec3bd2 | 2016-08-03 12:46:23 +0100 | [diff] [blame] | 429 | uint4_t VRegC_45cc() const; |
| 430 | uint16_t VRegC_4rcc() const; |
| 431 | |
| 432 | |
| 433 | // VRegH |
| 434 | bool HasVRegH() const; |
| 435 | int32_t VRegH() const; |
| 436 | uint16_t VRegH_45cc() const; |
| 437 | uint16_t VRegH_4rcc() const; |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 438 | |
| 439 | // Fills the given array with the 'arg' array of the instruction. |
Narayan Kamath | 14832ef | 2016-08-05 11:44:32 +0100 | [diff] [blame] | 440 | bool HasVarArgs() const; |
Ian Rogers | 29a2648 | 2014-05-02 15:27:29 -0700 | [diff] [blame] | 441 | void GetVarArgs(uint32_t args[kMaxVarArgRegs], uint16_t inst_data) const; |
| 442 | void GetVarArgs(uint32_t args[kMaxVarArgRegs]) const { |
| 443 | return GetVarArgs(args, Fetch16(0)); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 444 | } |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 445 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 446 | // Returns the opcode field of the instruction. The given "inst_data" parameter must be the first |
| 447 | // 16 bits of instruction. |
| 448 | Code Opcode(uint16_t inst_data) const { |
| 449 | DCHECK_EQ(inst_data, Fetch16(0)); |
| 450 | return static_cast<Code>(inst_data & 0xFF); |
| 451 | } |
| 452 | |
| 453 | // Returns the opcode field of the instruction from the first 16 bits of instruction. |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 454 | Code Opcode() const { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 455 | return Opcode(Fetch16(0)); |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 456 | } |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 457 | |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 458 | void SetOpcode(Code opcode) { |
| 459 | DCHECK_LT(static_cast<uint16_t>(opcode), 256u); |
| 460 | uint16_t* insns = reinterpret_cast<uint16_t*>(this); |
| 461 | insns[0] = (insns[0] & 0xff00) | static_cast<uint16_t>(opcode); |
| 462 | } |
| 463 | |
Sebastien Hertz | 543959c | 2013-07-03 12:00:19 +0200 | [diff] [blame] | 464 | void SetVRegA_10x(uint8_t val) { |
| 465 | DCHECK(FormatOf(Opcode()) == k10x); |
| 466 | uint16_t* insns = reinterpret_cast<uint16_t*>(this); |
| 467 | insns[0] = (val << 8) | (insns[0] & 0x00ff); |
| 468 | } |
| 469 | |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 470 | void SetVRegB_3rc(uint16_t val) { |
| 471 | DCHECK(FormatOf(Opcode()) == k3rc); |
| 472 | uint16_t* insns = reinterpret_cast<uint16_t*>(this); |
| 473 | insns[1] = val; |
| 474 | } |
| 475 | |
| 476 | void SetVRegB_35c(uint16_t val) { |
| 477 | DCHECK(FormatOf(Opcode()) == k35c); |
| 478 | uint16_t* insns = reinterpret_cast<uint16_t*>(this); |
| 479 | insns[1] = val; |
| 480 | } |
| 481 | |
| 482 | void SetVRegC_22c(uint16_t val) { |
| 483 | DCHECK(FormatOf(Opcode()) == k22c); |
| 484 | uint16_t* insns = reinterpret_cast<uint16_t*>(this); |
| 485 | insns[1] = val; |
| 486 | } |
| 487 | |
Nicolas Geoffray | 01b70e8 | 2016-11-17 10:58:36 +0000 | [diff] [blame] | 488 | void SetVRegA_21c(uint8_t val) { |
| 489 | DCHECK(FormatOf(Opcode()) == k21c); |
| 490 | uint16_t* insns = reinterpret_cast<uint16_t*>(this); |
| 491 | insns[0] = (val << 8) | (insns[0] & 0x00ff); |
| 492 | } |
| 493 | |
| 494 | void SetVRegB_21c(uint16_t val) { |
| 495 | DCHECK(FormatOf(Opcode()) == k21c); |
| 496 | uint16_t* insns = reinterpret_cast<uint16_t*>(this); |
| 497 | insns[1] = val; |
| 498 | } |
| 499 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 500 | // Returns the format of the given opcode. |
| 501 | static Format FormatOf(Code opcode) { |
| 502 | return kInstructionFormats[opcode]; |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Aart Bik | b1f3753 | 2015-06-29 11:03:55 -0700 | [diff] [blame] | 505 | // Returns the index type of the given opcode. |
| 506 | static IndexType IndexTypeOf(Code opcode) { |
| 507 | return kInstructionIndexTypes[opcode]; |
| 508 | } |
| 509 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 510 | // Returns the flags for the given opcode. |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 511 | static int FlagsOf(Code opcode) { |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 512 | return kInstructionFlags[opcode]; |
jeffhao | bdb7651 | 2011-09-07 11:43:16 -0700 | [diff] [blame] | 513 | } |
| 514 | |
buzbee | b1f1d64 | 2014-02-27 12:55:32 -0800 | [diff] [blame] | 515 | // Return the verify flags for the given opcode. |
| 516 | static int VerifyFlagsOf(Code opcode) { |
| 517 | return kInstructionVerifyFlags[opcode]; |
| 518 | } |
| 519 | |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 520 | // Returns true if this instruction is a branch. |
| 521 | bool IsBranch() const { |
| 522 | return (kInstructionFlags[Opcode()] & kBranch) != 0; |
| 523 | } |
| 524 | |
TDYa127 | 526643e | 2012-05-26 01:01:48 -0700 | [diff] [blame] | 525 | // Returns true if this instruction is a unconditional branch. |
| 526 | bool IsUnconditional() const { |
| 527 | return (kInstructionFlags[Opcode()] & kUnconditional) != 0; |
| 528 | } |
| 529 | |
Dragos Sbirlea | 39f9927 | 2013-06-25 13:17:36 -0700 | [diff] [blame] | 530 | // Returns the branch offset if this instruction is a branch. |
| 531 | int32_t GetTargetOffset() const; |
| 532 | |
| 533 | // Returns true if the instruction allows control flow to go to the following instruction. |
| 534 | bool CanFlowThrough() const; |
| 535 | |
Nicolas Geoffray | 9523a3e | 2015-07-17 11:51:28 +0000 | [diff] [blame] | 536 | // Returns true if the instruction is a quickened instruction. |
| 537 | bool IsQuickened() const { |
| 538 | return (kInstructionIndexTypes[Opcode()] == kIndexFieldOffset) || |
| 539 | (kInstructionIndexTypes[Opcode()] == kIndexVtableOffset); |
| 540 | } |
| 541 | |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 542 | // Returns true if this instruction is a switch. |
| 543 | bool IsSwitch() const { |
| 544 | return (kInstructionFlags[Opcode()] & kSwitch) != 0; |
| 545 | } |
| 546 | |
| 547 | // Returns true if this instruction can throw. |
| 548 | bool IsThrow() const { |
| 549 | return (kInstructionFlags[Opcode()] & kThrow) != 0; |
| 550 | } |
| 551 | |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 552 | // Determine if the instruction is any of 'return' instructions. |
| 553 | bool IsReturn() const { |
| 554 | return (kInstructionFlags[Opcode()] & kReturn) != 0; |
| 555 | } |
| 556 | |
| 557 | // Determine if this instruction ends execution of its basic block. |
| 558 | bool IsBasicBlockEnd() const { |
| 559 | return IsBranch() || IsReturn() || Opcode() == THROW; |
| 560 | } |
| 561 | |
| 562 | // Determine if this instruction is an invoke. |
| 563 | bool IsInvoke() const { |
| 564 | return (kInstructionFlags[Opcode()] & kInvoke) != 0; |
| 565 | } |
| 566 | |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 567 | // Determine if this instruction is experimental. |
| 568 | bool IsExperimental() const { |
| 569 | return (kInstructionFlags[Opcode()] & kExperimental) != 0; |
| 570 | } |
| 571 | |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 572 | int GetVerifyTypeArgumentA() const { |
| 573 | return (kInstructionVerifyFlags[Opcode()] & (kVerifyRegA | kVerifyRegAWide)); |
| 574 | } |
| 575 | |
| 576 | int GetVerifyTypeArgumentB() const { |
Ian Rogers | 5fb22a9 | 2014-06-13 10:31:28 -0700 | [diff] [blame] | 577 | return (kInstructionVerifyFlags[Opcode()] & (kVerifyRegB | kVerifyRegBField | |
| 578 | kVerifyRegBMethod | kVerifyRegBNewInstance | kVerifyRegBString | kVerifyRegBType | |
| 579 | kVerifyRegBWide)); |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | int GetVerifyTypeArgumentC() const { |
| 583 | return (kInstructionVerifyFlags[Opcode()] & (kVerifyRegC | kVerifyRegCField | |
Narayan Kamath | 14832ef | 2016-08-05 11:44:32 +0100 | [diff] [blame] | 584 | kVerifyRegCNewArray | kVerifyRegCType | kVerifyRegCWide)); |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 585 | } |
| 586 | |
Orion Hodson | cfa325e | 2016-10-13 10:25:54 +0100 | [diff] [blame] | 587 | int GetVerifyTypeArgumentH() const { |
| 588 | return (kInstructionVerifyFlags[Opcode()] & kVerifyRegHPrototype); |
| 589 | } |
| 590 | |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 591 | int GetVerifyExtraFlags() const { |
| 592 | return (kInstructionVerifyFlags[Opcode()] & (kVerifyArrayData | kVerifyBranchTarget | |
Andreas Gampe | c331431 | 2014-06-19 18:13:29 -0700 | [diff] [blame] | 593 | kVerifySwitchTargets | kVerifyVarArg | kVerifyVarArgNonZero | kVerifyVarArgRange | |
| 594 | kVerifyVarArgRangeNonZero | kVerifyError)); |
Ian Rogers | 5fb22a9 | 2014-06-13 10:31:28 -0700 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | bool GetVerifyIsRuntimeOnly() const { |
| 598 | return (kInstructionVerifyFlags[Opcode()] & kVerifyRuntimeOnly) != 0; |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 599 | } |
| 600 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 601 | // Get the dex PC of this instruction as a offset in code units from the beginning of insns. |
| 602 | uint32_t GetDexPc(const uint16_t* insns) const { |
| 603 | return (reinterpret_cast<const uint16_t*>(this) - insns); |
| 604 | } |
| 605 | |
Ian Rogers | d81871c | 2011-10-03 13:57:23 -0700 | [diff] [blame] | 606 | // Dump decoded version of instruction |
Ian Rogers | 2c8a857 | 2011-10-24 17:11:36 -0700 | [diff] [blame] | 607 | std::string DumpString(const DexFile*) const; |
| 608 | |
| 609 | // Dump code_units worth of this instruction, padding to code_units for shorter instructions |
| 610 | std::string DumpHex(size_t code_units) const; |
Ian Rogers | d81871c | 2011-10-03 13:57:23 -0700 | [diff] [blame] | 611 | |
Anestis Bechtsoudis | 32f500d | 2015-02-22 22:32:57 -0800 | [diff] [blame] | 612 | // Little-endian dump code_units worth of this instruction, padding to code_units for |
| 613 | // shorter instructions |
| 614 | std::string DumpHexLE(size_t instr_code_units) const; |
| 615 | |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 616 | uint16_t Fetch16(size_t offset) const { |
| 617 | const uint16_t* insns = reinterpret_cast<const uint16_t*>(this); |
| 618 | return insns[offset]; |
| 619 | } |
| 620 | |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 621 | private: |
| 622 | size_t SizeInCodeUnitsComplexOpcode() const; |
| 623 | |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 624 | uint32_t Fetch32(size_t offset) const { |
| 625 | return (Fetch16(offset) | ((uint32_t) Fetch16(offset + 1) << 16)); |
| 626 | } |
| 627 | |
| 628 | uint4_t InstA() const { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 629 | return InstA(Fetch16(0)); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | uint4_t InstB() const { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 633 | return InstB(Fetch16(0)); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | uint8_t InstAA() const { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 637 | return InstAA(Fetch16(0)); |
| 638 | } |
| 639 | |
| 640 | uint4_t InstA(uint16_t inst_data) const { |
| 641 | DCHECK_EQ(inst_data, Fetch16(0)); |
| 642 | return static_cast<uint4_t>((inst_data >> 8) & 0x0f); |
| 643 | } |
| 644 | |
| 645 | uint4_t InstB(uint16_t inst_data) const { |
| 646 | DCHECK_EQ(inst_data, Fetch16(0)); |
| 647 | return static_cast<uint4_t>(inst_data >> 12); |
| 648 | } |
| 649 | |
| 650 | uint8_t InstAA(uint16_t inst_data) const { |
| 651 | DCHECK_EQ(inst_data, Fetch16(0)); |
| 652 | return static_cast<uint8_t>(inst_data >> 8); |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 653 | } |
| 654 | |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 655 | static const char* const kInstructionNames[]; |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 656 | static Format const kInstructionFormats[]; |
Aart Bik | b1f3753 | 2015-06-29 11:03:55 -0700 | [diff] [blame] | 657 | static IndexType const kInstructionIndexTypes[]; |
Carl Shapiro | e4c1ce4 | 2011-07-09 02:31:57 -0700 | [diff] [blame] | 658 | static int const kInstructionFlags[]; |
jeffhao | ba5ebb9 | 2011-08-25 17:24:37 -0700 | [diff] [blame] | 659 | static int const kInstructionVerifyFlags[]; |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 660 | static int const kInstructionSizeInCodeUnits[]; |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 661 | DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction); |
| 662 | }; |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 663 | std::ostream& operator<<(std::ostream& os, const Instruction::Code& code); |
| 664 | std::ostream& operator<<(std::ostream& os, const Instruction::Format& format); |
| 665 | std::ostream& operator<<(std::ostream& os, const Instruction::Flags& flags); |
| 666 | std::ostream& operator<<(std::ostream& os, const Instruction::VerifyFlag& vflags); |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 667 | |
Carl Shapiro | 12eb78e | 2011-06-24 14:51:06 -0700 | [diff] [blame] | 668 | } // namespace art |
| 669 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 670 | #endif // ART_RUNTIME_DEX_INSTRUCTION_H_ |