Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | */ |
| 16 | |
| 17 | #include "intrinsics.h" |
| 18 | |
| 19 | #include "dex/quick/dex_file_method_inliner.h" |
| 20 | #include "dex/quick/dex_file_to_method_inliner_map.h" |
| 21 | #include "driver/compiler_driver.h" |
| 22 | #include "invoke_type.h" |
| 23 | #include "nodes.h" |
| 24 | #include "quick/inline_method_analyser.h" |
| 25 | |
| 26 | namespace art { |
| 27 | |
| 28 | // Function that returns whether an intrinsic is static/direct or virtual. |
| 29 | static inline InvokeType GetIntrinsicInvokeType(Intrinsics i) { |
| 30 | switch (i) { |
| 31 | case Intrinsics::kNone: |
| 32 | return kInterface; // Non-sensical for intrinsic. |
| 33 | #define OPTIMIZING_INTRINSICS(Name, IsStatic) \ |
| 34 | case Intrinsics::k ## Name: \ |
| 35 | return IsStatic; |
| 36 | #include "intrinsics_list.h" |
| 37 | INTRINSICS_LIST(OPTIMIZING_INTRINSICS) |
| 38 | #undef INTRINSICS_LIST |
| 39 | #undef OPTIMIZING_INTRINSICS |
| 40 | } |
| 41 | return kInterface; |
| 42 | } |
| 43 | |
| 44 | |
| 45 | |
| 46 | static Primitive::Type GetType(uint64_t data, bool is_op_size) { |
| 47 | if (is_op_size) { |
| 48 | switch (static_cast<OpSize>(data)) { |
| 49 | case kSignedByte: |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 50 | return Primitive::kPrimByte; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 51 | case kSignedHalf: |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 52 | return Primitive::kPrimShort; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 53 | case k32: |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 54 | return Primitive::kPrimInt; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 55 | case k64: |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 56 | return Primitive::kPrimLong; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 57 | default: |
| 58 | LOG(FATAL) << "Unknown/unsupported op size " << data; |
| 59 | UNREACHABLE(); |
| 60 | } |
| 61 | } else { |
| 62 | if ((data & kIntrinsicFlagIsLong) != 0) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 63 | return Primitive::kPrimLong; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 64 | } |
| 65 | if ((data & kIntrinsicFlagIsObject) != 0) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 66 | return Primitive::kPrimNot; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 67 | } |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 68 | return Primitive::kPrimInt; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 69 | } |
| 70 | } |
| 71 | |
| 72 | static Intrinsics GetIntrinsic(InlineMethod method) { |
| 73 | switch (method.opcode) { |
| 74 | // Floating-point conversions. |
| 75 | case kIntrinsicDoubleCvt: |
| 76 | return ((method.d.data & kIntrinsicFlagToFloatingPoint) == 0) ? |
| 77 | Intrinsics::kDoubleDoubleToRawLongBits : Intrinsics::kDoubleLongBitsToDouble; |
| 78 | case kIntrinsicFloatCvt: |
| 79 | return ((method.d.data & kIntrinsicFlagToFloatingPoint) == 0) ? |
| 80 | Intrinsics::kFloatFloatToRawIntBits : Intrinsics::kFloatIntBitsToFloat; |
| 81 | |
| 82 | // Bit manipulations. |
| 83 | case kIntrinsicReverseBits: |
| 84 | switch (GetType(method.d.data, true)) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 85 | case Primitive::kPrimInt: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 86 | return Intrinsics::kIntegerReverse; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 87 | case Primitive::kPrimLong: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 88 | return Intrinsics::kLongReverse; |
| 89 | default: |
| 90 | LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; |
| 91 | UNREACHABLE(); |
| 92 | } |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 93 | case kIntrinsicReverseBytes: |
| 94 | switch (GetType(method.d.data, true)) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 95 | case Primitive::kPrimShort: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 96 | return Intrinsics::kShortReverseBytes; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 97 | case Primitive::kPrimInt: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 98 | return Intrinsics::kIntegerReverseBytes; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 99 | case Primitive::kPrimLong: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 100 | return Intrinsics::kLongReverseBytes; |
| 101 | default: |
| 102 | LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; |
| 103 | UNREACHABLE(); |
| 104 | } |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 105 | |
| 106 | // Abs. |
| 107 | case kIntrinsicAbsDouble: |
| 108 | return Intrinsics::kMathAbsDouble; |
| 109 | case kIntrinsicAbsFloat: |
| 110 | return Intrinsics::kMathAbsFloat; |
| 111 | case kIntrinsicAbsInt: |
| 112 | return Intrinsics::kMathAbsInt; |
| 113 | case kIntrinsicAbsLong: |
| 114 | return Intrinsics::kMathAbsLong; |
| 115 | |
| 116 | // Min/max. |
| 117 | case kIntrinsicMinMaxDouble: |
| 118 | return ((method.d.data & kIntrinsicFlagMin) == 0) ? |
| 119 | Intrinsics::kMathMaxDoubleDouble : Intrinsics::kMathMinDoubleDouble; |
| 120 | case kIntrinsicMinMaxFloat: |
| 121 | return ((method.d.data & kIntrinsicFlagMin) == 0) ? |
| 122 | Intrinsics::kMathMaxFloatFloat : Intrinsics::kMathMinFloatFloat; |
| 123 | case kIntrinsicMinMaxInt: |
| 124 | return ((method.d.data & kIntrinsicFlagMin) == 0) ? |
| 125 | Intrinsics::kMathMaxIntInt : Intrinsics::kMathMinIntInt; |
| 126 | case kIntrinsicMinMaxLong: |
| 127 | return ((method.d.data & kIntrinsicFlagMin) == 0) ? |
| 128 | Intrinsics::kMathMaxLongLong : Intrinsics::kMathMinLongLong; |
| 129 | |
| 130 | // Misc math. |
| 131 | case kIntrinsicSqrt: |
| 132 | return Intrinsics::kMathSqrt; |
| 133 | case kIntrinsicCeil: |
| 134 | return Intrinsics::kMathCeil; |
| 135 | case kIntrinsicFloor: |
| 136 | return Intrinsics::kMathFloor; |
| 137 | case kIntrinsicRint: |
| 138 | return Intrinsics::kMathRint; |
| 139 | case kIntrinsicRoundDouble: |
| 140 | return Intrinsics::kMathRoundDouble; |
| 141 | case kIntrinsicRoundFloat: |
| 142 | return Intrinsics::kMathRoundFloat; |
| 143 | |
| 144 | // System.arraycopy. |
| 145 | case kIntrinsicSystemArrayCopyCharArray: |
| 146 | return Intrinsics::kSystemArrayCopyChar; |
| 147 | |
| 148 | // Thread.currentThread. |
| 149 | case kIntrinsicCurrentThread: |
| 150 | return Intrinsics::kThreadCurrentThread; |
| 151 | |
| 152 | // Memory.peek. |
| 153 | case kIntrinsicPeek: |
| 154 | switch (GetType(method.d.data, true)) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 155 | case Primitive::kPrimByte: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 156 | return Intrinsics::kMemoryPeekByte; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 157 | case Primitive::kPrimShort: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 158 | return Intrinsics::kMemoryPeekShortNative; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 159 | case Primitive::kPrimInt: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 160 | return Intrinsics::kMemoryPeekIntNative; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 161 | case Primitive::kPrimLong: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 162 | return Intrinsics::kMemoryPeekLongNative; |
| 163 | default: |
| 164 | LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; |
| 165 | UNREACHABLE(); |
| 166 | } |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 167 | |
| 168 | // Memory.poke. |
| 169 | case kIntrinsicPoke: |
| 170 | switch (GetType(method.d.data, true)) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 171 | case Primitive::kPrimByte: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 172 | return Intrinsics::kMemoryPokeByte; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 173 | case Primitive::kPrimShort: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 174 | return Intrinsics::kMemoryPokeShortNative; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 175 | case Primitive::kPrimInt: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 176 | return Intrinsics::kMemoryPokeIntNative; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 177 | case Primitive::kPrimLong: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 178 | return Intrinsics::kMemoryPokeLongNative; |
| 179 | default: |
| 180 | LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; |
| 181 | UNREACHABLE(); |
| 182 | } |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 183 | |
| 184 | // String. |
| 185 | case kIntrinsicCharAt: |
| 186 | return Intrinsics::kStringCharAt; |
| 187 | case kIntrinsicCompareTo: |
| 188 | return Intrinsics::kStringCompareTo; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 189 | case kIntrinsicGetCharsNoCheck: |
| 190 | return Intrinsics::kStringGetCharsNoCheck; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 191 | case kIntrinsicIsEmptyOrLength: |
Razvan A Lupusoru | 3e90a96 | 2015-03-27 13:44:44 -0700 | [diff] [blame] | 192 | // The inliner can handle these two cases - and this is the preferred approach |
| 193 | // since after inlining the call is no longer visible (as opposed to waiting |
| 194 | // until codegen to handle intrinsic). |
| 195 | return Intrinsics::kNone; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 196 | case kIntrinsicIndexOf: |
| 197 | return ((method.d.data & kIntrinsicFlagBase0) == 0) ? |
| 198 | Intrinsics::kStringIndexOfAfter : Intrinsics::kStringIndexOf; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 199 | case kIntrinsicNewStringFromBytes: |
| 200 | return Intrinsics::kStringNewStringFromBytes; |
| 201 | case kIntrinsicNewStringFromChars: |
| 202 | return Intrinsics::kStringNewStringFromChars; |
| 203 | case kIntrinsicNewStringFromString: |
| 204 | return Intrinsics::kStringNewStringFromString; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 205 | |
| 206 | case kIntrinsicCas: |
| 207 | switch (GetType(method.d.data, false)) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 208 | case Primitive::kPrimNot: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 209 | return Intrinsics::kUnsafeCASObject; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 210 | case Primitive::kPrimInt: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 211 | return Intrinsics::kUnsafeCASInt; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 212 | case Primitive::kPrimLong: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 213 | return Intrinsics::kUnsafeCASLong; |
| 214 | default: |
| 215 | LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; |
| 216 | UNREACHABLE(); |
| 217 | } |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 218 | case kIntrinsicUnsafeGet: { |
| 219 | const bool is_volatile = (method.d.data & kIntrinsicFlagIsVolatile); |
| 220 | switch (GetType(method.d.data, false)) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 221 | case Primitive::kPrimInt: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 222 | return is_volatile ? Intrinsics::kUnsafeGetVolatile : Intrinsics::kUnsafeGet; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 223 | case Primitive::kPrimLong: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 224 | return is_volatile ? Intrinsics::kUnsafeGetLongVolatile : Intrinsics::kUnsafeGetLong; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 225 | case Primitive::kPrimNot: |
| 226 | return is_volatile ? Intrinsics::kUnsafeGetObjectVolatile : Intrinsics::kUnsafeGetObject; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 227 | default: |
| 228 | LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; |
| 229 | UNREACHABLE(); |
| 230 | } |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 231 | } |
| 232 | case kIntrinsicUnsafePut: { |
| 233 | enum Sync { kNoSync, kVolatile, kOrdered }; |
| 234 | const Sync sync = |
| 235 | ((method.d.data & kIntrinsicFlagIsVolatile) != 0) ? kVolatile : |
| 236 | ((method.d.data & kIntrinsicFlagIsOrdered) != 0) ? kOrdered : |
| 237 | kNoSync; |
| 238 | switch (GetType(method.d.data, false)) { |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 239 | case Primitive::kPrimInt: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 240 | switch (sync) { |
| 241 | case kNoSync: |
| 242 | return Intrinsics::kUnsafePut; |
| 243 | case kVolatile: |
| 244 | return Intrinsics::kUnsafePutVolatile; |
| 245 | case kOrdered: |
| 246 | return Intrinsics::kUnsafePutOrdered; |
| 247 | } |
| 248 | break; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 249 | case Primitive::kPrimLong: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 250 | switch (sync) { |
| 251 | case kNoSync: |
| 252 | return Intrinsics::kUnsafePutLong; |
| 253 | case kVolatile: |
| 254 | return Intrinsics::kUnsafePutLongVolatile; |
| 255 | case kOrdered: |
| 256 | return Intrinsics::kUnsafePutLongOrdered; |
| 257 | } |
| 258 | break; |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 259 | case Primitive::kPrimNot: |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 260 | switch (sync) { |
| 261 | case kNoSync: |
| 262 | return Intrinsics::kUnsafePutObject; |
| 263 | case kVolatile: |
| 264 | return Intrinsics::kUnsafePutObjectVolatile; |
| 265 | case kOrdered: |
| 266 | return Intrinsics::kUnsafePutObjectOrdered; |
| 267 | } |
| 268 | break; |
| 269 | default: |
| 270 | LOG(FATAL) << "Unknown/unsupported op size " << method.d.data; |
| 271 | UNREACHABLE(); |
| 272 | } |
| 273 | break; |
| 274 | } |
| 275 | |
| 276 | // Virtual cases. |
| 277 | |
| 278 | case kIntrinsicReferenceGetReferent: |
| 279 | return Intrinsics::kReferenceGetReferent; |
| 280 | |
| 281 | // Quick inliner cases. Remove after refactoring. They are here so that we can use the |
| 282 | // compiler to warn on missing cases. |
| 283 | |
| 284 | case kInlineOpNop: |
| 285 | case kInlineOpReturnArg: |
| 286 | case kInlineOpNonWideConst: |
| 287 | case kInlineOpIGet: |
| 288 | case kInlineOpIPut: |
| 289 | return Intrinsics::kNone; |
| 290 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 291 | // String init cases, not intrinsics. |
| 292 | |
| 293 | case kInlineStringInit: |
| 294 | return Intrinsics::kNone; |
| 295 | |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 296 | // No default case to make the compiler warn on missing cases. |
| 297 | } |
| 298 | return Intrinsics::kNone; |
| 299 | } |
| 300 | |
| 301 | static bool CheckInvokeType(Intrinsics intrinsic, HInvoke* invoke) { |
| 302 | // The DexFileMethodInliner should have checked whether the methods are agreeing with |
| 303 | // what we expect, i.e., static methods are called as such. Add another check here for |
| 304 | // our expectations: |
| 305 | // Whenever the intrinsic is marked as static-or-direct, report an error if we find an |
| 306 | // InvokeVirtual. The other direction is not possible: we have intrinsics for virtual |
| 307 | // functions that will perform a check inline. If the precise type is known, however, |
| 308 | // the instruction will be sharpened to an InvokeStaticOrDirect. |
| 309 | InvokeType intrinsic_type = GetIntrinsicInvokeType(intrinsic); |
| 310 | InvokeType invoke_type = invoke->IsInvokeStaticOrDirect() ? |
| 311 | invoke->AsInvokeStaticOrDirect()->GetInvokeType() : |
| 312 | invoke->IsInvokeVirtual() ? kVirtual : kSuper; |
| 313 | switch (intrinsic_type) { |
| 314 | case kStatic: |
| 315 | return (invoke_type == kStatic); |
| 316 | case kDirect: |
| 317 | return (invoke_type == kDirect); |
| 318 | case kVirtual: |
| 319 | // Call might be devirtualized. |
| 320 | return (invoke_type == kVirtual || invoke_type == kDirect); |
| 321 | |
| 322 | default: |
| 323 | return false; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | // TODO: Refactor DexFileMethodInliner and have something nicer than InlineMethod. |
| 328 | void IntrinsicsRecognizer::Run() { |
| 329 | DexFileMethodInliner* inliner = driver_->GetMethodInlinerMap()->GetMethodInliner(dex_file_); |
| 330 | DCHECK(inliner != nullptr); |
| 331 | |
| 332 | for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) { |
| 333 | HBasicBlock* block = it.Current(); |
| 334 | for (HInstructionIterator inst_it(block->GetInstructions()); !inst_it.Done(); |
| 335 | inst_it.Advance()) { |
| 336 | HInstruction* inst = inst_it.Current(); |
| 337 | if (inst->IsInvoke()) { |
| 338 | HInvoke* invoke = inst->AsInvoke(); |
| 339 | InlineMethod method; |
| 340 | if (inliner->IsIntrinsic(invoke->GetDexMethodIndex(), &method)) { |
| 341 | Intrinsics intrinsic = GetIntrinsic(method); |
| 342 | |
| 343 | if (intrinsic != Intrinsics::kNone) { |
| 344 | if (!CheckInvokeType(intrinsic, invoke)) { |
| 345 | LOG(WARNING) << "Found an intrinsic with unexpected invoke type: " |
| 346 | << intrinsic << " for " |
| 347 | << PrettyMethod(invoke->GetDexMethodIndex(), *dex_file_); |
| 348 | } else { |
| 349 | invoke->SetIntrinsic(intrinsic); |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | std::ostream& operator<<(std::ostream& os, const Intrinsics& intrinsic) { |
| 359 | switch (intrinsic) { |
| 360 | case Intrinsics::kNone: |
| 361 | os << "No intrinsic."; |
| 362 | break; |
| 363 | #define OPTIMIZING_INTRINSICS(Name, IsStatic) \ |
| 364 | case Intrinsics::k ## Name: \ |
| 365 | os << # Name; \ |
| 366 | break; |
| 367 | #include "intrinsics_list.h" |
| 368 | INTRINSICS_LIST(OPTIMIZING_INTRINSICS) |
| 369 | #undef STATIC_INTRINSICS_LIST |
| 370 | #undef VIRTUAL_INTRINSICS_LIST |
| 371 | #undef OPTIMIZING_INTRINSICS |
| 372 | } |
| 373 | return os; |
| 374 | } |
| 375 | |
| 376 | } // namespace art |
| 377 | |