Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #262 from anmolsahoo25/inline-loads-specialized
Browse files Browse the repository at this point in the history
Inline loads specialized
  • Loading branch information
kayceesrk committed Aug 2, 2019
2 parents 8fbacb1 + c1bb7bd commit 3498284
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion asmcomp/cmmgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,7 @@ and transl_prim_1 env p arg dbg =
let ptr = transl env arg
in
( match immediate_or_pointer with
| Immediate -> Cop (Cload {memory_chunk=Word_int ; mutability=Mutable ; is_atomic=true} , [ptr; Cconst_int 0], dbg)
| Immediate -> Cop (Cload {memory_chunk=Word_int ; mutability=Mutable ; is_atomic=true} , [ptr], dbg)
| Pointer -> Cop (Cloadmut {is_atomic=true}, [ptr; Cconst_int 0], dbg) )
| prim ->
fatal_errorf "Cmmgen.transl_prim_1: %a" Printlambda.primitive prim
Expand Down
5 changes: 5 additions & 0 deletions bytecomp/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@ let specialize_primitive p env ty ~has_constant_constructor =
| (Pmakeblock(tag, mut, None), fields) ->
let shape = List.map (Typeopt.value_kind env) fields in
Pmakeblock(tag, mut, Some shape)
| (Patomic_load { immediate_or_pointer = Pointer }, _) ->
let is_int = match is_function_type env ty with
| None -> Pointer
| Some (_p1, rhs) -> maybe_pointer_type env rhs in
Patomic_load {immediate_or_pointer = is_int}
| _ -> p

(* Eta-expand a primitive *)
Expand Down
11 changes: 6 additions & 5 deletions stdlib/atomic.mli
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
type 'a t

val make : 'a -> 'a t
val get : 'a t -> 'a
external make : 'a -> 'a t = "%makemutable"
external get : 'a t -> 'a = "%atomic_load"
external exchange : 'a t -> 'a -> 'a = "%atomic_exchange"
external compare_and_set : 'a t -> 'a -> 'a -> bool = "%atomic_cas"
external fetch_and_add : int t -> int -> int = "%atomic_fetch_add"

val set : 'a t -> 'a -> unit
val exchange : 'a t -> 'a -> 'a
val compare_and_set : 'a t -> 'a -> 'a -> bool
val fetch_and_add : int t -> int -> int
val incr : int t -> unit
val decr : int t -> unit

0 comments on commit 3498284

Please sign in to comment.