// Tests the inliner on a recursive function, in particular to establish that // the inlining heuristics have some way to stop the compiler looping // indefinitely and, more constrainingly, that it has some way to stop // excessive but finite inlining.
// `func $recursive` has 95 bytecode bytes. With module- and function-level // inlining budgeting disabled, it is inlined into itself 1110 times, // processing an extra 105450 bytecode bytes. This is definitely excessive. // // With budgeting re-enabled, it is inlined just 9 times, as intended.
let t = `
(module
(func $recursive (export "recursive") (param i32) (result i32)
(i32.le_u (local.get 0) (i32.const 1)) if (result i32)
(i32.const 1) else
(i32.const 1)
let i = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(t)));
assertEq(i.exports.recursive(10), 14517361);
// This assertion will fail if there is runaway recursion, because the // optimised compilation will run long and hence not be completed by the time // the assertion is evaluated.
assertEq(wasmFunctionTier(i.exports.recursive), "optimized");
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
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.