// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details1// This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details2#pragma once34// When debugging complex issues, consider enabling one of these:5// This will reallocate the stack very aggressively at every opportunity; use this with asan to catch stale stack pointers6// #define HARDSTACKTESTS 17// This will call GC validation very aggressively at every incremental GC step; use this with caution as it's SLOW8// #define HARDMEMTESTS 19// This will call GC validation very aggressively at every GC opportunity; use this with caution as it's VERY SLOW10// #define HARDMEMTESTS 21112// To force MSVC2017+ to generate SSE2 code for some stdlib functions we need to locally enable /fp:fast13// Note that /fp:fast changes the semantics of floating point comparisons so this is only safe to do for functions without ones14#if defined(_MSC_VER) && !defined(__clang__)15#define LUAU_FASTMATH_BEGIN __pragma(float_control(precise, off, push))16#define LUAU_FASTMATH_END __pragma(float_control(pop))17#else18#define LUAU_FASTMATH_BEGIN19#define LUAU_FASTMATH_END20#endif2122// Some functions like floor/ceil have SSE4.1 equivalents but we currently support systems without SSE4.123// Note that we only need to do this when SSE4.1 support is not guaranteed by compiler settings, as otherwise compiler will optimize these for us.24#if (defined(__x86_64__) || defined(_M_X64)) && !defined(__SSE4_1__) && !defined(__AVX__)25#if defined(_MSC_VER) && !defined(__clang__)26#define LUAU_TARGET_SSE4127#elif defined(__GNUC__) && defined(__has_attribute)28#if __has_attribute(target)29#define LUAU_TARGET_SSE41 __attribute__((target("sse4.1")))30#endif31#endif32#endif3334// Used on functions that have a printf-like interface to validate them statically35#if defined(__GNUC__)36#define LUA_PRINTF_ATTR(fmt, arg) __attribute__((format(printf, fmt, arg)))37#else38#define LUA_PRINTF_ATTR(fmt, arg)39#endif4041#ifdef _MSC_VER42#define LUA_NORETURN __declspec(noreturn)43#else44#define LUA_NORETURN __attribute__((__noreturn__))45#endif4647// Can be used to reconfigure visibility/exports for public APIs48#ifndef LUA_API49#define LUA_API extern50#endif5152#define LUALIB_API LUA_API5354// Can be used to reconfigure visibility for internal APIs55#if defined(__GNUC__)56#define LUAI_FUNC __attribute__((visibility("hidden"))) extern57#define LUAI_DATA LUAI_FUNC58#else59#define LUAI_FUNC extern60#define LUAI_DATA extern61#endif6263// Can be used to reconfigure internal error handling to use longjmp instead of C++ EH64#ifndef LUA_USE_LONGJMP65#define LUA_USE_LONGJMP 066#endif6768// LUA_IDSIZE gives the maximum size for the description of the source69#ifndef LUA_IDSIZE70#define LUA_IDSIZE 25671#endif7273// LUA_MINSTACK is the guaranteed number of Lua stack slots available to a C function74#ifndef LUA_MINSTACK75#define LUA_MINSTACK 2076#endif7778// LUAI_MAXCSTACK limits the number of Lua stack slots that a C function can use79#ifndef LUAI_MAXCSTACK80#define LUAI_MAXCSTACK 800081#endif8283// LUAI_MAXCALLS limits the number of nested calls84#ifndef LUAI_MAXCALLS85#define LUAI_MAXCALLS 2000086#endif8788// LUAI_MAXCCALLS is the maximum depth for nested C calls; this limit depends on native stack size89#ifndef LUAI_MAXCCALLS90#define LUAI_MAXCCALLS 20091#endif9293// buffer size used for on-stack string operations; this limit depends on native stack size94#ifndef LUA_BUFFERSIZE95#define LUA_BUFFERSIZE 51296#endif9798// number of valid Lua userdata tags99#ifndef LUA_UTAG_LIMIT100#define LUA_UTAG_LIMIT 128101#endif102103// number of valid Lua lightuserdata tags104#ifndef LUA_LUTAG_LIMIT105#define LUA_LUTAG_LIMIT 128106#endif107108// upper bound for number of size classes used by page allocator109#ifndef LUA_SIZECLASSES110#define LUA_SIZECLASSES 40111#endif112113// available number of separate memory categories114#ifndef LUA_MEMORY_CATEGORIES115#define LUA_MEMORY_CATEGORIES 256116#endif117118// extra storage for execution callbacks in global state119#ifndef LUA_EXECUTION_CALLBACK_STORAGE120#define LUA_EXECUTION_CALLBACK_STORAGE 512121#endif122123// minimum size for the string table (must be power of 2)124#ifndef LUA_MINSTRTABSIZE125#define LUA_MINSTRTABSIZE 32126#endif127128// maximum number of captures supported by pattern matching129#ifndef LUA_MAXCAPTURES130#define LUA_MAXCAPTURES 32131#endif132133// }==================================================================134135#ifndef LUA_VECTOR_SIZE136#define LUA_VECTOR_SIZE 3 // must be 3 or 4137#endif138139#define LUA_EXTRA_SIZE (LUA_VECTOR_SIZE - 2)140141142