Skip to content

Commit a06d964

Browse files
committed
v0.18.1+luau706
1 parent 3e43936 commit a06d964

31 files changed

Lines changed: 3229 additions & 2614 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.0+luau705"
3+
version = "0.18.1+luau706"
44
authors = ["Aleksandr Orlenko <zxteam@protonmail.com>"]
55
edition = "2024"
66
repository = "https://github.com/mlua-rs/luau-src-rs"

luau/Ast/src/Parser.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4039,8 +4039,7 @@ AstExpr* Parser::parseInterpString()
40394039
{
40404040
AstArray<AstArray<char>> stringsArray = copy(strings);
40414041
AstArray<AstExpr*> exprs = copy(expressions);
4042-
AstExprInterpString* node =
4043-
allocator.alloc<AstExprInterpString>(Location{startLocation, lexer.previousLocation()}, stringsArray, exprs);
4042+
AstExprInterpString* node = allocator.alloc<AstExprInterpString>(Location{startLocation, lexer.previousLocation()}, stringsArray, exprs);
40444043
if (options.storeCstData)
40454044
cstNodeMap[node] = allocator.alloc<CstExprInterpString>(copy(sourceStrings), copy(stringPositions));
40464045
if (auto top = lexer.peekBraceStackTop())

luau/CodeGen/include/Luau/IrBuilder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ struct IrBuilder
5050

5151
IrOp cond(IrCondition cond);
5252

53+
IrOp inst(IrCmd cmd, const IrOps& ops);
54+
IrOp inst(IrCmd cmd, std::initializer_list<IrOp> ops);
5355
IrOp inst(IrCmd cmd);
5456
IrOp inst(IrCmd cmd, IrOp a);
5557
IrOp inst(IrCmd cmd, IrOp a, IrOp b);

luau/CodeGen/include/Luau/IrData.h

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@
66
#include "Luau/Label.h"
77
#include "Luau/RegisterX64.h"
88
#include "Luau/RegisterA64.h"
9+
#include "Luau/SmallVector.h"
910

1011
#include <optional>
1112
#include <vector>
1213

1314
#include <stdint.h>
1415
#include <string.h>
1516

17+
#define OP_A(inst) getOp(inst, 0)
18+
#define OP_B(inst) getOp(inst, 1)
19+
#define OP_C(inst) getOp(inst, 2)
20+
#define OP_D(inst) getOp(inst, 3)
21+
#define OP_E(inst) getOp(inst, 4)
22+
#define OP_F(inst) getOp(inst, 5)
23+
#define OP_G(inst) getOp(inst, 6)
24+
1625
struct Proto;
1726

1827
LUAU_FASTFLAG(LuauCodegenChainedSpills)
@@ -1008,18 +1017,15 @@ enum class IrValueKind : uint8_t
10081017
Count
10091018
};
10101019

1020+
using IrOps = SmallVector<IrOp, 6>;
1021+
10111022
struct IrInst
10121023
{
10131024
IrCmd cmd;
10141025

10151026
// Operands
1016-
IrOp a;
1017-
IrOp b;
1018-
IrOp c;
1019-
IrOp d;
1020-
IrOp e;
1021-
IrOp f;
1022-
IrOp g;
1027+
// All frequiently used instructions use only A-D slots.
1028+
IrOps ops;
10231029

10241030
uint32_t lastUse = 0;
10251031
uint16_t useCount = 0;
@@ -1032,6 +1038,20 @@ struct IrInst
10321038
bool needsReload = false;
10331039
};
10341040

1041+
inline IrOp& getOp(IrInst& inst, uint32_t idx)
1042+
{
1043+
if (LUAU_UNLIKELY(idx >= inst.ops.size()))
1044+
{
1045+
inst.ops.resize(idx + 1);
1046+
}
1047+
return inst.ops[idx];
1048+
}
1049+
1050+
inline IrOp& getOp(IrInst* inst, uint32_t idx)
1051+
{
1052+
return getOp(*inst, idx);
1053+
}
1054+
10351055
// When IrInst operands are used, current instruction index is often required to track lifetime
10361056
inline constexpr uint32_t kInvalidInstIdx = ~0u;
10371057

@@ -1068,13 +1088,8 @@ struct IrInstHash
10681088
uint32_t h = 25;
10691089

10701090
h = mix(h, uint32_t(key.cmd));
1071-
h = mix(h, key.a);
1072-
h = mix(h, key.b);
1073-
h = mix(h, key.c);
1074-
h = mix(h, key.d);
1075-
h = mix(h, key.e);
1076-
h = mix(h, key.f);
1077-
h = mix(h, key.g);
1091+
for (size_t i = 0; i < 7; i++)
1092+
h = mix(h, i < uint32_t(key.ops.size()) ? key.ops[i] : IrOp{});
10781093

10791094
// MurmurHash2 tail
10801095
h ^= h >> 13;
@@ -1089,7 +1104,35 @@ struct IrInstEq
10891104
{
10901105
bool operator()(const IrInst& a, const IrInst& b) const
10911106
{
1092-
return a.cmd == b.cmd && a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d && a.e == b.e && a.f == b.f && a.g == b.g;
1107+
if (a.cmd != b.cmd)
1108+
return false;
1109+
if (a.ops.size() == b.ops.size())
1110+
{
1111+
for (size_t i = 0; i < a.ops.size(); i++)
1112+
if (a.ops[i] != b.ops[i])
1113+
return false;
1114+
}
1115+
else if (a.ops.size() < b.ops.size())
1116+
{
1117+
size_t i = 0;
1118+
for (; i < a.ops.size(); i++)
1119+
if (a.ops[i] != b.ops[i])
1120+
return false;
1121+
for (; i < b.ops.size(); i++)
1122+
if (b.ops[i].kind != IrOpKind::None)
1123+
return false;
1124+
}
1125+
else
1126+
{
1127+
size_t i = 0;
1128+
for (; i < b.ops.size(); i++)
1129+
if (a.ops[i] != b.ops[i])
1130+
return false;
1131+
for (; i < a.ops.size(); i++)
1132+
if (a.ops[i].kind != IrOpKind::None)
1133+
return false;
1134+
}
1135+
return true;
10931136
}
10941137
};
10951138

luau/CodeGen/include/Luau/IrDump.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,7 @@ const char* getBytecodeTypeName(uint8_t type, const char* const* userdataTypes);
3838

3939
void toString(std::string& result, const BytecodeTypes& bcTypes, const char* const* userdataTypes);
4040

41-
void toStringDetailed(
42-
IrToStringContext& ctx,
43-
const IrBlock& block,
44-
uint32_t blockIdx,
45-
const IrInst& inst,
46-
uint32_t instIdx,
47-
IncludeUseInfo includeUseInfo
48-
);
41+
void toStringDetailed(IrToStringContext& ctx, const IrBlock& block, uint32_t blockIdx, IrInst& inst, uint32_t instIdx, IncludeUseInfo includeUseInfo);
4942
void toStringDetailed(
5043
IrToStringContext& ctx,
5144
const IrBlock& block,
@@ -55,9 +48,9 @@ void toStringDetailed(
5548
IncludeRegFlowInfo includeRegFlowInfo
5649
);
5750

58-
std::string toString(const IrFunction& function, IncludeUseInfo includeUseInfo);
51+
std::string toString(IrFunction& function, IncludeUseInfo includeUseInfo);
5952

60-
std::string dump(const IrFunction& function);
53+
std::string dump(IrFunction& function);
6154

6255
std::string toDot(const IrFunction& function, bool includeInst);
6356
std::string toDotCfg(const IrFunction& function);

luau/CodeGen/include/Luau/IrUtils.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,21 +287,19 @@ void visitArguments(IrInst& inst, F&& func)
287287
if (isPseudo(inst.cmd))
288288
return;
289289

290-
func(inst.a);
291-
func(inst.b);
292-
func(inst.c);
293-
func(inst.d);
294-
func(inst.e);
295-
func(inst.f);
296-
func(inst.g);
290+
for (auto& op : inst.ops)
291+
func(op);
297292
}
298293
template<typename F>
299294
bool anyArgumentMatch(IrInst& inst, F&& func)
300295
{
301296
if (isPseudo(inst.cmd))
302297
return false;
303298

304-
return func(inst.a) || func(inst.b) || func(inst.c) || func(inst.d) || func(inst.e) || func(inst.f) || func(inst.g);
299+
for (auto& op : inst.ops)
300+
if (func(op))
301+
return true;
302+
return false;
305303
}
306304

307305
bool isGCO(uint8_t tag);
@@ -310,6 +308,9 @@ bool isGCO(uint8_t tag);
310308
bool isUserdataBytecodeType(uint8_t ty);
311309
bool isCustomUserdataBytecodeType(uint8_t ty);
312310

311+
// Check that 'ty' is 'expected' or 'any'
312+
bool isExpectedOrUnknownBytecodeType(uint8_t ty, LuauBytecodeType expected);
313+
313314
HostMetamethod tmToHostMetamethod(int tm);
314315

315316
// Manually add or remove use of an operand

0 commit comments

Comments
 (0)