luau/tests/IrRegAllocX64.test.cpp
Andy Friesen fe7621ee8c
Sync to upstream/release/573 (#903)
* Work toward affording parallel type checking
* The interface to `LazyType` has changed:
* `LazyType` now takes a second callback that is passed the `LazyType&`
itself. This new callback is responsible for populating the field
`TypeId LazyType::unwrapped`. Multithreaded implementations should
acquire a lock in this callback.
* Modules now retain their `humanReadableNames`. This reduces the number
of cases where type checking has to call back to a `ModuleResolver`.
* https://github.com/Roblox/luau/pull/902
* Add timing info to the Luau REPL compilation output

We've also fixed some bugs and crashes in the new solver as we march
toward readiness.
* Thread ICEs (Internal Compiler Errors) back to the Frontend properly
* Refinements are no longer applied to lvalues
* More miscellaneous stability improvements

Lots of activity in the new JIT engine:

* Implement register spilling/restore for A64
* Correct Luau IR value restore location tracking
* Fixed use-after-free in x86 register allocator spill restore
* Use btz for bit tests
* Finish branch assembly support for A64
* Codesize and performance improvements for A64
* The bit32 library has been implemented for arm and x64

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-04-21 15:14:26 -07:00

58 lines
1.4 KiB
C++

// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#include "Luau/IrRegAllocX64.h"
#include "doctest.h"
using namespace Luau::CodeGen;
using namespace Luau::CodeGen::X64;
class IrRegAllocX64Fixture
{
public:
IrRegAllocX64Fixture()
: build(/* logText */ true, ABIX64::Windows)
, regs(build, function)
{
}
void checkMatch(std::string expected)
{
build.finalize();
CHECK("\n" + build.text == expected);
}
AssemblyBuilderX64 build;
IrFunction function;
IrRegAllocX64 regs;
};
TEST_SUITE_BEGIN("IrRegAllocX64");
TEST_CASE_FIXTURE(IrRegAllocX64Fixture, "RelocateFix")
{
IrInst irInst0{IrCmd::LOAD_DOUBLE};
irInst0.lastUse = 2;
function.instructions.push_back(irInst0);
IrInst irInst1{IrCmd::LOAD_DOUBLE};
irInst1.lastUse = 2;
function.instructions.push_back(irInst1);
function.instructions[0].regX64 = regs.takeReg(rax, 0);
regs.preserve(function.instructions[0]);
function.instructions[1].regX64 = regs.takeReg(rax, 1);
regs.restore(function.instructions[0], true);
LUAU_ASSERT(function.instructions[0].regX64 == rax);
LUAU_ASSERT(function.instructions[1].spilled);
checkMatch(R"(
vmovsd qword ptr [rsp+048h],rax
vmovsd qword ptr [rsp+050h],rax
vmovsd rax,qword ptr [rsp+048h]
)");
}
TEST_SUITE_END();