在文件compiler/dex/quick/quick_compiler.cc中取消 kCompilerDebugFlags 的注释,重新在根目录下编译,替换启动盘中相应的动态库。
用eclipse写一个Helloworld程序安装到android系统中,或者在 /data/dalvik-cache/ 目录下删除一个应用程序的oat文件(classes.dex文件),重启系统。根据Logcat日志查看dex2oat调用路径。
一.ART 的 interpret-only 模式执行路径:
int main(...) --> art::dex2oat(...) --> CompileApp(dex2oat) --> dex2oat.Compile() --> driver_->CompileAll(...) --> Compile(...) --> CompileDexFile(...) --> context.ForAll(...) -->
CompilerDriver::CompileClass(...) --> driver->CompileMethod(...) --> (*dex_to_dex_compiler)(...) --> ArtCompileDEX(...) --> dex_compiler.Compile()
在dex_compiler.Compile()函数中有四类操作码的替换:
CompileReturnVoid(...): 在需要 barrier 的地方将 RETURN-VOID 替换为 RETURN-VOID-BARRIER。
CompileCheckCast(...): 将 CHECK-CAST 替换为 2 个 NOP 指令。
CompileInstanceFieldAccess(...): 将获取字段的方式由通过索引获取替
用eclipse写一个Helloworld程序安装到android系统中,或者在 /data/dalvik-cache/ 目录下删除一个应用程序的oat文件(classes.dex文件),重启系统。根据Logcat日志查看dex2oat调用路径。
一.ART 的 interpret-only 模式执行路径:
int main(...) --> art::dex2oat(...) --> CompileApp(dex2oat) --> dex2oat.Compile() --> driver_->CompileAll(...) --> Compile(...) --> CompileDexFile(...) --> context.ForAll(...) -->
CompilerDriver::CompileClass(...) --> driver->CompileMethod(...) --> (*dex_to_dex_compiler)(...) --> ArtCompileDEX(...) --> dex_compiler.Compile()
在dex_compiler.Compile()函数中有四类操作码的替换:
CompileReturnVoid(...): 在需要 barrier 的地方将 RETURN-VOID 替换为 RETURN-VOID-BARRIER。
CompileCheckCast(...): 将 CHECK-CAST 替换为 2 个 NOP 指令。
CompileInstanceFieldAccess(...): 将获取字段的方式由通过索引获取替