blob: 68d5ad2f6e4b9c5313aeecad7d198c6c046263a7 [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"
Ian Rogerse63db272014-07-15 15:36:11 -070023#include "read_barrier-inl.h"
24
Vladimir Marko7624d252014-05-02 14:40:15 +010025namespace art {
26
Ian Rogersc0542af2014-09-03 16:16:56 -070027inline bool Runtime::IsClearedJniWeakGlobal(mirror::Object* obj) {
28 return obj == GetClearedJniWeakGlobal();
29}
30
31inline mirror::Object* Runtime::GetClearedJniWeakGlobal() {
32 mirror::Object* obj = sentinel_.Read();
Hiroshi Yamauchi8a741172014-09-08 13:22:56 -070033 DCHECK(obj != nullptr);
Ian Rogersc0542af2014-09-03 16:16:56 -070034 return obj;
35}
36
Mathieu Chartiere401d142015-04-22 13:56:20 -070037inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) {
Vladimir Marko7624d252014-05-02 14:40:15 +010038 DCHECK(method != nullptr);
39 // Cannot be imt-conflict-method or resolution-method.
Mathieu Chartiere401d142015-04-22 13:56:20 -070040 DCHECK_NE(method, GetImtConflictMethod());
41 DCHECK_NE(method, GetResolutionMethod());
Vladimir Marko7624d252014-05-02 14:40:15 +010042 // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods.
Hiroshi Yamauchiab088112014-07-14 13:00:14 -070043 if (method == GetCalleeSaveMethodUnchecked(Runtime::kRefsAndArgs)) {
Vladimir Marko7624d252014-05-02 14:40:15 +010044 return GetCalleeSaveMethodFrameInfo(Runtime::kRefsAndArgs);
Hiroshi Yamauchiab088112014-07-14 13:00:14 -070045 } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveAll)) {
Vladimir Marko7624d252014-05-02 14:40:15 +010046 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveAll);
47 } else {
Mathieu Chartiere401d142015-04-22 13:56:20 -070048 DCHECK_EQ(method, GetCalleeSaveMethodUnchecked(Runtime::kRefsOnly));
Vladimir Marko7624d252014-05-02 14:40:15 +010049 return GetCalleeSaveMethodFrameInfo(Runtime::kRefsOnly);
50 }
51}
52
Mathieu Chartiere401d142015-04-22 13:56:20 -070053inline ArtMethod* Runtime::GetResolutionMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070054 CHECK(HasResolutionMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070055 return resolution_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070056}
57
Mathieu Chartiere401d142015-04-22 13:56:20 -070058inline ArtMethod* Runtime::GetImtConflictMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070059 CHECK(HasImtConflictMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070060 return imt_conflict_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070061}
62
Mathieu Chartiere401d142015-04-22 13:56:20 -070063inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
64 CHECK(imt_unimplemented_method_ != nullptr);
65 return imt_unimplemented_method_;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070066}
67
Mathieu Chartiere401d142015-04-22 13:56:20 -070068inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
Ian Rogerse63db272014-07-15 15:36:11 -070069 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
70 DCHECK(HasCalleeSaveMethod(type));
Mathieu Chartiere401d142015-04-22 13:56:20 -070071 return GetCalleeSaveMethodUnchecked(type);
Ian Rogerse63db272014-07-15 15:36:11 -070072}
73
Mathieu Chartiere401d142015-04-22 13:56:20 -070074inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
Ian Rogerse63db272014-07-15 15:36:11 -070075 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Mathieu Chartiere401d142015-04-22 13:56:20 -070076 return reinterpret_cast<ArtMethod*>(callee_save_methods_[type]);
Ian Rogerse63db272014-07-15 15:36:11 -070077}
78
Vladimir Marko7624d252014-05-02 14:40:15 +010079} // namespace art
80
81#endif // ART_RUNTIME_RUNTIME_INL_H_