Hugo Musso Gualandi пре 3 година
родитељ
комит
74c1700704
2 измењених фајлова са 22 додато и 7 уклоњено
  1. 19 0
      src/functions_header.c
  2. 3 7
      src/luaot_functions.c

+ 19 - 0
src/functions_header.c

@@ -878,3 +878,22 @@ CallInfo* luaot_CALL(lua_State *L, LuaotExecuteState *ctx, const Instruction *pc
         return ctx->ci;
     }
 }
+
+static
+void luaot_VARARG(lua_State *L, LuaotExecuteState *ctx, const Instruction *pc,
+                  StkId ra, int n)
+{
+    Protect(luaT_getvarargs(L, ctx->ci, ra, n));
+}
+
+static
+void luaot_VARARGPREP(lua_State *L, LuaotExecuteState *ctx, const Instruction *pc,
+                      int a)
+{
+    ProtectNT(luaT_adjustvarargs(L, a, ctx->ci, ctx->cl->p));
+    if (l_unlikely(ctx->trap)) {  /* previous "Protect" updated trap */
+      luaD_hookcall(L, ctx->ci);
+      L->oldpc = 1;  /* next opcode will be seen as a "new" line */
+    }
+    updatebase(ctx->ci);  /* function has new base after adjustment */
+}

+ 3 - 7
src/luaot_functions.c

@@ -656,16 +656,12 @@ void create_function(Proto *f)
             }
             case OP_VARARG: {
                 println("    int n = GETARG_C(i) - 1;  /* required results */");
-                println("    Protect(luaT_getvarargs(L, ctx->ci, ra, n));");
+                println("    luaot_VARARG(L, ctx, pc, ra, n);");
                 break;
             }
             case OP_VARARGPREP: {
-                println("    ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ctx->ci, ctx->cl->p));");
-                println("    if (l_unlikely(ctx->trap)) {  /* previous \"Protect\" updated trap */");
-                println("      luaD_hookcall(L, ctx->ci);");
-                println("      L->oldpc = 1;  /* next opcode will be seen as a \"new\" line */");
-                println("    }");
-                println("    updatebase(ctx->ci);  /* function has new base after adjustment */");
+                println("    int a = GETARG_A(i);");
+                println("    luaot_VARARGPREP(L, ctx, pc, a);");
                 break;
             }
             case OP_EXTRAARG: {