Chang Xing | 605fe24 | 2017-07-20 15:57:21 -0700 | [diff] [blame] | 1 | /* |
| 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 Juravle | 3378768 | 2019-07-26 14:27:18 -0700 | [diff] [blame] | 20 | #include "sdk_checker.h" |
Chang Xing | 605fe24 | 2017-07-20 15:57:21 -0700 | [diff] [blame] | 21 | #include "class_linker.h" |
| 22 | |
| 23 | namespace art { |
Vladimir Marko | 7ed2d38 | 2019-11-25 10:41:53 +0000 | [diff] [blame] | 24 | |
| 25 | namespace gc { |
| 26 | class Heap; |
| 27 | } // namespace gc |
| 28 | |
Chang Xing | 605fe24 | 2017-07-20 15:57:21 -0700 | [diff] [blame] | 29 | // AotClassLinker is only used for AOT compiler, which includes some logic for class initialization |
| 30 | // which will only be used in pre-compilation. |
| 31 | class AotClassLinker : public ClassLinker { |
| 32 | public: |
| 33 | explicit AotClassLinker(InternTable *intern_table); |
| 34 | ~AotClassLinker(); |
| 35 | |
Calin Juravle | 3378768 | 2019-07-26 14:27:18 -0700 | [diff] [blame] | 36 | static bool CanReferenceInBootImageExtension(ObjPtr<mirror::Class> klass, gc::Heap* heap) |
Vladimir Marko | 7ed2d38 | 2019-11-25 10:41:53 +0000 | [diff] [blame] | 37 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 38 | |
Calin Juravle | 3378768 | 2019-07-26 14:27:18 -0700 | [diff] [blame] | 39 | 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 Juravle | 2c2724c | 2021-01-14 19:54:23 -0800 | [diff] [blame] | 47 | void SetEnablePublicSdkChecks(bool enabled) override; |
Calin Juravle | 3378768 | 2019-07-26 14:27:18 -0700 | [diff] [blame] | 48 | |
Mathieu Chartier | 9e050df | 2017-08-09 10:05:47 -0700 | [diff] [blame] | 49 | 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 Geoffray | 5b0b2e1 | 2021-03-19 14:48:40 +0000 | [diff] [blame] | 53 | verifier::VerifierDeps* verifier_deps, |
Mathieu Chartier | 9e050df | 2017-08-09 10:05:47 -0700 | [diff] [blame] | 54 | Handle<mirror::Class> klass, |
| 55 | verifier::HardFailLogMode log_level, |
| 56 | std::string* error_msg) |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 57 | override |
Mathieu Chartier | 9e050df | 2017-08-09 10:05:47 -0700 | [diff] [blame] | 58 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 59 | |
Chang Xing | 0c2c222 | 2017-08-04 14:36:17 -0700 | [diff] [blame] | 60 | // 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 Xing | 605fe24 | 2017-07-20 15:57:21 -0700 | [diff] [blame] | 67 | bool InitializeClass(Thread *self, |
| 68 | Handle<mirror::Class> klass, |
| 69 | bool can_run_clinit, |
| 70 | bool can_init_parents) |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 71 | override |
Chang Xing | 605fe24 | 2017-07-20 15:57:21 -0700 | [diff] [blame] | 72 | REQUIRES_SHARED(Locks::mutator_lock_) |
| 73 | REQUIRES(!Locks::dex_lock_); |
Vladimir Marko | d1f7351 | 2020-04-02 10:50:35 +0100 | [diff] [blame] | 74 | |
Vladimir Marko | d1f7351 | 2020-04-02 10:50:35 +0100 | [diff] [blame] | 75 | private: |
Calin Juravle | 3378768 | 2019-07-26 14:27:18 -0700 | [diff] [blame] | 76 | std::unique_ptr<SdkChecker> sdk_checker_; |
Chang Xing | 605fe24 | 2017-07-20 15:57:21 -0700 | [diff] [blame] | 77 | }; |
Vladimir Marko | d1f7351 | 2020-04-02 10:50:35 +0100 | [diff] [blame] | 78 | |
Chang Xing | 605fe24 | 2017-07-20 15:57:21 -0700 | [diff] [blame] | 79 | } // namespace art |
| 80 | |
| 81 | #endif // ART_RUNTIME_AOT_CLASS_LINKER_H_ |