[The JavaScript Journey]

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/95bc3d51-58b3-43b6-b703-4fe5416eed5b/Untitled.png

[Parsing JavaScript]

[Function Inlining - Turbofan의 최적화 예]

// 쓴 코드

const square = (x) => { return x * x }

const callFunction100Times = (func) => {
  for(let i = 0; i < 100; i++) {
    // the func param will be called 100 times
    func(2)
  }
}

callFunction100Times(square)

// V8엔진이 최적화 해버린 코드

const square = (x) => { return x * x }

const callFunction100Times = (func) => {
  for(let i = 100; i < 100; i++) {
    // the function is inlined so we don't have 
    // to keep calling func
    return x * x
  }
}

callFunction100Times(square)

Function inlining gotcha