Skip to content

Commit 1503aca

Browse files
committed
Bump Luau to 0.697
1 parent abef7ed commit 1503aca

File tree

19 files changed

+482
-227
lines changed

19 files changed

+482
-227
lines changed

luau/Ast/src/Parser.cpp

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ LUAU_FASTINTVARIABLE(LuauParseErrorLimit, 100)
1919
// See docs/SyntaxChanges.md for an explanation.
2020
LUAU_FASTFLAGVARIABLE(LuauSolverV2)
2121
LUAU_DYNAMIC_FASTFLAGVARIABLE(DebugLuauReportReturnTypeVariadicWithTypeSuffix, false)
22-
LUAU_FASTFLAGVARIABLE(LuauParseIncompleteInterpStringsWithLocation)
2322
LUAU_FASTFLAGVARIABLE(LuauParametrizedAttributeSyntax)
2423
LUAU_FASTFLAGVARIABLE(DebugLuauStringSingletonBasedOnQuotes)
2524
LUAU_FASTFLAGVARIABLE(LuauAutocompleteAttributes)
@@ -4023,33 +4022,27 @@ AstExpr* Parser::parseInterpString()
40234022
return reportExprError(endLocation, {}, "Double braces are not permitted within interpolated strings; did you mean '\\{'?");
40244023
case Lexeme::BrokenString:
40254024
nextLexeme();
4026-
if (!FFlag::LuauParseIncompleteInterpStringsWithLocation)
4027-
return reportExprError(endLocation, {}, "Malformed interpolated string; did you forget to add a '}'?");
40284025
LUAU_FALLTHROUGH;
40294026
case Lexeme::Eof:
40304027
{
4031-
if (FFlag::LuauParseIncompleteInterpStringsWithLocation)
4028+
AstArray<AstArray<char>> stringsArray = copy(strings);
4029+
AstArray<AstExpr*> exprs = copy(expressions);
4030+
AstExprInterpString* node =
4031+
allocator.alloc<AstExprInterpString>(Location{startLocation, lexer.previousLocation()}, stringsArray, exprs);
4032+
if (options.storeCstData)
4033+
cstNodeMap[node] = allocator.alloc<CstExprInterpString>(copy(sourceStrings), copy(stringPositions));
4034+
if (auto top = lexer.peekBraceStackTop())
40324035
{
4033-
AstArray<AstArray<char>> stringsArray = copy(strings);
4034-
AstArray<AstExpr*> exprs = copy(expressions);
4035-
AstExprInterpString* node =
4036-
allocator.alloc<AstExprInterpString>(Location{startLocation, lexer.previousLocation()}, stringsArray, exprs);
4037-
if (options.storeCstData)
4038-
cstNodeMap[node] = allocator.alloc<CstExprInterpString>(copy(sourceStrings), copy(stringPositions));
4039-
if (auto top = lexer.peekBraceStackTop())
4040-
{
4041-
// We are in a broken interpolated string, the top of the stack is non empty, we are missing '}'
4042-
if (*top == Lexer::BraceType::InterpolatedString)
4043-
report(lexer.previousLocation(), "Malformed interpolated string; did you forget to add a '}'?");
4044-
}
4045-
else
4046-
{
4047-
// We are in a broken interpolated string, the top of the stack is empty, we are missing '`'.
4048-
report(lexer.previousLocation(), "Malformed interpolated string; did you forget to add a '`'?");
4049-
}
4050-
return node;
4036+
// We are in a broken interpolated string, the top of the stack is non empty, we are missing '}'
4037+
if (*top == Lexer::BraceType::InterpolatedString)
4038+
report(lexer.previousLocation(), "Malformed interpolated string; did you forget to add a '}'?");
40514039
}
4052-
LUAU_FALLTHROUGH;
4040+
else
4041+
{
4042+
// We are in a broken interpolated string, the top of the stack is empty, we are missing '`'.
4043+
report(lexer.previousLocation(), "Malformed interpolated string; did you forget to add a '`'?");
4044+
}
4045+
return node;
40534046
}
40544047
default:
40554048
return reportExprError(endLocation, {}, "Malformed interpolated string, got %s", lexer.current().toString().c_str());

luau/CodeGen/src/CodeGenContext.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
LUAU_FASTINTVARIABLE(LuauCodeGenBlockSize, 4 * 1024 * 1024)
1717
LUAU_FASTINTVARIABLE(LuauCodeGenMaxTotalSize, 256 * 1024 * 1024)
18-
LUAU_FASTFLAGVARIABLE(LuauCodeGenUnassignedBcTargetAbort)
1918
LUAU_DYNAMIC_FASTFLAGVARIABLE(LuauCodeGenDisableWithNoReentry, false)
2019

2120
namespace Luau
@@ -447,31 +446,18 @@ void create(lua_State* L, SharedCodeGenContext* codeGenContext)
447446
NativeProtoExecDataPtr nativeExecData = createNativeProtoExecData(proto->sizecode);
448447

449448
uint32_t instTarget = ir.function.entryLocation;
449+
uint32_t unassignedOffset = ir.function.endLocation - instTarget;
450450

451-
if (FFlag::LuauCodeGenUnassignedBcTargetAbort)
451+
for (int i = 0; i < proto->sizecode; ++i)
452452
{
453-
uint32_t unassignedOffset = ir.function.endLocation - instTarget;
453+
const BytecodeMapping& bcMapping = ir.function.bcMapping[i];
454454

455-
for (int i = 0; i < proto->sizecode; ++i)
456-
{
457-
const BytecodeMapping& bcMapping = ir.function.bcMapping[i];
458-
459-
CODEGEN_ASSERT(bcMapping.asmLocation >= instTarget);
455+
CODEGEN_ASSERT(bcMapping.asmLocation >= instTarget);
460456

461-
if (bcMapping.asmLocation != ~0u)
462-
nativeExecData[i] = bcMapping.asmLocation - instTarget;
463-
else
464-
nativeExecData[i] = unassignedOffset;
465-
}
466-
}
467-
else
468-
{
469-
for (int i = 0; i < proto->sizecode; ++i)
470-
{
471-
CODEGEN_ASSERT(ir.function.bcMapping[i].asmLocation >= instTarget);
472-
473-
nativeExecData[i] = ir.function.bcMapping[i].asmLocation - instTarget;
474-
}
457+
if (bcMapping.asmLocation != ~0u)
458+
nativeExecData[i] = bcMapping.asmLocation - instTarget;
459+
else
460+
nativeExecData[i] = unassignedOffset;
475461
}
476462

477463
// Set first instruction offset to 0 so that entering this function still

luau/CodeGen/src/IrLoweringA64.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include "lstate.h"
1313
#include "lgc.h"
1414

15-
LUAU_FASTFLAG(LuauCodeGenUnassignedBcTargetAbort)
16-
LUAU_FASTFLAG(LuauCodeGenRegAutoSpillA64)
1715
LUAU_FASTFLAG(LuauCodegenDirectCompare2)
1816

1917
namespace Luau
@@ -273,8 +271,7 @@ IrLoweringA64::IrLoweringA64(AssemblyBuilderA64& build, ModuleHelpers& helpers,
273271

274272
void IrLoweringA64::lowerInst(IrInst& inst, uint32_t index, const IrBlock& next)
275273
{
276-
if (FFlag::LuauCodeGenRegAutoSpillA64)
277-
regs.currInstIdx = index;
274+
regs.currInstIdx = index;
278275

279276
valueTracker.beforeInstLowering(inst);
280277

@@ -2726,8 +2723,7 @@ void IrLoweringA64::lowerInst(IrInst& inst, uint32_t index, const IrBlock& next)
27262723

27272724
valueTracker.afterInstLowering(inst, index);
27282725

2729-
if (FFlag::LuauCodeGenRegAutoSpillA64)
2730-
regs.currInstIdx = kInvalidInstIdx;
2726+
regs.currInstIdx = kInvalidInstIdx;
27312727

27322728
regs.freeLastUseRegs(inst, index);
27332729
regs.freeTempRegs();
@@ -2772,12 +2768,9 @@ void IrLoweringA64::finishFunction()
27722768
build.b(helpers.updatePcAndContinueInVm);
27732769
}
27742770

2775-
if (FFlag::LuauCodeGenUnassignedBcTargetAbort)
2776-
{
2777-
// An undefined instruction is placed after the function to be used as an aborting jump offset
2778-
function.endLocation = build.setLabel().location;
2779-
build.udf();
2780-
}
2771+
// An undefined instruction is placed after the function to be used as an aborting jump offset
2772+
function.endLocation = build.setLabel().location;
2773+
build.udf();
27812774

27822775
if (stats)
27832776
{

luau/CodeGen/src/IrLoweringX64.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
#include "lstate.h"
1717
#include "lgc.h"
1818

19-
LUAU_FASTFLAG(LuauCodeGenUnassignedBcTargetAbort)
2019
LUAU_FASTFLAGVARIABLE(LuauCodeGenVBlendpdReorder)
21-
LUAU_FASTFLAG(LuauCodeGenRegAutoSpillA64)
2220
LUAU_FASTFLAG(LuauCodegenDirectCompare2)
2321

2422
namespace Luau
@@ -2357,8 +2355,7 @@ void IrLoweringX64::lowerInst(IrInst& inst, uint32_t index, const IrBlock& next)
23572355

23582356
valueTracker.afterInstLowering(inst, index);
23592357

2360-
if (FFlag::LuauCodeGenRegAutoSpillA64)
2361-
regs.currInstIdx = kInvalidInstIdx;
2358+
regs.currInstIdx = kInvalidInstIdx;
23622359

23632360
regs.freeLastUseRegs(inst, index);
23642361
}
@@ -2402,12 +2399,9 @@ void IrLoweringX64::finishFunction()
24022399
build.jmp(helpers.updatePcAndContinueInVm);
24032400
}
24042401

2405-
if (FFlag::LuauCodeGenUnassignedBcTargetAbort)
2406-
{
2407-
// An undefined instruction is placed after the function to be used as an aborting jump offset
2408-
function.endLocation = build.setLabel().location;
2409-
build.ud2();
2410-
}
2402+
// An undefined instruction is placed after the function to be used as an aborting jump offset
2403+
function.endLocation = build.setLabel().location;
2404+
build.ud2();
24112405

24122406
if (stats)
24132407
{

luau/CodeGen/src/IrRegAllocA64.cpp

Lines changed: 18 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <string.h>
1212

1313
LUAU_FASTFLAGVARIABLE(DebugCodegenChaosA64)
14-
LUAU_FASTFLAGVARIABLE(LuauCodeGenRegAutoSpillA64)
1514

1615
namespace Luau
1716
{
@@ -147,19 +146,11 @@ RegisterA64 IrRegAllocA64::allocReg(KindA64 kind, uint32_t index)
147146

148147
if (set.free == 0)
149148
{
150-
if (FFlag::LuauCodeGenRegAutoSpillA64)
149+
// Try to find and spill a register that is not used in the current instruction and has the furthest next use
150+
if (uint32_t furthestUseTarget = findInstructionWithFurthestNextUse(set); furthestUseTarget != kInvalidInstIdx)
151151
{
152-
// Try to find and spill a register that is not used in the current instruction and has the furthest next use
153-
if (uint32_t furthestUseTarget = findInstructionWithFurthestNextUse(set); furthestUseTarget != kInvalidInstIdx)
154-
{
155-
spill(set, index, furthestUseTarget);
156-
CODEGEN_ASSERT(set.free != 0);
157-
}
158-
else
159-
{
160-
error = true;
161-
return RegisterA64{kind, 0};
162-
}
152+
spill(set, index, furthestUseTarget);
153+
CODEGEN_ASSERT(set.free != 0);
163154
}
164155
else
165156
{
@@ -185,19 +176,11 @@ RegisterA64 IrRegAllocA64::allocTemp(KindA64 kind)
185176

186177
if (set.free == 0)
187178
{
188-
if (FFlag::LuauCodeGenRegAutoSpillA64)
179+
// Try to find and spill a register that is not used in the current instruction and has the furthest next use
180+
if (uint32_t furthestUseTarget = findInstructionWithFurthestNextUse(set); furthestUseTarget != kInvalidInstIdx)
189181
{
190-
// Try to find and spill a register that is not used in the current instruction and has the furthest next use
191-
if (uint32_t furthestUseTarget = findInstructionWithFurthestNextUse(set); furthestUseTarget != kInvalidInstIdx)
192-
{
193-
spill(set, currInstIdx, furthestUseTarget);
194-
CODEGEN_ASSERT(set.free != 0);
195-
}
196-
else
197-
{
198-
error = true;
199-
return RegisterA64{kind, 0};
200-
}
182+
spill(set, currInstIdx, furthestUseTarget);
183+
CODEGEN_ASSERT(set.free != 0);
201184
}
202185
else
203186
{
@@ -351,79 +334,16 @@ size_t IrRegAllocA64::spill(uint32_t index, std::initializer_list<RegisterA64> l
351334

352335
while (regs)
353336
{
354-
if (FFlag::LuauCodeGenRegAutoSpillA64)
355-
{
356-
int reg = 31 - countlz(regs);
357-
358-
uint32_t targetInstIdx = set.defs[reg];
359-
360-
CODEGEN_ASSERT(targetInstIdx != kInvalidInstIdx);
361-
CODEGEN_ASSERT(function.instructions[targetInstIdx].regA64.index == reg);
362-
363-
spill(set, index, targetInstIdx);
364-
365-
regs &= ~(1u << reg);
366-
}
367-
else
368-
{
369-
int reg = 31 - countlz(regs);
370-
371-
uint32_t inst = set.defs[reg];
372-
CODEGEN_ASSERT(inst != kInvalidInstIdx);
373-
374-
IrInst& def = function.instructions[inst];
375-
CODEGEN_ASSERT(def.regA64.index == reg);
376-
CODEGEN_ASSERT(!def.reusedReg);
377-
CODEGEN_ASSERT(!def.spilled);
378-
CODEGEN_ASSERT(!def.needsReload);
379-
380-
if (def.lastUse == index)
381-
{
382-
// instead of spilling the register to never reload it, we assume the register is not needed anymore
383-
}
384-
else if (getReloadAddress(function, def, /*limitToCurrentBlock*/ true).base != xzr)
385-
{
386-
// instead of spilling the register to stack, we can reload it from VM stack/constants
387-
// we still need to record the spill for restore(start) to work
388-
Spill s = {inst, def.regA64, -1};
389-
spills.push_back(s);
390-
391-
def.needsReload = true;
392-
393-
if (stats)
394-
stats->spillsToRestore++;
395-
}
396-
else
397-
{
398-
int slot = allocSpill(freeSpillSlots, def.regA64.kind);
399-
if (slot < 0)
400-
{
401-
slot = kInvalidSpill;
402-
error = true;
403-
}
404-
405-
build.str(def.regA64, mem(sp, sSpillArea.data + slot * 8));
406-
407-
Spill s = {inst, def.regA64, int8_t(slot)};
408-
spills.push_back(s);
409-
410-
def.spilled = true;
411-
412-
if (stats)
413-
{
414-
stats->spillsToSlot++;
415-
416-
if (slot != kInvalidSpill && unsigned(slot + 1) > stats->maxSpillSlotsUsed)
417-
stats->maxSpillSlotsUsed = slot + 1;
418-
}
419-
}
420-
421-
def.regA64 = noreg;
422-
423-
regs &= ~(1u << reg);
424-
set.free |= 1u << reg;
425-
set.defs[reg] = kInvalidInstIdx;
426-
}
337+
int reg = 31 - countlz(regs);
338+
339+
uint32_t targetInstIdx = set.defs[reg];
340+
341+
CODEGEN_ASSERT(targetInstIdx != kInvalidInstIdx);
342+
CODEGEN_ASSERT(function.instructions[targetInstIdx].regA64.index == reg);
343+
344+
spill(set, index, targetInstIdx);
345+
346+
regs &= ~(1u << reg);
427347
}
428348

429349
CODEGEN_ASSERT(set.free == set.base);
@@ -485,8 +405,6 @@ void IrRegAllocA64::restoreReg(IrInst& inst)
485405

486406
void IrRegAllocA64::spill(Set& set, uint32_t index, uint32_t targetInstIdx)
487407
{
488-
CODEGEN_ASSERT(FFlag::LuauCodeGenRegAutoSpillA64);
489-
490408
IrInst& def = function.instructions[targetInstIdx];
491409
int reg = def.regA64.index;
492410

@@ -543,8 +461,6 @@ void IrRegAllocA64::spill(Set& set, uint32_t index, uint32_t targetInstIdx)
543461

544462
uint32_t IrRegAllocA64::findInstructionWithFurthestNextUse(Set& set) const
545463
{
546-
CODEGEN_ASSERT(FFlag::LuauCodeGenRegAutoSpillA64);
547-
548464
if (currInstIdx == kInvalidInstIdx)
549465
return kInvalidInstIdx;
550466

luau/CodeGen/src/IrRegAllocX64.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
#include "EmitCommonX64.h"
88

9-
LUAU_FASTFLAG(LuauCodeGenRegAutoSpillA64)
10-
119
namespace Luau
1210
{
1311
namespace CodeGen
@@ -395,11 +393,8 @@ OperandX64 IrRegAllocX64::getRestoreAddress(const IrInst& inst, IrOp restoreOp)
395393

396394
uint32_t IrRegAllocX64::findInstructionWithFurthestNextUse(const std::array<uint32_t, 16>& regInstUsers) const
397395
{
398-
if (FFlag::LuauCodeGenRegAutoSpillA64)
399-
{
400-
if (currInstIdx == kInvalidInstIdx)
401-
return kInvalidInstIdx;
402-
}
396+
if (currInstIdx == kInvalidInstIdx)
397+
return kInvalidInstIdx;
403398

404399
uint32_t furthestUseTarget = kInvalidInstIdx;
405400
uint32_t furthestUseLocation = 0;

luau/CodeGen/src/IrValueLocationTracking.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#include "Luau/IrUtils.h"
55

6-
LUAU_FASTFLAGVARIABLE(LuauCodeGenRestoreFromSplitStore)
7-
86
namespace Luau
97
{
108
namespace CodeGen
@@ -177,12 +175,9 @@ void IrValueLocationTracking::afterInstLowering(IrInst& inst, uint32_t instIdx)
177175
recordRestoreOp(inst.b.index, inst.a);
178176
break;
179177
case IrCmd::STORE_SPLIT_TVALUE:
180-
if (FFlag::LuauCodeGenRestoreFromSplitStore)
181-
{
182-
// If this is not the last use of the stored value, we can restore it from this new location
183-
if (inst.c.kind == IrOpKind::Inst && function.instOp(inst.c).lastUse != instIdx)
184-
recordRestoreOp(inst.c.index, inst.a);
185-
}
178+
// If this is not the last use of the stored value, we can restore it from this new location
179+
if (inst.c.kind == IrOpKind::Inst && function.instOp(inst.c).lastUse != instIdx)
180+
recordRestoreOp(inst.c.index, inst.a);
186181
break;
187182
default:
188183
break;

0 commit comments

Comments
 (0)