0x7CFE / llst

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

Research the possibilities of statistically assisted type inference #17

Open 0x7CFE opened 11 years ago

0x7CFE commented 11 years ago

In statically typed environments Hindley-Milner algorithm may be used to infer the types of expression depending on it's parts. The question is, may this idea be applied to the Smalltalk's pure dynamic environment?

In case of JIT VM we have statistics of which call site affect what classes and potentionally object of what class is returned. Gathering this information we may find a places (call sites and methods) with classes tightly bound to one or more variables. If particular variable appeared to have only one class during the whole runtime, we may then perform an optimization that assumes that current variable always have this class. Thus, specializing the method. Inside, we may treat class as a statically assigned type. This allows us to apply type infering where it is possible.