Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: native_client_sdk/doc_generated/reference/pnacl-c-cpp-language-support.html

Issue 164413005: PNaCl documentation: add undefined behavior (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address jvoung's comments. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {{+bindTo:partials.standard_nacl_article}} 1 {{+bindTo:partials.standard_nacl_article}}
2 2
3 <section id="pnacl-c-c-language-support"> 3 <section id="pnacl-c-c-language-support">
4 <h1 id="pnacl-c-c-language-support">PNaCl C/C++ Language Support</h1> 4 <h1 id="pnacl-c-c-language-support">PNaCl C/C++ Language Support</h1>
5 <div class="contents local" id="contents" style="display: none"> 5 <div class="contents local" id="contents" style="display: none">
6 <ul class="small-gap"> 6 <ul class="small-gap">
7 <li><p class="first"><a class="reference internal" href="#source-language-suppor t" id="id2">Source language support</a></p> 7 <li><p class="first"><a class="reference internal" href="#source-language-suppor t" id="id2">Source language support</a></p>
8 <ul class="small-gap"> 8 <ul class="small-gap">
9 <li><a class="reference internal" href="#preprocessor-definitions" id="id3">Prep rocessor definitions</a></li> 9 <li><a class="reference internal" href="#preprocessor-definitions" id="id3">Prep rocessor definitions</a></li>
10 </ul> 10 </ul>
11 </li> 11 </li>
12 <li><p class="first"><a class="reference internal" href="#memory-model-and-atomi cs" id="id4">Memory Model and Atomics</a></p> 12 <li><p class="first"><a class="reference internal" href="#memory-model-and-atomi cs" id="id4">Memory Model and Atomics</a></p>
13 <ul class="small-gap"> 13 <ul class="small-gap">
14 <li><a class="reference internal" href="#memory-model-for-concurrent-operations" id="id5">Memory Model for Concurrent Operations</a></li> 14 <li><a class="reference internal" href="#memory-model-for-concurrent-operations" id="id5">Memory Model for Concurrent Operations</a></li>
15 <li><a class="reference internal" href="#atomic-memory-ordering-constraints" id= "id6">Atomic Memory Ordering Constraints</a></li> 15 <li><a class="reference internal" href="#atomic-memory-ordering-constraints" id= "id6">Atomic Memory Ordering Constraints</a></li>
16 <li><a class="reference internal" href="#volatile-memory-accesses" id="id7">Vola tile Memory Accesses</a></li> 16 <li><a class="reference internal" href="#volatile-memory-accesses" id="id7">Vola tile Memory Accesses</a></li>
17 </ul> 17 </ul>
18 </li> 18 </li>
19 <li><a class="reference internal" href="#threading" id="id8">Threading</a></li> 19 <li><a class="reference internal" href="#threading" id="id8">Threading</a></li>
20 <li><a class="reference internal" href="#setjmp-and-longjmp" id="id9"><code>setj mp</code> and <code>longjmp</code></a></li> 20 <li><a class="reference internal" href="#setjmp-and-longjmp" id="id9"><code>setj mp</code> and <code>longjmp</code></a></li>
21 <li><a class="reference internal" href="#c-exception-handling" id="id10">C++ Exc eption Handling</a></li> 21 <li><a class="reference internal" href="#c-exception-handling" id="id10">C++ Exc eption Handling</a></li>
22 <li><a class="reference internal" href="#inline-assembly" id="id11">Inline Assem bly</a></li> 22 <li><a class="reference internal" href="#inline-assembly" id="id11">Inline Assem bly</a></li>
23 <li><p class="first"><a class="reference internal" href="#future-directions" id= "id12">Future Directions</a></p> 23 <li><a class="reference internal" href="#undefined-behavior" id="id12">Undefined Behavior</a></li>
24 <li><a class="reference internal" href="#float-point" id="id13">Float-Point</a>< /li>
25 <li><p class="first"><a class="reference internal" href="#future-directions" id= "id14">Future Directions</a></p>
24 <ul class="small-gap"> 26 <ul class="small-gap">
25 <li><a class="reference internal" href="#simd" id="id13">SIMD</a></li> 27 <li><a class="reference internal" href="#simd" id="id15">SIMD</a></li>
26 <li><a class="reference internal" href="#inter-process-communication" id="id14"> Inter-Process Communication</a></li> 28 <li><a class="reference internal" href="#inter-process-communication" id="id16"> Inter-Process Communication</a></li>
27 <li><a class="reference internal" href="#posix-style-signal-handling" id="id15"> POSIX-style Signal Handling</a></li> 29 <li><a class="reference internal" href="#posix-style-signal-handling" id="id17"> POSIX-style Signal Handling</a></li>
28 <li><a class="reference internal" href="#computed-goto" id="id16">Computed <code >goto</code></a></li> 30 <li><a class="reference internal" href="#computed-goto" id="id18">Computed <code >goto</code></a></li>
29 </ul> 31 </ul>
30 </li> 32 </li>
31 </ul> 33 </ul>
32 34
33 </div><section id="source-language-support"> 35 </div><section id="source-language-support">
34 <h2 id="source-language-support">Source language support</h2> 36 <h2 id="source-language-support">Source language support</h2>
35 <p>The currently supported languages are C and C++. The PNaCl toolchain is 37 <p>The currently supported languages are C and C++. The PNaCl toolchain is
36 based on Clang 3.3, which fully supports C++11 and most of C11. A 38 based on Clang 3.3, which fully supports C++11 and most of C11. A
37 detailed status of the language support is available <a class="reference externa l" href="http://clang.llvm.org/cxx_status.html">here</a>.</p> 39 detailed status of the language support is available <a class="reference externa l" href="http://clang.llvm.org/cxx_status.html">here</a>.</p>
38 <p>For information on using languages other than C/C++, see the <a class="refere nce internal" href="/native-client/faq.html#other-languages"><em>FAQ 40 <p>For information on using languages other than C/C++, see the <a class="refere nce internal" href="/native-client/faq.html#other-languages"><em>FAQ
(...skipping 13 matching lines...) Expand all
52 <section id="memory-model-for-concurrent-operations"> 54 <section id="memory-model-for-concurrent-operations">
53 <h3 id="memory-model-for-concurrent-operations">Memory Model for Concurrent Oper ations</h3> 55 <h3 id="memory-model-for-concurrent-operations">Memory Model for Concurrent Oper ations</h3>
54 <p>The memory model offered by PNaCl relies on the same coding guidelines 56 <p>The memory model offered by PNaCl relies on the same coding guidelines
55 as the C11/C++11 one: concurrent accesses must always occur through 57 as the C11/C++11 one: concurrent accesses must always occur through
56 atomic primitives (offered by <a class="reference external" href="PNaClLangRef.h tml#atomicintrinsics">atomic intrinsics</a>), and these accesses must always 58 atomic primitives (offered by <a class="reference external" href="PNaClLangRef.h tml#atomicintrinsics">atomic intrinsics</a>), and these accesses must always
57 occur with the same size for the same memory location. Visibility of 59 occur with the same size for the same memory location. Visibility of
58 stores is provided on a happens-before basis that relates memory 60 stores is provided on a happens-before basis that relates memory
59 locations to each other as the C11/C++11 standards do.</p> 61 locations to each other as the C11/C++11 standards do.</p>
60 <p>Non-atomic memory accesses may be reordered, separated, elided or fused 62 <p>Non-atomic memory accesses may be reordered, separated, elided or fused
61 according to C and C++&#8217;s memory model before the pexe is created as well 63 according to C and C++&#8217;s memory model before the pexe is created as well
62 as after its creation.</p> 64 as after its creation. Accessing atomic memory location through
65 non-atomic primitives is <cite>Undefined Behavior &lt;undefined_behavior&gt;</ci te>.</p>
63 <p>As in C11/C++11 some atomic accesses may be implemented with locks on 66 <p>As in C11/C++11 some atomic accesses may be implemented with locks on
64 certain platforms. The <code>ATOMIC_*_LOCK_FREE</code> macros will always be 67 certain platforms. The <code>ATOMIC_*_LOCK_FREE</code> macros will always be
65 <code>1</code>, signifying that all types are sometimes lock-free. The 68 <code>1</code>, signifying that all types are sometimes lock-free. The
66 <code>is_lock_free</code> methods and <code>atomic_is_lock_free</code> will retu rn the 69 <code>is_lock_free</code> methods and <code>atomic_is_lock_free</code> will retu rn the
67 current platform&#8217;s implementation at translation time. These macros, 70 current platform&#8217;s implementation at translation time. These macros,
68 methods and functions are in the C11 header <code>&lt;stdatomic.h&gt;</code> and the 71 methods and functions are in the C11 header <code>&lt;stdatomic.h&gt;</code> and the
69 C++11 header <code>&lt;atomic&gt;</code>.</p> 72 C++11 header <code>&lt;atomic&gt;</code>.</p>
70 <p>The PNaCl toolchain supports concurrent memory accesses through legacy 73 <p>The PNaCl toolchain supports concurrent memory accesses through legacy
71 GCC-style <code>__sync_*</code> builtins, as well as through C11/C++11 atomic 74 GCC-style <code>__sync_*</code> builtins, as well as through C11/C++11 atomic
72 primitives and the underlying <a class="reference external" href="http://gcc.gnu .org/wiki/Atomic/GCCMM">GCCMM</a> <code>__atomic_*</code> 75 primitives and the underlying <a class="reference external" href="http://gcc.gnu .org/wiki/Atomic/GCCMM">GCCMM</a> <code>__atomic_*</code>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 <p>Inline assembly isn&#8217;t supported by PNaCl because it isn&#8217;t portabl e. The 164 <p>Inline assembly isn&#8217;t supported by PNaCl because it isn&#8217;t portabl e. The
162 one current exception is the common compiler barrier idiom 165 one current exception is the common compiler barrier idiom
163 <code>asm(&quot;&quot;:::&quot;memory&quot;)</code>, which gets transformed to a sequentially 166 <code>asm(&quot;&quot;:::&quot;memory&quot;)</code>, which gets transformed to a sequentially
164 consistent memory barrier (equivalent to <code>__sync_synchronize()</code>). In 167 consistent memory barrier (equivalent to <code>__sync_synchronize()</code>). In
165 PNaCl this barrier is only guaranteed to order <code>volatile</code> and atomic 168 PNaCl this barrier is only guaranteed to order <code>volatile</code> and atomic
166 memory accesses, though in practice the implementation attempts to also 169 memory accesses, though in practice the implementation attempts to also
167 prevent reordering of memory accesses to objects which may escape.</p> 170 prevent reordering of memory accesses to objects which may escape.</p>
168 <p>NaCl supports a fairly wide subset of inline assembly through GCC&#8217;s 171 <p>NaCl supports a fairly wide subset of inline assembly through GCC&#8217;s
169 inline assembly syntax, with the restriction that the sandboxing model 172 inline assembly syntax, with the restriction that the sandboxing model
170 for the target architecture has to be respected.</p> 173 for the target architecture has to be respected.</p>
174 </section><section id="undefined-behavior">
175 <h2 id="undefined-behavior">Undefined Behavior</h2>
176 <p>The C and C++ languages expose some undefined behavior which is
177 discussed in <cite>PNaCl Undefined Behavior &lt;undefined_behavior&gt;</cite>.</ p>
178 </section><section id="float-point">
179 <h2 id="float-point">Float-Point</h2>
180 <p>PNaCl exposes 32-bit and 64-bit floating point operations which are
181 mostly IEEE-754 compliant. There are a few caveats:</p>
182 <ul class="small-gap">
183 <li>Some <a class="reference internal" href="/native-client/reference/pnacl-unde fined-behavior.html#undefined-behavior-fp"><em>floating-point behavior is curren tly left as undefined</em></a>.</li>
184 <li>Different rounding modes are currently not usable, which isn&#8217;t
185 IEEE-754 compliant. PNaCl could support switching modes (the 4 modes
186 exposed by C99 <code>FLT_ROUNDS</code> macros).</li>
187 <li>Signaling <code>NaN</code> never fault.</li>
188 <li><p class="first">Fast-math optimizations are currently supported before <em> pexe</em> creation
189 time. A <em>pexe</em> loses all fast-math information when it is
190 created. Fast-math translation could be enabled at a later date,
191 potentially at a perf-function granularity. This wouldn&#8217;t affect
192 already-existing <em>pexe</em>; it would be an opt-in feature.</p>
193 <ul class="small-gap">
194 <li>Fused-multiply-add have higher precision and often execute faster;
195 PNaCl currently disallows them in the <em>pexe</em> because they aren&#8217;t
196 supported on all platforms and can&#8217;t realistically be
197 emulated. PNaCl could (but currently doesn&#8217;t) only generate them in
198 the backend if fast-math were specified and the hardware supports
199 the operation.</li>
200 <li>Transcendentals aren&#8217;t exposed by PNaCl&#8217;s ABI; they are part of the
201 math library that is included in the <em>pexe</em>. PNaCl could, but
202 currently doesn&#8217;t, use hardware support if fast-math were provided
203 in the <em>pexe</em>.</li>
204 </ul>
205 </li>
206 </ul>
171 </section><section id="future-directions"> 207 </section><section id="future-directions">
172 <h2 id="future-directions">Future Directions</h2> 208 <h2 id="future-directions">Future Directions</h2>
173 <section id="simd"> 209 <section id="simd">
174 <h3 id="simd">SIMD</h3> 210 <h3 id="simd">SIMD</h3>
175 <p>PNaCl currently doesn&#8217;t support SIMD. We plan to add SIMD support in th e 211 <p>PNaCl currently doesn&#8217;t support SIMD. We plan to add SIMD support in th e
176 very near future.</p> 212 very near future.</p>
177 <p>NaCl supports SIMD.</p> 213 <p>NaCl supports SIMD.</p>
178 </section><section id="inter-process-communication"> 214 </section><section id="inter-process-communication">
179 <h3 id="inter-process-communication">Inter-Process Communication</h3> 215 <h3 id="inter-process-communication">Inter-Process Communication</h3>
180 <p>Inter-process communication through shared memory is currently not 216 <p>Inter-process communication through shared memory is currently not
(...skipping 26 matching lines...) Expand all
207 <code>volatile</code> and atomics with same-thread signal handling would need 243 <code>volatile</code> and atomics with same-thread signal handling would need
208 to be carefully detailed.</p> 244 to be carefully detailed.</p>
209 </section><section id="computed-goto"> 245 </section><section id="computed-goto">
210 <h3 id="computed-goto">Computed <code>goto</code></h3> 246 <h3 id="computed-goto">Computed <code>goto</code></h3>
211 <p>PNaCl currently doesn&#8217;t support computed <code>goto</code>, a non-stand ard 247 <p>PNaCl currently doesn&#8217;t support computed <code>goto</code>, a non-stand ard
212 extension to C used by some interpreters.</p> 248 extension to C used by some interpreters.</p>
213 <p>NaCl supports computed <code>goto</code>.</p> 249 <p>NaCl supports computed <code>goto</code>.</p>
214 </section></section></section> 250 </section></section></section>
215 251
216 {{/partials.standard_nacl_article}} 252 {{/partials.standard_nacl_article}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698