Skip to content

Commit c1c6dbe

Browse files
committed
Fixed a few problems
- JIT modules now copy over when building with luajit as driver or package - jitargs now handles the args properly - jit regression fixed for -O -b -j - windows now delete bin correctly when cleaning - uses less mallocs due to removal of a couple arrays - fully fixed regression where D command didn't work properly
1 parent 2a4e4a0 commit c1c6dbe

File tree

9 files changed

+64
-53
lines changed

9 files changed

+64
-53
lines changed

build.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ setlocal
6060
del include\*.h
6161
del dll\*.dll
6262
del obj\*.o
63-
rmdir /S /Q bin\*
63+
rmdir /S /Q bin\Release
64+
rmdir /S /Q bin\Debug
6465

6566
echo Done.
6667
exit /b 0
@@ -146,6 +147,8 @@ setlocal
146147
REM Build dependencies
147148
IF [%2] == [luajit] (
148149
call :build_luajit
150+
mkdir %root%\jit
151+
xcopy /E /Y luajit-2.0\src\jit\* %root%\jit
149152
) ELSE (
150153
IF NOT EXIST "lua-all\%2" (
151154
echo Not a valid lua version!
@@ -185,6 +188,8 @@ setlocal
185188

186189
IF [%2] == [luajit] (
187190
call :build_luajit
191+
mkdir %root%\jit
192+
xcopy /E /Y luajit-2.0\src\jit\* %root%\jit
188193
) ELSE (
189194
IF NOT EXIST "lua-all\%2" (
190195
echo Not a valid lua version!

build.msvs.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ setlocal
5757
del dll\*.lib
5858
del dll\*.exp
5959
del obj\*.obj
60-
rmdir /S /Q bin\*
60+
rmdir /S /Q bin\Release
61+
rmdir /S /Q bin\Debug
6162

6263
echo Done.
6364
exit /b 0
@@ -143,6 +144,8 @@ setlocal
143144
REM Build dependencies
144145
IF [%2] == [luajit] (
145146
call :build_luajit
147+
mkdir %root%\jit
148+
xcopy /E /Y luajit-2.0\src\jit\* %root%\jit
146149
) ELSE (
147150
IF NOT EXIST "lua-all\%2" (
148151
echo Not a valid lua version!
@@ -184,6 +187,8 @@ setlocal
184187

185188
IF [%2] == [luajit] (
186189
call :build_luajit
190+
mkdir %root%\jit
191+
xcopy /E /Y luajit-2.0\src\jit\* %root%\jit
187192
) ELSE (
188193
IF NOT EXIST "lua-all\%2" (
189194
echo Not a valid lua version!

build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ build_install () {
237237
mv *.o $objdir
238238
if [ "$1" = "luajit" ]; then
239239
cp -r $dlldir/* $root
240+
mkdir $root/jit
240241
else
241242
cp $dlldir/$1.so $root/dll
242243
fi
@@ -302,6 +303,11 @@ if [ "$1" = "driver" ]; then
302303
# Build dependencies
303304
if [ "$2" = "luajit" ]; then
304305
build_luajit
306+
if [ ! -d "$root/jit" ]; then
307+
mkdir -p $root/jit
308+
cp -r luajit-2.0/src/jit/* $root/jit
309+
ls $root/jit
310+
fi
305311
else
306312
if [ ! -d "lua-all/$2" ]; then
307313
echo Not a valid lua version!
@@ -342,6 +348,11 @@ if [ "$1" = "package" ]; then
342348

343349
if [ "$2" = "luajit" ]; then
344350
build_luajit
351+
if [ ! -d "$root/jit" ]; then
352+
mkdir -p $root/jit
353+
cp -r luajit-2.0/src/jit/* $root/jit
354+
ls $root/jit
355+
fi
345356
else
346357
if [ ! -d "lua-all/$2" ]; then
347358
echo Not a valid lua version!

src/jitsupport.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#if defined(LUA_JIT_51)
25+
# include "luadriver.h"
2526
# include "jitsupport.h"
2627

2728
# include "lang.h"
@@ -169,26 +170,31 @@
169170
}
170171

171172

172-
int jitargs(lua_State* L, Array* luajit_jcmds, Array* luajit_opts,
173-
char** luajit_bc, int squelch, int post_exist)
174-
{
175-
if(luajit_jcmds != NULL) {
176-
for(size_t i=0; i<luajit_jcmds->size; i++)
177-
if(dojitcmd(L, (const char*) array_get(luajit_jcmds, i)) != 0)
178-
fputs(_("JS_FAILED_CONTROL_CMD"), stderr);
173+
int jitargs(lua_State* L, LC_ARGS ARGS) {
174+
175+
if(ARGS.jitjcmd != NULL) {
176+
const char* cmd = (*(ARGS.jitjcmd[ARGS.jitjcmd_argc] + 2) == '\0')
177+
? ARGS.jitjcmd[ARGS.jitjcmd_argc + 1]
178+
: ARGS.jitjcmd[ARGS.jitjcmd_argc] + 2;
179+
180+
if(cmd == 0)
181+
fputs(_("MALFORMED_J_NO_PARAM"), stderr);
182+
183+
if(dojitcmd(L, cmd) == 1)
184+
fputs(_("JS_FAILED_CONTROL_CMD"), stderr);
179185
}
180-
181-
if(luajit_opts != NULL) {
182-
for(size_t i=0; i<luajit_opts->size; i++)
183-
if(dojitopt(L, (const char*) array_get(luajit_opts, i)) != 0)
184-
fputs(_("JS_FAILED_SET_O"), stderr);
186+
187+
if(ARGS.jitocmd != NULL) {
188+
if(dojitopt(L, ARGS.jitocmd[ARGS.jitocmd_argc] + 2) == 1)
189+
fputs(_("JS_FAILED_SET_O"), stderr);
185190
}
186191

187-
if(squelch == 0 && post_exist == 1)
192+
if(ARGS.copyright_squelch == 0 && ARGS.post_exist == 1)
188193
print_jit_status(L);
189194

190-
if(luajit_bc != NULL)
191-
return dobytecode(L, luajit_bc);
195+
if(ARGS.jitbcmd != NULL)
196+
return dobytecode(L, ARGS.jitbcmd + ARGS.jitjcmd_argc + 1);
197+
192198

193199
return 0; // success
194200
}

src/jitsupport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# include "lualib.h"
2929
# include "lauxlib.h"
3030
# include "luajit.h"
31+
# include "luadriver.h"
3132

3233
# include "darr.h"
3334

@@ -38,8 +39,7 @@
3839
int dobytecode(lua_State* L, char** argv);
3940
void print_jit_status(lua_State* L);
4041

41-
int jitargs(lua_State* L, Array* luajit_jcmds, Array* luajit_opts,
42-
char** luajit_bc, int squelch, int post_exist);
42+
int jitargs(lua_State* L, LC_ARGS ARGS);
4343

4444
#endif // EOF if defined(LUA_JIT_51)
4545

src/lang.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
#pragma once
33

4+
#include <stdlib.h>
5+
#include <stdio.h>
6+
47
#include "darr.h"
58

69
typedef struct LangCache {

src/ldata.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,8 @@ LC_LD_API int luacon_loaddll(LC_ARGS _ARGS, LangCache* _lang)
202202

203203
#if defined(LUA_JIT_51)
204204
if(ARGS.no_libraries == 0) {
205-
int status = jitargs(L,
206-
ARGS.luajit_jcmds, ARGS.luajit_opts, ARGS.luajit_bc,
207-
ARGS.copyright_squelch, ARGS.post_exist);
208-
209-
if(ARGS.luajit_bc != NULL)
205+
int status = jitargs(L, ARGS);
206+
if(status != 0)
210207
return status;
211208
}
212209
#endif

src/luadriver.c

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -239,34 +239,17 @@ int main(int argc, char** argv) {
239239
i = argc;
240240
break;
241241
case 'j':
242-
if(ARGS.luajit_jcmds == NULL)
243-
ARGS.luajit_jcmds = array_new(DEFINES_INIT, DEFINES_EXPANSION);
244-
check_error_OOM(ARGS.luajit_jcmds == NULL, __LINE__);
245-
246-
char* jcmd = argv[i] + 2;
247-
if(*jcmd == ' ' || *jcmd == '\0') {
248-
if(i + 1 >= argc) {
249-
fprintf(stderr, _("MALFORMED_J_NO_PARAM"));
250-
break;
251-
} else
252-
jcmd = argv[i+1];
253-
}
254-
array_push(ARGS.luajit_jcmds, jcmd);
242+
ARGS.jitjcmd = argv;
243+
ARGS.jitjcmd_argc = i;
255244
break;
256245
case 'O':
257-
if(ARGS.luajit_opts == NULL)
258-
ARGS.luajit_opts = array_new(DEFINES_INIT, DEFINES_EXPANSION);
259-
check_error_OOM(ARGS.luajit_opts == NULL, __LINE__);
260-
if(strlen(argv[i]) > 2)
261-
array_push(ARGS.luajit_opts, argv[i] + 2);
262-
else
263-
fprintf(stderr, _("MALFORMED_O_NO_PARAM"));
246+
ARGS.jitocmd = argv;
247+
ARGS.jitocmd_argc = i;
264248
break;
265249
case 'b':
266-
if(i + 1 < argc)
267-
ARGS.luajit_bc = argv + i;
268-
else
269-
fprintf(stderr, _("MALFORMED_B_NO_PARAM"));
250+
ARGS.post_exist = 0;
251+
ARGS.jitbcmd = argv;
252+
ARGS.jitbcmd_argc = i;
270253
break;
271254
case '?':
272255
ARGS.do_help = 1;
@@ -319,8 +302,6 @@ int main(int argc, char** argv) {
319302
langfile_free(lang);
320303
array_free(ARGS.globals);
321304
array_free(ARGS.libraries);
322-
array_free(ARGS.luajit_jcmds);
323-
array_free(ARGS.luajit_opts);
324305

325306
#if defined(_WIN32) || defined(_WIN64)
326307
FreeLibrary(luacxt);

src/luadriver.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ typedef struct tag_LC_ARGS {
3535
char* run_str;
3636
Array* globals;
3737
Array* libraries;
38-
Array* luajit_jcmds;
39-
Array* luajit_opts;
4038
char** parameters_argv;
41-
char** luajit_bc;
4239
char** files_index;
4340
char** luac_argv;
41+
char** jitjcmd;
42+
char** jitocmd;
43+
char** jitbcmd;
44+
int jitjcmd_argc;
45+
int jitocmd_argc;
46+
int jitbcmd_argc;
4447
int luac_argc;
4548
int do_luac;
4649
int do_help;

0 commit comments

Comments
 (0)