mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 05:20:38 +00:00
d141a5c48d
* Fixed exported types not being suggested in autocomplete * `T...` is now convertible to `...any` (Fixes https://github.com/Roblox/luau/issues/767) * Fixed issue with `T?` not being convertible to `T | T` or `T?` (sometimes when internal pointer identity is different) * Fixed potential crash in missing table key error suggestion to use a similar existing key * `lua_topointer` now returns a pointer for strings C++ API Changes: * `prepareModuleScope` callback has moved from TypeChecker to Frontend * For LSPs, AstQuery functions (and `isWithinComment`) can be used without full Frontend data A lot of changes in our two experimental components as well. In our work on the new type-solver, the following issues were fixed: * Fixed table union and intersection indexing * Correct custom type environments are now used * Fixed issue with values of `free & number` type not accepted in numeric operations And these are the changes in native code generation (JIT): * arm64 lowering is almost complete with support for 99% of IR commands and all fastcalls * Fixed x64 assembly encoding for extended byte registers * More external x64 calls are aware of register allocator * `math.min`/`math.max` with more than 2 arguments are now lowered to IR as well * Fixed correctness issues with `math` library calls with multiple results in variadic context and with x64 register conflicts * x64 register allocator learnt to restore values from VM memory instead of always using stack spills * x64 exception unwind information now supports multiple functions and fixes function start offset in Dwarf2 info
82 lines
2 KiB
C++
82 lines
2 KiB
C++
// 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"
|
|
|
|
#include <vector>
|
|
|
|
namespace Luau
|
|
{
|
|
namespace CodeGen
|
|
{
|
|
|
|
// This struct matches the layout of x64 RUNTIME_FUNCTION from winnt.h
|
|
struct UnwindFunctionWin
|
|
{
|
|
uint32_t beginOffset;
|
|
uint32_t endOffset;
|
|
uint32_t unwindInfoOffset;
|
|
};
|
|
|
|
// This struct matches the layout of x64 UNWIND_INFO from ehdata.h
|
|
struct UnwindInfoWin
|
|
{
|
|
uint8_t version : 3;
|
|
uint8_t flags : 5;
|
|
uint8_t prologsize;
|
|
uint8_t unwindcodecount;
|
|
uint8_t framereg : 4;
|
|
uint8_t frameregoff : 4;
|
|
};
|
|
|
|
// This struct matches the layout of UNWIND_CODE from ehdata.h
|
|
struct UnwindCodeWin
|
|
{
|
|
uint8_t offset;
|
|
uint8_t opcode : 4;
|
|
uint8_t opinfo : 4;
|
|
};
|
|
|
|
class UnwindBuilderWin : public UnwindBuilder
|
|
{
|
|
public:
|
|
void setBeginOffset(size_t beginOffset) override;
|
|
size_t getBeginOffset() const override;
|
|
|
|
void startInfo() override;
|
|
|
|
void startFunction() override;
|
|
void spill(int espOffset, X64::RegisterX64 reg) override;
|
|
void save(X64::RegisterX64 reg) override;
|
|
void allocStack(int size) override;
|
|
void setupFrameReg(X64::RegisterX64 reg, int espOffset) override;
|
|
void finishFunction(uint32_t beginOffset, uint32_t endOffset) override;
|
|
|
|
void finishInfo() override;
|
|
|
|
size_t getSize() const override;
|
|
size_t getFunctionCount() const override;
|
|
|
|
void finalize(char* target, size_t offset, void* funcAddress, size_t funcSize) const override;
|
|
|
|
private:
|
|
size_t beginOffset = 0;
|
|
|
|
static const unsigned kRawDataLimit = 1024;
|
|
uint8_t rawData[kRawDataLimit];
|
|
uint8_t* rawDataPos = rawData;
|
|
|
|
std::vector<UnwindFunctionWin> unwindFunctions;
|
|
|
|
// Windows unwind codes are written in reverse, so we have to collect them all first
|
|
std::vector<UnwindCodeWin> unwindCodes;
|
|
|
|
uint8_t prologSize = 0;
|
|
X64::RegisterX64 frameReg = X64::noreg;
|
|
uint8_t frameRegOffset = 0;
|
|
uint32_t stackOffset = 0;
|
|
};
|
|
|
|
} // namespace CodeGen
|
|
} // namespace Luau
|