diff options
author | Mike Pall <mike> | 2010-04-25 18:35:47 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2010-04-25 18:35:47 +0200 |
commit | ef0904e80ba5996c27999a1f044e03761b84826f (patch) | |
tree | 1b5bd59d7e8df1fddcca27dfe1d82a3bc3990253 /src | |
parent | 87e4daf89c9f37e417993dedc9c5369da89ebca2 (diff) | |
download | luajit-ef0904e80ba5996c27999a1f044e03761b84826f.tar.gz luajit-ef0904e80ba5996c27999a1f044e03761b84826f.tar.bz2 luajit-ef0904e80ba5996c27999a1f044e03761b84826f.zip |
Make metamethod names proper GC roots.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildvm_x64.h | 2 | ||||
-rw-r--r-- | src/buildvm_x64win.h | 2 | ||||
-rw-r--r-- | src/buildvm_x86.dasc | 2 | ||||
-rw-r--r-- | src/buildvm_x86.h | 2 | ||||
-rw-r--r-- | src/lib_string.c | 5 | ||||
-rw-r--r-- | src/lj_err.c | 2 | ||||
-rw-r--r-- | src/lj_gc.c | 2 | ||||
-rw-r--r-- | src/lj_meta.c | 11 | ||||
-rw-r--r-- | src/lj_meta.h | 2 | ||||
-rw-r--r-- | src/lj_obj.h | 10 | ||||
-rw-r--r-- | src/lj_record.c | 12 | ||||
-rw-r--r-- | src/lj_str.c | 3 |
12 files changed, 26 insertions, 29 deletions
diff --git a/src/buildvm_x64.h b/src/buildvm_x64.h index b3466037..c9e2d64f 100644 --- a/src/buildvm_x64.h +++ b/src/buildvm_x64.h | |||
@@ -1089,7 +1089,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1089 | dasm_put(Dst, 1814); | 1089 | dasm_put(Dst, 1814); |
1090 | } | 1090 | } |
1091 | dasm_put(Dst, 1823, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, ~LJ_TLIGHTUD, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL); | 1091 | dasm_put(Dst, 1823, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, ~LJ_TLIGHTUD, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL); |
1092 | dasm_put(Dst, 1902, DISPATCH_GL(mmname)+4*MM_metatable, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next)); | 1092 | dasm_put(Dst, 1902, DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable), LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next)); |
1093 | dasm_put(Dst, 1960, LJ_TNIL, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT])); | 1093 | dasm_put(Dst, 1960, LJ_TNIL, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT])); |
1094 | dasm_put(Dst, 2029, 2+1, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK)); | 1094 | dasm_put(Dst, 2029, 2+1, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK)); |
1095 | dasm_put(Dst, 2098, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist), 2+1, LJ_TTAB, 1+1, LJ_TISNUM); | 1095 | dasm_put(Dst, 2098, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist), 2+1, LJ_TTAB, 1+1, LJ_TISNUM); |
diff --git a/src/buildvm_x64win.h b/src/buildvm_x64win.h index 69a8b27e..97581286 100644 --- a/src/buildvm_x64win.h +++ b/src/buildvm_x64win.h | |||
@@ -1089,7 +1089,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1089 | dasm_put(Dst, 1790); | 1089 | dasm_put(Dst, 1790); |
1090 | } | 1090 | } |
1091 | dasm_put(Dst, 1799, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, ~LJ_TLIGHTUD, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL); | 1091 | dasm_put(Dst, 1799, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, ~LJ_TLIGHTUD, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL); |
1092 | dasm_put(Dst, 1878, DISPATCH_GL(mmname)+4*MM_metatable, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next)); | 1092 | dasm_put(Dst, 1878, DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable), LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next)); |
1093 | dasm_put(Dst, 1935, LJ_TNIL, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT])); | 1093 | dasm_put(Dst, 1935, LJ_TNIL, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT])); |
1094 | dasm_put(Dst, 2003, 2+1, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK)); | 1094 | dasm_put(Dst, 2003, 2+1, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK)); |
1095 | dasm_put(Dst, 2072, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist), 2+1, LJ_TTAB, 1+1, LJ_TISNUM); | 1095 | dasm_put(Dst, 2072, DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist), 2+1, LJ_TTAB, 1+1, LJ_TISNUM); |
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index 942889ed..69195cf6 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
@@ -1302,7 +1302,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1302 | | test TAB:RB, TAB:RB | 1302 | | test TAB:RB, TAB:RB |
1303 | | mov dword [BASE-4], LJ_TNIL | 1303 | | mov dword [BASE-4], LJ_TNIL |
1304 | | jz ->fff_res1 | 1304 | | jz ->fff_res1 |
1305 | | mov STR:RC, [DISPATCH+DISPATCH_GL(mmname)+4*MM_metatable] | 1305 | | mov STR:RC, [DISPATCH+DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable)] |
1306 | | mov dword [BASE-4], LJ_TTAB // Store metatable as default result. | 1306 | | mov dword [BASE-4], LJ_TTAB // Store metatable as default result. |
1307 | | mov [BASE-8], TAB:RB | 1307 | | mov [BASE-8], TAB:RB |
1308 | | mov RA, TAB:RB->hmask | 1308 | | mov RA, TAB:RB->hmask |
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h index 84dd2802..7a0b08a7 100644 --- a/src/buildvm_x86.h +++ b/src/buildvm_x86.h | |||
@@ -1143,7 +1143,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
1143 | } else { | 1143 | } else { |
1144 | dasm_put(Dst, 1769); | 1144 | dasm_put(Dst, 1769); |
1145 | } | 1145 | } |
1146 | dasm_put(Dst, 1778, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL, DISPATCH_GL(mmname)+4*MM_metatable, LJ_TTAB); | 1146 | dasm_put(Dst, 1778, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL, DISPATCH_GL(gcroot)+4*(GCROOT_MMNAME+MM_metatable), LJ_TTAB); |
1147 | dasm_put(Dst, 1861, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next), LJ_TNIL); | 1147 | dasm_put(Dst, 1861, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next), LJ_TNIL); |
1148 | dasm_put(Dst, 1919, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT]), 2+1); | 1148 | dasm_put(Dst, 1919, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT]), 2+1); |
1149 | dasm_put(Dst, 1982, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); | 1149 | dasm_put(Dst, 1982, LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); |
diff --git a/src/lib_string.c b/src/lib_string.c index ab353c20..1231aeb2 100644 --- a/src/lib_string.c +++ b/src/lib_string.c | |||
@@ -774,7 +774,6 @@ LJLIB_CF(string_format) | |||
774 | LUALIB_API int luaopen_string(lua_State *L) | 774 | LUALIB_API int luaopen_string(lua_State *L) |
775 | { | 775 | { |
776 | GCtab *mt; | 776 | GCtab *mt; |
777 | GCstr *mmstr; | ||
778 | global_State *g; | 777 | global_State *g; |
779 | LJ_LIB_REG(L, string); | 778 | LJ_LIB_REG(L, string); |
780 | #if defined(LUA_COMPAT_GFIND) | 779 | #if defined(LUA_COMPAT_GFIND) |
@@ -785,9 +784,7 @@ LUALIB_API int luaopen_string(lua_State *L) | |||
785 | /* NOBARRIER: basemt is a GC root. */ | 784 | /* NOBARRIER: basemt is a GC root. */ |
786 | g = G(L); | 785 | g = G(L); |
787 | setgcref(basemt_it(g, LJ_TSTR), obj2gco(mt)); | 786 | setgcref(basemt_it(g, LJ_TSTR), obj2gco(mt)); |
788 | mmstr = strref(g->mmname[MM_index]); | 787 | settabV(L, lj_tab_setstr(L, mt, mmname_str(g, MM_index)), tabV(L->top-1)); |
789 | if (isdead(g, obj2gco(mmstr))) flipwhite(obj2gco(mmstr)); | ||
790 | settabV(L, lj_tab_setstr(L, mt, mmstr), tabV(L->top-1)); | ||
791 | mt->nomm = cast_byte(~(1u<<MM_index)); | 788 | mt->nomm = cast_byte(~(1u<<MM_index)); |
792 | return 1; | 789 | return 1; |
793 | } | 790 | } |
diff --git a/src/lj_err.c b/src/lj_err.c index 3570ebde..9ae376ff 100644 --- a/src/lj_err.c +++ b/src/lj_err.c | |||
@@ -213,7 +213,7 @@ static const char *getfuncname(lua_State *L, TValue *frame, const char **name) | |||
213 | if (bc_op(*ip) == BC_ITERC) slot -= 3; | 213 | if (bc_op(*ip) == BC_ITERC) slot -= 3; |
214 | return getobjname(funcproto(fn), ip, slot, name); | 214 | return getobjname(funcproto(fn), ip, slot, name); |
215 | } else if (mm != MM_MAX) { | 215 | } else if (mm != MM_MAX) { |
216 | *name = strdata(strref(G(L)->mmname[mm])); | 216 | *name = strdata(mmname_str(G(L), mm)); |
217 | return "metamethod"; | 217 | return "metamethod"; |
218 | } else { | 218 | } else { |
219 | return NULL; | 219 | return NULL; |
diff --git a/src/lj_gc.c b/src/lj_gc.c index bd31eabf..0f0ca82e 100644 --- a/src/lj_gc.c +++ b/src/lj_gc.c | |||
@@ -77,7 +77,7 @@ static void gc_mark(global_State *g, GCobj *o) | |||
77 | static void gc_mark_gcroot(global_State *g) | 77 | static void gc_mark_gcroot(global_State *g) |
78 | { | 78 | { |
79 | ptrdiff_t i; | 79 | ptrdiff_t i; |
80 | for (i = 0; i < GCROOT__MAX; i++) | 80 | for (i = 0; i < GCROOT_MAX; i++) |
81 | if (gcref(g->gcroot[i]) != NULL) | 81 | if (gcref(g->gcroot[i]) != NULL) |
82 | gc_markobj(g, gcref(g->gcroot[i])); | 82 | gc_markobj(g, gcref(g->gcroot[i])); |
83 | } | 83 | } |
diff --git a/src/lj_meta.c b/src/lj_meta.c index 41124fdc..ab8ae8fe 100644 --- a/src/lj_meta.c +++ b/src/lj_meta.c | |||
@@ -28,14 +28,13 @@ void lj_meta_init(lua_State *L) | |||
28 | #undef MMNAME | 28 | #undef MMNAME |
29 | global_State *g = G(L); | 29 | global_State *g = G(L); |
30 | const char *p, *q; | 30 | const char *p, *q; |
31 | uint32_t i; | 31 | uint32_t mm; |
32 | for (i = 0, p = metanames; *p; i++, p = q) { | 32 | for (mm = 0, p = metanames; *p; mm++, p = q) { |
33 | GCstr *s; | 33 | GCstr *s; |
34 | for (q = p+2; *q && *q != '_'; q++) ; | 34 | for (q = p+2; *q && *q != '_'; q++) ; |
35 | s = lj_str_new(L, p, (size_t)(q-p)); | 35 | s = lj_str_new(L, p, (size_t)(q-p)); |
36 | fixstring(s); /* Never collect these names. */ | 36 | /* NOBARRIER: g->gcroot[] is a GC root. */ |
37 | /* NOBARRIER: g->mmname[] is a GC root. */ | 37 | setgcref(g->gcroot[GCROOT_MMNAME+mm], obj2gco(s)); |
38 | setgcref(g->mmname[i], obj2gco(s)); | ||
39 | } | 38 | } |
40 | } | 39 | } |
41 | 40 | ||
@@ -62,7 +61,7 @@ cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm) | |||
62 | else | 61 | else |
63 | mt = tabref(basemt_obj(G(L), o)); | 62 | mt = tabref(basemt_obj(G(L), o)); |
64 | if (mt) { | 63 | if (mt) { |
65 | cTValue *mo = lj_tab_getstr(mt, strref(G(L)->mmname[mm])); | 64 | cTValue *mo = lj_tab_getstr(mt, mmname_str(G(L), mm)); |
66 | if (mo) | 65 | if (mo) |
67 | return mo; | 66 | return mo; |
68 | } | 67 | } |
diff --git a/src/lj_meta.h b/src/lj_meta.h index 9b2c3f73..0bb567cc 100644 --- a/src/lj_meta.h +++ b/src/lj_meta.h | |||
@@ -15,7 +15,7 @@ LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm); | |||
15 | 15 | ||
16 | #define lj_meta_fastg(g, mt, mm) \ | 16 | #define lj_meta_fastg(g, mt, mm) \ |
17 | ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ | 17 | ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ |
18 | lj_meta_cache(mt, mm, strref((g)->mmname[mm]))) | 18 | lj_meta_cache(mt, mm, mmname_str(g, mm))) |
19 | #define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) | 19 | #define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) |
20 | 20 | ||
21 | /* C helpers for some instructions, called from assembler VM. */ | 21 | /* C helpers for some instructions, called from assembler VM. */ |
diff --git a/src/lj_obj.h b/src/lj_obj.h index b01bd97b..defb2088 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
@@ -537,15 +537,18 @@ MMDEF(MMENUM) | |||
537 | 537 | ||
538 | /* GC root IDs. */ | 538 | /* GC root IDs. */ |
539 | typedef enum { | 539 | typedef enum { |
540 | GCROOT_MMNAME, /* Metamethod names. */ | ||
541 | GCROOT_MMNAME_LAST = GCROOT_MMNAME + MM_MAX-1, | ||
540 | GCROOT_BASEMT, /* Metatables for base types. */ | 542 | GCROOT_BASEMT, /* Metatables for base types. */ |
541 | GCROOT_BASEMT_NUM = ~LJ_TNUMX, /* Last base metatable. */ | 543 | GCROOT_BASEMT_NUM = GCROOT_BASEMT + ~LJ_TNUMX, |
542 | GCROOT_IO_INPUT, /* Userdata for default I/O input file. */ | 544 | GCROOT_IO_INPUT, /* Userdata for default I/O input file. */ |
543 | GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */ | 545 | GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */ |
544 | GCROOT__MAX | 546 | GCROOT_MAX |
545 | } GCRootID; | 547 | } GCRootID; |
546 | 548 | ||
547 | #define basemt_it(g, it) ((g)->gcroot[GCROOT_BASEMT+~(it)]) | 549 | #define basemt_it(g, it) ((g)->gcroot[GCROOT_BASEMT+~(it)]) |
548 | #define basemt_obj(g, o) ((g)->gcroot[GCROOT_BASEMT+itypemap(o)]) | 550 | #define basemt_obj(g, o) ((g)->gcroot[GCROOT_BASEMT+itypemap(o)]) |
551 | #define mmname_str(g, mm) (strref((g)->gcroot[GCROOT_MMNAME+(mm)])) | ||
549 | 552 | ||
550 | typedef struct GCState { | 553 | typedef struct GCState { |
551 | MSize total; /* Memory currently allocated. */ | 554 | MSize total; /* Memory currently allocated. */ |
@@ -595,8 +598,7 @@ typedef struct global_State { | |||
595 | BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */ | 598 | BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */ |
596 | GCRef jit_L; /* Current JIT code lua_State or NULL. */ | 599 | GCRef jit_L; /* Current JIT code lua_State or NULL. */ |
597 | MRef jit_base; /* Current JIT code L->base. */ | 600 | MRef jit_base; /* Current JIT code L->base. */ |
598 | GCRef gcroot[GCROOT__MAX]; /* GC roots. */ | 601 | GCRef gcroot[GCROOT_MAX]; /* GC roots. */ |
599 | GCRef mmname[MM_MAX]; /* Array holding metamethod names. */ | ||
600 | } global_State; | 602 | } global_State; |
601 | 603 | ||
602 | #define mainthread(g) (&gcref(g->mainthref)->th) | 604 | #define mainthread(g) (&gcref(g->mainthref)->th) |
diff --git a/src/lj_record.c b/src/lj_record.c index c71aa1a4..b5e35076 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -677,14 +677,12 @@ static int rec_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) | |||
677 | emitir(IRTG(mt ? IR_NE : IR_EQ, IRT_TAB), mix.tab, lj_ir_knull(J, IRT_TAB)); | 677 | emitir(IRTG(mt ? IR_NE : IR_EQ, IRT_TAB), mix.tab, lj_ir_knull(J, IRT_TAB)); |
678 | nocheck: | 678 | nocheck: |
679 | if (mt) { | 679 | if (mt) { |
680 | GCstr *mmstr = strref(J2G(J)->mmname[mm]); | 680 | GCstr *mmstr = mmname_str(J2G(J), mm); |
681 | cTValue *mo = lj_tab_getstr(mt, mmstr); | 681 | cTValue *mo = lj_tab_getstr(mt, mmstr); |
682 | if (mo && !tvisnil(mo)) | 682 | if (mo && !tvisnil(mo)) |
683 | copyTV(J->L, &ix->mobjv, mo); | 683 | copyTV(J->L, &ix->mobjv, mo); |
684 | ix->mtv = mt; | 684 | ix->mtv = mt; |
685 | settabV(J->L, &mix.tabv, mt); | 685 | settabV(J->L, &mix.tabv, mt); |
686 | if (isdead(J2G(J), obj2gco(mmstr))) | ||
687 | flipwhite(obj2gco(mmstr)); /* Need same logic as lj_str_new(). */ | ||
688 | setstrV(J->L, &mix.keyv, mmstr); | 686 | setstrV(J->L, &mix.keyv, mmstr); |
689 | mix.key = lj_ir_kstr(J, mmstr); | 687 | mix.key = lj_ir_kstr(J, mmstr); |
690 | mix.val = 0; | 688 | mix.val = 0; |
@@ -914,9 +912,9 @@ static int nommstr(jit_State *J, TRef key) | |||
914 | if (tref_isstr(key)) { | 912 | if (tref_isstr(key)) { |
915 | if (tref_isk(key)) { | 913 | if (tref_isk(key)) { |
916 | GCstr *str = ir_kstr(IR(tref_ref(key))); | 914 | GCstr *str = ir_kstr(IR(tref_ref(key))); |
917 | uint32_t i; | 915 | uint32_t mm; |
918 | for (i = 0; i <= MM_FAST; i++) | 916 | for (mm = 0; mm <= MM_FAST; mm++) |
919 | if (strref(J2G(J)->mmname[i]) == str) | 917 | if (mmname_str(J2G(J), mm) == str) |
920 | return 0; /* MUST be one the fast metamethod names. */ | 918 | return 0; /* MUST be one the fast metamethod names. */ |
921 | } else { | 919 | } else { |
922 | return 0; /* Variable string key MAY be a metamethod name. */ | 920 | return 0; /* Variable string key MAY be a metamethod name. */ |
@@ -999,7 +997,7 @@ static TRef rec_idx(jit_State *J, RecordIndex *ix) | |||
999 | /* Need to duplicate the hasmm check for the early guards. */ | 997 | /* Need to duplicate the hasmm check for the early guards. */ |
1000 | int hasmm = 0; | 998 | int hasmm = 0; |
1001 | if (ix->idxchain && mt) { | 999 | if (ix->idxchain && mt) { |
1002 | cTValue *mo = lj_tab_getstr(mt, strref(J2G(J)->mmname[MM_newindex])); | 1000 | cTValue *mo = lj_tab_getstr(mt, mmname_str(J2G(J), MM_newindex)); |
1003 | hasmm = mo && !tvisnil(mo); | 1001 | hasmm = mo && !tvisnil(mo); |
1004 | } | 1002 | } |
1005 | if (hasmm) | 1003 | if (hasmm) |
diff --git a/src/lj_str.c b/src/lj_str.c index 9aa62582..7b38cecc 100644 --- a/src/lj_str.c +++ b/src/lj_str.c | |||
@@ -88,7 +88,8 @@ GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx) | |||
88 | for (o = gcref(g->strhash[h & g->strmask]); o != NULL; o = gcnext(o)) { | 88 | for (o = gcref(g->strhash[h & g->strmask]); o != NULL; o = gcnext(o)) { |
89 | GCstr *tso = gco2str(o); | 89 | GCstr *tso = gco2str(o); |
90 | if (tso->len == len && (memcmp(str, strdata(tso), len) == 0)) { | 90 | if (tso->len == len && (memcmp(str, strdata(tso), len) == 0)) { |
91 | if (isdead(g, o)) flipwhite(o); /* Resurrect if dead. */ | 91 | /* Resurrect if dead. Can only happen with fixstring() (keywords). */ |
92 | if (isdead(g, o)) flipwhite(o); | ||
92 | return tso; /* Return existing string. */ | 93 | return tso; /* Return existing string. */ |
93 | } | 94 | } |
94 | } | 95 | } |