فهرست منبع

Reformat vmfetch instruction

Hugo Musso Gualandi 5 سال پیش
والد
کامیت
ebee5735ea
2فایلهای تغییر یافته به همراه17 افزوده شده و 6 حذف شده
  1. 7 4
      src/luaot.c
  2. 10 2
      src/luaot_header.c

+ 7 - 4
src/luaot.c

@@ -592,6 +592,12 @@ void create_function(Proto *p)
     println("  base = ci->func + 1;");
     println("  /* main loop of interpreter */");
     println("  Instruction *function_code = cl->p->code;");
+    println("  Instruction i;");
+    println("  StkId ra;");
+    println("  (void) function_code;");
+    println("  (void) i;");
+    println("  (void) ra;");
+
     println(" ");
 
     for (int pc = 0; pc < p->sizecode; pc++) {
@@ -621,10 +627,7 @@ void create_function(Proto *p)
         }
 
         println("  label_%02d : {", pc);
-        println("    aot_check_trap();");
-        println("    Instruction i = 0x%08x;", instr);
-        println("    StkId ra = RA(i);");
-        println("    (void) ra;");
+        println("    aot_vmfetch(0x%08x);", instr);
 
         switch (op) {
             case OP_MOVE:

+ 10 - 2
src/luaot_header.c

@@ -120,8 +120,16 @@
 // constants, the C compiler should be able to optimize the code in many cases.
 //
 
-#define aot_check_trap() \
+#undef  vmfetch
+#define aot_vmfetch(instr)	{ \
   if (trap) {  /* stack reallocation or hooks? */ \
     trap = luaG_traceexec(L, LUA_AOT_PC - 1);  /* handle hooks */ \
     updatebase(ci);  /* correct stack */ \
-  }
+  } \
+  i = instr; \
+  ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \
+}
+
+#undef  vmdispatch
+#undef  vmcase
+#undef  vmbreak