Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/CodeGen/include/Luau/UnwindBuilderDwarf2.h
2727 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#pragma once
3
4
#include "Luau/RegisterX64.h"
5
#include "UnwindBuilder.h"
6
7
#include <vector>
8
9
namespace Luau
10
{
11
namespace CodeGen
12
{
13
14
struct UnwindFunctionDwarf2
15
{
16
uint32_t beginOffset;
17
uint32_t endOffset;
18
uint32_t fdeEntryStartPos;
19
};
20
21
class UnwindBuilderDwarf2 : public UnwindBuilder
22
{
23
public:
24
void setBeginOffset(size_t beginOffset) override;
25
size_t getBeginOffset() const override;
26
27
void startInfo(Arch arch) override;
28
void startFunction() override;
29
void finishFunction(uint32_t beginOffset, uint32_t endOffset) override;
30
void finishInfo() override;
31
32
void prologueA64(uint32_t prologueSize, uint32_t stackSize, std::initializer_list<A64::RegisterA64> regs) override;
33
void prologueX64(
34
uint32_t prologueSize,
35
uint32_t stackSize,
36
bool setupFrame,
37
std::initializer_list<X64::RegisterX64> gpr,
38
const std::vector<X64::RegisterX64>& simd
39
) override;
40
41
size_t getUnwindInfoSize(size_t blockSize = 0) const override;
42
43
size_t finalize(char* target, size_t offset, void* funcAddress, size_t blockSize) const override;
44
45
private:
46
size_t beginOffset = 0;
47
48
std::vector<UnwindFunctionDwarf2> unwindFunctions;
49
50
static const unsigned kRawDataLimit = 1024;
51
uint8_t rawData[kRawDataLimit];
52
uint8_t* pos = rawData;
53
54
// We will remember the FDE location to write some of the fields like entry length, function start and size later
55
uint8_t* fdeEntryStart = nullptr;
56
};
57
58
} // namespace CodeGen
59
} // namespace Luau
60
61