1/*
2 * Copyright (C) 2012 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#include "callee_save_frame.h"
18#include "entrypoints/entrypoint_utils-inl.h"
19#include "class_linker-inl.h"
20#include "dex_file-inl.h"
21#include "gc/accounting/card_table-inl.h"
22#include "mirror/art_method-inl.h"
23#include "mirror/object_array-inl.h"
24#include "mirror/object-inl.h"
25
26namespace art {
27
28extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx,
29                                                             mirror::ArtMethod* referrer,
30                                                             Thread* self,
31                                                             StackReference<mirror::ArtMethod>* sp)
32    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
33  // Called to ensure static storage base is initialized for direct static field reads and writes.
34  // A class may be accessing another class' fields when it doesn't have access, as access has been
35  // given by inheritance.
36  FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
37  return ResolveVerifyAndClinit(type_idx, referrer, self, true, false);
38}
39
40extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx,
41                                                    mirror::ArtMethod* referrer,
42                                                    Thread* self,
43                                                    StackReference<mirror::ArtMethod>* sp)
44    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
45  // Called when method->dex_cache_resolved_types_[] misses.
46  FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
47  return ResolveVerifyAndClinit(type_idx, referrer, self, false, false);
48}
49
50extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx,
51    mirror::ArtMethod* referrer,
52    Thread* self,
53    StackReference<mirror::ArtMethod>* sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
54  // Called when caller isn't guaranteed to have access to a type and the dex cache may be
55  // unpopulated.
56  FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
57  return ResolveVerifyAndClinit(type_idx, referrer, self, false, true);
58}
59
60extern "C" mirror::String* artResolveStringFromCode(mirror::ArtMethod* referrer,
61                                                    int32_t string_idx,
62                                                    Thread* self,
63                                                    StackReference<mirror::ArtMethod>* sp)
64    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
65  FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
66  return ResolveStringFromCode(referrer, string_idx);
67}
68
69}  // namespace art
70