mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 13:30:40 +00:00
279855df91
- A series of major optimizations to type checking performance on complex programs/types (up to two orders of magnitude speedup for programs involving huge tagged unions) - Fix a few issues encountered by UBSAN (and maybe fix s390x builds) - Fix gcc-11 test builds - Fix a rare corner case where luau_load wouldn't wake inactive threads which could result in a use-after-free due to GC - Fix CLI crash when error object that's not a string escapes to top level - Fix Makefile suffixes on macOS Co-authored-by: Rodactor <rodactor@roblox.com>
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include "Luau/TypeVar.h"
|
|
|
|
LUAU_FASTFLAG(LuauShareTxnSeen);
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
// Log of where what TypeIds we are rebinding and what they used to be
|
|
struct TxnLog
|
|
{
|
|
TxnLog()
|
|
: originalSeenSize(0)
|
|
, ownedSeen()
|
|
, sharedSeen(&ownedSeen)
|
|
{
|
|
}
|
|
|
|
explicit TxnLog(std::vector<std::pair<TypeId, TypeId>>* sharedSeen)
|
|
: originalSeenSize(sharedSeen->size())
|
|
, ownedSeen()
|
|
, sharedSeen(sharedSeen)
|
|
{
|
|
}
|
|
|
|
explicit TxnLog(const std::vector<std::pair<TypeId, TypeId>>& ownedSeen)
|
|
: originalSeenSize(ownedSeen.size())
|
|
, ownedSeen(ownedSeen)
|
|
, sharedSeen(nullptr)
|
|
{
|
|
// This is deprecated!
|
|
LUAU_ASSERT(!FFlag::LuauShareTxnSeen);
|
|
}
|
|
|
|
TxnLog(const TxnLog&) = delete;
|
|
TxnLog& operator=(const TxnLog&) = delete;
|
|
|
|
TxnLog(TxnLog&&) = default;
|
|
TxnLog& operator=(TxnLog&&) = default;
|
|
|
|
void operator()(TypeId a);
|
|
void operator()(TypePackId a);
|
|
void operator()(TableTypeVar* a);
|
|
|
|
void rollback();
|
|
|
|
void concat(TxnLog rhs);
|
|
|
|
bool haveSeen(TypeId lhs, TypeId rhs);
|
|
void pushSeen(TypeId lhs, TypeId rhs);
|
|
void popSeen(TypeId lhs, TypeId rhs);
|
|
|
|
private:
|
|
std::vector<std::pair<TypeId, TypeVar>> typeVarChanges;
|
|
std::vector<std::pair<TypePackId, TypePackVar>> typePackChanges;
|
|
std::vector<std::pair<TableTypeVar*, std::optional<TypeId>>> tableChanges;
|
|
size_t originalSeenSize;
|
|
|
|
public:
|
|
std::vector<std::pair<TypeId, TypeId>> ownedSeen; // used to avoid infinite recursion when types are cyclic
|
|
std::vector<std::pair<TypeId, TypeId>>* sharedSeen; // shared with all the descendent logs
|
|
};
|
|
|
|
} // namespace Luau
|