Skip to content

Commit b6baee4

Browse files
committed
Bump Luau to 0.675
1 parent ff0108a commit b6baee4

File tree

7 files changed

+822
-335
lines changed

7 files changed

+822
-335
lines changed

luau/Ast/include/Luau/Parser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ class Parser
245245
};
246246

247247
TableIndexerResult parseTableIndexer(AstTableAccess access, std::optional<Location> accessLocation, Lexeme begin);
248+
// Remove with FFlagLuauStoreCSTData2
249+
AstTableIndexer* parseTableIndexer_DEPRECATED(AstTableAccess access, std::optional<Location> accessLocation, Lexeme begin);
248250

249251
AstTypeOrPack parseFunctionType(bool allowPack, const AstArray<AstAttr*>& attributes);
250252
AstType* parseFunctionTypeTail(

luau/Ast/src/Parser.cpp

Lines changed: 724 additions & 324 deletions
Large diffs are not rendered by default.

luau/CodeGen/include/Luau/CodeGen.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ void create(lua_State* L, SharedCodeGenContext* codeGenContext);
121121
// Enable or disable native execution according to `enabled` argument
122122
void setNativeExecutionEnabled(lua_State* L, bool enabled);
123123

124+
void disableNativeExecutionForFunction(lua_State* L, const int level) noexcept;
125+
124126
// Given a name, this function must return the index of the type which matches the type array used all CompilationOptions and AssemblyOptions
125127
// If the type is unknown, 0xff has to be returned
126128
using UserdataRemapperCallback = uint8_t(void* context, const char* name, size_t nameLength);

luau/CodeGen/src/CodeGenA64.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include "lstate.h"
1414

15+
LUAU_DYNAMIC_FASTFLAG(AddReturnExectargetCheck);
16+
1517
namespace Luau
1618
{
1719
namespace CodeGen
@@ -179,6 +181,14 @@ void emitReturn(AssemblyBuilderA64& build, ModuleHelpers& helpers)
179181

180182
build.ldr(x1, mem(rClosure, offsetof(Closure, l.p))); // cl->l.p aka proto
181183

184+
if (DFFlag::AddReturnExectargetCheck)
185+
{
186+
// Get new instruction location
187+
CODEGEN_ASSERT(offsetof(Proto, exectarget) == offsetof(Proto, execdata) + 8);
188+
build.ldp(x3, x4, mem(x1, offsetof(Proto, execdata)));
189+
build.cbz(x4, helpers.exitContinueVmClearNativeFlag);
190+
}
191+
182192
CODEGEN_ASSERT(offsetof(Proto, code) == offsetof(Proto, k) + 8);
183193
build.ldp(rConstants, rCode, mem(x1, offsetof(Proto, k))); // proto->k, proto->code
184194

@@ -188,9 +198,12 @@ void emitReturn(AssemblyBuilderA64& build, ModuleHelpers& helpers)
188198
build.ldr(x2, mem(x2, offsetof(CallInfo, savedpc))); // cip->savedpc
189199
build.sub(x2, x2, rCode);
190200

191-
// Get new instruction location and jump to it
192-
CODEGEN_ASSERT(offsetof(Proto, exectarget) == offsetof(Proto, execdata) + 8);
193-
build.ldp(x3, x4, mem(x1, offsetof(Proto, execdata)));
201+
if (!DFFlag::AddReturnExectargetCheck)
202+
{
203+
// Get new instruction location and jump to it
204+
CODEGEN_ASSERT(offsetof(Proto, exectarget) == offsetof(Proto, execdata) + 8);
205+
build.ldp(x3, x4, mem(x1, offsetof(Proto, execdata)));
206+
}
194207
build.ldr(w2, mem(x3, x2));
195208
build.add(x4, x4, x2);
196209
build.br(x4);

luau/CodeGen/src/CodeGenContext.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,21 @@ void setNativeExecutionEnabled(lua_State* L, bool enabled)
671671
L->global->ecb.enter = enabled ? onEnter : onEnterDisabled;
672672
}
673673

674+
void disableNativeExecutionForFunction(lua_State* L, const int level) noexcept
675+
{
676+
CODEGEN_ASSERT(unsigned(level) < unsigned(L->ci - L->base_ci));
677+
678+
const CallInfo* ci = L->ci - level;
679+
const TValue* o = ci->func;
680+
CODEGEN_ASSERT(ttisfunction(o));
681+
682+
Proto* proto = clvalue(o)->l.p;
683+
CODEGEN_ASSERT(proto);
684+
685+
CODEGEN_ASSERT(proto->codeentry != proto->code);
686+
onDestroyFunction(L, proto);
687+
}
688+
674689
static uint8_t userdataRemapperWrap(lua_State* L, const char* str, size_t len)
675690
{
676691
if (BaseCodeGenContext* codegenCtx = getCodeGenContext(L))

luau/CodeGen/src/EmitCommonX64.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
#include <utility>
1616

17+
18+
LUAU_DYNAMIC_FASTFLAGVARIABLE(AddReturnExectargetCheck, false);
19+
1720
namespace Luau
1821
{
1922
namespace CodeGen
@@ -458,6 +461,7 @@ void emitReturn(AssemblyBuilderX64& build, ModuleHelpers& helpers)
458461
// Registers alive: r9 (cip)
459462
RegisterX64 proto = rcx;
460463
RegisterX64 execdata = rbx;
464+
RegisterX64 exectarget = r10;
461465

462466
// Change closure
463467
build.mov(rax, qword[cip + offsetof(CallInfo, func)]);
@@ -471,6 +475,13 @@ void emitReturn(AssemblyBuilderX64& build, ModuleHelpers& helpers)
471475
build.test(byte[cip + offsetof(CallInfo, flags)], LUA_CALLINFO_NATIVE);
472476
build.jcc(ConditionX64::Zero, helpers.exitContinueVm); // Continue in interpreter if function has no native data
473477

478+
if (DFFlag::AddReturnExectargetCheck)
479+
{
480+
build.mov(exectarget, qword[proto + offsetof(Proto, exectarget)]);
481+
build.test(exectarget, exectarget);
482+
build.jcc(ConditionX64::Zero, helpers.exitContinueVmClearNativeFlag);
483+
}
484+
474485
// Change constants
475486
build.mov(rConstants, qword[proto + offsetof(Proto, k)]);
476487

@@ -486,7 +497,15 @@ void emitReturn(AssemblyBuilderX64& build, ModuleHelpers& helpers)
486497

487498
// Get new instruction location and jump to it
488499
build.mov(edx, dword[execdata + rax]);
489-
build.add(rdx, qword[proto + offsetof(Proto, exectarget)]);
500+
501+
if (DFFlag::AddReturnExectargetCheck)
502+
{
503+
build.add(rdx, exectarget);
504+
}
505+
else
506+
{
507+
build.add(rdx, qword[proto + offsetof(Proto, exectarget)]);
508+
}
490509
build.jmp(rdx);
491510
}
492511

luau/VM/src/lgcdebug.cpp

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <stdio.h>
1616

1717
LUAU_FASTFLAG(LuauCurrentLineBounds)
18+
LUAU_FASTFLAGVARIABLE(LuauHeapNameDetails)
1819

1920
static void validateobjref(global_State* g, GCObject* f, GCObject* t)
2021
{
@@ -728,10 +729,20 @@ static void enumclosure(EnumContext* ctx, Closure* cl)
728729

729730
char buf[LUA_IDSIZE];
730731

731-
if (p->source)
732-
snprintf(buf, sizeof(buf), "%s:%d %s", p->debugname ? getstr(p->debugname) : "", p->linedefined, getstr(p->source));
732+
if (FFlag::LuauHeapNameDetails)
733+
{
734+
if (p->source)
735+
snprintf(buf, sizeof(buf), "%s:%d %s", p->debugname ? getstr(p->debugname) : "unnamed", p->linedefined, getstr(p->source));
736+
else
737+
snprintf(buf, sizeof(buf), "%s:%d", p->debugname ? getstr(p->debugname) : "unnamed", p->linedefined);
738+
}
733739
else
734-
snprintf(buf, sizeof(buf), "%s:%d", p->debugname ? getstr(p->debugname) : "", p->linedefined);
740+
{
741+
if (p->source)
742+
snprintf(buf, sizeof(buf), "%s:%d %s", p->debugname ? getstr(p->debugname) : "", p->linedefined, getstr(p->source));
743+
else
744+
snprintf(buf, sizeof(buf), "%s:%d", p->debugname ? getstr(p->debugname) : "", p->linedefined);
745+
}
735746

736747
enumnode(ctx, obj2gco(cl), sizeLclosure(cl->nupvalues), buf);
737748
}
@@ -799,10 +810,21 @@ static void enumthread(EnumContext* ctx, lua_State* th)
799810

800811
char buf[LUA_IDSIZE];
801812

802-
if (p->source)
803-
snprintf(buf, sizeof(buf), "%s:%d %s", p->debugname ? getstr(p->debugname) : "", p->linedefined, getstr(p->source));
813+
if (FFlag::LuauHeapNameDetails)
814+
{
815+
if (p->source)
816+
snprintf(buf, sizeof(buf), "thread at %s:%d %s", p->debugname ? getstr(p->debugname) : "unnamed", p->linedefined, getstr(p->source));
817+
else
818+
snprintf(buf, sizeof(buf), "thread at %s:%d", p->debugname ? getstr(p->debugname) : "unnamed", p->linedefined);
819+
}
804820
else
805-
snprintf(buf, sizeof(buf), "%s:%d", p->debugname ? getstr(p->debugname) : "", p->linedefined);
821+
{
822+
823+
if (p->source)
824+
snprintf(buf, sizeof(buf), "%s:%d %s", p->debugname ? getstr(p->debugname) : "", p->linedefined, getstr(p->source));
825+
else
826+
snprintf(buf, sizeof(buf), "%s:%d", p->debugname ? getstr(p->debugname) : "", p->linedefined);
827+
}
806828

807829
enumnode(ctx, obj2gco(th), size, buf);
808830
}
@@ -835,7 +857,21 @@ static void enumproto(EnumContext* ctx, Proto* p)
835857
ctx->edge(ctx->context, enumtopointer(obj2gco(p)), p->execdata, "[native]");
836858
}
837859

838-
enumnode(ctx, obj2gco(p), size, p->source ? getstr(p->source) : NULL);
860+
if (FFlag::LuauHeapNameDetails)
861+
{
862+
char buf[LUA_IDSIZE];
863+
864+
if (p->source)
865+
snprintf(buf, sizeof(buf), "proto %s:%d %s", p->debugname ? getstr(p->debugname) : "unnamed", p->linedefined, getstr(p->source));
866+
else
867+
snprintf(buf, sizeof(buf), "proto %s:%d", p->debugname ? getstr(p->debugname) : "unnamed", p->linedefined);
868+
869+
enumnode(ctx, obj2gco(p), size, buf);
870+
}
871+
else
872+
{
873+
enumnode(ctx, obj2gco(p), size, p->source ? getstr(p->source) : NULL);
874+
}
839875

840876
if (p->sizek)
841877
enumedges(ctx, obj2gco(p), p->k, p->sizek, "constants");

0 commit comments

Comments
 (0)