blob: 4584351a6a28c9045ebb1216b570a28ce571ee2f [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"
Andreas Gampe8228cdf2017-05-30 15:03:54 -070023#include "base/callee_save_type.h"
Andreas Gampec15a2f42017-04-21 12:09:39 -070024#include "gc_root-inl.h"
Mathieu Chartier8778c522016-10-04 19:06:30 -070025#include "obj_ptr-inl.h"
Ian Rogerse63db272014-07-15 15:36:11 -070026
Vladimir Marko7624d252014-05-02 14:40:15 +010027namespace art {
28
Mathieu Chartier8778c522016-10-04 19:06:30 -070029inline bool Runtime::IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) {
Ian Rogersc0542af2014-09-03 16:16:56 -070030 return obj == GetClearedJniWeakGlobal();
31}
32
33inline mirror::Object* Runtime::GetClearedJniWeakGlobal() {
34 mirror::Object* obj = sentinel_.Read();
Hiroshi Yamauchi8a741172014-09-08 13:22:56 -070035 DCHECK(obj != nullptr);
Ian Rogersc0542af2014-09-03 16:16:56 -070036 return obj;
37}
38
Mathieu Chartiere401d142015-04-22 13:56:20 -070039inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) {
Vladimir Marko7624d252014-05-02 14:40:15 +010040 DCHECK(method != nullptr);
41 // Cannot be imt-conflict-method or resolution-method.
Mathieu Chartiere401d142015-04-22 13:56:20 -070042 DCHECK_NE(method, GetImtConflictMethod());
43 DCHECK_NE(method, GetResolutionMethod());
Vladimir Marko7624d252014-05-02 14:40:15 +010044 // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods.
Andreas Gampe8228cdf2017-05-30 15:03:54 -070045 if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveRefsAndArgs)) {
46 return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveRefsAndArgs);
47 } else if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveAllCalleeSaves)) {
48 return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveAllCalleeSaves);
49 } else if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveRefsOnly)) {
50 return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveRefsOnly);
Vladimir Marko952dbb12016-07-28 12:01:51 +010051 } else {
Mingyao Yang0a87a652017-04-12 13:43:15 -070052 DCHECK(method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverything) ||
53 method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverythingForClinit) ||
54 method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverythingForSuspendCheck));
Andreas Gampe8228cdf2017-05-30 15:03:54 -070055 return GetCalleeSaveMethodFrameInfo(CalleeSaveType::kSaveEverything);
Vladimir Marko7624d252014-05-02 14:40:15 +010056 }
57}
58
Mathieu Chartiere401d142015-04-22 13:56:20 -070059inline ArtMethod* Runtime::GetResolutionMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070060 CHECK(HasResolutionMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070061 return resolution_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070062}
63
Mathieu Chartiere401d142015-04-22 13:56:20 -070064inline ArtMethod* Runtime::GetImtConflictMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070065 CHECK(HasImtConflictMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070066 return imt_conflict_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070067}
68
Mathieu Chartiere401d142015-04-22 13:56:20 -070069inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
70 CHECK(imt_unimplemented_method_ != nullptr);
71 return imt_unimplemented_method_;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070072}
73
Mathieu Chartiere401d142015-04-22 13:56:20 -070074inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070075 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogerse63db272014-07-15 15:36:11 -070076 DCHECK(HasCalleeSaveMethod(type));
Mathieu Chartiere401d142015-04-22 13:56:20 -070077 return GetCalleeSaveMethodUnchecked(type);
Ian Rogerse63db272014-07-15 15:36:11 -070078}
79
Mathieu Chartiere401d142015-04-22 13:56:20 -070080inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070081 REQUIRES_SHARED(Locks::mutator_lock_) {
Andreas Gampe8228cdf2017-05-30 15:03:54 -070082 return reinterpret_cast<ArtMethod*>(callee_save_methods_[static_cast<size_t>(type)]);
Ian Rogerse63db272014-07-15 15:36:11 -070083}
84
Vladimir Marko7624d252014-05-02 14:40:15 +010085} // namespace art
86
87#endif // ART_RUNTIME_RUNTIME_INL_H_