The JavaScript engine consists of the following parts:
First, the compiler. The main task is to compile the source code into an abstract syntax tree, and then, in some engines, to convert the abstract syntax tree into bytecode.
Second, the interpreter. In some engines, the interpreter mainly accepts bytecode, interprets execution of the bytecode, and then relies on the recovery mechanism.
Third, JIT tools. A tool that can JIT to convert bytecode or abstract syntax tree to cost code, of course it also needs to rely on remembering
Four, garbage collector and Analysis tool (Profiler). They are responsible for garbage collection and collection of information in the engine to help improve engine performance and effectiveness.
CEF3 is based on the chromium kernel, the JS engine used is V8. Google, for performance, directly eliminates the step of converting bytecode, and even uses JavaScript to compile cost-coded code directly. The V8 API not only provides the ability to compile and run JavaScript code, but also provides other functions that interact with C + +, including registration of functions and data structures, error handling, security checks, and so on. C + + applications can use V8 as a common class library, simply by referencing V8.h.
The context of V8 is a standalone JavaScript execution environment that allows JavaScript applications to run on different V8 instances by using contexts. Executing a section of JavaScript code must display the specified context. This is because JavaScript provides a series of built-in auxiliary functions and global objects that can be invoked and modified by JavaScript code. If two unrelated JavaScript code modifies the global object at the same time, it may result in the user not wanting to see the results. According to the V8 specification, the execution JavaScript function must be within the context, so before invoking the executefunction we must enter the context, which must be exited after execution. This feature is provided by Cefv8context, and the most important members are enter, Exist, eval, and so on.
Resources:
Understanding WebKit and Chromium:javascript engine introduction
http://blog.csdn.net/milado_nju/article/details/22101681
Chromium/content v8::extension
Https://github.com/fanfeilong/cefutil/blob/master/doc/content_register_v8_extension.md