• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 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 #ifndef PLUGINS_ETS_RUNTIME_INTEGRATE_ETS_ANI_EXPO
16 #define PLUGINS_ETS_RUNTIME_INTEGRATE_ETS_ANI_EXPO
17 // NOLINTBEGIN
18 
19 #ifdef __cplusplus
20 #include <cstdarg>
21 #include <cstddef>
22 #include <cstdint>
23 #else
24 #include <stdarg.h>
25 #include <stddef.h>
26 #include <stdint.h>
27 #endif
28 #include <string>
29 #include <vector>
30 #include <ani.h>
31 
32 #include "libpandabase/macros.h"
33 
34 namespace ark::ets {
35 class PANDA_PUBLIC_API ETSAni {
36 public:
37     static constexpr std::string_view AOT_FILE_OPTION_PREFIX = "--ext:--aot-file=";
38     static constexpr std::string_view INTEROP_OPTION_PREFIX = "--ext:interop";
39     static constexpr std::string_view ENABLE_AN_OPTION = "--ext:--enable-an";
40     static void Prefork(ani_env *env);
41     static void Postfork(ani_env *env, const std::vector<ani_option> &options, bool postZygoteFork = true);
42 
43 private:
44     static void TryLoadAotFileForBoot();
45     static void LoadAotFileForApp(std::string const &aotFileName);
46     /**
47      * @brief Pre create exclusive worker for taskpool execution engine
48      * @return true if success, false if failed
49      */
50     static bool PreCreateExclusiveWorkerForTaskpool();
51 
52     /**
53      * @brief Destroy exclusive worker for taskpool execution engine in preFork
54      * @return true if success, false if failed
55      */
56     static bool DestroyExclusiveWorkerForTaskpoolIfExists();
57 
58     /**
59      * @brief Process taskpool worker in preFork and postFork
60      * @param preFork true if preFork, false if postFork
61      */
62     static void ProcessTaskpoolWorker(bool preFork);
63 };
64 }  // namespace ark::ets
65 #endif  // !PLUGINS_ETS_RUNTIME_INTEGRATE_ETS_ANI_EXPO
66