diff --git a/Compiler/src/Builtins.cpp b/Compiler/src/Builtins.cpp index d1c29d45..14cfd168 100644 --- a/Compiler/src/Builtins.cpp +++ b/Compiler/src/Builtins.cpp @@ -4,7 +4,7 @@ #include "Luau/Bytecode.h" #include "Luau/Compiler.h" -LUAU_FASTFLAG(LuauBit32ByteswapBuiltin) +LUAU_FASTFLAGVARIABLE(LuauBit32ByteswapBuiltin, true) namespace Luau { @@ -168,11 +168,8 @@ static int getBuiltinFunctionId(const Builtin& builtin, const CompileOptions& op return LBF_BIT32_COUNTLZ; if (builtin.method == "countrz") return LBF_BIT32_COUNTRZ; - if (builtin.method == "byteswap") - { - LUAU_ASSERT(FFlag::LuauBit32ByteswapBuiltin); + if (FFlag::LuauBit32ByteswapBuiltin && builtin.method == "byteswap") return LBF_BIT32_BYTESWAP; - } } if (builtin.object == "string") diff --git a/VM/src/lbitlib.cpp b/VM/src/lbitlib.cpp index 65572501..f69b23ce 100644 --- a/VM/src/lbitlib.cpp +++ b/VM/src/lbitlib.cpp @@ -5,7 +5,7 @@ #include "lcommon.h" #include "lnumutils.h" -LUAU_FASTFLAG(LuauBit32Byteswap) +LUAU_FASTFLAGVARIABLE(LuauBit32Byteswap, true) #define ALLONES ~0u #define NBITS int(8 * sizeof(unsigned)) @@ -214,9 +214,11 @@ static int b_countrz(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); - 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); return 1;