• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 ECMASCRIPT_PLATFORM_AOT_RUNTIME_INFO_H
17 #define ECMASCRIPT_PLATFORM_AOT_RUNTIME_INFO_H
18 
19 #include <signal.h>
20 #include <string>
21 
22 #include "ecmascript/compiler/aot_compiler_preprocessor.h"
23 #include "ecmascript/compiler/aot_file/an_file_data_manager.h"
24 #include "ecmascript/dfx/stackinfo/js_stackinfo.h"
25 #include "ecmascript/ohos/ohos_pkg_args.h"
26 #include "ecmascript/ecma_vm.h"
27 #include "llvm/BinaryFormat/ELF.h"
28 
29 namespace panda::ecmascript {
30 #ifdef JIT_ESCAPE_ENABLE
31 void GetSignalHandler(int signal, siginfo_t *info, void *context);
32 void SignalReg(int signo);
33 #endif
34 void SignalAllReg();
35 
36 using AotCompilerPreprocessor = kungfu::AotCompilerPreprocessor;
37 class AotCrashInfo {
38 constexpr static const char *const AOT_ESCAPE_DISABLE = "ark.aot.escape.disable";
39 constexpr static int AOT_CRASH_COUNT = 1;
40 constexpr static int OTHERS_CRASH_COUNT = 3;
41 constexpr static int JIT_CRASH_COUNT = 1;
42 constexpr static int JS_CRASH_COUNT = 3;
43 constexpr static int OPT_CODE_CRASH_THRESHOLD = 1;
44 public:
45     explicit AotCrashInfo() = default;
46     virtual ~AotCrashInfo() = default;
47 
GetInstance()48     static AotCrashInfo &GetInstance()
49     {
50         static AotCrashInfo singleAotCrashInfo;
51         return singleAotCrashInfo;
52     }
53 
54     bool IsAotEscapedOrNotInEnableList(EcmaVM *vm, const std::string &bundleName) const;
55     void SetOptionPGOProfiler(JSRuntimeOptions *options, const std::string &bundleName) const;
56     bool PUBLIC_API IsAotEscapedOrCompiledOnce(AotCompilerPreprocessor &cPreprocessor, int32_t &ret) const;
57     static bool PUBLIC_API IsAotEscaped(const std::string &pgoRealPath = "");
58     static bool IsJitEscape();
59     static bool GetAotEscapeDisable();
60     static std::string GetSandBoxPath();
61     static int GetAotCrashCount();
62     static int GetJitCrashCount();
63     static int GetJsCrashCount();
64     static int GetOthersCrashCount();
65 };
66 } // namespace panda::ecmascript
67 #endif  // ECMASCRIPT_PLATFORM_AOT_RUNTIME_INFO_H
68