diff options
author | Mike Pall <mike> | 2010-04-18 13:41:30 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2010-04-19 00:43:35 +0200 |
commit | 932cda0fe3cbd34e60aa68479935c946f69b756f (patch) | |
tree | 9e46aa620a75b5ac5bc95413b8b7b57e507d82a1 /src/lj_record.c | |
parent | ff82df797a5ddf6ed2610ff1808b1fdc53686ea1 (diff) | |
download | luajit-932cda0fe3cbd34e60aa68479935c946f69b756f.tar.gz luajit-932cda0fe3cbd34e60aa68479935c946f69b756f.tar.bz2 luajit-932cda0fe3cbd34e60aa68479935c946f69b756f.zip |
Replace on-trace GC frame syncing with interpreter exit.
Need to sync GC objects to stack only during atomic GC phase.
Need to setup a proper frame structure only for calling finalizers.
Force an exit to the interpreter and let it handle the uncommon cases.
Finally solves the "NYI: gcstep sync with frames" issue.
Diffstat (limited to 'src/lj_record.c')
-rw-r--r-- | src/lj_record.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/lj_record.c b/src/lj_record.c index e89d9c26..206eedca 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -1885,13 +1885,22 @@ static TRef rec_tnew(jit_State *J, uint32_t ah) | |||
1885 | 1885 | ||
1886 | /* -- Record bytecode ops ------------------------------------------------- */ | 1886 | /* -- Record bytecode ops ------------------------------------------------- */ |
1887 | 1887 | ||
1888 | /* Optimize state after comparison. */ | 1888 | /* Prepare for comparison. */ |
1889 | static void optstate_comp(jit_State *J, int cond) | 1889 | static void rec_comp_prep(jit_State *J) |
1890 | { | ||
1891 | /* Prevent merging with snapshot #0 (GC exit) since we fixup the PC. */ | ||
1892 | if (J->cur.nsnap == 1 && J->cur.snap[0].ref == J->cur.nins) | ||
1893 | emitir_raw(IRT(IR_NOP, IRT_NIL), 0, 0); | ||
1894 | lj_snap_add(J); | ||
1895 | } | ||
1896 | |||
1897 | /* Fixup comparison. */ | ||
1898 | static void rec_comp_fixup(jit_State *J, int cond) | ||
1890 | { | 1899 | { |
1891 | BCIns jmpins = J->pc[1]; | 1900 | BCIns jmpins = J->pc[1]; |
1892 | const BCIns *npc = J->pc + 2 + (cond ? bc_j(jmpins) : 0); | 1901 | const BCIns *npc = J->pc + 2 + (cond ? bc_j(jmpins) : 0); |
1893 | SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; | 1902 | SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; |
1894 | /* Avoid re-recording the comparison in side traces. */ | 1903 | /* Set PC to opposite target to avoid re-recording the comp. in side trace. */ |
1895 | J->cur.snapmap[snap->mapofs + snap->nent] = SNAP_MKPC(npc); | 1904 | J->cur.snapmap[snap->mapofs + snap->nent] = SNAP_MKPC(npc); |
1896 | J->needsnap = 1; | 1905 | J->needsnap = 1; |
1897 | /* Shrink last snapshot if possible. */ | 1906 | /* Shrink last snapshot if possible. */ |
@@ -1987,7 +1996,7 @@ void lj_record_ins(jit_State *J) | |||
1987 | break; /* Interpreter will throw for two different types. */ | 1996 | break; /* Interpreter will throw for two different types. */ |
1988 | } | 1997 | } |
1989 | } | 1998 | } |
1990 | lj_snap_add(J); | 1999 | rec_comp_prep(J); |
1991 | irop = (int)op - (int)BC_ISLT + (int)IR_LT; | 2000 | irop = (int)op - (int)BC_ISLT + (int)IR_LT; |
1992 | if (ta == IRT_NUM) { | 2001 | if (ta == IRT_NUM) { |
1993 | if ((irop & 1)) irop ^= 4; /* ISGE/ISGT are unordered. */ | 2002 | if ((irop & 1)) irop ^= 4; /* ISGE/ISGT are unordered. */ |
@@ -2004,7 +2013,7 @@ void lj_record_ins(jit_State *J) | |||
2004 | break; | 2013 | break; |
2005 | } | 2014 | } |
2006 | emitir(IRTG(irop, ta), ra, rc); | 2015 | emitir(IRTG(irop, ta), ra, rc); |
2007 | optstate_comp(J, ((int)op ^ irop) & 1); | 2016 | rec_comp_fixup(J, ((int)op ^ irop) & 1); |
2008 | } | 2017 | } |
2009 | break; | 2018 | break; |
2010 | 2019 | ||
@@ -2015,14 +2024,14 @@ void lj_record_ins(jit_State *J) | |||
2015 | /* Emit nothing for two non-table, non-udata consts. */ | 2024 | /* Emit nothing for two non-table, non-udata consts. */ |
2016 | if (!(tref_isk2(ra, rc) && !(tref_istab(ra) || tref_isudata(ra)))) { | 2025 | if (!(tref_isk2(ra, rc) && !(tref_istab(ra) || tref_isudata(ra)))) { |
2017 | int diff; | 2026 | int diff; |
2018 | lj_snap_add(J); | 2027 | rec_comp_prep(J); |
2019 | diff = rec_objcmp(J, ra, rc, rav, rcv); | 2028 | diff = rec_objcmp(J, ra, rc, rav, rcv); |
2020 | if (diff == 1 && (tref_istab(ra) || tref_isudata(ra))) { | 2029 | if (diff == 1 && (tref_istab(ra) || tref_isudata(ra))) { |
2021 | /* Only check __eq if different, but the same type (table or udata). */ | 2030 | /* Only check __eq if different, but the same type (table or udata). */ |
2022 | rec_mm_equal(J, &ix, (int)op); | 2031 | rec_mm_equal(J, &ix, (int)op); |
2023 | break; | 2032 | break; |
2024 | } | 2033 | } |
2025 | optstate_comp(J, ((int)op & 1) == !diff); | 2034 | rec_comp_fixup(J, ((int)op & 1) == !diff); |
2026 | } | 2035 | } |
2027 | break; | 2036 | break; |
2028 | 2037 | ||