Android深入浅出系列课程---Lesson13 LLY110529_虚拟机概述,JIT概述

本文介绍虚拟机的基本概念及其重要性,包括系统虚拟机和进程虚拟机的区别,并探讨了Java虚拟机(JVM)的特点及Java Just-In-Time(JIT)编译器如何提升程序执行效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 大家好,上一讲我们介绍了Android.Framework源码下载及编译,这一讲我们将进入虚拟机概述,JIT概述
        课程目标:
知道虚拟机的概念,JVM , JIT
        重点难点:        
虚拟机带来的好处
        考核目标:
C++ 和 Java编译上的区别   应用层代码不修改,为何有时候可以编译过,有时候编译不过 ?
        什么是虚拟机?
一种抽象,一种仿真
虚拟机(Virtual Machine)指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整计算机系统。
An efficient, isolated duplicate of a real machine. –Popek and Goldberg 1974

System virtual machine:一个系统的仿真和抽象,可供一个或多个操作系统在上面运行。Eg: VM Ware, QEMU, KVM
虚拟机指令集可与硬件CPU指令不同
提供隔离isolation

Process virtual machine:只供一个进程的仿真执行 Eg:JVM(Java Virtual Machine), Microsoft .NET
提供可移植性(portability)
WORA, Write once, run anywhere. --Slogan of Sun Microsystem
虚拟的机器:4G内存,标准的IO
        什么是JVM
Lesson13=1.jpg
2011-11-7 10:33:28 上传
下载附件 (19.31 KB)

WORA: Write Once, Compile once, run everywhere
应用程序和Bytecode编译器独立于硬件(machine-independent)

虚拟机软件仿真要实现指令集转换,虚拟地址物理地址的转换,代价慢!Java刚问世时比C/C++ 慢20X+

        什么是JIT
改进:实时编译JIT(Just in Time) compiler
只有新的Bytecode指令需要编译
A typical program with loops and repeated function calls should execute 10x faster using JIT.
No free lunch:需要储存空间,占内存(memory footprint)

啥叫实时? 编译什么? When and What to compile?
Method invoke time? Instruction fetch time? Application launch time?
Whole program?  A page?  Method?  Single instruction?

A compiler's primary function is to compile, organize the compilation, and go right back to compiling. It compiles basically only those things that require to be compiled, ignoring things that should not be compiled. The main way a compiler compiles, is to compile the things to be compiled until the compilation is complete.
        汇编器,链接器,加载器
汇编器(Assembler): 转换标签(Tag)为偏移量(offset),汇编语言的IDE,
链接器(Linker):多个目标文件和库变为一个可执行文件或新的库
Lesson13-2.jpg
2011-11-7 10:33:29 上传
下载附件 (6.68 KB)

静态vs动态链接
编译过的常用库二进制码只存一处 
更新方便,but … DLL Hell

加载器(Loader):加载到内存:execve().
本讲对虚拟机概述,JIT概述,下一讲将进入Handler-不可缺少的异步_
上,内容预告:AFF110529_Handler-不可缺少的异步_上,敬请期待。


特别推荐新课程:Android开发高端课程
http://www.mobidever.com/forum.php?mod=viewthread&tid=2098
本课视频地址:http://www.tudou.com/programs/view/eMFpniJRUJY/  (土豆网)
课程下载地址:http://www.verycd.com/topics/2900036/ (VeryCD电驴)
作者博客:http://www.mobidever.com/forum.php (Sundy-Android开发联盟)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值