blob: 2eb0bf75a140811a04d8c5a022e2ec5164842ffe [file] [log] [blame]
Vladimir Marko7624d252014-05-02 14:40:15 +01001/*
2 * Copyright (C) 2014 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#ifndef ART_RUNTIME_RUNTIME_INL_H_
18#define ART_RUNTIME_RUNTIME_INL_H_
19
20#include "runtime.h"
21
Mathieu Chartiere401d142015-04-22 13:56:20 -070022#include "art_method.h"
Mathieu Chartier673ed3d2015-08-28 14:56:43 -070023#include "class_linker.h"
Ian Rogerse63db272014-07-15 15:36:11 -070024#include "read_barrier-inl.h"
25
Vladimir Marko7624d252014-05-02 14:40:15 +010026namespace art {
27
Ian Rogersc0542af2014-09-03 16:16:56 -070028inline bool Runtime::IsClearedJniWeakGlobal(mirror::Object* obj) {
29 return obj == GetClearedJniWeakGlobal();
30}
31
32inline mirror::Object* Runtime::GetClearedJniWeakGlobal() {
33 mirror::Object* obj = sentinel_.Read();
Hiroshi Yamauchi8a741172014-09-08 13:22:56 -070034 DCHECK(obj != nullptr);
Ian Rogersc0542af2014-09-03 16:16:56 -070035 return obj;
36}
37
Mathieu Chartiere401d142015-04-22 13:56:20 -070038inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) {
Vladimir Marko7624d252014-05-02 14:40:15 +010039 DCHECK(method != nullptr);
40 // Cannot be imt-conflict-method or resolution-method.
Mathieu Chartiere401d142015-04-22 13:56:20 -070041 DCHECK_NE(method, GetImtConflictMethod());
42 DCHECK_NE(method, GetResolutionMethod());
Vladimir Marko7624d252014-05-02 14:40:15 +010043 // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010044 if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveRefsAndArgs)) {
45 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveRefsAndArgs);
46 } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveAllCalleeSaves)) {
47 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveAllCalleeSaves);
48 } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveRefsOnly)) {
49 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveRefsOnly);
Vladimir Marko952dbb12016-07-28 12:01:51 +010050 } else {
51 DCHECK_EQ(method, GetCalleeSaveMethodUnchecked(Runtime::kSaveEverything));
52 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveEverything);
Vladimir Marko7624d252014-05-02 14:40:15 +010053 }
54}
55
Mathieu Chartiere401d142015-04-22 13:56:20 -070056inline ArtMethod* Runtime::GetResolutionMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070057 CHECK(HasResolutionMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070058 return resolution_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070059}
60
Mathieu Chartiere401d142015-04-22 13:56:20 -070061inline ArtMethod* Runtime::GetImtConflictMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070062 CHECK(HasImtConflictMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070063 return imt_conflict_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070064}
65
Mathieu Chartiere401d142015-04-22 13:56:20 -070066inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
67 CHECK(imt_unimplemented_method_ != nullptr);
68 return imt_unimplemented_method_;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070069}
70
Mathieu Chartiere401d142015-04-22 13:56:20 -070071inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070072 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogerse63db272014-07-15 15:36:11 -070073 DCHECK(HasCalleeSaveMethod(type));
Mathieu Chartiere401d142015-04-22 13:56:20 -070074 return GetCalleeSaveMethodUnchecked(type);
Ian Rogerse63db272014-07-15 15:36:11 -070075}
76
Mathieu Chartiere401d142015-04-22 13:56:20 -070077inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070078 REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartiere401d142015-04-22 13:56:20 -070079 return reinterpret_cast<ArtMethod*>(callee_save_methods_[type]);
Ian Rogerse63db272014-07-15 15:36:11 -070080}
81
Vladimir Marko7624d252014-05-02 14:40:15 +010082} // namespace art
83
84#endif // ART_RUNTIME_RUNTIME_INL_H_