aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile7
-rw-r--r--src/lj_arch.h2
-rw-r--r--src/lj_err.c4
-rw-r--r--src/lj_frame.h4
-rw-r--r--src/ps4build.bat4
-rw-r--r--src/vm_x86.dasc24
6 files changed, 37 insertions, 8 deletions
diff --git a/src/Makefile b/src/Makefile
index 1d38fa25..5021e479 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -243,9 +243,6 @@ ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
243 TARGET_ARCH+= -D__CELLOS_LV2__ 243 TARGET_ARCH+= -D__CELLOS_LV2__
244 TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC 244 TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
245endif 245endif
246ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
247 TARGET_ARCH+= -DLUAJIT_NO_UNWIND
248endif
249 246
250TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH)) 247TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
251TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH)) 248TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
@@ -397,6 +394,10 @@ ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH)))
397else 394else
398 TARGET_ARCH+= -DLJ_ABI_SOFTFP=1 395 TARGET_ARCH+= -DLJ_ABI_SOFTFP=1
399endif 396endif
397ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
398 DASM_AFLAGS+= -D NO_UNWIND
399 TARGET_ARCH+= -DLUAJIT_NO_UNWIND
400endif
400DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH)))) 401DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH))))
401ifeq (Windows,$(TARGET_SYS)) 402ifeq (Windows,$(TARGET_SYS))
402 DASM_AFLAGS+= -D WIN 403 DASM_AFLAGS+= -D WIN
diff --git a/src/lj_arch.h b/src/lj_arch.h
index d3a9d57d..d89d1169 100644
--- a/src/lj_arch.h
+++ b/src/lj_arch.h
@@ -423,7 +423,7 @@
423#define LUAJIT_NO_EXP2 423#define LUAJIT_NO_EXP2
424#endif 424#endif
425 425
426#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 426#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4
427#define LJ_NO_UNWIND 1 427#define LJ_NO_UNWIND 1
428#endif 428#endif
429 429
diff --git a/src/lj_err.c b/src/lj_err.c
index 081bfde4..11b07b56 100644
--- a/src/lj_err.c
+++ b/src/lj_err.c
@@ -57,10 +57,10 @@
57** EXT cannot be enabled on WIN32 since system exceptions use code-driven SEH. 57** EXT cannot be enabled on WIN32 since system exceptions use code-driven SEH.
58** EXT is mandatory on WIN64 since the calling convention has an abundance 58** EXT is mandatory on WIN64 since the calling convention has an abundance
59** of callee-saved registers (rbx, rbp, rsi, rdi, r12-r15, xmm6-xmm15). 59** of callee-saved registers (rbx, rbp, rsi, rdi, r12-r15, xmm6-xmm15).
60** EXT is mandatory on POSIX/x64 since the interpreter doesn't save r12/r13. 60** The POSIX/x64 interpreter only saves r12/r13 for INT (e.g. PS4).
61*/ 61*/
62 62
63#if defined(__GNUC__) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)) 63#if defined(__GNUC__) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)) && !LJ_NO_UNWIND
64#define LJ_UNWIND_EXT 1 64#define LJ_UNWIND_EXT 1
65#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS 65#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS
66#define LJ_UNWIND_EXT 1 66#define LJ_UNWIND_EXT 1
diff --git a/src/lj_frame.h b/src/lj_frame.h
index cd57be22..f9810984 100644
--- a/src/lj_frame.h
+++ b/src/lj_frame.h
@@ -86,7 +86,11 @@ enum {
86#define CFRAME_OFS_ERRF (5*4) 86#define CFRAME_OFS_ERRF (5*4)
87#define CFRAME_OFS_NRES (4*4) 87#define CFRAME_OFS_NRES (4*4)
88#define CFRAME_OFS_MULTRES (1*4) 88#define CFRAME_OFS_MULTRES (1*4)
89#if LJ_NO_UNWIND
90#define CFRAME_SIZE (12*8)
91#else
89#define CFRAME_SIZE (10*8) 92#define CFRAME_SIZE (10*8)
93#endif
90#define CFRAME_SIZE_JIT (CFRAME_SIZE + 16) 94#define CFRAME_SIZE_JIT (CFRAME_SIZE + 16)
91#define CFRAME_SHIFT_MULTRES 0 95#define CFRAME_SHIFT_MULTRES 0
92#endif 96#endif
diff --git a/src/ps4build.bat b/src/ps4build.bat
index 42fc9a64..337a44fa 100644
--- a/src/ps4build.bat
+++ b/src/ps4build.bat
@@ -27,11 +27,11 @@ if exist minilua.exe.manifest^
27@minilua 27@minilua
28@if not errorlevel 8 goto :FAIL 28@if not errorlevel 8 goto :FAIL
29 29
30@set DASMFLAGS=-D P64 30@set DASMFLAGS=-D P64 -D NO_UNWIND
31minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc 31minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc
32@if errorlevel 1 goto :BAD 32@if errorlevel 1 goto :BAD
33 33
34%LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI host\buildvm*.c 34%LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_NO_UNWIND host\buildvm*.c
35@if errorlevel 1 goto :BAD 35@if errorlevel 1 goto :BAD
36%LJLINK% /out:buildvm.exe buildvm*.obj 36%LJLINK% /out:buildvm.exe buildvm*.obj
37@if errorlevel 1 goto :BAD 37@if errorlevel 1 goto :BAD
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
index 6cdb8cbd..129ab000 100644
--- a/src/vm_x86.dasc
+++ b/src/vm_x86.dasc
@@ -222,6 +222,9 @@
222|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). 222|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--).
223|.macro saveregs_ 223|.macro saveregs_
224| push rbx; push r15; push r14 224| push rbx; push r15; push r14
225|.if NO_UNWIND
226| push r13; push r12
227|.endif
225| sub rsp, CFRAME_SPACE 228| sub rsp, CFRAME_SPACE
226|.endmacro 229|.endmacro
227|.macro saveregs 230|.macro saveregs
@@ -229,15 +232,28 @@
229|.endmacro 232|.endmacro
230|.macro restoreregs 233|.macro restoreregs
231| add rsp, CFRAME_SPACE 234| add rsp, CFRAME_SPACE
235|.if NO_UNWIND
236| pop r12; pop r13
237|.endif
232| pop r14; pop r15; pop rbx; pop rbp 238| pop r14; pop r15; pop rbx; pop rbp
233|.endmacro 239|.endmacro
234| 240|
235|//----- 16 byte aligned, 241|//----- 16 byte aligned,
242|.if NO_UNWIND
243|.define SAVE_RET, aword [rsp+aword*11] //<-- rsp entering interpreter.
244|.define SAVE_R4, aword [rsp+aword*10]
245|.define SAVE_R3, aword [rsp+aword*9]
246|.define SAVE_R2, aword [rsp+aword*8]
247|.define SAVE_R1, aword [rsp+aword*7]
248|.define SAVE_RU2, aword [rsp+aword*6]
249|.define SAVE_RU1, aword [rsp+aword*5] //<-- rsp after register saves.
250|.else
236|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. 251|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter.
237|.define SAVE_R4, aword [rsp+aword*8] 252|.define SAVE_R4, aword [rsp+aword*8]
238|.define SAVE_R3, aword [rsp+aword*7] 253|.define SAVE_R3, aword [rsp+aword*7]
239|.define SAVE_R2, aword [rsp+aword*6] 254|.define SAVE_R2, aword [rsp+aword*6]
240|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. 255|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves.
256|.endif
241|.define SAVE_CFRAME, aword [rsp+aword*4] 257|.define SAVE_CFRAME, aword [rsp+aword*4]
242|.define SAVE_PC, dword [rsp+dword*7] 258|.define SAVE_PC, dword [rsp+dword*7]
243|.define SAVE_L, dword [rsp+dword*6] 259|.define SAVE_L, dword [rsp+dword*6]
@@ -6119,6 +6135,10 @@ static void emit_asm_debug(BuildCtx *ctx)
6119 "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ 6135 "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */
6120 "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ 6136 "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */
6121 "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ 6137 "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */
6138#if LJ_NO_UNWIND
6139 "\t.byte 0x8d\n\t.uleb128 0x6\n" /* offset r13 */
6140 "\t.byte 0x8c\n\t.uleb128 0x7\n" /* offset r12 */
6141#endif
6122#else 6142#else
6123 "\t.long .Lbegin\n" 6143 "\t.long .Lbegin\n"
6124 "\t.long %d\n" 6144 "\t.long %d\n"
@@ -6154,6 +6174,7 @@ static void emit_asm_debug(BuildCtx *ctx)
6154 "\t.align " SZPTR "\n" 6174 "\t.align " SZPTR "\n"
6155 ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); 6175 ".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
6156#endif 6176#endif
6177#if !LJ_NO_UNWIND
6157#if (defined(__sun__) && defined(__svr4__)) 6178#if (defined(__sun__) && defined(__svr4__))
6158#if LJ_64 6179#if LJ_64
6159 fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); 6180 fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n");
@@ -6242,7 +6263,9 @@ static void emit_asm_debug(BuildCtx *ctx)
6242 "\t.align " SZPTR "\n" 6263 "\t.align " SZPTR "\n"
6243 ".LEFDE3:\n\n", (int)ctx->codesz - fcofs); 6264 ".LEFDE3:\n\n", (int)ctx->codesz - fcofs);
6244#endif 6265#endif
6266#endif
6245 break; 6267 break;
6268#if !LJ_NO_UNWIND
6246 /* Mental note: never let Apple design an assembler. 6269 /* Mental note: never let Apple design an assembler.
6247 ** Or a linker. Or a plastic case. But I digress. 6270 ** Or a linker. Or a plastic case. But I digress.
6248 */ 6271 */
@@ -6370,6 +6393,7 @@ static void emit_asm_debug(BuildCtx *ctx)
6370#endif 6393#endif
6371 } 6394 }
6372 break; 6395 break;
6396#endif
6373 default: /* Difficult for other modes. */ 6397 default: /* Difficult for other modes. */
6374 break; 6398 break;
6375 } 6399 }