当前位置:网站首页>IL Runtime
IL Runtime
2022-07-03 16:40:00 【Crossing the water and looking for the other shore】
- background
- iOS The reason why it can't be hotter
- Apple AppStore In the audit criteria of , It is expressly forbidden for applications to allocate memory with executable permissions
- with JIT The script virtual machine of function cannot run
- Unable to load dynamic link library
- Android Google Play mandatory 64 Bits must also be used IL2CPP 了
- Lua and il runtime Can explain and execute
- from 2015 R & D started in , Now the latest version is 2.0
- There are many online mmo, The card , leisure , Chess and card games use il runtime
- iOS The reason why it can't be hotter
2、 principle
C# Operating principle :c# The code is compiled into cil( Interlingua ), And then by cil Translate it into clr( common language ), Finally, it is compiled into the corresponding machine code
MSIL and MonoCecil Are two key class libraries
Realization principle :
Read dll Meta information of types and methods in , And in the method body il Assembly instruction , and dll Corresponding pdb Debug symbol file
After reading out the information to be modified , Make changes , And then write back to dll
======================================
3、 Concept note :
- about il runtime Come on ,dll It is an ordinary binary resource file , So it can be used assetbundle Compression or encryption ,( At the same time, it can also be used for the main project unity To reinforce )
- Il runtime The object created in is unmanaged memory , You need to manage your own memory , Memory operations can be performed through pointers
- Il runtime The interpreter of is a huge switch case Method , take c# Compiled intermediate assembly language for execution
- Il runtime There are two patterns , One is trestle vm, The other is register type vm
- The more assembly instructions , The lower the performance of the interpreter
- Plank type vm: The advantage is cross platform , The disadvantage is that there are many instructions
- register vm: The advantage is that there are fewer instructions ( Because it is associated with hardware ), The disadvantage is that it corresponds to a specific platform architecture ( Such as x86)
- I won't support it unsafe ,volatile,p/Invoke And other functions that need to deal with hardware or operating system
4、 Engineering structure
By the main project that does not need heat change and the heat change project of the heat change part , Two projects .
Before each bag , You need to export the heat change project as dll, Put it in the main project streamAsset Under the table of contents
5、il runtime Implementation details
- iType: all il runtime Base class of inner type
- iMethod: Base class of all methods
- ILTypeInstance: All instances are of this type
6、il runtime Use
- CLR Redirect
- Use of delegation
- Ctrip and asynchronous use
- Use of reflection interface
- Serialization Library
Be careful : Cross domain inheritance cannot inherit more , Otherwise, the corresponding adapter will not be found
7、 How the performance
- Il runtime vs lua ( The data ( Such as calculation , Native interface calls ) Are better than lua)
- The configuration table should be read on demand , Otherwise, it will occupy a lot of memory
- Il runtime 2.0 Register mode is added in , It can improve performance in Intensive Computing
- because il runtime There is a lazy loading mechanism , Therefore, we need to use the preheating mechanism to solve the problem of slow speed for the first time
- The heat change project calls the main project , The performance is higher than that of the main project , Therefore, the project structure should be reasonably planned ( Some framework underlying things can be placed in the main project , Some business logic or content that changes frequently is put in hot Engineering )
- Update The logic of should also be put in the main project , Call the thermal engineering through events
- Expensive independent algorithms , Such as physical calculation or routing algorithm , And other tool methods should be in the main project
- Foreach in Use value type , stay il runtime There will be frequent packing and unpacking operations , It can lead to gc The birth of
- Registering value type bindings will reduce gc Recycled calls
- Use... Correctly clr Binding will speed up execution
- Need to be in release Test in mode (editor There will be many auxiliary tools , It will affect the test results , perhaps debug There will also be a lot of debugging information processing in mode )
8、 Division of heat range
Main works :
Resource management , Scene management , Network message management ,ui frame , Battle frame , Common underlying components
agreement , Serialization and parsing
Sdk Integrate
Third party plug-ins
Hotter Engineering :
The business logic of the battle
Ui Business logic
agreement , Configuration table
Sdk Call logic
Be careful :
Cross module calls should use event dispatch to reduce coupling , Convenient for follow-up heat
Use link.xml Reserve main engineering interface
Used in events that need to be handled by the main project object Universal parameters of
Use xil Of aop The thermal repair scheme provides the minimum guarantee of the main engineering code
Don't use it more frequently in hot projects monobehaver, Because it will be designed to prefabricate and serialize the fields on the corresponding script , This part is in unity The engine layer is complex and the serialization interface is not open
边栏推荐
- NSQ source code installation and operation process
- 于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
- First knowledge of database
- Alibaba P8 painstakingly sorted it out. Summary of APP UI automated testing ideas. Check it out
- Page dynamics [2]keyframes
- Why does the std:: string operation perform poorly- Why do std::string operations perform poorly?
- 程序猿如何快速成长
- Interviewer: how does the JVM allocate and recycle off heap memory
- 线程池执行定时任务
- Hibernate的缓存机制/会话级缓存机制
猜你喜欢
TCP congestion control details | 3 design space
Add color to the interface automation test framework and realize the enterprise wechat test report
一台服务器最大并发 tcp 连接数多少?65535?
【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事
关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM
Threejs Part 2: vertex concept, geometry structure
Interviewer: how does the JVM allocate and recycle off heap memory
Record a jar package conflict resolution process
Basis of target detection (IOU)
Multithread 02 thread join
随机推荐
NSQ源码安装运行过程
Pointcut expression
What is the difference between 14Cr1MoR container plate and 14Cr1MoR (H)? Chemical composition and performance analysis of 14Cr1MoR
Basis of target detection (IOU)
Overview of satellite navigation system
word 退格键删除不了选中文本,只能按delete
Détails du contrôle de la congestion TCP | 3. Espace de conception
Processing strategy of message queue message loss and repeated message sending
Nifi from introduction to practice (nanny level tutorial) - flow
如何在本机搭建SVN服务器
Interviewer: how does the JVM allocate and recycle off heap memory
[combinatorics] polynomial theorem (polynomial coefficients | full arrangement of multiple sets | number of schemes corresponding to the ball sub model | polynomial coefficient correlation identity)
MySQL single table field duplicate data takes the latest SQL statement
JSON 与 BSON 区别
[combinatorics] non descending path problem (outline of non descending path problem | basic model of non descending path problem | non descending path problem expansion model 1 non origin starting poi
Cocos Creator 2. X automatic packaging (build + compile)
What kind of material is 14Cr1MoR? Analysis of chemical composition and mechanical properties of 14Cr1MoR
一台服务器最大并发 tcp 连接数多少?65535?
The mixlab editing team is recruiting teammates~~
斑马识别成狗,AI犯错的原因被斯坦福找到了