Skip to content

Commit

Permalink
Updated Luau from 0.607 to 0.631
Browse files Browse the repository at this point in the history
  • Loading branch information
NixAJ committed Jun 25, 2024
1 parent 332027d commit 29ece49
Show file tree
Hide file tree
Showing 305 changed files with 34,257 additions and 7,748 deletions.
2 changes: 2 additions & 0 deletions Dependencies/luau/Luau/.github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ jobs:
valgrind --tool=callgrind ./luau-compile --null -O1 bench/other/LuauPolyfillMap.lua 2>&1 | filter map-O1 | tee -a compile-output.txt
valgrind --tool=callgrind ./luau-compile --null -O2 bench/other/LuauPolyfillMap.lua 2>&1 | filter map-O2 | tee -a compile-output.txt
valgrind --tool=callgrind ./luau-compile --codegennull -O2 bench/other/LuauPolyfillMap.lua 2>&1 | filter map-O2-codegen | tee -a compile-output.txt
valgrind --tool=callgrind ./luau-compile --codegennull -O2 -t1 bench/other/LuauPolyfillMap.lua 2>&1 | filter map-O2-t1-codegen | tee -a compile-output.txt
valgrind --tool=callgrind ./luau-compile --null -O0 bench/other/regex.lua 2>&1 | filter regex-O0 | tee -a compile-output.txt
valgrind --tool=callgrind ./luau-compile --null -O1 bench/other/regex.lua 2>&1 | filter regex-O1 | tee -a compile-output.txt
valgrind --tool=callgrind ./luau-compile --null -O2 bench/other/regex.lua 2>&1 | filter regex-O2 | tee -a compile-output.txt
valgrind --tool=callgrind ./luau-compile --codegennull -O2 bench/other/regex.lua 2>&1 | filter regex-O2-codegen | tee -a compile-output.txt
valgrind --tool=callgrind ./luau-compile --codegennull -O2 -t1 bench/other/regex.lua 2>&1 | filter regex-O2-t1-codegen | tee -a compile-output.txt
- name: Checkout benchmark results
uses: actions/checkout@v3
Expand Down
5 changes: 4 additions & 1 deletion Dependencies/luau/Luau/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ jobs:
unix:
strategy:
matrix:
os: [{name: ubuntu, version: ubuntu-latest}, {name: macos, version: macos-latest}]
os: [{name: ubuntu, version: ubuntu-latest}, {name: macos, version: macos-latest}, {name: macos-arm, version: macos-14}]
name: ${{matrix.os.name}}
runs-on: ${{matrix.os.version}}
steps:
- uses: actions/checkout@v1
- name: work around ASLR+ASAN compatibility
run: sudo sysctl -w vm.mmap_rnd_bits=28
if: matrix.os.name == 'ubuntu'
- name: make tests
run: |
make -j2 config=sanitize werror=1 native=1 luau-tests
Expand Down
2 changes: 2 additions & 0 deletions Dependencies/luau/Luau/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/build/
/build[.-]*/
/cmake/
/cmake[.-]*/
/coverage/
/.vs/
/.vscode/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@ TypeId makeOption(NotNull<BuiltinTypes> builtinTypes, TypeArena& arena, TypeId t
/** Small utility function for building up type definitions from C++.
*/
TypeId makeFunction( // Monomorphic
TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> paramTypes, std::initializer_list<TypeId> retTypes);
TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> paramTypes, std::initializer_list<TypeId> retTypes,
bool checked = false);

TypeId makeFunction( // Polymorphic
TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> generics, std::initializer_list<TypePackId> genericPacks,
std::initializer_list<TypeId> paramTypes, std::initializer_list<TypeId> retTypes);
std::initializer_list<TypeId> paramTypes, std::initializer_list<TypeId> retTypes, bool checked = false);

TypeId makeFunction( // Monomorphic
TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> paramTypes, std::initializer_list<std::string> paramNames,
std::initializer_list<TypeId> retTypes);
std::initializer_list<TypeId> retTypes, bool checked = false);

TypeId makeFunction( // Polymorphic
TypeArena& arena, std::optional<TypeId> selfType, std::initializer_list<TypeId> generics, std::initializer_list<TypePackId> genericPacks,
std::initializer_list<TypeId> paramTypes, std::initializer_list<std::string> paramNames, std::initializer_list<TypeId> retTypes);
std::initializer_list<TypeId> paramTypes, std::initializer_list<std::string> paramNames, std::initializer_list<TypeId> retTypes,
bool checked = false);

void attachMagicFunction(TypeId ty, MagicFunction fn);
void attachDcrMagicFunction(TypeId ty, DcrMagicFunction fn);
Expand Down
2 changes: 0 additions & 2 deletions Dependencies/luau/Luau/Analysis/include/Luau/Clone.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ struct CloneState

SeenTypes seenTypes;
SeenTypePacks seenTypePacks;

int recursionCount = 0;
};

TypePackId clone(TypePackId tp, TypeArena& dest, CloneState& cloneState);
Expand Down
163 changes: 94 additions & 69 deletions Dependencies/luau/Luau/Analysis/include/Luau/Constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@
namespace Luau
{

enum class ValueContext;
struct Scope;

// if resultType is a freeType, assignmentType <: freeType <: resultType bounds
struct EqualityConstraint
{
TypeId resultType;
TypeId assignmentType;
};

// subType <: superType
struct SubtypeConstraint
{
Expand All @@ -40,21 +48,16 @@ struct GeneralizationConstraint
{
TypeId generalizedType;
TypeId sourceType;
};

// subType ~ inst superType
struct InstantiationConstraint
{
TypeId subType;
TypeId superType;
std::vector<TypeId> interiorTypes;
};

// variables ~ iterate iterator
// Unpack the iterator, figure out what types it iterates over, and bind those types to variables.
struct IterableConstraint
{
TypePackId iterator;
TypePackId variables;
std::vector<TypeId> variables;

const AstNode* nextAstFragment;
DenseHashMap<const AstNode*, TypeId>* astForInNextTypes;
Expand Down Expand Up @@ -90,18 +93,44 @@ struct FunctionCallConstraint
DenseHashMap<const AstNode*, TypeId>* astOverloadResolvedTypes = nullptr;
};

// result ~ prim ExpectedType SomeSingletonType MultitonType
// function_check fn argsPack
//
// If ExpectedType is potentially a singleton (an actual singleton or a union
// that contains a singleton), then result ~ SomeSingletonType
// If fn is a function type and argsPack is a partially solved
// pack of arguments to be supplied to the function, propagate the argument
// types of fn into the types of argsPack. This is used to implement
// bidirectional inference of lambda arguments.
struct FunctionCheckConstraint
{
TypeId fn;
TypePackId argsPack;

class AstExprCall* callSite = nullptr;
NotNull<DenseHashMap<const AstExpr*, TypeId>> astTypes;
NotNull<DenseHashMap<const AstExpr*, TypeId>> astExpectedTypes;
};

// prim FreeType ExpectedType PrimitiveType
//
// FreeType is bounded below by the singleton type and above by PrimitiveType
// initially. When this constraint is resolved, it will check that the bounds
// of the free type are well-formed by subtyping.
//
// If they are not well-formed, then FreeType is replaced by its lower bound
//
// If they are well-formed and ExpectedType is potentially a singleton (an
// actual singleton or a union that contains a singleton),
// then FreeType is replaced by its lower bound
//
// else result ~ MultitonType
// else FreeType is replaced by PrimitiveType
struct PrimitiveTypeConstraint
{
TypeId resultType;
TypeId expectedType;
TypeId singletonType;
TypeId multitonType;
TypeId freeType;

// potentially gets used to force the lower bound?
std::optional<TypeId> expectedType;

// the primitive type to check against
TypeId primitiveType;
};

// result ~ hasProp type "prop_name"
Expand All @@ -120,6 +149,16 @@ struct HasPropConstraint
TypeId resultType;
TypeId subjectType;
std::string prop;
ValueContext context;

// We want to track if this `HasPropConstraint` comes from a conditional.
// If it does, we're going to change the behavior of property look-up a bit.
// In particular, we're going to return `unknownType` for property lookups
// on `table` or inexact table types where the property is not present.
//
// This allows us to refine table types to have additional properties
// without reporting errors in typechecking on the property tests.
bool inConditional = false;

// HACK: We presently need types like true|false or string|"hello" when
// deciding whether a particular literal expression should have a singleton
Expand All @@ -140,77 +179,61 @@ struct HasPropConstraint
bool suppressSimplification = false;
};

// result ~ setProp subjectType ["prop", "prop2", ...] propType
// resultType ~ hasIndexer subjectType indexType
//
// If the subject is a table or table-like thing that already has the named
// property chain, we unify propType with that existing property type.
// If the subject type is a table or table-like thing that supports indexing,
// populate the type result with the result type of such an index operation.
//
// If the subject is a free table, we augment it in place.
//
// If the subject is an unsealed table, result is an augmented table that
// includes that new prop.
struct SetPropConstraint
// If the subject is not indexable, resultType is bound to errorType.
struct HasIndexerConstraint
{
TypeId resultType;
TypeId subjectType;
std::vector<std::string> path;
TypeId propType;
TypeId indexType;
};

// result ~ setIndexer subjectType indexType propType
// assignProp lhsType propName rhsType
//
// If the subject is a table or table-like thing that already has an indexer,
// unify its indexType and propType with those from this constraint.
//
// If the table is a free or unsealed table, we augment it with a new indexer.
struct SetIndexerConstraint
// Assign a value of type rhsType into the named property of lhsType.

struct AssignPropConstraint
{
TypeId resultType;
TypeId subjectType;
TypeId indexType;
TypeId lhsType;
std::string propName;
TypeId rhsType;

/// The canonical write type of the property. It is _solely_ used to
/// populate astTypes during constraint resolution. Nothing should ever
/// block on it.
TypeId propType;

// When we generate constraints, we increment the remaining prop count on
// the table if we are able. This flag informs the solver as to whether or
// not it should in turn decrement the prop count when this constraint is
// dispatched.
bool decrementPropCount = false;
};

// if negation:
// result ~ if isSingleton D then ~D else unknown where D = discriminantType
// if not negation:
// result ~ if isSingleton D then D else unknown where D = discriminantType
struct SingletonOrTopTypeConstraint
struct AssignIndexConstraint
{
TypeId resultType;
TypeId discriminantType;
bool negated;
TypeId lhsType;
TypeId indexType;
TypeId rhsType;

/// The canonical write type of the property. It is _solely_ used to
/// populate astTypes during constraint resolution. Nothing should ever
/// block on it.
TypeId propType;
};

// resultType ~ unpack sourceTypePack
// resultTypes ~ unpack sourceTypePack
//
// Similar to PackSubtypeConstraint, but with one important difference: If the
// sourcePack is blocked, this constraint blocks.
struct UnpackConstraint
{
TypePackId resultPack;
std::vector<TypeId> resultPack;
TypePackId sourcePack;

// UnpackConstraint is sometimes used to resolve the types of assignments.
// When this is the case, any LocalTypes in resultPack can have their
// domains extended by the corresponding type from sourcePack.
bool resultIsLValue = false;
};

// resultType ~ T0 op T1 op ... op TN
//
// op is either union or intersection. If any of the input types are blocked,
// this constraint will block unless forced.
struct SetOpConstraint
{
enum
{
Intersection,
Union
} mode;

TypeId resultType;
std::vector<TypeId> types;
};

// ty ~ reduce ty
Expand All @@ -229,9 +252,9 @@ struct ReducePackConstraint
TypePackId tp;
};

using ConstraintV = Variant<SubtypeConstraint, PackSubtypeConstraint, GeneralizationConstraint, InstantiationConstraint, IterableConstraint,
NameConstraint, TypeAliasExpansionConstraint, FunctionCallConstraint, PrimitiveTypeConstraint, HasPropConstraint, SetPropConstraint,
SetIndexerConstraint, SingletonOrTopTypeConstraint, UnpackConstraint, SetOpConstraint, ReduceConstraint, ReducePackConstraint>;
using ConstraintV = Variant<SubtypeConstraint, PackSubtypeConstraint, GeneralizationConstraint, IterableConstraint, NameConstraint,
TypeAliasExpansionConstraint, FunctionCallConstraint, FunctionCheckConstraint, PrimitiveTypeConstraint, HasPropConstraint, HasIndexerConstraint,
AssignPropConstraint, AssignIndexConstraint, UnpackConstraint, ReduceConstraint, ReducePackConstraint, EqualityConstraint>;

struct Constraint
{
Expand All @@ -246,11 +269,13 @@ struct Constraint

std::vector<NotNull<Constraint>> dependencies;

DenseHashSet<TypeId> getFreeTypes() const;
DenseHashSet<TypeId> getMaybeMutatedFreeTypes() const;
};

using ConstraintPtr = std::unique_ptr<Constraint>;

bool isReferenceCountedType(const TypeId typ);

inline Constraint& asMutable(const Constraint& c)
{
return const_cast<Constraint&>(c);
Expand Down
Loading

0 comments on commit 29ece49

Please sign in to comment.