# 2.0 - V8 Pipeline

## 0. Compiler pipeline

Source: JavaScript Start-up Performance by Addy Osmani

Take the following function for example,

function add(x, y) {
return x + y;
}

for (var i = 0; i < 1000000; ++i) {
}


The add function was called so many times that V8 marks it as “hot”. So Turbofan will come in to optimize this function and produce machine code. Since add has only been called with smi arguments, Turbofan can produce machine code that only works for small integers.
Later, add("hello", "world") was called. Now the arguments are no longer smis, hence the assumption that the arguments are smis is invalid, and so V8 will deoptimize and fall back to bytecode.