codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
365 stars 75 forks source link

Add inline caches #122

Open codefrau opened 3 years ago

codefrau commented 3 years ago

As pointed out by Stefan Marr inline caches could help improve lookup performance in the current JIT and even the interpreter. This is probably the simplest thing we can do right now to improve send performance (I wouldn't expect too much of a speedup though).

We might be able to add the cache to a CompiledMethod object on the fly. It could be a dictionary indexed by the send's pc.

Something would need to be stored in the selector objects too, for invalidation. Maybe a list of dict+pc pairs so individual entries can be invalidated.

Might need to hook into finalization to clean out garbage in these.

Ref: https://www.complang.tuwien.ac.at/kps09/pdfs/brunthaler.pdf