Nicolas Geoffray | a42363f | 2015-12-17 14:57:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 "art_method.h" |
| 18 | #include "jit/jit.h" |
| 19 | #include "jit/jit_code_cache.h" |
| 20 | #include "oat_quick_method_header.h" |
| 21 | #include "scoped_thread_state_change.h" |
| 22 | #include "stack_map.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | static void do_checks(jclass cls, const char* method_name) { |
| 27 | ScopedObjectAccess soa(Thread::Current()); |
| 28 | mirror::Class* klass = soa.Decode<mirror::Class*>(cls); |
| 29 | jit::Jit* jit = Runtime::Current()->GetJit(); |
| 30 | jit::JitCodeCache* code_cache = jit->GetCodeCache(); |
| 31 | ArtMethod* method = klass->FindDeclaredDirectMethodByName(method_name, sizeof(void*)); |
Nicolas Geoffray | a60e220 | 2016-01-28 18:15:53 +0000 | [diff] [blame] | 32 | |
Nicolas Geoffray | c26f128 | 2016-01-29 11:41:25 +0000 | [diff] [blame] | 33 | OatQuickMethodHeader* header = nullptr; |
| 34 | // Infinite loop... Test harness will have its own timeout. |
| 35 | while (true) { |
| 36 | header = OatQuickMethodHeader::FromEntryPoint(method->GetEntryPointFromQuickCompiledCode()); |
| 37 | if (code_cache->ContainsPc(header->GetCode())) { |
| 38 | break; |
| 39 | } else { |
| 40 | // sleep one second to give time to the JIT compiler. |
| 41 | sleep(1); |
| 42 | } |
| 43 | } |
Nicolas Geoffray | a42363f | 2015-12-17 14:57:09 +0000 | [diff] [blame] | 44 | |
| 45 | CodeInfo info = header->GetOptimizedCodeInfo(); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 46 | CodeInfoEncoding encoding = info.ExtractEncoding(); |
| 47 | CHECK(info.HasInlineInfo(encoding)); |
Nicolas Geoffray | a42363f | 2015-12-17 14:57:09 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | extern "C" JNIEXPORT void JNICALL Java_Main_ensureJittedAndPolymorphicInline(JNIEnv*, jclass cls) { |
| 51 | jit::Jit* jit = Runtime::Current()->GetJit(); |
| 52 | if (jit == nullptr) { |
| 53 | return; |
| 54 | } |
| 55 | |
Nicolas Geoffray | c26f128 | 2016-01-29 11:41:25 +0000 | [diff] [blame] | 56 | if (kIsDebugBuild) { |
| 57 | // A debug build might often compile the methods without profiling informations filled. |
| 58 | return; |
| 59 | } |
| 60 | |
Nicolas Geoffray | a42363f | 2015-12-17 14:57:09 +0000 | [diff] [blame] | 61 | do_checks(cls, "testInvokeVirtual"); |
| 62 | do_checks(cls, "testInvokeInterface"); |
Nicolas Geoffray | 1be7cbd | 2016-04-29 13:56:01 +0100 | [diff] [blame] | 63 | do_checks(cls, "$noinline$testInlineToSameTarget"); |
Nicolas Geoffray | a42363f | 2015-12-17 14:57:09 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | } // namespace art |