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