]> Cypherpunks.ru repositories - gostls13.git/blobdiff - doc/go_mem.html
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / doc / go_mem.html
index 9bcf06707aa3c2bb6d9902da3a1140c779382902..026c1172e3a4c0ea9fa8f147202471f083b2cae8 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Memory Model",
-       "Subtitle": "Version of May 31, 2014",
+       "Subtitle": "Version of June 6, 2022",
        "Path": "/ref/mem"
 }-->
 
@@ -85,7 +85,7 @@ the approach presented by Hans-J. Boehm and Sarita V. Adve in
 “<a href="https://www.hpl.hp.com/techreports/2008/HPL-2008-56.pdf">Foundations of the C++ Concurrency Memory Model</a>”,
 published in PLDI 2008.
 The definition of data-race-free programs and the guarantee of sequential consistency
-for race-free progams are equivalent to the ones in that work.
+for race-free programs are equivalent to the ones in that work.
 </p>
 
 <p>
@@ -159,6 +159,7 @@ union of the sequenced before and synchronized before relations.
 For an ordinary (non-synchronizing) data read <i>r</i> on a memory location <i>x</i>,
 <i>W</i>(<i>r</i>) must be a write <i>w</i> that is <i>visible</i> to <i>r</i>,
 where visible means that both of the following hold:
+</p>
 
 <ol>
 <li><i>w</i> happens before <i>r</i>.
@@ -205,7 +206,7 @@ by other languages, including C, C++, Java, JavaScript, Rust, and Swift.
 
 <p>
 Certain Go language operations such as goroutine creation and memory allocation
-act as synchronization opeartions.
+act as synchronization operations.
 The effect of these operations on the synchronized-before partial order
 is documented in the “Synchronization” section below.
 Individual packages are responsible for providing similar documentation
@@ -221,7 +222,7 @@ for programs that do contain races.
 </p>
 
 <p>
-First, any implementation can, upon detecting a data race,
+Any implementation can, upon detecting a data race,
 report the race and halt execution of the program.
 Implementations using ThreadSanitizer
 (accessed with “<code>go</code> <code>build</code> <code>-race</code>”)
@@ -229,7 +230,18 @@ do exactly this.
 </p>
 
 <p>
-Otherwise, a read <i>r</i> of a memory location <i>x</i>
+A read of an array, struct, or complex number
+may by implemented as a read of each individual sub-value
+(array element, struct field, or real/imaginary component),
+in any order.
+Similarly, a write of an array, struct, or complex number
+may be implemented as a write of each individual sub-value,
+in any order.
+</p>
+
+<p>
+A read <i>r</i> of a memory location <i>x</i>
+holding a value
 that is not larger than a machine word must observe
 some write <i>w</i> such that <i>r</i> does not happen before <i>w</i>
 and there is no write <i>w'</i> such that <i>w</i> happens before <i>w'</i>