• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
22 #include "arch/instruction_set.h"
23 #include "art_method.h"
24 #include "base/callee_save_type.h"
25 #include "base/casts.h"
26 #include "base/mutex.h"
27 #include "entrypoints/quick/callee_save_frame.h"
28 #include "gc_root-inl.h"
29 #include "obj_ptr-inl.h"
30 #include "thread_list.h"
31 
32 namespace art {
33 
IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj)34 inline bool Runtime::IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) {
35   return obj == GetClearedJniWeakGlobal();
36 }
37 
GetClearedJniWeakGlobal()38 inline mirror::Object* Runtime::GetClearedJniWeakGlobal() {
39   mirror::Object* obj = sentinel_.Read();
40   DCHECK(obj != nullptr);
41   return obj;
42 }
43 
GetRuntimeMethodFrameInfo(ArtMethod * method)44 inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) {
45   DCHECK(method != nullptr);
46   DCHECK_EQ(instruction_set_, kRuntimeISA);
47   // Cannot be imt-conflict-method or resolution-method.
48   DCHECK_NE(method, GetImtConflictMethod());
49   DCHECK_NE(method, GetResolutionMethod());
50   // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods.
51   if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveRefsAndArgs)) {
52     return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveRefsAndArgs);
53   } else if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveAllCalleeSaves)) {
54     return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveAllCalleeSaves);
55   } else if (method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveRefsOnly)) {
56     return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveRefsOnly);
57   } else {
58     DCHECK(method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverything) ||
59            method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverythingForClinit) ||
60            method == GetCalleeSaveMethodUnchecked(CalleeSaveType::kSaveEverythingForSuspendCheck));
61     return RuntimeCalleeSaveFrame::GetMethodFrameInfo(CalleeSaveType::kSaveEverything);
62   }
63 }
64 
GetResolutionMethod()65 inline ArtMethod* Runtime::GetResolutionMethod() {
66   CHECK(HasResolutionMethod());
67   return resolution_method_;
68 }
69 
GetImtConflictMethod()70 inline ArtMethod* Runtime::GetImtConflictMethod() {
71   CHECK(HasImtConflictMethod());
72   return imt_conflict_method_;
73 }
74 
GetImtUnimplementedMethod()75 inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
76   CHECK(imt_unimplemented_method_ != nullptr);
77   return imt_unimplemented_method_;
78 }
79 
GetCalleeSaveMethod(CalleeSaveType type)80 inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
81     REQUIRES_SHARED(Locks::mutator_lock_) {
82   DCHECK(HasCalleeSaveMethod(type));
83   return GetCalleeSaveMethodUnchecked(type);
84 }
85 
GetCalleeSaveMethodUnchecked(CalleeSaveType type)86 inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
87     REQUIRES_SHARED(Locks::mutator_lock_) {
88   return reinterpret_cast64<ArtMethod*>(callee_save_methods_[static_cast<size_t>(type)]);
89 }
90 
91 }  // namespace art
92 
93 #endif  // ART_RUNTIME_RUNTIME_INL_H_
94