Files
Charles Munger c52a53b160 Add prepare hint to javascript example (#6016)
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.
2024-01-16 22:13:22 -06:00

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);