eris: Fix a bug in eris GC handling
This commit is contained in:
@@ -1269,13 +1269,15 @@ u_proto(Info *info) { /* ... proto */
|
|||||||
p->maxstacksize = READ_VALUE(uint8_t);
|
p->maxstacksize = READ_VALUE(uint8_t);
|
||||||
|
|
||||||
/* Read byte code. */
|
/* Read byte code. */
|
||||||
p->sizecode = READ_VALUE(int);
|
int sizecode = READ_VALUE(int);
|
||||||
eris_reallocvector(info->L, p->code, 0, p->sizecode, Instruction);
|
eris_reallocvector(info->L, p->code, 0, sizecode, Instruction);
|
||||||
|
p->sizecode = sizecode;
|
||||||
READ(p->code, p->sizecode, Instruction);
|
READ(p->code, p->sizecode, Instruction);
|
||||||
|
|
||||||
/* Read constants. */
|
/* Read constants. */
|
||||||
p->sizek = READ_VALUE(int);
|
int sizek = READ_VALUE(int);
|
||||||
eris_reallocvector(info->L, p->k, 0, p->sizek, TValue);
|
eris_reallocvector(info->L, p->k, 0, sizek, TValue);
|
||||||
|
p->sizek = sizek;
|
||||||
/* Set all values to nil to avoid confusing the GC. */
|
/* Set all values to nil to avoid confusing the GC. */
|
||||||
for (i = 0, n = p->sizek; i < n; ++i) {
|
for (i = 0, n = p->sizek; i < n; ++i) {
|
||||||
eris_setnilvalue(&p->k[i]);
|
eris_setnilvalue(&p->k[i]);
|
||||||
@@ -1291,8 +1293,9 @@ u_proto(Info *info) { /* ... proto */
|
|||||||
poppath(info);
|
poppath(info);
|
||||||
|
|
||||||
/* Read child protos. */
|
/* Read child protos. */
|
||||||
p->sizep = READ_VALUE(int);
|
int sizep = READ_VALUE(int);
|
||||||
eris_reallocvector(info->L, p->p, 0, p->sizep, Proto*);
|
eris_reallocvector(info->L, p->p, 0, sizep, Proto*);
|
||||||
|
p->sizep = sizep;
|
||||||
/* Null all entries to avoid confusing the GC. */
|
/* Null all entries to avoid confusing the GC. */
|
||||||
memset(p->p, 0, p->sizep * sizeof(Proto*));
|
memset(p->p, 0, p->sizep * sizeof(Proto*));
|
||||||
pushpath(info, ".protos");
|
pushpath(info, ".protos");
|
||||||
@@ -1313,8 +1316,9 @@ u_proto(Info *info) { /* ... proto */
|
|||||||
poppath(info);
|
poppath(info);
|
||||||
|
|
||||||
/* Read upvalues. */
|
/* Read upvalues. */
|
||||||
p->sizeupvalues = READ_VALUE(int);
|
int sizeupvalues = READ_VALUE(int);
|
||||||
eris_reallocvector(info->L, p->upvalues, 0, p->sizeupvalues, Upvaldesc);
|
eris_reallocvector(info->L, p->upvalues, 0, sizeupvalues, Upvaldesc);
|
||||||
|
p->sizeupvalues = sizeupvalues;
|
||||||
for (i = 0, n = p->sizeupvalues; i < n; ++i) {
|
for (i = 0, n = p->sizeupvalues; i < n; ++i) {
|
||||||
p->upvalues[i].name = NULL;
|
p->upvalues[i].name = NULL;
|
||||||
p->upvalues[i].instack = READ_VALUE(uint8_t);
|
p->upvalues[i].instack = READ_VALUE(uint8_t);
|
||||||
@@ -1334,13 +1338,16 @@ u_proto(Info *info) { /* ... proto */
|
|||||||
lua_pop(info->L, 1); /* ... proto */
|
lua_pop(info->L, 1); /* ... proto */
|
||||||
|
|
||||||
/* Read line information. */
|
/* Read line information. */
|
||||||
p->sizelineinfo = READ_VALUE(int);
|
int sizelineinfo = READ_VALUE(int);
|
||||||
eris_reallocvector(info->L, p->lineinfo, 0, p->sizelineinfo, int);
|
eris_reallocvector(info->L, p->lineinfo, 0, sizelineinfo, int);
|
||||||
|
p->sizelineinfo = sizelineinfo;
|
||||||
|
|
||||||
READ(p->lineinfo, p->sizelineinfo, int);
|
READ(p->lineinfo, p->sizelineinfo, int);
|
||||||
|
|
||||||
/* Read locals info. */
|
/* Read locals info. */
|
||||||
p->sizelocvars = READ_VALUE(int);
|
int sizelocvars = READ_VALUE(int);
|
||||||
eris_reallocvector(info->L, p->locvars, 0, p->sizelocvars, LocVar);
|
eris_reallocvector(info->L, p->locvars, 0, sizelocvars, LocVar);
|
||||||
|
p->sizelocvars = sizelocvars;
|
||||||
/* Null the variable names to avoid confusing the GC. */
|
/* Null the variable names to avoid confusing the GC. */
|
||||||
for (i = 0, n = p->sizelocvars; i < n; ++i) {
|
for (i = 0, n = p->sizelocvars; i < n; ++i) {
|
||||||
p->locvars[i].varname = NULL;
|
p->locvars[i].varname = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user