Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync to upstream/release/624 #1245

Merged
merged 87 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
a0b9950
Sync to upstream/release/602
aatxe Nov 3, 2023
efe133a
Merge branch 'upstream' into merge
aatxe Nov 3, 2023
4b68791
Sync to upstream/release/603
alexmccord Nov 10, 2023
6343648
Merge branch 'master' into merge
alexmccord Nov 10, 2023
e57cbf6
Merge branch 'heads/upstream' into merge
alexmccord Nov 10, 2023
674c6c4
Sync to upstream/release/604
andyfriesen Nov 17, 2023
4320153
Merge branch 'master' into merge
andyfriesen Nov 17, 2023
2d4a544
Merge branch 'upstream' into merge
andyfriesen Nov 17, 2023
557e77a
VM
Vighnesh-V Dec 2, 2023
98d2db7
add stdint import
Vighnesh-V Dec 2, 2023
e70eec0
Merge branch 'upstream' into merge
Vighnesh-V Dec 2, 2023
7985414
resolve one last merge conflict
Vighnesh-V Dec 2, 2023
c592f50
can CI handle this?
Vighnesh-V Dec 2, 2023
41669c9
Sync to upstream/release/605
Vighnesh-V Dec 2, 2023
c932b8e
remove tests for require by string
Vighnesh-V Dec 2, 2023
c48ffc3
endif
Vighnesh-V Dec 2, 2023
69728e8
Sync to upstream/release/606
vegorov-rbx Dec 8, 2023
f5441d7
Merge branch 'master' into merge
vegorov-rbx Dec 8, 2023
6068432
Merge branch 'upstream' into merge
vegorov-rbx Dec 8, 2023
139b169
Merge fix
vegorov-rbx Dec 8, 2023
f9c5cdd
Sync to upstream/release/607
aatxe Dec 15, 2023
89090a1
Merge branch 'master' into merge
aatxe Dec 15, 2023
d622618
Merge branch 'upstream' into merge
aatxe Dec 15, 2023
adea0f8
fix ubuntu build with import for cstddef in DenseHash
aatxe Dec 15, 2023
d4883bf
Merge branch 'upstream' of https://github.com/luau-lang/luau into ups…
Vighnesh-V Jan 11, 2024
0d5c842
Sync to upstream/release/608
Vighnesh-V Jan 12, 2024
74b0d00
Merge branch 'master' into merge
Vighnesh-V Jan 12, 2024
7932835
Merge branch 'upstream' into merge
Vighnesh-V Jan 12, 2024
50b4779
Sync to upstream/release/608
Vighnesh-V Jan 12, 2024
2f7509d
Merge branch 'upstream' into merge
Vighnesh-V Jan 12, 2024
38aa074
resolve memory leak in VecDeque
Vighnesh-V Jan 12, 2024
064d845
Sync to upstream/release/609
vegorov-rbx Jan 19, 2024
59a29fd
Merge branch 'master' into merge
vegorov-rbx Jan 19, 2024
2fd3da3
Merge branch 'upstream' into merge
vegorov-rbx Jan 19, 2024
0edacdd
Sync to upstream/release/610
aatxe Jan 27, 2024
e3aba92
Merge branch 'master' into merge
aatxe Jan 27, 2024
ce2665d
Merge branch 'upstream' into merge
aatxe Jan 27, 2024
dfa512b
Sync to upstream/release/611
alexmccord Feb 2, 2024
f8f0dd9
Merge branch 'master' into merge
alexmccord Feb 2, 2024
88d2b93
Merge branch 'heads/upstream' into merge
alexmccord Feb 2, 2024
5559c7f
Fix the stack-use-after-scope.
alexmccord Feb 2, 2024
1a6da94
Sync to upstream/release/612
andyfriesen Feb 9, 2024
45e72ee
Merge branch 'master' into merge
andyfriesen Feb 9, 2024
ffd9f32
Merge branch 'upstream' into merge
andyfriesen Feb 9, 2024
158d60c
Sync to upstream/release/613
vegorov-rbx Feb 16, 2024
1778950
Merge branch 'master' into merge
vegorov-rbx Feb 16, 2024
b5f2813
Merge branch 'upstream' into merge
vegorov-rbx Feb 16, 2024
22686ef
Sync to upstream/release/614
Vighnesh-V Feb 23, 2024
ccb5385
Merge branch 'master' into merge
Vighnesh-V Feb 23, 2024
0ab33af
Merge branch 'upstream' into merge
Vighnesh-V Feb 23, 2024
d4a2665
Sync to upstream/release/615
vegorov-rbx Mar 1, 2024
532fd10
Merge branch 'master' into merge
vegorov-rbx Mar 1, 2024
f36cae2
Merge branch 'upstream' into merge
vegorov-rbx Mar 1, 2024
ed4ce84
Merge fixes
vegorov-rbx Mar 1, 2024
27a05c0
Sync to upstream/release/616
aatxe Mar 8, 2024
9e1a26c
Merge branch 'master' into merge
aatxe Mar 8, 2024
1ebdfe0
Merge branch 'upstream' into merge
aatxe Mar 9, 2024
f27d4f5
Sync to upstream/release/617
alexmccord Mar 15, 2024
5e9a567
Merge branch 'master' into merge
alexmccord Mar 15, 2024
c1bbf1e
Merge branch 'heads/upstream' into merge
alexmccord Mar 15, 2024
6fff08b
Sync to upstream/release/618
andyfriesen Mar 22, 2024
a30b2ae
Merge branch 'master' into merge
andyfriesen Mar 22, 2024
4931165
Merge branch 'upstream' into merge
andyfriesen Mar 22, 2024
d8f49d6
Compiler fixes for MSVC and GCC.
andyfriesen Mar 22, 2024
fb90dc0
Sync with upstream/release/620
AmaranthineCodices Mar 30, 2024
77598ed
Merge branch 'master' into merge
AmaranthineCodices Mar 30, 2024
3e1b413
Merge branch 'upstream' into merge
AmaranthineCodices Mar 30, 2024
c730a51
Sync to upstream/release/620
Vighnesh-V Apr 5, 2024
6bef0b1
Merge branch 'master' into merge
Vighnesh-V Apr 5, 2024
2e1c040
Merge branch 'upstream' into merge
Vighnesh-V Apr 5, 2024
9cb93a9
manually fix cmake configuration error
Vighnesh-V Apr 5, 2024
0f19739
remove trailing .
Vighnesh-V Apr 5, 2024
5aa6d99
transplant game engine fix for memory safety issues in normalization …
Vighnesh-V Apr 5, 2024
0f0c0e4
Sync to upstream/release/621
vegorov-rbx Apr 12, 2024
7c346a0
Merge branch 'master' into merge
vegorov-rbx Apr 12, 2024
f97e96d
Merge branch 'upstream' into merge
vegorov-rbx Apr 12, 2024
858b93a
Sync fixup
vegorov-rbx Apr 12, 2024
67b9145
Sync to upstream/release/622
aatxe Apr 19, 2024
5cf508a
Merge branch 'master' into merge
aatxe Apr 19, 2024
641e9f6
Merge branch 'upstream' into merge
aatxe Apr 19, 2024
50a2f8d
Sync to upstream/release/623
alexmccord Apr 25, 2024
8d0a650
Merge branch 'master' into merge
alexmccord Apr 25, 2024
76ed1a5
Merge branch 'heads/upstream' into merge
alexmccord Apr 25, 2024
88dd289
Fix missing include.
alexmccord Apr 25, 2024
93468ca
Sync to upstream/release/624
andyfriesen May 3, 2024
f4ecf43
Merge branch 'master' into merge
andyfriesen May 3, 2024
1ad7b9c
Merge branch 'upstream' into merge
andyfriesen May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Analysis/include/Luau/Normalize.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ class Normalizer
TypeId negate(TypeId there);
void subtractPrimitive(NormalizedType& here, TypeId ty);
void subtractSingleton(NormalizedType& here, TypeId ty);
NormalizationResult intersectNormalWithNegationTy(TypeId toNegate, NormalizedType& intersect, bool useDeprecated = false);

// ------- Normalizing intersections
TypeId intersectionOfTops(TypeId here, TypeId there);
Expand Down
10 changes: 6 additions & 4 deletions Analysis/src/ConstraintGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1900,10 +1900,7 @@ Inference ConstraintGenerator::check(const ScopePtr& scope, AstExprGlobal* globa
return Inference{*ty, refinementArena.proposition(key, builtinTypes->truthyType)};
}
else
{
reportError(global->location, UnknownSymbol{global->name.value, UnknownSymbol::Binding});
return Inference{builtinTypes->errorRecoveryType()};
}
}

Inference ConstraintGenerator::checkIndexName(const ScopePtr& scope, const RefinementKey* key, AstExpr* indexee, const std::string& index, Location indexLocation)
Expand Down Expand Up @@ -2453,7 +2450,12 @@ ConstraintGenerator::LValueBounds ConstraintGenerator::checkLValue(const ScopePt
{
std::optional<TypeId> annotatedTy = scope->lookup(Symbol{global->name});
if (annotatedTy)
return {annotatedTy, arena->addType(BlockedType{})};
{
DefId def = dfg->getDef(global);
TypeId assignedTy = arena->addType(BlockedType{});
rootScope->lvalueTypes[def] = assignedTy;
return {annotatedTy, assignedTy};
}
else
return {annotatedTy, std::nullopt};
}
Expand Down
14 changes: 8 additions & 6 deletions Analysis/src/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,9 +1619,7 @@ std::pair<bool, std::optional<TypeId>> ConstraintSolver::tryDispatchSetIndexer(
{
if (tt->indexer)
{
if (isBlocked(tt->indexer->indexType))
return {block(tt->indexer->indexType, constraint), std::nullopt};
else if (isBlocked(tt->indexer->indexResultType))
if (isBlocked(tt->indexer->indexResultType))
return {block(tt->indexer->indexResultType, constraint), std::nullopt};

unify(constraint, indexType, tt->indexer->indexType);
Expand Down Expand Up @@ -2014,10 +2012,14 @@ bool ConstraintSolver::tryDispatchIterableTable(TypeId iteratorTy, const Iterabl
if (std::optional<TypeId> instantiatedNextFn = instantiate(builtinTypes, arena, NotNull{&limits}, constraint->scope, nextFn))
{
const FunctionType* nextFn = get<FunctionType>(*instantiatedNextFn);
LUAU_ASSERT(nextFn);
const TypePackId nextRetPack = nextFn->retTypes;

pushConstraint(constraint->scope, constraint->location, UnpackConstraint{c.variables, nextRetPack, /* resultIsLValue=*/true});
// If nextFn is nullptr, then the iterator function has an improper signature.
if (nextFn)
{
const TypePackId nextRetPack = nextFn->retTypes;
pushConstraint(constraint->scope, constraint->location, UnpackConstraint{c.variables, nextRetPack, /* resultIsLValue=*/true});
}

return true;
}
else
Expand Down
121 changes: 87 additions & 34 deletions Analysis/src/Normalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ LUAU_FASTFLAGVARIABLE(LuauNormalizeAwayUninhabitableTables, false)
LUAU_FASTFLAGVARIABLE(LuauFixNormalizeCaching, false);
LUAU_FASTFLAGVARIABLE(LuauNormalizeNotUnknownIntersection, false);
LUAU_FASTFLAGVARIABLE(LuauFixCyclicUnionsOfIntersections, false);
LUAU_FASTFLAGVARIABLE(LuauFixReduceStackPressure, false);

// This could theoretically be 2000 on amd64, but x86 requires this.
LUAU_FASTINTVARIABLE(LuauNormalizeIterationLimit, 1200);
Expand All @@ -36,6 +37,11 @@ static bool fixCyclicUnionsOfIntersections()
return FFlag::LuauFixCyclicUnionsOfIntersections || FFlag::DebugLuauDeferredConstraintResolution;
}

static bool fixReduceStackPressure()
{
return FFlag::LuauFixReduceStackPressure || FFlag::DebugLuauDeferredConstraintResolution;
}

namespace Luau
{

Expand All @@ -45,6 +51,14 @@ static bool normalizeAwayUninhabitableTables()
return FFlag::LuauNormalizeAwayUninhabitableTables || FFlag::DebugLuauDeferredConstraintResolution;
}

static bool shouldEarlyExit(NormalizationResult res)
{
// if res is hit limits, return control flow
if (res == NormalizationResult::HitLimits || res == NormalizationResult::False)
return true;
return false;
}

TypeIds::TypeIds(std::initializer_list<TypeId> tys)
{
for (TypeId ty : tys)
Expand Down Expand Up @@ -1729,6 +1743,27 @@ bool Normalizer::withinResourceLimits()
return true;
}

NormalizationResult Normalizer::intersectNormalWithNegationTy(TypeId toNegate, NormalizedType& intersect, bool useDeprecated)
{

std::optional<NormalizedType> negated;
if (useDeprecated)
{
const NormalizedType* normal = DEPRECATED_normalize(toNegate);
negated = negateNormal(*normal);
}
else
{
std::shared_ptr<const NormalizedType> normal = normalize(toNegate);
negated = negateNormal(*normal);
}

if (!negated)
return NormalizationResult::False;
intersectNormals(intersect, *negated);
return NormalizationResult::True;
}

// See above for an explaination of `ignoreSmallerTyvars`.
NormalizationResult Normalizer::unionNormalWithTy(NormalizedType& here, TypeId there, Set<TypeId>& seenSetTypes, int ignoreSmallerTyvars)
{
Expand Down Expand Up @@ -2541,8 +2576,8 @@ std::optional<TypeId> Normalizer::intersectionOfTables(TypeId here, TypeId there
state = tttv->state;

TypeLevel level = max(httv->level, tttv->level);
TableType result{state, level};

std::unique_ptr<TableType> result = nullptr;
bool hereSubThere = true;
bool thereSubHere = true;

Expand All @@ -2563,8 +2598,18 @@ std::optional<TypeId> Normalizer::intersectionOfTables(TypeId here, TypeId there
if (tprop.readTy.has_value())
{
// if the intersection of the read types of a property is uninhabited, the whole table is `never`.
if (normalizeAwayUninhabitableTables() && NormalizationResult::False == isIntersectionInhabited(*hprop.readTy, *tprop.readTy))
return {builtinTypes->neverType};
if (fixReduceStackPressure())
{
if (normalizeAwayUninhabitableTables() &&
NormalizationResult::True != isIntersectionInhabited(*hprop.readTy, *tprop.readTy))
return {builtinTypes->neverType};
}
else
{
if (normalizeAwayUninhabitableTables() &&
NormalizationResult::False == isIntersectionInhabited(*hprop.readTy, *tprop.readTy))
return {builtinTypes->neverType};
}

TypeId ty = simplifyIntersection(builtinTypes, NotNull{arena}, *hprop.readTy, *tprop.readTy).result;
prop.readTy = ty;
Expand Down Expand Up @@ -2614,14 +2659,21 @@ std::optional<TypeId> Normalizer::intersectionOfTables(TypeId here, TypeId there
// TODO: string indexers

if (prop.readTy || prop.writeTy)
result.props[name] = prop;
{
if (!result.get())
result = std::make_unique<TableType>(TableType{state, level});
result->props[name] = prop;
}
}

for (const auto& [name, tprop] : tttv->props)
{
if (httv->props.count(name) == 0)
{
result.props[name] = tprop;
if (!result.get())
result = std::make_unique<TableType>(TableType{state, level});

result->props[name] = tprop;
hereSubThere = false;
}
}
Expand All @@ -2631,18 +2683,24 @@ std::optional<TypeId> Normalizer::intersectionOfTables(TypeId here, TypeId there
// TODO: What should intersection of indexes be?
TypeId index = unionType(httv->indexer->indexType, tttv->indexer->indexType);
TypeId indexResult = intersectionType(httv->indexer->indexResultType, tttv->indexer->indexResultType);
result.indexer = {index, indexResult};
if (!result.get())
result = std::make_unique<TableType>(TableType{state, level});
result->indexer = {index, indexResult};
hereSubThere &= (httv->indexer->indexType == index) && (httv->indexer->indexResultType == indexResult);
thereSubHere &= (tttv->indexer->indexType == index) && (tttv->indexer->indexResultType == indexResult);
}
else if (httv->indexer)
{
result.indexer = httv->indexer;
if (!result.get())
result = std::make_unique<TableType>(TableType{state, level});
result->indexer = httv->indexer;
thereSubHere = false;
}
else if (tttv->indexer)
{
result.indexer = tttv->indexer;
if (!result.get())
result = std::make_unique<TableType>(TableType{state, level});
result->indexer = tttv->indexer;
hereSubThere = false;
}

Expand All @@ -2652,7 +2710,12 @@ std::optional<TypeId> Normalizer::intersectionOfTables(TypeId here, TypeId there
else if (thereSubHere)
table = ttable;
else
table = arena->addType(std::move(result));
{
if (result.get())
table = arena->addType(std::move(*result));
else
table = arena->addType(TableType{state, level});
}

if (tmtable && hmtable)
{
Expand Down Expand Up @@ -3150,19 +3213,15 @@ NormalizationResult Normalizer::intersectNormalWithTy(NormalizedType& here, Type
{
if (fixNormalizeCaching())
{
std::shared_ptr<const NormalizedType> normal = normalize(t);
std::optional<NormalizedType> negated = negateNormal(*normal);
if (!negated)
return NormalizationResult::False;
intersectNormals(here, *negated);
NormalizationResult res = intersectNormalWithNegationTy(t, here);
if (shouldEarlyExit(res))
return res;
}
else
{
const NormalizedType* normal = DEPRECATED_normalize(t);
std::optional<NormalizedType> negated = negateNormal(*normal);
if (!negated)
return NormalizationResult::False;
intersectNormals(here, *negated);
NormalizationResult res = intersectNormalWithNegationTy(t, here, /* useDeprecated */ true);
if (shouldEarlyExit(res))
return res;
}
}
else if (const UnionType* itv = get<UnionType>(t))
Expand All @@ -3171,11 +3230,9 @@ NormalizationResult Normalizer::intersectNormalWithTy(NormalizedType& here, Type
{
for (TypeId part : itv->options)
{
std::shared_ptr<const NormalizedType> normalPart = normalize(part);
std::optional<NormalizedType> negated = negateNormal(*normalPart);
if (!negated)
return NormalizationResult::False;
intersectNormals(here, *negated);
NormalizationResult res = intersectNormalWithNegationTy(part, here);
if (shouldEarlyExit(res))
return res;
}
}
else
Expand All @@ -3184,22 +3241,18 @@ NormalizationResult Normalizer::intersectNormalWithTy(NormalizedType& here, Type
{
for (TypeId part : itv->options)
{
std::shared_ptr<const NormalizedType> normalPart = normalize(part);
std::optional<NormalizedType> negated = negateNormal(*normalPart);
if (!negated)
return NormalizationResult::False;
intersectNormals(here, *negated);
NormalizationResult res = intersectNormalWithNegationTy(part, here);
if (shouldEarlyExit(res))
return res;
}
}
else
{
for (TypeId part : itv->options)
{
const NormalizedType* normalPart = DEPRECATED_normalize(part);
std::optional<NormalizedType> negated = negateNormal(*normalPart);
if (!negated)
return NormalizationResult::False;
intersectNormals(here, *negated);
NormalizationResult res = intersectNormalWithNegationTy(part, here, /* useDeprecated */ true);
if (shouldEarlyExit(res))
return res;
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Analysis/src/TypeChecker2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,9 @@ struct TypeChecker2

void visit(AstExprGlobal* expr)
{
// TODO!
NotNull<Scope> scope = stack.back();
if (!scope->lookup(expr->name))
reportError(UnknownSymbol{expr->name.value, UnknownSymbol::Binding}, expr->location);
}

void visit(AstExprVarargs* expr)
Expand Down
1 change: 1 addition & 0 deletions CLI/Compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ static bool compileFile(const char* name, CompileFormat format, Luau::CodeGen::A
{
options.includeAssembly = format != CompileFormat::CodegenIr;
options.includeIr = format != CompileFormat::CodegenAsm;
options.includeIrTypes = format != CompileFormat::CodegenAsm;
options.includeOutlinedCode = format == CompileFormat::CodegenVerbose;
}

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ if(LUAU_BUILD_TESTS)
target_link_libraries(Luau.UnitTest PRIVATE Luau.Analysis Luau.Compiler Luau.CodeGen)

target_compile_options(Luau.Conformance PRIVATE ${LUAU_OPTIONS})
target_compile_definitions(Luau.Conformance PRIVATE DOCTEST_CONFIG_DOUBLE_STRINGIFY)
target_include_directories(Luau.Conformance PRIVATE extern)
target_link_libraries(Luau.Conformance PRIVATE Luau.Analysis Luau.Compiler Luau.CodeGen Luau.VM)
if(CMAKE_SYSTEM_NAME MATCHES "Android|iOS")
Expand Down
4 changes: 4 additions & 0 deletions CodeGen/include/Luau/CodeGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ enum class CodeGenCompilationResult
CodeGenAssemblerFinalizationFailure = 7, // Failure during assembler finalization
CodeGenLoweringFailure = 8, // Lowering failed
AllocationFailed = 9, // Native codegen failed due to an allocation error

Count = 10,
};

std::string toString(const CodeGenCompilationResult& result);

struct ProtoCompilationFailure
{
CodeGenCompilationResult result = CodeGenCompilationResult::Success;
Expand Down
32 changes: 28 additions & 4 deletions CodeGen/src/BytecodeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
#include "Luau/IrUtils.h"

#include "lobject.h"
#include "lstate.h"

#include <algorithm>

#include <algorithm>

LUAU_FASTFLAG(LuauCodegenDirectUserdataFlow)
LUAU_FASTFLAG(LuauLoadTypeInfo) // Because new VM typeinfo load changes the format used by Codegen, same flag is used
LUAU_FASTFLAGVARIABLE(LuauCodegenTypeInfo, false) // New analysis is flagged separately
LUAU_FASTFLAG(LuauTypeInfoLookupImprovement)
LUAU_FASTFLAGVARIABLE(LuauCodegenVectorMispredictFix, false)

namespace Luau
{
Expand Down Expand Up @@ -771,10 +775,30 @@ void analyzeBytecodeTypes(IrFunction& function)

regTags[ra] = LBC_TYPE_ANY;

// Assuming that vector component is being indexed
// TODO: check what key is used
if (bcType.a == LBC_TYPE_VECTOR)
regTags[ra] = LBC_TYPE_NUMBER;
if (FFlag::LuauCodegenVectorMispredictFix)
{
if (bcType.a == LBC_TYPE_VECTOR)
{
TString* str = gco2ts(function.proto->k[kc].value.gc);
const char* field = getstr(str);

if (str->len == 1)
{
// Same handling as LOP_GETTABLEKS block in lvmexecute.cpp - case-insensitive comparison with "X" / "Y" / "Z"
char ch = field[0] | ' ';

if (ch == 'x' || ch == 'y' || ch == 'z')
regTags[ra] = LBC_TYPE_NUMBER;
}
}
}
else
{
// Assuming that vector component is being indexed
// TODO: check what key is used
if (bcType.a == LBC_TYPE_VECTOR)
regTags[ra] = LBC_TYPE_NUMBER;
}

bcType.result = regTags[ra];
break;
Expand Down
Loading
Loading