blob: c045e841ba856445408296fd1898dd7c6afe88aa [file] [log] [blame]
Ian Rogers57b86d42012-03-27 16:05:41 -07001/*
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
Mathieu Chartiere401d142015-04-22 13:56:20 -070017#include "art_method-inl.h"
Ian Rogers57b86d42012-03-27 16:05:41 -070018#include "callee_save_frame.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070019#include "entrypoints/entrypoint_utils-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080020#include "class_linker-inl.h"
Ian Rogersfa46d3e2013-05-15 00:16:04 -070021#include "dex_file-inl.h"
Ian Rogers7655f292013-07-29 11:07:13 -070022#include "gc/accounting/card_table-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080023#include "mirror/object_array-inl.h"
Ian Rogers4f6ad8a2013-03-18 15:27:28 -070024#include "mirror/object-inl.h"
Ian Rogers57b86d42012-03-27 16:05:41 -070025
26namespace art {
27
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +010028extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx, Thread* self)
Mathieu Chartier90443472015-07-16 20:32:27 -070029 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogerse2645d32012-04-11 14:42:42 -070030 // Called to ensure static storage base is initialized for direct static field reads and writes.
31 // A class may be accessing another class' fields when it doesn't have access, as access has been
32 // given by inheritance.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070033 ScopedQuickEntrypointChecks sqec(self);
Vladimir Markofd36f1f2016-08-03 18:49:58 +010034 auto* caller = GetCalleeSaveMethodCaller(self, Runtime::kSaveRefsOnly);
Vladimir Marko5ea536a2015-04-20 20:11:30 +010035 return ResolveVerifyAndClinit(type_idx, caller, self, true, false);
Ian Rogers57b86d42012-03-27 16:05:41 -070036}
37
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +010038extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, Thread* self)
Mathieu Chartier90443472015-07-16 20:32:27 -070039 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogerse2645d32012-04-11 14:42:42 -070040 // Called when method->dex_cache_resolved_types_[] misses.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070041 ScopedQuickEntrypointChecks sqec(self);
Vladimir Markofd36f1f2016-08-03 18:49:58 +010042 auto* caller = GetCalleeSaveMethodCaller(self, Runtime::kSaveRefsOnly);
Vladimir Marko5ea536a2015-04-20 20:11:30 +010043 return ResolveVerifyAndClinit(type_idx, caller, self, false, false);
Ian Rogers57b86d42012-03-27 16:05:41 -070044}
45
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +010046extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx, Thread* self)
Mathieu Chartier90443472015-07-16 20:32:27 -070047 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogers57b86d42012-03-27 16:05:41 -070048 // Called when caller isn't guaranteed to have access to a type and the dex cache may be
Ian Rogerse2645d32012-04-11 14:42:42 -070049 // unpopulated.
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070050 ScopedQuickEntrypointChecks sqec(self);
Vladimir Markofd36f1f2016-08-03 18:49:58 +010051 auto* caller = GetCalleeSaveMethodCaller(self, Runtime::kSaveRefsOnly);
Vladimir Marko5ea536a2015-04-20 20:11:30 +010052 return ResolveVerifyAndClinit(type_idx, caller, self, false, true);
Ian Rogers57b86d42012-03-27 16:05:41 -070053}
54
Nicolas Geoffray7ea6a172015-05-19 18:58:54 +010055extern "C" mirror::String* artResolveStringFromCode(int32_t string_idx, Thread* self)
Mathieu Chartier90443472015-07-16 20:32:27 -070056 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -070057 ScopedQuickEntrypointChecks sqec(self);
Vladimir Markofd36f1f2016-08-03 18:49:58 +010058 auto* caller = GetCalleeSaveMethodCaller(self, Runtime::kSaveRefsOnly);
Vladimir Marko5ea536a2015-04-20 20:11:30 +010059 return ResolveStringFromCode(caller, string_idx);
Ian Rogers57b86d42012-03-27 16:05:41 -070060}
61
62} // namespace art