Skip to content

Commit 9a00fcd

Browse files
committed
Update Luau to 0.650
1 parent 309572e commit 9a00fcd

30 files changed

+1204
-63
lines changed

luau/Ast/include/Luau/Ast.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,7 @@ class AstVisitor
14901490
}
14911491
};
14921492

1493+
bool isLValue(const AstExpr*);
14931494
AstName getIdentifier(AstExpr*);
14941495
Location getLocation(const AstTypeList& typeList);
14951496

@@ -1520,4 +1521,4 @@ struct hash<Luau::AstName>
15201521
}
15211522
};
15221523

1523-
} // namespace std
1524+
} // namespace std

luau/Ast/include/Luau/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class Parser
217217
AstType* parseTableType(bool inDeclarationContext = false);
218218
AstTypeOrPack parseSimpleType(bool allowPack, bool inDeclarationContext = false);
219219

220-
AstTypeOrPack parseTypeOrPack();
220+
AstTypeOrPack parseSimpleTypeOrPack();
221221
AstType* parseType(bool inDeclarationContext = false);
222222

223223
AstTypePack* parseTypePack();

luau/Ast/src/Ast.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,14 @@ void AstTypePackGeneric::visit(AstVisitor* visitor)
11461146
visitor->visit(this);
11471147
}
11481148

1149+
bool isLValue(const AstExpr* expr)
1150+
{
1151+
return expr->is<AstExprLocal>()
1152+
|| expr->is<AstExprGlobal>()
1153+
|| expr->is<AstExprIndexName>()
1154+
|| expr->is<AstExprIndexExpr>();
1155+
}
1156+
11491157
AstName getIdentifier(AstExpr* node)
11501158
{
11511159
if (AstExprGlobal* expr = node->as<AstExprGlobal>())
@@ -1170,4 +1178,4 @@ Location getLocation(const AstTypeList& typeList)
11701178
return result;
11711179
}
11721180

1173-
} // namespace Luau
1181+
} // namespace Luau

luau/Ast/src/Parser.cpp

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <errno.h>
1010
#include <limits.h>
11+
#include <string.h>
1112

1213
LUAU_FASTINTVARIABLE(LuauRecursionLimit, 1000)
1314
LUAU_FASTINTVARIABLE(LuauTypeLengthLimit, 1000)
@@ -16,11 +17,12 @@ LUAU_FASTINTVARIABLE(LuauParseErrorLimit, 100)
1617
// Warning: If you are introducing new syntax, ensure that it is behind a separate
1718
// flag so that we don't break production games by reverting syntax changes.
1819
// See docs/SyntaxChanges.md for an explanation.
19-
LUAU_FASTFLAGVARIABLE(LuauSolverV2, false)
20-
LUAU_FASTFLAGVARIABLE(LuauNativeAttribute, false)
21-
LUAU_FASTFLAGVARIABLE(LuauAttributeSyntaxFunExpr, false)
22-
LUAU_FASTFLAGVARIABLE(LuauUserDefinedTypeFunctionsSyntax2, false)
23-
LUAU_FASTFLAGVARIABLE(LuauAllowFragmentParsing, false)
20+
LUAU_FASTFLAGVARIABLE(LuauSolverV2)
21+
LUAU_FASTFLAGVARIABLE(LuauNativeAttribute)
22+
LUAU_FASTFLAGVARIABLE(LuauAttributeSyntaxFunExpr)
23+
LUAU_FASTFLAGVARIABLE(LuauUserDefinedTypeFunctionsSyntax2)
24+
LUAU_FASTFLAGVARIABLE(LuauAllowFragmentParsing)
25+
LUAU_FASTFLAGVARIABLE(LuauPortableStringZeroCheck)
2426

2527
namespace Luau
2628
{
@@ -188,9 +190,18 @@ Parser::Parser(const char* buffer, size_t bufferSize, AstNameTable& names, Alloc
188190
functionStack.reserve(8);
189191
functionStack.push_back(top);
190192

191-
nameSelf = names.addStatic("self");
192-
nameNumber = names.addStatic("number");
193-
nameError = names.addStatic(kParseNameError);
193+
if (FFlag::LuauAllowFragmentParsing)
194+
{
195+
nameSelf = names.getOrAdd("self");
196+
nameNumber = names.getOrAdd("number");
197+
nameError = names.getOrAdd(kParseNameError);
198+
}
199+
else
200+
{
201+
nameSelf = names.addStatic("self");
202+
nameNumber = names.addStatic("number");
203+
nameError = names.addStatic(kParseNameError);
204+
}
194205
nameNil = names.getOrAdd("nil"); // nil is a reserved keyword
195206

196207
matchRecoveryStopOnToken.assign(Lexeme::Type::Reserved_END, 0);
@@ -1122,7 +1133,8 @@ AstStat* Parser::parseDeclaration(const Location& start, const AstArray<AstAttr*
11221133
AstType* type = parseType();
11231134

11241135
// since AstName contains a char*, it can't contain null
1125-
bool containsNull = chars && (strnlen(chars->data, chars->size) < chars->size);
1136+
bool containsNull = chars && (FFlag::LuauPortableStringZeroCheck ? memchr(chars->data, 0, chars->size) != nullptr
1137+
: strnlen(chars->data, chars->size) < chars->size);
11261138

11271139
if (chars && !containsNull)
11281140
{
@@ -1600,7 +1612,8 @@ AstType* Parser::parseTableType(bool inDeclarationContext)
16001612
AstType* type = parseType();
16011613

16021614
// since AstName contains a char*, it can't contain null
1603-
bool containsNull = chars && (strnlen(chars->data, chars->size) < chars->size);
1615+
bool containsNull = chars && (FFlag::LuauPortableStringZeroCheck ? memchr(chars->data, 0, chars->size) != nullptr
1616+
: strnlen(chars->data, chars->size) < chars->size);
16041617

16051618
if (chars && !containsNull)
16061619
props.push_back(AstTableProp{AstName(chars->data), begin.location, type, access, accessLocation});
@@ -1849,7 +1862,7 @@ AstType* Parser::parseTypeSuffix(AstType* type, const Location& begin)
18491862
ParseError::raise(begin, "Composite type was not an intersection or union.");
18501863
}
18511864

1852-
AstTypeOrPack Parser::parseTypeOrPack()
1865+
AstTypeOrPack Parser::parseSimpleTypeOrPack()
18531866
{
18541867
unsigned int oldRecursionCount = recursionCounter;
18551868
// recursion counter is incremented in parseSimpleType
@@ -2864,7 +2877,7 @@ std::pair<AstArray<AstGenericType>, AstArray<AstGenericTypePack>> Parser::parseG
28642877
}
28652878
else
28662879
{
2867-
auto [type, typePack] = parseTypeOrPack();
2880+
auto [type, typePack] = parseSimpleTypeOrPack();
28682881

28692882
if (type)
28702883
report(type->location, "Expected type pack after '=', got type");
@@ -2941,7 +2954,7 @@ AstArray<AstTypeOrPack> Parser::parseTypeParams()
29412954
}
29422955
else if (lexer.current().type == '(')
29432956
{
2944-
auto [type, typePack] = parseTypeOrPack();
2957+
auto [type, typePack] = parseSimpleTypeOrPack();
29452958

29462959
if (typePack)
29472960
parameters.push_back({{}, typePack});

luau/Ast/src/TimeTrace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <time.h>
2828

29-
LUAU_FASTFLAGVARIABLE(DebugLuauTimeTracing, false)
29+
LUAU_FASTFLAGVARIABLE(DebugLuauTimeTracing)
3030
namespace Luau
3131
{
3232
namespace TimeTrace

luau/CodeGen/src/BytecodeAnalysis.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,40 @@ static void applyBuiltinCall(int bfid, BytecodeTypes& types)
515515
types.a = LBC_TYPE_TABLE;
516516
types.b = LBC_TYPE_TABLE;
517517
break;
518+
case LBF_VECTOR_MAGNITUDE:
519+
types.result = LBC_TYPE_NUMBER;
520+
types.a = LBC_TYPE_VECTOR;
521+
break;
522+
case LBF_VECTOR_NORMALIZE:
523+
types.result = LBC_TYPE_VECTOR;
524+
types.a = LBC_TYPE_VECTOR;
525+
break;
526+
case LBF_VECTOR_CROSS:
527+
types.result = LBC_TYPE_VECTOR;
528+
types.a = LBC_TYPE_VECTOR;
529+
types.b = LBC_TYPE_VECTOR;
530+
break;
531+
case LBF_VECTOR_DOT:
532+
types.result = LBC_TYPE_NUMBER;
533+
types.a = LBC_TYPE_VECTOR;
534+
types.b = LBC_TYPE_VECTOR;
535+
break;
536+
case LBF_VECTOR_FLOOR:
537+
case LBF_VECTOR_CEIL:
538+
case LBF_VECTOR_ABS:
539+
case LBF_VECTOR_SIGN:
540+
case LBF_VECTOR_CLAMP:
541+
types.result = LBC_TYPE_VECTOR;
542+
types.a = LBC_TYPE_VECTOR;
543+
types.b = LBC_TYPE_VECTOR;
544+
break;
545+
case LBF_VECTOR_MIN:
546+
case LBF_VECTOR_MAX:
547+
types.result = LBC_TYPE_VECTOR;
548+
types.a = LBC_TYPE_VECTOR;
549+
types.b = LBC_TYPE_VECTOR;
550+
types.c = LBC_TYPE_VECTOR; // We can mark optional arguments
551+
break;
518552
}
519553
}
520554

luau/CodeGen/src/CodeGen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
#endif
4242
#endif
4343

44-
LUAU_FASTFLAGVARIABLE(DebugCodegenNoOpt, false)
45-
LUAU_FASTFLAGVARIABLE(DebugCodegenOptSize, false)
46-
LUAU_FASTFLAGVARIABLE(DebugCodegenSkipNumbering, false)
44+
LUAU_FASTFLAGVARIABLE(DebugCodegenNoOpt)
45+
LUAU_FASTFLAGVARIABLE(DebugCodegenOptSize)
46+
LUAU_FASTFLAGVARIABLE(DebugCodegenSkipNumbering)
4747

4848
// Per-module IR instruction count limit
4949
LUAU_FASTINTVARIABLE(CodegenHeuristicsInstructionLimit, 1'048'576) // 1 M

luau/CodeGen/src/CodeGenUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,10 @@ Udata* newUserdata(lua_State* L, size_t s, int tag)
226226

227227
if (Table* h = L->global->udatamt[tag])
228228
{
229-
u->metatable = h;
229+
// currently, we always allocate unmarked objects, so forward barrier can be skipped
230+
LUAU_ASSERT(!isblack(obj2gco(u)));
230231

231-
luaC_objbarrier(L, u, h);
232+
u->metatable = h;
232233
}
233234

234235
return u;

luau/CodeGen/src/IrRegAllocA64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <string.h>
1212

13-
LUAU_FASTFLAGVARIABLE(DebugCodegenChaosA64, false)
13+
LUAU_FASTFLAGVARIABLE(DebugCodegenChaosA64)
1414

1515
namespace Luau
1616
{

0 commit comments

Comments
 (0)