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 "art_method.h"
23#include "read_barrier-inl.h"
24
25namespace art {
26
27inline bool Runtime::IsClearedJniWeakGlobal(mirror::Object* obj) {
28  return obj == GetClearedJniWeakGlobal();
29}
30
31inline mirror::Object* Runtime::GetClearedJniWeakGlobal() {
32  mirror::Object* obj = sentinel_.Read();
33  DCHECK(obj != nullptr);
34  return obj;
35}
36
37inline QuickMethodFrameInfo Runtime::GetRuntimeMethodFrameInfo(ArtMethod* method) {
38  DCHECK(method != nullptr);
39  // Cannot be imt-conflict-method or resolution-method.
40  DCHECK_NE(method, GetImtConflictMethod());
41  DCHECK_NE(method, GetResolutionMethod());
42  // Don't use GetCalleeSaveMethod(), some tests don't set all callee save methods.
43  if (method == GetCalleeSaveMethodUnchecked(Runtime::kRefsAndArgs)) {
44    return GetCalleeSaveMethodFrameInfo(Runtime::kRefsAndArgs);
45  } else if (method == GetCalleeSaveMethodUnchecked(Runtime::kSaveAll)) {
46    return GetCalleeSaveMethodFrameInfo(Runtime::kSaveAll);
47  } else {
48    DCHECK_EQ(method, GetCalleeSaveMethodUnchecked(Runtime::kRefsOnly));
49    return GetCalleeSaveMethodFrameInfo(Runtime::kRefsOnly);
50  }
51}
52
53inline ArtMethod* Runtime::GetResolutionMethod() {
54  CHECK(HasResolutionMethod());
55  return resolution_method_;
56}
57
58inline ArtMethod* Runtime::GetImtConflictMethod() {
59  CHECK(HasImtConflictMethod());
60  return imt_conflict_method_;
61}
62
63inline ArtMethod* Runtime::GetImtUnimplementedMethod() {
64  CHECK(imt_unimplemented_method_ != nullptr);
65  return imt_unimplemented_method_;
66}
67
68inline ArtMethod* Runtime::GetCalleeSaveMethod(CalleeSaveType type)
69    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
70  DCHECK(HasCalleeSaveMethod(type));
71  return GetCalleeSaveMethodUnchecked(type);
72}
73
74inline ArtMethod* Runtime::GetCalleeSaveMethodUnchecked(CalleeSaveType type)
75    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
76  return reinterpret_cast<ArtMethod*>(callee_save_methods_[type]);
77}
78
79}  // namespace art
80
81#endif  // ART_RUNTIME_RUNTIME_INL_H_
82