Browse Source

Add subroutine for aot_vmfetch

Hugo Musso Gualandi 3 years ago
parent
commit
3ff9680788
2 changed files with 13 additions and 6 deletions
  1. 11 4
      src/functions_header.c
  2. 2 2
      src/luaot_functions.c

+ 11 - 4
src/functions_header.c

@@ -12,7 +12,7 @@
 //
 //
 
-struct LuaotExecuteState {
+typedef struct {
     //lua_State *L;
     //Instruction i;
     CallInfo *ci;
@@ -21,7 +21,7 @@ struct LuaotExecuteState {
     StkId base;
     const Instruction *pc;
     int trap;
-};
+} LuaotExecuteState;
 
 
 //
@@ -160,8 +160,7 @@ struct LuaotExecuteState {
 #undef  vmfetch
 #define aot_vmfetch(instr)	{ \
   if (l_unlikely(ctx->trap)) {  /* stack reallocation or hooks? */ \
-    ctx->trap = luaG_traceexec(L, LUAOT_PC - 1);  /* handle hooks */ \
-    updatebase(ctx->ci);  /* correct stack */ \
+    luaot_vmfetch_trap(L, ctx, LUAOT_PC-1); \
   } \
   i = instr; \
   ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \
@@ -171,3 +170,11 @@ struct LuaotExecuteState {
 #undef  vmcase
 #undef  vmbreak
 
+
+static
+void luaot_vmfetch_trap(lua_State *L, LuaotExecuteState *ctx, const Instruction *pc)
+{
+    ctx->trap = luaG_traceexec(L, pc);  /* handle hooks */ \
+    updatebase(ctx->ci);  /* correct stack */ \
+}
+

+ 2 - 2
src/luaot_functions.c

@@ -41,8 +41,8 @@ void create_function(Proto *f)
     println("static");
     println("CallInfo *magic_implementation_%02d(lua_State *L, CallInfo *ci)", func_id);
     println("{");
-    println("  struct LuaotExecuteState ctx_;");
-    println("  struct LuaotExecuteState *ctx = &ctx_;");
+    println("  LuaotExecuteState ctx_;");
+    println("  LuaotExecuteState *ctx = &ctx_;");
     printnl();    
     println("  ctx->ci = ci;");
     println("  ctx->trap = L->hookmask;");