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/lj_record.c | |
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/lj_record.c')
-rw-r--r-- | src/lj_record.c | 12 |
1 files changed, 5 insertions, 7 deletions
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) |