mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Optimize for loops using setpvaluefast, a variant of setpvalue which only sets the value of lightuserdata without setting type and tag
This commit is contained in:
parent
bdc142e948
commit
86476fda4c
3 changed files with 12 additions and 5 deletions
|
@ -71,7 +71,7 @@ bool forgLoopTableIter(lua_State* L, Table* h, int index, TValue* ra)
|
|||
|
||||
if (!ttisnil(e))
|
||||
{
|
||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
setpvaluefast(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
setnvalue(ra + 3, double(index + 1));
|
||||
setobj2s(L, ra + 4, e);
|
||||
|
||||
|
@ -90,7 +90,7 @@ bool forgLoopTableIter(lua_State* L, Table* h, int index, TValue* ra)
|
|||
|
||||
if (!ttisnil(gval(n)))
|
||||
{
|
||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
setpvaluefast(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
getnodekey(L, ra + 3, n);
|
||||
setobj(L, ra + 4, gval(n));
|
||||
|
||||
|
@ -115,7 +115,7 @@ bool forgLoopNodeIter(lua_State* L, Table* h, int index, TValue* ra)
|
|||
|
||||
if (!ttisnil(gval(n)))
|
||||
{
|
||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
setpvaluefast(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
getnodekey(L, ra + 3, n);
|
||||
setobj(L, ra + 4, gval(n));
|
||||
|
||||
|
|
|
@ -134,6 +134,13 @@ typedef struct lua_TValue
|
|||
i_o->tt = LUA_TLIGHTUSERDATA; \
|
||||
}
|
||||
|
||||
#define setpvaluefast(obj, x, tag) \
|
||||
{ \
|
||||
TValue* i_o = (obj); \
|
||||
LUAU_ASSERT(i_o->tt == LUA_TLIGHTUSERDATA && lightuserdatatag(i_o) == tag); \
|
||||
i_o->value.p = (x); \
|
||||
}
|
||||
|
||||
#define setbvalue(obj, x) \
|
||||
{ \
|
||||
TValue* i_o = (obj); \
|
||||
|
|
|
@ -2354,7 +2354,7 @@ reentry:
|
|||
|
||||
if (!ttisnil(e))
|
||||
{
|
||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
setpvaluefast(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
setnvalue(ra + 3, double(index + 1));
|
||||
setobj2s(L, ra + 4, e);
|
||||
|
||||
|
@ -2375,7 +2375,7 @@ reentry:
|
|||
|
||||
if (!ttisnil(gval(n)))
|
||||
{
|
||||
setpvalue(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
setpvaluefast(ra + 2, reinterpret_cast<void*>(uintptr_t(index + 1)), LU_TAG_ITERATOR);
|
||||
getnodekey(L, ra + 3, n);
|
||||
setobj2s(L, ra + 4, gval(n));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue