Facebookhipmo-phpvm implementation overview (2) from the above, we can see that the core runtime environment code is in src/runtme/eval. This article mainly gives a brief overview of the code implementation here. the following descriptions are classified by folders. 1. runtime: core data structure (symbol table) during runtime 1. assoc_list.cpp & nb facebook hiphop php vm implementation overview (2)
We can see from the above that the code of the core runtime environment is in src/runtme/eval. This article mainly briefly describes the code implementation here, and the following description is classified by folder.
1. runtime: core data structure during running (symbol table)
1. assoc_list.cpp variable Association table
2. code_coverage.cpp Code Coverage Tool
3. jit cache of file_repository.cpp php file
4. variable_environment.cpp maintains the environment (such as the class and scope) of each function and variable)
5. variant_stack.cpp variable stack structure (can be used to record the function call relationship)
6. the most important runtime information of eval_state.cpp is collected here, such as the current objects, the methods, global functions, and constants of each object ......
7. eval_object_data.h records the information of a class.
8. a stack frame in the eval_frame_injection.h function call
II. ext
This directory encapsulates methods for adding external functions to the runtime,
III. parser
Parser implemented by YACC (the EBNF syntax file is hphp. y, hphp. tab. cpp is generated by a tool). This parser is different from the compiler directory. here it mainly serves semantic parsing (which can be understood as TreeWalker ). For hiphop php vm, semantic processing is to map php code to c ++ code (a large number of external functions are required for runtime ).
1. Overview of hphp. y
Grammar start symbol: start
Processing of file inclusion relationships and statement addition in src/runtime/eval/parser. cpp, the output of onXXX () is an AST, and the top node is statement.
4. debugger uses the socket-implemented debugger
Finally, the real start is void DebuggerProxy: processInterrupt (required interrupt & cmd)
V. base
Basic data structure statement
VI. ast
Perform semantic processing on the AST parsed by parser (that is, convert php code to c ++ code for each layer of tree node)
The unified interface for each statement is
Virtual Statement * optimize (VariableEnvironment & env) {return NULL;} // optimization Statement
Virtual void eval (VariableEnvironment & env) const = 0; // process the statement relationship
Virtual void byteCode (ByteCodeProgram & code) const ;//
Dump (std: ostream & out) const = 0; // Output c ++ code
PS:
Eval: The Inheritance structure developed by Construct is beautifully written.
VII. Scope of analysis
8. runtime semantic processing is the main process for translating php to c ++.
Eval. cpp Variant eval (LVariableTable * vars, CObjRef self, CStrRef code_str, bool prepend_php/* = true */)
9. implementation of function calls
Basic idea of function calling: Find the execution environment information such as object, method, and variable based on the symbol table information, and create a thread stack frame each time a function is entered, convert php function calls to the execution logic of external functions
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.