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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
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
jberryman
GHC
Commits
3ca7ecb5
Commit
3ca7ecb5
authored
Mar 29, 2012
by
rrnewton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add casArray# primop, similar to casMutVar# but for array elements
parent
82bbc386
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
0 deletions
+37
-0
compiler/prelude/primops.txt.pp
compiler/prelude/primops.txt.pp
+8
-0
includes/stg/MiscClosures.h
includes/stg/MiscClosures.h
+1
-0
rts/Linker.c
rts/Linker.c
+1
-0
rts/PrimOps.cmm
rts/PrimOps.cmm
+27
-0
No files found.
compiler/prelude/primops.txt.pp
View file @
3ca7ecb5
...
...
@@ -794,6 +794,14 @@ primop ThawArrayOp "thawArray#" GenPrimOp
has_side_effects = True
code_size = { primOpCodeSizeForeignCall + 4 }
primop CasArrayOp "casArray#" GenPrimOp
MutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
{Unsafe, machine-level atomic compare and swap on an element within an Array.}
with
out_of_line = True
has_side_effects = True
------------------------------------------------------------------------
section "Byte Arrays"
{Operations on {\tt ByteArray\#}. A {\tt ByteArray\#} is a just a region of
...
...
includes/stg/MiscClosures.h
View file @
3ca7ecb5
...
...
@@ -364,6 +364,7 @@ RTS_FUN_DECL(stg_word64ToIntegerzh);
#endif
RTS_FUN_DECL
(
stg_unsafeThawArrayzh
);
RTS_FUN_DECL
(
stg_casArrayzh
);
RTS_FUN_DECL
(
stg_newByteArrayzh
);
RTS_FUN_DECL
(
stg_newPinnedByteArrayzh
);
RTS_FUN_DECL
(
stg_newAlignedPinnedByteArrayzh
);
...
...
rts/Linker.c
View file @
3ca7ecb5
...
...
@@ -1144,6 +1144,7 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(stg_labelThreadzh) \
SymI_HasProto(stg_newArrayzh) \
SymI_HasProto(stg_newArrayArrayzh) \
SymI_HasProto(stg_casArrayzh) \
SymI_HasProto(stg_newBCOzh) \
SymI_HasProto(stg_newByteArrayzh) \
SymI_HasProto_redirect(newCAF, newDynCAF) \
...
...
rts/PrimOps.cmm
View file @
3ca7ecb5
...
...
@@ -206,6 +206,33 @@ stg_unsafeThawArrayzh ( gcptr arr )
}
}
stg_casArrayzh
/* MutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #) */
{
W_
arr
,
p
,
ind
,
old
,
new
,
h
,
len
;
arr
=
R1
;
// anything else?
ind
=
R2
;
old
=
R3
;
new
=
R4
;
p
=
arr
+
SIZEOF_StgMutArrPtrs
+
WDS
(
ind
);
(
h
)
=
foreign
"
C
"
cas
(
p
,
old
,
new
)
[];
if
(
h
!=
old
)
{
// Failure, return what was there instead of 'old':
RET_NP
(
1
,
h
);
}
else
{
// Compare and Swap Succeeded:
if
(
GET_INFO
(
arr
)
==
stg_MUT_ARR_PTRS_CLEAN_info
)
{
SET_HDR
(
arr
,
stg_MUT_ARR_PTRS_DIRTY_info
,
CCCS
);
len
=
StgMutArrPtrs_ptrs
(
arr
);
// The write barrier. We must write a byte into the mark table:
I8
[
arr
+
SIZEOF_StgMutArrPtrs
+
WDS
(
len
)
+
(
ind
>>
MUT_ARR_PTRS_CARD_BITS
)]
=
1
;
}
RET_NP
(
0
,
h
);
}
}
stg_newArrayArrayzh
(
W_
n
/* words */
)
{
W_
words
,
size
;
...
...
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