Use fast flags correctly

This commit is contained in:
Dekkonot 2023-10-17 14:25:18 -07:00
parent f6c07e2032
commit 9bf6888aa8
No known key found for this signature in database
2 changed files with 7 additions and 8 deletions

View file

@ -4,7 +4,7 @@
#include "Luau/Bytecode.h" #include "Luau/Bytecode.h"
#include "Luau/Compiler.h" #include "Luau/Compiler.h"
LUAU_FASTFLAG(LuauBit32ByteswapBuiltin) LUAU_FASTFLAGVARIABLE(LuauBit32ByteswapBuiltin, true)
namespace Luau namespace Luau
{ {
@ -168,11 +168,8 @@ static int getBuiltinFunctionId(const Builtin& builtin, const CompileOptions& op
return LBF_BIT32_COUNTLZ; return LBF_BIT32_COUNTLZ;
if (builtin.method == "countrz") if (builtin.method == "countrz")
return LBF_BIT32_COUNTRZ; return LBF_BIT32_COUNTRZ;
if (builtin.method == "byteswap") if (FFlag::LuauBit32ByteswapBuiltin && builtin.method == "byteswap")
{
LUAU_ASSERT(FFlag::LuauBit32ByteswapBuiltin);
return LBF_BIT32_BYTESWAP; return LBF_BIT32_BYTESWAP;
}
} }
if (builtin.object == "string") if (builtin.object == "string")

View file

@ -5,7 +5,7 @@
#include "lcommon.h" #include "lcommon.h"
#include "lnumutils.h" #include "lnumutils.h"
LUAU_FASTFLAG(LuauBit32Byteswap) LUAU_FASTFLAGVARIABLE(LuauBit32Byteswap, true)
#define ALLONES ~0u #define ALLONES ~0u
#define NBITS int(8 * sizeof(unsigned)) #define NBITS int(8 * sizeof(unsigned))
@ -214,9 +214,11 @@ static int b_countrz(lua_State* L)
static int b_swap(lua_State* L) static int b_swap(lua_State* L)
{ {
LUAU_ASSERT(FFlag::LuauBit32Byteswap); if (!FFlag::LuauBit32Byteswap)
luaL_error(L, "bit32.byteswap isn't enabled");
b_uint n = luaL_checkunsigned(L, 1); b_uint n = luaL_checkunsigned(L, 1);
n = ((n >> 24) & 0xff) | ((n << 8) & 0xff0000) | ((n >> 8) & 0xff00) | ((n << 24) & 0xff000000); n = (n << 24) | ((n << 8) & 0xff0000) | (n >> 8 & 0xff00) | n >> 24;
lua_pushunsigned(L, n); lua_pushunsigned(L, n);
return 1; return 1;