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 24namespace art { 25 26static 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*)); 32 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 } 44 45 CodeInfo info = header->GetOptimizedCodeInfo(); 46 CodeInfoEncoding encoding = info.ExtractEncoding(); 47 CHECK(info.HasInlineInfo(encoding)); 48} 49 50extern "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 56 if (kIsDebugBuild) { 57 // A debug build might often compile the methods without profiling informations filled. 58 return; 59 } 60 61 do_checks(cls, "testInvokeVirtual"); 62 do_checks(cls, "testInvokeInterface"); 63 do_checks(cls, "$noinline$testInlineToSameTarget"); 64} 65 66} // namespace art 67