EECS 768 Virtual Machines 1
High-Level Language VM – Outline
- Introduction
- Virtualizing conventional ISA Vs. HLL VM ISA
- Pascal P-code virtual machine
- OO HLL virtual machines
– properties, architecture, terms
- Implementation of HLL virtual machine
High-Level Language VM Outline Introduction Virtualizing - - PowerPoint PPT Presentation
High-Level Language VM Outline Introduction Virtualizing conventional ISA Vs. HLL VM ISA Pascal P-code virtual machine OO HLL virtual machines properties, architecture, terms Implementation of HLL virtual machine
EECS 768 Virtual Machines 1
EECS 768 Virtual Machines 2
HLL Program Intermediate Code Memory Image Object Code (ISA) Compiler front-end Compiler back-end Loader HLL Program Portable Code ( Virtual ISA ) Host Instructions
Compiler VM loader VM Interpreter/Translator Traditional HLL VM
EECS 768 Virtual Machines 3
EECS 768 Virtual Machines 4
EECS 768 Virtual Machines 5
EECS 768 Virtual Machines 6
EECS 768 Virtual Machines 7
EECS 768 Virtual Machines 8
EECS 768 Virtual Machines 9
EECS 768 Virtual Machines 10
EECS 768 Virtual Machines 11
EECS 768 Virtual Machines 12
EECS 768 Virtual Machines 13
EECS 768 Virtual Machines 14
EECS 768 Virtual Machines 15
EECS 768 Virtual Machines 16
Metadata Code Machine Independent Program File Loader Virtual Machine Implementation Interpreter Internal Data Structures Translator Native Code
EECS 768 Virtual Machines 17
Public File
Remote System
Other File
Local System
Accessible Local File application VMM Other Local File Network User Process Sandbox Boundary
EECS 768 Virtual Machines 18
class file class file class file class file
Emulation Engine loader
native method native method lib. method lib. method loaded method loaded method loaded method loaded method loaded method loaded method
Network, File System trusted
trusted trusted
local file
security agent
trusted
local file
standard libraries
EECS 768 Virtual Machines 19
Binary Class hash encrypt Transmit Binary Class Signed Hash hash decrypt private key public key compare match => signature OK
EECS 768 Virtual Machines 20
Method 1 Method 2 Method 3 Method 4 System System Untrusted Untrusted principal Full Full Write A
Write B
permissions Method 5 (in io API) System Full Check Method System Full
Inspect Stack
prohibited
X
EECS 768 Virtual Machines 21
EECS 768 Virtual Machines 22
EECS 768 Virtual Machines 23
EECS 768 Virtual Machines 24
EECS 768 Virtual Machines 25
EECS 768 Virtual Machines 26
Operands
Locals
Object Object Object index implied index Array implied
HEAP
Instruction stream
STACK FRAME CONSTANT POOL
index
EECS 768 Virtual Machines 27
index
index1 index2
data
data1 data2
EECS 768 Virtual Machines 28
EECS 768 Virtual Machines 29
EECS 768 Virtual Machines 30
iload A //push int. A from local mem. iload B //push int. B from local mem. If_cmpne 0 else // branch if B ne 0 iload C // push int. C from local mem. goto endelse else: iload F //push F endelse: add // add from stack; result to stack istore D // pop sum to D
EECS 768 Virtual Machines 31
iload B // push int. B from local mem. If_cmpne 0 skip1 // branch if B ne 0 iload C // push int. C from local mem. skip1: iload D // push D iload E // push E if_cmpne 0 skip2 // branch if E ne 0 add // add stack; result to stack skip2: istore F // pop to F
EECS 768 Virtual Machines 32
EECS 768 Virtual Machines 33
Magic Number Version Information Constant Pool
Access Flags This Class Super Class Interfaces Interface Count Field Information Field count Methods count Methods Attributes Count Attributes
EECS 768 Virtual Machines 34
EECS 768 Virtual Machines 35
method area heap Java stacks native method stacks
Memory
Class Loader Subsystem
class files native method libraries
addresses data & instructions Execution Engine
PCs & implied regs native method interface
Garbage Collector
EECS 768 Virtual Machines 36
EECS 768 Virtual Machines 37
Global Memory Objects with statically defined(fixed) types Local Storage Operand Storage Declared (fixed) types Tracked types Load: type determined from reference/field type Store: must be to reference and field with correct types Move to local storage: must be to a location with correct type Move to operand stroage: type determined from local storage type ALU tracked types Array loads are range checked Array stores are range checked
EECS 768 Virtual Machines 38
EECS 768 Virtual Machines 39
EECS 768 Virtual Machines 40
EECS 768 Virtual Machines 41
EECS 768 Virtual Machines 42
Java HLL Program Compile and Load Bytecode Methods
array getfield/ putfield C Program Compile and Load Native Machine Code invoke native method Native Data Structures load/store
Java Side Native Side
JNI get/put
EECS 768 Virtual Machines 43
EECS 768 Virtual Machines 44
. . .
Root Set Global Heap A B D C E F H G
EECS 768 Virtual Machines 45
EECS 768 Virtual Machines 46
EECS 768 Virtual Machines 47
A B C D E F G H free A B C E G free
EECS 768 Virtual Machines 48
A B C D E F G H free unused A B C E G free unused
EECS 768 Virtual Machines 49
Global Heap
(e.g. on stack) Handle Pool Object Pool A B
EECS 768 Virtual Machines 50
EECS 768 Virtual Machines 51
EECS 768 Virtual Machines 52
. . .
Root Set A B D C
. . .
A B D C Root Set
EECS 768 Virtual Machines 53