0x7CFE / llst

LLVM powered Little Smalltalk.
Other
93 stars 10 forks source link

Implement Polymorphic Inline Cache (PIC) #68

Open 0x7CFE opened 9 years ago

0x7CFE commented 9 years ago

In order to send a message VM need to find the method which will dispatch the message. Lookup is performed by traversing method dictionaries of receiver class, it's parent and so on. When method is found it is stored to VM method cache to make sequential access faster. Method cache work very well. Typical hit to miss ratio is way more than 85%.

Still, every lookup has it's cost. Even if fallback call to sendMessage() is on the hot path, it's evaluation breaks the data locality, distorts the branch statistics and disturbs branch prediction mechanism.

With the help of inline caches we may link all hot code into a single jump chain, which theoretically should improve the performance.

In this case, inline cache will act as L1 and VM cache will act as L2. L1 should not be large. It's main goal is to provide temporary storage for address of resolved method's function. If it will be too many entries in L1 it's effect will be neutralized.