Browse Source

Enable coroutines by default on trampoline

Hugo Musso Gualandi 4 years ago
parent
commit
fe377d50c4
3 changed files with 15 additions and 9 deletions
  1. 9 7
      scripts/bench-run.lua
  2. 3 1
      src/luaot-trampoline.c
  3. 3 1
      src/luaot.c

+ 9 - 7
scripts/bench-run.lua

@@ -29,11 +29,13 @@ local benchs = {
 }
 }
 
 
 local impls = {
 local impls = {
-    { name = "jit", suffix = "",     interpreter = "luajit",     compile = false                    },
-    { name = "lua", suffix = "",     interpreter = "../src/lua", compile = false,                   },
-    { name = "aot", suffix = "_aot", interpreter = "../src/lua", compile = "../src/luaot"           },
-    { name = "cor", suffix = "_cor", interpreter = "../src/lua", compile = "../src/luaot -C"        },
-    { name = "trm", suffix = "_trm", interpreter = "../src/lua", compile = "../src/luaot-trampoline"},
+    { name = "jit", suffix = "",     interpreter = "luajit",        compile = false                           },
+    { name = "jof", suffix = "",     interpreter = "luajit -j off", compile = false                           },
+    { name = "lua", suffix = "",     interpreter = "../src/lua",    compile = false,                          },
+    { name = "swt", suffix = "",     interpreter = "../src/lua-sw", compile = false,                          },
+    { name = "aot", suffix = "_aot", interpreter = "../src/lua",    compile = "../src/luaot"                  },
+    { name = "cor", suffix = "_cor", interpreter = "../src/lua",    compile = "../src/luaot --coro"           },
+    { name = "trm", suffix = "_trm", interpreter = "../src/lua",    compile = "../src/luaot-trampoline --coro"},
 }
 }
 
 
 --
 --
@@ -90,14 +92,14 @@ for _, b in ipairs(benchs) do
     for _, s in ipairs(impls) do
     for _, s in ipairs(impls) do
 
 
         local mod
         local mod
-        if s.name == "jit" and exists(b.name.."_jit.lua") then
+        if string.match(s.interpreter, "luajit") and exists(b.name.."_jit.lua") then
             mod = b.name .. "_jit"
             mod = b.name .. "_jit"
         else
         else
             mod = b.name .. s.suffix
             mod = b.name .. s.suffix
         end
         end
 
 
         local n = assert(b[nkey])
         local n = assert(b[nkey])
-        local cmd = prepare("$1 main.lua $2 $3 > /dev/null", s.interpreter, mod, n)
+        local cmd = prepare(s.interpreter .. " main.lua $1 $2 > /dev/null", mod, n)
 
 
         for rep = 1, repetitions do
         for rep = 1, repetitions do
             print(string.format("RUN %s %s %s", b.name, s.name, rep))
             print(string.format("RUN %s %s %s", b.name, s.name, rep))

+ 3 - 1
src/luaot-trampoline.c

@@ -93,8 +93,10 @@ static void doargs(int argc, char **argv)
         if (do_opts && arg[0] == '-') {
         if (do_opts && arg[0] == '-') {
             if (0 == strcmp(arg, "--")) {
             if (0 == strcmp(arg, "--")) {
                 do_opts = 0;
                 do_opts = 0;
-            } else if (0 == strcmp(arg, "-C")) {
+            } else if (0 == strcmp(arg, "--coro")) {
                 enable_coroutines = 1;
                 enable_coroutines = 1;
+            } else if (0 == strcmp(arg, "--no-coro")) {
+                enable_coroutines = 0;
             } else if (0 == strcmp(arg, "-h")) {
             } else if (0 == strcmp(arg, "-h")) {
                 usage();
                 usage();
                 exit(0);
                 exit(0);

+ 3 - 1
src/luaot.c

@@ -93,8 +93,10 @@ static void doargs(int argc, char **argv)
         if (do_opts && arg[0] == '-') {
         if (do_opts && arg[0] == '-') {
             if (0 == strcmp(arg, "--")) {
             if (0 == strcmp(arg, "--")) {
                 do_opts = 0;
                 do_opts = 0;
-            } else if (0 == strcmp(arg, "-C")) {
+            } else if (0 == strcmp(arg, "--coro")) {
                 enable_coroutines = 1;
                 enable_coroutines = 1;
+            } else if (0 == strcmp(arg, "--no-coro")) {
+                enable_coroutines = 0;
             } else if (0 == strcmp(arg, "-h")) {
             } else if (0 == strcmp(arg, "-h")) {
                 usage();
                 usage();
                 exit(0);
                 exit(0);