mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-24 00:14:05 +02:00
add back the old host patches for lua to improve portability
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@14631 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
871d69669e
commit
4d27062031
@ -19,6 +19,7 @@ PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
|
||||
http://www.tecgraf.puc-rio.br/lua/ftp/
|
||||
PKG_MD5SUM:=d0870f2de55d59c1c8419f36e8fac150
|
||||
|
||||
HOST_PATCH_DIR=./patches-host
|
||||
include $(INCLUDE_DIR)/host-build.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
3806
package/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch
Normal file
3806
package/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch
Normal file
File diff suppressed because it is too large
Load Diff
13
package/lua/patches-host/015-lnum-ppc-compat.patch
Normal file
13
package/lua/patches-host/015-lnum-ppc-compat.patch
Normal file
@ -0,0 +1,13 @@
|
||||
Index: lua-5.1.3/src/lua.h
|
||||
===================================================================
|
||||
--- lua-5.1.3.orig/src/lua.h 2008-06-29 11:45:55.000000000 +0200
|
||||
+++ lua-5.1.3/src/lua.h 2008-06-29 11:46:28.000000000 +0200
|
||||
@@ -79,7 +79,7 @@
|
||||
* not acceptable for 5.1, maybe 5.2 onwards?
|
||||
* 9: greater than existing (5.1) type values.
|
||||
*/
|
||||
-#define LUA_TINT (-2)
|
||||
+#define LUA_TINT 9
|
||||
|
||||
#define LUA_TNIL 0
|
||||
#define LUA_TBOOLEAN 1
|
154
package/lua/patches-host/020-shared_liblua.patch
Normal file
154
package/lua/patches-host/020-shared_liblua.patch
Normal file
@ -0,0 +1,154 @@
|
||||
Index: lua-5.1.4/Makefile
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/Makefile 2008-08-24 16:46:37.000000000 +0200
|
||||
+++ lua-5.1.4/Makefile 2008-08-24 16:48:42.000000000 +0200
|
||||
@@ -42,8 +42,8 @@
|
||||
|
||||
# What to install.
|
||||
TO_BIN= lua luac
|
||||
-TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
|
||||
-TO_LIB= liblua.a
|
||||
+TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp lnum_config.h
|
||||
+TO_LIB= liblua.a liblua.so.$R
|
||||
TO_MAN= lua.1 luac.1
|
||||
|
||||
# Lua version and release.
|
||||
@@ -63,6 +63,7 @@
|
||||
cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
|
||||
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
|
||||
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
|
||||
+ ln -s liblua.so.$R $(INSTALL_LIB)/liblua.so
|
||||
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
|
||||
|
||||
ranlib:
|
||||
Index: lua-5.1.4/src/ldo.h
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/src/ldo.h 2008-08-24 16:46:37.000000000 +0200
|
||||
+++ lua-5.1.4/src/ldo.h 2008-08-24 16:48:42.000000000 +0200
|
||||
@@ -46,7 +46,7 @@
|
||||
LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
|
||||
LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
|
||||
LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
|
||||
-LUAI_FUNC void luaD_growstack (lua_State *L, int n);
|
||||
+LUA_API void luaD_growstack (lua_State *L, int n);
|
||||
|
||||
LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
|
||||
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
|
||||
Index: lua-5.1.4/src/lfunc.h
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/src/lfunc.h 2008-08-24 16:46:37.000000000 +0200
|
||||
+++ lua-5.1.4/src/lfunc.h 2008-08-24 16:48:42.000000000 +0200
|
||||
@@ -18,7 +18,7 @@
|
||||
cast(int, sizeof(TValue *)*((n)-1)))
|
||||
|
||||
|
||||
-LUAI_FUNC Proto *luaF_newproto (lua_State *L);
|
||||
+LUA_API Proto *luaF_newproto (lua_State *L);
|
||||
LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
|
||||
LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
|
||||
LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
|
||||
Index: lua-5.1.4/src/lmem.h
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/src/lmem.h 2008-08-24 16:46:37.000000000 +0200
|
||||
+++ lua-5.1.4/src/lmem.h 2008-08-24 16:48:42.000000000 +0200
|
||||
@@ -38,9 +38,9 @@
|
||||
((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
|
||||
|
||||
|
||||
-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
|
||||
+LUA_API void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
|
||||
size_t size);
|
||||
-LUAI_FUNC void *luaM_toobig (lua_State *L);
|
||||
+LUA_API void *luaM_toobig (lua_State *L);
|
||||
LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
|
||||
size_t size_elem, int limit,
|
||||
const char *errormsg);
|
||||
Index: lua-5.1.4/src/lstring.h
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/src/lstring.h 2008-08-24 16:46:37.000000000 +0200
|
||||
+++ lua-5.1.4/src/lstring.h 2008-08-24 16:48:42.000000000 +0200
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
|
||||
LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
|
||||
-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
|
||||
+LUA_API TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
|
||||
|
||||
|
||||
#endif
|
||||
Index: lua-5.1.4/src/lundump.h
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/src/lundump.h 2008-08-24 16:46:37.000000000 +0200
|
||||
+++ lua-5.1.4/src/lundump.h 2008-08-24 16:48:42.000000000 +0200
|
||||
@@ -17,7 +17,7 @@
|
||||
LUAI_FUNC void luaU_header (char* h);
|
||||
|
||||
/* dump one chunk; from ldump.c */
|
||||
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
|
||||
+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
|
||||
|
||||
#ifdef luac_c
|
||||
/* print one chunk; from print.c */
|
||||
Index: lua-5.1.4/src/Makefile
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/src/Makefile 2008-08-24 16:48:20.000000000 +0200
|
||||
+++ lua-5.1.4/src/Makefile 2008-08-24 16:48:42.000000000 +0200
|
||||
@@ -23,6 +23,7 @@
|
||||
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
|
||||
|
||||
LUA_A= liblua.a
|
||||
+LUA_SO= liblua.so
|
||||
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
|
||||
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
|
||||
lundump.o lvm.o lzio.o lnum.o
|
||||
@@ -33,11 +34,12 @@
|
||||
LUA_O= lua.o
|
||||
|
||||
LUAC_T= luac
|
||||
-LUAC_O= luac.o print.o
|
||||
+LUAC_O= luac.o print.o lopcodes.o
|
||||
|
||||
ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
|
||||
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
|
||||
+ALL_T= $(LUA_A) $(LUA_SO) $(LUA_T) $(LUAC_T)
|
||||
ALL_A= $(LUA_A)
|
||||
+ALL_SO= $(LUA_SO)
|
||||
|
||||
default: $(PLAT)
|
||||
|
||||
@@ -47,14 +49,23 @@
|
||||
|
||||
a: $(ALL_A)
|
||||
|
||||
+so: $(ALL_SO)
|
||||
+
|
||||
$(LUA_A): $(CORE_O) $(LIB_O)
|
||||
$(AR) $@ $?
|
||||
$(RANLIB) $@
|
||||
|
||||
-$(LUA_T): $(LUA_O) $(LUA_A)
|
||||
- $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
|
||||
+$(LUA_SO): $(CORE_O) $(LIB_O)
|
||||
+ $(CC) -o $@.$(PKG_VERSION) -shared -soname="$@.$(PKG_VERSION)" $? -nostdlib -lgcc
|
||||
+ ln -fs $@.$(PKG_VERSION) $@
|
||||
+
|
||||
+$(LUA_T): $(LUA_O) $(LUA_SO)
|
||||
+ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUA_O) $(LIBS)
|
||||
+
|
||||
+$(LUAC_T): $(LUAC_O) $(LUA_SO)
|
||||
+ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUAC_O) $(LIBS)
|
||||
|
||||
-$(LUAC_T): $(LUAC_O) $(LUA_A)
|
||||
+$(LUAC_T)-host: $(LUAC_O) $(LUA_A)
|
||||
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
|
||||
|
||||
clean:
|
||||
@@ -96,7 +107,7 @@
|
||||
$(MAKE) all MYCFLAGS=
|
||||
|
||||
linux:
|
||||
- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
|
||||
+ $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
|
||||
|
||||
macosx:
|
||||
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
|
115
package/lua/patches-host/030-archindependent-bytecode.patch
Normal file
115
package/lua/patches-host/030-archindependent-bytecode.patch
Normal file
@ -0,0 +1,115 @@
|
||||
Index: lua-5.1.4/src/ldump.c
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/src/ldump.c 2008-08-24 16:48:20.000000000 +0200
|
||||
+++ lua-5.1.4/src/ldump.c 2008-08-24 16:48:52.000000000 +0200
|
||||
@@ -67,12 +67,12 @@
|
||||
{
|
||||
if (s==NULL || getstr(s)==NULL)
|
||||
{
|
||||
- size_t size=0;
|
||||
+ unsigned int size=0;
|
||||
DumpVar(size,D);
|
||||
}
|
||||
else
|
||||
{
|
||||
- size_t size=s->tsv.len+1; /* include trailing '\0' */
|
||||
+ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
|
||||
DumpVar(size,D);
|
||||
DumpBlock(getstr(s),size,D);
|
||||
}
|
||||
Index: lua-5.1.4/src/lundump.c
|
||||
===================================================================
|
||||
--- lua-5.1.4.orig/src/lundump.c 2008-08-24 16:48:20.000000000 +0200
|
||||
+++ lua-5.1.4/src/lundump.c 2008-08-24 16:48:52.000000000 +0200
|
||||
@@ -25,6 +25,7 @@
|
||||
ZIO* Z;
|
||||
Mbuffer* b;
|
||||
const char* name;
|
||||
+ int swap;
|
||||
} LoadState;
|
||||
|
||||
#ifdef LUAC_TRUST_BINARIES
|
||||
@@ -40,7 +41,6 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
|
||||
#define LoadByte(S) (lu_byte)LoadChar(S)
|
||||
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
|
||||
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
|
||||
@@ -51,6 +51,49 @@
|
||||
IF (r!=0, "unexpected end");
|
||||
}
|
||||
|
||||
+static void LoadMem (LoadState* S, void* b, int n, size_t size)
|
||||
+{
|
||||
+ LoadBlock(S,b,n*size);
|
||||
+ if (S->swap)
|
||||
+ {
|
||||
+ char* p=(char*) b;
|
||||
+ char c;
|
||||
+ switch (size)
|
||||
+ {
|
||||
+ case 1:
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ while (n--)
|
||||
+ {
|
||||
+ c=p[0]; p[0]=p[1]; p[1]=c;
|
||||
+ p+=2;
|
||||
+ }
|
||||
+ break;
|
||||
+ case 4:
|
||||
+ while (n--)
|
||||
+ {
|
||||
+ c=p[0]; p[0]=p[3]; p[3]=c;
|
||||
+ c=p[1]; p[1]=p[2]; p[2]=c;
|
||||
+ p+=4;
|
||||
+ }
|
||||
+ break;
|
||||
+ case 8:
|
||||
+ while (n--)
|
||||
+ {
|
||||
+ c=p[0]; p[0]=p[7]; p[7]=c;
|
||||
+ c=p[1]; p[1]=p[6]; p[6]=c;
|
||||
+ c=p[2]; p[2]=p[5]; p[5]=c;
|
||||
+ c=p[3]; p[3]=p[4]; p[4]=c;
|
||||
+ p+=8;
|
||||
+ }
|
||||
+ break;
|
||||
+ default:
|
||||
+ IF(1, "bad size");
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int LoadChar(LoadState* S)
|
||||
{
|
||||
char x;
|
||||
@@ -82,7 +125,7 @@
|
||||
|
||||
static TString* LoadString(LoadState* S)
|
||||
{
|
||||
- size_t size;
|
||||
+ unsigned int size;
|
||||
LoadVar(S,size);
|
||||
if (size==0)
|
||||
return NULL;
|
||||
@@ -196,6 +239,7 @@
|
||||
char s[LUAC_HEADERSIZE];
|
||||
luaU_header(h);
|
||||
LoadBlock(S,s,LUAC_HEADERSIZE);
|
||||
+ S->swap=(s[6]!=h[6]); s[6]=h[6];
|
||||
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
|
||||
}
|
||||
|
||||
@@ -230,7 +274,7 @@
|
||||
*h++=(char)LUAC_FORMAT;
|
||||
*h++=(char)*(char*)&x; /* endianness */
|
||||
*h++=(char)sizeof(int);
|
||||
- *h++=(char)sizeof(size_t);
|
||||
+ *h++=(char)sizeof(unsigned int);
|
||||
*h++=(char)sizeof(Instruction);
|
||||
*h++=(char)sizeof(lua_Number);
|
||||
|
53
package/lua/patches-host/100-no_readline.patch
Normal file
53
package/lua/patches-host/100-no_readline.patch
Normal file
@ -0,0 +1,53 @@
|
||||
diff -ur lua-luci-5.1.3/src/luaconf.h lua-luci-5.1.3-new/src/luaconf.h
|
||||
--- lua-luci-5.1.3/src/luaconf.h 2008-04-14 13:19:54.000000000 +0200
|
||||
+++ lua-luci-5.1.3-new/src/luaconf.h 2008-04-14 13:19:17.000000000 +0200
|
||||
@@ -38,7 +38,6 @@
|
||||
#if defined(LUA_USE_LINUX)
|
||||
#define LUA_USE_POSIX
|
||||
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
|
||||
-#define LUA_USE_READLINE /* needs some extra libraries */
|
||||
#endif
|
||||
|
||||
#if defined(LUA_USE_MACOSX)
|
||||
Nur in lua-luci-5.1.3-new/src: luaconf.h.orig.
|
||||
diff -ur lua-luci-5.1.3/src/Makefile lua-luci-5.1.3-new/src/Makefile
|
||||
--- lua-luci-5.1.3/src/Makefile 2008-04-14 13:19:57.000000000 +0200
|
||||
+++ lua-luci-5.1.3-new/src/Makefile 2008-04-14 13:19:17.000000000 +0200
|
||||
@@ -17,6 +17,7 @@
|
||||
MYCFLAGS=
|
||||
MYLDFLAGS=
|
||||
MYLIBS=
|
||||
+# USE_READLINE=1
|
||||
|
||||
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
|
||||
|
||||
@@ -86,7 +87,7 @@
|
||||
@echo "MYLIBS = $(MYLIBS)"
|
||||
|
||||
# convenience targets for popular platforms
|
||||
-
|
||||
+RFLAG=$(if $(USE_READLINE),-DLUA_USE_READLINE)
|
||||
none:
|
||||
@echo "Please choose a platform:"
|
||||
@echo " $(PLATS)"
|
||||
@@ -101,16 +102,16 @@
|
||||
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
|
||||
|
||||
freebsd:
|
||||
- $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
|
||||
+ $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E$(if $(USE_READLINE), -lreadline)"
|
||||
|
||||
generic:
|
||||
$(MAKE) all MYCFLAGS=
|
||||
|
||||
linux:
|
||||
- $(MAKE) all MYCFLAGS+=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
|
||||
+ $(MAKE) all MYCFLAGS+="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E -ldl $(if $(USE_READLINE), -lreadline -lhistory -lncurses)"
|
||||
|
||||
macosx:
|
||||
- $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
|
||||
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX $(if $(USE_READLINE), MYLIBS="-lreadline")
|
||||
# use this on Mac OS X 10.3-
|
||||
# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
|
||||
|
||||
Nur in lua-luci-5.1.3-new/src: Makefile.orig.
|
15
package/lua/patches-host/200-lua-path.patch
Normal file
15
package/lua/patches-host/200-lua-path.patch
Normal file
@ -0,0 +1,15 @@
|
||||
--- b/src/luaconf.h 2008-05-06 20:10:46.000000000 +0200
|
||||
+++ a/src/luaconf.h 2008-05-06 20:10:27.000000000 +0200
|
||||
@@ -95,9 +95,9 @@
|
||||
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
|
||||
|
||||
#else
|
||||
-#define LUA_ROOT "/usr/local/"
|
||||
-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
|
||||
-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
|
||||
+#define LUA_ROOT "/usr/"
|
||||
+#define LUA_LDIR LUA_ROOT "share/lua/"
|
||||
+#define LUA_CDIR LUA_ROOT "lib/lua/"
|
||||
#define LUA_PATH_DEFAULT \
|
||||
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
|
||||
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
|
363
package/lua/patches-host/300-opcode_performance.patch
Normal file
363
package/lua/patches-host/300-opcode_performance.patch
Normal file
@ -0,0 +1,363 @@
|
||||
--- a/src/lvm.c
|
||||
+++ b/src/lvm.c
|
||||
@@ -31,6 +31,9 @@
|
||||
/* limit for table tag-method chains (to avoid loops) */
|
||||
#define MAXTAGLOOP 100
|
||||
|
||||
+#ifdef __GNUC__
|
||||
+#define COMPUTED_GOTO 1
|
||||
+#endif
|
||||
|
||||
/*
|
||||
* If 'obj' is a string, it is tried to be interpreted as a number.
|
||||
@@ -562,12 +565,63 @@
|
||||
ARITH_OP1_END
|
||||
#endif
|
||||
|
||||
+#ifdef COMPUTED_GOTO
|
||||
+#define OPCODE_TARGET(op) DO_OP_##op:
|
||||
+#define CALL_OPCODE(op) goto *opcodes[op];
|
||||
+#define OPCODE_PTR(op) [OP_##op] = &&DO_OP_##op
|
||||
+#else
|
||||
+#define OPCODE_TARGET(op) case OP_##op:
|
||||
+#define CALL_OPCODE(op) switch (op)
|
||||
+#endif
|
||||
+
|
||||
|
||||
void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
LClosure *cl;
|
||||
StkId base;
|
||||
TValue *k;
|
||||
const Instruction *pc;
|
||||
+#ifdef COMPUTED_GOTO
|
||||
+ static const void *opcodes[] = {
|
||||
+ OPCODE_PTR(MOVE),
|
||||
+ OPCODE_PTR(LOADK),
|
||||
+ OPCODE_PTR(LOADBOOL),
|
||||
+ OPCODE_PTR(LOADNIL),
|
||||
+ OPCODE_PTR(GETUPVAL),
|
||||
+ OPCODE_PTR(GETGLOBAL),
|
||||
+ OPCODE_PTR(GETTABLE),
|
||||
+ OPCODE_PTR(SETGLOBAL),
|
||||
+ OPCODE_PTR(SETUPVAL),
|
||||
+ OPCODE_PTR(SETTABLE),
|
||||
+ OPCODE_PTR(NEWTABLE),
|
||||
+ OPCODE_PTR(SELF),
|
||||
+ OPCODE_PTR(ADD),
|
||||
+ OPCODE_PTR(SUB),
|
||||
+ OPCODE_PTR(MUL),
|
||||
+ OPCODE_PTR(DIV),
|
||||
+ OPCODE_PTR(MOD),
|
||||
+ OPCODE_PTR(POW),
|
||||
+ OPCODE_PTR(UNM),
|
||||
+ OPCODE_PTR(NOT),
|
||||
+ OPCODE_PTR(LEN),
|
||||
+ OPCODE_PTR(CONCAT),
|
||||
+ OPCODE_PTR(JMP),
|
||||
+ OPCODE_PTR(EQ),
|
||||
+ OPCODE_PTR(LT),
|
||||
+ OPCODE_PTR(LE),
|
||||
+ OPCODE_PTR(TEST),
|
||||
+ OPCODE_PTR(TESTSET),
|
||||
+ OPCODE_PTR(CALL),
|
||||
+ OPCODE_PTR(TAILCALL),
|
||||
+ OPCODE_PTR(RETURN),
|
||||
+ OPCODE_PTR(FORLOOP),
|
||||
+ OPCODE_PTR(FORPREP),
|
||||
+ OPCODE_PTR(TFORLOOP),
|
||||
+ OPCODE_PTR(SETLIST),
|
||||
+ OPCODE_PTR(CLOSE),
|
||||
+ OPCODE_PTR(CLOSURE),
|
||||
+ OPCODE_PTR(VARARG)
|
||||
+ };
|
||||
+#endif
|
||||
reentry: /* entry point */
|
||||
lua_assert(isLua(L->ci));
|
||||
pc = L->savedpc;
|
||||
@@ -592,33 +646,33 @@
|
||||
lua_assert(base == L->base && L->base == L->ci->base);
|
||||
lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
|
||||
lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
|
||||
- switch (GET_OPCODE(i)) {
|
||||
- case OP_MOVE: {
|
||||
+ CALL_OPCODE(GET_OPCODE(i)) {
|
||||
+ OPCODE_TARGET(MOVE) {
|
||||
setobjs2s(L, ra, RB(i));
|
||||
continue;
|
||||
}
|
||||
- case OP_LOADK: {
|
||||
+ OPCODE_TARGET(LOADK) {
|
||||
setobj2s(L, ra, KBx(i));
|
||||
continue;
|
||||
}
|
||||
- case OP_LOADBOOL: {
|
||||
+ OPCODE_TARGET(LOADBOOL) {
|
||||
setbvalue(ra, GETARG_B(i));
|
||||
if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
|
||||
continue;
|
||||
}
|
||||
- case OP_LOADNIL: {
|
||||
+ OPCODE_TARGET(LOADNIL) {
|
||||
TValue *rb = RB(i);
|
||||
do {
|
||||
setnilvalue(rb--);
|
||||
} while (rb >= ra);
|
||||
continue;
|
||||
}
|
||||
- case OP_GETUPVAL: {
|
||||
+ OPCODE_TARGET(GETUPVAL) {
|
||||
int b = GETARG_B(i);
|
||||
setobj2s(L, ra, cl->upvals[b]->v);
|
||||
continue;
|
||||
}
|
||||
- case OP_GETGLOBAL: {
|
||||
+ OPCODE_TARGET(GETGLOBAL) {
|
||||
TValue g;
|
||||
TValue *rb = KBx(i);
|
||||
sethvalue(L, &g, cl->env);
|
||||
@@ -626,88 +680,88 @@
|
||||
Protect(luaV_gettable(L, &g, rb, ra));
|
||||
continue;
|
||||
}
|
||||
- case OP_GETTABLE: {
|
||||
+ OPCODE_TARGET(GETTABLE) {
|
||||
Protect(luaV_gettable(L, RB(i), RKC(i), ra));
|
||||
continue;
|
||||
}
|
||||
- case OP_SETGLOBAL: {
|
||||
+ OPCODE_TARGET(SETGLOBAL) {
|
||||
TValue g;
|
||||
sethvalue(L, &g, cl->env);
|
||||
lua_assert(ttisstring(KBx(i)));
|
||||
Protect(luaV_settable(L, &g, KBx(i), ra));
|
||||
continue;
|
||||
}
|
||||
- case OP_SETUPVAL: {
|
||||
+ OPCODE_TARGET(SETUPVAL) {
|
||||
UpVal *uv = cl->upvals[GETARG_B(i)];
|
||||
setobj(L, uv->v, ra);
|
||||
luaC_barrier(L, uv, ra);
|
||||
continue;
|
||||
}
|
||||
- case OP_SETTABLE: {
|
||||
+ OPCODE_TARGET(SETTABLE) {
|
||||
Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
|
||||
continue;
|
||||
}
|
||||
- case OP_NEWTABLE: {
|
||||
+ OPCODE_TARGET(NEWTABLE) {
|
||||
int b = GETARG_B(i);
|
||||
int c = GETARG_C(i);
|
||||
sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
|
||||
Protect(luaC_checkGC(L));
|
||||
continue;
|
||||
}
|
||||
- case OP_SELF: {
|
||||
+ OPCODE_TARGET(SELF) {
|
||||
StkId rb = RB(i);
|
||||
setobjs2s(L, ra+1, rb);
|
||||
Protect(luaV_gettable(L, rb, RKC(i), ra));
|
||||
continue;
|
||||
}
|
||||
- case OP_ADD: {
|
||||
+ OPCODE_TARGET(ADD) {
|
||||
TValue *rb = RKB(i), *rc= RKC(i);
|
||||
arith_op_continue( luai_numadd, try_addint, luai_vectadd );
|
||||
Protect(Arith(L, ra, rb, rc, TM_ADD)); \
|
||||
continue;
|
||||
}
|
||||
- case OP_SUB: {
|
||||
+ OPCODE_TARGET(SUB) {
|
||||
TValue *rb = RKB(i), *rc= RKC(i);
|
||||
arith_op_continue( luai_numsub, try_subint, luai_vectsub );
|
||||
Protect(Arith(L, ra, rb, rc, TM_SUB));
|
||||
continue;
|
||||
}
|
||||
- case OP_MUL: {
|
||||
+ OPCODE_TARGET(MUL) {
|
||||
TValue *rb = RKB(i), *rc= RKC(i);
|
||||
arith_op_continue(luai_nummul, try_mulint, luai_vectmul);
|
||||
Protect(Arith(L, ra, rb, rc, TM_MUL));
|
||||
continue;
|
||||
}
|
||||
- case OP_DIV: {
|
||||
+ OPCODE_TARGET(DIV) {
|
||||
TValue *rb = RKB(i), *rc= RKC(i);
|
||||
arith_op_continue(luai_numdiv, try_divint, luai_vectdiv);
|
||||
Protect(Arith(L, ra, rb, rc, TM_DIV));
|
||||
continue;
|
||||
}
|
||||
- case OP_MOD: {
|
||||
+ OPCODE_TARGET(MOD) {
|
||||
TValue *rb = RKB(i), *rc= RKC(i);
|
||||
arith_op_continue_scalar(luai_nummod, try_modint); /* scalars only */
|
||||
Protect(Arith(L, ra, rb, rc, TM_MOD));
|
||||
continue;
|
||||
}
|
||||
- case OP_POW: {
|
||||
+ OPCODE_TARGET(POW) {
|
||||
TValue *rb = RKB(i), *rc= RKC(i);
|
||||
arith_op_continue(luai_numpow, try_powint, luai_vectpow);
|
||||
Protect(Arith(L, ra, rb, rc, TM_POW));
|
||||
continue;
|
||||
}
|
||||
- case OP_UNM: {
|
||||
+ OPCODE_TARGET(UNM) {
|
||||
TValue *rb = RB(i);
|
||||
arith_op1_continue(luai_numunm, try_unmint, luai_vectunm);
|
||||
Protect(Arith(L, ra, rb, rb, TM_UNM));
|
||||
continue;
|
||||
}
|
||||
- case OP_NOT: {
|
||||
+ OPCODE_TARGET(NOT) {
|
||||
int res = l_isfalse(RB(i)); /* next assignment may change this value */
|
||||
setbvalue(ra, res);
|
||||
continue;
|
||||
}
|
||||
- case OP_LEN: {
|
||||
+ OPCODE_TARGET(LEN) {
|
||||
const TValue *rb = RB(i);
|
||||
switch (ttype(rb)) {
|
||||
case LUA_TTABLE: {
|
||||
@@ -727,18 +781,18 @@
|
||||
}
|
||||
continue;
|
||||
}
|
||||
- case OP_CONCAT: {
|
||||
+ OPCODE_TARGET(CONCAT) {
|
||||
int b = GETARG_B(i);
|
||||
int c = GETARG_C(i);
|
||||
Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
|
||||
setobjs2s(L, RA(i), base+b);
|
||||
continue;
|
||||
}
|
||||
- case OP_JMP: {
|
||||
+ OPCODE_TARGET(JMP) {
|
||||
dojump(L, pc, GETARG_sBx(i));
|
||||
continue;
|
||||
}
|
||||
- case OP_EQ: {
|
||||
+ OPCODE_TARGET(EQ) {
|
||||
TValue *rb = RKB(i);
|
||||
TValue *rc = RKC(i);
|
||||
Protect(
|
||||
@@ -748,7 +802,7 @@
|
||||
pc++;
|
||||
continue;
|
||||
}
|
||||
- case OP_LT: {
|
||||
+ OPCODE_TARGET(LT) {
|
||||
Protect(
|
||||
if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
|
||||
dojump(L, pc, GETARG_sBx(*pc));
|
||||
@@ -756,7 +810,7 @@
|
||||
pc++;
|
||||
continue;
|
||||
}
|
||||
- case OP_LE: {
|
||||
+ OPCODE_TARGET(LE) {
|
||||
Protect(
|
||||
if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
|
||||
dojump(L, pc, GETARG_sBx(*pc));
|
||||
@@ -764,13 +818,13 @@
|
||||
pc++;
|
||||
continue;
|
||||
}
|
||||
- case OP_TEST: {
|
||||
+ OPCODE_TARGET(TEST) {
|
||||
if (l_isfalse(ra) != GETARG_C(i))
|
||||
dojump(L, pc, GETARG_sBx(*pc));
|
||||
pc++;
|
||||
continue;
|
||||
}
|
||||
- case OP_TESTSET: {
|
||||
+ OPCODE_TARGET(TESTSET) {
|
||||
TValue *rb = RB(i);
|
||||
if (l_isfalse(rb) != GETARG_C(i)) {
|
||||
setobjs2s(L, ra, rb);
|
||||
@@ -779,7 +833,7 @@
|
||||
pc++;
|
||||
continue;
|
||||
}
|
||||
- case OP_CALL: {
|
||||
+ OPCODE_TARGET(CALL) {
|
||||
int b = GETARG_B(i);
|
||||
int nresults = GETARG_C(i) - 1;
|
||||
if (b != 0) L->top = ra+b; /* else previous instruction set top */
|
||||
@@ -800,7 +854,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
- case OP_TAILCALL: {
|
||||
+ OPCODE_TARGET(TAILCALL) {
|
||||
int b = GETARG_B(i);
|
||||
if (b != 0) L->top = ra+b; /* else previous instruction set top */
|
||||
L->savedpc = pc;
|
||||
@@ -832,7 +886,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
- case OP_RETURN: {
|
||||
+ OPCODE_TARGET(RETURN) {
|
||||
int b = GETARG_B(i);
|
||||
if (b != 0) L->top = ra+b-1;
|
||||
if (L->openupval) luaF_close(L, base);
|
||||
@@ -847,7 +901,7 @@
|
||||
goto reentry;
|
||||
}
|
||||
}
|
||||
- case OP_FORLOOP: {
|
||||
+ OPCODE_TARGET(FORLOOP) {
|
||||
/* If start,step and limit are all integers, we don't need to check
|
||||
* against overflow in the looping.
|
||||
*/
|
||||
@@ -875,7 +929,7 @@
|
||||
}
|
||||
continue;
|
||||
}
|
||||
- case OP_FORPREP: {
|
||||
+ OPCODE_TARGET(FORPREP) {
|
||||
const TValue *init = ra;
|
||||
const TValue *plimit = ra+1;
|
||||
const TValue *pstep = ra+2;
|
||||
@@ -898,7 +952,7 @@
|
||||
dojump(L, pc, GETARG_sBx(i));
|
||||
continue;
|
||||
}
|
||||
- case OP_TFORLOOP: {
|
||||
+ OPCODE_TARGET(TFORLOOP) {
|
||||
StkId cb = ra + 3; /* call base */
|
||||
setobjs2s(L, cb+2, ra+2);
|
||||
setobjs2s(L, cb+1, ra+1);
|
||||
@@ -914,7 +968,7 @@
|
||||
pc++;
|
||||
continue;
|
||||
}
|
||||
- case OP_SETLIST: {
|
||||
+ OPCODE_TARGET(SETLIST) {
|
||||
int n = GETARG_B(i);
|
||||
int c = GETARG_C(i);
|
||||
int last;
|
||||
@@ -936,11 +990,11 @@
|
||||
}
|
||||
continue;
|
||||
}
|
||||
- case OP_CLOSE: {
|
||||
+ OPCODE_TARGET(CLOSE) {
|
||||
luaF_close(L, ra);
|
||||
continue;
|
||||
}
|
||||
- case OP_CLOSURE: {
|
||||
+ OPCODE_TARGET(CLOSURE) {
|
||||
Proto *p;
|
||||
Closure *ncl;
|
||||
int nup, j;
|
||||
@@ -960,7 +1014,7 @@
|
||||
Protect(luaC_checkGC(L));
|
||||
continue;
|
||||
}
|
||||
- case OP_VARARG: {
|
||||
+ OPCODE_TARGET(VARARG) {
|
||||
int b = GETARG_B(i) - 1;
|
||||
int j;
|
||||
CallInfo *ci = L->ci;
|
Loading…
Reference in New Issue
Block a user