From webcore to V8, V8 engine webcore
I don't want to talk about V8 here. Please use Baidu. Since we have developed webkit by ourselves, subsequent V8 learning and research will be based on the combination of webkit and V8 (currently we have not studied blink, but simply changed the official JavaScriptCore engine of webkit to V8 ), not purely V8.
Here we will only introduce the webcore entry
Starting with the webcore js entry, there is a function in html lexical parsing:
Bool HTMLDocumentParser: canTakeNextToken (SynchronousMode mode, PumpSession & session)
This will determine whether to continue parsing, where:
// If we're paused waiting for a script, we try to execute scripts before continuing.
Bool shouldContinueParsing = runScriptsForPausedTreeBuilder ();
Here is the resolution entry. continue until a void ScriptElement: executeScript (const ScriptSourceCode & sourceCode) function of the dom module.
Void ScriptElement: executeScript (const ScriptSourceCode & sourceCode)
{
ASSERT (m_alreadyStarted );
If (sourceCode. isEmpty ())
Return;
If (! M_isExternalScript &&! M_element-> document ()-> contentSecurityPolicy ()-> allowInlineScript ())
Return;
RefPtr <Document> document = m_element-> document ();
ASSERT (document );
If (Frame * frame = document-> frame ()){
{
IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer (m_isExternalScript? Document. get (): 0 );
// Create a script from the script element node, using the script
// Block's source and the script block's type.
// Note: This is where the script is compiled and actually executed.
Frame-> script ()-> evaluate (sourceCode );
}
Document: updateStyleForAllDocuments ();
}
}
Now, the comments have been clearly written. From here, we will leave webcore to prepare for entering the js engine.
Frame-> script ()-> evaluate (sourceCode); call the scriptcontroler of the binding module to enter the binding module, the binding module JSC has a lot of similarities with V8. Next, I will analyze the binding module of v8.