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. |
JF
2014/09/22 16:53:05
Mention SIMD too? Or maybe rephrase to explain tha
jpmedley
2014/09/22 17:19:50
Done.
| |
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 convenient, making it ill-suited for the |
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 |
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- |
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. Although, PNaCl can be more efficient on some operating systems than on |
60 problem described above. Future versions of hosting environments should | 61 others. PNaCl boasts the same level of security as NaCl. Future versions of |
61 have no problem executing the **pexe**, even on new architectures. | 62 hosting environments should have no problem executing the pexe, even on new |
62 Moreover, if an existing architecture is subsequently enhanced, the | 63 architectures. Moreover, if an existing architecture is enhanced, the pexe |
63 **pexe** doesn't even have to be recompiled. In some cases the | 64 doesn't need to be recompiled. In some cases the client-side translation will |
64 client-side translation will automatically be able to take advantage of | 65 automatically take advantage of new capabilities. A pexe can be part of any web |
65 the new capabilities. A **pexe** module can be part of any web | 66 application. It does not have to be distributed through the Chrome Web Store. In |
66 application. It does not have to be distributed through the Chrome Web | 67 short, PNaCl combines the portability of existing web technologies with the |
67 Store. In short, PNaCl combines the portability of existing web technologies | 68 performance and security benefits of Native Client. |
68 with the performance and security benefits of Native Client. | |
69 | 69 |
70 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 |
71 as compared to NaCl. These limitations are described below. | 71 as compared to NaCl. These limitations are described below. |
72 | 72 |
73 .. _when-to-use-pnacl: | |
74 | |
73 When to use PNaCl | 75 When to use PNaCl |
74 ================= | 76 ================= |
75 | 77 |
76 PNaCl is the preferred toolchain for Native Client, and the only way to deploy | 78 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 | 79 Native Client modules without the Google Web Store. Unless your project is |
78 of the narrow limitations described below | 80 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. | 81 NaCl<when-to-use-nacl>`", you should use PNaCl. |
80 | 82 |
81 Beginning with version 31, the Chrome browser supports translation of | 83 Since version 31, Chrome supports translation of pexe |
82 **pexe** modules and their use in web applications, without requiring | 84 modules and their use in web applications without requiring installation either |
83 any installation (either of a browser plugin or of the applications | 85 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 | 86 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 | 87 hosting platforms in the future. |
86 future. | |
87 | 88 |
88 If controlled distribution through the Chrome Web Store is an important part | 89 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 | 90 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 | 91 still use the PNaCl toolchain and distribute your application through the Chrome |
91 through the Chrome Web Store, and thereby take advantage of the | 92 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 | 93 having to explicitly compile your application for all supported architectures. |
93 for all supported architectures. | |
94 | 94 |
95 .. _when-to-use-nacl: | 95 .. _when-to-use-nacl: |
96 | 96 |
97 When to use NaCl | 97 When to use NaCl |
98 ================ | 98 ================ |
99 | 99 |
100 The limitations below apply to the current release of PNaCl. If any of | 100 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 | 101 |
104 * PNaCl does not support architecture-specific | 102 * Your application requires architecture-specific instructions such as, for |
105 instructions in an application (i.e., inline assembly), but tries to | 103 example, inline assembly. PNaCl tries to offer high-performance portable |
106 offer high-performance portable equivalents. One such example is | 104 equivalents. One such example is PNaCl's :ref:`Portable SIMD Vectors |
107 PNaCl's :ref:`Portable SIMD Vectors <portable_simd_vectors>`. | 105 <portable_simd_vectors>`. |
108 * PNaCl only supports static linking with the ``newlib`` | 106 * Your application uses dynamic linking. PNaCl only supports static linking |
109 C standard library (the Native Client SDK provides a PNaCl port of | 107 with a PNaCl port of the ``newlib`` C standard library . Dynamic linking and |
JF
2014/09/22 16:53:05
There's a space before the period .
jpmedley
2014/09/22 17:19:50
Done.
| |
110 ``newlib``). Dynamic linking and ``glibc`` are not yet supported. | 108 ``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. | 109 linking in future versions of PNaCl. |
112 * PNaCl does not support some GNU extensions | 110 * Your application uses certain GNU extensions not supported by PNaCl's LLVM |
113 like taking the address of a label for computed ``goto``, or nested | 111 toolchain, like taking the address of a label for computed ``goto``, or nested |
114 functions. | 112 functions. |
OLD | NEW |