2022-09-16 06:38:17 +08:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Luau/RegisterX64.h"
|
|
|
|
#include "UnwindBuilder.h"
|
|
|
|
|
2023-04-15 02:06:22 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2022-09-16 06:38:17 +08:00
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
namespace CodeGen
|
|
|
|
{
|
|
|
|
|
2023-04-15 02:06:22 +08:00
|
|
|
struct UnwindFunctionDwarf2
|
|
|
|
{
|
|
|
|
uint32_t beginOffset;
|
|
|
|
uint32_t endOffset;
|
|
|
|
uint32_t fdeEntryStartPos;
|
|
|
|
};
|
|
|
|
|
2022-09-16 06:38:17 +08:00
|
|
|
class UnwindBuilderDwarf2 : public UnwindBuilder
|
|
|
|
{
|
|
|
|
public:
|
2022-10-07 08:23:29 +08:00
|
|
|
void setBeginOffset(size_t beginOffset) override;
|
|
|
|
size_t getBeginOffset() const override;
|
|
|
|
|
2023-05-06 05:52:49 +08:00
|
|
|
void startInfo(Arch arch) override;
|
2023-04-15 02:06:22 +08:00
|
|
|
void startFunction() override;
|
|
|
|
void finishFunction(uint32_t beginOffset, uint32_t endOffset) override;
|
|
|
|
void finishInfo() override;
|
2022-09-16 06:38:17 +08:00
|
|
|
|
2023-05-06 05:52:49 +08:00
|
|
|
void prologueA64(uint32_t prologueSize, uint32_t stackSize, std::initializer_list<A64::RegisterA64> regs) override;
|
2024-08-02 22:30:04 +08:00
|
|
|
void prologueX64(
|
|
|
|
uint32_t prologueSize,
|
|
|
|
uint32_t stackSize,
|
|
|
|
bool setupFrame,
|
|
|
|
std::initializer_list<X64::RegisterX64> gpr,
|
|
|
|
const std::vector<X64::RegisterX64>& simd
|
|
|
|
) override;
|
2023-05-06 05:52:49 +08:00
|
|
|
|
2024-05-27 01:09:09 +08:00
|
|
|
size_t getUnwindInfoSize(size_t blockSize = 0) const override;
|
2022-09-16 06:38:17 +08:00
|
|
|
|
2024-05-27 01:09:09 +08:00
|
|
|
size_t finalize(char* target, size_t offset, void* funcAddress, size_t blockSize) const override;
|
2022-09-16 06:38:17 +08:00
|
|
|
|
|
|
|
private:
|
2022-10-07 08:23:29 +08:00
|
|
|
size_t beginOffset = 0;
|
|
|
|
|
2023-04-15 02:06:22 +08:00
|
|
|
std::vector<UnwindFunctionDwarf2> unwindFunctions;
|
|
|
|
|
|
|
|
static const unsigned kRawDataLimit = 1024;
|
2022-09-24 03:17:25 +08:00
|
|
|
uint8_t rawData[kRawDataLimit];
|
|
|
|
uint8_t* pos = rawData;
|
2022-09-16 06:38:17 +08:00
|
|
|
|
|
|
|
// We will remember the FDE location to write some of the fields like entry length, function start and size later
|
2022-09-24 03:17:25 +08:00
|
|
|
uint8_t* fdeEntryStart = nullptr;
|
2022-09-16 06:38:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace Luau
|