| 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 Floating-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 * The default rounding mode is round-to-nearest and other rounding modes |
| 207 are currently not usable, which isn't IEEE-754 compliant. PNaCl could |
| 208 support switching modes (the 4 modes exposed by C99 ``FLT_ROUNDS`` |
| 209 macros). |
| 210 * Signaling ``NaN`` never fault. |
| 211 * Fast-math optimizations are currently supported before *pexe* creation |
| 212 time. A *pexe* loses all fast-math information when it is |
| 213 created. Fast-math translation could be enabled at a later date, |
| 214 potentially at a perf-function granularity. This wouldn't affect |
| 215 already-existing *pexe*; it would be an opt-in feature. |
| 216 |
| 217 * Fused-multiply-add have higher precision and often execute faster; |
| 218 PNaCl currently disallows them in the *pexe* because they aren't |
| 219 supported on all platforms and can't realistically be |
| 220 emulated. PNaCl could (but currently doesn't) only generate them in |
| 221 the backend if fast-math were specified and the hardware supports |
| 222 the operation. |
| 223 * Transcendentals aren't exposed by PNaCl's ABI; they are part of the |
| 224 math library that is included in the *pexe*. PNaCl could, but |
| 225 currently doesn't, use hardware support if fast-math were provided |
| 226 in the *pexe*. |
| 227 |
| 191 Future Directions | 228 Future Directions |
| 192 ================= | 229 ================= |
| 193 | 230 |
| 194 SIMD | 231 SIMD |
| 195 ---- | 232 ---- |
| 196 | 233 |
| 197 PNaCl currently doesn't support SIMD. We plan to add SIMD support in the | 234 PNaCl currently doesn't support SIMD. We plan to add SIMD support in the |
| 198 very near future. | 235 very near future. |
| 199 | 236 |
| 200 NaCl supports SIMD. | 237 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 | 274 ``volatile`` and atomics with same-thread signal handling would need |
| 238 to be carefully detailed. | 275 to be carefully detailed. |
| 239 | 276 |
| 240 Computed ``goto`` | 277 Computed ``goto`` |
| 241 ----------------- | 278 ----------------- |
| 242 | 279 |
| 243 PNaCl currently doesn't support computed ``goto``, a non-standard | 280 PNaCl currently doesn't support computed ``goto``, a non-standard |
| 244 extension to C used by some interpreters. | 281 extension to C used by some interpreters. |
| 245 | 282 |
| 246 NaCl supports computed ``goto``. | 283 NaCl supports computed ``goto``. |
| OLD | NEW |