• 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_COMPILER_AOT_COMPILATION_ENV_H
17 #define ECMASCRIPT_COMPILER_AOT_COMPILATION_ENV_H
18 
19 #include "ecmascript/compiler/compilation_env.h"
20 
21 namespace panda::ecmascript {
22 class AOTCompilationEnv final : public CompilationEnv {
23 public:
24     PUBLIC_API AOTCompilationEnv(EcmaVM *vm);
25     ~AOTCompilationEnv() = default;
IsAotCompiler()26     bool IsAotCompiler() const override
27     {
28         return true;
29     }
30 
SupportHeapConstant()31     bool SupportHeapConstant() const override
32     {
33         return false;
34     }
35 
SupportIntrinsic()36     bool SupportIntrinsic() const override
37     {
38         return false;
39     }
40 
SupportNonExistIC()41     bool SupportNonExistIC() const override
42     {
43         return false;
44     }
45 
GetDependencies()46     kungfu::LazyDeoptAllDependencies *GetDependencies() const override
47     {
48         LOG_FULL(FATAL) << "Aot should not get dependencies";
49         UNREACHABLE();
50     }
51 
GetHostThread()52     JSThread *GetHostThread() const override
53     {
54         return thread_;
55     }
56 
57     JSRuntimeOptions &GetJSOptions() const override;
58 
59     // thread
60     GlobalEnvField GetArrayHClassIndex(ElementsKind kind, bool isProtoType) const override;
61     const BuiltinHClassEntries &GetBuiltinHClassEntries() const override;
62     JSHClass *GetBuiltinPrototypeHClass(BuiltinTypeId type) const override;
63 
64     // context
65     JSTaggedValue FindConstpool(const JSPandaFile *jsPandaFile, panda_file::File::EntityId id) const override;
66     JSTaggedValue FindConstpool(const JSPandaFile *jsPandaFile, int32_t index) const override;
67     JSTaggedValue FindOrCreateUnsharedConstpool(const uint32_t methodOffset) const override;
68     JSTaggedValue FindOrCreateUnsharedConstpool(JSTaggedValue sharedConstpool) const override;
69     JSHandle<ConstantPool> FindOrCreateConstPool(const JSPandaFile *jsPandaFile,
70         panda_file::File::EntityId id) override;
71     JSTaggedValue GetConstantPoolByMethodOffset(const uint32_t methodOffset) const override;
72 
73     // ConstantPool
74     JSTaggedValue GetArrayLiteralFromCache(JSTaggedValue constpool, uint32_t index, CString entry) const override;
75     JSTaggedValue GetObjectLiteralFromCache(JSTaggedValue constpool, uint32_t index, CString entry) const override;
76     JSTaggedValue GetMethodFromCache(JSTaggedValue constpool, uint32_t index) const override;
77     panda_file::File::EntityId GetIdFromCache(JSTaggedValue constpool, uint32_t index) const override;
78 
79     // GlobalEnv
80     JSHandle<GlobalEnv> GetGlobalEnv() const override;
81 
82     // GlobalConstants
83     const GlobalEnvConstants *GlobalConstants() const override;
84 
85     JSTaggedValue GetStringFromConstantPool(const uint32_t methodOffset, const uint16_t cpIdx,
86         bool allowAlloc = true) const override;
87 
88     JSHandle<JSTaggedValue> NewJSHandle(JSTaggedValue value) const override;
89 };
90 } // namespace panda::ecmascript
91 #endif  // ECMASCRIPT_COMPILER_AOT_COMPILATION_ENV_H
92