Chapter 8. Dynamic linking: The implementation

 

This chapter covers

  • Using dynamic linking in a single-page application
  • Creating multiple instances of Emscripten’s JavaScript Module object, with each instance dynamically linked to a different WebAssembly side module
  • Reducing the size of the WebAssembly main module by enabling dead code elimination

In chapter 7, you learned about the different approaches available for dynamically linking WebAssembly modules:

  • dlopen, in which your C or C++ code manually links to a module, obtaining function pointers to the specific functions as they’re required
  • dynamicLibraries, in which your JavaScript provides Emscripten with a list of modules to link to, and Emscripten automatically links to those modules during its initialization
  • Manually linking, in which your JavaScript takes the exports of one module and passes them as the imports to another module using the WebAssembly JavaScript API

In this chapter, you’re going to use the dynamicLibraries approach in which Emscripten handles the dynamic linking for you based on a list of modules that you specify.

Suppose the company that created the online version of its point-of-sale application’s Edit Product page now wants to create the Place Order form shown in figure 8.1. Like the Edit Product page, the Place Order form will use a WebAssembly module for validating the user’s entries.

Figure 8.1. The new Place Order form

8.1. Creating the WebAssembly modules

8.2. Adjusting the web page

Real-world use cases

Exercises

Summary

sitemap