Find your content:

Search form

Learn nodejs -simple way - How v8 engine optimize the code?

 
Share

Inlining

The first optimization is inlining as much code as possible in advance. Inlining is the process of replacing a call site with the body of the called function. Check the below image.

 

Inline caching

Lets look at the below code snippet.

function display(user){
	return "Welcome "+user;
}

var user = "John Smith";
display(user);
display(user);
display(user);
display(user);
// Engine just assumes display equals "Welcome John Smith";
// To save time and caches display method
display(user);
display(user);
display(user);

 

If you are a advanced user and learn more about how Google v8 engine works, please click here.

 

My Block Status

My Block Content