mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 14:04:04 -05:00
Without this additional line, v8 trunk produces no output, and v8 11.3 produces a bunch of assembly with no `imull` instruction. I don't actually know much about v8 or javascript, but based on [this mailing list post](https://groups.google.com/g/v8-users/c/xlx22gScRNs/m/yE2-boWsBQAJ) and testing on godbolt.org, this works.
17 lines
359 B
JavaScript
17 lines
359 B
JavaScript
function square(a) {
|
|
let result = a * a;
|
|
return result;
|
|
}
|
|
|
|
// Collect type information on next call of function
|
|
%PrepareFunctionForOptimization(square)
|
|
|
|
// Call function once to fill type information
|
|
square(23);
|
|
|
|
// Call function again to go from uninitialized -> pre-monomorphic -> monomorphic
|
|
square(13);
|
|
%OptimizeFunctionOnNextCall(square);
|
|
square(71);
|
|
|