Documentation

Miri.Concurrency.AtomicDispatch

Clock and store-buffer dispatch for atomic accesses #

This module composes the source-backed vector-clock and weak-memory state operations at the same callback boundaries as Miri's validate_atomic_op/buffered_atomic_* hooks. It does not implement MPlaceTy, pointer validation, scalar memory, scalar RMW operators, UB diagnostics, or the interpreter's allow_data_races_* callbacks. Those remain caller obligations. In particular, buffered writes and RMWs are post-memory- write hooks; their arguments are the values already produced/written by the interpreter. Atomic loads receive the already-read latest-in-modification-order value used by Miri's fallback path.

The global state stores an optional per-allocation weak-memory map because Miri attaches StoreBufferAlloc only when that backend is active. SC read metadata is updated before lookup/choice, SC store metadata after validation, and SC RMW read/write metadata after validation. Per-byte validation retains partial cell/clock changes on an error and stops at the first failing byte.

Full state slice needed by the pinned atomic clock/store-buffer hooks. The caller owns interpreter memory and scheduler transitions. none means this allocation has no weak-memory AllocExtra payload.

Instances For

    Explicit failures at the atomic clock/store-buffer boundary.

    Instances For
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        structure Miri.Concurrency.AtomicTransition (Value Result : Type) :

        State is returned alongside every success or failure, including an error after DedupRangeMap/per-byte clock mutation.

        Instances For

          A source outdated-load diagnostic request. Rendering the pointer/span and emitting Miri's non-halting diagnostic remain interpreter callbacks.

          Instances For
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Value returned by the source buffered-load hook. choice = none denotes the latest-memory fallback; a buffered none value still represents an uninitialized selected store and is deliberately not coerced to a value.

              Instances For

                Convert the same allocation interval between Miri's AllocRange and the data-race module's byte-count view.

                Equations
                Instances For

                  Run one source validate_atomic_op body. Its operation closure is applied to each byte in increasing offset order by VClockAlloc.runRange; successful operations conservatively increment once through GlobalState.maybePerformSyncOperation. Race/error paths preserve the failed cell and all earlier byte updates, but do not increment the outer clock.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    A cut at the actual source RNG operation. SC metadata, buffer lookup and active-clock errors precede the cut; fallback reads never request a draw.

                    Instances For
                      def Miri.Concurrency.prepareBufferedAtomicRead {Value : Type} (state : AtomicState Value) (threads : ThreadManager) (range : Memory.AllocRange) (ordering : AtomicReadOrd) (latestInMemory : Value) :
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def Miri.Concurrency.finishBufferedAtomicRead {Value : Type} (working : AtomicState Value) (threads : ThreadManager) (range : Memory.AllocRange) (ordering : AtomicReadOrd) (handle : StoreBufferHandle Value) (clocks : ThreadClockSet) (choiceRank : Nat) :

                        Continue the same source operation after selecting a supported store. Callers commit prepare's state before requesting an effectful choice.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def Miri.Concurrency.bufferedAtomicRead {Value : Type} (state : AtomicState Value) (threads : ThreadManager) (range : Memory.AllocRange) (ordering : AtomicReadOrd) (latestInMemory : Value) (choiceRank : Nat) :

                          Deterministic explicit-rank API retained as composition of the exact source prefix and continuation. No choice is used on a fallback path.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Port weak_memory.rs::perform_read_on_buffered_latest, used only after a failed compare-exchange. Unlike ordinary buffered loads it never selects an older store and does not run a second atomic validation. The source SC-read mark occurs before the buffer lookup and therefore remains on a missing-buffer fallback.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              The failed compare-exchange path: source validates an atomic load with no selected-store override, then records a load from the latest retained buffer element.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def Miri.Concurrency.bufferedAtomicWrite {Value : Type} (state : AtomicState Value) (threads : ThreadManager) (range : Memory.AllocRange) (ordering : AtomicWriteOrd) (value : Value) (initial : Option Value) :

                                The buffered_atomic_write hook. Callers must have completed Miri's atomic_access_check, vanilla memory write, and successful validate_atomic_store before invoking it. The source SC-write mark occurs before range sync-clock collection and buffer creation.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  def Miri.Concurrency.bufferedAtomicRmw {Value : Type} (state : AtomicState Value) (threads : ThreadManager) (range : Memory.AllocRange) (ordering : AtomicRwOrd) (oldValue newValue : Value) :

                                  The buffered_atomic_rmw hook. Callers supply the already-read old value and already-computed/written new value after a successful validate_atomic_rmw. The hook marks both SC edges, reads metadata from the latest buffered store, then appends the new store using the updated allocation sync clock.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    def Miri.Concurrency.atomicStoreState {Value : Type} (state : AtomicState Value) (threads : ThreadManager) (range : Memory.AllocRange) (ordering : AtomicWriteOrd) (value : Value) (initial : Option Value) :

                                    Compose Miri's validate_atomic_store then buffered_atomic_write state hooks. The interpreter must already have performed its normal memory write; this function does not create or mutate the scalar memory allocation.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      def Miri.Concurrency.atomicRmwState {Value : Type} (state : AtomicState Value) (threads : ThreadManager) (range : Memory.AllocRange) (ordering : AtomicRwOrd) (oldValue newValue : Value) :

                                      Compose Miri's validate_atomic_rmw then buffered_atomic_rmw state hooks. Actual memory read, RMW scalar computation, and write remain caller operations performed before this post-write state transition.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For