Chromium Code Reviews| 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: | |
| 16 | |
| 15 Native Client (NaCl) | 17 Native Client (NaCl) |
| 16 ==================== | 18 ==================== |
| 17 | 19 |
| 18 Native Client enables the execution of native code securely inside web | 20 Native Client enables the execution of native code securely inside web |
| 19 applications through the use of advanced `Software Fault Isolation (SFI) | 21 applications through the use of advanced `Software Fault Isolation (SFI) |
| 20 techniques <http://research.google.com/pubs/pub35649.html>`_. Since its launch in | 22 techniques <http://research.google.com/pubs/pub35649.html>`_. Native Client |
| 21 2011, Native Client has provided developers with the ability to harness a | 23 allows you to harness a client machine's computational power to a fuller extent |
| 22 client machine's computational power to a much fuller extent than traditional | 24 than traditional web technologies by running compiled C and C++ code at |
| 23 web technologies, by running compiled C and C++ code at near-native speeds and | 25 near-native speeds and taking advantage of multiple cores with shared memory. |
| 24 taking advantage of multiple cores with shared memory. | |
| 25 | 26 |
| 26 While Native Client provides operating system independence, it requires | 27 While Native Client provides operating system independence, it requires you to |
| 27 developers to generate architecture-specific executable | 28 generate architecture-specific executables (**nexe**) for each hardware |
| 28 (**nexe**) modules for each hardware platform. This is not only inconvenient | 29 platform. This is neither portable nor conveient, making it ill-suited for the |
|
JF
2014/09/19 18:16:17
s/conveient/convenient/
jpmedley
2014/09/19 20:40:33
Done.
| |
| 29 for developers, but architecture-specific machine code is not portable and thus | 30 open web. |
| 30 not well-suited for the open web. The traditional method of application | 31 |
| 31 distribution on the web is through a self-contained bundle of HTML, CSS, | 32 The traditional method of application distribution on the web is through self- |
| 32 JavaScript, and other resources (images, etc.) that can be hosted on a server | 33 contained bundles of HTML, CSS, JavaScript, and other resources (images, etc.) |
| 33 and run inside a web browser. With this type of distribution, a website | 34 that can be hosted on a server and run inside a web browser. With this type of |
| 34 created today should still work years later, on all platforms. | 35 distribution, a website created today should still work years later, on all |
| 35 Architecture-specific executables are clearly not a good fit for distribution | 36 platforms. Architecture-specific executables are clearly not a good fit for |
| 36 on the web. As a consequence, Native Client has been restricted to | 37 distribution on the web. Consequently, Native Client has been until recently |
| 37 applications and browser extensions that are installed through the | 38 restricted to applications and browser extensions that are installed through the |
| 38 Chrome Web Store. | 39 Chrome Web Store. |
| 39 | 40 |
| 41 .. _portable-native-client-pnacl: | |
| 42 | |
| 40 Portable Native Client (PNaCl) | 43 Portable Native Client (PNaCl) |
| 41 ============================== | 44 ============================== |
| 42 | 45 |
| 43 PNaCl solves the portability problem by splitting the compilation process | 46 PNaCl solves the portability problem by splitting the compilation process |
| 44 into two parts: | 47 into two parts: |
| 45 | 48 |
| 46 #. compiling the source code to a portable bitcode format, and | 49 #. compiling the source code to a bitcode executable (pexe), and |
|
JF
2014/09/19 18:16:17
We usually use **nexe** and **pexe**, though I thi
jpmedley
2014/09/19 20:40:33
To what end? I don't think it's really needed and
JF
2014/09/22 16:53:05
It just makes them bold. I'm not necessarily advoc
| |
| 47 #. translating the bitcode to a host-specific executable just before execution. | 50 #. translating the bitcode to a host-specific executable as soon as the module |
| 51 loads in the browser but before any code execution. | |
| 48 | 52 |
| 49 PNaCl enables developers to distribute **portable executables** (**pexe**) | 53 This portability aligns Native Client with existing open web technologies such |
| 50 modules that the hosting environment (in other words, the Chrome browser) can | 54 as JavaScript. You can distribute a pexe as part of an application (along with |
| 51 translate to native code before executing. This portability aligns Native Client | 55 HTML, CSS, and JavaScript), and the user's machine is simply able to run it. |
| 52 with existing open web technologies such as JavaScript. A developer can | |
| 53 distribute a **pexe** as part of an application (along with HTML, CSS, and | |
| 54 JavaScript), and the user's machine is simply able to run it. | |
| 55 | 56 |
| 56 With PNaCl, a developer generates a single **pexe** from source code, | 57 With PNaCl, you'll generate a single pexe, rather than multiple platform- |
| 57 rather than multiple platform-specific nexes. The **pexe** provides both | 58 specific nexes. Since the pexe uses an abstract, architecture- and os- |
|
JF
2014/09/19 18:16:17
Capitalize OS.
jpmedley
2014/09/19 20:40:33
Done.
| |
| 58 architecture- and OS-independence. Since the **pexe** uses an abstract, | 59 independent format, it does not suffer from the portability problem described |
| 59 architecture-independent format, it does not suffer from the portability | 60 above. Future versions of hosting environments should have no problem executing |
| 60 problem described above. Future versions of hosting environments should | 61 the pexe, even on new architectures. Moreover, if an existing architecture is |
| 61 have no problem executing the **pexe**, even on new architectures. | 62 enhanced, the pexe doesn't need to be recompiled. In some cases the client-side |
| 62 Moreover, if an existing architecture is subsequently enhanced, the | 63 translation will automatically take advantage of new capabilities. A pexe can be |
| 63 **pexe** doesn't even have to be recompiled. In some cases the | 64 part of any web application. It does not have to be distributed through the |
| 64 client-side translation will automatically be able to take advantage of | 65 Chrome Web Store. In short, PNaCl combines the portability of existing web |
| 65 the new capabilities. A **pexe** module can be part of any web | 66 technologies with the performance and security benefits of Native Client. |
|
JF
2014/09/19 18:16:17
Interesting points we may want to make:
* NaCl is
jpmedley
2014/09/19 20:40:32
Done.
| |
| 66 application. It does not have to be distributed through the Chrome Web | |
| 67 Store. In short, PNaCl combines the portability of existing web technologies | |
| 68 with the performance and security benefits of Native Client. | |
| 69 | 67 |
| 70 PNaCl is a new technology, and as such it still has a few limitations | 68 PNaCl is a new technology, and as such it still has a few limitations |
| 71 as compared to NaCl. These limitations are described below. | 69 as compared to NaCl. These limitations are described below. |
| 72 | 70 |
| 71 .. _when-to-use-pnacl: | |
| 72 | |
| 73 When to use PNaCl | 73 When to use PNaCl |
| 74 ================= | 74 ================= |
| 75 | 75 |
| 76 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 |
| 77 Native Client modules on the open web. Unless your project is subject to one | 77 Native Client modules without the Google Web Store. Unless your project is |
| 78 of the narrow limitations described below | 78 subject to one of the narrow limitations described under ":ref:`When to use |
| 79 (see :ref:`When to use NaCl<when-to-use-nacl>`), you should use PNaCl. | 79 NaCl<when-to-use-nacl>`", you should use PNaCl. |
| 80 | 80 |
| 81 Beginning with version 31, the Chrome browser supports translation of | 81 Since version 31, Chrome supports translation of pexe |
| 82 **pexe** modules and their use in web applications, without requiring | 82 modules and their use in web applications without requiring installation either |
| 83 any installation (either of a browser plugin or of the applications | 83 of a browser plug-in or of the applications themselves. Native Client and PNaCl |
| 84 themselves). Native Client and PNaCl are open-source technologies, and | 84 are open-source technologies, and our hope is that they will be added to other |
| 85 our hope is that they will be added to other hosting platforms in the | 85 hosting platforms in the future. |
| 86 future. | |
| 87 | 86 |
| 88 If controlled distribution through the Chrome Web Store is an important part | 87 If controlled distribution through the Chrome Web Store is an important part of |
| 89 of your product plan, the benefits of PNaCl are less critical for you. But | 88 your product plan, the benefits of PNaCl are less critical for you. But you can |
| 90 you can still use the PNaCl toolchain and distribute your application | 89 still use the PNaCl toolchain and distribute your application through the Chrome |
| 91 through the Chrome Web Store, and thereby take advantage of the | 90 Web Store, and thereby take advantage of the conveniences of PNaCl, such as not |
| 92 conveniences of PNaCl, such as not having to explicitly compile your application | 91 having to explicitly compile your application for all supported architectures. |
| 93 for all supported architectures. | |
| 94 | 92 |
| 95 .. _when-to-use-nacl: | 93 .. _when-to-use-nacl: |
| 96 | 94 |
| 97 When to use NaCl | 95 When to use NaCl |
| 98 ================ | 96 ================ |
| 99 | 97 |
| 100 The limitations below apply to the current release of PNaCl. If any of | 98 Use NaCl if any of the following apply to your application: |
| 101 these limitations are critical for your application, you should use | |
| 102 non-portable NaCl: | |
| 103 | 99 |
| 104 * PNaCl does not support architecture-specific | 100 * Your application requires architecture-specific instructions such as, for |
| 105 instructions in an application (i.e., inline assembly), but tries to | 101 example, inline assembly. PNaCl tries to offer high-performance portable |
| 106 offer high-performance portable equivalents. One such example is | 102 equivalents. One such example is PNaCl's :ref:`Portable SIMD Vectors |
| 107 PNaCl's :ref:`Portable SIMD Vectors <portable_simd_vectors>`. | 103 <portable_simd_vectors>`. |
| 108 * PNaCl only supports static linking with the ``newlib`` | 104 * Your application uses dynamic linking. PNaCl only supports static linking |
| 109 C standard library (the Native Client SDK provides a PNaCl port of | 105 with a PNaCl port of the ``newlib`` C standard library . Dynamic linking and |
| 110 ``newlib``). Dynamic linking and ``glibc`` are not yet supported. | 106 ``glibc`` are not yet supported in PNaCl. Work is under way to enable dynamic |
| 111 Work is under way to enable dynamic linking in future versions of PNaCl. | 107 linking in future versions of PNaCl. |
| 112 * PNaCl does not support some GNU extensions | 108 * Your application uses certain GNU extensions not supported by PNaCl, like |
|
JF
2014/09/19 18:16:17
"not supported by PNaCl's LLVM toolchain".
jpmedley
2014/09/19 20:40:33
Done.
| |
| 113 like taking the address of a label for computed ``goto``, or nested | 109 taking the address of a label for computed ``goto``, or nested functions. |
| 114 functions. | |
| OLD | NEW |