WebAssembly / compilation-hints

Compilation Hints
Other
0 stars 0 forks source link

Question on call targets hint #9

Open eqrion opened 1 month ago

eqrion commented 1 month ago

For SpiderMonkey, we're working towards collecting the following lattice of call target information for indirect calls:

unknown
|
monomorphic(funcIndex)
|
polymorphic(funcIndex, funcIndex, ...)
|
megamorphic

unknown means that we have no information at all. megamorphic means that we've observed so many call targets that we don't believe it's worth tracking them.

Is this possible to encode into call target hints? If a call target hint is missing for a call instruction, is that interpreted as 'unknown' or 'megamorphic'? If I'm reading it right, a call target hint with an empty call target information vector inside of it seems like it could be interpreted as 'megamorphic'.

ecmziegler commented 1 month ago

Because information might be missing, there is no clear way of identifying megamorphic call sites. It is of course implementation specific, but the idea was that once we decided to tier up, we will not be collecting call frequencies anymore. So there is no difference in between unknown and megamorphic as both lead to no inlining and no feedback collection.

This might be different in the future or for other engines. One way of dealing with that would be to allow for adding information to other targets. So, you could just attribute all the calls to this other category in case of megamorphic sites while truly unknown call information is simply omitted.

Alternatively, we could encode this as having information but the vector of call targets simply being empty.