2023-01-13 22:10:01 +00:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#pragma once
|
|
|
|
|
Sync to upstream/release/562 (#828)
* Fixed rare use-after-free in analysis during table unification
A lot of work these past months went into two new Luau components:
* A near full rewrite of the typechecker using a new deferred constraint
resolution system
* Native code generation for AoT/JiT compilation of VM bytecode into x64
(avx)/arm64 instructions
Both of these components are far from finished and we don't provide
documentation on building and using them at this point.
However, curious community members expressed interest in learning about
changes that go into these components each week, so we are now listing
them here in the 'sync' pull request descriptions.
---
New typechecker can be enabled by setting
DebugLuauDeferredConstraintResolution flag to 'true'.
It is considered unstable right now, so try it at your own risk.
Even though it already provides better type inference than the current
one in some cases, our main goal right now is to reach feature parity
with current typechecker.
Features which improve over the capabilities of the current typechecker
are marked as '(NEW)'.
Changes to new typechecker:
* Regular for loop index and parameters are now typechecked
* Invalid type annotations on local variables are ignored to improve
autocomplete
* Fixed missing autocomplete type suggestions for function arguments
* Type reduction is now performed to produce simpler types to be
presented to the user (error messages, custom LSPs)
* Internally, complex types like '((number | string) & ~(false?)) |
string' can be produced, which is just 'string | number' when simplified
* Fixed spots where support for unknown and never types was missing
* (NEW) Length operator '#' is now valid to use on top table type, this
type comes up when doing typeof(x) == "table" guards and isn't available
in current typechecker
---
Changes to native code generation:
* Additional math library fast calls are now lowered to x64: math.ldexp,
math.round, math.frexp, math.modf, math.sign and math.clamp
2023-02-03 19:26:13 +00:00
|
|
|
#include "Luau/IrData.h"
|
2024-01-27 03:20:56 +00:00
|
|
|
#include "Luau/CodeGen.h"
|
2023-01-13 22:10:01 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Luau
|
|
|
|
{
|
|
|
|
namespace CodeGen
|
|
|
|
{
|
|
|
|
|
2023-03-10 20:21:07 +00:00
|
|
|
struct CfgInfo;
|
|
|
|
|
2023-01-13 22:10:01 +00:00
|
|
|
const char* getCmdName(IrCmd cmd);
|
|
|
|
const char* getBlockKindName(IrBlockKind kind);
|
|
|
|
|
|
|
|
struct IrToStringContext
|
|
|
|
{
|
|
|
|
std::string& result;
|
2023-03-24 18:03:04 +00:00
|
|
|
const std::vector<IrBlock>& blocks;
|
|
|
|
const std::vector<IrConst>& constants;
|
|
|
|
const CfgInfo& cfg;
|
2023-01-13 22:10:01 +00:00
|
|
|
};
|
|
|
|
|
2023-02-10 19:40:38 +00:00
|
|
|
void toString(IrToStringContext& ctx, const IrInst& inst, uint32_t index);
|
|
|
|
void toString(IrToStringContext& ctx, const IrBlock& block, uint32_t index); // Block title
|
2023-01-13 22:10:01 +00:00
|
|
|
void toString(IrToStringContext& ctx, IrOp op);
|
|
|
|
|
|
|
|
void toString(std::string& result, IrConst constant);
|
2023-12-02 07:46:57 +00:00
|
|
|
void toString(std::string& result, const BytecodeTypes& bcTypes);
|
2023-01-13 22:10:01 +00:00
|
|
|
|
2024-01-19 18:04:46 +00:00
|
|
|
void toStringDetailed(
|
2024-01-27 03:20:56 +00:00
|
|
|
IrToStringContext& ctx, const IrBlock& block, uint32_t blockIdx, const IrInst& inst, uint32_t instIdx, IncludeUseInfo includeUseInfo);
|
|
|
|
void toStringDetailed(IrToStringContext& ctx, const IrBlock& block, uint32_t blockIdx, IncludeUseInfo includeUseInfo, IncludeCfgInfo includeCfgInfo,
|
|
|
|
IncludeRegFlowInfo includeRegFlowInfo);
|
2023-02-10 19:40:38 +00:00
|
|
|
|
2024-01-27 03:20:56 +00:00
|
|
|
std::string toString(const IrFunction& function, IncludeUseInfo includeUseInfo);
|
2023-01-13 22:10:01 +00:00
|
|
|
|
2023-03-24 18:03:04 +00:00
|
|
|
std::string dump(const IrFunction& function);
|
2023-01-20 20:27:03 +00:00
|
|
|
|
2023-03-24 18:03:04 +00:00
|
|
|
std::string toDot(const IrFunction& function, bool includeInst);
|
2023-06-16 18:35:18 +01:00
|
|
|
std::string toDotCfg(const IrFunction& function);
|
|
|
|
std::string toDotDjGraph(const IrFunction& function);
|
2023-03-17 19:20:37 +00:00
|
|
|
|
2023-03-24 18:03:04 +00:00
|
|
|
std::string dumpDot(const IrFunction& function, bool includeInst);
|
2023-03-17 19:20:37 +00:00
|
|
|
|
2023-01-13 22:10:01 +00:00
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace Luau
|