Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/sljit/dist/sljit_src Apply adapted patch fr...



details:   https://anonhg.NetBSD.org/src/rev/d112ba0379b2
branches:  trunk
changeset: 782737:d112ba0379b2
user:      alnsn <alnsn%NetBSD.org@localhost>
date:      Sun Nov 18 14:36:37 2012 +0000

description:
Apply adapted patch from the author of sljit to fix cdecl functions
generation on i386.

diffstat:

 sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h   |   3 +-
 sys/external/bsd/sljit/dist/sljit_src/sljitLir.c              |   3 +
 sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c     |  50 +++++++---
 sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c |   3 -
 4 files changed, 41 insertions(+), 18 deletions(-)

diffs (140 lines):

diff -r 3bb588039598 -r d112ba0379b2 sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h
--- a/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h       Sun Nov 18 08:24:02 2012 +0000
+++ b/sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h       Sun Nov 18 14:36:37 2012 +0000
@@ -308,7 +308,8 @@
 #define SLJIT_X86_32_FASTCALL 1
 
 #else /* defined(_WIN32) */
-#define SLJIT_CALL __stdcall
+/* The cdecl attribute is the default. */
+#define SLJIT_CALL
 #endif
 
 #else /* Other architectures. */
diff -r 3bb588039598 -r d112ba0379b2 sys/external/bsd/sljit/dist/sljit_src/sljitLir.c
--- a/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c  Sun Nov 18 08:24:02 2012 +0000
+++ b/sys/external/bsd/sljit/dist/sljit_src/sljitLir.c  Sun Nov 18 14:36:37 2012 +0000
@@ -190,6 +190,9 @@
 
 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
 #define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1
+#if !(defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
+#define FIXED_LOCALS_OFFSET (3 * sizeof(sljit_w))
+#endif
 #endif
 
 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
diff -r 3bb588039598 -r d112ba0379b2 sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c
--- a/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c Sun Nov 18 08:24:02 2012 +0000
+++ b/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c Sun Nov 18 14:36:37 2012 +0000
@@ -136,7 +136,11 @@
        }
 #endif
 
+#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
        locals_offset = 2 * sizeof(sljit_uw);
+#else
+       locals_offset = 2 * sizeof(sljit_uw) + FIXED_LOCALS_OFFSET;
+#endif
        compiler->temporaries_start = locals_offset;
        if (temporaries > 3)
                locals_offset += (temporaries - 3) * sizeof(sljit_uw);
@@ -146,19 +150,24 @@
        compiler->locals_offset = locals_offset;
        local_size = locals_offset + ((local_size + sizeof(sljit_uw) - 1) & ~(sizeof(sljit_uw) - 1));
 
+       compiler->local_size = local_size;
 #ifdef _WIN32
        if (local_size > 1024) {
+#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
                FAIL_IF(emit_do_imm(compiler, 0xb8 + reg_map[SLJIT_TEMPORARY_REG1], local_size));
+#else
+               local_size -= FIXED_LOCALS_OFFSET;
+               FAIL_IF(emit_do_imm(compiler, 0xb8 + reg_map[SLJIT_TEMPORARY_REG1], local_size));
+               FAIL_IF(emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
+                       SLJIT_LOCALS_REG, 0, SLJIT_LOCALS_REG, 0, SLJIT_IMM, FIXED_LOCALS_OFFSET));
+#endif
                FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_grow_stack)));
        }
 #endif
 
-       compiler->local_size = local_size;
        SLJIT_ASSERT(local_size > 0);
        return emit_non_cum_binary(compiler, 0x2b, 0x29, 0x5 << 3, 0x2d,
                SLJIT_LOCALS_REG, 0, SLJIT_LOCALS_REG, 0, SLJIT_IMM, local_size);
-
-       return SLJIT_SUCCESS;
 }
 
 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
@@ -175,7 +184,11 @@
        compiler->logical_local_size = local_size;
 #endif
 
+#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
        locals_offset = 2 * sizeof(sljit_uw);
+#else
+       locals_offset = 2 * sizeof(sljit_uw) + FIXED_LOCALS_OFFSET;
+#endif
        compiler->temporaries_start = locals_offset;
        if (temporaries > 3)
                locals_offset += (temporaries - 3) * sizeof(sljit_uw);
@@ -228,10 +241,7 @@
        else
                RET();
 #else
-       if (compiler->args > 0)
-               RETN(compiler->args * sizeof(sljit_w));
-       else
-               RET();
+       RET();
 #endif
 
        return SLJIT_SUCCESS;
@@ -433,14 +443,26 @@
        *buf++ = 0x8b;
        *buf++ = 0xc0 | (reg_map[SLJIT_TEMPORARY_REG3] << 3) | reg_map[SLJIT_TEMPORARY_REG1];
 #else
-       buf = (sljit_ub*)ensure_buf(compiler, type - SLJIT_CALL0 + 1);
+       buf = (sljit_ub*)ensure_buf(compiler, 1 + 4 * (type - SLJIT_CALL0));
        FAIL_IF(!buf);
-       INC_SIZE(type - SLJIT_CALL0);
-       if (type >= SLJIT_CALL3)
-               PUSH_REG(reg_map[SLJIT_TEMPORARY_REG3]);
-       if (type >= SLJIT_CALL2)
-               PUSH_REG(reg_map[SLJIT_TEMPORARY_REG2]);
-       PUSH_REG(reg_map[SLJIT_TEMPORARY_REG1]);
+       INC_SIZE(4 * (type - SLJIT_CALL0));
+
+       *buf++ = 0x89;
+       *buf++ = 0x40 | (reg_map[SLJIT_TEMPORARY_REG1] << 3) | 0x4 /* SIB */;
+       *buf++ = (0x4 /* none*/ << 3) | reg_map[SLJIT_LOCALS_REG];
+       *buf++ = 0;
+       if (type >= SLJIT_CALL2) {
+               *buf++ = 0x89;
+               *buf++ = 0x40 | (reg_map[SLJIT_TEMPORARY_REG2] << 3) | 0x4 /* SIB */;
+               *buf++ = (0x4 /* none*/ << 3) | reg_map[SLJIT_LOCALS_REG];
+               *buf++ = sizeof(sljit_w);
+       }
+       if (type >= SLJIT_CALL3) {
+               *buf++ = 0x89;
+               *buf++ = 0x40 | (reg_map[SLJIT_TEMPORARY_REG3] << 3) | 0x4 /* SIB */;
+               *buf++ = (0x4 /* none*/ << 3) | reg_map[SLJIT_LOCALS_REG];
+               *buf++ = 2 * sizeof(sljit_w);
+       }
 #endif
        return SLJIT_SUCCESS;
 }
diff -r 3bb588039598 -r d112ba0379b2 sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c
--- a/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c     Sun Nov 18 08:24:02 2012 +0000
+++ b/sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c     Sun Nov 18 14:36:37 2012 +0000
@@ -2353,9 +2353,6 @@
                }
                if (src == SLJIT_MEM1(SLJIT_LOCALS_REG) && type >= SLJIT_CALL3)
                        srcw += sizeof(sljit_w);
-#else
-               if (src == SLJIT_MEM1(SLJIT_LOCALS_REG))
-                       srcw += sizeof(sljit_w) * (type - SLJIT_CALL0);
 #endif
 #endif
 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && defined(_WIN64)



Home | Main Index | Thread Index | Old Index