module = new WebAssembly.Module(wasmTextToBinary(code));
instance = new WebAssembly.Instance(module);
// Same test but with a struct escaping in one of the branches. // This should prevent the struct to be optimized.
code =`
(module
(type $point (struct
(field $x (mut i32))
(field $y (mut i32))
))
module = new WebAssembly.Module(wasmTextToBinary(code));
instance = new WebAssembly.Instance(module);
// In this example, one struct is stored into another one. // The inner struct is escaping into the other one and will // not be optimized. // The outer struct will be optimized by Scalar Replacement.
code =`
(module
;; Define a struct type for the inner struct
(type $InnerStruct (struct
(field (mut i32))
))
;; Define a struct type for the outer struct
(type $OuterStruct (struct
(field (mut i32))
(field (mut i32))
(field (ref $InnerStruct)) ;; Reference to InnerStruct
))
;; Define a function to create and fill both structs.
(func $createStructs (result (ref $InnerStruct))
(local $inner (ref $InnerStruct))
(local $outer (ref $OuterStruct))
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.