1 This is already upstream in libffi, but not yet in Mozilla. |
|
2 |
|
3 --- mozilla-esr31/js/src/ctypes/libffi/src/sparc/ffi.c.orig 2015-06-04 17:42:52.335127713 -0700 |
|
4 +++ mozilla-esr31/js/src/ctypes/libffi/src/sparc/ffi.c 2015-06-04 17:42:52.343504239 -0700 |
|
5 @@ -406,8 +406,50 @@ |
|
6 /* We don't yet support calling 32bit code from 64bit */ |
|
7 FFI_ASSERT(0); |
|
8 #else |
|
9 - ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes, |
|
10 - cif->flags, rvalue, fn); |
|
11 + if (rvalue && (cif->rtype->type == FFI_TYPE_STRUCT |
|
12 +#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE |
|
13 + || cif->flags == FFI_TYPE_LONGDOUBLE |
|
14 +#endif |
|
15 + )) |
|
16 + { |
|
17 + /* For v8, we need an "unimp" with size of returning struct */ |
|
18 + /* behind "call", so we alloc some executable space for it. */ |
|
19 + /* l7 is used, we need to make sure v8.S doesn't use %l7. */ |
|
20 + unsigned int *call_struct = NULL; |
|
21 + ffi_closure_alloc(32, &call_struct); |
|
22 + if (call_struct) |
|
23 + { |
|
24 + unsigned long f = (unsigned long)fn; |
|
25 + call_struct[0] = 0xae10001f; /* mov %i7, %l7 */ |
|
26 + call_struct[1] = 0xbe10000f; /* mov %o7, %i7 */ |
|
27 + call_struct[2] = 0x03000000 | f >> 10; /* sethi %hi(fn), %g1 */ |
|
28 + call_struct[3] = 0x9fc06000 | (f & 0x3ff); /* jmp %g1+%lo(fn), %o7 */ |
|
29 + call_struct[4] = 0x01000000; /* nop */ |
|
30 + if (cif->rtype->size < 0x7f) |
|
31 + call_struct[5] = cif->rtype->size; /* unimp */ |
|
32 + else |
|
33 + call_struct[5] = 0x01000000; /* nop */ |
|
34 + call_struct[6] = 0x81c7e008; /* ret */ |
|
35 + call_struct[7] = 0xbe100017; /* mov %l7, %i7 */ |
|
36 + asm volatile ("iflush %0; iflush %0+8; iflush %0+16; iflush %0+24" : : |
|
37 + "r" (call_struct) : "memory"); |
|
38 + /* SPARC v8 requires 5 instructions for flush to be visible */ |
|
39 + asm volatile ("nop; nop; nop; nop; nop"); |
|
40 + ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes, |
|
41 + cif->flags, rvalue, call_struct); |
|
42 + ffi_closure_free(call_struct); |
|
43 + } |
|
44 + else |
|
45 + { |
|
46 + ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes, |
|
47 + cif->flags, rvalue, fn); |
|
48 + } |
|
49 + } |
|
50 + else |
|
51 + { |
|
52 + ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes, |
|
53 + cif->flags, rvalue, fn); |
|
54 + } |
|
55 #endif |
|
56 break; |
|
57 case FFI_V9: |
|
58 @@ -468,13 +510,13 @@ |
|
59 closure->fun = fun; |
|
60 closure->user_data = user_data; |
|
61 |
|
62 - /* Flush the Icache. FIXME: alignment isn't certain, assume 8 bytes */ |
|
63 + /* Flush the Icache. closure is 8 bytes aligned */ |
|
64 #ifdef SPARC64 |
|
65 - asm volatile ("flush %0" : : "r" (closure) : "memory"); |
|
66 - asm volatile ("flush %0" : : "r" (((char *) closure) + 8) : "memory"); |
|
67 + asm volatile ("flush %0; flush %0+8" : : "r" (closure) : "memory"); |
|
68 #else |
|
69 - asm volatile ("iflush %0" : : "r" (closure) : "memory"); |
|
70 - asm volatile ("iflush %0" : : "r" (((char *) closure) + 8) : "memory"); |
|
71 + asm volatile ("iflush %0; iflush %0+8" : : "r" (closure) : "memory"); |
|
72 + /* SPARC v8 requires 5 instructions for flush to be visible */ |
|
73 + asm volatile ("nop; nop; nop; nop; nop"); |
|
74 #endif |
|
75 |
|
76 return FFI_OK; |
|
77 --- mozilla-esr31/js/src/ctypes/libffi/configure.orig 2015-06-04 17:42:52.338127066 -0700 |
|
78 +++ mozilla-esr31/js/src/ctypes/libffi/configure 2015-06-04 17:42:52.344846571 -0700 |
|
79 @@ -12425,7 +12425,7 @@ |
|
80 |
|
81 case "$target" in |
|
82 # Darwin 10 (OSX 10.6) and beyond allocate non-executable pages |
|
83 - *-apple-darwin1* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*) |
|
84 + *-apple-darwin1* | *-*-freebsd* | *-*-openbsd* | *-*-solaris*) |
|
85 |
|
86 $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h |
|
87 |
|