-
-
Save xushijie/8174975 to your computer and use it in GitHub Desktop.
This is basic background literature for dynamic language and polymorphic inline cache. | |
The basic idea: | |
1, collect type information by recording all of the receiver types actually used at a given call site. | |
2, The compiler can exploit this type information to generate better code when recompiling a method. |
Inline cache would result bad performance if cached type does not match given object type. False Cache Locality
Inline Cache(monomorphic) VS polymorphic VS megamorphic ( http://en.wikipedia.org/wiki/Inline_caching for simple explanation )
Type prediction, analysis and split may work in some scenarios.
Nevertheless, there are classes of variables and expressions that type analysis cannot analyze well. One such class is the types of arguments to the method (our SELFsystem customizes on the type of the receiver, but not on the type of arguments).
Another important class is the types of instance variables and array elements (actually, any assignable heap cell).
These weaknesses of type analysis can be quite damaging to the overall performance of the system, espe-
cially for typical object-oriented programs
dynamic compilation(dynamic translation): dynamically compiling and caching machine code.
L. Peter Deutsch and Alan Schiffman, “Efficient Implementation of the Smalltalk-80 System.” Proceedings of the 11th Symposium on the Principles of Programming Languages , Salt Lake City, UT,1984.
The dynamic compilation is the same concept as today's JIT that tries to compile bytecode into native code for performance benefit.
Assumption for inline cache in this paper is that: a message is send to object of type X, it is likely the object is still X next time.