• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_RT_CALL_SIGNATURE_H
17 #define ECMASCRIPT_COMPILER_RT_CALL_SIGNATURE_H
18 
19 #include "ecmascript/compiler/call_signature.h"
20 #include "ecmascript/stubs/runtime_stubs.h"
21 
22 namespace panda::ecmascript::kungfu {
23 class RuntimeStubCSigns {
24 public:
25     enum ID {
26 #define DEF_RUNTIME_STUB_ID(name) ID_##name,
27         RUNTIME_STUB_LIST(DEF_RUNTIME_STUB_ID)
28 #undef DEF_RUNTIME_STUB_ID
29         NUM_OF_STUBS
30     };
31 
32     enum NoGCStubID {
33 #define DEF_RUNTIME_STUB_ID(name) NOGCSTUB_ID_##name,
34         RUNTIME_ASM_STUB_LIST(DEF_RUNTIME_STUB_ID)
35         RUNTIME_STUB_WITHOUT_GC_LIST(DEF_RUNTIME_STUB_ID)
36 #undef DEF_RUNTIME_STUB_ID
37         NUM_OF_RTSTUBS_WITHOUT_GC
38     };
39 
40     static void Initialize();
41 
42     static void GetASMCSigns(std::vector<const CallSignature*>& callSigns);
43 
Get(size_t index)44     static const CallSignature *Get(size_t index)
45     {
46         ASSERT(index < NUM_OF_RTSTUBS_WITHOUT_GC);
47         return &callSigns_[index];
48     }
49 
GetRTName(int index)50     static std::string GetRTName(int index)
51     {
52         ASSERT(index < NUM_OF_STUBS);
53         switch (index) {
54 #define DEF_STUB_NAME(name) case ID_##name: { return std::string("RTStub_") + #name; }
55 RUNTIME_STUB_LIST(DEF_STUB_NAME)
56 #undef DEF_STUB_NAME
57             default:
58                 return "unknown";
59         }
60         return "unknown";
61     }
62 
63 private:
64     static CallSignature callSigns_[NUM_OF_RTSTUBS_WITHOUT_GC];
65 };
66 #define RTSTUB_ID(name) kungfu::RuntimeStubCSigns::ID_##name
67 } // namespace panda::ecmascript::kungfu
68 #endif  // ECMASCRIPT_COMPILER_RT_CALL_SIGNATURE_H