blob: 30a19c87d3d92a41cccf8176497afc1f9cb6cc14 [file] [log] [blame]
Chang Xing605fe242017-07-20 15:57:21 -07001/*
2 * Copyright (C) 2017 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_AOT_CLASS_LINKER_H_
18#define ART_RUNTIME_AOT_CLASS_LINKER_H_
19
Calin Juravle33787682019-07-26 14:27:18 -070020#include "sdk_checker.h"
Chang Xing605fe242017-07-20 15:57:21 -070021#include "class_linker.h"
22
23namespace art {
Vladimir Marko7ed2d382019-11-25 10:41:53 +000024
25namespace gc {
26class Heap;
27} // namespace gc
28
Chang Xing605fe242017-07-20 15:57:21 -070029// AotClassLinker is only used for AOT compiler, which includes some logic for class initialization
30// which will only be used in pre-compilation.
31class AotClassLinker : public ClassLinker {
32 public:
33 explicit AotClassLinker(InternTable *intern_table);
34 ~AotClassLinker();
35
Calin Juravle33787682019-07-26 14:27:18 -070036static bool CanReferenceInBootImageExtension(ObjPtr<mirror::Class> klass, gc::Heap* heap)
Vladimir Marko7ed2d382019-11-25 10:41:53 +000037 REQUIRES_SHARED(Locks::mutator_lock_);
38
Calin Juravle33787682019-07-26 14:27:18 -070039 void SetSdkChecker(std::unique_ptr<SdkChecker>&& sdk_checker_);
40 const SdkChecker* GetSdkChecker() const;
41
42 bool DenyAccessBasedOnPublicSdk(ArtMethod* art_method ATTRIBUTE_UNUSED) const override
43 REQUIRES_SHARED(Locks::mutator_lock_);
44 bool DenyAccessBasedOnPublicSdk(ArtField* art_field ATTRIBUTE_UNUSED) const override
45 REQUIRES_SHARED(Locks::mutator_lock_);
46 bool DenyAccessBasedOnPublicSdk(const char* type_descriptor ATTRIBUTE_UNUSED) const override;
Calin Juravle2c2724c2021-01-14 19:54:23 -080047 void SetEnablePublicSdkChecks(bool enabled) override;
Calin Juravle33787682019-07-26 14:27:18 -070048
Mathieu Chartier9e050df2017-08-09 10:05:47 -070049 protected:
50 // Overridden version of PerformClassVerification allows skipping verification if the class was
51 // previously verified but unloaded.
52 verifier::FailureKind PerformClassVerification(Thread* self,
Nicolas Geoffray5b0b2e12021-03-19 14:48:40 +000053 verifier::VerifierDeps* verifier_deps,
Mathieu Chartier9e050df2017-08-09 10:05:47 -070054 Handle<mirror::Class> klass,
55 verifier::HardFailLogMode log_level,
56 std::string* error_msg)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010057 override
Mathieu Chartier9e050df2017-08-09 10:05:47 -070058 REQUIRES_SHARED(Locks::mutator_lock_);
59
Chang Xing0c2c2222017-08-04 14:36:17 -070060 // Override AllocClass because aot compiler will need to perform a transaction check to determine
61 // can we allocate class from heap.
62 bool CanAllocClass()
63 override
64 REQUIRES_SHARED(Locks::mutator_lock_)
65 REQUIRES(!Roles::uninterruptible_);
66
Chang Xing605fe242017-07-20 15:57:21 -070067 bool InitializeClass(Thread *self,
68 Handle<mirror::Class> klass,
69 bool can_run_clinit,
70 bool can_init_parents)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010071 override
Chang Xing605fe242017-07-20 15:57:21 -070072 REQUIRES_SHARED(Locks::mutator_lock_)
73 REQUIRES(!Locks::dex_lock_);
Vladimir Markod1f73512020-04-02 10:50:35 +010074
Vladimir Markod1f73512020-04-02 10:50:35 +010075 private:
Calin Juravle33787682019-07-26 14:27:18 -070076 std::unique_ptr<SdkChecker> sdk_checker_;
Chang Xing605fe242017-07-20 15:57:21 -070077};
Vladimir Markod1f73512020-04-02 10:50:35 +010078
Chang Xing605fe242017-07-20 15:57:21 -070079} // namespace art
80
81#endif // ART_RUNTIME_AOT_CLASS_LINKER_H_