summaryrefslogtreecommitdiff
path: root/src/lj_record.c
diff options
context:
space:
mode:
authorMike Pall <mike>2010-02-18 19:37:30 +0100
committerMike Pall <mike>2010-02-18 19:37:30 +0100
commitbbe7d818d9d9d47c48f255104166a58e7f65d3ec (patch)
tree95272f7b7a6ac217ba0a7f1359897b9f7c4af10c /src/lj_record.c
parentb11eeab906b4c5f26f257d8c75987769abd68507 (diff)
downloadluajit-bbe7d818d9d9d47c48f255104166a58e7f65d3ec.tar.gz
luajit-bbe7d818d9d9d47c48f255104166a58e7f65d3ec.tar.bz2
luajit-bbe7d818d9d9d47c48f255104166a58e7f65d3ec.zip
Allow linking to already compiled functions.
Diffstat (limited to 'src/lj_record.c')
-rw-r--r--src/lj_record.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index 3f7c2bde..42f9a8ae 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -1734,22 +1734,40 @@ static void check_call_unroll(jit_State *J)
1734 } 1734 }
1735} 1735}
1736 1736
1737static void rec_func_lua(jit_State *J) 1737/* Record Lua function setup. */
1738static void rec_func_setup(jit_State *J)
1738{ 1739{
1739 GCproto *pt = J->pt; 1740 GCproto *pt = J->pt;
1741 BCReg s, numparams = pt->numparams;
1740 if ((pt->flags & PROTO_NO_JIT)) 1742 if ((pt->flags & PROTO_NO_JIT))
1741 lj_trace_err(J, LJ_TRERR_CJITOFF); 1743 lj_trace_err(J, LJ_TRERR_CJITOFF);
1742 lua_assert(!(pt->flags & PROTO_IS_VARARG)); 1744 lua_assert(!(pt->flags & PROTO_IS_VARARG));
1743 if (J->baseslot + pt->framesize >= LJ_MAX_JSLOTS) 1745 if (J->baseslot + pt->framesize >= LJ_MAX_JSLOTS)
1744 lj_trace_err(J, LJ_TRERR_STACKOV); 1746 lj_trace_err(J, LJ_TRERR_STACKOV);
1745 /* Fill up missing args with nil. */ 1747 /* Fill up missing parameters with nil. */
1746 while (J->maxslot < pt->numparams) 1748 for (s = J->maxslot; s < numparams; s++)
1747 J->base[J->maxslot++] = TREF_NIL; 1749 J->base[s] = TREF_NIL;
1748 /* The remaining slots should never be read before they are written. */ 1750 /* The remaining slots should never be read before they are written. */
1749 J->maxslot = pt->numparams; 1751 J->maxslot = numparams;
1752}
1753
1754/* Record entry to a Lua function. */
1755static void rec_func_lua(jit_State *J)
1756{
1757 rec_func_setup(J);
1750 check_call_unroll(J); 1758 check_call_unroll(J);
1751} 1759}
1752 1760
1761/* Record entry to an already compiled function. */
1762static void rec_func_jit(jit_State *J, TraceNo lnk)
1763{
1764 rec_func_setup(J);
1765 J->instunroll = 0; /* Cannot continue across a compiled function. */
1766 if (J->pc == J->startpc && J->framedepth + J->retdepth == 0)
1767 lnk = J->curtrace; /* Can form an extra tail-recursive loop. */
1768 rec_stop(J, lnk); /* Link to the function. */
1769}
1770
1753/* -- Record allocations -------------------------------------------------- */ 1771/* -- Record allocations -------------------------------------------------- */
1754 1772
1755static TRef rec_tnew(jit_State *J, uint32_t ah) 1773static TRef rec_tnew(jit_State *J, uint32_t ah)
@@ -2127,9 +2145,8 @@ void lj_record_ins(jit_State *J)
2127 case BC_FUNCF: 2145 case BC_FUNCF:
2128 rec_func_lua(J); 2146 rec_func_lua(J);
2129 break; 2147 break;
2130
2131 case BC_JFUNCF: 2148 case BC_JFUNCF:
2132 lj_trace_err(J, LJ_TRERR_NYILNKF); 2149 rec_func_jit(J, rc);
2133 break; 2150 break;
2134 2151
2135 case BC_FUNCV: 2152 case BC_FUNCV: