mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-20 09:48:08 +00:00
25cc75b096
* 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 solver * Initial work toward tracking the upper and lower bounds of types more accurately. 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
112 lines
3.7 KiB
C++
112 lines
3.7 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#include "NativeState.h"
|
|
|
|
#include "Luau/UnwindBuilder.h"
|
|
|
|
#include "CodeGenUtils.h"
|
|
|
|
#include "lbuiltins.h"
|
|
#include "lgc.h"
|
|
#include "ltable.h"
|
|
#include "lfunc.h"
|
|
#include "lvm.h"
|
|
|
|
#include <math.h>
|
|
#include <string.h>
|
|
|
|
namespace Luau
|
|
{
|
|
namespace CodeGen
|
|
{
|
|
|
|
constexpr unsigned kBlockSize = 4 * 1024 * 1024;
|
|
constexpr unsigned kMaxTotalSize = 256 * 1024 * 1024;
|
|
|
|
NativeState::NativeState()
|
|
: codeAllocator(kBlockSize, kMaxTotalSize)
|
|
{
|
|
}
|
|
|
|
NativeState::~NativeState() = default;
|
|
|
|
void initFunctions(NativeState& data)
|
|
{
|
|
static_assert(sizeof(data.context.luauF_table) == sizeof(luauF_table), "fastcall tables are not of the same length");
|
|
memcpy(data.context.luauF_table, luauF_table, sizeof(luauF_table));
|
|
|
|
data.context.luaV_lessthan = luaV_lessthan;
|
|
data.context.luaV_lessequal = luaV_lessequal;
|
|
data.context.luaV_equalval = luaV_equalval;
|
|
data.context.luaV_doarith = luaV_doarith;
|
|
data.context.luaV_dolen = luaV_dolen;
|
|
data.context.luaV_prepareFORN = luaV_prepareFORN;
|
|
data.context.luaV_gettable = luaV_gettable;
|
|
data.context.luaV_settable = luaV_settable;
|
|
data.context.luaV_getimport = luaV_getimport;
|
|
data.context.luaV_concat = luaV_concat;
|
|
|
|
data.context.luaH_getn = luaH_getn;
|
|
data.context.luaH_new = luaH_new;
|
|
data.context.luaH_clone = luaH_clone;
|
|
data.context.luaH_resizearray = luaH_resizearray;
|
|
|
|
data.context.luaC_barriertable = luaC_barriertable;
|
|
data.context.luaC_barrierf = luaC_barrierf;
|
|
data.context.luaC_barrierback = luaC_barrierback;
|
|
data.context.luaC_step = luaC_step;
|
|
|
|
data.context.luaF_close = luaF_close;
|
|
data.context.luaF_findupval = luaF_findupval;
|
|
data.context.luaF_newLclosure = luaF_newLclosure;
|
|
|
|
data.context.luaT_gettm = luaT_gettm;
|
|
data.context.luaT_objtypenamestr = luaT_objtypenamestr;
|
|
|
|
data.context.libm_exp = exp;
|
|
data.context.libm_pow = pow;
|
|
data.context.libm_fmod = fmod;
|
|
data.context.libm_log = log;
|
|
data.context.libm_log2 = log2;
|
|
data.context.libm_log10 = log10;
|
|
data.context.libm_ldexp = ldexp;
|
|
data.context.libm_round = round;
|
|
data.context.libm_frexp = frexp;
|
|
data.context.libm_modf = modf;
|
|
|
|
data.context.libm_asin = asin;
|
|
data.context.libm_sin = sin;
|
|
data.context.libm_sinh = sinh;
|
|
data.context.libm_acos = acos;
|
|
data.context.libm_cos = cos;
|
|
data.context.libm_cosh = cosh;
|
|
data.context.libm_atan = atan;
|
|
data.context.libm_atan2 = atan2;
|
|
data.context.libm_tan = tan;
|
|
data.context.libm_tanh = tanh;
|
|
|
|
data.context.forgLoopTableIter = forgLoopTableIter;
|
|
data.context.forgLoopNodeIter = forgLoopNodeIter;
|
|
data.context.forgLoopNonTableFallback = forgLoopNonTableFallback;
|
|
data.context.forgPrepXnextFallback = forgPrepXnextFallback;
|
|
data.context.callProlog = callProlog;
|
|
data.context.callEpilogC = callEpilogC;
|
|
|
|
data.context.callFallback = callFallback;
|
|
|
|
data.context.executeGETGLOBAL = executeGETGLOBAL;
|
|
data.context.executeSETGLOBAL = executeSETGLOBAL;
|
|
data.context.executeGETTABLEKS = executeGETTABLEKS;
|
|
data.context.executeSETTABLEKS = executeSETTABLEKS;
|
|
|
|
data.context.executeNEWCLOSURE = executeNEWCLOSURE;
|
|
data.context.executeNAMECALL = executeNAMECALL;
|
|
data.context.executeFORGPREP = executeFORGPREP;
|
|
data.context.executeGETVARARGSMultRet = executeGETVARARGSMultRet;
|
|
data.context.executeGETVARARGSConst = executeGETVARARGSConst;
|
|
data.context.executeDUPCLOSURE = executeDUPCLOSURE;
|
|
data.context.executePREPVARARGS = executePREPVARARGS;
|
|
data.context.executeSETLIST = executeSETLIST;
|
|
}
|
|
|
|
} // namespace CodeGen
|
|
} // namespace Luau
|