Basic understanding of Flutter

After five years of development, I have never had the habit of blogging. Recently, something happened to realize the importance of recording and sharing. The following are the notes I took when I was studying a year ago, which is equivalent to moving a place to save~

Flutter: A mobile application SDK, including framework tools and Widgets. No webView or native controls of the operating system are used. Use your own high-performance rendering engine (Skia) to draw widgets. The core has only one layer of lightweight C/C++ code.

Run on Android. The C/C++ code of the engine is compiled with Android's NDK. Any Dart code is AOT compiled into local code. Flutter applications run using the native instruction set (no interpreter involved)

Running on iOS, the engine's C/C++ code is compiled with LLVM, and any Dart code is compiled into native code by AOT. Flutter applications run using the native instruction set (no interpreter involved)

Additional explanation:

JIT (Just-In-Time-Just-In-Time Compilation) and AOT (Ahead-Of-Time-Pre-Compilation)

There are two types of Android virtual machines: Dalvik and ART ( android runtime ) . JIT and AOT are different compilation strategies used by virtual machines to improve operating efficiency .

JIT means Just In Time Compiler , which is just-in- time compilation technology , dynamic compilation. Related to the Dalvik virtual machine. The introduction of JIT has improved Dalvik's performance by 3~6 times.

JIT defect : You need to recompile every time you start the application (no cache)

AOT is static compilation, and ART (android runtime) 5.0 will be used to replace Dalvik.

Defects of AOT : application optimization after application installation and system upgrade is time-consuming (recompile, convert program code into machine language)

                      Optimized files will take up additional storage space (caching conversion results)

Coexistence of JIT and AOT

On Android 7.0, the JIT compiler is used again, adopting the AOT/JIT hybrid compilation strategy, which features:

When the app is installed, the dex will not be compiled again. When the app is running, the dex file will be executed directly through the parser. The hot functions will be identified and compiled by the JIT and stored in the jit code cache and a profile file will be generated to record the hot functions Information. When the phone enters IDLE (Idle) or Charging (Charging) state, the system will scan the profile file in the App directory and execute the AOT process to compile it.

to sum up:

Dalvik and ART are two operating environments of Android, which can also be called Android virtual machines. JIT and AOT are two different compilation strategies adopted by the Android virtual machine.

The Dart runtime and compiler support a combination of two key features of Flutter:

JIT-based rapid development cycle : Flutter adopts the JIT mode in the development phase, which avoids compiling every change and greatly saves development time;

AOT-based release package : Flutter can generate efficient ARM code through AOT during release to ensure application performance. JavaScript does not have this capability.

 

Guess you like

Origin blog.csdn.net/guoyingmiss/article/details/110817977