diff options
author | Sam Gross <colesbury@gmail.com> | 2016-06-17 18:04:12 +0300 |
---|---|---|
committer | Sam Gross <colesbury@gmail.com> | 2016-06-17 18:04:12 +0300 |
commit | e4a8016a35c6ce621e4cec0581f1ced4b2a94ef9 (patch) | |
tree | 12d601b6f22d058c2805977e95e034bcf0b5c413 | |
parent | 612123da84a8d51e0d766f10cc8b6bee6bab1d9d (diff) | |
parent | 4b54994170f9a7177ae92de337cc4d2033c2043c (diff) |
Merge pull request #17 from xHasKx/master
- Refactor TO_NUMBER macro
- Remove generate_call_h.sh
-rw-r--r-- | call.c | 1 | ||||
-rw-r--r-- | call_x64.h | 501 | ||||
-rw-r--r-- | call_x64win.h | 475 | ||||
-rw-r--r-- | call_x86.dasc | 25 | ||||
-rw-r--r-- | call_x86.h | 441 | ||||
-rw-r--r-- | ffi.c | 18 | ||||
-rw-r--r-- | test.lua | 27 |
7 files changed, 812 insertions, 676 deletions
@@ -170,6 +170,7 @@ static void* reserve_code(struct jit* jit, lua_State* L, size_t sz) ADDFUNC(NULL, push_cdata); ADDFUNC(NULL, push_int); ADDFUNC(NULL, push_uint); + ADDFUNC(NULL, lua_pushinteger); ADDFUNC(NULL, push_float); ADDFUNC(jit->kernel32_dll, SetLastError); ADDFUNC(jit->kernel32_dll, GetLastError); @@ -18,105 +18,116 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -static const unsigned char build_actionlist[2016] = { - 248,10,184,1,0,0,0,76,139,109,252,240,76,139,101,252,248,72,137,252,236,93, - 195,255,248,11,232,251,1,0,72,185,237,237,137,1,184,0,0,0,0,76,139,109,252, - 240,76,139,101,252,248,72,137,252,236,93,195,255,248,12,102,15,214,68,36, - 32,232,251,1,0,72,185,237,237,137,1,252,243,15,126,68,36,32,76,137,231,232, - 251,1,1,252,233,244,10,255,248,13,15,182,192,137,68,36,32,232,251,1,0,72, - 185,237,237,137,1,139,68,36,32,72,137,198,76,137,231,232,251,1,2,252,233, - 244,10,255,248,14,137,68,36,32,232,251,1,0,72,185,237,237,137,1,139,68,36, - 32,72,137,198,76,137,231,232,251,1,3,252,233,244,10,255,248,15,137,68,36, - 32,232,251,1,0,72,185,237,237,137,1,139,68,36,32,72,137,198,76,137,231,232, - 251,1,4,252,233,244,10,255,248,16,102,184,0,0,72,190,237,237,76,137,231,232, - 251,1,5,255,248,17,102,184,0,0,72,190,237,237,76,137,231,232,251,1,5,255, - 248,18,102,15,214,69,252,240,102,15,214,77,232,102,15,214,85,224,102,15,214, - 93,216,102,15,214,101,208,102,15,214,109,200,102,15,214,117,192,102,15,214, - 125,184,72,137,125,176,72,137,117,168,72,137,85,160,72,137,77,152,76,137, - 69,144,76,137,77,136,195,255,72,139,141,233,255,72,137,132,253,36,233,255, - 221,133,233,255,217,133,233,255,252,243,15,126,133,233,255,252,243,15,90, - 133,233,255,221,156,253,36,233,255,217,156,253,36,233,255,102,15,214,132, - 253,36,233,255,252,242,15,90,192,102,15,214,132,253,36,233,255,252,242,15, - 90,192,102,15,126,132,253,36,233,255,85,72,137,229,65,84,72,129,252,236,239, - 232,244,18,255,73,188,237,237,255,72,199,194,237,72,199,198,237,76,137,231, - 232,251,1,6,255,72,199,194,237,72,199,198,252,255,252,255,252,255,252,255, - 76,137,231,232,251,1,6,255,72,199,194,237,72,199,198,237,76,137,231,232,251, - 1,6,72,186,237,237,72,199,198,252,255,252,255,252,255,252,255,76,137,231, - 232,251,1,7,255,72,137,8,72,199,198,252,254,252,255,252,255,252,255,76,137, - 231,232,251,1,8,255,72,186,237,237,72,199,198,0,0,0,0,76,137,231,232,251, - 1,7,255,72,137,8,255,102,15,214,0,255,217,24,255,217,88,4,255,102,15,214, - 64,8,255,76,137,231,232,251,1,1,255,15,182,201,72,137,206,76,137,231,232, - 251,1,2,255,15,182,201,255,15,190,201,255,72,137,206,76,137,231,232,251,1, - 3,255,15,183,201,255,15,191,201,255,72,137,206,76,137,231,232,251,1,4,255, - 72,185,237,237,72,199,194,237,72,199,198,237,76,137,231,232,251,1,9,255,72, - 199,194,237,72,199,198,252,254,252,255,252,255,252,255,76,137,231,232,251, - 1,6,72,185,237,237,72,199,194,252,255,252,255,252,255,252,255,72,199,198, - 252,254,252,255,252,255,252,255,76,137,231,232,251,1,10,72,137,68,36,32,72, - 199,198,252,252,252,255,252,255,252,255,76,137,231,232,251,1,11,72,139,68, - 36,32,255,72,199,194,237,72,199,198,252,254,252,255,252,255,252,255,76,137, - 231,232,251,1,6,72,185,237,237,72,199,194,252,255,252,255,252,255,252,255, - 72,199,198,252,254,252,255,252,255,252,255,76,137,231,232,251,1,12,137,68, - 36,32,72,199,198,252,252,252,255,252,255,252,255,76,137,231,232,251,1,11, - 139,68,36,32,255,72,199,198,252,254,252,255,252,255,252,255,76,137,231,232, - 251,1,11,255,72,199,198,252,255,252,255,252,255,252,255,76,137,231,232,251, - 1,13,255,72,199,198,252,255,252,255,252,255,252,255,76,137,231,232,251,1, - 14,255,137,68,36,32,72,199,198,252,253,252,255,252,255,252,255,76,137,231, - 232,251,1,11,139,68,36,32,255,72,199,198,252,255,252,255,252,255,252,255, - 76,137,231,232,251,1,15,255,72,199,198,252,255,252,255,252,255,252,255,76, - 137,231,232,251,1,16,255,72,137,68,36,32,72,199,198,252,253,252,255,252,255, - 252,255,76,137,231,232,251,1,11,72,139,68,36,32,255,72,199,198,252,255,252, - 255,252,255,252,255,76,137,231,232,251,1,17,72,137,68,36,32,72,199,198,252, - 253,252,255,252,255,252,255,76,137,231,232,251,1,11,72,139,68,36,32,255,72, - 199,198,252,255,252,255,252,255,252,255,76,137,231,232,251,1,18,102,15,214, - 68,36,32,72,199,198,252,253,252,255,252,255,252,255,76,137,231,232,251,1, - 11,255,252,242,15,90,68,36,32,255,252,243,15,126,68,36,32,255,72,199,198, - 252,255,252,255,252,255,252,255,76,137,231,232,251,1,19,102,15,214,68,36, - 32,72,199,198,252,253,252,255,252,255,252,255,76,137,231,232,251,1,11,252, - 243,15,126,68,36,32,255,72,199,198,252,255,252,255,252,255,252,255,76,137, - 231,232,251,1,20,102,15,214,68,36,32,102,15,214,76,36,40,72,199,198,252,253, - 252,255,252,255,252,255,76,137,231,232,251,1,11,252,243,15,126,68,36,32,252, - 243,15,126,76,36,40,255,72,139,141,233,72,199,194,252,255,252,255,252,255, - 252,255,76,137,230,72,137,207,232,251,1,20,72,131,252,236,4,72,199,198,252, - 253,252,255,252,255,252,255,76,137,231,232,251,1,11,255,76,139,101,252,248, - 72,137,252,236,93,194,236,255,85,72,137,229,65,84,65,85,73,137,252,252,76, - 137,231,232,251,1,21,73,137,197,72,129,252,248,239,15,140,244,16,255,15,143, - 244,17,255,72,193,224,4,72,41,196,72,129,252,236,239,255,72,186,237,237,72, - 199,198,0,0,0,0,76,137,231,232,251,1,7,72,131,252,236,16,255,72,185,237,237, - 72,199,194,237,72,199,198,237,76,137,231,232,251,1,10,255,72,185,237,237, - 72,199,194,237,72,199,198,237,76,137,231,232,251,1,22,255,72,185,237,237, - 72,199,194,237,72,199,198,237,76,137,231,232,251,1,12,255,72,199,198,237, - 76,137,231,232,251,1,14,255,15,182,192,255,15,190,192,255,15,183,192,255, - 15,191,192,255,72,199,198,237,76,137,231,232,251,1,14,131,252,248,0,15,149, - 208,15,182,192,255,72,199,198,237,76,137,231,232,251,1,13,255,72,199,198, - 237,76,137,231,232,251,1,17,255,72,199,198,237,76,137,231,232,251,1,15,255, - 72,199,198,237,76,137,231,232,251,1,16,255,72,199,198,237,76,137,231,232, - 251,1,18,255,72,199,198,237,76,137,231,232,251,1,20,255,252,243,15,126,193, - 255,72,141,132,253,36,233,72,131,252,236,4,72,199,194,237,76,137,230,72,137, - 199,232,251,1,20,255,72,199,198,237,76,137,231,232,251,1,19,255,72,199,198, - 237,76,137,231,232,251,1,19,137,4,36,217,4,36,255,137,20,36,217,4,36,255, - 72,137,224,72,129,192,239,73,137,192,72,199,193,237,76,137,252,234,72,199, - 198,237,76,137,231,232,251,1,23,255,72,137,224,72,129,192,239,73,137,192, - 72,199,193,237,76,137,252,234,72,199,198,237,76,137,231,232,251,1,24,255, - 72,137,224,72,129,192,239,73,137,193,73,199,192,237,72,199,193,237,76,137, - 252,234,72,199,198,237,76,137,231,232,251,1,25,255,72,185,237,237,139,1,72, - 137,199,232,251,1,26,255,72,131,196,32,255,252,243,15,126,188,253,36,233, - 255,252,243,15,126,180,253,36,233,255,252,243,15,126,172,253,36,233,255,252, - 243,15,126,164,253,36,233,255,252,243,15,126,156,253,36,233,255,252,243,15, - 126,148,253,36,233,255,252,243,15,126,140,253,36,233,255,252,243,15,126,132, - 253,36,233,255,76,139,140,253,36,233,255,76,139,132,253,36,233,255,72,139, - 140,253,36,233,255,72,139,148,253,36,233,255,72,139,180,253,36,233,255,72, - 139,60,36,255,72,129,196,239,255,176,8,255,232,251,1,27,72,131,252,236,48, - 255,72,137,68,36,32,232,251,1,0,72,185,237,237,137,1,72,186,237,237,72,199, - 198,237,76,137,231,232,251,1,7,72,139,76,36,32,72,137,8,252,233,244,10,255, - 72,137,68,36,32,232,251,1,0,72,185,237,237,137,1,72,186,237,237,72,199,198, - 0,0,0,0,76,137,231,232,251,1,7,72,139,76,36,32,72,137,8,252,233,244,10,255, - 102,15,214,68,36,32,232,251,1,0,72,185,237,237,137,1,72,186,237,237,72,199, - 198,237,76,137,231,232,251,1,7,72,139,76,36,32,72,137,8,252,233,244,10,255, - 102,15,214,76,36,40,102,15,214,68,36,32,232,251,1,0,72,185,237,237,137,1, - 72,186,237,237,72,199,198,237,76,137,231,232,251,1,7,72,139,76,36,40,72,137, - 72,8,72,139,76,36,32,72,137,8,252,233,244,10,255,252,233,244,11,255,252,233, - 244,13,255,252,233,244,14,255,252,233,244,15,255,252,243,15,90,192,252,233, - 244,12,255 +static const unsigned char build_actionlist[2100] = { + 248,10,184,1,0.0,0.0,0.0,76,139,109,252,240,76,139,101,252,248,72,137,252, + 236,93,195,255,248,11,232,251,1,0,72,185,237,237,137,1,184,0,0.0,0.0,0.0, + 76,139,109,252,240,76,139,101,252,248,72,137,252,236,93,195,255,248,12,102.0, + 15.0,214,68,36,32,232,251,1,0,72,185,237,237,137,1,252,243.0,15.0,126,68, + 36,32,76,137,231,232,251,1,1,252,233,244,10,255,248,13,15.0,182,192,137,68, + 36,32,232,251,1,0,72,185,237,237,137,1,139,68,36,32,72,137,198,76,137,231, + 232,251,1,2,252,233,244,10,255,248,14,137,68,36,32,232,251,1,0,72,185,237, + 237,137,1,139,68,36,32,72,137,198,76,137,231,232,251,1,3,252,233,244,10,255, + 248,15,137,68,36,32,232,251,1,0,72,185,237,237,137,1,139,68,36,32,72,137, + 198,76,137,231,232,251,1,4,252,233,244,10,255,248,16,72,137,68,36,32,232, + 251,1,0,72,185,237,237,137,1,72,139,68,36,32,72,137,198,76,137,231,232,251, + 1,5,252,233,244,10,255,248,17,72,137,68,36,32,232,251,1,0,72,185,237,237, + 137,1,72,139,68,36,32,72,137,198,76,137,231,232,251,1,5,252,233,244,10,255, + 248,18,102,184,0,0.0,72,190,237,237,76,137,231,232,251,1,6,255,248,19,102, + 184,0,0.0,72,190,237,237,76,137,231,232,251,1,6,255,248,20,102.0,15.0,214, + 69,252,240,102.0,15.0,214,77,232,102.0,15.0,214,85,224,102.0,15.0,214,93, + 216,102.0,15.0,214,101,208,102.0,15.0,214,109,200,102.0,15.0,214,117,192, + 102.0,15.0,214,125,184,72,137,125,176,72,137,117,168,72,137,85,160,72,137, + 77,152,76,137,69,144,76,137,77,136,195,255,72,139,141,233,255,72,137,132, + 253,36,233,255,221.0,133,233,255,217.0,133,233,255,252,243.0,15.0,126,133, + 233,255,252,243.0,15.0,90,133,233,255,221.0,156,253,36,233,255,217.0,156, + 253,36,233,255,102.0,15.0,214,132,253,36,233,255,252,242.0,15.0,90,192,102.0, + 15.0,214,132,253,36,233,255,252,242.0,15.0,90,192,102.0,15.0,126,132,253, + 36,233,255,85,72,137,229,65,84,72,129.0,252,236,239,232,244,20,255,73,188, + 237,237,255,72,199.0,194,237,72,199.0,198,237,76,137,231,232,251,1,7,255, + 72,199.0,194,237,72,199.0,198,252,255,252,255.0,252,255.0,252,255.0,76,137, + 231,232,251,1,7,255,72,199.0,194,237,72,199.0,198,237,76,137,231,232,251, + 1,7,72,186,237,237,72,199.0,198,252,255,252,255.0,252,255.0,252,255.0,76, + 137,231,232,251,1,8,255,72,137,8,72,199.0,198,252,254,252,255.0,252,255.0, + 252,255.0,76,137,231,232,251,1,9,255,72,186,237,237,72,199.0,198,0,0.0,0.0, + 0.0,76,137,231,232,251,1,8,255,72,137,8,255,102.0,15.0,214,0,255,217.0,24, + 255,217.0,88,4,255,102.0,15.0,214,64,8,255,76,137,231,232,251,1,1,255,15.0, + 182,201,72,137,206,76,137,231,232,251,1,2,255,15.0,182,201,255,15.0,190,201, + 255,72,137,206,76,137,231,232,251,1,3,255,15.0,183,201,255,15.0,191,201,255, + 72,137,206,76,137,231,232,251,1,4,255,72,185,237,237,72,199.0,194,237,72, + 199.0,198,237,76,137,231,232,251,1,10,255,72,199.0,194,237,72,199.0,198,252, + 254,252,255.0,252,255.0,252,255.0,76,137,231,232,251,1,7,72,185,237,237,72, + 199.0,194,252,255,252,255.0,252,255.0,252,255.0,72,199.0,198,252,254,252, + 255.0,252,255.0,252,255.0,76,137,231,232,251,1,11,72,137,68,36,32,72,199.0, + 198,252,252,252,255.0,252,255.0,252,255.0,76,137,231,232,251,1,12,72,139, + 68,36,32,255,72,199.0,194,237,72,199.0,198,252,254,252,255.0,252,255.0,252, + 255.0,76,137,231,232,251,1,7,72,185,237,237,72,199.0,194,252,255,252,255.0, + 252,255.0,252,255.0,72,199.0,198,252,254,252,255.0,252,255.0,252,255.0,76, + 137,231,232,251,1,13,137,68,36,32,72,199.0,198,252,252,252,255.0,252,255.0, + 252,255.0,76,137,231,232,251,1,12,139,68,36,32,255,72,199.0,198,252,254,252, + 255.0,252,255.0,252,255.0,76,137,231,232,251,1,12,255,72,199.0,198,252,255, + 252,255.0,252,255.0,252,255.0,76,137,231,232,251,1,14,255,72,199.0,198,252, + 255,252,255.0,252,255.0,252,255.0,76,137,231,232,251,1,15,255,137,68,36,32, + 72,199.0,198,252,253,252,255.0,252,255.0,252,255.0,76,137,231,232,251,1,12, + 139,68,36,32,255,72,199.0,198,252,255,252,255.0,252,255.0,252,255.0,76,137, + 231,232,251,1,16,255,72,199.0,198,252,255,252,255.0,252,255.0,252,255.0,76, + 137,231,232,251,1,17,255,72,137,68,36,32,72,199.0,198,252,253,252,255.0,252, + 255.0,252,255.0,76,137,231,232,251,1,12,72,139,68,36,32,255,72,199.0,198, + 252,255,252,255.0,252,255.0,252,255.0,76,137,231,232,251,1,18,72,137,68,36, + 32,72,199.0,198,252,253,252,255.0,252,255.0,252,255.0,76,137,231,232,251, + 1,12,72,139,68,36,32,255,72,199.0,198,252,255,252,255.0,252,255.0,252,255.0, + 76,137,231,232,251,1,19,102.0,15.0,214,68,36,32,72,199.0,198,252,253,252, + 255.0,252,255.0,252,255.0,76,137,231,232,251,1,12,255,252,242.0,15.0,90,68, + 36,32,255,252,243.0,15.0,126,68,36,32,255,72,199.0,198,252,255,252,255.0, + 252,255.0,252,255.0,76,137,231,232,251,1,20,102.0,15.0,214,68,36,32,72,199.0, + 198,252,253,252,255.0,252,255.0,252,255.0,76,137,231,232,251,1,12,252,243.0, + 15.0,126,68,36,32,255,72,199.0,198,252,255,252,255.0,252,255.0,252,255.0, + 76,137,231,232,251,1,21,102.0,15.0,214,68,36,32,102.0,15.0,214,76,36,40,72, + 199.0,198,252,253,252,255.0,252,255.0,252,255.0,76,137,231,232,251,1,12,252, + 243.0,15.0,126,68,36,32,252,243.0,15.0,126,76,36,40,255,72,139,141,233,72, + 199.0,194,252,255,252,255.0,252,255.0,252,255.0,76,137,230,72,137,207,232, + 251,1,21,72,131.0,252,236,4,72,199.0,198,252,253,252,255.0,252,255.0,252, + 255.0,76,137,231,232,251,1,12,255,76,139,101,252,248,72,137,252,236,93,194, + 236,255,85,72,137,229,65,84,65,85,73,137,252,252,76,137,231,232,251,1,22, + 73,137,197,72,129.0,252,248,239,15.0,140,244,18,255,15.0,143,244,19,255,72, + 193.0,224,4,72,41,196,72,129.0,252,236,239,255,72,186,237,237,72,199.0,198, + 0,0.0,0.0,0.0,76,137,231,232,251,1,8,72,131.0,252,236,16,255,72,185,237,237, + 72,199.0,194,237,72,199.0,198,237,76,137,231,232,251,1,11,255,72,185,237, + 237,72,199.0,194,237,72,199.0,198,237,76,137,231,232,251,1,23,255,72,185, + 237,237,72,199.0,194,237,72,199.0,198,237,76,137,231,232,251,1,13,255,72, + 199.0,198,237,76,137,231,232,251,1,15,255,15.0,182,192,255,15.0,190,192,255, + 15.0,183,192,255,15.0,191,192,255,72,199.0,198,237,76,137,231,232,251,1,15, + 131.0,252,248,0,15.0,149.0,208,15.0,182,192,255,72,199.0,198,237,76,137,231, + 232,251,1,14,255,72,199.0,198,237,76,137,231,232,251,1,18,255,72,199.0,198, + 237,76,137,231,232,251,1,16,255,72,199.0,198,237,76,137,231,232,251,1,17, + 255,72,199.0,198,237,76,137,231,232,251,1,19,255,72,199.0,198,237,76,137, + 231,232,251,1,21,255,252,243.0,15.0,126,193,255,72,141,132,253,36,233,72, + 131.0,252,236,4,72,199.0,194,237,76,137,230,72,137,199,232,251,1,21,255,72, + 199.0,198,237,76,137,231,232,251,1,20,255,72,199.0,198,237,76,137,231,232, + 251,1,20,137,4,36,217.0,4,36,255,137,20,36,217.0,4,36,255,72,137,224,72,129.0, + 192,239,73,137,192,72,199.0,193,237,76,137,252,234,72,199.0,198,237,76,137, + 231,232,251,1,24,255,72,137,224,72,129.0,192,239,73,137,192,72,199.0,193, + 237,76,137,252,234,72,199.0,198,237,76,137,231,232,251,1,25,255,72,137,224, + 72,129.0,192,239,73,137,193,73,199.0,192,237,72,199.0,193,237,76,137,252, + 234,72,199.0,198,237,76,137,231,232,251,1,26,255,72,185,237,237,139,1,72, + 137,199,232,251,1,27,255,72,131.0,196,32,255,252,243.0,15.0,126,188,253,36, + 233,255,252,243.0,15.0,126,180,253,36,233,255,252,243.0,15.0,126,172,253, + 36,233,255,252,243.0,15.0,126,164,253,36,233,255,252,243.0,15.0,126,156,253, + 36,233,255,252,243.0,15.0,126,148,253,36,233,255,252,243.0,15.0,126,140,253, + 36,233,255,252,243.0,15.0,126,132,253,36,233,255,76,139,140,253,36,233,255, + 76,139,132,253,36,233,255,72,139,140,253,36,233,255,72,139,148,253,36,233, + 255,72,139,180,253,36,233,255,72,139,60,36,255,72,129.0,196,239,255,176,8, + 255,232,251,1,28,72,131.0,252,236,48,255,72,137,68,36,32,232,251,1,0,72,185, + 237,237,137,1,72,186,237,237,72,199.0,198,237,76,137,231,232,251,1,8,72,139, + 76,36,32,72,137,8,252,233,244,10,255,252,233,244,17,255,252,233,244,16,255, + 72,137,68,36,32,232,251,1,0,72,185,237,237,137,1,72,186,237,237,72,199.0, + 198,0,0.0,0.0,0.0,76,137,231,232,251,1,8,72,139,76,36,32,72,137,8,252,233, + 244,10,255,102.0,15.0,214,68,36,32,232,251,1,0,72,185,237,237,137,1,72,186, + 237,237,72,199.0,198,237,76,137,231,232,251,1,8,72,139,76,36,32,72,137,8, + 252,233,244,10,255,102.0,15.0,214,76,36,40,102.0,15.0,214,68,36,32,232,251, + 1,0,72,185,237,237,137,1,72,186,237,237,72,199.0,198,237,76,137,231,232,251, + 1,8,72,139,76,36,40,72,137,72,8,72,139,76,36,32,72,137,8,252,233,244,10,255, + 252,233,244,11,255,252,233,244,13,255,252,233,244,14,255,252,233,244,15,255, + 252,243.0,15.0,90,192,252,233,244,12,255 }; static const char *const globnames[] = { @@ -126,6 +137,8 @@ static const char *const globnames[] = { "lua_return_bool", "lua_return_int", "lua_return_uint", + "lua_return_long", + "lua_return_ulong", "too_few_arguments", "too_many_arguments", "save_registers", @@ -137,6 +150,7 @@ static const char *const extnames[] = { "lua_pushboolean", "push_int", "push_uint", + "lua_pushinteger", "luaL_error", "lua_rawgeti", "push_cdata", @@ -240,11 +254,17 @@ void compile_globals(struct jit* jit, lua_State* L) dasm_put(Dst, 168, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); - dasm_put(Dst, 203, (unsigned int)((uintptr_t)(&"too few arguments")), (unsigned int)(((uintptr_t)(&"too few arguments"))>>32)); +#if LUA_VERSION_NUM == 503 + dasm_put(Dst, 203, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); - dasm_put(Dst, 221, (unsigned int)((uintptr_t)(&"too many arguments")), (unsigned int)(((uintptr_t)(&"too many arguments"))>>32)); + dasm_put(Dst, 240, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); +#endif + + dasm_put(Dst, 277, (unsigned int)((uintptr_t)(&"too few arguments")), (unsigned int)(((uintptr_t)(&"too few arguments"))>>32)); + + dasm_put(Dst, 295, (unsigned int)((uintptr_t)(&"too many arguments")), (unsigned int)(((uintptr_t)(&"too many arguments"))>>32)); - dasm_put(Dst, 239); + dasm_put(Dst, 313); compile(Dst, L, NULL, LUA_NOREF); } @@ -354,25 +374,25 @@ static void get_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int /* grab the register from the shadow space */ #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { - dasm_put(Dst, 308, 16 + 8*reg->regs); + dasm_put(Dst, 382, 16 + 8*reg->regs); reg->regs++; } #elif __amd64__ if (reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 308, - 80 - 8*reg->ints); + dasm_put(Dst, 382, - 80 - 8*reg->ints); reg->ints++; } #else if (!is_int64 && reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 309, - 8 - 4*reg->ints); + dasm_put(Dst, 383, - 8 - 4*reg->ints); reg->ints++; } #endif else if (is_int64) { - dasm_put(Dst, 308, reg->off); + dasm_put(Dst, 382, reg->off); reg->off += 8; } else { - dasm_put(Dst, 309, reg->off); + dasm_put(Dst, 383, reg->off); reg->off += 4; } } @@ -381,17 +401,17 @@ static void add_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int { #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { - dasm_put(Dst, 313, 32 + 8*(reg->regs)); + dasm_put(Dst, 387, 32 + 8*(reg->regs)); reg->is_int[reg->regs++] = 1; } #elif __amd64__ if (reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 313, 32 + 8*reg->ints); + dasm_put(Dst, 387, 32 + 8*reg->ints); reg->ints++; } #else if (!is_int64 && reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 313, 32 + 4*reg->ints); + dasm_put(Dst, 387, 32 + 4*reg->ints); reg->ints++; } #endif @@ -402,10 +422,10 @@ static void add_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int } #endif if (is_int64) { - dasm_put(Dst, 313, reg->off); + dasm_put(Dst, 387, reg->off); reg->off += 8; } else { - dasm_put(Dst, 314, reg->off); + dasm_put(Dst, 388, reg->off); reg->off += 4; } } @@ -416,10 +436,10 @@ static void get_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #if !defined _WIN64 && !defined __amd64__ assert(MAX_FLOAT_REGISTERS(ct) == 0); if (is_double) { - dasm_put(Dst, 320, reg->off); + dasm_put(Dst, 394, reg->off); reg->off += 8; } else { - dasm_put(Dst, 324, reg->off); + dasm_put(Dst, 398, reg->off); reg->off += 4; } #else @@ -442,9 +462,9 @@ static void get_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i } if (is_double) { - dasm_put(Dst, 328, off); + dasm_put(Dst, 402, off); } else { - dasm_put(Dst, 335, off); + dasm_put(Dst, 409, off); } #endif } @@ -454,10 +474,10 @@ static void add_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #if !defined _WIN64 && !defined __amd64__ assert(MAX_FLOAT_REGISTERS(ct) == 0); if (is_double) { - dasm_put(Dst, 342, reg->off); + dasm_put(Dst, 416, reg->off); reg->off += 8; } else { - dasm_put(Dst, 348, reg->off); + dasm_put(Dst, 422, reg->off); reg->off += 4; } #else @@ -465,28 +485,28 @@ static void add_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { if (is_double) { - dasm_put(Dst, 354, 32 + 8*(reg->regs)); + dasm_put(Dst, 428, 32 + 8*(reg->regs)); } else { - dasm_put(Dst, 362, 32 + 8*(reg->regs)); + dasm_put(Dst, 436, 32 + 8*(reg->regs)); } reg->is_float[reg->regs++] = 1; } #else if (reg->floats < MAX_FLOAT_REGISTERS(ct)) { if (is_double) { - dasm_put(Dst, 354, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); + dasm_put(Dst, 428, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); } else { - dasm_put(Dst, 362, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); + dasm_put(Dst, 436, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); } reg->floats++; } #endif else if (is_double) { - dasm_put(Dst, 354, reg->off); + dasm_put(Dst, 428, reg->off); reg->off += 8; } else { - dasm_put(Dst, 375, reg->off); + dasm_put(Dst, 449, reg->off); reg->off += 4; } #endif @@ -542,21 +562,21 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp // setup a stack frame to hold args for the call into lua_call - dasm_put(Dst, 388, 8 + 16 + 32 + REGISTER_STACK_SPACE(ct)); + dasm_put(Dst, 462, 8 + 16 + 32 + REGISTER_STACK_SPACE(ct)); if (ct->calling_convention == FAST_CALL) { } // hardcode the lua_State* value into the assembly - dasm_put(Dst, 403, (unsigned int)((uintptr_t)(L)), (unsigned int)(((uintptr_t)(L))>>32)); + dasm_put(Dst, 477, (unsigned int)((uintptr_t)(L)), (unsigned int)(((uintptr_t)(L))>>32)); /* get the upval table */ - dasm_put(Dst, 408, ref, LUA_REGISTRYINDEX); + dasm_put(Dst, 482, ref, LUA_REGISTRYINDEX); /* get the lua function */ lua_pushvalue(L, fidx); lua_rawseti(L, -2, ++num_upvals); assert(num_upvals == CALLBACK_FUNC_USR_IDX); - dasm_put(Dst, 424, num_upvals); + dasm_put(Dst, 498, num_upvals); #if !defined _WIN64 && !defined __amd64__ lua_rawgeti(L, ct_usr, 0); @@ -581,90 +601,90 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp /* on the lua stack in the callback: * upval tbl, lua func, i-1 args */ - dasm_put(Dst, 447, num_upvals-1, -i-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 521, num_upvals-1, -i-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_pointer(Dst, ct, ®); - dasm_put(Dst, 485); + dasm_put(Dst, 559); } else { switch (mt->type) { case INT64_TYPE: lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* mt */ lua_pop(L, 1); - dasm_put(Dst, 507, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 581, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_int(Dst, ct, ®, 1); - dasm_put(Dst, 526); + dasm_put(Dst, 600); break; case INTPTR_TYPE: lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* mt */ lua_pop(L, 1); - dasm_put(Dst, 507, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 581, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_pointer(Dst, ct, ®); - dasm_put(Dst, 526); + dasm_put(Dst, 600); break; case COMPLEX_FLOAT_TYPE: lua_pop(L, 1); #if defined _WIN64 || defined __amd64__ /* complex floats are two floats packed into a double */ - dasm_put(Dst, 507, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 581, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_float(Dst, ct, ®, 1); - dasm_put(Dst, 530); + dasm_put(Dst, 604); #else /* complex floats are real followed by imag on the stack */ - dasm_put(Dst, 507, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 581, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_float(Dst, ct, ®, 0); - dasm_put(Dst, 535); + dasm_put(Dst, 609); get_float(Dst, ct, ®, 0); - dasm_put(Dst, 538); + dasm_put(Dst, 612); #endif break; case COMPLEX_DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 507, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 581, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); /* real */ get_float(Dst, ct, ®, 1); - dasm_put(Dst, 530); + dasm_put(Dst, 604); /* imag */ get_float(Dst, ct, ®, 1); - dasm_put(Dst, 542); + dasm_put(Dst, 616); break; case FLOAT_TYPE: case DOUBLE_TYPE: lua_pop(L, 1); get_float(Dst, ct, ®, mt->type == DOUBLE_TYPE); - dasm_put(Dst, 548); + dasm_put(Dst, 622); break; case BOOL_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); - dasm_put(Dst, 556); + dasm_put(Dst, 630); break; case INT8_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 570); + dasm_put(Dst, 644); } else { - dasm_put(Dst, 574); + dasm_put(Dst, 648); } - dasm_put(Dst, 578); + dasm_put(Dst, 652); break; case INT16_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 589); + dasm_put(Dst, 663); } else { - dasm_put(Dst, 593); + dasm_put(Dst, 667); } - dasm_put(Dst, 578); + dasm_put(Dst, 652); break; case ENUM_TYPE: @@ -672,9 +692,9 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 597); + dasm_put(Dst, 671); } else { - dasm_put(Dst, 578); + dasm_put(Dst, 652); } break; @@ -687,7 +707,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_rawgeti(L, ct_usr, 0); mt = (const struct ctype*) lua_touserdata(L, -1); - dasm_put(Dst, 608, (unsigned int)((uintptr_t)(0)), (unsigned int)(((uintptr_t)(0))>>32), (mt->pointers || mt->is_reference || mt->type != VOID_TYPE) ? 1 : 0, nargs); + dasm_put(Dst, 682, (unsigned int)((uintptr_t)(0)), (unsigned int)(((uintptr_t)(0))>>32), (mt->pointers || mt->is_reference || mt->type != VOID_TYPE) ? 1 : 0, nargs); // Unpack the return argument if not "void", also clean-up the lua stack // to remove the return argument and bind table. Use lua_settop rather @@ -696,7 +716,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* usr value */ lua_rawseti(L, -2, ++num_upvals); /* mt */ - dasm_put(Dst, 628, num_upvals-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 702, num_upvals-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); } else { switch (mt->type) { @@ -704,12 +724,12 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* usr value */ lua_rawseti(L, -2, ++num_upvals); /* mt */ - dasm_put(Dst, 712, num_upvals-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 786, num_upvals-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); break; case VOID_TYPE: lua_pop(L, 1); - dasm_put(Dst, 794); + dasm_put(Dst, 868); break; case BOOL_TYPE: @@ -718,38 +738,38 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp case INT32_TYPE: lua_pop(L, 1); if (mt->is_unsigned) { - dasm_put(Dst, 813); + dasm_put(Dst, 887); } else { - dasm_put(Dst, 832); + dasm_put(Dst, 906); } - dasm_put(Dst, 851); + dasm_put(Dst, 925); break; case INT64_TYPE: lua_pop(L, 1); if (mt->is_unsigned) { - dasm_put(Dst, 878); + dasm_put(Dst, 952); } else { - dasm_put(Dst, 897); + dasm_put(Dst, 971); } - dasm_put(Dst, 916); + dasm_put(Dst, 990); break; case INTPTR_TYPE: lua_pop(L, 1); - dasm_put(Dst, 945); + dasm_put(Dst, 1019); break; case FLOAT_TYPE: case DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 992); + dasm_put(Dst, 1066); if (mt->type == FLOAT_TYPE) { - dasm_put(Dst, 1035); + dasm_put(Dst, 1109); } else { - dasm_put(Dst, 1043); + dasm_put(Dst, 1117); } break; @@ -760,7 +780,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp #endif /* on 64 bit complex floats are two floats packed into a double, * on 32 bit returned complex floats use eax and edx */ - dasm_put(Dst, 1051); + dasm_put(Dst, 1125); break; case COMPLEX_DOUBLE_TYPE: @@ -773,9 +793,9 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp * the returned arg is stored which is popped by the called * function */ #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1101); + dasm_put(Dst, 1175); #else - dasm_put(Dst, 1164, hidden_arg_off); + dasm_put(Dst, 1238, hidden_arg_off); #endif break; @@ -784,7 +804,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp } } - dasm_put(Dst, 1213, x86_return_size(L, ct_usr, ct)); + dasm_put(Dst, 1287, x86_return_size(L, ct_usr, ct)); lua_pop(L, 1); /* upval table - already in registry */ assert(lua_gettop(L) == top); @@ -826,15 +846,15 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty luaL_error(L, "vararg is only allowed with the c calling convention"); } - dasm_put(Dst, 1226, nargs); + dasm_put(Dst, 1300, nargs); if (!ct->has_var_arg) { - dasm_put(Dst, 1258); + dasm_put(Dst, 1332); } /* no need to zero extend eax returned by lua_gettop to rax as x86-64 * preguarentees that the upper 32 bits will be zero */ - dasm_put(Dst, 1263, 32 + REGISTER_STACK_SPACE(ct)); + dasm_put(Dst, 1337, 32 + REGISTER_STACK_SPACE(ct)); #if !defined _WIN64 && !defined __amd64__ /* Returned complex doubles require a hidden first parameter where the @@ -845,7 +865,7 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty /* we can allocate more space for arguments as long as no add_* * function has been called yet, mbr_ct will be added as an upvalue in * the return processing later */ - dasm_put(Dst, 1276, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32)); + dasm_put(Dst, 1350, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32)); add_pointer(Dst, ct, ®); } lua_pop(L, 1); @@ -858,80 +878,80 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty if (mbr_ct->pointers || mbr_ct->is_reference) { lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1300, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1374, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); add_pointer(Dst, ct, ®); } else { switch (mbr_ct->type) { case FUNCTION_PTR_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1320, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1394, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); add_pointer(Dst, ct, ®); break; case ENUM_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1340, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1414, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); add_int(Dst, ct, ®, 0); break; case INT8_TYPE: - dasm_put(Dst, 1360, i); + dasm_put(Dst, 1434, i); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1372); + dasm_put(Dst, 1446); } else { - dasm_put(Dst, 1376); + dasm_put(Dst, 1450); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INT16_TYPE: - dasm_put(Dst, 1360, i); + dasm_put(Dst, 1434, i); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1380); + dasm_put(Dst, 1454); } else { - dasm_put(Dst, 1384); + dasm_put(Dst, 1458); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case BOOL_TYPE: - dasm_put(Dst, 1388, i); + dasm_put(Dst, 1462, i); add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INT32_TYPE: if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1410, i); + dasm_put(Dst, 1484, i); } else { - dasm_put(Dst, 1360, i); + dasm_put(Dst, 1434, i); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INTPTR_TYPE: - dasm_put(Dst, 1422, i); + dasm_put(Dst, 1496, i); add_pointer(Dst, ct, ®); lua_pop(L, 1); break; case INT64_TYPE: if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1434, i); + dasm_put(Dst, 1508, i); } else { - dasm_put(Dst, 1446, i); + dasm_put(Dst, 1520, i); } add_int(Dst, ct, ®, 1); lua_pop(L, 1); break; case DOUBLE_TYPE: - dasm_put(Dst, 1458, i); + dasm_put(Dst, 1532, i); add_float(Dst, ct, ®, 1); lua_pop(L, 1); break; @@ -942,33 +962,33 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty * the returned arg is stored (this is popped by the called * function) */ #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1470, i); + dasm_put(Dst, 1544, i); add_float(Dst, ct, ®, 1); - dasm_put(Dst, 1482); + dasm_put(Dst, 1556); add_float(Dst, ct, ®, 1); #else - dasm_put(Dst, 1488, reg.off, i); + dasm_put(Dst, 1562, reg.off, i); reg.off += 16; #endif lua_pop(L, 1); break; case FLOAT_TYPE: - dasm_put(Dst, 1458, i); + dasm_put(Dst, 1532, i); add_float(Dst, ct, ®, 0); lua_pop(L, 1); break; case COMPLEX_FLOAT_TYPE: #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1514, i); + dasm_put(Dst, 1588, i); /* complex floats are two floats packed into a double */ add_float(Dst, ct, ®, 1); #else /* returned complex floats use eax and edx */ - dasm_put(Dst, 1526, i); + dasm_put(Dst, 1600, i); add_float(Dst, ct, ®, 0); - dasm_put(Dst, 1544); + dasm_put(Dst, 1618); add_float(Dst, ct, ®, 0); #endif lua_pop(L, 1); @@ -993,14 +1013,14 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty reg.regs = MAX_REGISTERS(ct); #elif defined __amd64__ if (reg.floats < MAX_FLOAT_REGISTERS(ct)) { - dasm_put(Dst, 1551, 32 + 8*(MAX_INT_REGISTERS(ct) + reg.floats), MAX_FLOAT_REGISTERS(ct) - reg.floats, nargs+1); + dasm_put(Dst, 1625, 32 + 8*(MAX_INT_REGISTERS(ct) + reg.floats), MAX_FLOAT_REGISTERS(ct) - reg.floats, nargs+1); } if (reg.ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 1581, 32 + 8*(reg.ints), MAX_INT_REGISTERS(ct) - reg.ints, nargs+1); + dasm_put(Dst, 1655, 32 + 8*(reg.ints), MAX_INT_REGISTERS(ct) - reg.ints, nargs+1); } - dasm_put(Dst, 1611, reg.off, MAX_FLOAT_REGISTERS(ct) - reg.floats, MAX_INT_REGISTERS(ct) - reg.ints, nargs+1); + dasm_put(Dst, 1685, reg.off, MAX_FLOAT_REGISTERS(ct) - reg.floats, MAX_INT_REGISTERS(ct) - reg.ints, nargs+1); reg.floats = MAX_FLOAT_REGISTERS(ct); reg.ints = MAX_INT_REGISTERS(ct); @@ -1008,10 +1028,10 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty #endif } - dasm_put(Dst, 1645, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); + dasm_put(Dst, 1719, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); /* remove the stack space to call local functions */ - dasm_put(Dst, 1659); + dasm_put(Dst, 1733); #ifdef _WIN64 switch (reg.regs) { @@ -1045,43 +1065,43 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty #elif defined __amd64__ switch (reg.floats) { case 8: - dasm_put(Dst, 1664, 8*(MAX_INT_REGISTERS(ct)+7)); + dasm_put(Dst, 1738, 8*(MAX_INT_REGISTERS(ct)+7)); case 7: - dasm_put(Dst, 1673, 8*(MAX_INT_REGISTERS(ct)+6)); + dasm_put(Dst, 1747, 8*(MAX_INT_REGISTERS(ct)+6)); case 6: - dasm_put(Dst, 1682, 8*(MAX_INT_REGISTERS(ct)+5)); + dasm_put(Dst, 1756, 8*(MAX_INT_REGISTERS(ct)+5)); case 5: - dasm_put(Dst, 1691, 8*(MAX_INT_REGISTERS(ct)+4)); + dasm_put(Dst, 1765, 8*(MAX_INT_REGISTERS(ct)+4)); case 4: - dasm_put(Dst, 1700, 8*(MAX_INT_REGISTERS(ct)+3)); + dasm_put(Dst, 1774, 8*(MAX_INT_REGISTERS(ct)+3)); case 3: - dasm_put(Dst, 1709, 8*(MAX_INT_REGISTERS(ct)+2)); + dasm_put(Dst, 1783, 8*(MAX_INT_REGISTERS(ct)+2)); case 2: - dasm_put(Dst, 1718, 8*(MAX_INT_REGISTERS(ct)+1)); + dasm_put(Dst, 1792, 8*(MAX_INT_REGISTERS(ct)+1)); case 1: - dasm_put(Dst, 1727, 8*(MAX_INT_REGISTERS(ct))); + dasm_put(Dst, 1801, 8*(MAX_INT_REGISTERS(ct))); case 0: break; } switch (reg.ints) { case 6: - dasm_put(Dst, 1736, 8*5); + dasm_put(Dst, 1810, 8*5); case 5: - dasm_put(Dst, 1743, 8*4); + dasm_put(Dst, 1817, 8*4); case 4: - dasm_put(Dst, 1750, 8*3); + dasm_put(Dst, 1824, 8*3); case 3: - dasm_put(Dst, 1757, 8*2); + dasm_put(Dst, 1831, 8*2); case 2: - dasm_put(Dst, 1764, 8*1); + dasm_put(Dst, 1838, 8*1); case 1: - dasm_put(Dst, 1771); + dasm_put(Dst, 1845); case 0: break; } - dasm_put(Dst, 1776, REGISTER_STACK_SPACE(ct)); + dasm_put(Dst, 1850, REGISTER_STACK_SPACE(ct)); #else if (ct->calling_convention == FAST_CALL) { switch (reg.ints) { @@ -1099,11 +1119,11 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty /* al stores an upper limit on the number of float register, note that * its allowed to be more than the actual number of float registers used as * long as its 0-8 */ - dasm_put(Dst, 1781); + dasm_put(Dst, 1855); } #endif - dasm_put(Dst, 1784); + dasm_put(Dst, 1858); /* note on windows X86 the stack may be only aligned to 4 (stdcall will * have popped a multiple of 4 bytes), but we don't need 16 byte alignment on @@ -1116,81 +1136,90 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty if (mbr_ct->pointers || mbr_ct->is_reference || mbr_ct->type == INTPTR_TYPE) { lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1794, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1868, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); } else { switch (mbr_ct->type) { case FUNCTION_PTR_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1794, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1868, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); break; case INT64_TYPE: +#if LUA_VERSION_NUM == 503 + lua_pop(L, 1); + if (mbr_ct->is_unsigned) { + dasm_put(Dst, 1911); + } else { + dasm_put(Dst, 1916); + } +#else num_upvals++; - dasm_put(Dst, 1837, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32)); + dasm_put(Dst, 1921, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32)); +#endif break; case COMPLEX_FLOAT_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1883, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1967, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); break; case COMPLEX_DOUBLE_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1927, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); + dasm_put(Dst, 2011, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); break; case VOID_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1986); + dasm_put(Dst, 2070); break; case BOOL_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1991); + dasm_put(Dst, 2075); break; case INT8_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1372); + dasm_put(Dst, 1446); } else { - dasm_put(Dst, 1376); + dasm_put(Dst, 1450); } - dasm_put(Dst, 1996); + dasm_put(Dst, 2080); break; case INT16_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1380); + dasm_put(Dst, 1454); } else { - dasm_put(Dst, 1384); + dasm_put(Dst, 1458); } - dasm_put(Dst, 1996); + dasm_put(Dst, 2080); break; case INT32_TYPE: case ENUM_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 2001); + dasm_put(Dst, 2085); } else { - dasm_put(Dst, 1996); + dasm_put(Dst, 2080); } break; case FLOAT_TYPE: lua_pop(L, 1); - dasm_put(Dst, 2006); + dasm_put(Dst, 2090); break; case DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 2011); + dasm_put(Dst, 2095); break; default: diff --git a/call_x64win.h b/call_x64win.h index 29d3884..aa6f2da 100644 --- a/call_x64win.h +++ b/call_x64win.h @@ -18,101 +18,112 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -static const unsigned char build_actionlist[1959] = { - 248,10,184,1,0,0,0,76,139,109,252,240,76,139,101,252,248,72,137,252,236,93, - 195,255,248,11,232,251,1,0,72,185,237,237,137,1,184,0,0,0,0,76,139,109,252, - 240,76,139,101,252,248,72,137,252,236,93,195,255,248,12,102,15,214,68,36, - 32,232,251,1,0,72,185,237,237,137,1,252,243,15,126,76,36,32,76,137,225,232, - 251,1,1,252,233,244,10,255,248,13,15,182,192,137,68,36,32,232,251,1,0,72, - 185,237,237,137,1,139,68,36,32,72,137,194,76,137,225,232,251,1,2,252,233, - 244,10,255,248,14,137,68,36,32,232,251,1,0,72,185,237,237,137,1,139,68,36, - 32,72,137,194,76,137,225,232,251,1,3,252,233,244,10,255,248,15,137,68,36, - 32,232,251,1,0,72,185,237,237,137,1,139,68,36,32,72,137,194,76,137,225,232, - 251,1,4,252,233,244,10,255,248,16,102,184,0,0,72,186,237,237,76,137,225,232, - 251,1,5,255,248,17,102,184,0,0,72,186,237,237,76,137,225,232,251,1,5,255, - 248,18,72,137,77,16,72,137,85,24,76,137,69,32,76,137,77,40,102,15,214,69, - 252,240,102,15,214,77,232,102,15,214,85,224,102,15,214,93,216,195,255,72, - 139,141,233,255,72,137,132,253,36,233,255,221,133,233,255,217,133,233,255, - 252,243,15,126,133,233,255,252,243,15,90,133,233,255,221,156,253,36,233,255, - 217,156,253,36,233,255,102,15,214,132,253,36,233,255,252,242,15,90,192,102, - 15,214,132,253,36,233,255,252,242,15,90,192,102,15,126,132,253,36,233,255, - 85,72,137,229,65,84,72,129,252,236,239,232,244,18,255,73,188,237,237,255, - 73,199,192,237,72,199,194,237,76,137,225,232,251,1,6,255,73,199,192,237,72, - 199,194,252,255,252,255,252,255,252,255,76,137,225,232,251,1,6,255,73,199, - 192,237,72,199,194,237,76,137,225,232,251,1,6,73,184,237,237,72,199,194,252, - 255,252,255,252,255,252,255,76,137,225,232,251,1,7,255,72,137,8,72,199,194, - 252,254,252,255,252,255,252,255,76,137,225,232,251,1,8,255,73,184,237,237, - 72,199,194,0,0,0,0,76,137,225,232,251,1,7,255,72,137,8,255,102,15,214,0,255, - 217,24,255,217,88,4,255,102,15,214,64,8,255,252,243,15,126,200,76,137,225, - 232,251,1,1,255,15,182,201,72,137,202,76,137,225,232,251,1,2,255,15,182,201, - 255,15,190,201,255,72,137,202,76,137,225,232,251,1,3,255,15,183,201,255,15, - 191,201,255,72,137,202,76,137,225,232,251,1,4,255,73,185,237,237,73,199,192, - 237,72,199,194,237,76,137,225,232,251,1,9,255,73,199,192,237,72,199,194,252, - 254,252,255,252,255,252,255,76,137,225,232,251,1,6,73,185,237,237,73,199, - 192,252,255,252,255,252,255,252,255,72,199,194,252,254,252,255,252,255,252, - 255,76,137,225,232,251,1,10,72,137,68,36,32,72,199,194,252,252,252,255,252, - 255,252,255,76,137,225,232,251,1,11,72,139,68,36,32,255,73,199,192,237,72, - 199,194,252,254,252,255,252,255,252,255,76,137,225,232,251,1,6,73,185,237, - 237,73,199,192,252,255,252,255,252,255,252,255,72,199,194,252,254,252,255, - 252,255,252,255,76,137,225,232,251,1,12,137,68,36,32,72,199,194,252,252,252, - 255,252,255,252,255,76,137,225,232,251,1,11,139,68,36,32,255,72,199,194,252, - 254,252,255,252,255,252,255,76,137,225,232,251,1,11,255,72,199,194,252,255, - 252,255,252,255,252,255,76,137,225,232,251,1,13,255,72,199,194,252,255,252, - 255,252,255,252,255,76,137,225,232,251,1,14,255,137,68,36,32,72,199,194,252, - 253,252,255,252,255,252,255,76,137,225,232,251,1,11,139,68,36,32,255,72,199, - 194,252,255,252,255,252,255,252,255,76,137,225,232,251,1,15,255,72,199,194, - 252,255,252,255,252,255,252,255,76,137,225,232,251,1,16,255,72,137,68,36, - 32,72,199,194,252,253,252,255,252,255,252,255,76,137,225,232,251,1,11,72, - 139,68,36,32,255,72,199,194,252,255,252,255,252,255,252,255,76,137,225,232, - 251,1,17,72,137,68,36,32,72,199,194,252,253,252,255,252,255,252,255,76,137, - 225,232,251,1,11,72,139,68,36,32,255,72,199,194,252,255,252,255,252,255,252, - 255,76,137,225,232,251,1,18,102,15,214,68,36,32,72,199,194,252,253,252,255, - 252,255,252,255,76,137,225,232,251,1,11,255,252,242,15,90,68,36,32,255,252, - 243,15,126,68,36,32,255,72,199,194,252,255,252,255,252,255,252,255,76,137, - 225,232,251,1,19,102,15,214,68,36,32,72,199,194,252,253,252,255,252,255,252, - 255,76,137,225,232,251,1,11,252,243,15,126,68,36,32,255,72,199,194,252,255, - 252,255,252,255,252,255,76,137,225,232,251,1,20,102,15,214,68,36,32,102,15, - 214,76,36,40,72,199,194,252,253,252,255,252,255,252,255,76,137,225,232,251, - 1,11,252,243,15,126,68,36,32,252,243,15,126,76,36,40,255,72,139,141,233,73, - 199,192,252,255,252,255,252,255,252,255,76,137,226,72,137,201,232,251,1,20, - 72,131,252,236,4,72,199,194,252,253,252,255,252,255,252,255,76,137,225,232, - 251,1,11,255,76,139,101,252,248,72,137,252,236,93,194,236,255,85,72,137,229, - 65,84,65,85,73,137,204,72,131,252,236,32,76,137,225,232,251,1,21,73,137,197, - 72,129,252,248,239,15,140,244,16,255,15,143,244,17,255,72,193,224,4,72,41, - 196,72,129,252,236,239,255,73,184,237,237,72,199,194,0,0,0,0,76,137,225,232, - 251,1,7,72,131,252,236,16,255,73,185,237,237,73,199,192,237,72,199,194,237, - 76,137,225,232,251,1,10,255,73,185,237,237,73,199,192,237,72,199,194,237, - 76,137,225,232,251,1,22,255,73,185,237,237,73,199,192,237,72,199,194,237, - 76,137,225,232,251,1,12,255,72,199,194,237,76,137,225,232,251,1,14,255,15, - 182,192,255,15,190,192,255,15,183,192,255,15,191,192,255,72,199,194,237,76, - 137,225,232,251,1,14,131,252,248,0,15,149,208,15,182,192,255,72,199,194,237, - 76,137,225,232,251,1,13,255,72,199,194,237,76,137,225,232,251,1,17,255,72, - 199,194,237,76,137,225,232,251,1,15,255,72,199,194,237,76,137,225,232,251, - 1,16,255,72,199,194,237,76,137,225,232,251,1,18,255,72,199,194,237,76,137, - 225,232,251,1,20,255,252,243,15,126,193,255,72,141,132,253,36,233,72,131, - 252,236,4,73,199,192,237,76,137,226,72,137,193,232,251,1,20,255,72,199,194, - 237,76,137,225,232,251,1,19,255,72,199,194,237,76,137,225,232,251,1,19,137, - 4,36,217,4,36,255,137,20,36,217,4,36,255,73,129,252,253,239,15,142,244,247, - 72,137,224,72,129,192,239,73,137,193,77,137,232,72,199,194,237,76,137,225, - 232,251,1,23,72,137,224,72,129,192,239,73,137,193,73,199,192,237,72,199,194, - 237,76,137,225,232,251,1,24,252,233,244,248,248,1,72,137,224,72,129,192,239, - 73,137,193,77,137,232,72,199,194,237,76,137,225,232,251,1,24,248,2,255,72, - 137,224,72,129,192,239,73,137,193,77,137,232,72,199,194,237,76,137,225,232, - 251,1,23,255,72,185,237,237,139,1,72,137,193,232,251,1,25,255,72,131,196, - 32,255,252,243,15,126,156,253,36,233,255,76,139,140,253,36,233,255,252,243, - 15,126,148,253,36,233,255,76,139,132,253,36,233,255,252,243,15,126,140,253, - 36,233,255,72,139,148,253,36,233,255,252,243,15,126,4,36,255,72,139,12,36, - 255,232,251,1,26,72,131,252,236,48,255,72,137,68,36,32,232,251,1,0,72,185, - 237,237,137,1,73,184,237,237,72,199,194,237,76,137,225,232,251,1,7,72,139, - 76,36,32,72,137,8,252,233,244,10,255,72,137,68,36,32,232,251,1,0,72,185,237, - 237,137,1,73,184,237,237,72,199,194,0,0,0,0,76,137,225,232,251,1,7,72,139, - 76,36,32,72,137,8,252,233,244,10,255,102,15,214,68,36,32,232,251,1,0,72,185, - 237,237,137,1,73,184,237,237,72,199,194,237,76,137,225,232,251,1,7,72,139, - 76,36,32,72,137,8,252,233,244,10,255,102,15,214,76,36,40,102,15,214,68,36, - 32,232,251,1,0,72,185,237,237,137,1,73,184,237,237,72,199,194,237,76,137, - 225,232,251,1,7,72,139,76,36,40,72,137,72,8,72,139,76,36,32,72,137,8,252, - 233,244,10,255,252,233,244,11,255,252,233,244,13,255,252,233,244,14,255,252, - 233,244,15,255,252,243,15,90,192,252,233,244,12,255 +static const unsigned char build_actionlist[2043] = { + 248,10,184,1,0.0,0.0,0.0,76,139,109,252,240,76,139,101,252,248,72,137,252, + 236,93,195,255,248,11,232,251,1,0,72,185,237,237,137,1,184,0,0.0,0.0,0.0, + 76,139,109,252,240,76,139,101,252,248,72,137,252,236,93,195,255,248,12,102.0, + 15.0,214,68,36,32,232,251,1,0,72,185,237,237,137,1,252,243.0,15.0,126,76, + 36,32,76,137,225,232,251,1,1,252,233,244,10,255,248,13,15.0,182,192,137,68, + 36,32,232,251,1,0,72,185,237,237,137,1,139,68,36,32,72,137,194,76,137,225, + 232,251,1,2,252,233,244,10,255,248,14,137,68,36,32,232,251,1,0,72,185,237, + 237,137,1,139,68,36,32,72,137,194,76,137,225,232,251,1,3,252,233,244,10,255, + 248,15,137,68,36,32,232,251,1,0,72,185,237,237,137,1,139,68,36,32,72,137, + 194,76,137,225,232,251,1,4,252,233,244,10,255,248,16,72,137,68,36,32,232, + 251,1,0,72,185,237,237,137,1,72,139,68,36,32,72,137,194,76,137,225,232,251, + 1,5,252,233,244,10,255,248,17,72,137,68,36,32,232,251,1,0,72,185,237,237, + 137,1,72,139,68,36,32,72,137,194,76,137,225,232,251,1,5,252,233,244,10,255, + 248,18,102,184,0,0.0,72,186,237,237,76,137,225,232,251,1,6,255,248,19,102, + 184,0,0.0,72,186,237,237,76,137,225,232,251,1,6,255,248,20,72,137,77,16,72, + 137,85,24,76,137,69,32,76,137,77,40,102.0,15.0,214,69,252,240,102.0,15.0, + 214,77,232,102.0,15.0,214,85,224,102.0,15.0,214,93,216,195,255,72,139,141, + 233,255,72,137,132,253,36,233,255,221.0,133,233,255,217.0,133,233,255,252, + 243.0,15.0,126,133,233,255,252,243.0,15.0,90,133,233,255,221.0,156,253,36, + 233,255,217.0,156,253,36,233,255,102.0,15.0,214,132,253,36,233,255,252,242.0, + 15.0,90,192,102.0,15.0,214,132,253,36,233,255,252,242.0,15.0,90,192,102.0, + 15.0,126,132,253,36,233,255,85,72,137,229,65,84,72,129.0,252,236,239,232, + 244,20,255,73,188,237,237,255,73,199.0,192,237,72,199.0,194,237,76,137,225, + 232,251,1,7,255,73,199.0,192,237,72,199.0,194,252,255,252,255.0,252,255.0, + 252,255.0,76,137,225,232,251,1,7,255,73,199.0,192,237,72,199.0,194,237,76, + 137,225,232,251,1,7,73,184,237,237,72,199.0,194,252,255,252,255.0,252,255.0, + 252,255.0,76,137,225,232,251,1,8,255,72,137,8,72,199.0,194,252,254,252,255.0, + 252,255.0,252,255.0,76,137,225,232,251,1,9,255,73,184,237,237,72,199.0,194, + 0,0.0,0.0,0.0,76,137,225,232,251,1,8,255,72,137,8,255,102.0,15.0,214,0,255, + 217.0,24,255,217.0,88,4,255,102.0,15.0,214,64,8,255,252,243.0,15.0,126,200, + 76,137,225,232,251,1,1,255,15.0,182,201,72,137,202,76,137,225,232,251,1,2, + 255,15.0,182,201,255,15.0,190,201,255,72,137,202,76,137,225,232,251,1,3,255, + 15.0,183,201,255,15.0,191,201,255,72,137,202,76,137,225,232,251,1,4,255,73, + 185,237,237,73,199.0,192,237,72,199.0,194,237,76,137,225,232,251,1,10,255, + 73,199.0,192,237,72,199.0,194,252,254,252,255.0,252,255.0,252,255.0,76,137, + 225,232,251,1,7,73,185,237,237,73,199.0,192,252,255,252,255.0,252,255.0,252, + 255.0,72,199.0,194,252,254,252,255.0,252,255.0,252,255.0,76,137,225,232,251, + 1,11,72,137,68,36,32,72,199.0,194,252,252,252,255.0,252,255.0,252,255.0,76, + 137,225,232,251,1,12,72,139,68,36,32,255,73,199.0,192,237,72,199.0,194,252, + 254,252,255.0,252,255.0,252,255.0,76,137,225,232,251,1,7,73,185,237,237,73, + 199.0,192,252,255,252,255.0,252,255.0,252,255.0,72,199.0,194,252,254,252, + 255.0,252,255.0,252,255.0,76,137,225,232,251,1,13,137,68,36,32,72,199.0,194, + 252,252,252,255.0,252,255.0,252,255.0,76,137,225,232,251,1,12,139,68,36,32, + 255,72,199.0,194,252,254,252,255.0,252,255.0,252,255.0,76,137,225,232,251, + 1,12,255,72,199.0,194,252,255,252,255.0,252,255.0,252,255.0,76,137,225,232, + 251,1,14,255,72,199.0,194,252,255,252,255.0,252,255.0,252,255.0,76,137,225, + 232,251,1,15,255,137,68,36,32,72,199.0,194,252,253,252,255.0,252,255.0,252, + 255.0,76,137,225,232,251,1,12,139,68,36,32,255,72,199.0,194,252,255,252,255.0, + 252,255.0,252,255.0,76,137,225,232,251,1,16,255,72,199.0,194,252,255,252, + 255.0,252,255.0,252,255.0,76,137,225,232,251,1,17,255,72,137,68,36,32,72, + 199.0,194,252,253,252,255.0,252,255.0,252,255.0,76,137,225,232,251,1,12,72, + 139,68,36,32,255,72,199.0,194,252,255,252,255.0,252,255.0,252,255.0,76,137, + 225,232,251,1,18,72,137,68,36,32,72,199.0,194,252,253,252,255.0,252,255.0, + 252,255.0,76,137,225,232,251,1,12,72,139,68,36,32,255,72,199.0,194,252,255, + 252,255.0,252,255.0,252,255.0,76,137,225,232,251,1,19,102.0,15.0,214,68,36, + 32,72,199.0,194,252,253,252,255.0,252,255.0,252,255.0,76,137,225,232,251, + 1,12,255,252,242.0,15.0,90,68,36,32,255,252,243.0,15.0,126,68,36,32,255,72, + 199.0,194,252,255,252,255.0,252,255.0,252,255.0,76,137,225,232,251,1,20,102.0, + 15.0,214,68,36,32,72,199.0,194,252,253,252,255.0,252,255.0,252,255.0,76,137, + 225,232,251,1,12,252,243.0,15.0,126,68,36,32,255,72,199.0,194,252,255,252, + 255.0,252,255.0,252,255.0,76,137,225,232,251,1,21,102.0,15.0,214,68,36,32, + 102.0,15.0,214,76,36,40,72,199.0,194,252,253,252,255.0,252,255.0,252,255.0, + 76,137,225,232,251,1,12,252,243.0,15.0,126,68,36,32,252,243.0,15.0,126,76, + 36,40,255,72,139,141,233,73,199.0,192,252,255,252,255.0,252,255.0,252,255.0, + 76,137,226,72,137,201,232,251,1,21,72,131.0,252,236,4,72,199.0,194,252,253, + 252,255.0,252,255.0,252,255.0,76,137,225,232,251,1,12,255,76,139,101,252, + 248,72,137,252,236,93,194,236,255,85,72,137,229,65,84,65,85,73,137,204,72, + 131.0,252,236,32,76,137,225,232,251,1,22,73,137,197,72,129.0,252,248,239, + 15.0,140,244,18,255,15.0,143,244,19,255,72,193.0,224,4,72,41,196,72,129.0, + 252,236,239,255,73,184,237,237,72,199.0,194,0,0.0,0.0,0.0,76,137,225,232, + 251,1,8,72,131.0,252,236,16,255,73,185,237,237,73,199.0,192,237,72,199.0, + 194,237,76,137,225,232,251,1,11,255,73,185,237,237,73,199.0,192,237,72,199.0, + 194,237,76,137,225,232,251,1,23,255,73,185,237,237,73,199.0,192,237,72,199.0, + 194,237,76,137,225,232,251,1,13,255,72,199.0,194,237,76,137,225,232,251,1, + 15,255,15.0,182,192,255,15.0,190,192,255,15.0,183,192,255,15.0,191,192,255, + 72,199.0,194,237,76,137,225,232,251,1,15,131.0,252,248,0,15.0,149.0,208,15.0, + 182,192,255,72,199.0,194,237,76,137,225,232,251,1,14,255,72,199.0,194,237, + 76,137,225,232,251,1,18,255,72,199.0,194,237,76,137,225,232,251,1,16,255, + 72,199.0,194,237,76,137,225,232,251,1,17,255,72,199.0,194,237,76,137,225, + 232,251,1,19,255,72,199.0,194,237,76,137,225,232,251,1,21,255,252,243.0,15.0, + 126,193,255,72,141,132,253,36,233,72,131.0,252,236,4,73,199.0,192,237,76, + 137,226,72,137,193,232,251,1,21,255,72,199.0,194,237,76,137,225,232,251,1, + 20,255,72,199.0,194,237,76,137,225,232,251,1,20,137,4,36,217.0,4,36,255,137, + 20,36,217.0,4,36,255,73,129.0,252,253,239,15.0,142,244,247.0,72,137,224,72, + 129.0,192,239,73,137,193,77,137,232,72,199.0,194,237,76,137,225,232,251,1, + 24,72,137,224,72,129.0,192,239,73,137,193,73,199.0,192,237,72,199.0,194,237, + 76,137,225,232,251,1,25,252,233,244,248.0,248,1,72,137,224,72,129.0,192,239, + 73,137,193,77,137,232,72,199.0,194,237,76,137,225,232,251,1,25,248,2,255, + 72,137,224,72,129.0,192,239,73,137,193,77,137,232,72,199.0,194,237,76,137, + 225,232,251,1,24,255,72,185,237,237,139,1,72,137,193,232,251,1,26,255,72, + 131.0,196,32,255,252,243.0,15.0,126,156,253,36,233,255,76,139,140,253,36, + 233,255,252,243.0,15.0,126,148,253,36,233,255,76,139,132,253,36,233,255,252, + 243.0,15.0,126,140,253,36,233,255,72,139,148,253,36,233,255,252,243.0,15.0, + 126,4,36,255,72,139,12,36,255,232,251,1,27,72,131.0,252,236,48,255,72,137, + 68,36,32,232,251,1,0,72,185,237,237,137,1,73,184,237,237,72,199.0,194,237, + 76,137,225,232,251,1,8,72,139,76,36,32,72,137,8,252,233,244,10,255,252,233, + 244,17,255,252,233,244,16,255,72,137,68,36,32,232,251,1,0,72,185,237,237, + 137,1,73,184,237,237,72,199.0,194,0,0.0,0.0,0.0,76,137,225,232,251,1,8,72, + 139,76,36,32,72,137,8,252,233,244,10,255,102.0,15.0,214,68,36,32,232,251, + 1,0,72,185,237,237,137,1,73,184,237,237,72,199.0,194,237,76,137,225,232,251, + 1,8,72,139,76,36,32,72,137,8,252,233,244,10,255,102.0,15.0,214,76,36,40,102.0, + 15.0,214,68,36,32,232,251,1,0,72,185,237,237,137,1,73,184,237,237,72,199.0, + 194,237,76,137,225,232,251,1,8,72,139,76,36,40,72,137,72,8,72,139,76,36,32, + 72,137,8,252,233,244,10,255,252,233,244,11,255,252,233,244,13,255,252,233, + 244,14,255,252,233,244,15,255,252,243.0,15.0,90,192,252,233,244,12,255 }; static const char *const globnames[] = { @@ -122,6 +133,8 @@ static const char *const globnames[] = { "lua_return_bool", "lua_return_int", "lua_return_uint", + "lua_return_long", + "lua_return_ulong", "too_few_arguments", "too_many_arguments", "save_registers", @@ -133,6 +146,7 @@ static const char *const extnames[] = { "lua_pushboolean", "push_int", "push_uint", + "lua_pushinteger", "luaL_error", "lua_rawgeti", "push_cdata", @@ -235,11 +249,17 @@ void compile_globals(struct jit* jit, lua_State* L) dasm_put(Dst, 168, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); - dasm_put(Dst, 203, (unsigned int)((uintptr_t)(&"too few arguments")), (unsigned int)(((uintptr_t)(&"too few arguments"))>>32)); +#if LUA_VERSION_NUM == 503 + dasm_put(Dst, 203, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); - dasm_put(Dst, 221, (unsigned int)((uintptr_t)(&"too many arguments")), (unsigned int)(((uintptr_t)(&"too many arguments"))>>32)); + dasm_put(Dst, 240, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); +#endif + + dasm_put(Dst, 277, (unsigned int)((uintptr_t)(&"too few arguments")), (unsigned int)(((uintptr_t)(&"too few arguments"))>>32)); + + dasm_put(Dst, 295, (unsigned int)((uintptr_t)(&"too many arguments")), (unsigned int)(((uintptr_t)(&"too many arguments"))>>32)); - dasm_put(Dst, 239); + dasm_put(Dst, 313); compile(Dst, L, NULL, LUA_NOREF); } @@ -349,25 +369,25 @@ static void get_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int /* grab the register from the shadow space */ #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { - dasm_put(Dst, 280, 16 + 8*reg->regs); + dasm_put(Dst, 354, 16 + 8*reg->regs); reg->regs++; } #elif __amd64__ if (reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 280, - 80 - 8*reg->ints); + dasm_put(Dst, 354, - 80 - 8*reg->ints); reg->ints++; } #else if (!is_int64 && reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 281, - 8 - 4*reg->ints); + dasm_put(Dst, 355, - 8 - 4*reg->ints); reg->ints++; } #endif else if (is_int64) { - dasm_put(Dst, 280, reg->off); + dasm_put(Dst, 354, reg->off); reg->off += 8; } else { - dasm_put(Dst, 281, reg->off); + dasm_put(Dst, 355, reg->off); reg->off += 4; } } @@ -376,17 +396,17 @@ static void add_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int { #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { - dasm_put(Dst, 285, 32 + 8*(reg->regs)); + dasm_put(Dst, 359, 32 + 8*(reg->regs)); reg->is_int[reg->regs++] = 1; } #elif __amd64__ if (reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 285, 32 + 8*reg->ints); + dasm_put(Dst, 359, 32 + 8*reg->ints); reg->ints++; } #else if (!is_int64 && reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 285, 32 + 4*reg->ints); + dasm_put(Dst, 359, 32 + 4*reg->ints); reg->ints++; } #endif @@ -397,10 +417,10 @@ static void add_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int } #endif if (is_int64) { - dasm_put(Dst, 285, reg->off); + dasm_put(Dst, 359, reg->off); reg->off += 8; } else { - dasm_put(Dst, 286, reg->off); + dasm_put(Dst, 360, reg->off); reg->off += 4; } } @@ -411,10 +431,10 @@ static void get_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #if !defined _WIN64 && !defined __amd64__ assert(MAX_FLOAT_REGISTERS(ct) == 0); if (is_double) { - dasm_put(Dst, 292, reg->off); + dasm_put(Dst, 366, reg->off); reg->off += 8; } else { - dasm_put(Dst, 296, reg->off); + dasm_put(Dst, 370, reg->off); reg->off += 4; } #else @@ -437,9 +457,9 @@ static void get_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i } if (is_double) { - dasm_put(Dst, 300, off); + dasm_put(Dst, 374, off); } else { - dasm_put(Dst, 307, off); + dasm_put(Dst, 381, off); } #endif } @@ -449,10 +469,10 @@ static void add_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #if !defined _WIN64 && !defined __amd64__ assert(MAX_FLOAT_REGISTERS(ct) == 0); if (is_double) { - dasm_put(Dst, 314, reg->off); + dasm_put(Dst, 388, reg->off); reg->off += 8; } else { - dasm_put(Dst, 320, reg->off); + dasm_put(Dst, 394, reg->off); reg->off += 4; } #else @@ -460,28 +480,28 @@ static void add_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { if (is_double) { - dasm_put(Dst, 326, 32 + 8*(reg->regs)); + dasm_put(Dst, 400, 32 + 8*(reg->regs)); } else { - dasm_put(Dst, 334, 32 + 8*(reg->regs)); + dasm_put(Dst, 408, 32 + 8*(reg->regs)); } reg->is_float[reg->regs++] = 1; } #else if (reg->floats < MAX_FLOAT_REGISTERS(ct)) { if (is_double) { - dasm_put(Dst, 326, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); + dasm_put(Dst, 400, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); } else { - dasm_put(Dst, 334, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); + dasm_put(Dst, 408, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); } reg->floats++; } #endif else if (is_double) { - dasm_put(Dst, 326, reg->off); + dasm_put(Dst, 400, reg->off); reg->off += 8; } else { - dasm_put(Dst, 347, reg->off); + dasm_put(Dst, 421, reg->off); reg->off += 4; } #endif @@ -537,21 +557,21 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp // setup a stack frame to hold args for the call into lua_call - dasm_put(Dst, 360, 8 + 16 + 32 + REGISTER_STACK_SPACE(ct)); + dasm_put(Dst, 434, 8 + 16 + 32 + REGISTER_STACK_SPACE(ct)); if (ct->calling_convention == FAST_CALL) { } // hardcode the lua_State* value into the assembly - dasm_put(Dst, 375, (unsigned int)((uintptr_t)(L)), (unsigned int)(((uintptr_t)(L))>>32)); + dasm_put(Dst, 449, (unsigned int)((uintptr_t)(L)), (unsigned int)(((uintptr_t)(L))>>32)); /* get the upval table */ - dasm_put(Dst, 380, ref, LUA_REGISTRYINDEX); + dasm_put(Dst, 454, ref, LUA_REGISTRYINDEX); /* get the lua function */ lua_pushvalue(L, fidx); lua_rawseti(L, -2, ++num_upvals); assert(num_upvals == CALLBACK_FUNC_USR_IDX); - dasm_put(Dst, 396, num_upvals); + dasm_put(Dst, 470, num_upvals); #if !defined _WIN64 && !defined __amd64__ lua_rawgeti(L, ct_usr, 0); @@ -576,90 +596,90 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp /* on the lua stack in the callback: * upval tbl, lua func, i-1 args */ - dasm_put(Dst, 419, num_upvals-1, -i-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 493, num_upvals-1, -i-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_pointer(Dst, ct, ®); - dasm_put(Dst, 457); + dasm_put(Dst, 531); } else { switch (mt->type) { case INT64_TYPE: lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* mt */ lua_pop(L, 1); - dasm_put(Dst, 479, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 553, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_int(Dst, ct, ®, 1); - dasm_put(Dst, 498); + dasm_put(Dst, 572); break; case INTPTR_TYPE: lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* mt */ lua_pop(L, 1); - dasm_put(Dst, 479, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 553, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_pointer(Dst, ct, ®); - dasm_put(Dst, 498); + dasm_put(Dst, 572); break; case COMPLEX_FLOAT_TYPE: lua_pop(L, 1); #if defined _WIN64 || defined __amd64__ /* complex floats are two floats packed into a double */ - dasm_put(Dst, 479, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 553, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_float(Dst, ct, ®, 1); - dasm_put(Dst, 502); + dasm_put(Dst, 576); #else /* complex floats are real followed by imag on the stack */ - dasm_put(Dst, 479, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 553, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); get_float(Dst, ct, ®, 0); - dasm_put(Dst, 507); + dasm_put(Dst, 581); get_float(Dst, ct, ®, 0); - dasm_put(Dst, 510); + dasm_put(Dst, 584); #endif break; case COMPLEX_DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 479, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 553, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); /* real */ get_float(Dst, ct, ®, 1); - dasm_put(Dst, 502); + dasm_put(Dst, 576); /* imag */ get_float(Dst, ct, ®, 1); - dasm_put(Dst, 514); + dasm_put(Dst, 588); break; case FLOAT_TYPE: case DOUBLE_TYPE: lua_pop(L, 1); get_float(Dst, ct, ®, mt->type == DOUBLE_TYPE); - dasm_put(Dst, 520); + dasm_put(Dst, 594); break; case BOOL_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); - dasm_put(Dst, 533); + dasm_put(Dst, 607); break; case INT8_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 547); + dasm_put(Dst, 621); } else { - dasm_put(Dst, 551); + dasm_put(Dst, 625); } - dasm_put(Dst, 555); + dasm_put(Dst, 629); break; case INT16_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 566); + dasm_put(Dst, 640); } else { - dasm_put(Dst, 570); + dasm_put(Dst, 644); } - dasm_put(Dst, 555); + dasm_put(Dst, 629); break; case ENUM_TYPE: @@ -667,9 +687,9 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 574); + dasm_put(Dst, 648); } else { - dasm_put(Dst, 555); + dasm_put(Dst, 629); } break; @@ -682,7 +702,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_rawgeti(L, ct_usr, 0); mt = (const struct ctype*) lua_touserdata(L, -1); - dasm_put(Dst, 585, (unsigned int)((uintptr_t)(0)), (unsigned int)(((uintptr_t)(0))>>32), (mt->pointers || mt->is_reference || mt->type != VOID_TYPE) ? 1 : 0, nargs); + dasm_put(Dst, 659, (unsigned int)((uintptr_t)(0)), (unsigned int)(((uintptr_t)(0))>>32), (mt->pointers || mt->is_reference || mt->type != VOID_TYPE) ? 1 : 0, nargs); // Unpack the return argument if not "void", also clean-up the lua stack // to remove the return argument and bind table. Use lua_settop rather @@ -691,7 +711,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* usr value */ lua_rawseti(L, -2, ++num_upvals); /* mt */ - dasm_put(Dst, 605, num_upvals-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 679, num_upvals-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); } else { switch (mt->type) { @@ -699,12 +719,12 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* usr value */ lua_rawseti(L, -2, ++num_upvals); /* mt */ - dasm_put(Dst, 689, num_upvals-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); + dasm_put(Dst, 763, num_upvals-1, (unsigned int)((uintptr_t)(mt)), (unsigned int)(((uintptr_t)(mt))>>32)); break; case VOID_TYPE: lua_pop(L, 1); - dasm_put(Dst, 771); + dasm_put(Dst, 845); break; case BOOL_TYPE: @@ -713,38 +733,38 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp case INT32_TYPE: lua_pop(L, 1); if (mt->is_unsigned) { - dasm_put(Dst, 790); + dasm_put(Dst, 864); } else { - dasm_put(Dst, 809); + dasm_put(Dst, 883); } - dasm_put(Dst, 828); + dasm_put(Dst, 902); break; case INT64_TYPE: lua_pop(L, 1); if (mt->is_unsigned) { - dasm_put(Dst, 855); + dasm_put(Dst, 929); } else { - dasm_put(Dst, 874); + dasm_put(Dst, 948); } - dasm_put(Dst, 893); + dasm_put(Dst, 967); break; case INTPTR_TYPE: lua_pop(L, 1); - dasm_put(Dst, 922); + dasm_put(Dst, 996); break; case FLOAT_TYPE: case DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 969); + dasm_put(Dst, 1043); if (mt->type == FLOAT_TYPE) { - dasm_put(Dst, 1012); + dasm_put(Dst, 1086); } else { - dasm_put(Dst, 1020); + dasm_put(Dst, 1094); } break; @@ -755,7 +775,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp #endif /* on 64 bit complex floats are two floats packed into a double, * on 32 bit returned complex floats use eax and edx */ - dasm_put(Dst, 1028); + dasm_put(Dst, 1102); break; case COMPLEX_DOUBLE_TYPE: @@ -768,9 +788,9 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp * the returned arg is stored which is popped by the called * function */ #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1078); + dasm_put(Dst, 1152); #else - dasm_put(Dst, 1141, hidden_arg_off); + dasm_put(Dst, 1215, hidden_arg_off); #endif break; @@ -779,7 +799,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp } } - dasm_put(Dst, 1190, x86_return_size(L, ct_usr, ct)); + dasm_put(Dst, 1264, x86_return_size(L, ct_usr, ct)); lua_pop(L, 1); /* upval table - already in registry */ assert(lua_gettop(L) == top); @@ -821,15 +841,15 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty luaL_error(L, "vararg is only allowed with the c calling convention"); } - dasm_put(Dst, 1203, nargs); + dasm_put(Dst, 1277, nargs); if (!ct->has_var_arg) { - dasm_put(Dst, 1239); + dasm_put(Dst, 1313); } /* no need to zero extend eax returned by lua_gettop to rax as x86-64 * preguarentees that the upper 32 bits will be zero */ - dasm_put(Dst, 1244, 32 + REGISTER_STACK_SPACE(ct)); + dasm_put(Dst, 1318, 32 + REGISTER_STACK_SPACE(ct)); #if !defined _WIN64 && !defined __amd64__ /* Returned complex doubles require a hidden first parameter where the @@ -840,7 +860,7 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty /* we can allocate more space for arguments as long as no add_* * function has been called yet, mbr_ct will be added as an upvalue in * the return processing later */ - dasm_put(Dst, 1257, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32)); + dasm_put(Dst, 1331, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32)); add_pointer(Dst, ct, ®); } lua_pop(L, 1); @@ -853,80 +873,80 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty if (mbr_ct->pointers || mbr_ct->is_reference) { lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1281, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1355, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); add_pointer(Dst, ct, ®); } else { switch (mbr_ct->type) { case FUNCTION_PTR_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1301, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1375, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); add_pointer(Dst, ct, ®); break; case ENUM_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1321, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1395, (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals), i); add_int(Dst, ct, ®, 0); break; case INT8_TYPE: - dasm_put(Dst, 1341, i); + dasm_put(Dst, 1415, i); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1353); + dasm_put(Dst, 1427); } else { - dasm_put(Dst, 1357); + dasm_put(Dst, 1431); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INT16_TYPE: - dasm_put(Dst, 1341, i); + dasm_put(Dst, 1415, i); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1361); + dasm_put(Dst, 1435); } else { - dasm_put(Dst, 1365); + dasm_put(Dst, 1439); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case BOOL_TYPE: - dasm_put(Dst, 1369, i); + dasm_put(Dst, 1443, i); add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INT32_TYPE: if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1391, i); + dasm_put(Dst, 1465, i); } else { - dasm_put(Dst, 1341, i); + dasm_put(Dst, 1415, i); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INTPTR_TYPE: - dasm_put(Dst, 1403, i); + dasm_put(Dst, 1477, i); add_pointer(Dst, ct, ®); lua_pop(L, 1); break; case INT64_TYPE: if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1415, i); + dasm_put(Dst, 1489, i); } else { - dasm_put(Dst, 1427, i); + dasm_put(Dst, 1501, i); } add_int(Dst, ct, ®, 1); lua_pop(L, 1); break; case DOUBLE_TYPE: - dasm_put(Dst, 1439, i); + dasm_put(Dst, 1513, i); add_float(Dst, ct, ®, 1); lua_pop(L, 1); break; @@ -937,33 +957,33 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty * the returned arg is stored (this is popped by the called * function) */ #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1451, i); + dasm_put(Dst, 1525, i); add_float(Dst, ct, ®, 1); - dasm_put(Dst, 1463); + dasm_put(Dst, 1537); add_float(Dst, ct, ®, 1); #else - dasm_put(Dst, 1469, reg.off, i); + dasm_put(Dst, 1543, reg.off, i); reg.off += 16; #endif lua_pop(L, 1); break; case FLOAT_TYPE: - dasm_put(Dst, 1439, i); + dasm_put(Dst, 1513, i); add_float(Dst, ct, ®, 0); lua_pop(L, 1); break; case COMPLEX_FLOAT_TYPE: #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1495, i); + dasm_put(Dst, 1569, i); /* complex floats are two floats packed into a double */ add_float(Dst, ct, ®, 1); #else /* returned complex floats use eax and edx */ - dasm_put(Dst, 1507, i); + dasm_put(Dst, 1581, i); add_float(Dst, ct, ®, 0); - dasm_put(Dst, 1525); + dasm_put(Dst, 1599); add_float(Dst, ct, ®, 0); #endif lua_pop(L, 1); @@ -979,9 +999,9 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty #ifdef _WIN64 if (reg.regs < MAX_REGISTERS(ct)) { assert(reg.regs == nargs); - dasm_put(Dst, 1532, MAX_REGISTERS(ct), 32 + 8*MAX_REGISTERS(ct), MAX_REGISTERS(ct)+1, 32 + 8*(reg.regs), MAX_REGISTERS(ct), nargs+1, 32 + 8*(reg.regs), nargs+1); + dasm_put(Dst, 1606, MAX_REGISTERS(ct), 32 + 8*MAX_REGISTERS(ct), MAX_REGISTERS(ct)+1, 32 + 8*(reg.regs), MAX_REGISTERS(ct), nargs+1, 32 + 8*(reg.regs), nargs+1); } else { - dasm_put(Dst, 1623, reg.off, nargs+1); + dasm_put(Dst, 1697, reg.off, nargs+1); } for (i = nargs; i < MAX_REGISTERS(ct); i++) { @@ -1002,40 +1022,40 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty #endif } - dasm_put(Dst, 1648, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); + dasm_put(Dst, 1722, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32)); /* remove the stack space to call local functions */ - dasm_put(Dst, 1662); + dasm_put(Dst, 1736); #ifdef _WIN64 switch (reg.regs) { case 4: if (reg.is_float[3]) { - dasm_put(Dst, 1667, 8*3); + dasm_put(Dst, 1741, 8*3); } if (reg.is_int[3]) { - dasm_put(Dst, 1676, 8*3); + dasm_put(Dst, 1750, 8*3); } case 3: if (reg.is_float[2]) { - dasm_put(Dst, 1683, 8*2); + dasm_put(Dst, 1757, 8*2); } if (reg.is_int[2]) { - dasm_put(Dst, 1692, 8*2); + dasm_put(Dst, 1766, 8*2); } case 2: if (reg.is_float[1]) { - dasm_put(Dst, 1699, 8*1); + dasm_put(Dst, 1773, 8*1); } if (reg.is_int[1]) { - dasm_put(Dst, 1708, 8*1); + dasm_put(Dst, 1782, 8*1); } case 1: if (reg.is_float[0]) { - dasm_put(Dst, 1715); + dasm_put(Dst, 1789); } if (reg.is_int[0]) { - dasm_put(Dst, 1722); + dasm_put(Dst, 1796); } case 0: break; @@ -1089,7 +1109,7 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty } #endif - dasm_put(Dst, 1727); + dasm_put(Dst, 1801); /* note on windows X86 the stack may be only aligned to 4 (stdcall will * have popped a multiple of 4 bytes), but we don't need 16 byte alignment on @@ -1102,81 +1122,90 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty if (mbr_ct->pointers || mbr_ct->is_reference || mbr_ct->type == INTPTR_TYPE) { lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1737, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1811, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); } else { switch (mbr_ct->type) { case FUNCTION_PTR_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1737, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1811, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); break; case INT64_TYPE: +#if LUA_VERSION_NUM == 503 + lua_pop(L, 1); + if (mbr_ct->is_unsigned) { + dasm_put(Dst, 1854); + } else { + dasm_put(Dst, 1859); + } +#else num_upvals++; - dasm_put(Dst, 1780, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32)); + dasm_put(Dst, 1864, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32)); +#endif break; case COMPLEX_FLOAT_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1826, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1910, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); break; case COMPLEX_DOUBLE_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1870, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1954, (unsigned int)((uintptr_t)(perr)), (unsigned int)(((uintptr_t)(perr))>>32), (unsigned int)((uintptr_t)(mbr_ct)), (unsigned int)(((uintptr_t)(mbr_ct))>>32), lua_upvalueindex(num_upvals)); break; case VOID_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1929); + dasm_put(Dst, 2013); break; case BOOL_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1934); + dasm_put(Dst, 2018); break; case INT8_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1353); + dasm_put(Dst, 1427); } else { - dasm_put(Dst, 1357); + dasm_put(Dst, 1431); } - dasm_put(Dst, 1939); + dasm_put(Dst, 2023); break; case INT16_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1361); + dasm_put(Dst, 1435); } else { - dasm_put(Dst, 1365); + dasm_put(Dst, 1439); } - dasm_put(Dst, 1939); + dasm_put(Dst, 2023); break; case INT32_TYPE: case ENUM_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1944); + dasm_put(Dst, 2028); } else { - dasm_put(Dst, 1939); + dasm_put(Dst, 2023); } break; case FLOAT_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1949); + dasm_put(Dst, 2033); break; case DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1954); + dasm_put(Dst, 2038); break; default: diff --git a/call_x86.dasc b/call_x86.dasc index 909e63b..9d7b147 100644 --- a/call_x86.dasc +++ b/call_x86.dasc @@ -312,6 +312,22 @@ void compile_globals(struct jit* jit, lua_State* L) | call_rr extern push_uint, L_ARG, rax | jmp ->lua_return_arg +#if LUA_VERSION_NUM == 503 + |->lua_return_long: + | mov [rsp+32], rax + | get_errno + | mov rax, [rsp+32] + | call_rr extern lua_pushinteger, L_ARG, rax + | jmp ->lua_return_arg + + |->lua_return_ulong: + | mov [rsp+32], rax + | get_errno + | mov rax, [rsp+32] + | call_rr extern lua_pushinteger, L_ARG, rax + | jmp ->lua_return_arg +#endif + |->too_few_arguments: | mov ax, 0 | call_rp extern luaL_error, L_ARG, &"too few arguments" @@ -1452,6 +1468,14 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty break; case INT64_TYPE: +#if LUA_VERSION_NUM == 503 + lua_pop(L, 1); + if (mbr_ct->is_unsigned) { + | jmp ->lua_return_ulong + } else { + | jmp ->lua_return_long + } +#else num_upvals++; | // save the return value |.if X64 @@ -1476,6 +1500,7 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty |.endif | | jmp ->lua_return_arg +#endif break; case COMPLEX_FLOAT_TYPE: @@ -18,91 +18,100 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -static const unsigned char build_actionlist[1800] = { - 248,10,184,1,0,0,0,139,117,252,248,139,125,252,252,137,252,236,93,195,255, - 248,11,232,251,1,0,185,237,137,1,184,0,0,0,0,139,117,252,248,139,125,252, - 252,137,252,236,93,195,255,248,12,221,92,36,4,232,251,1,0,185,237,137,1,137, - 60,36,232,251,1,1,252,233,244,10,255,248,13,15,182,192,137,68,36,32,232,251, - 1,0,185,237,137,1,139,68,36,32,137,68,36,4,137,60,36,232,251,1,2,252,233, - 244,10,255,248,14,137,68,36,32,232,251,1,0,185,237,137,1,139,68,36,32,137, - 68,36,4,137,60,36,232,251,1,3,252,233,244,10,255,248,15,137,68,36,32,232, - 251,1,0,185,237,137,1,139,68,36,32,137,68,36,4,137,60,36,232,251,1,4,252, - 233,244,10,255,248,16,102,184,0,0,199,68,36,4,237,137,60,36,232,251,1,5,255, - 248,17,102,184,0,0,199,68,36,4,237,137,60,36,232,251,1,5,255,248,18,137,77, - 252,248,137,85,252,244,195,255,139,141,233,255,139,141,233,139,149,233,255, - 137,132,253,36,233,255,137,132,253,36,233,137,148,253,36,233,255,221,133, - 233,255,217,133,233,255,252,243,15,126,133,233,255,252,243,15,90,133,233, - 255,221,156,253,36,233,255,217,156,253,36,233,255,102,15,214,132,253,36,233, - 255,252,242,15,90,192,102,15,214,132,253,36,233,255,252,242,15,90,192,102, - 15,126,132,253,36,233,255,85,137,229,87,129,252,236,239,255,232,244,18,255, - 191,237,255,199,68,36,8,237,199,68,36,4,237,137,60,36,232,251,1,6,255,199, - 68,36,8,237,199,68,36,4,252,255,252,255,252,255,252,255,137,60,36,232,251, - 1,6,255,199,68,36,8,237,199,68,36,4,237,137,60,36,232,251,1,6,199,68,36,8, - 237,199,68,36,4,252,255,252,255,252,255,252,255,137,60,36,232,251,1,7,255, - 137,8,199,68,36,4,252,254,252,255,252,255,252,255,137,60,36,232,251,1,8,255, - 199,68,36,8,237,199,68,36,4,0,0,0,0,137,60,36,232,251,1,7,255,137,8,137,80, - 4,255,137,8,255,102,15,214,0,255,217,24,255,217,88,4,255,221,24,255,221,88, - 8,255,221,92,36,4,137,60,36,232,251,1,1,255,15,182,201,137,76,36,4,137,60, - 36,232,251,1,2,255,15,182,201,255,15,190,201,255,137,76,36,4,137,60,36,232, - 251,1,3,255,15,183,201,255,15,191,201,255,137,76,36,4,137,60,36,232,251,1, - 4,255,199,68,36,12,0,0,0,0,199,68,36,8,237,199,68,36,4,237,137,60,36,232, - 251,1,9,255,199,68,36,8,237,199,68,36,4,252,254,252,255,252,255,252,255,137, - 60,36,232,251,1,6,199,68,36,12,237,199,68,36,8,252,255,252,255,252,255,252, - 255,199,68,36,4,252,254,252,255,252,255,252,255,137,60,36,232,251,1,10,137, - 68,36,32,199,68,36,4,252,252,252,255,252,255,252,255,137,60,36,232,251,1, - 11,139,68,36,32,255,199,68,36,8,237,199,68,36,4,252,254,252,255,252,255,252, - 255,137,60,36,232,251,1,6,199,68,36,12,237,199,68,36,8,252,255,252,255,252, - 255,252,255,199,68,36,4,252,254,252,255,252,255,252,255,137,60,36,232,251, - 1,12,137,68,36,32,199,68,36,4,252,252,252,255,252,255,252,255,137,60,36,232, - 251,1,11,139,68,36,32,255,199,68,36,4,252,254,252,255,252,255,252,255,137, - 60,36,232,251,1,11,255,199,68,36,4,252,255,252,255,252,255,252,255,137,60, - 36,232,251,1,13,255,199,68,36,4,252,255,252,255,252,255,252,255,137,60,36, - 232,251,1,14,255,137,68,36,32,199,68,36,4,252,253,252,255,252,255,252,255, - 137,60,36,232,251,1,11,139,68,36,32,255,199,68,36,4,252,255,252,255,252,255, - 252,255,137,60,36,232,251,1,15,255,199,68,36,4,252,255,252,255,252,255,252, - 255,137,60,36,232,251,1,16,255,137,68,36,32,137,84,36,36,199,68,36,4,252, - 253,252,255,252,255,252,255,137,60,36,232,251,1,11,139,68,36,32,139,84,36, - 36,255,199,68,36,4,252,255,252,255,252,255,252,255,137,60,36,232,251,1,17, - 137,68,36,32,199,68,36,4,252,253,252,255,252,255,252,255,137,60,36,232,251, - 1,11,139,68,36,32,255,199,68,36,4,252,255,252,255,252,255,252,255,137,60, - 36,232,251,1,18,255,221,92,36,32,199,68,36,4,252,253,252,255,252,255,252, - 255,137,60,36,232,251,1,11,221,68,36,32,255,199,68,36,4,252,255,252,255,252, - 255,252,255,137,60,36,232,251,1,19,137,68,36,32,137,84,36,36,199,68,36,4, - 252,253,252,255,252,255,252,255,137,60,36,232,251,1,11,139,68,36,32,139,84, - 36,36,255,199,68,36,4,252,255,252,255,252,255,252,255,137,60,36,232,251,1, - 20,102,15,214,68,36,32,102,15,214,76,36,40,199,68,36,4,252,253,252,255,252, - 255,252,255,137,60,36,232,251,1,11,252,243,15,126,68,36,32,252,243,15,126, - 76,36,40,255,139,141,233,199,68,36,8,252,255,252,255,252,255,252,255,137, - 124,36,4,137,12,36,232,251,1,20,131,252,236,4,199,68,36,4,252,253,252,255, - 252,255,252,255,137,60,36,232,251,1,11,255,139,125,252,252,137,252,236,93, - 194,236,255,85,137,229,87,86,139,189,233,131,252,236,16,137,60,36,232,251, - 1,21,137,198,129,252,248,239,15,140,244,16,255,15,143,244,17,255,193,224, - 4,41,196,129,252,236,239,255,199,68,36,8,237,199,68,36,4,0,0,0,0,137,60,36, - 232,251,1,7,131,252,236,16,255,199,68,36,12,237,199,68,36,8,237,199,68,36, - 4,237,137,60,36,232,251,1,10,255,199,68,36,12,237,199,68,36,8,237,199,68, - 36,4,237,137,60,36,232,251,1,22,255,199,68,36,12,237,199,68,36,8,237,199, - 68,36,4,237,137,60,36,232,251,1,12,255,199,68,36,4,237,137,60,36,232,251, - 1,14,255,15,182,192,255,15,190,192,255,15,183,192,255,15,191,192,255,199, - 68,36,4,237,137,60,36,232,251,1,14,131,252,248,0,15,149,208,15,182,192,255, - 199,68,36,4,237,137,60,36,232,251,1,13,255,199,68,36,4,237,137,60,36,232, - 251,1,17,255,199,68,36,4,237,137,60,36,232,251,1,15,255,199,68,36,4,237,137, - 60,36,232,251,1,16,255,199,68,36,4,237,137,60,36,232,251,1,18,255,199,68, - 36,4,237,137,60,36,232,251,1,20,255,252,243,15,126,193,255,141,132,253,36, - 233,131,252,236,4,199,68,36,8,237,137,124,36,4,137,4,36,232,251,1,20,255, - 199,68,36,4,237,137,60,36,232,251,1,19,255,199,68,36,4,237,137,60,36,232, - 251,1,19,137,4,36,217,4,36,255,137,20,36,217,4,36,255,137,224,129,192,239, - 137,68,36,12,137,116,36,8,199,68,36,4,237,137,60,36,232,251,1,23,255,185, - 237,139,1,137,4,36,232,251,1,24,255,131,196,32,255,139,148,253,36,233,255, - 139,12,36,255,129,196,239,255,232,251,1,25,131,252,236,48,255,137,68,36,32, - 232,251,1,0,185,237,137,1,199,68,36,8,237,199,68,36,4,237,137,60,36,232,251, - 1,7,139,76,36,32,137,8,252,233,244,10,255,137,84,36,36,137,68,36,32,232,251, - 1,0,185,237,137,1,199,68,36,8,237,199,68,36,4,0,0,0,0,137,60,36,232,251,1, - 7,139,76,36,36,139,84,36,32,137,72,4,137,16,252,233,244,10,255,137,68,36, - 32,137,84,36,36,232,251,1,0,185,237,137,1,199,68,36,8,237,199,68,36,4,237, - 137,60,36,232,251,1,7,139,76,36,32,137,8,139,76,36,36,137,72,4,252,233,244, - 10,255,131,252,236,4,232,251,1,0,185,237,137,1,252,233,244,10,255,252,233, - 244,11,255,252,233,244,13,255,252,233,244,14,255,252,233,244,15,255,252,233, - 244,12,255 +static const unsigned char build_actionlist[1878] = { + 248,10,184,1,0.0,0.0,0.0,139,117,252,248,139,125,252,252,137,252,236,93,195, + 255,248,11,232,251,1,0,185,237,137,1,184,0,0.0,0.0,0.0,139,117,252,248,139, + 125,252,252,137,252,236,93,195,255,248,12,221.0,92,36,4,232,251,1,0,185,237, + 137,1,137,60,36,232,251,1,1,252,233,244,10,255,248,13,15.0,182,192,137,68, + 36,32,232,251,1,0,185,237,137,1,139,68,36,32,137,68,36,4,137,60,36,232,251, + 1,2,252,233,244,10,255,248,14,137,68,36,32,232,251,1,0,185,237,137,1,139, + 68,36,32,137,68,36,4,137,60,36,232,251,1,3,252,233,244,10,255,248,15,137, + 68,36,32,232,251,1,0,185,237,137,1,139,68,36,32,137,68,36,4,137,60,36,232, + 251,1,4,252,233,244,10,255,248,16,137,68,36,32,232,251,1,0,185,237,137,1, + 139,68,36,32,137,68,36,4,137,60,36,232,251,1,5,252,233,244,10,255,248,17, + 137,68,36,32,232,251,1,0,185,237,137,1,139,68,36,32,137,68,36,4,137,60,36, + 232,251,1,5,252,233,244,10,255,248,18,102,184,0,0.0,199.0,68,36,4,237,137, + 60,36,232,251,1,6,255,248,19,102,184,0,0.0,199.0,68,36,4,237,137,60,36,232, + 251,1,6,255,248,20,137,77,252,248,137,85,252,244,195,255,139,141,233,255, + 139,141,233,139,149,233,255,137,132,253,36,233,255,137,132,253,36,233,137, + 148,253,36,233,255,221.0,133,233,255,217.0,133,233,255,252,243.0,15.0,126, + 133,233,255,252,243.0,15.0,90,133,233,255,221.0,156,253,36,233,255,217.0, + 156,253,36,233,255,102.0,15.0,214,132,253,36,233,255,252,242.0,15.0,90,192, + 102.0,15.0,214,132,253,36,233,255,252,242.0,15.0,90,192,102.0,15.0,126,132, + 253,36,233,255,85,137,229,87,129.0,252,236,239,255,232,244,20,255,191,237, + 255,199.0,68,36,8,237,199.0,68,36,4,237,137,60,36,232,251,1,7,255,199.0,68, + 36,8,237,199.0,68,36,4,252,255,252,255.0,252,255.0,252,255.0,137,60,36,232, + 251,1,7,255,199.0,68,36,8,237,199.0,68,36,4,237,137,60,36,232,251,1,7,199.0, + 68,36,8,237,199.0,68,36,4,252,255,252,255.0,252,255.0,252,255.0,137,60,36, + 232,251,1,8,255,137,8,199.0,68,36,4,252,254,252,255.0,252,255.0,252,255.0, + 137,60,36,232,251,1,9,255,199.0,68,36,8,237,199.0,68,36,4,0,0.0,0.0,0.0,137, + 60,36,232,251,1,8,255,137,8,137,80,4,255,137,8,255,102.0,15.0,214,0,255,217.0, + 24,255,217.0,88,4,255,221.0,24,255,221.0,88,8,255,221.0,92,36,4,137,60,36, + 232,251,1,1,255,15.0,182,201,137,76,36,4,137,60,36,232,251,1,2,255,15.0,182, + 201,255,15.0,190,201,255,137,76,36,4,137,60,36,232,251,1,3,255,15.0,183,201, + 255,15.0,191,201,255,137,76,36,4,137,60,36,232,251,1,4,255,199.0,68,36,12, + 0,0.0,0.0,0.0,199.0,68,36,8,237,199.0,68,36,4,237,137,60,36,232,251,1,10, + 255,199.0,68,36,8,237,199.0,68,36,4,252,254,252,255.0,252,255.0,252,255.0, + 137,60,36,232,251,1,7,199.0,68,36,12,237,199.0,68,36,8,252,255,252,255.0, + 252,255.0,252,255.0,199.0,68,36,4,252,254,252,255.0,252,255.0,252,255.0,137, + 60,36,232,251,1,11,137,68,36,32,199.0,68,36,4,252,252,252,255.0,252,255.0, + 252,255.0,137,60,36,232,251,1,12,139,68,36,32,255,199.0,68,36,8,237,199.0, + 68,36,4,252,254,252,255.0,252,255.0,252,255.0,137,60,36,232,251,1,7,199.0, + 68,36,12,237,199.0,68,36,8,252,255,252,255.0,252,255.0,252,255.0,199.0,68, + 36,4,252,254,252,255.0,252,255.0,252,255.0,137,60,36,232,251,1,13,137,68, + 36,32,199.0,68,36,4,252,252,252,255.0,252,255.0,252,255.0,137,60,36,232,251, + 1,12,139,68,36,32,255,199.0,68,36,4,252,254,252,255.0,252,255.0,252,255.0, + 137,60,36,232,251,1,12,255,199.0,68,36,4,252,255,252,255.0,252,255.0,252, + 255.0,137,60,36,232,251,1,14,255,199.0,68,36,4,252,255,252,255.0,252,255.0, + 252,255.0,137,60,36,232,251,1,15,255,137,68,36,32,199.0,68,36,4,252,253,252, + 255.0,252,255.0,252,255.0,137,60,36,232,251,1,12,139,68,36,32,255,199.0,68, + 36,4,252,255,252,255.0,252,255.0,252,255.0,137,60,36,232,251,1,16,255,199.0, + 68,36,4,252,255,252,255.0,252,255.0,252,255.0,137,60,36,232,251,1,17,255, + 137,68,36,32,137,84,36,36,199.0,68,36,4,252,253,252,255.0,252,255.0,252,255.0, + 137,60,36,232,251,1,12,139,68,36,32,139,84,36,36,255,199.0,68,36,4,252,255, + 252,255.0,252,255.0,252,255.0,137,60,36,232,251,1,18,137,68,36,32,199.0,68, + 36,4,252,253,252,255.0,252,255.0,252,255.0,137,60,36,232,251,1,12,139,68, + 36,32,255,199.0,68,36,4,252,255,252,255.0,252,255.0,252,255.0,137,60,36,232, + 251,1,19,255,221.0,92,36,32,199.0,68,36,4,252,253,252,255.0,252,255.0,252, + 255.0,137,60,36,232,251,1,12,221.0,68,36,32,255,199.0,68,36,4,252,255,252, + 255.0,252,255.0,252,255.0,137,60,36,232,251,1,20,137,68,36,32,137,84,36,36, + 199.0,68,36,4,252,253,252,255.0,252,255.0,252,255.0,137,60,36,232,251,1,12, + 139,68,36,32,139,84,36,36,255,199.0,68,36,4,252,255,252,255.0,252,255.0,252, + 255.0,137,60,36,232,251,1,21,102.0,15.0,214,68,36,32,102.0,15.0,214,76,36, + 40,199.0,68,36,4,252,253,252,255.0,252,255.0,252,255.0,137,60,36,232,251, + 1,12,252,243.0,15.0,126,68,36,32,252,243.0,15.0,126,76,36,40,255,139,141, + 233,199.0,68,36,8,252,255,252,255.0,252,255.0,252,255.0,137,124,36,4,137, + 12,36,232,251,1,21,131.0,252,236,4,199.0,68,36,4,252,253,252,255.0,252,255.0, + 252,255.0,137,60,36,232,251,1,12,255,139,125,252,252,137,252,236,93,194,236, + 255,85,137,229,87,86,139,189,233,131.0,252,236,16,137,60,36,232,251,1,22, + 137,198,129.0,252,248,239,15.0,140,244,18,255,15.0,143,244,19,255,193.0,224, + 4,41,196,129.0,252,236,239,255,199.0,68,36,8,237,199.0,68,36,4,0,0.0,0.0, + 0.0,137,60,36,232,251,1,8,131.0,252,236,16,255,199.0,68,36,12,237,199.0,68, + 36,8,237,199.0,68,36,4,237,137,60,36,232,251,1,11,255,199.0,68,36,12,237, + 199.0,68,36,8,237,199.0,68,36,4,237,137,60,36,232,251,1,23,255,199.0,68,36, + 12,237,199.0,68,36,8,237,199.0,68,36,4,237,137,60,36,232,251,1,13,255,199.0, + 68,36,4,237,137,60,36,232,251,1,15,255,15.0,182,192,255,15.0,190,192,255, + 15.0,183,192,255,15.0,191,192,255,199.0,68,36,4,237,137,60,36,232,251,1,15, + 131.0,252,248,0,15.0,149.0,208,15.0,182,192,255,199.0,68,36,4,237,137,60, + 36,232,251,1,14,255,199.0,68,36,4,237,137,60,36,232,251,1,18,255,199.0,68, + 36,4,237,137,60,36,232,251,1,16,255,199.0,68,36,4,237,137,60,36,232,251,1, + 17,255,199.0,68,36,4,237,137,60,36,232,251,1,19,255,199.0,68,36,4,237,137, + 60,36,232,251,1,21,255,252,243.0,15.0,126,193,255,141,132,253,36,233,131.0, + 252,236,4,199.0,68,36,8,237,137,124,36,4,137,4,36,232,251,1,21,255,199.0, + 68,36,4,237,137,60,36,232,251,1,20,255,199.0,68,36,4,237,137,60,36,232,251, + 1,20,137,4,36,217.0,4,36,255,137,20,36,217.0,4,36,255,137,224,129.0,192,239, + 137,68,36,12,137,116,36,8,199.0,68,36,4,237,137,60,36,232,251,1,24,255,185, + 237,139,1,137,4,36,232,251,1,25,255,131.0,196,32,255,139,148,253,36,233,255, + 139,12,36,255,129.0,196,239,255,232,251,1,26,131.0,252,236,48,255,137,68, + 36,32,232,251,1,0,185,237,137,1,199.0,68,36,8,237,199.0,68,36,4,237,137,60, + 36,232,251,1,8,139,76,36,32,137,8,252,233,244,10,255,252,233,244,17,255,252, + 233,244,16,255,137,84,36,36,137,68,36,32,232,251,1,0,185,237,137,1,199.0, + 68,36,8,237,199.0,68,36,4,0,0.0,0.0,0.0,137,60,36,232,251,1,8,139,76,36,36, + 139,84,36,32,137,72,4,137,16,252,233,244,10,255,137,68,36,32,137,84,36,36, + 232,251,1,0,185,237,137,1,199.0,68,36,8,237,199.0,68,36,4,237,137,60,36,232, + 251,1,8,139,76,36,32,137,8,139,76,36,36,137,72,4,252,233,244,10,255,131.0, + 252,236,4,232,251,1,0,185,237,137,1,252,233,244,10,255,252,233,244,11,255, + 252,233,244,13,255,252,233,244,14,255,252,233,244,15,255,252,233,244,12,255 }; static const char *const globnames[] = { @@ -112,6 +121,8 @@ static const char *const globnames[] = { "lua_return_bool", "lua_return_int", "lua_return_uint", + "lua_return_long", + "lua_return_ulong", "too_few_arguments", "too_many_arguments", "save_registers", @@ -123,6 +134,7 @@ static const char *const extnames[] = { "lua_pushboolean", "push_int", "push_uint", + "lua_pushinteger", "luaL_error", "lua_rawgeti", "push_cdata", @@ -224,11 +236,17 @@ void compile_globals(struct jit* jit, lua_State* L) dasm_put(Dst, 147, perr); - dasm_put(Dst, 181, (ptrdiff_t)("too few arguments")); +#if LUA_VERSION_NUM == 503 + dasm_put(Dst, 181, perr); - dasm_put(Dst, 200, (ptrdiff_t)("too many arguments")); + dasm_put(Dst, 215, perr); +#endif + + dasm_put(Dst, 249, (ptrdiff_t)("too few arguments")); - dasm_put(Dst, 219); + dasm_put(Dst, 268, (ptrdiff_t)("too many arguments")); + + dasm_put(Dst, 287); compile(Dst, L, NULL, LUA_NOREF); } @@ -338,25 +356,25 @@ static void get_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int /* grab the register from the shadow space */ #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { - dasm_put(Dst, 231, 16 + 8*reg->regs); + dasm_put(Dst, 299, 16 + 8*reg->regs); reg->regs++; } #elif __amd64__ if (reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 231, - 80 - 8*reg->ints); + dasm_put(Dst, 299, - 80 - 8*reg->ints); reg->ints++; } #else if (!is_int64 && reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 231, - 8 - 4*reg->ints); + dasm_put(Dst, 299, - 8 - 4*reg->ints); reg->ints++; } #endif else if (is_int64) { - dasm_put(Dst, 235, reg->off, reg->off + 4); + dasm_put(Dst, 303, reg->off, reg->off + 4); reg->off += 8; } else { - dasm_put(Dst, 231, reg->off); + dasm_put(Dst, 299, reg->off); reg->off += 4; } } @@ -365,17 +383,17 @@ static void add_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int { #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { - dasm_put(Dst, 242, 32 + 8*(reg->regs)); + dasm_put(Dst, 310, 32 + 8*(reg->regs)); reg->is_int[reg->regs++] = 1; } #elif __amd64__ if (reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 242, 32 + 8*reg->ints); + dasm_put(Dst, 310, 32 + 8*reg->ints); reg->ints++; } #else if (!is_int64 && reg->ints < MAX_INT_REGISTERS(ct)) { - dasm_put(Dst, 242, 32 + 4*reg->ints); + dasm_put(Dst, 310, 32 + 4*reg->ints); reg->ints++; } #endif @@ -386,10 +404,10 @@ static void add_int(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, int } #endif if (is_int64) { - dasm_put(Dst, 248, reg->off, reg->off + 4); + dasm_put(Dst, 316, reg->off, reg->off + 4); reg->off += 8; } else { - dasm_put(Dst, 242, reg->off); + dasm_put(Dst, 310, reg->off); reg->off += 4; } } @@ -400,10 +418,10 @@ static void get_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #if !defined _WIN64 && !defined __amd64__ assert(MAX_FLOAT_REGISTERS(ct) == 0); if (is_double) { - dasm_put(Dst, 259, reg->off); + dasm_put(Dst, 327, reg->off); reg->off += 8; } else { - dasm_put(Dst, 263, reg->off); + dasm_put(Dst, 331, reg->off); reg->off += 4; } #else @@ -426,9 +444,9 @@ static void get_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i } if (is_double) { - dasm_put(Dst, 267, off); + dasm_put(Dst, 335, off); } else { - dasm_put(Dst, 274, off); + dasm_put(Dst, 342, off); } #endif } @@ -438,10 +456,10 @@ static void add_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #if !defined _WIN64 && !defined __amd64__ assert(MAX_FLOAT_REGISTERS(ct) == 0); if (is_double) { - dasm_put(Dst, 281, reg->off); + dasm_put(Dst, 349, reg->off); reg->off += 8; } else { - dasm_put(Dst, 287, reg->off); + dasm_put(Dst, 355, reg->off); reg->off += 4; } #else @@ -449,28 +467,28 @@ static void add_float(Dst_DECL, const struct ctype* ct, struct reg_alloc* reg, i #ifdef _WIN64 if (reg->regs < MAX_REGISTERS(ct)) { if (is_double) { - dasm_put(Dst, 293, 32 + 8*(reg->regs)); + dasm_put(Dst, 361, 32 + 8*(reg->regs)); } else { - dasm_put(Dst, 301, 32 + 8*(reg->regs)); + dasm_put(Dst, 369, 32 + 8*(reg->regs)); } reg->is_float[reg->regs++] = 1; } #else if (reg->floats < MAX_FLOAT_REGISTERS(ct)) { if (is_double) { - dasm_put(Dst, 293, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); + dasm_put(Dst, 361, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); } else { - dasm_put(Dst, 301, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); + dasm_put(Dst, 369, 32 + 8*(MAX_INT_REGISTERS(ct) + reg->floats)); } reg->floats++; } #endif else if (is_double) { - dasm_put(Dst, 293, reg->off); + dasm_put(Dst, 361, reg->off); reg->off += 8; } else { - dasm_put(Dst, 314, reg->off); + dasm_put(Dst, 382, reg->off); reg->off += 4; } #endif @@ -526,22 +544,22 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp // setup a stack frame to hold args for the call into lua_call - dasm_put(Dst, 327, 4 + 16 + 32 + REGISTER_STACK_SPACE(ct)); + dasm_put(Dst, 395, 4 + 16 + 32 + REGISTER_STACK_SPACE(ct)); if (ct->calling_convention == FAST_CALL) { - dasm_put(Dst, 336); + dasm_put(Dst, 404); } // hardcode the lua_State* value into the assembly - dasm_put(Dst, 340, L); + dasm_put(Dst, 408, L); /* get the upval table */ - dasm_put(Dst, 343, ref, LUA_REGISTRYINDEX); + dasm_put(Dst, 411, ref, LUA_REGISTRYINDEX); /* get the lua function */ lua_pushvalue(L, fidx); lua_rawseti(L, -2, ++num_upvals); assert(num_upvals == CALLBACK_FUNC_USR_IDX); - dasm_put(Dst, 361, num_upvals); + dasm_put(Dst, 429, num_upvals); #if !defined _WIN64 && !defined __amd64__ lua_rawgeti(L, ct_usr, 0); @@ -566,90 +584,90 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp /* on the lua stack in the callback: * upval tbl, lua func, i-1 args */ - dasm_put(Dst, 386, num_upvals-1, -i-1, mt); + dasm_put(Dst, 454, num_upvals-1, -i-1, mt); get_pointer(Dst, ct, ®); - dasm_put(Dst, 428); + dasm_put(Dst, 496); } else { switch (mt->type) { case INT64_TYPE: lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* mt */ lua_pop(L, 1); - dasm_put(Dst, 450, mt); + dasm_put(Dst, 518, mt); get_int(Dst, ct, ®, 1); - dasm_put(Dst, 471); + dasm_put(Dst, 539); break; case INTPTR_TYPE: lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* mt */ lua_pop(L, 1); - dasm_put(Dst, 450, mt); + dasm_put(Dst, 518, mt); get_pointer(Dst, ct, ®); - dasm_put(Dst, 477); + dasm_put(Dst, 545); break; case COMPLEX_FLOAT_TYPE: lua_pop(L, 1); #if defined _WIN64 || defined __amd64__ /* complex floats are two floats packed into a double */ - dasm_put(Dst, 450, mt); + dasm_put(Dst, 518, mt); get_float(Dst, ct, ®, 1); - dasm_put(Dst, 480); + dasm_put(Dst, 548); #else /* complex floats are real followed by imag on the stack */ - dasm_put(Dst, 450, mt); + dasm_put(Dst, 518, mt); get_float(Dst, ct, ®, 0); - dasm_put(Dst, 485); + dasm_put(Dst, 553); get_float(Dst, ct, ®, 0); - dasm_put(Dst, 488); + dasm_put(Dst, 556); #endif break; case COMPLEX_DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 450, mt); + dasm_put(Dst, 518, mt); /* real */ get_float(Dst, ct, ®, 1); - dasm_put(Dst, 492); + dasm_put(Dst, 560); /* imag */ get_float(Dst, ct, ®, 1); - dasm_put(Dst, 495); + dasm_put(Dst, 563); break; case FLOAT_TYPE: case DOUBLE_TYPE: lua_pop(L, 1); get_float(Dst, ct, ®, mt->type == DOUBLE_TYPE); - dasm_put(Dst, 499); + dasm_put(Dst, 567); break; case BOOL_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); - dasm_put(Dst, 511); + dasm_put(Dst, 579); break; case INT8_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 526); + dasm_put(Dst, 594); } else { - dasm_put(Dst, 530); + dasm_put(Dst, 598); } - dasm_put(Dst, 534); + dasm_put(Dst, 602); break; case INT16_TYPE: lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 546); + dasm_put(Dst, 614); } else { - dasm_put(Dst, 550); + dasm_put(Dst, 618); } - dasm_put(Dst, 534); + dasm_put(Dst, 602); break; case ENUM_TYPE: @@ -657,9 +675,9 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_pop(L, 1); get_int(Dst, ct, ®, 0); if (mt->is_unsigned) { - dasm_put(Dst, 554); + dasm_put(Dst, 622); } else { - dasm_put(Dst, 534); + dasm_put(Dst, 602); } break; @@ -672,7 +690,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_rawgeti(L, ct_usr, 0); mt = (const struct ctype*) lua_touserdata(L, -1); - dasm_put(Dst, 566, (mt->pointers || mt->is_reference || mt->type != VOID_TYPE) ? 1 : 0, nargs); + dasm_put(Dst, 634, (mt->pointers || mt->is_reference || mt->type != VOID_TYPE) ? 1 : 0, nargs); // Unpack the return argument if not "void", also clean-up the lua stack // to remove the return argument and bind table. Use lua_settop rather @@ -681,7 +699,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* usr value */ lua_rawseti(L, -2, ++num_upvals); /* mt */ - dasm_put(Dst, 592, num_upvals-1, mt); + dasm_put(Dst, 660, num_upvals-1, mt); } else { switch (mt->type) { @@ -689,12 +707,12 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp lua_getuservalue(L, -1); lua_rawseti(L, -3, ++num_upvals); /* usr value */ lua_rawseti(L, -2, ++num_upvals); /* mt */ - dasm_put(Dst, 680, num_upvals-1, mt); + dasm_put(Dst, 748, num_upvals-1, mt); break; case VOID_TYPE: lua_pop(L, 1); - dasm_put(Dst, 768); + dasm_put(Dst, 836); break; case BOOL_TYPE: @@ -703,38 +721,38 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp case INT32_TYPE: lua_pop(L, 1); if (mt->is_unsigned) { - dasm_put(Dst, 788); + dasm_put(Dst, 856); } else { - dasm_put(Dst, 808); + dasm_put(Dst, 876); } - dasm_put(Dst, 828); + dasm_put(Dst, 896); break; case INT64_TYPE: lua_pop(L, 1); if (mt->is_unsigned) { - dasm_put(Dst, 856); + dasm_put(Dst, 924); } else { - dasm_put(Dst, 876); + dasm_put(Dst, 944); } - dasm_put(Dst, 896); + dasm_put(Dst, 964); break; case INTPTR_TYPE: lua_pop(L, 1); - dasm_put(Dst, 932); + dasm_put(Dst, 1000); break; case FLOAT_TYPE: case DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 979); + dasm_put(Dst, 1047); if (mt->type == FLOAT_TYPE) { } else { } - dasm_put(Dst, 999); + dasm_put(Dst, 1067); break; case COMPLEX_FLOAT_TYPE: @@ -744,7 +762,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp #endif /* on 64 bit complex floats are two floats packed into a double, * on 32 bit returned complex floats use eax and edx */ - dasm_put(Dst, 1027); + dasm_put(Dst, 1095); break; case COMPLEX_DOUBLE_TYPE: @@ -757,9 +775,9 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp * the returned arg is stored which is popped by the called * function */ #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1082); + dasm_put(Dst, 1150); #else - dasm_put(Dst, 1147, hidden_arg_off); + dasm_put(Dst, 1215, hidden_arg_off); #endif break; @@ -768,7 +786,7 @@ cfunction compile_callback(lua_State* L, int fidx, int ct_usr, const struct ctyp } } - dasm_put(Dst, 1197, x86_return_size(L, ct_usr, ct)); + dasm_put(Dst, 1265, x86_return_size(L, ct_usr, ct)); lua_pop(L, 1); /* upval table - already in registry */ assert(lua_gettop(L) == top); @@ -810,15 +828,15 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty luaL_error(L, "vararg is only allowed with the c calling convention"); } - dasm_put(Dst, 1208, 8, nargs); + dasm_put(Dst, 1276, 8, nargs); if (!ct->has_var_arg) { - dasm_put(Dst, 1238); + dasm_put(Dst, 1306); } /* no need to zero extend eax returned by lua_gettop to rax as x86-64 * preguarentees that the upper 32 bits will be zero */ - dasm_put(Dst, 1243, 32 + REGISTER_STACK_SPACE(ct)); + dasm_put(Dst, 1311, 32 + REGISTER_STACK_SPACE(ct)); #if !defined _WIN64 && !defined __amd64__ /* Returned complex doubles require a hidden first parameter where the @@ -829,7 +847,7 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty /* we can allocate more space for arguments as long as no add_* * function has been called yet, mbr_ct will be added as an upvalue in * the return processing later */ - dasm_put(Dst, 1253, mbr_ct); + dasm_put(Dst, 1321, mbr_ct); add_pointer(Dst, ct, ®); } lua_pop(L, 1); @@ -842,80 +860,80 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty if (mbr_ct->pointers || mbr_ct->is_reference) { lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1278, mbr_ct, lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1346, mbr_ct, lua_upvalueindex(num_upvals), i); add_pointer(Dst, ct, ®); } else { switch (mbr_ct->type) { case FUNCTION_PTR_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1301, mbr_ct, lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1369, mbr_ct, lua_upvalueindex(num_upvals), i); add_pointer(Dst, ct, ®); break; case ENUM_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1324, mbr_ct, lua_upvalueindex(num_upvals), i); + dasm_put(Dst, 1392, mbr_ct, lua_upvalueindex(num_upvals), i); add_int(Dst, ct, ®, 0); break; case INT8_TYPE: - dasm_put(Dst, 1347, i); + dasm_put(Dst, 1415, i); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1360); + dasm_put(Dst, 1428); } else { - dasm_put(Dst, 1364); + dasm_put(Dst, 1432); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INT16_TYPE: - dasm_put(Dst, 1347, i); + dasm_put(Dst, 1415, i); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1368); + dasm_put(Dst, 1436); } else { - dasm_put(Dst, 1372); + dasm_put(Dst, 1440); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case BOOL_TYPE: - dasm_put(Dst, 1376, i); + dasm_put(Dst, 1444, i); add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INT32_TYPE: if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1399, i); + dasm_put(Dst, 1467, i); } else { - dasm_put(Dst, 1347, i); + dasm_put(Dst, 1415, i); } add_int(Dst, ct, ®, 0); lua_pop(L, 1); break; case INTPTR_TYPE: - dasm_put(Dst, 1412, i); + dasm_put(Dst, 1480, i); add_pointer(Dst, ct, ®); lua_pop(L, 1); break; case INT64_TYPE: if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1425, i); + dasm_put(Dst, 1493, i); } else { - dasm_put(Dst, 1438, i); + dasm_put(Dst, 1506, i); } add_int(Dst, ct, ®, 1); lua_pop(L, 1); break; case DOUBLE_TYPE: - dasm_put(Dst, 1451, i); + dasm_put(Dst, 1519, i); add_float(Dst, ct, ®, 1); lua_pop(L, 1); break; @@ -926,33 +944,33 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty * the returned arg is stored (this is popped by the called * function) */ #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1464, i); + dasm_put(Dst, 1532, i); add_float(Dst, ct, ®, 1); - dasm_put(Dst, 1477); + dasm_put(Dst, 1545); add_float(Dst, ct, ®, 1); #else - dasm_put(Dst, 1483, reg.off, i); + dasm_put(Dst, 1551, reg.off, i); reg.off += 16; #endif lua_pop(L, 1); break; case FLOAT_TYPE: - dasm_put(Dst, 1451, i); + dasm_put(Dst, 1519, i); add_float(Dst, ct, ®, 0); lua_pop(L, 1); break; case COMPLEX_FLOAT_TYPE: #if defined _WIN64 || defined __amd64__ - dasm_put(Dst, 1509, i); + dasm_put(Dst, 1577, i); /* complex floats are two floats packed into a double */ add_float(Dst, ct, ®, 1); #else /* returned complex floats use eax and edx */ - dasm_put(Dst, 1522, i); + dasm_put(Dst, 1590, i); add_float(Dst, ct, ®, 0); - dasm_put(Dst, 1541); + dasm_put(Dst, 1609); add_float(Dst, ct, ®, 0); #endif lua_pop(L, 1); @@ -986,14 +1004,14 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty reg.floats = MAX_FLOAT_REGISTERS(ct); reg.ints = MAX_INT_REGISTERS(ct); #else - dasm_put(Dst, 1548, reg.off, nargs+1); + dasm_put(Dst, 1616, reg.off, nargs+1); #endif } - dasm_put(Dst, 1574, perr); + dasm_put(Dst, 1642, perr); /* remove the stack space to call local functions */ - dasm_put(Dst, 1586); + dasm_put(Dst, 1654); #ifdef _WIN64 switch (reg.regs) { @@ -1053,14 +1071,14 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty if (ct->calling_convention == FAST_CALL) { switch (reg.ints) { case 2: - dasm_put(Dst, 1590, 4); + dasm_put(Dst, 1658, 4); case 1: - dasm_put(Dst, 1596); + dasm_put(Dst, 1664); case 0: break; } - dasm_put(Dst, 1600, REGISTER_STACK_SPACE(ct)); + dasm_put(Dst, 1668, REGISTER_STACK_SPACE(ct)); } #endif @@ -1072,7 +1090,7 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty } #endif - dasm_put(Dst, 1604); + dasm_put(Dst, 1672); /* note on windows X86 the stack may be only aligned to 4 (stdcall will * have popped a multiple of 4 bytes), but we don't need 16 byte alignment on @@ -1085,81 +1103,90 @@ void compile_function(lua_State* L, cfunction func, int ct_usr, const struct cty if (mbr_ct->pointers || mbr_ct->is_reference || mbr_ct->type == INTPTR_TYPE) { lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1613, perr, mbr_ct, lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1681, perr, mbr_ct, lua_upvalueindex(num_upvals)); } else { switch (mbr_ct->type) { case FUNCTION_PTR_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1613, perr, mbr_ct, lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1681, perr, mbr_ct, lua_upvalueindex(num_upvals)); break; case INT64_TYPE: +#if LUA_VERSION_NUM == 503 + lua_pop(L, 1); + if (mbr_ct->is_unsigned) { + dasm_put(Dst, 1721); + } else { + dasm_put(Dst, 1726); + } +#else num_upvals++; - dasm_put(Dst, 1653, perr, mbr_ct); + dasm_put(Dst, 1731, perr, mbr_ct); +#endif break; case COMPLEX_FLOAT_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1707, perr, mbr_ct, lua_upvalueindex(num_upvals)); + dasm_put(Dst, 1785, perr, mbr_ct, lua_upvalueindex(num_upvals)); break; case COMPLEX_DOUBLE_TYPE: lua_getuservalue(L, -1); num_upvals += 2; - dasm_put(Dst, 1758, perr); + dasm_put(Dst, 1836, perr); break; case VOID_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1775); + dasm_put(Dst, 1853); break; case BOOL_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1780); + dasm_put(Dst, 1858); break; case INT8_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1360); + dasm_put(Dst, 1428); } else { - dasm_put(Dst, 1364); + dasm_put(Dst, 1432); } - dasm_put(Dst, 1785); + dasm_put(Dst, 1863); break; case INT16_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1368); + dasm_put(Dst, 1436); } else { - dasm_put(Dst, 1372); + dasm_put(Dst, 1440); } - dasm_put(Dst, 1785); + dasm_put(Dst, 1863); break; case INT32_TYPE: case ENUM_TYPE: lua_pop(L, 1); if (mbr_ct->is_unsigned) { - dasm_put(Dst, 1790); + dasm_put(Dst, 1868); } else { - dasm_put(Dst, 1785); + dasm_put(Dst, 1863); } break; case FLOAT_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1795); + dasm_put(Dst, 1873); break; case DOUBLE_TYPE: lua_pop(L, 1); - dasm_put(Dst, 1795); + dasm_put(Dst, 1873); break; default: @@ -190,7 +190,7 @@ static int64_t check_intptr(lua_State* L, int idx, void* p, struct ctype* ct) static int get_cfunction_address(lua_State* L, int idx, cfunction* addr); -#define TO_NUMBER(TYPE, ALLOW_POINTERS) \ +#define TO_NUMBER(TYPE, ALLOW_POINTERS, LUA_TONUMBER) \ TYPE ret = 0; \ void* p; \ struct ctype ct; \ @@ -202,7 +202,7 @@ static int get_cfunction_address(lua_State* L, int idx, cfunction* addr); break; \ \ case LUA_TNUMBER: \ - ret = (TYPE) lua_tonumber(L, idx); \ + ret = (TYPE) LUA_TONUMBER(L, idx); \ break; \ \ case LUA_TSTRING: \ @@ -265,10 +265,10 @@ static int get_cfunction_address(lua_State* L, int idx, cfunction* addr); } \ static int64_t cast_int64(lua_State* L, int idx, int is_cast) -{ TO_NUMBER(int64_t, is_cast); return ret; } +{ TO_NUMBER(int64_t, is_cast, lua_tointeger); return ret; } static uint64_t cast_uint64(lua_State* L, int idx, int is_cast) -{ TO_NUMBER(uint64_t, is_cast); return ret; } +{ TO_NUMBER(uint64_t, is_cast, lua_tointeger); return ret; } int32_t check_int32(lua_State* L, int idx) { return (int32_t) cast_int64(L, idx, 0); } @@ -283,13 +283,13 @@ uint64_t check_uint64(lua_State* L, int idx) { return cast_uint64(L, idx, 0); } double check_double(lua_State* L, int idx) -{ TO_NUMBER(double, 0); return ret; } +{ TO_NUMBER(double, 0, lua_tonumber); return ret; } float check_float(lua_State* L, int idx) -{ TO_NUMBER(double, 0); return ret; } +{ TO_NUMBER(double, 0, lua_tonumber); return ret; } uintptr_t check_uintptr(lua_State* L, int idx) -{ TO_NUMBER(uintptr_t, 1); return ret; } +{ TO_NUMBER(uintptr_t, 1, lua_tointeger); return ret; } complex_double check_complex_double(lua_State* L, int idx) { @@ -356,7 +356,7 @@ static size_t unpack_vararg(lua_State* L, int i, char* to) return sizeof(int); case LUA_TNUMBER: - *(double*) to = lua_tonumber(L, i); + *(double*) to = lua_tonumber(L, i); // TODO in Lua 5.3: lua_tointeger sometimes should be here return sizeof(double); case LUA_TSTRING: @@ -526,7 +526,7 @@ static void* check_pointer(lua_State* L, int idx, struct ctype* ct) ct->is_unsigned = 1; ct->pointers = 0; lua_pushnil(L); - return (void*) (uintptr_t) lua_tonumber(L, idx); + return (void*) (uintptr_t) lua_tonumber(L, idx); // TODO in Lua 5.3: maybe change to lua_tointeger case LUA_TLIGHTUSERDATA: ct->type = VOID_TYPE; @@ -749,6 +749,32 @@ __attribute__((dllimport)) void __attribute__((__cdecl__)) alEnable( ALenum capa check(ffi.sizeof('struct {char foo[alignof(uint64_t)];}'), ffi.alignof('uint64_t')) +-- Check native number type for int64_t/uint64_t function args/returns in Lua 5.3 +if _VERSION == "Lua 5.3" then + local native_7F = 0x7FFFFFFFFFFFFFFF + local cdata_long_7F = ffi.new("int64_t", 0x7FFFFFFFFFFFFFFF) + local cdata_ulong_7F = ffi.new("uint64_t", 0x7FFFFFFFFFFFFFFF) + + local native_80 = 0x8000000000000000 + + for _, func in ipairs{ffi.C.add_i64, ffi.C.add_u64} do + -- 0x7FFFFFFFFFFFFFFF (native) + 1 == 0x8000000000000000 (native) + local res = func(native_7F, 1) + assert(type(res) == "number", "native_7F: returned value not a number") + assert(res == native_80, "native_7F: math error") + + -- 0x7FFFFFFFFFFFFFFF (cdata int64_t) + 1 == 0x8000000000000000 (native) + local res = func(cdata_long_7F, 1) + assert(type(res) == "number", "cdata_long_7F: returned value not a number") + assert(res == native_80, "cdata_long_7F: math error") + + -- 0x7FFFFFFFFFFFFFFF (cdata uint64_t) + 1 == 0x8000000000000000 (native) + local res = func(cdata_ulong_7F, 1) + assert(type(res) == "number", "cdata_ulong_7F: returned value not a number") + assert(res == native_80, "cdata_ulong_7F: math error") + end +end + -- Long double is not supported yet but it should be parsed ffi.cdef('long double foo(long double val);') check(tostring(ffi.debug().functions.foo):match('ctype(%b<>)'), '<long double (*)(long double)>') @@ -975,4 +1001,3 @@ assert(str == 'test: foo', str) f:close() print('Test PASSED') - |