V8 JavaScript Engine

Posted: June 14, 2012 in Uncategorized

In my last few blog posts I focused on, Event-Driven Programming, JavaScript and Node.JS. Now let’s see actually this works. The JavaScript Engine is an interpreter that executes the JavaScript. These engines are most of the time used in the web browsers; each one has its own engine like for example the IE has its codename “Chakra” and for Chrome the V8. And here comes the topic of this blog post the V8.

The V8 is a very powerful engine developed by Google; it is mainly developed using C++. The main reason I am talking about the V8 is that the Node JS is based on V8. So I tried to understand how the parallelism of the incoming request is done using it. V8 is an open source engine you can work on it and learn more about it from this link. In the coming part I will try to show out how the V8 engine works and how I think this can help the cloud with solving the problem of handling the increasing number of connections.

The V8 is mainly composed of 3 things: Handle, Scope and Context. I won’t take long explaining them, but for more information you can visit this webpage. However I will explain the 3, I won’t go in deep. The first thing is the handle; this is the one responsible for pointing on the objects. The handle is also divided into 2 things, the local handle and the persistent handle. The first one is created when there is a function call, the persistent one is created and deleted when specified, this handle mainly deals with the DOM.

The Scope is the container of the handles according to this website.

For the Context this is the environment that interprets the JavaScript and executes it, one of the important things it offers is that it allows multiple JavaScript code to run in a single instance of the V8 engine.

After Explaining the main components of the V8 so far, let us try to clarify how this works for the Node JS especially it is based on V8. JavaScript running on the server side, there is no DOM to deal with but only with incoming traffic to execute the required functions and return the result. So I imagine is that with each incoming request rather than executing and creating a new context it allows you some of the incoming traffic to share the same context so executing the functions more faster.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s