blob: 41c239d60bc32002a5bff3eda7bd0952914cd14e [file] [log] [blame]
Andreas Gampe71fb52f2014-12-29 17:43:08 -08001/*
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
Andreas Gampebfb5ba92015-09-01 15:45:02 +000019#include "art_method.h"
20#include "class_linker.h"
Andreas Gampe71fb52f2014-12-29 17:43:08 -080021#include "dex/quick/dex_file_method_inliner.h"
22#include "dex/quick/dex_file_to_method_inliner_map.h"
23#include "driver/compiler_driver.h"
24#include "invoke_type.h"
Andreas Gampebfb5ba92015-09-01 15:45:02 +000025#include "mirror/dex_cache-inl.h"
Andreas Gampe71fb52f2014-12-29 17:43:08 -080026#include "nodes.h"
27#include "quick/inline_method_analyser.h"
Andreas Gampebfb5ba92015-09-01 15:45:02 +000028#include "scoped_thread_state_change.h"
29#include "thread-inl.h"
Vladimir Marko80afd022015-05-19 18:08:00 +010030#include "utils.h"
Andreas Gampe71fb52f2014-12-29 17:43:08 -080031
32namespace art {
33
34// Function that returns whether an intrinsic is static/direct or virtual.
35static inline InvokeType GetIntrinsicInvokeType(Intrinsics i) {
36 switch (i) {
37 case Intrinsics::kNone:
38 return kInterface; // Non-sensical for intrinsic.
Agi Csaki05f20562015-08-19 14:58:14 -070039#define OPTIMIZING_INTRINSICS(Name, IsStatic, NeedsEnvironmentOrCache) \
Andreas Gampe71fb52f2014-12-29 17:43:08 -080040 case Intrinsics::k ## Name: \
41 return IsStatic;
42#include "intrinsics_list.h"
43INTRINSICS_LIST(OPTIMIZING_INTRINSICS)
44#undef INTRINSICS_LIST
45#undef OPTIMIZING_INTRINSICS
46 }
47 return kInterface;
48}
49
agicsaki57b81ec2015-08-11 17:39:37 -070050// Function that returns whether an intrinsic needs an environment or not.
Agi Csaki05f20562015-08-19 14:58:14 -070051static inline IntrinsicNeedsEnvironmentOrCache NeedsEnvironmentOrCache(Intrinsics i) {
agicsaki57b81ec2015-08-11 17:39:37 -070052 switch (i) {
53 case Intrinsics::kNone:
Agi Csaki05f20562015-08-19 14:58:14 -070054 return kNeedsEnvironmentOrCache; // Non-sensical for intrinsic.
55#define OPTIMIZING_INTRINSICS(Name, IsStatic, NeedsEnvironmentOrCache) \
agicsaki57b81ec2015-08-11 17:39:37 -070056 case Intrinsics::k ## Name: \
Agi Csaki05f20562015-08-19 14:58:14 -070057 return NeedsEnvironmentOrCache;
agicsaki57b81ec2015-08-11 17:39:37 -070058#include "intrinsics_list.h"
59INTRINSICS_LIST(OPTIMIZING_INTRINSICS)
60#undef INTRINSICS_LIST
61#undef OPTIMIZING_INTRINSICS
62 }
Agi Csaki05f20562015-08-19 14:58:14 -070063 return kNeedsEnvironmentOrCache;
agicsaki57b81ec2015-08-11 17:39:37 -070064}
Andreas Gampe71fb52f2014-12-29 17:43:08 -080065
66static Primitive::Type GetType(uint64_t data, bool is_op_size) {
67 if (is_op_size) {
68 switch (static_cast<OpSize>(data)) {
69 case kSignedByte:
Andreas Gampe878d58c2015-01-15 23:24:00 -080070 return Primitive::kPrimByte;
Andreas Gampe71fb52f2014-12-29 17:43:08 -080071 case kSignedHalf:
Andreas Gampe878d58c2015-01-15 23:24:00 -080072 return Primitive::kPrimShort;
Andreas Gampe71fb52f2014-12-29 17:43:08 -080073 case k32:
Andreas Gampe878d58c2015-01-15 23:24:00 -080074 return Primitive::kPrimInt;
Andreas Gampe71fb52f2014-12-29 17:43:08 -080075 case k64:
Andreas Gampe878d58c2015-01-15 23:24:00 -080076 return Primitive::kPrimLong;
Andreas Gampe71fb52f2014-12-29 17:43:08 -080077 default:
78 LOG(FATAL) << "Unknown/unsupported op size " << data;
79 UNREACHABLE();
80 }
81 } else {
82 if ((data & kIntrinsicFlagIsLong) != 0) {
Andreas Gampe878d58c2015-01-15 23:24:00 -080083 return Primitive::kPrimLong;
Andreas Gampe71fb52f2014-12-29 17:43:08 -080084 }
85 if ((data & kIntrinsicFlagIsObject) != 0) {
Andreas Gampe878d58c2015-01-15 23:24:00 -080086 return Primitive::kPrimNot;
Andreas Gampe71fb52f2014-12-29 17:43:08 -080087 }
Andreas Gampe878d58c2015-01-15 23:24:00 -080088 return Primitive::kPrimInt;
Andreas Gampe71fb52f2014-12-29 17:43:08 -080089 }
90}
91
agicsaki6cff09a2015-08-12 21:20:43 -070092static Intrinsics GetIntrinsic(InlineMethod method, InstructionSet instruction_set) {
93 if (instruction_set == kMips || instruction_set == kMips64) {
94 return Intrinsics::kNone;
95 }
Andreas Gampe71fb52f2014-12-29 17:43:08 -080096 switch (method.opcode) {
97 // Floating-point conversions.
98 case kIntrinsicDoubleCvt:
99 return ((method.d.data & kIntrinsicFlagToFloatingPoint) == 0) ?
100 Intrinsics::kDoubleDoubleToRawLongBits : Intrinsics::kDoubleLongBitsToDouble;
101 case kIntrinsicFloatCvt:
102 return ((method.d.data & kIntrinsicFlagToFloatingPoint) == 0) ?
103 Intrinsics::kFloatFloatToRawIntBits : Intrinsics::kFloatIntBitsToFloat;
104
105 // Bit manipulations.
106 case kIntrinsicReverseBits:
107 switch (GetType(method.d.data, true)) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800108 case Primitive::kPrimInt:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800109 return Intrinsics::kIntegerReverse;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800110 case Primitive::kPrimLong:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800111 return Intrinsics::kLongReverse;
112 default:
113 LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
114 UNREACHABLE();
115 }
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800116 case kIntrinsicReverseBytes:
117 switch (GetType(method.d.data, true)) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800118 case Primitive::kPrimShort:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800119 return Intrinsics::kShortReverseBytes;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800120 case Primitive::kPrimInt:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800121 return Intrinsics::kIntegerReverseBytes;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800122 case Primitive::kPrimLong:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800123 return Intrinsics::kLongReverseBytes;
124 default:
125 LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
126 UNREACHABLE();
127 }
Scott Wakeling611d3392015-07-10 11:42:06 +0100128 case kIntrinsicNumberOfLeadingZeros:
129 switch (GetType(method.d.data, true)) {
130 case Primitive::kPrimInt:
131 return Intrinsics::kIntegerNumberOfLeadingZeros;
132 case Primitive::kPrimLong:
133 return Intrinsics::kLongNumberOfLeadingZeros;
134 default:
135 LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
136 UNREACHABLE();
137 }
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800138
139 // Abs.
140 case kIntrinsicAbsDouble:
141 return Intrinsics::kMathAbsDouble;
142 case kIntrinsicAbsFloat:
143 return Intrinsics::kMathAbsFloat;
144 case kIntrinsicAbsInt:
145 return Intrinsics::kMathAbsInt;
146 case kIntrinsicAbsLong:
147 return Intrinsics::kMathAbsLong;
148
149 // Min/max.
150 case kIntrinsicMinMaxDouble:
151 return ((method.d.data & kIntrinsicFlagMin) == 0) ?
152 Intrinsics::kMathMaxDoubleDouble : Intrinsics::kMathMinDoubleDouble;
153 case kIntrinsicMinMaxFloat:
154 return ((method.d.data & kIntrinsicFlagMin) == 0) ?
155 Intrinsics::kMathMaxFloatFloat : Intrinsics::kMathMinFloatFloat;
156 case kIntrinsicMinMaxInt:
157 return ((method.d.data & kIntrinsicFlagMin) == 0) ?
158 Intrinsics::kMathMaxIntInt : Intrinsics::kMathMinIntInt;
159 case kIntrinsicMinMaxLong:
160 return ((method.d.data & kIntrinsicFlagMin) == 0) ?
161 Intrinsics::kMathMaxLongLong : Intrinsics::kMathMinLongLong;
162
163 // Misc math.
164 case kIntrinsicSqrt:
165 return Intrinsics::kMathSqrt;
166 case kIntrinsicCeil:
167 return Intrinsics::kMathCeil;
168 case kIntrinsicFloor:
169 return Intrinsics::kMathFloor;
170 case kIntrinsicRint:
171 return Intrinsics::kMathRint;
172 case kIntrinsicRoundDouble:
173 return Intrinsics::kMathRoundDouble;
174 case kIntrinsicRoundFloat:
175 return Intrinsics::kMathRoundFloat;
176
177 // System.arraycopy.
178 case kIntrinsicSystemArrayCopyCharArray:
179 return Intrinsics::kSystemArrayCopyChar;
180
181 // Thread.currentThread.
182 case kIntrinsicCurrentThread:
183 return Intrinsics::kThreadCurrentThread;
184
185 // Memory.peek.
186 case kIntrinsicPeek:
187 switch (GetType(method.d.data, true)) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800188 case Primitive::kPrimByte:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800189 return Intrinsics::kMemoryPeekByte;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800190 case Primitive::kPrimShort:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800191 return Intrinsics::kMemoryPeekShortNative;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800192 case Primitive::kPrimInt:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800193 return Intrinsics::kMemoryPeekIntNative;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800194 case Primitive::kPrimLong:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800195 return Intrinsics::kMemoryPeekLongNative;
196 default:
197 LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
198 UNREACHABLE();
199 }
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800200
201 // Memory.poke.
202 case kIntrinsicPoke:
203 switch (GetType(method.d.data, true)) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800204 case Primitive::kPrimByte:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800205 return Intrinsics::kMemoryPokeByte;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800206 case Primitive::kPrimShort:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800207 return Intrinsics::kMemoryPokeShortNative;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800208 case Primitive::kPrimInt:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800209 return Intrinsics::kMemoryPokeIntNative;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800210 case Primitive::kPrimLong:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800211 return Intrinsics::kMemoryPokeLongNative;
212 default:
213 LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
214 UNREACHABLE();
215 }
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800216
217 // String.
218 case kIntrinsicCharAt:
219 return Intrinsics::kStringCharAt;
220 case kIntrinsicCompareTo:
221 return Intrinsics::kStringCompareTo;
agicsaki7da072f2015-08-12 20:30:17 -0700222 case kIntrinsicEquals:
223 return Intrinsics::kStringEquals;
Jeff Hao848f70a2014-01-15 13:49:50 -0800224 case kIntrinsicGetCharsNoCheck:
225 return Intrinsics::kStringGetCharsNoCheck;
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800226 case kIntrinsicIsEmptyOrLength:
Razvan A Lupusoru3e90a962015-03-27 13:44:44 -0700227 // The inliner can handle these two cases - and this is the preferred approach
228 // since after inlining the call is no longer visible (as opposed to waiting
229 // until codegen to handle intrinsic).
230 return Intrinsics::kNone;
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800231 case kIntrinsicIndexOf:
232 return ((method.d.data & kIntrinsicFlagBase0) == 0) ?
233 Intrinsics::kStringIndexOfAfter : Intrinsics::kStringIndexOf;
Jeff Hao848f70a2014-01-15 13:49:50 -0800234 case kIntrinsicNewStringFromBytes:
235 return Intrinsics::kStringNewStringFromBytes;
236 case kIntrinsicNewStringFromChars:
237 return Intrinsics::kStringNewStringFromChars;
238 case kIntrinsicNewStringFromString:
239 return Intrinsics::kStringNewStringFromString;
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800240
241 case kIntrinsicCas:
242 switch (GetType(method.d.data, false)) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800243 case Primitive::kPrimNot:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800244 return Intrinsics::kUnsafeCASObject;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800245 case Primitive::kPrimInt:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800246 return Intrinsics::kUnsafeCASInt;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800247 case Primitive::kPrimLong:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800248 return Intrinsics::kUnsafeCASLong;
249 default:
250 LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
251 UNREACHABLE();
252 }
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800253 case kIntrinsicUnsafeGet: {
254 const bool is_volatile = (method.d.data & kIntrinsicFlagIsVolatile);
255 switch (GetType(method.d.data, false)) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800256 case Primitive::kPrimInt:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800257 return is_volatile ? Intrinsics::kUnsafeGetVolatile : Intrinsics::kUnsafeGet;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800258 case Primitive::kPrimLong:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800259 return is_volatile ? Intrinsics::kUnsafeGetLongVolatile : Intrinsics::kUnsafeGetLong;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800260 case Primitive::kPrimNot:
261 return is_volatile ? Intrinsics::kUnsafeGetObjectVolatile : Intrinsics::kUnsafeGetObject;
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800262 default:
263 LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
264 UNREACHABLE();
265 }
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800266 }
267 case kIntrinsicUnsafePut: {
268 enum Sync { kNoSync, kVolatile, kOrdered };
269 const Sync sync =
270 ((method.d.data & kIntrinsicFlagIsVolatile) != 0) ? kVolatile :
271 ((method.d.data & kIntrinsicFlagIsOrdered) != 0) ? kOrdered :
272 kNoSync;
273 switch (GetType(method.d.data, false)) {
Andreas Gampe878d58c2015-01-15 23:24:00 -0800274 case Primitive::kPrimInt:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800275 switch (sync) {
276 case kNoSync:
277 return Intrinsics::kUnsafePut;
278 case kVolatile:
279 return Intrinsics::kUnsafePutVolatile;
280 case kOrdered:
281 return Intrinsics::kUnsafePutOrdered;
282 }
283 break;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800284 case Primitive::kPrimLong:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800285 switch (sync) {
286 case kNoSync:
287 return Intrinsics::kUnsafePutLong;
288 case kVolatile:
289 return Intrinsics::kUnsafePutLongVolatile;
290 case kOrdered:
291 return Intrinsics::kUnsafePutLongOrdered;
292 }
293 break;
Andreas Gampe878d58c2015-01-15 23:24:00 -0800294 case Primitive::kPrimNot:
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800295 switch (sync) {
296 case kNoSync:
297 return Intrinsics::kUnsafePutObject;
298 case kVolatile:
299 return Intrinsics::kUnsafePutObjectVolatile;
300 case kOrdered:
301 return Intrinsics::kUnsafePutObjectOrdered;
302 }
303 break;
304 default:
305 LOG(FATAL) << "Unknown/unsupported op size " << method.d.data;
306 UNREACHABLE();
307 }
308 break;
309 }
310
311 // Virtual cases.
312
313 case kIntrinsicReferenceGetReferent:
314 return Intrinsics::kReferenceGetReferent;
315
316 // Quick inliner cases. Remove after refactoring. They are here so that we can use the
317 // compiler to warn on missing cases.
318
319 case kInlineOpNop:
320 case kInlineOpReturnArg:
321 case kInlineOpNonWideConst:
322 case kInlineOpIGet:
323 case kInlineOpIPut:
324 return Intrinsics::kNone;
325
Jeff Hao848f70a2014-01-15 13:49:50 -0800326 // String init cases, not intrinsics.
327
328 case kInlineStringInit:
329 return Intrinsics::kNone;
330
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800331 // No default case to make the compiler warn on missing cases.
332 }
333 return Intrinsics::kNone;
334}
335
Andreas Gampebfb5ba92015-09-01 15:45:02 +0000336static bool CheckInvokeType(Intrinsics intrinsic, HInvoke* invoke, const DexFile& dex_file) {
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800337 // The DexFileMethodInliner should have checked whether the methods are agreeing with
338 // what we expect, i.e., static methods are called as such. Add another check here for
339 // our expectations:
Andreas Gampebfb5ba92015-09-01 15:45:02 +0000340 //
341 // Whenever the intrinsic is marked as static, report an error if we find an InvokeVirtual.
342 //
343 // Whenever the intrinsic is marked as direct and we find an InvokeVirtual, a devirtualization
344 // failure occured. We might be in a situation where we have inlined a method that calls an
345 // intrinsic, but that method is in a different dex file on which we do not have a
346 // verified_method that would have helped the compiler driver sharpen the call. In that case,
347 // make sure that the intrinsic is actually for some final method (or in a final class), as
348 // otherwise the intrinsics setup is broken.
349 //
350 // For the last direction, we have intrinsics for virtual functions that will perform a check
351 // inline. If the precise type is known, however, the instruction will be sharpened to an
352 // InvokeStaticOrDirect.
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800353 InvokeType intrinsic_type = GetIntrinsicInvokeType(intrinsic);
354 InvokeType invoke_type = invoke->IsInvokeStaticOrDirect() ?
355 invoke->AsInvokeStaticOrDirect()->GetInvokeType() :
356 invoke->IsInvokeVirtual() ? kVirtual : kSuper;
357 switch (intrinsic_type) {
358 case kStatic:
359 return (invoke_type == kStatic);
Andreas Gampebfb5ba92015-09-01 15:45:02 +0000360
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800361 case kDirect:
Andreas Gampebfb5ba92015-09-01 15:45:02 +0000362 if (invoke_type == kDirect) {
363 return true;
364 }
365 if (invoke_type == kVirtual) {
366 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
367 ScopedObjectAccess soa(Thread::Current());
368 ArtMethod* art_method =
369 class_linker->FindDexCache(soa.Self(), dex_file)->GetResolvedMethod(
370 invoke->GetDexMethodIndex(), class_linker->GetImagePointerSize());
371 return art_method != nullptr &&
372 (art_method->IsFinal() || art_method->GetDeclaringClass()->IsFinal());
373 }
374 return false;
375
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800376 case kVirtual:
377 // Call might be devirtualized.
378 return (invoke_type == kVirtual || invoke_type == kDirect);
379
380 default:
381 return false;
382 }
383}
384
385// TODO: Refactor DexFileMethodInliner and have something nicer than InlineMethod.
386void IntrinsicsRecognizer::Run() {
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800387 for (HReversePostOrderIterator it(*graph_); !it.Done(); it.Advance()) {
388 HBasicBlock* block = it.Current();
389 for (HInstructionIterator inst_it(block->GetInstructions()); !inst_it.Done();
390 inst_it.Advance()) {
391 HInstruction* inst = inst_it.Current();
392 if (inst->IsInvoke()) {
393 HInvoke* invoke = inst->AsInvoke();
394 InlineMethod method;
Andreas Gampebfb5ba92015-09-01 15:45:02 +0000395 const DexFile& dex_file = invoke->GetDexFile();
396 DexFileMethodInliner* inliner = driver_->GetMethodInlinerMap()->GetMethodInliner(&dex_file);
Nicolas Geoffrayd5111bf2015-05-22 15:37:09 +0100397 DCHECK(inliner != nullptr);
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800398 if (inliner->IsIntrinsic(invoke->GetDexMethodIndex(), &method)) {
agicsaki6cff09a2015-08-12 21:20:43 -0700399 Intrinsics intrinsic = GetIntrinsic(method, graph_->GetInstructionSet());
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800400
401 if (intrinsic != Intrinsics::kNone) {
Andreas Gampebfb5ba92015-09-01 15:45:02 +0000402 if (!CheckInvokeType(intrinsic, invoke, dex_file)) {
Andreas Gampea14b9fe2015-08-24 22:49:59 +0000403 LOG(WARNING) << "Found an intrinsic with unexpected invoke type: "
Andreas Gampebfb5ba92015-09-01 15:45:02 +0000404 << intrinsic << " for "
405 << PrettyMethod(invoke->GetDexMethodIndex(), invoke->GetDexFile())
406 << invoke->DebugName();
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800407 } else {
Agi Csaki05f20562015-08-19 14:58:14 -0700408 invoke->SetIntrinsic(intrinsic, NeedsEnvironmentOrCache(intrinsic));
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800409 }
410 }
411 }
412 }
413 }
414 }
415}
416
417std::ostream& operator<<(std::ostream& os, const Intrinsics& intrinsic) {
418 switch (intrinsic) {
419 case Intrinsics::kNone:
David Brazdil109c89a2015-07-31 17:10:43 +0100420 os << "None";
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800421 break;
Agi Csaki05f20562015-08-19 14:58:14 -0700422#define OPTIMIZING_INTRINSICS(Name, IsStatic, NeedsEnvironmentOrCache) \
Andreas Gampe71fb52f2014-12-29 17:43:08 -0800423 case Intrinsics::k ## Name: \
424 os << # Name; \
425 break;
426#include "intrinsics_list.h"
427INTRINSICS_LIST(OPTIMIZING_INTRINSICS)
428#undef STATIC_INTRINSICS_LIST
429#undef VIRTUAL_INTRINSICS_LIST
430#undef OPTIMIZING_INTRINSICS
431 }
432 return os;
433}
434
435} // namespace art