projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Export blockUserSignals and unblockUserSignals (needed for #2870)
[ghc-hetmet.git]
/
rts
/
Adjustor.c
diff --git
a/rts/Adjustor.c
b/rts/Adjustor.c
index
03fb5d9
..
e021487
100644
(file)
--- a/
rts/Adjustor.c
+++ b/
rts/Adjustor.c
@@
-42,9
+42,9
@@
Haskell side.
#include "RtsUtils.h"
#include <stdlib.h>
#include "RtsUtils.h"
#include <stdlib.h>
-#if defined(USE_LIBFFI)
+#if defined(USE_LIBFFI_FOR_ADJUSTORS)
-#include <ffi.h>
+#include "ffi.h"
#include <string.h>
void
#include <string.h>
void
@@
-73,6
+73,7
@@
static ffi_type * char_to_ffi_type(char c)
case 's': return &ffi_type_uint16;
case 'B': return &ffi_type_sint8;
case 'b': return &ffi_type_uint8;
case 's': return &ffi_type_uint16;
case 'B': return &ffi_type_sint8;
case 'b': return &ffi_type_uint8;
+ case 'p': return &ffi_type_pointer;
default: barf("char_to_ffi_type: unknown type '%c'", c);
}
}
default: barf("char_to_ffi_type: unknown type '%c'", c);
}
}
@@
-89,6
+90,7
@@
createAdjustor (int cconv,
ffi_type *result_type;
ffi_closure *cl;
int r, abi;
ffi_type *result_type;
ffi_closure *cl;
int r, abi;
+ void *code;
n_args = strlen(typeString) - 1;
cif = stgMallocBytes(sizeof(ffi_cif), "createAdjustor");
n_args = strlen(typeString) - 1;
cif = stgMallocBytes(sizeof(ffi_cif), "createAdjustor");
@@
-114,13
+116,15
@@
createAdjustor (int cconv,
r = ffi_prep_cif(cif, abi, n_args, result_type, arg_types);
if (r != FFI_OK) barf("ffi_prep_cif failed: %d", r);
r = ffi_prep_cif(cif, abi, n_args, result_type, arg_types);
if (r != FFI_OK) barf("ffi_prep_cif failed: %d", r);
- // ToDo: use ffi_closure_alloc()
- cl = allocateExec(sizeof(ffi_closure));
+ cl = allocateExec(sizeof(ffi_closure), &code);
+ if (cl == NULL) {
+ barf("createAdjustor: failed to allocate memory");
+ }
r = ffi_prep_closure(cl, cif, (void*)wptr, hptr/*userdata*/);
if (r != FFI_OK) barf("ffi_prep_closure failed: %d", r);
r = ffi_prep_closure(cl, cif, (void*)wptr, hptr/*userdata*/);
if (r != FFI_OK) barf("ffi_prep_closure failed: %d", r);
- return (void*)cl;
+ return (void*)code;
}
#else // To end of file...
}
#else // To end of file...
@@
-328,6
+332,7
@@
createAdjustor(int cconv, StgStablePtr hptr,
)
{
void *adjustor = NULL;
)
{
void *adjustor = NULL;
+ void *code;
switch (cconv)
{
switch (cconv)
{
@@
-345,7
+350,7
@@
createAdjustor(int cconv, StgStablePtr hptr,
<c>: ff e0 jmp %eax # and jump to it.
# the callee cleans up the stack
*/
<c>: ff e0 jmp %eax # and jump to it.
# the callee cleans up the stack
*/
- adjustor = allocateExec(14);
+ adjustor = allocateExec(14,&code);
{
unsigned char *const adj_code = (unsigned char *)adjustor;
adj_code[0x00] = (unsigned char)0x58; /* popl %eax */
{
unsigned char *const adj_code = (unsigned char *)adjustor;
adj_code[0x00] = (unsigned char)0x58; /* popl %eax */
@@
-390,7
+395,7
@@
createAdjustor(int cconv, StgStablePtr hptr,
That's (thankfully) the case here with the restricted set of
return types that we support.
*/
That's (thankfully) the case here with the restricted set of
return types that we support.
*/
- adjustor = allocateExec(17);
+ adjustor = allocateExec(17,&code);
{
unsigned char *const adj_code = (unsigned char *)adjustor;
{
unsigned char *const adj_code = (unsigned char *)adjustor;
@@
-415,7
+420,7
@@
createAdjustor(int cconv, StgStablePtr hptr,
We offload most of the work to AdjustorAsm.S.
*/
We offload most of the work to AdjustorAsm.S.
*/
- AdjustorStub *adjustorStub = allocateExec(sizeof(AdjustorStub));
+ AdjustorStub *adjustorStub = allocateExec(sizeof(AdjustorStub),&code);
adjustor = adjustorStub;
extern void adjustorCode(void);
adjustor = adjustorStub;
extern void adjustorCode(void);
@@
-513,7
+518,7
@@
createAdjustor(int cconv, StgStablePtr hptr,
}
if (i < 6) {
}
if (i < 6) {
- adjustor = allocateExec(0x30);
+ adjustor = allocateExec(0x30,&code);
*(StgInt32 *)adjustor = 0x49c1894d;
*(StgInt32 *)(adjustor+0x4) = 0x8948c889;
*(StgInt32 *)adjustor = 0x49c1894d;
*(StgInt32 *)(adjustor+0x4) = 0x8948c889;
@@
-527,7
+532,7
@@
createAdjustor(int cconv, StgStablePtr hptr,
}
else
{
}
else
{
- adjustor = allocateExec(0x40);
+ adjustor = allocateExec(0x40,&code);
*(StgInt32 *)adjustor = 0x35ff5141;
*(StgInt32 *)(adjustor+0x4) = 0x00000020;
*(StgInt32 *)adjustor = 0x35ff5141;
*(StgInt32 *)(adjustor+0x4) = 0x00000020;
@@
-574,7
+579,7
@@
createAdjustor(int cconv, StgStablePtr hptr,
similarly, and local variables should be accessed via %fp, not %sp. In a
nutshell: This should work! (Famous last words! :-)
*/
similarly, and local variables should be accessed via %fp, not %sp. In a
nutshell: This should work! (Famous last words! :-)
*/
- adjustor = allocateExec(4*(11+1));
+ adjustor = allocateExec(4*(11+1),&code);
{
unsigned long *const adj_code = (unsigned long *)adjustor;
{
unsigned long *const adj_code = (unsigned long *)adjustor;
@@
-651,7
+656,7
@@
TODO: Depending on how much allocation overhead stgMallocBytes uses for
4 bytes (getting rid of the nop), hence saving memory. [ccshan]
*/
ASSERT(((StgWord64)wptr & 3) == 0);
4 bytes (getting rid of the nop), hence saving memory. [ccshan]
*/
ASSERT(((StgWord64)wptr & 3) == 0);
- adjustor = allocateExec(48);
+ adjustor = allocateExec(48,&code);
{
StgWord64 *const code = (StgWord64 *)adjustor;
{
StgWord64 *const code = (StgWord64 *)adjustor;
@@
-715,7
+720,7
@@
TODO: Depending on how much allocation overhead stgMallocBytes uses for
}
else
{
}
else
{
- if((t == 'l' || t == 'L' || t == 'd')
+ if(t == 'l' || t == 'L' || t == 'd')
{
if(src_offset % 8)
src_offset += 4;
{
if(src_offset % 8)
src_offset += 4;
@@
-756,7
+761,7
@@
TODO: Depending on how much allocation overhead stgMallocBytes uses for
*/
// allocate space for at most 4 insns per parameter
// plus 14 more instructions.
*/
// allocate space for at most 4 insns per parameter
// plus 14 more instructions.
- adjustor = allocateExec(4 * (4*n + 14));
+ adjustor = allocateExec(4 * (4*n + 14),&code);
code = (unsigned*)adjustor;
*code++ = 0x48000008; // b *+8
code = (unsigned*)adjustor;
*code++ = 0x48000008; // b *+8
@@
-915,7
+920,7
@@
TODO: Depending on how much allocation overhead stgMallocBytes uses for
#ifdef FUNDESCS
adjustorStub = stgMallocBytes(sizeof(AdjustorStub), "createAdjustor");
#else
#ifdef FUNDESCS
adjustorStub = stgMallocBytes(sizeof(AdjustorStub), "createAdjustor");
#else
- adjustorStub = allocateExec(sizeof(AdjustorStub));
+ adjustorStub = allocateExec(sizeof(AdjustorStub),&code);
#endif
adjustor = adjustorStub;
#endif
adjustor = adjustorStub;
@@
-1088,7
+1093,7
@@
TODO: Depending on how much allocation overhead stgMallocBytes uses for
}
/* Have fun! */
}
/* Have fun! */
- return adjustor;
+ return code;
}
}
@@
-1166,9
+1171,10
@@
if ( *(unsigned char*)ptr != 0xe8 ) {
#else
ASSERT(0);
#endif
#else
ASSERT(0);
#endif
- *((unsigned char*)ptr) = '\0';
+ // Can't write to this memory, it is only executable:
+ // *((unsigned char*)ptr) = '\0';
freeExec(ptr);
}
freeExec(ptr);
}
-#endif // !USE_LIBFFI
+#endif // !USE_LIBFFI_FOR_ADJUSTORS