Hugo Musso Gualandi 5 лет назад
Родитель
Сommit
d2b39d5cfb
5 измененных файлов с 24 добавлено и 6 удалено
  1. 6 0
      .gitignore
  2. 8 1
      src/ldo.c
  3. 1 0
      src/lfunc.c
  4. 7 0
      src/lobject.h
  5. 2 5
      src/luaconf.h

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
+src/lua
+src/luac
+
+*.a
+*.o
+*.so

+ 8 - 1
src/ldo.c

@@ -501,7 +501,14 @@ void luaD_call (lua_State *L, StkId func, int nresults) {
       for (; narg < nfixparams; narg++)
         setnilvalue(s2v(L->top++));  /* complete missing arguments */
       lua_assert(ci->top <= L->stack_last);
-      luaV_execute(L, ci);  /* run the function */
+
+      /* run the function */
+      if (p->aot_implementation) {
+          p->aot_implementation(L, ci);
+      } else {
+          luaV_execute(L, ci);
+      }
+
       break;
     }
     default: {  /* not a function */

+ 1 - 0
src/lfunc.c

@@ -265,6 +265,7 @@ Proto *luaF_newproto (lua_State *L) {
   f->linedefined = 0;
   f->lastlinedefined = 0;
   f->source = NULL;
+  f->aot_implementation = NULL;
   return f;
 }
 

+ 7 - 0
src/lobject.h

@@ -490,6 +490,11 @@ typedef struct AbsLineInfo {
   int line;
 } AbsLineInfo;
 
+/*
+** AOT implementation
+*/ 
+typedef void (*aot_compiled_function) (lua_State *L, struct CallInfo *ci);
+
 /*
 ** Function Prototypes
 */
@@ -516,6 +521,8 @@ typedef struct Proto {
   LocVar *locvars;  /* information about local variables (debug information) */
   TString  *source;  /* used for debug information */
   GCObject *gclist;
+
+  aot_compiled_function aot_implementation;
 } Proto;
 
 /* }================================================================== */

+ 2 - 5
src/luaconf.h

@@ -315,12 +315,9 @@
 ** give a warning about it. To avoid these warnings, change to the
 ** default definition.
 */
-#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
-    defined(__ELF__)		/* { */
-#define LUAI_FUNC	__attribute__((visibility("internal"))) extern
-#else				/* }{ */
+
+/* AOT: export all internal APIs */
 #define LUAI_FUNC	extern
-#endif				/* } */
 
 #define LUAI_DDEC(dec)	LUAI_FUNC dec
 #define LUAI_DDEF	/* empty */