blob: a094e3a174b44c3d787dfd16e7bab88930ffa8ea [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
Vladimir Markod1f73512020-04-02 10:50:35 +010039 bool SetUpdatableBootClassPackages(const std::vector<std::string>& packages);
40
Calin Juravle33787682019-07-26 14:27:18 -070041 void SetSdkChecker(std::unique_ptr<SdkChecker>&& sdk_checker_);
42 const SdkChecker* GetSdkChecker() const;
43
44 bool DenyAccessBasedOnPublicSdk(ArtMethod* art_method ATTRIBUTE_UNUSED) const override
45 REQUIRES_SHARED(Locks::mutator_lock_);
46 bool DenyAccessBasedOnPublicSdk(ArtField* art_field ATTRIBUTE_UNUSED) const override
47 REQUIRES_SHARED(Locks::mutator_lock_);
48 bool DenyAccessBasedOnPublicSdk(const char* type_descriptor ATTRIBUTE_UNUSED) const override;
Calin Juravle2c2724c2021-01-14 19:54:23 -080049 void SetEnablePublicSdkChecks(bool enabled) override;
Calin Juravle33787682019-07-26 14:27:18 -070050
Mathieu Chartier9e050df2017-08-09 10:05:47 -070051 protected:
52 // Overridden version of PerformClassVerification allows skipping verification if the class was
53 // previously verified but unloaded.
54 verifier::FailureKind PerformClassVerification(Thread* self,
55 Handle<mirror::Class> klass,
56 verifier::HardFailLogMode log_level,
57 std::string* error_msg)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010058 override
Mathieu Chartier9e050df2017-08-09 10:05:47 -070059 REQUIRES_SHARED(Locks::mutator_lock_);
60
Chang Xing0c2c2222017-08-04 14:36:17 -070061 // Override AllocClass because aot compiler will need to perform a transaction check to determine
62 // can we allocate class from heap.
63 bool CanAllocClass()
64 override
65 REQUIRES_SHARED(Locks::mutator_lock_)
66 REQUIRES(!Roles::uninterruptible_);
67
Chang Xing605fe242017-07-20 15:57:21 -070068 bool InitializeClass(Thread *self,
69 Handle<mirror::Class> klass,
70 bool can_run_clinit,
71 bool can_init_parents)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010072 override
Chang Xing605fe242017-07-20 15:57:21 -070073 REQUIRES_SHARED(Locks::mutator_lock_)
74 REQUIRES(!Locks::dex_lock_);
Vladimir Markod1f73512020-04-02 10:50:35 +010075
76 bool IsUpdatableBootClassPathDescriptor(const char* descriptor) override;
77
78 private:
79 std::vector<std::string> updatable_boot_class_path_descriptor_prefixes_;
Calin Juravle33787682019-07-26 14:27:18 -070080
81 std::unique_ptr<SdkChecker> sdk_checker_;
Chang Xing605fe242017-07-20 15:57:21 -070082};
Vladimir Markod1f73512020-04-02 10:50:35 +010083
Chang Xing605fe242017-07-20 15:57:21 -070084} // namespace art
85
86#endif // ART_RUNTIME_AOT_CLASS_LINKER_H_