From 62a392ff465b26b39f91a4959895a8330c4eeebd Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 2 Mar 2018 15:59:19 -0300 Subject: [PATCH] using jump tables when available --- lvm.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lvm.c b/lvm.c index cd54369e..891e7d8d 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.347 2018/02/23 13:13:31 roberto Exp roberto $ +** $Id: lvm.c,v 2.348 2018/02/26 14:16:05 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -31,6 +31,16 @@ #include "lvm.h" +/* +** By default, use jump tables in the main interpreter loop on gcc +** and compatible compilers. +*/ +#if !defined(LUA_USE_JUMPTABLE) +#define LUA_USE_JUMPTABLE defined(__GNUC__) +#endif + + + /* limit for table tag-method chains (to avoid infinite loops) */ #define MAXTAGLOOP 2000 @@ -871,6 +881,9 @@ void luaV_execute (lua_State *L, CallInfo *ci) { StkId base; const Instruction *pc; int trap; +#if LUA_USE_JUMPTABLE +#include "ljumptab.h" +#endif tailcall: trap = L->hookmask; cl = clLvalue(s2v(ci->func));