blob: 0daa7769ed14f9e797d8185c54c567222285eee1 [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
Vladimir Markod3083dd2018-05-17 08:43:47 +010022#include "arch/instruction_set.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070023#include "art_method.h"
Andreas Gampe8228cdf2017-05-30 15:03:54 -070024#include "base/callee_save_type.h"
Vladimir Marko78baed52018-10-11 10:44:58 +010025#include "base/casts.h"
Andreas Gampe44f67602018-11-28 08:27:27 -080026#include "base/mutex.h"
Vladimir Markod3083dd2018-05-17 08:43:47 +010027#include "entrypoints/quick/callee_save_frame.h"
Andreas Gampec15a2f42017-04-21 12:09:39 -070028#include "gc_root-inl.h"
Mathieu Chartier8778c522016-10-04 19:06:30 -070029#include "obj_ptr-inl.h"
David Srbecky28f6cff2018-10-16 15:07:28 +010030#include "thread_list.h"
Ian Rogerse63db272014-07-15 15:36:11 -070031
Vladimir Marko7624d252014-05-02 14:40:15 +010032namespace art {
33
Mathieu Chartier8778c522016-10-04 19:06:30 -070034inline bool Runtime::IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) {
Ian Rogersc0542af2014-09-03 16:16:56 -070035 return obj == GetClearedJniWeakGlobal();
36}
37
38inline mirror::Object* Runtime::GetClearedJniWeakGlobal() {
39 mirror::Object* obj = sentinel_.Read();
Hiroshi Yamauchi8a741172014-09-08 13:22:56 -070040 DCHECK(obj != nullptr);
Ian Rogersc0542af2014-09-03 16:16:56 -070041 return obj;
42}
43
Mathieu Chartiere401d142015-04-22 13:56:20 -070044inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) {
Vladimir Marko7624d252014-05-02 14:40:15 +010045 DCHECK(method != nullptr);
Vladimir Markod3083dd2018-05-17 08:43:47 +010046 DCHECK_EQ(instruction_set_, kRuntimeISA);
Vladimir Marko7624d252014-05-02 14:40:15 +010047 // Cannot be imt-conflict-method or resolution-method.
Mathieu Chartiere401d142015-04-22 13:56:20 -070048 DCHECK_NE(method, GetImtConflictMethod());
49 DCHECK_NE(method, GetResolutionMethod());
Vladimir Marko7624d252014-05-02 14:40:15 +010050 // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods.
Andreas Gampe8228cdf2017-05-30 15:03:54 -070051 if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveRefsAndArgs)) {
Vladimir Markod3083dd2018-05-17 08:43:47 +010052 return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveRefsAndArgs);
Andreas Gampe8228cdf2017-05-30 15:03:54 -070053 } else if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveAllCalleeSaves)) {
Vladimir Markod3083dd2018-05-17 08:43:47 +010054 return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveAllCalleeSaves);
Andreas Gampe8228cdf2017-05-30 15:03:54 -070055 } else if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveRefsOnly)) {
Vladimir Markod3083dd2018-05-17 08:43:47 +010056 return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveRefsOnly);
Vladimir Marko952dbb12016-07-28 12:01:51 +010057 } else {
Mingyao Yang0a87a652017-04-12 13:43:15 -070058 DCHECK(method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverything) ||
59 method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverythingForClinit) ||
60 method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverythingForSuspendCheck));
Vladimir Markod3083dd2018-05-17 08:43:47 +010061 return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveEverything);
Vladimir Marko7624d252014-05-02 14:40:15 +010062 }
63}
64
Mathieu Chartiere401d142015-04-22 13:56:20 -070065inline ArtMethod* Runtime::GetResolutionMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070066 CHECK(HasResolutionMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070067 return resolution_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070068}
69
Mathieu Chartiere401d142015-04-22 13:56:20 -070070inline ArtMethod* Runtime::GetImtConflictMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070071 CHECK(HasImtConflictMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070072 return imt_conflict_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070073}
74
Mathieu Chartiere401d142015-04-22 13:56:20 -070075inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
76 CHECK(imt_unimplemented_method_ != nullptr);
77 return imt_unimplemented_method_;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070078}
79
Mathieu Chartiere401d142015-04-22 13:56:20 -070080inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070081 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogerse63db272014-07-15 15:36:11 -070082 DCHECK(HasCalleeSaveMethod(type));
Mathieu Chartiere401d142015-04-22 13:56:20 -070083 return GetCalleeSaveMethodUnchecked(type);
Ian Rogerse63db272014-07-15 15:36:11 -070084}
85
Mathieu Chartiere401d142015-04-22 13:56:20 -070086inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070087 REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko78baed52018-10-11 10:44:58 +010088 return reinterpret_cast64<ArtMethod*>(callee_save_methods_[static_cast<size_t>(type)]);
Ian Rogerse63db272014-07-15 15:36:11 -070089}
90
Vladimir Marko7624d252014-05-02 14:40:15 +010091} // namespace art
92
93#endif // ART_RUNTIME_RUNTIME_INL_H_