|
@@ -19,12 +19,21 @@ void println_goto_ret()
|
|
{
|
|
{
|
|
// This is the piece of code that is after the "ret" label.
|
|
// This is the piece of code that is after the "ret" label.
|
|
// It should be used in the places that do "goto ret;"
|
|
// It should be used in the places that do "goto ret;"
|
|
|
|
+ #if AOT_USE_TAILCALL
|
|
println(" if (ci->callstatus & CIST_FRESH)");
|
|
println(" if (ci->callstatus & CIST_FRESH)");
|
|
println(" return; /* end this frame */");
|
|
println(" return; /* end this frame */");
|
|
println(" else {");
|
|
println(" else {");
|
|
println(" ci = ci->previous;");
|
|
println(" ci = ci->previous;");
|
|
println(" return luaV_execute(L, ci); /* continue running caller in this frame */"); // (!)
|
|
println(" return luaV_execute(L, ci); /* continue running caller in this frame */"); // (!)
|
|
println(" }");
|
|
println(" }");
|
|
|
|
+ #else
|
|
|
|
+ println(" if (ci->callstatus & CIST_FRESH)");
|
|
|
|
+ println(" return NULL; /* end this frame */");
|
|
|
|
+ println(" else {");
|
|
|
|
+ println(" ci = ci->previous;");
|
|
|
|
+ println(" return ci;");
|
|
|
|
+ println(" }");
|
|
|
|
+ #endif
|
|
}
|
|
}
|
|
|
|
|
|
static
|
|
static
|
|
@@ -40,7 +49,11 @@ void create_function(Proto *f)
|
|
}
|
|
}
|
|
|
|
|
|
println("static");
|
|
println("static");
|
|
|
|
+#if AOT_USE_TAILCALL
|
|
println("void magic_implementation_%02d(lua_State *L, CallInfo *ci)", func_id);
|
|
println("void magic_implementation_%02d(lua_State *L, CallInfo *ci)", func_id);
|
|
|
|
+#else
|
|
|
|
+ println("CallInfo *magic_implementation_%02d(lua_State *L, CallInfo *ci)", func_id);
|
|
|
|
+#endif
|
|
println("{");
|
|
println("{");
|
|
println(" LClosure *cl;");
|
|
println(" LClosure *cl;");
|
|
println(" TValue *k;");
|
|
println(" TValue *k;");
|
|
@@ -574,7 +587,11 @@ void create_function(Proto *f)
|
|
println(" else {");
|
|
println(" else {");
|
|
println(" ci = newci;");
|
|
println(" ci = newci;");
|
|
println(" ci->callstatus = 0; /* call re-uses 'luaV_execute' */");
|
|
println(" ci->callstatus = 0; /* call re-uses 'luaV_execute' */");
|
|
|
|
+ #if AOT_USE_TAILCALL
|
|
println(" return luaV_execute(L, ci);"); // (!!!)
|
|
println(" return luaV_execute(L, ci);"); // (!!!)
|
|
|
|
+ #else
|
|
|
|
+ println(" return ci;");
|
|
|
|
+ #endif
|
|
println(" }");
|
|
println(" }");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -609,7 +626,11 @@ void create_function(Proto *f)
|
|
println(" }");
|
|
println(" }");
|
|
println(" ci->func -= delta; /* restore 'func' (if vararg) */");
|
|
println(" ci->func -= delta; /* restore 'func' (if vararg) */");
|
|
println(" luaD_pretailcall(L, ci, ra, b); /* prepare call frame */");
|
|
println(" luaD_pretailcall(L, ci, ra, b); /* prepare call frame */");
|
|
|
|
+ #if AOT_USE_TAILCALL
|
|
println(" return luaV_execute(L, ci); /* execute the callee */"); // (!)
|
|
println(" return luaV_execute(L, ci); /* execute the callee */"); // (!)
|
|
|
|
+ #else
|
|
|
|
+ println(" return ci;");
|
|
|
|
+ #endif
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case OP_RETURN: {
|
|
case OP_RETURN: {
|