-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync to upstream/release/589 (#1000)
* Progress toward a diffing algorithm for types. We hope that this will be useful for writing clearer error messages. * Add a missing recursion limiter in `Unifier::tryUnifyTables`. This was causing a crash in certain situations. * Luau heap graph enumeration improvements: * Weak references are not reported * Added tag as a fallback name of non-string table links * Included top Luau function information in thread name to understand where thread might be suspended * Constant folding for `math.pi` and `math.huge` at -O2 * Optimize `string.format` and `%*` * This change makes string interpolation 1.5x-2x faster depending on the number and type of formatted components, assuming a few are using primitive types, and reduces associated GC pressure. New type checker: * Initial work toward tracking the upper and lower bounds of types accurately. Native code generation (JIT): * Add IrCmd::CHECK_TRUTHY for improved assert fast-calls * Do not compute type map for modules without types * Capture metatable+readonly state for NEW_TABLE IR instructions * Replace JUMP_CMP_ANY with CMP_ANY and existing JUMP_EQ_INT * Add support for exits to VM with reentry lock in VmExit --------- Co-authored-by: Arseny Kapoulkine <[email protected]> Co-authored-by: Vyacheslav Egorov <[email protected]>
- Loading branch information
1 parent
fff897a
commit 0b2755f
Showing
78 changed files
with
3,162 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details | ||
|
||
#pragma once | ||
|
||
#include "Luau/DenseHash.h" | ||
#include "Luau/NotNull.h" | ||
|
||
#include <optional> | ||
#include <vector> | ||
#include <utility> | ||
|
||
namespace Luau | ||
{ | ||
|
||
using TypeId = const struct Type*; | ||
using TypePackId = const struct TypePackVar*; | ||
|
||
struct BuiltinTypes; | ||
struct InternalErrorReporter; | ||
struct Scope; | ||
struct TypeArena; | ||
|
||
enum class OccursCheckResult | ||
{ | ||
Pass, | ||
Fail | ||
}; | ||
|
||
struct Unifier2 | ||
{ | ||
NotNull<TypeArena> arena; | ||
NotNull<BuiltinTypes> builtinTypes; | ||
NotNull<InternalErrorReporter> ice; | ||
|
||
int recursionCount = 0; | ||
int recursionLimit = 0; | ||
|
||
Unifier2(NotNull<TypeArena> arena, NotNull<BuiltinTypes> builtinTypes, NotNull<InternalErrorReporter> ice); | ||
|
||
/** Attempt to commit the subtype relation subTy <: superTy to the type | ||
* graph. | ||
* | ||
* @returns true if successful. | ||
* | ||
* Note that incoherent types can and will successfully be unified. We stop | ||
* when we *cannot know* how to relate the provided types, not when doing so | ||
* would narrow something down to never or broaden it to unknown. | ||
* | ||
* Presently, the only way unification can fail is if we attempt to bind one | ||
* free TypePack to another and encounter an occurs check violation. | ||
*/ | ||
bool unify(TypeId subTy, TypeId superTy); | ||
|
||
// TODO think about this one carefully. We don't do unions or intersections of type packs | ||
bool unify(TypePackId subTp, TypePackId superTp); | ||
|
||
std::optional<TypeId> generalize(NotNull<Scope> scope, TypeId ty); | ||
private: | ||
|
||
/** | ||
* @returns simplify(left | right) | ||
*/ | ||
TypeId mkUnion(TypeId left, TypeId right); | ||
|
||
/** | ||
* @returns simplify(left & right) | ||
*/ | ||
TypeId mkIntersection(TypeId left, TypeId right); | ||
|
||
// Returns true if needle occurs within haystack already. ie if we bound | ||
// needle to haystack, would a cyclic TypePack result? | ||
OccursCheckResult occursCheck(DenseHashSet<TypePackId>& seen, TypePackId needle, TypePackId haystack); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.