| OLD | NEW |
| 1 .. _nacl-and-pnacl: | 1 .. _nacl-and-pnacl: |
| 2 | 2 |
| 3 ############## | 3 ############## |
| 4 NaCl and PNaCl | 4 NaCl and PNaCl |
| 5 ############## | 5 ############## |
| 6 | 6 |
| 7 This document describes the differences between **Native Client** and | 7 This document describes the differences between **Native Client** and |
| 8 **Portable Native Client**, and provides recommendations for when to use each. | 8 **Portable Native Client**, and provides recommendations for when to use each. |
| 9 | 9 |
| 10 .. contents:: | 10 .. contents:: |
| 11 :local: | 11 :local: |
| 12 :backlinks: none | 12 :backlinks: none |
| 13 :depth: 2 | 13 :depth: 2 |
| 14 | 14 |
| 15 Native Client (NaCl) | 15 Native Client (NaCl) |
| 16 ==================== | 16 ==================== |
| 17 | 17 |
| 18 Native Client enables the execution of native code securely inside web | 18 Native Client enables the execution of native code securely inside web |
| 19 applications through the use of advanced `Software Fault Isolation (SFI) | 19 applications through the use of advanced `Software Fault Isolation (SFI) |
| 20 techniques </native-client/community/talks#research>`_. Since its launch in | 20 techniques </native-client/community/talks#research>`_. Since its launch in |
| 21 2011, Native Client has provided developers with the ability to harness a | 21 2011, Native Client has provided developers with the ability to harness a |
| 22 client machine's computational power to a much fuller extent than traditional | 22 client machine's computational power to a much fuller extent than traditional |
| 23 web technologies, by running compiled C and C++ code at near-native speeds and | 23 web technologies, by running compiled C and C++ code at near-native speeds and |
| 24 taking advantage of multiple cores with shared memory. | 24 taking advantage of multiple cores with shared memory. |
| 25 | 25 |
| 26 While Native Client provides operating system independence, it requires | 26 While Native Client provides operating system independence, it requires |
| 27 developers to generate architecture-specific executable modules | 27 developers to generate architecture-specific executable |
| 28 (**nexe** modules) for each hardware platform. This is not only inconvenient | 28 (**nexe**) modules for each hardware platform. This is not only inconvenient |
| 29 for developers, but architecture-specific machine code is not portable and thus | 29 for developers, but architecture-specific machine code is not portable and thus |
| 30 not well-suited for the open web. The traditional method of application | 30 not well-suited for the open web. The traditional method of application |
| 31 distribution on the web is through a self-contained bundle of HTML, CSS, | 31 distribution on the web is through a self-contained bundle of HTML, CSS, |
| 32 JavaScript, and other resources (images, etc.) that can be hosted on a server | 32 JavaScript, and other resources (images, etc.) that can be hosted on a server |
| 33 and run inside a web browser. With this type of distribution, a website | 33 and run inside a web browser. With this type of distribution, a website |
| 34 created today should still work years later, on all platforms. | 34 created today should still work years later, on all platforms. |
| 35 Architecture-specific executables are clearly not a good fit for distribution | 35 Architecture-specific executables are clearly not a good fit for distribution |
| 36 on the web. As a consequence, Native Client has been restricted to | 36 on the web. As a consequence, Native Client has been restricted to |
| 37 applications and browser extensions that are installed through the | 37 applications and browser extensions that are installed through the |
| 38 Chrome Web Store. | 38 Chrome Web Store. |
| 39 | 39 |
| 40 Portable Native Client (PNaCl) | 40 Portable Native Client (PNaCl) |
| 41 ============================== | 41 ============================== |
| 42 | 42 |
| 43 PNaCl solves the portability problem by splitting the compilation process | 43 PNaCl solves the portability problem by splitting the compilation process |
| 44 into two parts: | 44 into two parts: |
| 45 | 45 |
| 46 #. compiling the source code to a portable bitcode format, and | 46 #. compiling the source code to a portable bitcode format, and |
| 47 #. translating the bitcode to a host-specific executable. | 47 #. translating the bitcode to a host-specific executable just before execution. |
| 48 | 48 |
| 49 PNaCl enables developers | 49 PNaCl enables developers to distribute **portable executables** (**pexe**) |
| 50 to distribute **portable executables** (**pexe** modules) that the hosting | 50 modules that the hosting environment (in other words, the Chrome browser) can |
| 51 environment (e.g., the Chrome browser) can translate to native code before | 51 translate to native code before executing. This portability aligns Native Client |
| 52 executing. This portability aligns Native Client with existing open web | 52 with existing open web technologies such as JavaScript. A developer can |
| 53 technologies such as JavaScript: A developer can distribute a **pexe** | 53 distribute a **pexe** as part of an application (along with HTML, CSS, and |
| 54 as part of an application (along with HTML, CSS, and JavaScript), | 54 JavaScript), and the user's machine is simply able to run it. |
| 55 and the user's machine is simply able to run it. | |
| 56 | 55 |
| 57 With PNaCl, a developer generates a single **pexe** from source code, | 56 With PNaCl, a developer generates a single **pexe** from source code, |
| 58 rather than multiple platform-specific nexes. The **pexe** provides both | 57 rather than multiple platform-specific nexes. The **pexe** provides both |
| 59 architecture- and OS-independence. Since the **pexe** uses an abstract, | 58 architecture- and OS-independence. Since the **pexe** uses an abstract, |
| 60 architecture-independent format, it does not suffer from the portability | 59 architecture-independent format, it does not suffer from the portability |
| 61 problem described above. Future versions of hosting environments should | 60 problem described above. Future versions of hosting environments should |
| 62 have no problem executing the **pexe**, even on new architectures. | 61 have no problem executing the **pexe**, even on new architectures. |
| 63 Moreover, if an existing architecture is subsequently enhanced, the | 62 Moreover, if an existing architecture is subsequently enhanced, the |
| 64 **pexe** doesn't even have to be recompiled---in some cases the | 63 **pexe** doesn't even have to be recompiled. In some cases the |
| 65 client-side translation will automatically be able to take advantage of | 64 client-side translation will automatically be able to take advantage of |
| 66 the new capabilities. | 65 the new capabilities. A **pexe** module can be part of any web |
| 67 | 66 application. It does not have to be distributed through the Chrome Web |
| 68 **In short, PNaCl combines the portability of existing web technologies with | 67 Store. In short, PNaCl combines the portability of existing web technologies |
| 69 the performance and security benefits of Native Client.** | 68 with the performance and security benefits of Native Client. |
| 70 | |
| 71 With the advent of PNaCl, the distribution restriction of Native Client | |
| 72 can be lifted. Specifically, a **pexe** module can be part of any web | |
| 73 application---it does not have to be distributed through the Chrome Web | |
| 74 Store. | |
| 75 | 69 |
| 76 PNaCl is a new technology, and as such it still has a few limitations | 70 PNaCl is a new technology, and as such it still has a few limitations |
| 77 as compared to NaCl. These limitations are described below. | 71 as compared to NaCl. These limitations are described below. |
| 78 | 72 |
| 79 When to use PNaCl | 73 When to use PNaCl |
| 80 ================= | 74 ================= |
| 81 | 75 |
| 82 PNaCl is the preferred toolchain for Native Client, and the only way to deploy | 76 PNaCl is the preferred toolchain for Native Client, and the only way to deploy |
| 83 Native Client modules on the open web. Unless your project is subject to one | 77 Native Client modules on the open web. Unless your project is subject to one |
| 84 of the narrow limitations described below | 78 of the narrow limitations described below |
| (...skipping 15 matching lines...) Expand all Loading... |
| 100 | 94 |
| 101 .. _when-to-use-nacl: | 95 .. _when-to-use-nacl: |
| 102 | 96 |
| 103 When to use NaCl | 97 When to use NaCl |
| 104 ================ | 98 ================ |
| 105 | 99 |
| 106 The limitations below apply to the current release of PNaCl. If any of | 100 The limitations below apply to the current release of PNaCl. If any of |
| 107 these limitations are critical for your application, you should use | 101 these limitations are critical for your application, you should use |
| 108 non-portable NaCl: | 102 non-portable NaCl: |
| 109 | 103 |
| 110 * By its nature, PNaCl does not support architecture-specific | 104 * PNaCl does not support architecture-specific |
| 111 instructions in an application (i.e., inline assembly), but tries to | 105 instructions in an application (i.e., inline assembly), but tries to |
| 112 offer high-performance portable equivalents. One such example is | 106 offer high-performance portable equivalents. One such example is |
| 113 PNaCl's :ref:`Portable SIMD Vectors <portable_simd_vectors>`. | 107 PNaCl's :ref:`Portable SIMD Vectors <portable_simd_vectors>`. |
| 114 * Currently PNaCl only supports static linking with the ``newlib`` | 108 * PNaCl only supports static linking with the ``newlib`` |
| 115 C standard library (the Native Client SDK provides a PNaCl port of | 109 C standard library (the Native Client SDK provides a PNaCl port of |
| 116 ``newlib``). Dynamic linking and ``glibc`` are not yet supported. | 110 ``newlib``). Dynamic linking and ``glibc`` are not yet supported. |
| 117 Work is under way to enable dynamic linking in future versions of PNaCl. | 111 Work is under way to enable dynamic linking in future versions of PNaCl. |
| 118 * In the initial release, PNaCl does not support some GNU extensions | 112 * PNaCl does not support some GNU extensions |
| 119 like taking the address of a label for computed ``goto``, or nested | 113 like taking the address of a label for computed ``goto``, or nested |
| 120 functions. | 114 functions. |
| OLD | NEW |