bug (GC can collect long identifier during parser) + change (using
a single constant table for all functions in a chunk)
This commit is contained in:
15
llex.c
15
llex.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: llex.c,v 2.67 2013/06/19 14:27:00 roberto Exp roberto $
|
||||
** $Id: llex.c,v 2.68 2013/08/21 20:09:51 roberto Exp roberto $
|
||||
** Lexical Analyzer
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -119,22 +119,25 @@ l_noret luaX_syntaxerror (LexState *ls, const char *msg) {
|
||||
|
||||
|
||||
/*
|
||||
** creates a new string and anchors it in function's table so that
|
||||
** it will not be collected until the end of the function's compilation
|
||||
** (by that time it should be anchored in function's prototype)
|
||||
** creates a new string and anchors it in scanner's table so that
|
||||
** it will not be collected until the end of the compilation
|
||||
** (by that time it should be anchored somewhere)
|
||||
*/
|
||||
TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
|
||||
lua_State *L = ls->L;
|
||||
TValue *o; /* entry for `str' */
|
||||
TString *ts = luaS_newlstr(L, str, l); /* create new string */
|
||||
setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */
|
||||
o = luaH_set(L, ls->fs->h, L->top - 1);
|
||||
if (ttisnil(o)) { /* not in use yet? (see 'addK') */
|
||||
o = luaH_set(L, ls->h, L->top - 1);
|
||||
if (ttisnil(o)) { /* not in use yet? */
|
||||
/* boolean value does not need GC barrier;
|
||||
table has no metatable, so it does not need to invalidate cache */
|
||||
setbvalue(o, 1); /* t[string] = true */
|
||||
luaC_checkGC(L);
|
||||
}
|
||||
else { /* string already present */
|
||||
ts = rawtsvalue(keyfromval(o)); /* re-use value previously stored */
|
||||
}
|
||||
L->top--; /* remove string from stack */
|
||||
return ts;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user