[android_webview] Call super.onMeasure in AwTestContainerView.
[chromium-blink-merge.git] / native_client_sdk / doc_generated / nacl-and-pnacl.html
blobec83b1a38c504f15991659c327610e4d8dfd89cc
1 {{+bindTo:partials.standard_nacl_article}}
3 <section id="nacl-and-pnacl">
4 <span id="id1"></span><h1 id="nacl-and-pnacl"><span id="id1"></span>NaCl and PNaCl</h1>
5 <p>This document describes the differences between <strong>Native Client</strong> and
6 <strong>Portable Native Client</strong>, and provides recommendations for when to use each.</p>
7 <div class="contents local" id="contents" style="display: none">
8 <ul class="small-gap">
9 <li><a class="reference internal" href="#native-client-nacl" id="id3">Native Client (NaCl)</a></li>
10 <li><a class="reference internal" href="#portable-native-client-pnacl" id="id4">Portable Native Client (PNaCl)</a></li>
11 <li><a class="reference internal" href="#when-to-use-pnacl" id="id5">When to use PNaCl</a></li>
12 <li><a class="reference internal" href="#when-to-use-nacl" id="id6">When to use NaCl</a></li>
13 </ul>
15 </div><h2 id="native-client-nacl">Native Client (NaCl)</h2>
16 <p>Native Client enables the execution of native code securely inside web
17 applications through the use of advanced <a class="reference external" href="/native-client/community/talks#research">Software Fault Isolation (SFI)
18 techniques</a>. Since its launch in
19 2011, Native Client has provided developers with the ability to harness a
20 client machine&#8217;s computational power to a much fuller extent than traditional
21 web technologies, by running compiled C and C++ code at near-native speeds and
22 taking advantage of multiple cores with shared memory.</p>
23 <p>While Native Client provides operating system independence, it requires
24 developers to generate architecture-specific executable
25 (<strong>nexe</strong>) modules for each hardware platform. This is not only inconvenient
26 for developers, but architecture-specific machine code is not portable and thus
27 not well-suited for the open web. The traditional method of application
28 distribution on the web is through a self-contained bundle of HTML, CSS,
29 JavaScript, and other resources (images, etc.) that can be hosted on a server
30 and run inside a web browser. With this type of distribution, a website
31 created today should still work years later, on all platforms.
32 Architecture-specific executables are clearly not a good fit for distribution
33 on the web. As a consequence, Native Client has been restricted to
34 applications and browser extensions that are installed through the
35 Chrome Web Store.</p>
36 <h2 id="portable-native-client-pnacl">Portable Native Client (PNaCl)</h2>
37 <p>PNaCl solves the portability problem by splitting the compilation process
38 into two parts:</p>
39 <ol class="arabic simple">
40 <li>compiling the source code to a portable bitcode format, and</li>
41 <li>translating the bitcode to a host-specific executable just before execution.</li>
42 </ol>
43 <p>PNaCl enables developers to distribute <strong>portable executables</strong> (<strong>pexe</strong>)
44 modules that the hosting environment (in other words, the Chrome browser) can
45 translate to native code before executing. This portability aligns Native Client
46 with existing open web technologies such as JavaScript. A developer can
47 distribute a <strong>pexe</strong> as part of an application (along with HTML, CSS, and
48 JavaScript), and the user&#8217;s machine is simply able to run it.</p>
49 <p>With PNaCl, a developer generates a single <strong>pexe</strong> from source code,
50 rather than multiple platform-specific nexes. The <strong>pexe</strong> provides both
51 architecture- and OS-independence. Since the <strong>pexe</strong> uses an abstract,
52 architecture-independent format, it does not suffer from the portability
53 problem described above. Future versions of hosting environments should
54 have no problem executing the <strong>pexe</strong>, even on new architectures.
55 Moreover, if an existing architecture is subsequently enhanced, the
56 <strong>pexe</strong> doesn&#8217;t even have to be recompiled. In some cases the
57 client-side translation will automatically be able to take advantage of
58 the new capabilities. A <strong>pexe</strong> module can be part of any web
59 application. It does not have to be distributed through the Chrome Web
60 Store. In short, PNaCl combines the portability of existing web technologies
61 with the performance and security benefits of Native Client.</p>
62 <p>PNaCl is a new technology, and as such it still has a few limitations
63 as compared to NaCl. These limitations are described below.</p>
64 <h2 id="when-to-use-pnacl">When to use PNaCl</h2>
65 <p>PNaCl is the preferred toolchain for Native Client, and the only way to deploy
66 Native Client modules on the open web. Unless your project is subject to one
67 of the narrow limitations described below
68 (see <a class="reference internal" href="#when-to-use-nacl"><em>When to use NaCl</em></a>), you should use PNaCl.</p>
69 <p>Beginning with version 31, the Chrome browser supports translation of
70 <strong>pexe</strong> modules and their use in web applications, without requiring
71 any installation (either of a browser plugin or of the applications
72 themselves). Native Client and PNaCl are open-source technologies, and
73 our hope is that they will be added to other hosting platforms in the
74 future.</p>
75 <p>If controlled distribution through the Chrome Web Store is an important part
76 of your product plan, the benefits of PNaCl are less critical for you. But
77 you can still use the PNaCl toolchain and distribute your application
78 through the Chrome Web Store, and thereby take advantage of the
79 conveniences of PNaCl, such as not having to explicitly compile your application
80 for all supported architectures.</p>
81 <h2 id="when-to-use-nacl"><span id="id2"></span>When to use NaCl</h2>
82 <p>The limitations below apply to the current release of PNaCl. If any of
83 these limitations are critical for your application, you should use
84 non-portable NaCl:</p>
85 <ul class="small-gap">
86 <li>PNaCl does not support architecture-specific
87 instructions in an application (i.e., inline assembly), but tries to
88 offer high-performance portable equivalents. One such example is
89 PNaCl&#8217;s <a class="reference internal" href="/native-client/reference/pnacl-c-cpp-language-support.html#portable-simd-vectors"><em>Portable SIMD Vectors</em></a>.</li>
90 <li>PNaCl only supports static linking with the <code>newlib</code>
91 C standard library (the Native Client SDK provides a PNaCl port of
92 <code>newlib</code>). Dynamic linking and <code>glibc</code> are not yet supported.
93 Work is under way to enable dynamic linking in future versions of PNaCl.</li>
94 <li>PNaCl does not support some GNU extensions
95 like taking the address of a label for computed <code>goto</code>, or nested
96 functions.</li>
97 </ul>
98 </section>
100 {{/partials.standard_nacl_article}}