• 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 #include "ecmascript/compiler/rt_call_signature.h"
17 
18 #include "ecmascript/compiler/call_signature.h"
19 #include "ecmascript/compiler/assembler_module.h"
20 #include "ecmascript/stubs/runtime_stubs.h"
21 
22 namespace panda::ecmascript::kungfu {
23 CallSignature RuntimeStubCSigns::callSigns_[RuntimeStubCSigns::NUM_OF_RTSTUBS_WITHOUT_GC];
24 
Initialize()25 void RuntimeStubCSigns::Initialize()
26 {
27 #define INIT_SIGNATURES(name)                                        \
28     name##CallSignature::Initialize(&callSigns_[ID_##name]);         \
29     callSigns_[ID_##name].SetName(std::string("RTStub_") + #name);   \
30     callSigns_[ID_##name].SetID(ID_##name);                          \
31     assert(callSigns_[ID_##name].IsRuntimeNGCStub() ||               \
32            callSigns_[ID_##name].IsRuntimeStub() ||                  \
33            callSigns_[ID_##name].IsDeoptStub()   ||                  \
34            callSigns_[ID_##name].IsRuntimeVAStub());
35 
36     RUNTIME_STUB_WITHOUT_GC_LIST(INIT_SIGNATURES)
37     RUNTIME_ASM_STUB_LIST(INIT_SIGNATURES)
38 #undef INIT_SIGNATURES
39 
40 #define INIT_ASM_SIGNATURES(name)                                                     \
41     callSigns_[RuntimeStubCSigns::ID_##name].SetName(std::string("RTStub_") + #name); \
42     callSigns_[RuntimeStubCSigns::ID_##name].SetConstructor(                          \
43         []([[maybe_unused]]void* arg) {                                               \
44             return static_cast<void*>(new name##Stub());                              \
45     });
46 
47     RUNTIME_ASM_STUB_LIST(INIT_ASM_SIGNATURES)
48 #undef INIT_ASM_SIGNATURES
49 }
50 
GetASMCSigns(std::vector<const CallSignature * > & outputCallSigns)51 void RuntimeStubCSigns::GetASMCSigns(std::vector<const CallSignature*>& outputCallSigns)
52 {
53 #define INIT_ASM_SIGNATURES(name) \
54     outputCallSigns.push_back(&callSigns_[RuntimeStubCSigns::ID_##name]);
55 
56     RUNTIME_ASM_STUB_LIST(INIT_ASM_SIGNATURES)
57 #undef INIT_ASM_SIGNATURES
58 }
59 } // namespace panda::ecmascript::kungfu
60