1 /** 2 * Copyright (c) 2021-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PANDA_VERIFICATION_PUBLIC_H_ 17 #define PANDA_VERIFICATION_PUBLIC_H_ 18 19 #include "runtime/include/mem/allocator.h" 20 #include "runtime/include/method.h" 21 #include "runtime/include/runtime_options.h" 22 #include <functional> 23 #include <string_view> 24 namespace ark { 25 class ClassLinker; 26 } // namespace ark 27 28 namespace ark::verifier { 29 30 /// @brief Verification mode 31 enum class VerificationMode { 32 DISABLED, // No verification 33 ON_THE_FLY, // Verify methods before they are executed (used by panda/ark executable) 34 AHEAD_OF_TIME, // Verify methods at startup (used by verifier executable) 35 DEBUG // Debug verification by enabling breakpoints (used by verifier executable) 36 }; 37 38 PANDA_PUBLIC_API bool IsEnabled(VerificationMode mode); 39 PANDA_PUBLIC_API VerificationMode VerificationModeFromString(const std::string &mode); 40 41 using Config = struct Config; // NOLINT(bugprone-forward-declaration-namespace) 42 43 Config *NewConfig(); 44 bool LoadConfigFile(Config *config, std::string_view configFileName); 45 void DestroyConfig(Config *config); 46 47 bool IsEnabled(Config const *config); 48 bool IsOnlyVerify(Config const *config); 49 50 using Service = struct Service; 51 52 Service *CreateService(Config const *config, ark::mem::InternalAllocatorPtr allocator, ClassLinker *linker, 53 std::string const &cacheFileName); 54 void DestroyService(Service *service, bool updateCacheFile); 55 56 Config const *GetServiceConfig(Service const *service); 57 58 enum class Status { OK, FAILED, UNKNOWN }; 59 60 PANDA_PUBLIC_API Status Verify(Service *service, ark::Method *method, VerificationMode mode); 61 62 } // namespace ark::verifier 63 64 #endif // PANDA_VERIFICATION_PUBLIC_H_ 65