Chapter 2. A look inside WebAssembly modules

 

This chapter covers

  • Descriptions of a WebAssembly module’s known and custom sections

In this chapter, you’ll learn about the different sections of a WebAssembly module and their purposes. I’ll offer more detail as you proceed through this book, but it’s helpful to have a basic understanding of how modules are structured and how the different sections work together.

Some benefits of a module’s different sections and how they’re designed are

  • Efficiency—The binary bytecode can be parsed, validated, and compiled in a single pass.
  • Streaming—Parsing, validation, and compilation can begin before all the data has been downloaded.
  • Parallelization—It’s possible for the parsing, validation, and compilation to be performed in parallel.
  • Security—The module doesn’t have direct access to the device memory, and items like function pointers are called on your code’s behalf.

Figure 2.1 represents the basic structure of the WebAssembly binary bytecode. Although you’ll interact with the various sections when working with WebAssembly modules, the compiler is responsible for creating the sections as needed and placing them in the proper order based on your code.

Figure 2.1. The basic structure of the WebAssembly binary bytecode, highlighting the known and custom sections

2.1. Known sections

2.2. Custom sections

Summary

sitemap