diff --git a/doc/ext_buffer.html b/doc/ext_buffer.html index 61f425f1..54bb66f6 100644 --- a/doc/ext_buffer.html +++ b/doc/ext_buffer.html @@ -85,7 +85,7 @@ operations.
The string buffer library also includes a high-performance -serializer for Lua objects. +serializer for Lua objects.
+Note: this is the only place where creating a boxed scalar number type is +actually useful. Never use ffi.new("int"), ffi.new("float") +etc. anywhere else! +
++Ditto for ffi.cast(). Explicitly boxing scalars does not +improve performance or force int or float arithmetic! It +just adds costly boxing, unboxing and conversions steps. And it may lead +to surprise results, because +cdata arithmetic on scalar numbers +is always performed on 64 bit integers. +
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c index 923824d9..b298d3f7 100644 --- a/src/lj_ffrecord.c +++ b/src/lj_ffrecord.c @@ -1005,6 +1005,7 @@ static void recff_format(jit_State *J, RecordFFData *rd, TRef hdr, int sbufx) GCstr *fmt = argv2str(J, &rd->argv[arg]); FormatState fs; SFormat sf; + int nfmt = 0; /* Specialize to the format string. */ emitir(IRTG(IR_EQ, IRT_STR), trfmt, lj_ir_kstr(J, fmt)); lj_strfmt_init(&fs, strdata(fmt), fmt->len); @@ -1082,6 +1083,7 @@ static void recff_format(jit_State *J, RecordFFData *rd, TRef hdr, int sbufx) recff_nyiu(J, rd); return; } + if (++nfmt > 100) lj_trace_err(J, LJ_TRERR_TRACEOV); } if (sbufx) { emitir(IRT(IR_USE, IRT_NIL), tr, 0); diff --git a/src/lj_jit.h b/src/lj_jit.h index 6902fba3..59f92e55 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h @@ -460,8 +460,8 @@ typedef struct jit_State { #endif IRIns *irbuf; /* Temp. IR instruction buffer. Biased with REF_BIAS. */ - IRRef irtoplim; /* Upper limit of instuction buffer (biased). */ - IRRef irbotlim; /* Lower limit of instuction buffer (biased). */ + IRRef irtoplim; /* Upper limit of instruction buffer (biased). */ + IRRef irbotlim; /* Lower limit of instruction buffer (biased). */ IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */ MSize sizesnap; /* Size of temp. snapshot buffer. */ diff --git a/src/lj_snap.c b/src/lj_snap.c index f3645e87..6fda08ba 100644 --- a/src/lj_snap.c +++ b/src/lj_snap.c @@ -801,7 +801,6 @@ static void snap_restoredata(jit_State *J, GCtrace *T, ExitState *ex, *(lua_Number *)dst = (lua_Number)*(int32_t *)dst; return; } - src = (int32_t *)&ex->gpr[r-RID_MIN_GPR]; #if !LJ_SOFTFP if (r >= RID_MAX_GPR) { src = (int32_t *)&ex->fpr[r-RID_MIN_FPR]; @@ -815,7 +814,10 @@ static void snap_restoredata(jit_State *J, GCtrace *T, ExitState *ex, #endif } else #endif - if (LJ_64 && LJ_BE && sz == 4) src++; + { + src = (int32_t *)&ex->gpr[r-RID_MIN_GPR]; + if (LJ_64 && LJ_BE && sz == 4) src++; + } } } lj_assertJ(sz == 1 || sz == 2 || sz == 4 || sz == 8, diff --git a/src/nxbuild.bat b/src/nxbuild.bat index 7f84b747..91513397 100644 --- a/src/nxbuild.bat +++ b/src/nxbuild.bat @@ -99,20 +99,21 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c @if errorlevel 1 goto :BAD @rem ---- Cross compiler ---- +@set NXCOMPILER_ROOT="%NINTENDO_SDK_ROOT%\Compilers\NintendoClang" @if "%platform%" neq "x64" goto :NX32_CROSSBUILD -@set LJCOMPILE="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\clang" -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c -@set LJLIB="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\aarch64-nintendo-nx-elf-ar" rc +@set LJCOMPILE="%NXCOMPILER_ROOT%\bin\clang" --target=aarch64-nintendo-nx-elf -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c +@set LJLIB="%NXCOMPILER_ROOT%\bin\llvm-ar" rc @set TARGETLIB_SUFFIX=nx64 -%NINTENDO_SDK_ROOT%\Compilers\NX\nx\aarch64\bin\aarch64-nintendo-nx-elf-as -o lj_vm.o lj_vm.s +%NXCOMPILER_ROOT%\bin\clang --target=aarch64-nintendo-nx-elf -o lj_vm.o -c lj_vm.s goto :DEBUGCHECK :NX32_CROSSBUILD -@set LJCOMPILE="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\clang" -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c -@set LJLIB="%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\armv7l-nintendo-nx-eabihf-ar" rc +@set LJCOMPILE="%NXCOMPILER_ROOT%\bin\clang" --target=armv7l-nintendo-nx-eabihf -Wall -I%NINTENDO_SDK_ROOT%\Include %DASMTARGET% -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC -c +@set LJLIB="%NXCOMPILER_ROOT%\bin\llvm-ar" rc @set TARGETLIB_SUFFIX=nx32 -%NINTENDO_SDK_ROOT%\Compilers\NX\nx\armv7l\bin\armv7l-nintendo-nx-eabihf-as -o lj_vm.o lj_vm.s +%NXCOMPILER_ROOT%\bin\clang --target=armv7l-nintendo-nx-eabihf -o lj_vm.o -c lj_vm.s :DEBUGCHECK @if "%1" neq "debug" goto :NODEBUG