## 4 Tools for WebAssembly Development
### WebAssembly Standardized Features for Existing Web Browsers and Tools
The SP value is ultimately saved in a mutable global and loaded from the parameter at function entry points. This approach provides an optimization, as passing the SP to all functions is unnecessary and it is only required for exported functions. * New Solution for Globals using Wasm.Global: the new solution suggests loosening the restriction on importing and exporting mutable globals to provide a better solution for thread-local values. This allows for the usage of mutable globals as thread-local storage. In the web binding, exported globals are of the Wasm.Global type rather than being converted to JavaScript Numbers. A Wasm.Global object comprises a single global value that can be simultaneously referenced by multiple Instance objects. Each Global object has two internal slots. The _Import/Export Mutable Globals_ scheme aims to enhance Wasm's capabilities by allowing the import and export of mutable globals. This enables the provision of mutable thread-local values that can be dynamically linked, addressing scenarios such as utilization of the C++ stack pointer. This proposal presents multiple solutions, highlighting the benefits and drawbacks of each approach. By allowing the import and export of mutable globals, Wasm gains greater flexibility in handling thread-local variables and opens up new possibilities for dynamic linking. * **Reference types** The Reference Types for Wasm proposal aims to introduce new types and instructions to enhance interoperation with the host environment and provide more flexibility within Wasm. The motivation behind this proposal includes easier and more efficient interoperability, manipulation of tables (paving the way for future extensions), and smoother transition paths to features such as garbage collection. The proposal introduces the following key additions. * **New Types** The schema adds the type \"externref,\" which can be used as both a value type and a table element type. Additionally, \"funcref\" is introduced as a value type. * **Table Instructions** Instructions are provided to get and set table slots, ensuring that basic manipulation of tables is possible within Wasm. Furthermore, missing instructions such as table size, grow, and fill are added. * **Multiple Tables** The scheme allows for the use of multiple tables, increasing flexibility and enabling more complex data structures. * **Possible Future Extensions** The technique mentions potential future extensions that could be explored. * **Subtyping** The introduction of a simple subtype relation between reference types to enable various extensions. * **Equality on References** Allows references to be compared by identity while ensuring implementation details are not observable in a non-deterministic manner. * **Typed Function References** Enhances the representation of function pointers and enables the easy passing of functions between modules. * **Down Casts** Introduces a cast instruction to enable the implementation of generics using anyref as a top type. It is worth noting that several of the future extensions mentioned here are covered by separate proposals, such as the Typed Function References proposal and the garbage collection proposal. The _Reference Types_ proposal for Wasm suggests the introduction of new types, instructions, and features to improve interoperability, table manipulation, and flexibility within Wasm. These additions aim to enhance the overall capabilities of Wasm while setting the stage for potential future extensions. * Instead of trapping on positive or negative overflow, the saturating instructions return the maximum or minimum integer value, respectively, without trapping. - Instead of trapping on NaN, the saturating instructions return 0 without trapping. To accommodate the new instructions, a new prefix byte is introduced, labeled _\"misc\"_, which is intended to be used for future miscellaneous operations. The encodings for the new instructions utilize this prefix, allowing for clear differentiation from other instructions.