Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions luajit/src/lj_cdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ GCcdata *lj_cdata_newv(lua_State *L, CTypeID id, CTSize sz, CTSize align)
cdatav(cd)->extra = extra;
cdatav(cd)->len = sz;
g = G(L);
setgcrefr(cd->nextgc, g->gc.root);
setgcref(g->gc.root, obj2gco(cd));
lj_gc_addtoroot(g, obj2gco(cd));
newwhite(g, obj2gco(cd));
cd->marked |= LJ_GC_ISCDATA;
cd->gct = ~LJ_TCDATA;
Expand Down
2 changes: 1 addition & 1 deletion luajit/src/lj_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ enum {
#define frame_gc(f) (gcref((f)->fr.func))
#define frame_ftsz(f) ((ptrdiff_t)(f)->fr.tp.ftsz)
#define frame_pc(f) (mref((f)->fr.tp.pcr, const BCIns))
#define setframe_gc(f, p, tp) (setgcref((f)->fr.func, (p)), UNUSED(tp))
#define setframe_gc(f, p, tp) do { setgcref((f)->fr.func, (p)); UNUSED(tp); } while(0)
#define setframe_ftsz(f, sz) ((f)->fr.tp.ftsz = (int32_t)(sz))
#define setframe_pc(f, pc) (setmref((f)->fr.tp.pcr, (pc)))
#endif
Expand Down
2 changes: 2 additions & 0 deletions luajit/src/lj_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env)
fn->c.gct = ~LJ_TFUNC;
fn->c.ffid = FF_C;
fn->c.nupvalues = (uint8_t)nelems;
setrawgcrefnull(fn->c.env); // Needed as else it would try to decrement a invalid gcref!
/* NOBARRIER: The GCfunc is new (marked white). */
setmref(fn->c.pc, &G(L)->bc_cfunc_ext);
setgcref(fn->c.env, obj2gco(env));
Expand All @@ -127,6 +128,7 @@ static GCfunc *func_newL(lua_State *L, GCproto *pt, GCtab *env)
fn->l.gct = ~LJ_TFUNC;
fn->l.ffid = FF_LUA;
fn->l.nupvalues = 0; /* Set to zero until upvalues are initialized. */
setrawgcrefnull(fn->l.env); // Needed as else it would try to decrement a invalid gcref!
/* NOBARRIER: Really a setgcref. But the GCfunc is new (marked white). */
setmref(fn->l.pc, proto_bc(pt));
setgcref(fn->l.env, obj2gco(env));
Expand Down
71 changes: 69 additions & 2 deletions luajit/src/lj_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "lj_dispatch.h"
#include "lj_vm.h"
#include "lj_vmevent.h"
#include <stdio.h>

#define GCSTEPSIZE 1024u
#define GCSWEEPMAX 40
Expand Down Expand Up @@ -84,6 +85,7 @@
lj_assertG(gct == ~LJ_TFUNC || gct == ~LJ_TTAB ||
gct == ~LJ_TTHREAD || gct == ~LJ_TPROTO || gct == ~LJ_TTRACE,
"bad GC type %d", gct);
printf("Bad GC type %d - %d\n", gct, ~LJ_TTAB);
setgcrefr(o->gch.gclist, g->gc.gray);
setgcref(g->gc.gray, o);
}
Expand Down Expand Up @@ -433,6 +435,7 @@
int ow = otherwhite(g);
uintptr_t u = gcrefu(*chain);
GCRef q;
setrawgcrefnull(q);
GCRef *p = &q;
GCobj *o;
setgcrefp(q, (u & ~(uintptr_t)1));
Expand Down Expand Up @@ -869,6 +872,10 @@
lj_assertG(checkptrGC(p),
"allocated memory address %p outside required range", p);
g->gc.total = (g->gc.total - osz) + nsz;
#if LUA_ZERO_OUT_MEMORY
if (osz == 0)
memset(p, 0, nsz);
#endif
return p;
}

Expand All @@ -882,8 +889,10 @@
lj_assertG(checkptrGC(o),
"allocated memory address %p outside required range", o);
g->gc.total += size;
setgcrefr(o->gch.nextgc, g->gc.root);
setgcref(g->gc.root, o);
#if LUA_ZERO_OUT_MEMORY
memset(o, 0, size);
#endif
lj_gc_addtoroot(g, o);
newwhite(g, o);
return o;
}
Expand All @@ -901,3 +910,61 @@
return p;
}

/* GC Reference states (Old version) */

/*LJ_FUNC void LJ_FASTCALL lj_mark_referenced(global_State *g, GCobj *obj)
{

}*/

Check warning on line 918 in luajit/src/lj_gc.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CQn5d-9jiF72-cv&open=AZrE1CQn5d-9jiF72-cv&pullRequest=97

/*
Left out for now as I wanna make a try without this to maintain only two lists. And with the reference counter this should also be avoidable at the cost of 4 bytes of memory.
LJ_FUNC void LJ_FASTCALL lj_mark_semireferenced(global_State *g, GCobj *obj)
{

}*/

/*LJ_FUNC void LJ_FASTCALL lj_mark_nonreferenced(global_State *g, GCobj *obj)
{
// Unlinking from previous list / referenced list.

Check warning on line 929 in luajit/src/lj_gc.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the misleading "//" characters.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CQn5d-9jiF72-cr&open=AZrE1CQn5d-9jiF72-cr&pullRequest=97
GCobj* prev = gcref(obj->gch.lastgc);
if (prev)
prev->gch.nextgc = obj->gch.nextgc;

GCobj* next = gcref(obj->gch.nextgc);
if (next)
setgcref(next->gch.lastgc, prev); // Should be fine even if prev is null

Check warning on line 936 in luajit/src/lj_gc.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the misleading "//" characters.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CQn5d-9jiF72-cs&open=AZrE1CQn5d-9jiF72-cs&pullRequest=97

obj->gch.refcount = 0; // Time to vanish, though normally we should check if its not 0, too lazy rn tho

Check warning on line 938 in luajit/src/lj_gc.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the misleading "//" characters.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CQn5d-9jiF72-ct&open=AZrE1CQn5d-9jiF72-ct&pullRequest=97
setgcrefr(obj->gch.nextgc, g->gc.nonreferencedroot);
setgcrefr(obj->gch.nextgc, g->gc.nonreferencedroot);
}*/

Check warning on line 941 in luajit/src/lj_gc.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CQn5d-9jiF72-cw&open=AZrE1CQn5d-9jiF72-cw&pullRequest=97

// Should be called on a new fresh object
LJ_FUNC void LJ_FASTCALL lj_gc_addtoroot(global_State *g, GCobj *obj)
{
obj->gch.refcount = 0;
setrawgcrefr(obj->gch.nextgc, g->gc.root);
setrawgcref(g->gc.root, obj);
}

LJ_FUNC void LJ_FASTCALL lj_gc_incr_ref(GCobj *obj)
{
printf("incr ref %i\n", ++obj->gch.refcount);
}

LJ_FUNC void LJ_FASTCALL lj_gc_decr_ref(GCobj *obj)
{
if (!obj)
return;

printf("ref %i\n", obj->gch.refcount);
if (obj->gch.refcount > 100 || obj->gch.refcount <= 0)
__debugbreak();

if (--obj->gch.refcount <= 0)
{
// ToDo: Free it

Check warning on line 967 in luajit/src/lj_gc.c

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "ToDo" comment.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CQn5d-9jiF72-cu&open=AZrE1CQn5d-9jiF72-cu&pullRequest=97
printf("freeing reference\n");
}
}
7 changes: 7 additions & 0 deletions luajit/src/lj_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
#endif
LJ_FUNC void lj_gc_fullgc(lua_State *L);

// Universal function so that not like 20 places do the exact same
LJ_FUNC void LJ_FASTCALL lj_gc_addtoroot(global_State *g, GCobj *obj);

Check warning on line 76 in luajit/src/lj_gc.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

unused function 'lj_gc_addtoroot'

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CQF5d-9jiF72-cq&open=AZrE1CQF5d-9jiF72-cq&pullRequest=97

// LJ_FUNC void LJ_FASTCALL lj_mark_referenced(global_State *g, GCobj *obj);
// LJ_FUNC void LJ_FASTCALL lj_mark_semireferenced(global_State *g, GCobj *obj);
// LJ_FUNC void LJ_FASTCALL lj_mark_nonreferenced(global_State *g, GCobj *obj);

Check warning on line 80 in luajit/src/lj_gc.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CQF5d-9jiF72-cp&open=AZrE1CQF5d-9jiF72-cp&pullRequest=97

/* GC check: drive collector forward if the GC threshold has been reached. */
#define lj_gc_check(L) \
{ if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) \
Expand Down
1 change: 1 addition & 0 deletions luajit/src/lj_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud)
/* Non-native generation returns a dumpable, but non-runnable prototype. */
setprotoV(L, L->top++, pt);
}
gcrefdirect_decrement(pt);
return NULL;
}

Expand Down
78 changes: 65 additions & 13 deletions luajit/src/lj_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,59 @@
} GCRef;

/* Common GC header for all collectable objects. */
#define GCHeader GCRef nextgc; uint8_t marked; uint8_t gct
/* This occupies 6 bytes, so use the next 2 bytes for non-32 bit fields. */
/* We got lastgc to double link it to make insertion/removal in the roots faster though I think I could get rid of that again later, just gonna keep it for now */
/* Having the refcount be second allows structs like GCcdata on 64x to save 8 bytes alignment */
/* as nextgc will be 8 bytes and refcount will be 4 with additional 4 one byte variables which all fit into 16 bytes in total */
#define GCHeader /*GCRef lastgc;*/ GCRef nextgc; uint32_t refcount; uint8_t marked; uint8_t gct

Check warning on line 66 in luajit/src/lj_obj.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CUQ5d-9jiF72-c1&open=AZrE1CUQ5d-9jiF72-c1&pullRequest=97
/* This occupies 10 bytes, so use the next 2 bytes for non-32 bit fields. */

typedef union GCobj GCobj;

Check warning on line 69 in luajit/src/lj_obj.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"using" should be preferred to "typedef" for type aliasing.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CUQ5d-9jiF72-c4&open=AZrE1CUQ5d-9jiF72-c4&pullRequest=97
LJ_FUNC void LJ_FASTCALL lj_gc_decr_ref(GCobj *obj);
#define gcrefdirect_decrement(gc) (lj_gc_decr_ref((GCobj*)gc))
#define gcref_decrement(gc) (lj_gc_decr_ref(gcref(gc)))

Check warning on line 72 in luajit/src/lj_obj.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

1st function call argument is an uninitialized value

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CUQ5d-9jiF72-c3&open=AZrE1CUQ5d-9jiF72-c3&pullRequest=97

#define LJ_GC_REF_DEBUG
#ifdef LJ_GC_REF_DEBUG
LJ_FUNC void LJ_FASTCALL lj_gc_incr_ref(GCobj *obj);
#define gcrefdirect_increment(gc) (lj_gc_incr_ref((GCobj*)gc))
#define gcref_increment(gc) (lj_gc_incr_ref(gcref(gc)))
#else
#define gcrefdirect_increment(gc) (++gc->gch.refcount)
#define gcref_increment(gc) (++gcref(gc)->gch.refcount)
#endif

#if LJ_GC64
#define gcref(r) ((GCobj *)(r).gcptr64)
#define gcrefp(r, t) ((t *)(void *)(r).gcptr64)
#define gcrefu(r) ((r).gcptr64)
#define gcrefeq(r1, r2) ((r1).gcptr64 == (r2).gcptr64)

#define setgcref(r, gc) ((r).gcptr64 = (uint64_t)&(gc)->gch)
#define setrawgcref(r, gc) ((r).gcptr64 = (uint64_t)&(gc)->gch)
#define setgcreft(r, gc, it) \
(r).gcptr64 = (uint64_t)&(gc)->gch | (((uint64_t)(it)) << 47)
#define setgcrefp(r, p) ((r).gcptr64 = (uint64_t)(p))
#define setgcrefnull(r) ((r).gcptr64 = 0)
#define setgcrefr(r, v) ((r).gcptr64 = (v).gcptr64)
#define setrawgcrefp(r, p) ((r).gcptr64 = (uint64_t)(p))
#define setrawgcrefnull(r) ((r).gcptr64 = 0)
#define setrawgcrefr(r, v) ((r).gcptr64 = (v).gcptr64)

#define setgcref(r, gc) do { gcref_decrement(r); setrawgcref(r, gc); if ((r).gcptr64 != 0) { gcref_increment(r); } } while(0)
#define setgcrefp(r, p) do { gcref_decrement(r); setrawgcrefp(r, p); if ((r).gcptr64 != 0) { gcref_increment(r); } } while(0)
#define setgcrefnull(r) do { gcref_decrement(r); setrawgcrefnull(r); } while(0)
#define setgcrefr(r, v) do { gcref_decrement(r); setrawgcrefr(r, v); if ((r).gcptr64 != 0) { gcref_increment(r); } } while(0)
#else
#define gcref(r) ((GCobj *)(uintptr_t)(r).gcptr32)
#define gcrefp(r, t) ((t *)(void *)(uintptr_t)(r).gcptr32)
#define gcrefu(r) ((r).gcptr32)
#define gcrefeq(r1, r2) ((r1).gcptr32 == (r2).gcptr32)

#define setgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch)
#define setgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p))
#define setgcrefnull(r) ((r).gcptr32 = 0)
#define setgcrefr(r, v) ((r).gcptr32 = (v).gcptr32)
#define setrawgcref(r, gc) ((r).gcptr32 = (uint32_t)(uintptr_t)&(gc)->gch)
#define setrawgcrefp(r, p) ((r).gcptr32 = (uint32_t)(uintptr_t)(p))
#define setrawgcrefnull(r) ((r).gcptr32 = 0)
#define setrawgcrefr(r, v) ((r).gcptr32 = (v).gcptr32)

#define setgcref(r, gc) do { gcref_decrement(r); setrawgcref(r, gc); if ((r).gcptr32 != 0) { gcref_increment(r); } } while(0)
#define setgcrefp(r, p) do { gcref_decrement(r); setrawgcrefp(r, p); if ((r).gcptr32 != 0) { gcref_increment(r); } } while(0)
#define setgcrefnull(r) do { gcref_decrement(r); setrawgcrefnull(r); } while(0)
#define setgcrefr(r, v) do { gcref_decrement(r); setrawgcrefr(r, v); if ((r).gcptr32 != 0) { gcref_increment(r); } } while(0)
#endif

#define gcnext(gc) (gcref((gc)->gch.nextgc))
Expand Down Expand Up @@ -608,6 +636,10 @@
#endif
MSize sweepstr; /* Sweep position in string table. */
GCRef root; /* List of all collectable objects. */
// Old idea though maybe still worth a try later, but rn I wanna test it with a ref counter
// GCRef referencedroot; /* List of all objects that are referenced / shouldn't be collected */

Check warning on line 640 in luajit/src/lj_obj.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the misleading "/*" characters.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CUQ5d-9jiF72-cx&open=AZrE1CUQ5d-9jiF72-cx&pullRequest=97
// GCRef semireferencedroot; /* List of all objects that may be referenced / a sweep through referencedroot is needed to determen their state */

Check warning on line 641 in luajit/src/lj_obj.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the misleading "/*" characters.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CUQ5d-9jiF72-cy&open=AZrE1CUQ5d-9jiF72-cy&pullRequest=97
// GCRef nonreferencedroot; /* List of all objects that are not referenced / should be collected */

Check warning on line 642 in luajit/src/lj_obj.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the misleading "/*" characters.

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CUQ5d-9jiF72-cz&open=AZrE1CUQ5d-9jiF72-cz&pullRequest=97
MRef sweep; /* Sweep position in root list. */
GCRef gray; /* List of gray objects. */
GCRef grayagain; /* List of objects for atomic traversal. */
Expand Down Expand Up @@ -893,7 +925,7 @@
#elif LJ_64
o->u64 = (uint64_t)p | (((uint64_t)0xffff) << 48);
#else
setgcrefp(o->gcr, p); setitype(o, LJ_TLIGHTUD);
setrawgcrefp(o->gcr, p); setitype(o, LJ_TLIGHTUD);
#endif
}

Expand Down Expand Up @@ -921,12 +953,12 @@
#endif
}

static LJ_AINLINE void setgcVraw(TValue *o, GCobj *v, uint32_t itype)

Check warning on line 956 in luajit/src/lj_obj.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "o" is "union TValue *".

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CUQ5d-9jiF72-c0&open=AZrE1CUQ5d-9jiF72-c0&pullRequest=97
{
#if LJ_GC64
setgcreft(o->gcr, v, itype);
setrawgcreft(o->gcr, v, itype);

Check warning on line 959 in luajit/src/lj_obj.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Passed-by-value struct argument contains uninitialized data (e.g., field: 'gcptr64')

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1CUQ5d-9jiF72-c2&open=AZrE1CUQ5d-9jiF72-c2&pullRequest=97
#else
setgcref(o->gcr, v); setitype(o, itype);
setrawgcref(o->gcr, v); setitype(o, itype);
#endif
}

Expand All @@ -936,10 +968,30 @@
checklivetv(L, o, "store to dead GC object");
}

static LJ_AINLINE void setgcVRef(lua_State *L, TValue *o, GCobj *v, uint32_t it)
{
if (!(tvisbool(o) || tvisnumber(o) || tvisnil(o)))
{
gcref_decrement(o->gcr);
}

setgcVraw(o, v, it);
checklivetv(L, o, "store to dead GC object");

if (!(tvisbool(o) || tvisnumber(o) || tvisnil(o)) && v)
{
gcref_increment(o->gcr);
}
}

#define define_setV(name, type, tag) \
static LJ_AINLINE void name(lua_State *L, TValue *o, const type *v) \
{ \
setgcV(L, o, obj2gco(v), tag); \
} \
static LJ_AINLINE void name##Ref(lua_State *L, TValue *o, const type *v) \
{ \
setgcVRef(L, o, obj2gco(v), tag); \
}
define_setV(setstrV, GCstr, LJ_TSTR)
define_setV(setthreadV, lua_State, LJ_TTHREAD)
Expand Down
2 changes: 2 additions & 0 deletions luajit/src/lj_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,8 @@ static GCproto *fs_finish(LexState *ls, BCLine line)
pt->flags = (uint8_t)(fs->flags & ~(PROTO_HAS_RETURN|PROTO_FIXUP_RETURN));
pt->numparams = fs->numparams;
pt->framesize = fs->framesize;
gcrefdirect_increment(pt);
setrawgcrefnull(pt->chunkname);
setgcref(pt->chunkname, obj2gco(ls->chunkname));

/* Close potentially uninitialized gap between bc and kgc. */
Expand Down
6 changes: 4 additions & 2 deletions luajit/src/lj_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ static GCstr *lj_str_alloc(lua_State *L, const char *str, MSize len,
s->gct = ~LJ_TSTR;
s->len = len;
s->hash = hash;
s->refcount = 0;
#ifndef STRID_RESEED_INTERVAL
s->sid = g->str.id++;
#elif STRID_RESEED_INTERVAL
Expand All @@ -302,9 +303,10 @@ static GCstr *lj_str_alloc(lua_State *L, const char *str, MSize len,
/* Add to string hash table. */
hash &= g->str.mask;
u = gcrefu(g->str.tab[hash]);
setgcrefp(s->nextgc, (u & ~(uintptr_t)1));
setrawgcrefnull(s->nextgc); // Gotta set it to 0 as else decr_ref will trigger
setrawgcrefp(s->nextgc, (u & ~(uintptr_t)1));
/* NOBARRIER: The string table is a GC root. */
setgcrefp(g->str.tab[hash], ((uintptr_t)s | (u & 1)));
setrawgcrefp(g->str.tab[hash], ((uintptr_t)s | (u & 1)));
if (g->str.num++ > g->str.mask) /* Allow a 100% load factor. */
lj_str_resize(L, (g->str.mask<<1)+1); /* Grow string table. */
return s; /* Return newly interned string. */
Expand Down
6 changes: 4 additions & 2 deletions luajit/src/lj_tab.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "lj_err.h"
#include "lj_tab.h"
#include "lj_lib.h"
#include <stdio.h>

/* -- Object hashing ------------------------------------------------------ */

Expand Down Expand Up @@ -91,7 +92,7 @@ static GCtab *newtab(lua_State *L, uint32_t asize, uint32_t hbits)
t->nomm = (uint8_t)~0;
t->colo = (int8_t)asize;
setmref(t->array, (TValue *)((char *)t + sizeof(GCtab)));
setgcrefnull(t->metatable);
setrawgcrefnull(t->metatable);
t->asize = asize;
t->hmask = 0;
nilnode = &G(L)->nilnode;
Expand All @@ -106,7 +107,7 @@ static GCtab *newtab(lua_State *L, uint32_t asize, uint32_t hbits)
t->nomm = (uint8_t)~0;
t->colo = 0;
setmref(t->array, NULL);
setgcrefnull(t->metatable);
setrawgcrefnull(t->metatable);
t->asize = 0; /* In case the array allocation fails. */
t->hmask = 0;
nilnode = &G(L)->nilnode;
Expand Down Expand Up @@ -555,6 +556,7 @@ TValue *lj_tab_setstr(lua_State *L, GCtab *t, const GCstr *key)
if (tvisstr(&n->key) && strV(&n->key) == key)
return &n->val;
} while ((n = nextnode(n)));
printf("tab_setstr %s\n", strdata(key));
setstrV(L, &k, key);
return lj_tab_newkey(L, t, &k);
}
Expand Down
3 changes: 1 addition & 2 deletions luajit/src/lj_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ static void trace_save(jit_State *J, GCtrace *T)
size_t szins = (J->cur.nins-J->cur.nk)*sizeof(IRIns);
char *p = (char *)T + sztr;
memcpy(T, &J->cur, sizeof(GCtrace));
setgcrefr(T->nextgc, J2G(J)->gc.root);
setgcrefp(J2G(J)->gc.root, T);
lj_gc_addtoroot(J2G(J), gcref(T->nextgc));
newwhite(J2G(J), T);
T->gct = ~LJ_TTRACE;
T->ir = (IRIns *)p - J->cur.nk; /* The IR has already been copied above. */
Expand Down
2 changes: 2 additions & 0 deletions luajit/src/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,6 @@
#define luai_apicheck(L, o) { (void)L; }
#endif

#define LUA_ZERO_OUT_MEMORY 1

Check failure on line 154 in luajit/src/luaconf.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this macro by "const", "constexpr" or an "enum".

See more on https://sonarcloud.io/project/issues?id=RaphaelIT7_gmod-holylib&issues=AZrE1COE5d-9jiF72-co&open=AZrE1COE5d-9jiF72-co&pullRequest=97

#endif
Loading
Loading