2022-09-16 06:13:58 +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 <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
namespace CodeGen
|
|
|
|
{
|
|
|
|
|
2023-04-14 20:05:27 +08:00
|
|
|
// This value is used in 'finishFunction' to mark the function that spans to the end of the whole code block
|
|
|
|
static uint32_t kFullBlockFuncton = ~0u;
|
|
|
|
|
2022-09-16 06:13:58 +08:00
|
|
|
class UnwindBuilder
|
|
|
|
{
|
|
|
|
public:
|
2022-10-07 07:55:58 +08:00
|
|
|
virtual ~UnwindBuilder() = default;
|
|
|
|
|
|
|
|
virtual void setBeginOffset(size_t beginOffset) = 0;
|
|
|
|
virtual size_t getBeginOffset() const = 0;
|
2022-09-16 06:13:58 +08:00
|
|
|
|
2023-04-14 20:05:27 +08:00
|
|
|
virtual void startInfo() = 0;
|
2022-09-16 06:13:58 +08:00
|
|
|
|
2023-04-14 20:05:27 +08:00
|
|
|
virtual void startFunction() = 0;
|
2023-03-03 21:45:38 +08:00
|
|
|
virtual void spill(int espOffset, X64::RegisterX64 reg) = 0;
|
|
|
|
virtual void save(X64::RegisterX64 reg) = 0;
|
2022-09-16 06:13:58 +08:00
|
|
|
virtual void allocStack(int size) = 0;
|
2023-03-03 21:45:38 +08:00
|
|
|
virtual void setupFrameReg(X64::RegisterX64 reg, int espOffset) = 0;
|
2023-04-14 20:05:27 +08:00
|
|
|
virtual void finishFunction(uint32_t beginOffset, uint32_t endOffset) = 0;
|
2022-09-16 06:13:58 +08:00
|
|
|
|
2023-04-14 20:05:27 +08:00
|
|
|
virtual void finishInfo() = 0;
|
2022-09-16 06:13:58 +08:00
|
|
|
|
|
|
|
virtual size_t getSize() const = 0;
|
2023-04-14 20:05:27 +08:00
|
|
|
virtual size_t getFunctionCount() const = 0;
|
2022-09-16 06:13:58 +08:00
|
|
|
|
|
|
|
// This will place the unwinding data at the target address and might update values of some fields
|
2023-04-14 20:05:27 +08:00
|
|
|
virtual void finalize(char* target, size_t offset, void* funcAddress, size_t funcSize) const = 0;
|
2022-09-16 06:13:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace Luau
|