Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,253
Issues
4,253
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
397
Merge Requests
397
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
972c044d
Commit
972c044d
authored
Jun 08, 2013
by
ian@well-typed.com
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use libffi for iOS adjustors; fixes
#7718
Based on a patch from Stephen Blackheath.
parent
0d860381
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
6 deletions
+59
-6
includes/rts/storage/GC.h
includes/rts/storage/GC.h
+5
-2
rts/sm/Storage.c
rts/sm/Storage.c
+54
-4
No files found.
includes/rts/storage/GC.h
View file @
972c044d
...
...
@@ -154,8 +154,11 @@ StgPtr allocate ( Capability *cap, W_ n );
StgPtr
allocatePinned
(
Capability
*
cap
,
W_
n
);
/* memory allocator for executable memory */
void
*
allocateExec
(
W_
len
,
void
**
exec_addr
);
void
freeExec
(
void
*
p
);
typedef
void
*
AdjustorWritable
;
typedef
void
*
AdjustorExecutable
;
AdjustorWritable
allocateExec
(
W_
len
,
AdjustorExecutable
*
exec_addr
);
void
freeExec
(
AdjustorExecutable
p
);
// Used by GC checks in external .cmm code:
extern
W_
large_alloc_lim
;
...
...
rts/sm/Storage.c
View file @
972c044d
...
...
@@ -29,6 +29,9 @@
#include "Trace.h"
#include "GC.h"
#include "Evac.h"
#if defined(ios_HOST_OS)
#include "Hash.h"
#endif
#include <string.h>
...
...
@@ -1094,7 +1097,7 @@ calcNeeded (rtsBool force_major, memcount *blocks_needed)
// because it knows how to work around the restrictions put in place
// by SELinux.
void
*
allocateExec
(
W_
bytes
,
void
*
*
exec_ret
)
AdjustorWritable
allocateExec
(
W_
bytes
,
AdjustorExecutable
*
exec_ret
)
{
void
**
ret
,
**
exec
;
ACQUIRE_SM_LOCK
;
...
...
@@ -1107,18 +1110,65 @@ void *allocateExec (W_ bytes, void **exec_ret)
}
// freeExec gets passed the executable address, not the writable address.
void
freeExec
(
void
*
addr
)
void
freeExec
(
AdjustorExecutable
addr
)
{
void
*
writable
;
AdjustorWritable
writable
;
writable
=
*
((
void
**
)
addr
-
1
);
ACQUIRE_SM_LOCK
;
ffi_closure_free
(
writable
);
RELEASE_SM_LOCK
}
#elif defined(ios_HOST_OS)
static
HashTable
*
allocatedExecs
;
AdjustorWritable
allocateExec
(
W_
bytes
,
AdjustorExecutable
*
exec_ret
)
{
AdjustorWritable
writ
;
ffi_closure
*
cl
;
if
(
bytes
!=
sizeof
(
ffi_closure
))
{
barf
(
"allocateExec: for ffi_closure only"
);
}
ACQUIRE_SM_LOCK
;
cl
=
writ
=
ffi_closure_alloc
((
size_t
)
bytes
,
exec_ret
);
if
(
cl
!=
NULL
)
{
if
(
allocatedExecs
==
NULL
)
{
allocatedExecs
=
allocHashTable
();
}
insertHashTable
(
allocatedExecs
,
(
StgWord
)
*
exec_ret
,
writ
);
}
RELEASE_SM_LOCK
;
return
writ
;
}
AdjustorWritable
execToWritable
(
AdjustorExecutable
exec
)
{
AdjustorWritable
writ
;
ACQUIRE_SM_LOCK
;
if
(
allocatedExecs
==
NULL
||
(
writ
=
lookupHashTable
(
allocatedExecs
,
(
StgWord
)
exec
))
==
NULL
)
{
RELEASE_SM_LOCK
;
barf
(
"execToWritable: not found"
);
}
RELEASE_SM_LOCK
;
return
writ
;
}
void
freeExec
(
AdjustorExecutable
exec
)
{
AdjustorWritable
writ
;
ffi_closure
*
cl
;
cl
=
writ
=
execToWritable
(
exec
);
ACQUIRE_SM_LOCK
;
removeHashTable
(
allocatedExecs
,
(
StgWord
)
exec
,
writ
);
ffi_closure_free
(
cl
);
RELEASE_SM_LOCK
}
#else
void
*
allocateExec
(
W_
bytes
,
void
*
*
exec_ret
)
AdjustorWritable
allocateExec
(
W_
bytes
,
AdjustorExecutable
*
exec_ret
)
{
void
*
ret
;
W_
n
;
...
...
Moritz Angermann
@angerman
mentioned in merge request
!3641
·
Oct 07, 2020
mentioned in merge request
!3641
mentioned in merge request !3641
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment