Just curious - Artificial Intelligenece in Compilation

Hi,

I am just curious. Is it possible to embed Artificial
Intelligence inside compiler? So as the program gets executed,
the A.I looks at it and optimizes the byte code next time so
that every run becomes little more efficient?

Say I code a function add(a, b), as it runs, the A.I will know
that a and b are mostly Integer, so with that info it can
optimize the byte code. Like strategy algorithm it can pick up
the best byte code for given inputs thus making execution faster.

This specific optimization is called *Dynamic Type Inference*,
*Dynamic Type Feedback*, *Dynamic Specialization* or something
similar. It was pioneered in the Smalltalk community (more
precisely, in the Self VM) in the 1980s and is a standard
optimization technique for modern high-performance adaptive
dynamic execution engines such as HotSpot or V8 (both of which
were actually developed by the same people as the Self VM).

In the Ruby community, at least Rubinius, TruffleRuby, JRuby,
IronRuby, MagLev, and Topaz do it.

Other, related, optimizations of this kind are *Speculative
Inlining* and *Inline Caching*.

It has nothing whatsoever to do with AI, though.

jwm

I am just curious. Is it possible to embed Artificial
Intelligence inside compiler? So as the program gets executed,
the A.I looks at it and optimizes the byte code next time so
that every run becomes little more efficient?

As Jörg said, no AI needed for that. And btw, it is not "in
compilation" at all. The point is that all these things happen at
runtime.

Say I code a function add(a, b), as it runs, the A.I will know
that a and b are mostly Integer, so with that info it can
optimize the byte code. Like strategy algorithm it can pick up
the best byte code for given inputs thus making execution faster.

This specific optimization is called *Dynamic Type Inference*,
*Dynamic Type Feedback*, *Dynamic Specialization* or something
similar. It was pioneered in the Smalltalk community (more
precisely, in the Self VM) in the 1980s and is a standard
optimization technique for modern high-performance adaptive
dynamic execution engines such as HotSpot or V8 (both of which
were actually developed by the same people as the Self VM).

In the Ruby community, at least Rubinius, TruffleRuby, JRuby,
IronRuby, MagLev, and Topaz do it.

Other, related, optimizations of this kind are *Speculative
Inlining* and *Inline Caching*.

The JVM also does a lot of these things including JIT. Other keywords
to google for "managed code".

Kind regards

robert

···

On Sat, Jun 10, 2017 at 11:30 AM, Jörg W Mittag <ruby-talk@joergwmittag.de> wrote:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/