diff options
author | Mike Pall <mike> | 2010-02-08 05:27:43 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-02-08 05:27:43 +0100 |
commit | 48d93d8c84eb72e720d90ed7861f353a2c417470 (patch) | |
tree | 1c7c45ea387160c6e5f4ae0f86d29ba6e4d88a1b /src | |
parent | 60b5af44222fff87a7184365a7f49654032d4cbf (diff) | |
download | luajit-48d93d8c84eb72e720d90ed7861f353a2c417470.tar.gz luajit-48d93d8c84eb72e720d90ed7861f353a2c417470.tar.bz2 luajit-48d93d8c84eb72e720d90ed7861f353a2c417470.zip |
Redesign of prototype generation, part 2: late init of chunkname.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_lex.c | 4 | ||||
-rw-r--r-- | src/lj_parse.c | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/lj_lex.c b/src/lj_lex.c index 28aad901..6cb785b5 100644 --- a/src/lj_lex.c +++ b/src/lj_lex.c | |||
@@ -333,10 +333,6 @@ void lj_lex_setup(lua_State *L, LexState *ls) | |||
333 | setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XBCLOAD)); | 333 | setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XBCLOAD)); |
334 | lj_err_throw(L, LUA_ERRSYNTAX); | 334 | lj_err_throw(L, LUA_ERRSYNTAX); |
335 | } | 335 | } |
336 | /* This is an unanchored GCstr before it's stored in the prototype. | ||
337 | ** Do this last since next() calls the reader which may call the GC. | ||
338 | */ | ||
339 | ls->chunkname = lj_str_newz(L, ls->chunkarg); | ||
340 | } | 336 | } |
341 | 337 | ||
342 | /* Cleanup lexer state. */ | 338 | /* Cleanup lexer state. */ |
diff --git a/src/lj_parse.c b/src/lj_parse.c index d949698f..c1fc5dd6 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c | |||
@@ -1171,6 +1171,7 @@ static GCproto *fs_finish(LexState *ls, BCLine line) | |||
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | /* Initialize prototype fields. */ | 1173 | /* Initialize prototype fields. */ |
1174 | setgcref(pt->chunkname, obj2gco(ls->chunkname)); | ||
1174 | pt->flags = fs->flags; | 1175 | pt->flags = fs->flags; |
1175 | pt->framesize = fs->framesize; | 1176 | pt->framesize = fs->framesize; |
1176 | pt->linedefined = fs->linedefined; | 1177 | pt->linedefined = fs->linedefined; |
@@ -1213,7 +1214,6 @@ static void fs_init(LexState *ls, FuncState *fs, BCLine line) | |||
1213 | fs->nactvar = 0; | 1214 | fs->nactvar = 0; |
1214 | fs->nuv = 0; | 1215 | fs->nuv = 0; |
1215 | fs->bl = NULL; | 1216 | fs->bl = NULL; |
1216 | setgcref(pt->chunkname, obj2gco(ls->chunkname)); | ||
1217 | fs->flags = 0; | 1217 | fs->flags = 0; |
1218 | fs->framesize = 2; /* Minimum frame size. */ | 1218 | fs->framesize = 2; /* Minimum frame size. */ |
1219 | fs->linedefined = line; | 1219 | fs->linedefined = line; |
@@ -2205,6 +2205,10 @@ GCproto *lj_parse(LexState *ls) | |||
2205 | { | 2205 | { |
2206 | struct FuncState fs; | 2206 | struct FuncState fs; |
2207 | GCproto *pt; | 2207 | GCproto *pt; |
2208 | lua_State *L = ls->L; | ||
2209 | ls->chunkname = lj_str_newz(L, ls->chunkarg); | ||
2210 | setstrV(L, L->top, ls->chunkname); /* Anchor chunkname string. */ | ||
2211 | incr_top(L); | ||
2208 | ls->level = 0; | 2212 | ls->level = 0; |
2209 | fs_init(ls, &fs, 0); | 2213 | fs_init(ls, &fs, 0); |
2210 | fs.flags |= PROTO_IS_VARARG; /* Main chunk is always a vararg func. */ | 2214 | fs.flags |= PROTO_IS_VARARG; /* Main chunk is always a vararg func. */ |
@@ -2213,6 +2217,7 @@ GCproto *lj_parse(LexState *ls) | |||
2213 | if (ls->token != TK_eof) | 2217 | if (ls->token != TK_eof) |
2214 | err_token(ls, TK_eof); | 2218 | err_token(ls, TK_eof); |
2215 | pt = fs_finish(ls, ls->linenumber); | 2219 | pt = fs_finish(ls, ls->linenumber); |
2220 | L->top--; /* Drop chunkname. */ | ||
2216 | lua_assert(fs.prev == NULL); | 2221 | lua_assert(fs.prev == NULL); |
2217 | lua_assert(ls->fs == NULL); | 2222 | lua_assert(ls->fs == NULL); |
2218 | lua_assert(pt->sizeuv == 0); | 2223 | lua_assert(pt->sizeuv == 0); |