blob: 55eac5c30a9103625ba4b0e335ff301186ad7bb6 [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 jit->CompileMethod(method, soa.Self());
33
Nicolas Geoffraya42363f2015-12-17 14:57:09 +000034 OatQuickMethodHeader* header = OatQuickMethodHeader::FromEntryPoint(
35 method->GetEntryPointFromQuickCompiledCode());
36 CHECK(code_cache->ContainsPc(header->GetCode()));
37
38 CodeInfo info = header->GetOptimizedCodeInfo();
39 CHECK(info.HasInlineInfo());
40}
41
42extern "C" JNIEXPORT void JNICALL Java_Main_ensureJittedAndPolymorphicInline(JNIEnv*, jclass cls) {
43 jit::Jit* jit = Runtime::Current()->GetJit();
44 if (jit == nullptr) {
45 return;
46 }
47
48 do_checks(cls, "testInvokeVirtual");
49 do_checks(cls, "testInvokeInterface");
50}
51
52} // namespace art