blob: 8346550c93ae9bb97a789b44dd733f77d15eee83 [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"
Mathieu Chartier8778c522016-10-04 19:06:30 -070024#include "obj_ptr-inl.h"
Ian Rogerse63db272014-07-15 15:36:11 -070025#include "read_barrier-inl.h"
26
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.
Vladimir Markofd36f1f2016-08-03 18:49:58 +010045 if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveRefsAndArgs)) {
46 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveRefsAndArgs);
47 } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveAllCalleeSaves)) {
48 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveAllCalleeSaves);
49 } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveRefsOnly)) {
50 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveRefsOnly);
Vladimir Marko952dbb12016-07-28 12:01:51 +010051 } else {
52 DCHECK_EQ(method, GetCalleeSaveMethodUnchecked(Runtime::kSaveEverything));
53 return GetCalleeSaveMethodFrameInfo(Runtime::kSaveEverything);
Vladimir Marko7624d252014-05-02 14:40:15 +010054 }
55}
56
Mathieu Chartiere401d142015-04-22 13:56:20 -070057inline ArtMethod* Runtime::GetResolutionMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070058 CHECK(HasResolutionMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070059 return resolution_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070060}
61
Mathieu Chartiere401d142015-04-22 13:56:20 -070062inline ArtMethod* Runtime::GetImtConflictMethod() {
Ian Rogerse63db272014-07-15 15:36:11 -070063 CHECK(HasImtConflictMethod());
Mathieu Chartiere401d142015-04-22 13:56:20 -070064 return imt_conflict_method_;
Ian Rogerse63db272014-07-15 15:36:11 -070065}
66
Mathieu Chartiere401d142015-04-22 13:56:20 -070067inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
68 CHECK(imt_unimplemented_method_ != nullptr);
69 return imt_unimplemented_method_;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070070}
71
Mathieu Chartiere401d142015-04-22 13:56:20 -070072inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070073 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogerse63db272014-07-15 15:36:11 -070074 DCHECK(HasCalleeSaveMethod(type));
Mathieu Chartiere401d142015-04-22 13:56:20 -070075 return GetCalleeSaveMethodUnchecked(type);
Ian Rogerse63db272014-07-15 15:36:11 -070076}
77
Mathieu Chartiere401d142015-04-22 13:56:20 -070078inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070079 REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartiere401d142015-04-22 13:56:20 -070080 return reinterpret_cast<ArtMethod*>(callee_save_methods_[type]);
Ian Rogerse63db272014-07-15 15:36:11 -070081}
82
Vladimir Marko7624d252014-05-02 14:40:15 +010083} // namespace art
84
85#endif // ART_RUNTIME_RUNTIME_INL_H_