mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 13:00:38 +00:00
47ad768c69
# What's Changed ## New Type Solver - Many fixes to crashes, assertions, and hangs - Binary type family aliases now have a default parameter - Added a debug check for unsolved types escaping the constraint solver - Overloaded functions are no longer inferred - Unification creates additional subtyping constraints for blocked types - Attempt to guess the result type for type families that are too large to resolve timely ## Native Code Generation - Fixed `IrCmd::CHECK_TRUTHY` lowering in a specific case - Detailed compilation errors are now supported - More work on the new allocator --- # Internal Contributors Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: James McNellis <jmcnellis@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com>
137 lines
3.5 KiB
C++
137 lines
3.5 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
// Compiler codegen control macros
|
|
#ifdef _MSC_VER
|
|
#define LUAU_NORETURN __declspec(noreturn)
|
|
#define LUAU_NOINLINE __declspec(noinline)
|
|
#define LUAU_FORCEINLINE __forceinline
|
|
#define LUAU_LIKELY(x) x
|
|
#define LUAU_UNLIKELY(x) x
|
|
#define LUAU_UNREACHABLE() __assume(false)
|
|
#define LUAU_DEBUGBREAK() __debugbreak()
|
|
#else
|
|
#define LUAU_NORETURN __attribute__((__noreturn__))
|
|
#define LUAU_NOINLINE __attribute__((noinline))
|
|
#define LUAU_FORCEINLINE inline __attribute__((always_inline))
|
|
#define LUAU_LIKELY(x) __builtin_expect(x, 1)
|
|
#define LUAU_UNLIKELY(x) __builtin_expect(x, 0)
|
|
#define LUAU_UNREACHABLE() __builtin_unreachable()
|
|
#define LUAU_DEBUGBREAK() __builtin_trap()
|
|
#endif
|
|
|
|
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
#define LUAU_BIG_ENDIAN
|
|
#endif
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
using AssertHandler = int (*)(const char* expression, const char* file, int line, const char* function);
|
|
|
|
inline AssertHandler& assertHandler()
|
|
{
|
|
static AssertHandler handler = nullptr;
|
|
return handler;
|
|
}
|
|
|
|
// We want 'inline' to correctly link this function declared in the header
|
|
// But we also want to prevent compiler from inlining this function when optimization and assertions are enabled together
|
|
// Reason for that is that compilation times can increase significantly in such a configuration
|
|
LUAU_NOINLINE inline int assertCallHandler(const char* expression, const char* file, int line, const char* function)
|
|
{
|
|
if (AssertHandler handler = assertHandler())
|
|
return handler(expression, file, line, function);
|
|
|
|
return 1;
|
|
}
|
|
|
|
} // namespace Luau
|
|
|
|
#if !defined(NDEBUG) || defined(LUAU_ENABLE_ASSERT)
|
|
#define LUAU_ASSERT(expr) ((void)(!!(expr) || (Luau::assertCallHandler(#expr, __FILE__, __LINE__, __FUNCTION__) && (LUAU_DEBUGBREAK(), 0))))
|
|
#define LUAU_ASSERTENABLED
|
|
#else
|
|
#define LUAU_ASSERT(expr) (void)sizeof(!!(expr))
|
|
#endif
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
template<typename T>
|
|
struct FValue
|
|
{
|
|
static FValue* list;
|
|
|
|
T value;
|
|
bool dynamic;
|
|
const char* name;
|
|
FValue* next;
|
|
|
|
FValue(const char* name, T def, bool dynamic)
|
|
: value(def)
|
|
, dynamic(dynamic)
|
|
, name(name)
|
|
, next(list)
|
|
{
|
|
list = this;
|
|
}
|
|
|
|
LUAU_FORCEINLINE operator T() const
|
|
{
|
|
return value;
|
|
}
|
|
};
|
|
|
|
template<typename T>
|
|
FValue<T>* FValue<T>::list = nullptr;
|
|
|
|
} // namespace Luau
|
|
|
|
#define LUAU_FASTFLAG(flag) \
|
|
namespace FFlag \
|
|
{ \
|
|
extern Luau::FValue<bool> flag; \
|
|
}
|
|
#define LUAU_FASTFLAGVARIABLE(flag, def) \
|
|
namespace FFlag \
|
|
{ \
|
|
Luau::FValue<bool> flag(#flag, def, false); \
|
|
}
|
|
#define LUAU_FASTINT(flag) \
|
|
namespace FInt \
|
|
{ \
|
|
extern Luau::FValue<int> flag; \
|
|
}
|
|
#define LUAU_FASTINTVARIABLE(flag, def) \
|
|
namespace FInt \
|
|
{ \
|
|
Luau::FValue<int> flag(#flag, def, false); \
|
|
}
|
|
|
|
#define LUAU_DYNAMIC_FASTFLAG(flag) \
|
|
namespace DFFlag \
|
|
{ \
|
|
extern Luau::FValue<bool> flag; \
|
|
}
|
|
#define LUAU_DYNAMIC_FASTFLAGVARIABLE(flag, def) \
|
|
namespace DFFlag \
|
|
{ \
|
|
Luau::FValue<bool> flag(#flag, def, true); \
|
|
}
|
|
#define LUAU_DYNAMIC_FASTINT(flag) \
|
|
namespace DFInt \
|
|
{ \
|
|
extern Luau::FValue<int> flag; \
|
|
}
|
|
#define LUAU_DYNAMIC_FASTINTVARIABLE(flag, def) \
|
|
namespace DFInt \
|
|
{ \
|
|
Luau::FValue<int> flag(#flag, def, true); \
|
|
}
|
|
|
|
#if defined(__GNUC__)
|
|
#define LUAU_PRINTF_ATTR(fmt, arg) __attribute__((format(printf, fmt, arg)))
|
|
#else
|
|
#define LUAU_PRINTF_ATTR(fmt, arg)
|
|
#endif
|