2022-09-15 23:38:17 +01: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-14 19:06:22 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2022-09-15 23:38:17 +01:00
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
namespace CodeGen
|
|
|
|
{
|
|
|
|
|
2023-04-14 19:06:22 +01:00
|
|
|
struct UnwindFunctionDwarf2
|
|
|
|
{
|
|
|
|
uint32_t beginOffset;
|
|
|
|
uint32_t endOffset;
|
|
|
|
uint32_t fdeEntryStartPos;
|
|
|
|
};
|
|
|
|
|
2022-09-15 23:38:17 +01:00
|
|
|
class UnwindBuilderDwarf2 : public UnwindBuilder
|
|
|
|
{
|
|
|
|
public:
|
2022-10-07 01:23:29 +01:00
|
|
|
void setBeginOffset(size_t beginOffset) override;
|
|
|
|
size_t getBeginOffset() const override;
|
|
|
|
|
2023-04-14 19:06:22 +01:00
|
|
|
void startInfo() override;
|
2022-09-15 23:38:17 +01:00
|
|
|
|
2023-04-14 19:06:22 +01:00
|
|
|
void startFunction() override;
|
2023-03-03 20:21:14 +00:00
|
|
|
void spill(int espOffset, X64::RegisterX64 reg) override;
|
|
|
|
void save(X64::RegisterX64 reg) override;
|
2022-09-15 23:38:17 +01:00
|
|
|
void allocStack(int size) override;
|
2023-03-03 20:21:14 +00:00
|
|
|
void setupFrameReg(X64::RegisterX64 reg, int espOffset) override;
|
2023-04-14 19:06:22 +01:00
|
|
|
void finishFunction(uint32_t beginOffset, uint32_t endOffset) override;
|
2022-09-15 23:38:17 +01:00
|
|
|
|
2023-04-14 19:06:22 +01:00
|
|
|
void finishInfo() override;
|
2022-09-15 23:38:17 +01:00
|
|
|
|
|
|
|
size_t getSize() const override;
|
2023-04-14 19:06:22 +01:00
|
|
|
size_t getFunctionCount() const override;
|
2022-09-15 23:38:17 +01:00
|
|
|
|
2023-04-14 19:06:22 +01:00
|
|
|
void finalize(char* target, size_t offset, void* funcAddress, size_t funcSize) const override;
|
2022-09-15 23:38:17 +01:00
|
|
|
|
|
|
|
private:
|
2022-10-07 01:23:29 +01:00
|
|
|
size_t beginOffset = 0;
|
|
|
|
|
2023-04-14 19:06:22 +01:00
|
|
|
std::vector<UnwindFunctionDwarf2> unwindFunctions;
|
|
|
|
|
|
|
|
static const unsigned kRawDataLimit = 1024;
|
2022-09-23 20:17:25 +01:00
|
|
|
uint8_t rawData[kRawDataLimit];
|
|
|
|
uint8_t* pos = rawData;
|
2022-09-15 23:38:17 +01:00
|
|
|
|
|
|
|
uint32_t stackOffset = 0;
|
|
|
|
|
|
|
|
// We will remember the FDE location to write some of the fields like entry length, function start and size later
|
2022-09-23 20:17:25 +01:00
|
|
|
uint8_t* fdeEntryStart = nullptr;
|
2022-09-15 23:38:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace Luau
|