blob: bfa8c549bfe311dc188685b2989bcef27599e499 [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.
Hiroshi Yamauchiab088112014-07-14 13:00:14 -070044 if (method == GetCalleeSaveMethodUnchecked(Runtime::kRefsAndArgs)) {
Vladimir Marko7624d252014-05-02 14:40:15 +010045 return GetCalleeSaveMethodFrameInfo(Runtime::kRefsAndArgs);
Hiroshi Yamauchiab088112014-07-14 13:00:14 -070046 } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveAll)) {
Vladimir Marko7624d252014-05-02 14:40:15 +010047 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveAll);
48 } else {
Mathieu Chartiere401d142015-04-22 13:56:20 -070049 DCHECK_EQ(method, GetCalleeSaveMethodUnchecked(Runtime::kRefsOnly));
Vladimir Marko7624d252014-05-02 14:40:15 +010050 return GetCalleeSaveMethodFrameInfo(Runtime::kRefsOnly);
51 }
52}
53
Mathieu Chartiere401d142015-04-22 13:56:20 -070054inline ArtMethod* Runtime::GetResolutionMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070055 CHECK(HasResolutionMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070056 return resolution_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070057}
58
Mathieu Chartiere401d142015-04-22 13:56:20 -070059inline ArtMethod* Runtime::GetImtConflictMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070060 CHECK(HasImtConflictMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070061 return imt_conflict_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070062}
63
Mathieu Chartiere401d142015-04-22 13:56:20 -070064inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
65 CHECK(imt_unimplemented_method_ != nullptr);
66 return imt_unimplemented_method_;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070067}
68
Mathieu Chartiere401d142015-04-22 13:56:20 -070069inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
Mathieu Chartier90443472015-07-16 20:32:27 -070070 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogerse63db272014-07-15 15:36:11 -070071 DCHECK(HasCalleeSaveMethod(type));
Mathieu Chartiere401d142015-04-22 13:56:20 -070072 return GetCalleeSaveMethodUnchecked(type);
Ian Rogerse63db272014-07-15 15:36:11 -070073}
74
Mathieu Chartiere401d142015-04-22 13:56:20 -070075inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
Mathieu Chartier90443472015-07-16 20:32:27 -070076 SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartiere401d142015-04-22 13:56:20 -070077 return reinterpret_cast<ArtMethod*>(callee_save_methods_[type]);
Ian Rogerse63db272014-07-15 15:36:11 -070078}
79
Vladimir Marko7624d252014-05-02 14:40:15 +010080} // namespace art
81
82#endif // ART_RUNTIME_RUNTIME_INL_H_