当前位置:网站首页>[question] Compilation Principle
[question] Compilation Principle
2022-07-07 11:23:00 【Hua Weiyun】
Preface :
Author's brief introduction :, Focus on the bottom of the computer , Worked as a senior engineer in the back end of a financial company , Be good at high security in the trading field / You can use / Concurrent / Performance design and architecture
Java New star creators in the field 、 Alibaba cloud expert Blogger 、 Huawei cloud sharing expert
If this article is good , Please Focus on 、 give the thumbs-up 、 Collection The third company supports bloggers
Introduction to this article : Part 1 Reason out , Compilation principle is the process of translating high-level language into assembly language or machine language , In this chapter, we introduce the principle and process of compilation design in detail , And with Graal Compiler certification
One 、 What does the compilation process look like ?
First , Let's take a look at how human translation from English to Chinese is done , We need to find the , The meaning of the word , Analyzing the grammar of this sentence , Finally, translate this sentence into Chinese through semantics , The compilation process of our computer is similar to this process
We think of things like Java、PyThon、Go、C++ Language and so on cannot be operated directly ISA Instruction set ( As mentioned above ) Of , We also need a high-level language compile Into a unified assembly language ( One tool needed is , compiler ), Then call the assembly code process .
When I Java、Python、C++ Wait for the language , The compiler will pass Analyze morphology , for example if else wait , Construct according to the obtained words and parts of speech AST(AST: Abstract syntax tree (abstract syntax code,AST) Is the tree representation of the abstract syntax structure of the source code ), The resulting tree is a tree structure in which each node represents a kind of source code , Translate it into... Through semantics IR Language ( For example java Turn into .class Bytecode ), Finally, analyze and optimize according to the optimization strategy of the compiler ( for example JVM Instruction rearrangement in ) Get the target language
Two 、 Compilation fundamentals
After being familiar with the compilation process, we still need more knowledge points to support , Learn more through a few detailed questions , What are the defined grammars ? Since we want components AST, We need to define the syntax and word position of each compilation , So the coding information will be defined 、 Encoded word 、 Specify where words appear ; Definition ( distinguish ) What is the word ? The smallest unit of identification information
For what we need to do ( Compile high-level language into assembly language or machine language ) This process , We can understand that it takes three steps to put the elephant in the refrigerator , Open the refrigerator , Stuffed with elephants , Turn off the fridge. .
Compilation can also be divided into three steps front end -》 Interlingua -》 Back end , The front end is developed by front-end developers who need to access the current compiler , To adapt to multiple languages , The process is High level language source code -》 Lexical analysis -》 Syntax analysis -》 artifacts AST The process of -》 To intermediate language , Intermediate language decoupling , The back-end is developed by different back-end developers who need access to the current compiler , To adapt to multiple target machine languages (ISA), Get the intermediate language -》 Do analysis and optimization , Finally, the target language is generated .
3、 ... and 、 Explain profound theories in simple language Graal compiler
Understand the principle and process of compilation , We need to know who helped us do so much work , This tool is the compiler , Here we use the author Java Language ( You can also compile scala、python Other languages ) The compiler Graal Introduce the above principles
Graal compiler Support cross platform based Hot spotJVM Upper intermediate language IR Language —— Bytecode , All kinds of languages (Java、Python、R、JS、C/C++、Scala) Can be in JVM On the implementation , Can enjoy JVM A high performance .GC、 Platform and other features , The picture below is GraalVM Architecture diagram of compiler
1、Truffle Framework:Java's AST Interpreter Framework(Java Of AST Interpreter frame , This thing is a tool for converting various other languages into intermediate languages )
2、Graal Compiler :JIT compiler written in Java( use Java Compiling JIT compiler , It's a JIT Just in time compiler , It has achieved 3)
3、JVM CI (JVM Compiler Interface) Interface for Writing JIT Compiler in Java(JVM Compiler interface , Is an interface specification , Defined JIT Specification of just in time compiler )
4、Java Hotspot VM( This is what we commonly call JVM)
5、JIT( Just in time compiler ), This implements the front-end and back-end of the compilation principle , Just dynamically compile the language in memory
Graal Is and JDK Together with , As an internal module jdk.internal.vm.compiler in .Graal and JVM It's through JVM CI(JVM Compiler Interface) Come on communicate Of . among JVM CI It is also an internal module in jdk.internal.vm.ci in . Here is a brief introduction to the compiler proof compilation process , And how the compiler should be designed , Later, the author will explain the principle of compiler in detail .
This paper summarizes : In this chapter, we first translate what we should do in English , Reasoning out , Compilation principle of computer , And the principle and process of compiling design are introduced in detail , Zoe Graal Compiler certification .
边栏推荐
- Mpx 插件
- When initializing 'float', what is the difference between converting to 'float' and adding 'f' as a suffix?
- Poj1821 fence problem solving Report
- Interprocess communication (IPC)
- JS add spaces to the string
- 学习笔记|数据小白使用DataEase制作数据大屏
- Rolling puddle Uni_ App (VIII)
- Verilog realizes nixie tube display driver [with source code]
- audit 移植
- JSON format query of MySQL
猜你喜欢

Verilog 实现数码管显视驱动【附源码】

关于SIoU《SIoU Loss: More Powerful Learning for Bounding Box Regression Zhora Gevorgyan 》的一些看法及代码实现

在我有限的软件测试经历里,一段专职的自动化测试经验总结

How to use cherry pick?

Shardingsphere sub database and table examples (logical table, real table, binding table, broadcast table, single table)

Using ENSP to do MPLS pseudo wire test

Design intelligent weighing system based on Huawei cloud IOT (STM32)
![Verilog design responder [with source code]](/img/91/6359a2f3fa0045b4a88956a475488c.png)
Verilog design responder [with source code]

RationalDMIS2022阵列工件测量

Basic knowledge of process (orphan, zombie process)
随机推荐
Audit migration
聊聊SOC启动(九) 为uboot 添加新的board
使用MeterSphere让你的测试工作持续高效
Input type= "password" how to solve the problem of password automatically brought in
Rolling puddle Uni_ App (VIII)
Antd select selector drop-down box follows the scroll bar to scroll through the solution
Add a self incrementing sequence number to the antd table component
关于SIoU《SIoU Loss: More Powerful Learning for Bounding Box Regression Zhora Gevorgyan 》的一些看法及代码实现
Briefly introduce closures and some application scenarios
Une fois que l'uniapp a sauté de la page dans onlaunch, cliquez sur Event Failure resolution
Socket socket programming
Distributed database master-slave configuration (MySQL)
基于Retrofit框架的金山API翻译功能案例
Verilog 实现数码管显视驱动【附源码】
VIM命令模式与输入模式切换
How to use cherry pick?
Cmake learning manual
Static semantic check of clang tidy in cicd
Qt|多个窗口共有一个提示框类
vim 的各种用法,很实用哦,都是本人是在工作中学习和总结的




