Skip to content

Commit 8aae594

Browse files
committed
v0.18.2+luau708
1 parent a06d964 commit 8aae594

36 files changed

Lines changed: 1562 additions & 1855 deletions

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "luau0-src"
3-
version = "0.18.1+luau706"
3+
version = "0.18.2+luau708"
44
authors = ["Aleksandr Orlenko <zxteam@protonmail.com>"]
55
edition = "2024"
66
repository = "https://github.com/mlua-rs/luau-src-rs"

luau/Ast/src/Ast.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,11 @@ AstExprInstantiate::AstExprInstantiate(const Location& location, AstExpr* expr,
557557

558558
void AstExprInstantiate::visit(AstVisitor* visitor)
559559
{
560-
expr->visit(visitor);
560+
LUAU_ASSERT(FFlag::LuauExplicitTypeInstantiationSyntax);
561561

562562
if (visitor->visit(this))
563563
{
564+
expr->visit(visitor);
564565
visitTypeOrPackArray(visitor, typeArguments);
565566
}
566567
}

luau/Ast/src/Parser.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LUAU_DYNAMIC_FASTFLAGVARIABLE(DebugLuauReportReturnTypeVariadicWithTypeSuffix, f
2222
LUAU_FASTFLAGVARIABLE(LuauExplicitTypeInstantiationSyntax)
2323
LUAU_FASTFLAG(LuauStandaloneParseType)
2424
LUAU_FASTFLAGVARIABLE(LuauCstStatDoWithStatsStart)
25+
LUAU_FASTFLAGVARIABLE(DesugaredArrayTypeReferenceIsEmpty)
2526

2627
// Clip with DebugLuauReportReturnTypeVariadicWithTypeSuffix
2728
bool luau_telemetry_parsed_return_type_variadic_with_type_suffix = false;
@@ -2189,8 +2190,17 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
21892190

21902191
// array-like table type: {T} desugars into {[number]: T}
21912192
isArray = true;
2192-
AstType* index = allocator.alloc<AstTypeReference>(type->location, std::nullopt, nameNumber, std::nullopt, type->location);
2193-
indexer = allocator.alloc<AstTableIndexer>(AstTableIndexer{index, type, type->location, access, accessLocation});
2193+
if (FFlag::DesugaredArrayTypeReferenceIsEmpty)
2194+
{
2195+
Location nullTypeLocation = Location(start.begin, 0);
2196+
AstType* index = allocator.alloc<AstTypeReference>(nullTypeLocation, std::nullopt, nameNumber, std::nullopt, nullTypeLocation);
2197+
indexer = allocator.alloc<AstTableIndexer>(AstTableIndexer{index, type, type->location, access, accessLocation});
2198+
}
2199+
else
2200+
{
2201+
AstType* index = allocator.alloc<AstTypeReference>(type->location, std::nullopt, nameNumber, std::nullopt, type->location);
2202+
indexer = allocator.alloc<AstTableIndexer>(AstTableIndexer{index, type, type->location, access, accessLocation});
2203+
}
21942204

21952205
break;
21962206
}

luau/CodeGen/include/Luau/AssemblyBuilderA64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ class AssemblyBuilderA64
167167
void umov_4s(RegisterA64 dst, RegisterA64 src, uint8_t index);
168168

169169
void fcmeq_4s(RegisterA64 dst, RegisterA64 src1, RegisterA64 src2);
170+
void fcmgt_4s(RegisterA64 dst, RegisterA64 src1, RegisterA64 src2);
170171
void bit(RegisterA64 dst, RegisterA64 src, RegisterA64 mask);
172+
void bif(RegisterA64 dst, RegisterA64 src, RegisterA64 mask);
171173

172174
// Floating-point rounding and conversions
173175
void frinta(RegisterA64 dst, RegisterA64 src);

luau/CodeGen/include/Luau/AssemblyBuilderX64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ class AssemblyBuilderX64
171171
void vmovups(OperandX64 dst, OperandX64 src);
172172
void vmovq(OperandX64 lhs, OperandX64 rhs);
173173

174+
void vmaxps(OperandX64 dst, OperandX64 src1, OperandX64 src2);
174175
void vmaxsd(OperandX64 dst, OperandX64 src1, OperandX64 src2);
175176
void vmaxss(OperandX64 dst, OperandX64 src1, OperandX64 src2);
177+
void vminps(OperandX64 dst, OperandX64 src1, OperandX64 src2);
176178
void vminsd(OperandX64 dst, OperandX64 src1, OperandX64 src2);
177179
void vminss(OperandX64 dst, OperandX64 src1, OperandX64 src2);
178180

luau/CodeGen/include/Luau/IrAnalysis.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ void updateLastUseLocations(IrFunction& function, const std::vector<uint32_t>& s
2525
uint32_t getNextInstUse(IrFunction& function, uint32_t targetInstIdx, uint32_t startInstIdx);
2626

2727
// Returns how many values are coming into the block (live in) and how many are coming out of the block (live out)
28-
std::pair<uint32_t, uint32_t> getLiveInOutValueCount_NEW(IrFunction& function, IrBlock& start, bool visitChain);
29-
std::pair<uint32_t, uint32_t> getLiveInOutValueCount_DEPRECATED(IrFunction& function, IrBlock& block);
28+
std::pair<uint32_t, uint32_t> getLiveInOutValueCount(IrFunction& function, IrBlock& start, bool visitChain);
3029
uint32_t getLiveInValueCount(IrFunction& function, IrBlock& block);
3130
uint32_t getLiveOutValueCount(IrFunction& function, IrBlock& block);
3231

luau/CodeGen/include/Luau/IrBuilder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ struct IrBuilder
3636

3737
// Clones all instructions into the current block
3838
// Source block that is cloned cannot use values coming in from a predecessor
39-
void clone_NEW(std::vector<uint32_t> sourceIdxs, bool removeCurrentTerminator);
40-
void clone_DEPRECATED(const IrBlock& source, bool removeCurrentTerminator);
39+
void clone(std::vector<uint32_t> sourceIdxs, bool removeCurrentTerminator);
4140

4241
IrOp undef();
4342

luau/CodeGen/include/Luau/IrData.h

Lines changed: 46 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424

2525
struct Proto;
2626

27-
LUAU_FASTFLAG(LuauCodegenChainedSpills)
28-
2927
namespace Luau
3028
{
3129
namespace CodeGen
3230
{
3331

3432
struct LoweringStats;
3533

34+
constexpr uint8_t kUnknownTag = 0xff;
35+
3636
// IR extensions to LuauBuiltinFunction enum (these only exist inside IR, and start from 256 to avoid collisions)
3737
enum
3838
{
@@ -264,22 +264,40 @@ enum class IrCmd : uint8_t
264264
SELECT_IF_TRUTHY,
265265

266266
// Add/Sub/Mul/Div/Idiv two vectors
267-
// A, B: TValue
267+
// A, B: TValue (vector)
268268
ADD_VEC,
269269
SUB_VEC,
270270
MUL_VEC,
271271
DIV_VEC,
272272
IDIV_VEC,
273273
// Lanewise A * B + C
274-
// A, B, C: TValue
274+
// A, B, C: TValue (vector)
275275
MULADD_VEC,
276276

277277
// Negate a vector
278-
// A: TValue
278+
// A: TValue (vector)
279279
UNM_VEC,
280280

281+
// Get the minimum/maximum of two vector elements
282+
// If one of the element values is NaN, 'B' is returned as the result
283+
// A, B: TValue (vector)
284+
MIN_VEC,
285+
MAX_VEC,
286+
287+
// Round vector elements to negative infinity
288+
// A: TValue (vector)
289+
FLOOR_VEC,
290+
291+
// Round vector elements to positive infinity
292+
// A: TValue (vector)
293+
CEIL_VEC,
294+
295+
// Get absolute value of vector elements
296+
// A: TValue (vector)
297+
ABS_VEC,
298+
281299
// Compute dot product between two vectors as a float number (use FLOAT_TO_NUM to convert to double)
282-
// A, B: TValue
300+
// A, B: TValue (vector)
283301
DOT_VEC,
284302

285303
// Extract a component of a vector (use FLOAT_TO_NUM to convert to double)
@@ -444,10 +462,6 @@ enum class IrCmd : uint8_t
444462
// A: double
445463
NUM_TO_FLOAT,
446464

447-
// Converts a double number to a vector with the value in X/Y/Z
448-
// A: double
449-
NUM_TO_VEC_DEPRECATED,
450-
451465
// Converts a float number to a vector with the value in X/Y/Z (use NUM_TO_FLOAT to convert from double)
452466
// A: float
453467
FLOAT_TO_VEC,
@@ -1024,7 +1038,7 @@ struct IrInst
10241038
IrCmd cmd;
10251039

10261040
// Operands
1027-
// All frequiently used instructions use only A-D slots.
1041+
// All frequently used instructions use only A-F slots.
10281042
IrOps ops;
10291043

10301044
uint32_t lastUse = 0;
@@ -1052,6 +1066,20 @@ inline IrOp& getOp(IrInst* inst, uint32_t idx)
10521066
return getOp(*inst, idx);
10531067
}
10541068

1069+
inline bool hasOp(IrInst& inst, uint32_t idx)
1070+
{
1071+
return idx < inst.ops.size();
1072+
}
1073+
1074+
// TODO: once we update kind checks to not use getOp, it will no longer cause a resize and second part can be removed
1075+
#define HAS_OP_A(inst) (0 < (inst).ops.size() && (inst).ops[0].kind != IrOpKind::None)
1076+
#define HAS_OP_B(inst) (1 < (inst).ops.size() && (inst).ops[1].kind != IrOpKind::None)
1077+
#define HAS_OP_C(inst) (2 < (inst).ops.size() && (inst).ops[2].kind != IrOpKind::None)
1078+
#define HAS_OP_D(inst) (3 < (inst).ops.size() && (inst).ops[3].kind != IrOpKind::None)
1079+
#define HAS_OP_E(inst) (4 < (inst).ops.size() && (inst).ops[4].kind != IrOpKind::None)
1080+
#define HAS_OP_F(inst) (5 < (inst).ops.size() && (inst).ops[5].kind != IrOpKind::None)
1081+
#define HAS_OP_G(inst) (6 < (inst).ops.size() && (inst).ops[6].kind != IrOpKind::None)
1082+
10551083
// When IrInst operands are used, current instruction index is often required to track lifetime
10561084
inline constexpr uint32_t kInvalidInstIdx = ~0u;
10571085

@@ -1233,8 +1261,7 @@ struct IrFunction
12331261
uint32_t endLocation = 0;
12341262

12351263
// For each instruction, an operand that can be used to recompute the value
1236-
std::vector<IrOp> valueRestoreOps_DEPRECATED; // TODO: Remove with FFlagLuauCodegenChainedSpills
1237-
std::vector<ValueRestoreLocation> valueRestoreOps_NEW;
1264+
std::vector<ValueRestoreLocation> valueRestoreOps;
12381265
std::vector<uint32_t> validRestoreOpBlocks;
12391266

12401267
BytecodeTypeInfo bcOriginalTypeInfo; // Bytecode type information as loaded
@@ -1379,63 +1406,19 @@ struct IrFunction
13791406
return uint32_t(&inst - instructions.data());
13801407
}
13811408

1382-
void recordRestoreOp_DEPRECATED(uint32_t instIdx, IrOp location)
1383-
{
1384-
CODEGEN_ASSERT(!FFlag::LuauCodegenChainedSpills);
1385-
1386-
if (instIdx >= valueRestoreOps_DEPRECATED.size())
1387-
valueRestoreOps_DEPRECATED.resize(instIdx + 1);
1388-
1389-
valueRestoreOps_DEPRECATED[instIdx] = location;
1390-
}
1391-
1392-
IrOp findRestoreOp_DEPRECATED(uint32_t instIdx, bool limitToCurrentBlock) const
1393-
{
1394-
CODEGEN_ASSERT(!FFlag::LuauCodegenChainedSpills);
1395-
1396-
if (instIdx >= valueRestoreOps_DEPRECATED.size())
1397-
return {};
1398-
1399-
// When spilled, values can only reference restore operands in the current block chain
1400-
if (limitToCurrentBlock)
1401-
{
1402-
for (uint32_t blockIdx : validRestoreOpBlocks)
1403-
{
1404-
const IrBlock& block = blocks[blockIdx];
1405-
1406-
if (instIdx >= block.start && instIdx <= block.finish)
1407-
return valueRestoreOps_DEPRECATED[instIdx];
1408-
}
1409-
1410-
return {};
1411-
}
1412-
1413-
return valueRestoreOps_DEPRECATED[instIdx];
1414-
}
1415-
1416-
IrOp findRestoreOp_DEPRECATED(const IrInst& inst, bool limitToCurrentBlock) const
1417-
{
1418-
CODEGEN_ASSERT(!FFlag::LuauCodegenChainedSpills);
1419-
1420-
return findRestoreOp_DEPRECATED(getInstIndex(inst), limitToCurrentBlock);
1421-
}
1422-
14231409
void recordRestoreLocation(uint32_t instIdx, ValueRestoreLocation location)
14241410
{
1425-
CODEGEN_ASSERT(FFlag::LuauCodegenChainedSpills);
14261411
CODEGEN_ASSERT(location.op.kind == IrOpKind::None || location.op.kind == IrOpKind::VmReg || location.op.kind == IrOpKind::VmConst);
14271412

1428-
if (instIdx >= valueRestoreOps_NEW.size())
1429-
valueRestoreOps_NEW.resize(instIdx + 1);
1413+
if (instIdx >= valueRestoreOps.size())
1414+
valueRestoreOps.resize(instIdx + 1);
14301415

1431-
valueRestoreOps_NEW[instIdx] = location;
1416+
valueRestoreOps[instIdx] = location;
14321417
}
14331418

14341419
ValueRestoreLocation findRestoreLocation(uint32_t instIdx, bool limitToCurrentBlock) const
14351420
{
1436-
CODEGEN_ASSERT(FFlag::LuauCodegenChainedSpills);
1437-
1438-
if (instIdx >= valueRestoreOps_NEW.size())
1421+
if (instIdx >= valueRestoreOps.size())
14391422
return {};
14401423

14411424
// When spilled, values can only reference restore operands in the current block chain
@@ -1446,26 +1429,22 @@ struct IrFunction
14461429
const IrBlock& block = blocks[blockIdx];
14471430

14481431
if (instIdx >= block.start && instIdx <= block.finish)
1449-
return valueRestoreOps_NEW[instIdx];
1432+
return valueRestoreOps[instIdx];
14501433
}
14511434

14521435
return {};
14531436
}
14541437

1455-
return valueRestoreOps_NEW[instIdx];
1438+
return valueRestoreOps[instIdx];
14561439
}
14571440

14581441
ValueRestoreLocation findRestoreLocation(const IrInst& inst, bool limitToCurrentBlock) const
14591442
{
1460-
CODEGEN_ASSERT(FFlag::LuauCodegenChainedSpills);
1461-
14621443
return findRestoreLocation(getInstIndex(inst), limitToCurrentBlock);
14631444
}
14641445

14651446
bool hasRestoreLocation(const IrInst& inst, bool limitToCurrentBlock) const
14661447
{
1467-
CODEGEN_ASSERT(FFlag::LuauCodegenChainedSpills);
1468-
14691448
return findRestoreLocation(getInstIndex(inst), limitToCurrentBlock).op.kind != IrOpKind::None;
14701449
}
14711450

luau/CodeGen/include/Luau/IrRegAllocX64.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ struct IrRegAllocX64
5454

5555
unsigned findSpillStackSlot(IrValueKind valueKind);
5656

57-
// TODO: Remove with FFlagLuauCodegenChainedSpills
58-
IrOp getRestoreOp_DEPRECATED(const IrInst& inst) const;
59-
bool hasRestoreOp_DEPRECATED(const IrInst& inst) const;
60-
OperandX64 getRestoreAddress_DEPRECATED(const IrInst& inst, IrOp restoreOp);
61-
6257
OperandX64 getRestoreAddress(const IrInst& inst, ValueRestoreLocation restoreLocation);
6358

6459
// Register used by instruction is about to be freed, have to find a way to restore value later
@@ -89,7 +84,6 @@ struct IrRegAllocX64
8984
std::array<uint32_t, 16> xmmInstUsers;
9085
uint8_t usableXmmRegCount = 0;
9186

92-
std::bitset<256> usedSpillSlots_DEPRECATED;
9387
std::bitset<512> usedSpillSlotHalfs; // A bit for every stack slot split in 4 byte halfs
9488
unsigned maxUsedSlot = 0; // Maximum number of 8 byte stack slots used
9589

luau/CodeGen/include/Luau/IrUtils.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ inline bool hasResult(IrCmd cmd)
129129
case IrCmd::DIV_VEC:
130130
case IrCmd::IDIV_VEC:
131131
case IrCmd::UNM_VEC:
132+
case IrCmd::MIN_VEC:
133+
case IrCmd::MAX_VEC:
134+
case IrCmd::FLOOR_VEC:
135+
case IrCmd::CEIL_VEC:
136+
case IrCmd::ABS_VEC:
132137
case IrCmd::DOT_VEC:
133138
case IrCmd::EXTRACT_VEC:
134139
case IrCmd::NOT_ANY:
@@ -151,7 +156,6 @@ inline bool hasResult(IrCmd cmd)
151156
case IrCmd::NUM_TO_UINT:
152157
case IrCmd::FLOAT_TO_NUM:
153158
case IrCmd::NUM_TO_FLOAT:
154-
case IrCmd::NUM_TO_VEC_DEPRECATED:
155159
case IrCmd::FLOAT_TO_VEC:
156160
case IrCmd::TAG_VECTOR:
157161
case IrCmd::TRUNCATE_UINT:
@@ -280,6 +284,7 @@ inline IrCondition getNegatedCondition(IrCondition cond)
280284
}
281285

282286
IrValueKind getCmdValueKind(IrCmd cmd);
287+
IrValueKind getConstValueKind(const IrConst& constant);
283288

284289
template<typename F>
285290
void visitArguments(IrInst& inst, F&& func)
@@ -367,5 +372,8 @@ IrBlock* tryGetNextBlockInChain(IrFunction& function, IrBlock& block);
367372

368373
bool isEntryBlock(const IrBlock& block);
369374

375+
// When an operand is an instruction, try to extract the tag which is contained inside that value
376+
std::optional<uint8_t> tryGetOperandTag(IrFunction& function, IrOp op);
377+
370378
} // namespace CodeGen
371379
} // namespace Luau

0 commit comments

Comments
 (0)