Files
ark_js_runtime/ecmascript/compiler/assembler_module.h
T
sunzhe23 941be6ea2a Generate asm code for AsmInterCallRuntime
issue: #I53761

Signed-off-by: sunzhe23 <sunzhe23@huawei.com>
2022-04-17 23:49:48 -07:00

92 lines
2.4 KiB
C++

/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ECMASCRIPT_COMPILER_ASSEMBLER_MODULE_H
#define ECMASCRIPT_COMPILER_ASSEMBLER_MODULE_H
#include <string>
#include <vector>
#include "assembler/assembler.h"
#include "ecmascript/compiler/call_signature.h"
#include "ecmascript/stubs/runtime_stubs.h"
namespace panda::ecmascript::kungfu {
class AssemblerModule {
public:
void Run(const std::string &triple, Chunk* chunk);
size_t GetFunctionCount() const
{
return offsetTable_.size();
}
size_t GetFunction(size_t index) const
{
return offsetTable_[index];
}
uint8_t* GetBuffer() const
{
return buffer_;
}
size_t GetBufferSize() const
{
return bufferSize_;
}
void SetUpForAsmStubs();
const std::vector<CallSignature*> &GetCSigns() const
{
return asmCallSigns_;
}
size_t GetCodeBufferOffset() const
{
return codeBufferOffset_;
}
void SetCodeBufferOffset(size_t offset)
{
codeBufferOffset_ = offset;
}
void GenerateStubsX64(Chunk* chunk);
private:
std::vector<CallSignature *> asmCallSigns_;
std::vector<size_t> offsetTable_;
size_t codeBufferOffset_ {0};
uint8_t* buffer_ {nullptr};
size_t bufferSize_ {0};
};
class AssemblerStub {
public:
virtual void Generate(Assembler* assembler) = 0;
virtual ~AssemblerStub() = default;
};
#define DECLARE_ASM_STUB_CLASS(name) \
class name##Stub : public AssemblerStub { \
public: \
~name##Stub() = default; \
void Generate(Assembler* assembler) override; \
}
RUNTIME_ASM_STUB_LIST(DECLARE_ASM_STUB_CLASS);
#undef DECLARE_ASM_STUB_CLASS
} // namespace panda::ecmascript::kunfu
#endif // ECMASCRIPT_COMPILER_ASSEMBLER_MODULE_H