OLD | NEW |
1 ============================ | 1 ============================ |
2 PNaCl C/C++ Language Support | 2 PNaCl C/C++ Language Support |
3 ============================ | 3 ============================ |
4 | 4 |
5 .. contents:: | 5 .. contents:: |
6 :local: | 6 :local: |
7 :backlinks: none | 7 :backlinks: none |
8 :depth: 3 | 8 :depth: 3 |
9 | 9 |
10 Source language support | 10 Source language support |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 The memory model offered by PNaCl relies on the same coding guidelines | 42 The memory model offered by PNaCl relies on the same coding guidelines |
43 as the C11/C++11 one: concurrent accesses must always occur through | 43 as the C11/C++11 one: concurrent accesses must always occur through |
44 atomic primitives (offered by `atomic intrinsics | 44 atomic primitives (offered by `atomic intrinsics |
45 <PNaClLangRef.html#atomicintrinsics>`_), and these accesses must always | 45 <PNaClLangRef.html#atomicintrinsics>`_), and these accesses must always |
46 occur with the same size for the same memory location. Visibility of | 46 occur with the same size for the same memory location. Visibility of |
47 stores is provided on a happens-before basis that relates memory | 47 stores is provided on a happens-before basis that relates memory |
48 locations to each other as the C11/C++11 standards do. | 48 locations to each other as the C11/C++11 standards do. |
49 | 49 |
50 Non-atomic memory accesses may be reordered, separated, elided or fused | 50 Non-atomic memory accesses may be reordered, separated, elided or fused |
51 according to C and C++'s memory model before the pexe is created as well | 51 according to C and C++'s memory model before the pexe is created as well |
52 as after its creation. | 52 as after its creation. Accessing atomic memory location through |
| 53 non-atomic primitives is `Undefined Behavior <undefined_behavior>`. |
53 | 54 |
54 As in C11/C++11 some atomic accesses may be implemented with locks on | 55 As in C11/C++11 some atomic accesses may be implemented with locks on |
55 certain platforms. The ``ATOMIC_*_LOCK_FREE`` macros will always be | 56 certain platforms. The ``ATOMIC_*_LOCK_FREE`` macros will always be |
56 ``1``, signifying that all types are sometimes lock-free. The | 57 ``1``, signifying that all types are sometimes lock-free. The |
57 ``is_lock_free`` methods and ``atomic_is_lock_free`` will return the | 58 ``is_lock_free`` methods and ``atomic_is_lock_free`` will return the |
58 current platform's implementation at translation time. These macros, | 59 current platform's implementation at translation time. These macros, |
59 methods and functions are in the C11 header ``<stdatomic.h>`` and the | 60 methods and functions are in the C11 header ``<stdatomic.h>`` and the |
60 C++11 header ``<atomic>``. | 61 C++11 header ``<atomic>``. |
61 | 62 |
62 The PNaCl toolchain supports concurrent memory accesses through legacy | 63 The PNaCl toolchain supports concurrent memory accesses through legacy |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 ``asm("":::"memory")``, which gets transformed to a sequentially | 182 ``asm("":::"memory")``, which gets transformed to a sequentially |
182 consistent memory barrier (equivalent to ``__sync_synchronize()``). In | 183 consistent memory barrier (equivalent to ``__sync_synchronize()``). In |
183 PNaCl this barrier is only guaranteed to order ``volatile`` and atomic | 184 PNaCl this barrier is only guaranteed to order ``volatile`` and atomic |
184 memory accesses, though in practice the implementation attempts to also | 185 memory accesses, though in practice the implementation attempts to also |
185 prevent reordering of memory accesses to objects which may escape. | 186 prevent reordering of memory accesses to objects which may escape. |
186 | 187 |
187 NaCl supports a fairly wide subset of inline assembly through GCC's | 188 NaCl supports a fairly wide subset of inline assembly through GCC's |
188 inline assembly syntax, with the restriction that the sandboxing model | 189 inline assembly syntax, with the restriction that the sandboxing model |
189 for the target architecture has to be respected. | 190 for the target architecture has to be respected. |
190 | 191 |
| 192 Undefined Behavior |
| 193 ================== |
| 194 |
| 195 The C and C++ languages expose some undefined behavior which is |
| 196 discussed in `PNaCl Undefined Behavior <undefined_behavior>`. |
| 197 |
| 198 Float-Point |
| 199 =========== |
| 200 |
| 201 PNaCl exposes 32-bit and 64-bit floating point operations which are |
| 202 mostly IEEE-754 compliant. There are a few caveats: |
| 203 |
| 204 * Some :ref:`floating-point behavior is currently left as undefined |
| 205 <undefined_behavior_fp>`. |
| 206 * Different rounding modes are currently not usable, which isn't |
| 207 IEEE-754 compliant. PNaCl could support switching modes (the 4 modes |
| 208 exposed by C99 ``FLT_ROUNDS`` macros). |
| 209 * Signaling ``NaN`` never fault. |
| 210 * Fast-math optimizations are currently supported before *pexe* creation |
| 211 time. A *pexe* loses all fast-math information when it is |
| 212 created. Fast-math translation could be enabled at a later date, |
| 213 potentially at a perf-function granularity. This wouldn't affect |
| 214 already-existing *pexe*; it would be an opt-in feature. |
| 215 |
| 216 * Fused-multiply-add have higher precision and often execute faster; |
| 217 PNaCl currently disallows them in the *pexe* because they aren't |
| 218 supported on all platforms and can't realistically be |
| 219 emulated. PNaCl could (but currently doesn't) only generate them in |
| 220 the backend if fast-math were specified and the hardware supports |
| 221 the operation. |
| 222 * Transcendentals aren't exposed by PNaCl's ABI; they are part of the |
| 223 math library that is included in the *pexe*. PNaCl could, but |
| 224 currently doesn't, use hardware support if fast-math were provided |
| 225 in the *pexe*. |
| 226 |
191 Future Directions | 227 Future Directions |
192 ================= | 228 ================= |
193 | 229 |
194 SIMD | 230 SIMD |
195 ---- | 231 ---- |
196 | 232 |
197 PNaCl currently doesn't support SIMD. We plan to add SIMD support in the | 233 PNaCl currently doesn't support SIMD. We plan to add SIMD support in the |
198 very near future. | 234 very near future. |
199 | 235 |
200 NaCl supports SIMD. | 236 NaCl supports SIMD. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 ``volatile`` and atomics with same-thread signal handling would need | 273 ``volatile`` and atomics with same-thread signal handling would need |
238 to be carefully detailed. | 274 to be carefully detailed. |
239 | 275 |
240 Computed ``goto`` | 276 Computed ``goto`` |
241 ----------------- | 277 ----------------- |
242 | 278 |
243 PNaCl currently doesn't support computed ``goto``, a non-standard | 279 PNaCl currently doesn't support computed ``goto``, a non-standard |
244 extension to C used by some interpreters. | 280 extension to C used by some interpreters. |
245 | 281 |
246 NaCl supports computed ``goto``. | 282 NaCl supports computed ``goto``. |
OLD | NEW |