blob: 7b2c6cbcd5e3f8bfacf954464dc952a677924923 [file] [log] [blame]
Nicolas Geoffraya42363f2015-12-17 14:57:09 +00001/*
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*));
Nicolas Geoffraya60e2202016-01-28 18:15:53 +000032
Nicolas Geoffrayc26f1282016-01-29 11:41:25 +000033 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 Geoffraya42363f2015-12-17 14:57:09 +000044
45 CodeInfo info = header->GetOptimizedCodeInfo();
David Srbecky09ed0982016-02-12 21:58:43 +000046 CodeInfoEncoding encoding = info.ExtractEncoding();
47 CHECK(info.HasInlineInfo(encoding));
Nicolas Geoffraya42363f2015-12-17 14:57:09 +000048}
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
Nicolas Geoffrayc26f1282016-01-29 11:41:25 +000056 if (kIsDebugBuild) {
57 // A debug build might often compile the methods without profiling informations filled.
58 return;
59 }
60
Nicolas Geoffraya42363f2015-12-17 14:57:09 +000061 do_checks(cls, "testInvokeVirtual");
62 do_checks(cls, "testInvokeInterface");
Nicolas Geoffray1be7cbd2016-04-29 13:56:01 +010063 do_checks(cls, "$noinline$testInlineToSameTarget");
Nicolas Geoffraya42363f2015-12-17 14:57:09 +000064}
65
66} // namespace art