Skip to content
Snippets Groups Projects
Commit de86652f authored by Ralf Jung's avatar Ralf Jung
Browse files

allow comparing more things in CAS

See the comments in the code for why that makes sense
parent 6b0f3bfb
No related branches found
No related tags found
No related merge requests found
...@@ -370,13 +370,16 @@ Definition bin_op_eval (op : bin_op) (v1 v2 : val) : option val := ...@@ -370,13 +370,16 @@ Definition bin_op_eval (op : bin_op) (v1 v2 : val) : option val :=
(** Return whether it is possible to use CAS to compare vl (current value) with v1 (netest value). *) (** Return whether it is possible to use CAS to compare vl (current value) with v1 (netest value). *)
Definition vals_cas_compare_safe (vl v1 : val) : Prop := Definition vals_cas_compare_safe (vl v1 : val) : Prop :=
match vl, v1 with match vl, v1 with
(* We allow comparing literals with each other. *)
| LitV _, LitV _ => True | LitV _, LitV _ => True
(* We want to support CAS'ing [NONEV] to [SOMEV #l]. An implementation of (* We assume that [NONEV] is represented as a NULL-pointer and [SOMEV x] as a
this is possible if literals have an invalid bit pattern that can be used to pointer to a location (never written to after allocation) storing [x]. Then
represent NONE. *) comparing [NONEV] with [NONEV] or [SOMEV x] is possible atomically by testing
for NULL. Comparing [SOMEV x] with [SOMEV y] is not possible though. *)
| NONEV, NONEV => True | NONEV, NONEV => True
| NONEV, SOMEV (LitV _) => True | NONEV, SOMEV _ => True
| SOMEV (LitV _), NONEV => True | SOMEV _, NONEV => True
(* We don't allow comparing anything else. *)
| _, _ => False | _, _ => False
end. end.
(** Just a sanity check. *) (** Just a sanity check. *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment