Skip to content

Commit

Permalink
v0.8.1+luau611
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Feb 3, 2024
1 parent 3cacc8c commit 49b3643
Show file tree
Hide file tree
Showing 30 changed files with 912 additions and 119 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "luau0-src"
version = "0.8.0+luau609"
version = "0.8.1+luau611"
authors = ["Aleksandr Orlenko <[email protected]>"]
edition = "2021"
repository = "https://github.com/khvzak/luau-src-rs"
Expand Down
24 changes: 5 additions & 19 deletions luau/Ast/include/Luau/Ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class AstExprFunction : public AstExpr
AstExprFunction(const Location& location, const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks,
AstLocal* self, const AstArray<AstLocal*>& args, bool vararg, const Location& varargLocation, AstStatBlock* body, size_t functionDepth,
const AstName& debugname, const std::optional<AstTypeList>& returnAnnotation = {}, AstTypePack* varargAnnotation = nullptr,
bool DEPRECATED_hasEnd = false, const std::optional<Location>& argLocation = std::nullopt);
const std::optional<Location>& argLocation = std::nullopt);

void visit(AstVisitor* visitor) override;

Expand All @@ -406,8 +406,6 @@ class AstExprFunction : public AstExpr

AstName debugname;

// TODO clip with FFlag::LuauClipExtraHasEndProps
bool DEPRECATED_hasEnd = false;
std::optional<Location> argLocation;
};

Expand Down Expand Up @@ -573,7 +571,7 @@ class AstStatIf : public AstStat
LUAU_RTTI(AstStatIf)

AstStatIf(const Location& location, AstExpr* condition, AstStatBlock* thenbody, AstStat* elsebody, const std::optional<Location>& thenLocation,
const std::optional<Location>& elseLocation, bool DEPRECATED_hasEnd);
const std::optional<Location>& elseLocation);

void visit(AstVisitor* visitor) override;

Expand All @@ -585,17 +583,14 @@ class AstStatIf : public AstStat

// Active for 'elseif' as well
std::optional<Location> elseLocation;

// TODO clip with FFlag::LuauClipExtraHasEndProps
bool DEPRECATED_hasEnd = false;
};

class AstStatWhile : public AstStat
{
public:
LUAU_RTTI(AstStatWhile)

AstStatWhile(const Location& location, AstExpr* condition, AstStatBlock* body, bool hasDo, const Location& doLocation, bool DEPRECATED_hasEnd);
AstStatWhile(const Location& location, AstExpr* condition, AstStatBlock* body, bool hasDo, const Location& doLocation);

void visit(AstVisitor* visitor) override;

Expand All @@ -604,9 +599,6 @@ class AstStatWhile : public AstStat

bool hasDo = false;
Location doLocation;

// TODO clip with FFlag::LuauClipExtraHasEndProps
bool DEPRECATED_hasEnd = false;
};

class AstStatRepeat : public AstStat
Expand Down Expand Up @@ -690,7 +682,7 @@ class AstStatFor : public AstStat
LUAU_RTTI(AstStatFor)

AstStatFor(const Location& location, AstLocal* var, AstExpr* from, AstExpr* to, AstExpr* step, AstStatBlock* body, bool hasDo,
const Location& doLocation, bool DEPRECATED_hasEnd);
const Location& doLocation);

void visit(AstVisitor* visitor) override;

Expand All @@ -702,9 +694,6 @@ class AstStatFor : public AstStat

bool hasDo = false;
Location doLocation;

// TODO clip with FFlag::LuauClipExtraHasEndProps
bool DEPRECATED_hasEnd = false;
};

class AstStatForIn : public AstStat
Expand All @@ -713,7 +702,7 @@ class AstStatForIn : public AstStat
LUAU_RTTI(AstStatForIn)

AstStatForIn(const Location& location, const AstArray<AstLocal*>& vars, const AstArray<AstExpr*>& values, AstStatBlock* body, bool hasIn,
const Location& inLocation, bool hasDo, const Location& doLocation, bool DEPRECATED_hasEnd);
const Location& inLocation, bool hasDo, const Location& doLocation);

void visit(AstVisitor* visitor) override;

Expand All @@ -726,9 +715,6 @@ class AstStatForIn : public AstStat

bool hasDo = false;
Location doLocation;

// TODO clip with FFlag::LuauClipExtraHasEndProps
bool DEPRECATED_hasEnd = false;
};

class AstStatAssign : public AstStat
Expand Down
15 changes: 5 additions & 10 deletions luau/Ast/src/Ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void AstExprIndexExpr::visit(AstVisitor* visitor)

AstExprFunction::AstExprFunction(const Location& location, const AstArray<AstGenericType>& generics, const AstArray<AstGenericTypePack>& genericPacks,
AstLocal* self, const AstArray<AstLocal*>& args, bool vararg, const Location& varargLocation, AstStatBlock* body, size_t functionDepth,
const AstName& debugname, const std::optional<AstTypeList>& returnAnnotation, AstTypePack* varargAnnotation, bool DEPRECATED_hasEnd,
const AstName& debugname, const std::optional<AstTypeList>& returnAnnotation, AstTypePack* varargAnnotation,
const std::optional<Location>& argLocation)
: AstExpr(ClassIndex(), location)
, generics(generics)
Expand All @@ -177,7 +177,6 @@ AstExprFunction::AstExprFunction(const Location& location, const AstArray<AstGen
, body(body)
, functionDepth(functionDepth)
, debugname(debugname)
, DEPRECATED_hasEnd(DEPRECATED_hasEnd)
, argLocation(argLocation)
{
}
Expand Down Expand Up @@ -395,14 +394,13 @@ void AstStatBlock::visit(AstVisitor* visitor)
}

AstStatIf::AstStatIf(const Location& location, AstExpr* condition, AstStatBlock* thenbody, AstStat* elsebody,
const std::optional<Location>& thenLocation, const std::optional<Location>& elseLocation, bool DEPRECATED_hasEnd)
const std::optional<Location>& thenLocation, const std::optional<Location>& elseLocation)
: AstStat(ClassIndex(), location)
, condition(condition)
, thenbody(thenbody)
, elsebody(elsebody)
, thenLocation(thenLocation)
, elseLocation(elseLocation)
, DEPRECATED_hasEnd(DEPRECATED_hasEnd)
{
}

Expand All @@ -418,13 +416,12 @@ void AstStatIf::visit(AstVisitor* visitor)
}
}

AstStatWhile::AstStatWhile(const Location& location, AstExpr* condition, AstStatBlock* body, bool hasDo, const Location& doLocation, bool DEPRECATED_hasEnd)
AstStatWhile::AstStatWhile(const Location& location, AstExpr* condition, AstStatBlock* body, bool hasDo, const Location& doLocation)
: AstStat(ClassIndex(), location)
, condition(condition)
, body(body)
, hasDo(hasDo)
, doLocation(doLocation)
, DEPRECATED_hasEnd(DEPRECATED_hasEnd)
{
}

Expand Down Expand Up @@ -526,7 +523,7 @@ void AstStatLocal::visit(AstVisitor* visitor)
}

AstStatFor::AstStatFor(const Location& location, AstLocal* var, AstExpr* from, AstExpr* to, AstExpr* step, AstStatBlock* body, bool hasDo,
const Location& doLocation, bool DEPRECATED_hasEnd)
const Location& doLocation)
: AstStat(ClassIndex(), location)
, var(var)
, from(from)
Expand All @@ -535,7 +532,6 @@ AstStatFor::AstStatFor(const Location& location, AstLocal* var, AstExpr* from, A
, body(body)
, hasDo(hasDo)
, doLocation(doLocation)
, DEPRECATED_hasEnd(DEPRECATED_hasEnd)
{
}

Expand All @@ -557,7 +553,7 @@ void AstStatFor::visit(AstVisitor* visitor)
}

AstStatForIn::AstStatForIn(const Location& location, const AstArray<AstLocal*>& vars, const AstArray<AstExpr*>& values, AstStatBlock* body,
bool hasIn, const Location& inLocation, bool hasDo, const Location& doLocation, bool DEPRECATED_hasEnd)
bool hasIn, const Location& inLocation, bool hasDo, const Location& doLocation)
: AstStat(ClassIndex(), location)
, vars(vars)
, values(values)
Expand All @@ -566,7 +562,6 @@ AstStatForIn::AstStatForIn(const Location& location, const AstArray<AstLocal*>&
, inLocation(inLocation)
, hasDo(hasDo)
, doLocation(doLocation)
, DEPRECATED_hasEnd(DEPRECATED_hasEnd)
{
}

Expand Down
48 changes: 17 additions & 31 deletions luau/Ast/src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ LUAU_FASTINTVARIABLE(LuauParseErrorLimit, 100)
// Warning: If you are introducing new syntax, ensure that it is behind a separate
// flag so that we don't break production games by reverting syntax changes.
// See docs/SyntaxChanges.md for an explanation.
LUAU_FASTFLAGVARIABLE(LuauClipExtraHasEndProps, false)
LUAU_FASTFLAG(LuauCheckedFunctionSyntax)
LUAU_FASTFLAGVARIABLE(LuauReadWritePropertySyntax, false)

Expand Down Expand Up @@ -373,18 +372,15 @@ AstStat* Parser::parseIf()
AstStat* elsebody = nullptr;
Location end = start;
std::optional<Location> elseLocation;
bool DEPRECATED_hasEnd = false;

if (lexer.current().type == Lexeme::ReservedElseif)
{
if (FFlag::LuauClipExtraHasEndProps)
thenbody->hasEnd = true;
thenbody->hasEnd = true;
unsigned int oldRecursionCount = recursionCounter;
incrementRecursionCounter("elseif");
elseLocation = lexer.current().location;
elsebody = parseIf();
end = elsebody->location;
DEPRECATED_hasEnd = elsebody->as<AstStatIf>()->DEPRECATED_hasEnd;
recursionCounter = oldRecursionCount;
}
else
Expand All @@ -393,8 +389,7 @@ AstStat* Parser::parseIf()

if (lexer.current().type == Lexeme::ReservedElse)
{
if (FFlag::LuauClipExtraHasEndProps)
thenbody->hasEnd = true;
thenbody->hasEnd = true;
elseLocation = lexer.current().location;
matchThenElse = lexer.current();
nextLexeme();
Expand All @@ -406,21 +401,17 @@ AstStat* Parser::parseIf()
end = lexer.current().location;

bool hasEnd = expectMatchEndAndConsume(Lexeme::ReservedEnd, matchThenElse);
DEPRECATED_hasEnd = hasEnd;

if (FFlag::LuauClipExtraHasEndProps)
if (elsebody)
{
if (elsebody)
{
if (AstStatBlock* elseBlock = elsebody->as<AstStatBlock>())
elseBlock->hasEnd = hasEnd;
}
else
thenbody->hasEnd = hasEnd;
if (AstStatBlock* elseBlock = elsebody->as<AstStatBlock>())
elseBlock->hasEnd = hasEnd;
}
else
thenbody->hasEnd = hasEnd;
}

return allocator.alloc<AstStatIf>(Location(start, end), cond, thenbody, elsebody, thenLocation, elseLocation, DEPRECATED_hasEnd);
return allocator.alloc<AstStatIf>(Location(start, end), cond, thenbody, elsebody, thenLocation, elseLocation);
}

// while exp do block end
Expand All @@ -444,10 +435,9 @@ AstStat* Parser::parseWhile()
Location end = lexer.current().location;

bool hasEnd = expectMatchEndAndConsume(Lexeme::ReservedEnd, matchDo);
if (FFlag::LuauClipExtraHasEndProps)
body->hasEnd = hasEnd;
body->hasEnd = hasEnd;

return allocator.alloc<AstStatWhile>(Location(start, end), cond, body, hasDo, matchDo.location, hasEnd);
return allocator.alloc<AstStatWhile>(Location(start, end), cond, body, hasDo, matchDo.location);
}

// repeat block until exp
Expand All @@ -467,8 +457,7 @@ AstStat* Parser::parseRepeat()
functionStack.back().loopDepth--;

bool hasUntil = expectMatchEndAndConsume(Lexeme::ReservedUntil, matchRepeat);
if (FFlag::LuauClipExtraHasEndProps)
body->hasEnd = hasUntil;
body->hasEnd = hasUntil;

AstExpr* cond = parseExpr();

Expand Down Expand Up @@ -565,10 +554,9 @@ AstStat* Parser::parseFor()
Location end = lexer.current().location;

bool hasEnd = expectMatchEndAndConsume(Lexeme::ReservedEnd, matchDo);
if (FFlag::LuauClipExtraHasEndProps)
body->hasEnd = hasEnd;
body->hasEnd = hasEnd;

return allocator.alloc<AstStatFor>(Location(start, end), var, from, to, step, body, hasDo, matchDo.location, hasEnd);
return allocator.alloc<AstStatFor>(Location(start, end), var, from, to, step, body, hasDo, matchDo.location);
}
else
{
Expand Down Expand Up @@ -609,11 +597,10 @@ AstStat* Parser::parseFor()
Location end = lexer.current().location;

bool hasEnd = expectMatchEndAndConsume(Lexeme::ReservedEnd, matchDo);
if (FFlag::LuauClipExtraHasEndProps)
body->hasEnd = hasEnd;
body->hasEnd = hasEnd;

return allocator.alloc<AstStatForIn>(
Location(start, end), copy(vars), copy(values), body, hasIn, inLocation, hasDo, matchDo.location, hasEnd);
Location(start, end), copy(vars), copy(values), body, hasIn, inLocation, hasDo, matchDo.location);
}
}

Expand Down Expand Up @@ -1100,11 +1087,10 @@ std::pair<AstExprFunction*, AstLocal*> Parser::parseFunctionBody(
Location end = lexer.current().location;

bool hasEnd = expectMatchEndAndConsume(Lexeme::ReservedEnd, matchFunction);
if (FFlag::LuauClipExtraHasEndProps)
body->hasEnd = hasEnd;
body->hasEnd = hasEnd;

return {allocator.alloc<AstExprFunction>(Location(start, end), generics, genericPacks, self, vars, vararg, varargLocation, body,
functionStack.size(), debugname, typelist, varargAnnotation, hasEnd, argLocation),
functionStack.size(), debugname, typelist, varargAnnotation, argLocation),
funLocal};
}

Expand Down
5 changes: 5 additions & 0 deletions luau/CodeGen/include/Luau/AssemblyBuilderA64.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ class AssemblyBuilderA64
void fsqrt(RegisterA64 dst, RegisterA64 src);
void fsub(RegisterA64 dst, RegisterA64 src1, RegisterA64 src2);

void ins_4s(RegisterA64 dst, RegisterA64 src, uint8_t index);
void ins_4s(RegisterA64 dst, uint8_t dstIndex, RegisterA64 src, uint8_t srcIndex);
void dup_4s(RegisterA64 dst, RegisterA64 src, uint8_t index);

// Floating-point rounding and conversions
void frinta(RegisterA64 dst, RegisterA64 src);
void frintm(RegisterA64 dst, RegisterA64 src);
Expand Down Expand Up @@ -207,6 +211,7 @@ class AssemblyBuilderA64
void placeSR3(const char* name, RegisterA64 dst, RegisterA64 src1, RegisterA64 src2, uint8_t op, int shift = 0, int N = 0);
void placeSR2(const char* name, RegisterA64 dst, RegisterA64 src, uint8_t op, uint8_t op2 = 0);
void placeR3(const char* name, RegisterA64 dst, RegisterA64 src1, RegisterA64 src2, uint8_t op, uint8_t op2);
void placeR3(const char* name, RegisterA64 dst, RegisterA64 src1, RegisterA64 src2, uint8_t sizes, uint8_t op, uint8_t op2);
void placeR1(const char* name, RegisterA64 dst, RegisterA64 src, uint32_t op);
void placeI12(const char* name, RegisterA64 dst, RegisterA64 src1, int src2, uint8_t op);
void placeI16(const char* name, RegisterA64 dst, int src, uint8_t op, int shift = 0);
Expand Down
11 changes: 11 additions & 0 deletions luau/CodeGen/include/Luau/AssemblyBuilderX64.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,18 @@ class AssemblyBuilderX64
void vaddss(OperandX64 dst, OperandX64 src1, OperandX64 src2);

void vsubsd(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vsubps(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vmulsd(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vmulps(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vdivsd(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vdivps(OperandX64 dst, OperandX64 src1, OperandX64 src2);

void vandps(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vandpd(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vandnpd(OperandX64 dst, OperandX64 src1, OperandX64 src2);

void vxorpd(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vorps(OperandX64 dst, OperandX64 src1, OperandX64 src2);
void vorpd(OperandX64 dst, OperandX64 src1, OperandX64 src2);

void vucomisd(OperandX64 src1, OperandX64 src2);
Expand Down Expand Up @@ -159,6 +164,9 @@ class AssemblyBuilderX64

void vblendvpd(RegisterX64 dst, RegisterX64 src1, OperandX64 mask, RegisterX64 src3);

void vpshufps(RegisterX64 dst, RegisterX64 src1, OperandX64 src2, uint8_t shuffle);
void vpinsrd(RegisterX64 dst, RegisterX64 src1, OperandX64 src2, uint8_t offset);

// Run final checks
bool finalize();

Expand All @@ -176,9 +184,11 @@ class AssemblyBuilderX64
}

// Constant allocation (uses rip-relative addressing)
OperandX64 i32(int32_t value);
OperandX64 i64(int64_t value);
OperandX64 f32(float value);
OperandX64 f64(double value);
OperandX64 u32x4(uint32_t x, uint32_t y, uint32_t z, uint32_t w);
OperandX64 f32x4(float x, float y, float z, float w);
OperandX64 f64x2(double x, double y);
OperandX64 bytes(const void* ptr, size_t size, size_t align = 8);
Expand Down Expand Up @@ -260,6 +270,7 @@ class AssemblyBuilderX64
std::vector<Label> pendingLabels;
std::vector<uint32_t> labelLocations;

DenseHashMap<uint32_t, int32_t> constCache32;
DenseHashMap<uint64_t, int32_t> constCache64;

bool finalized = false;
Expand Down
Loading

0 comments on commit 49b3643

Please sign in to comment.