mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 21:40:43 +00:00
140e5a1495
* Fixed incorrect lexeme generated for string parts in the middle of an interpolated string (Fixes https://github.com/Roblox/luau/issues/744) * DeprecatedApi lint can report some issues without type inference information * Fixed performance of autocomplete requests when suggestions have large intersection types (Solves https://github.com/Roblox/luau/discussions/847) * Marked `table.getn`/`foreach`/`foreachi` as deprecated ([RFC: Deprecate table.getn/foreach/foreachi](https://github.com/Roblox/luau/blob/master/rfcs/deprecate-table-getn-foreach.md)) * With -O2 optimization level, we now optimize builtin calls based on known argument/return count. Note that this change can be observable if `getfenv/setfenv` is used to substitute a builtin, especially if arity is different. Fastcall heavy tests show a 1-2% improvement. * Luau can now be built with clang-cl (Fixes https://github.com/Roblox/luau/issues/736) We also made many improvements to our experimental components. For our new type solver: * Overhauled data flow analysis system, fixed issues with 'repeat' loops, global variables and type annotations * Type refinements now work on generic table indexing with a string literal * Type refinements will properly track potentially 'nil' values (like t[x] for a missing key) and their further refinements * Internal top table type is now isomorphic to `{}` which fixes issues when `typeof(v) == 'table'` type refinement is handled * References to non-existent types in type annotations no longer resolve to 'error' type like in old solver * Improved handling of class unions in property access expressions * Fixed default type packs * Unsealed tables can now have metatables * Restored expected types for function arguments And for native code generation: * Added min and max IR instructions mapping to vminsd/vmaxsd on x64 * We now speculatively extract direct execution fast-paths based on expected types of expressions which provides better optimization opportunities inside a single basic block * Translated existing math fastcalls to IR form to improve tag guard removal and constant propagation
73 lines
2 KiB
C++
73 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/Common.h"
|
|
#include "Luau/Bytecode.h"
|
|
#include "Luau/IrData.h"
|
|
|
|
#include <vector>
|
|
|
|
struct Proto;
|
|
typedef uint32_t Instruction;
|
|
|
|
namespace Luau
|
|
{
|
|
namespace CodeGen
|
|
{
|
|
|
|
struct AssemblyOptions;
|
|
|
|
struct IrBuilder
|
|
{
|
|
void buildFunctionIr(Proto* proto);
|
|
|
|
void rebuildBytecodeBasicBlocks(Proto* proto);
|
|
void translateInst(LuauOpcode op, const Instruction* pc, int i);
|
|
|
|
bool isInternalBlock(IrOp block);
|
|
void beginBlock(IrOp block);
|
|
|
|
void loadAndCheckTag(IrOp loc, uint8_t tag, IrOp fallback);
|
|
|
|
// Clones all instructions into the current block
|
|
// Source block that is cloned cannot use values coming in from a predecessor
|
|
void clone(const IrBlock& source, bool removeCurrentTerminator);
|
|
|
|
IrOp constBool(bool value);
|
|
IrOp constInt(int value);
|
|
IrOp constUint(unsigned value);
|
|
IrOp constDouble(double value);
|
|
IrOp constTag(uint8_t value);
|
|
IrOp constAny(IrConst constant);
|
|
|
|
IrOp cond(IrCondition cond);
|
|
|
|
IrOp inst(IrCmd cmd);
|
|
IrOp inst(IrCmd cmd, IrOp a);
|
|
IrOp inst(IrCmd cmd, IrOp a, IrOp b);
|
|
IrOp inst(IrCmd cmd, IrOp a, IrOp b, IrOp c);
|
|
IrOp inst(IrCmd cmd, IrOp a, IrOp b, IrOp c, IrOp d);
|
|
IrOp inst(IrCmd cmd, IrOp a, IrOp b, IrOp c, IrOp d, IrOp e);
|
|
IrOp inst(IrCmd cmd, IrOp a, IrOp b, IrOp c, IrOp d, IrOp e, IrOp f);
|
|
|
|
IrOp block(IrBlockKind kind); // Requested kind can be ignored if we are in an outlined sequence
|
|
IrOp blockAtInst(uint32_t index);
|
|
|
|
IrOp vmReg(uint8_t index);
|
|
IrOp vmConst(uint32_t index);
|
|
IrOp vmUpvalue(uint8_t index);
|
|
|
|
bool inTerminatedBlock = false;
|
|
|
|
bool activeFastcallFallback = false;
|
|
IrOp fastcallFallbackReturn;
|
|
|
|
IrFunction function;
|
|
|
|
uint32_t activeBlockIdx = ~0u;
|
|
|
|
std::vector<uint32_t> instIndexToBlock; // Block index at the bytecode instruction
|
|
};
|
|
|
|
} // namespace CodeGen
|
|
} // namespace Luau
|