Java Byte Codes (0xCAFEBABE) cs205: engineering software

Slides:



Advertisements
Similar presentations
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Advertisements

1 Lecture 10 Intermediate Representations. 2 front end »produces an intermediate representation (IR) for the program. optimizer »transforms the code in.
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
BA1 JVM arkitektur BA2 Specifikation I The Java Virtual Machine Specification specificeres bl.a.: –De grundlæggende datatyper.
1 1 Lecture 14 Java Virtual Machine Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Instruction Set Architecture & Design
Intermediate code generation. Code Generation Create linear representation of program Result can be machine code, assembly code, code for an abstract.
JETT 2003 Java.compareTo(C++). JAVA Java Platform consists of 4 parts: –Java Language –Java API –Java class format –Java Virtual Machine.
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
Consider With x = 10 we may proceed as (10-1) = 9 (10-7) = 3 (9*3) = 27 (10-11) = -1 27/(-1) = -27 Writing intermediates on paper.
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
5/6/99 Ashish Sabharwal1 JVM Architecture n Local storage area –Randomly accessible –Just like standard RAM –Stores variables (eg. an array) –Have to specify.
Code Generation Introduction. Compiler (scalac, gcc) Compiler (scalac, gcc) machine code (e.g. x86, arm, JVM) efficient to execute i=0 while (i < 10)
Intro to Java The Java Virtual Machine. What is the JVM  a software emulation of a hypothetical computing machine that runs Java bytecodes (Java compiler.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 18: 0xCAFEBABE (Java Byte Codes)
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Application Security Tom Chothia Computer Security, Lecture 14.
1 The Java Virtual Machine Yearly Programming Project.
Krakatoa: Decompilation in Java “Does Bytecode Reveal Source?” Todd A. Proebsting Scott A. Watterson The University of Arizona Presented by Karl von Randow.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 19: Security in Java Real or.
Machine Instruction Characteristics
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Java Bytecode What is a.class file anyway? Dan Fleck George Mason University Fall 2007.
Lecture 10 : Introduction to Java Virtual Machine
Roopa.T PESIT, Bangalore. Source and Credits Dalvik VM, Dan Bornstein Google IO 2008 The Dalvik virtual machine Architecture by David Ehringer.
5-1 Chapter 5 - Languages and the Machine Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of Computer.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
1 cs205: engineering software university of virginia fall 2006 Forgiveness and Permissions.
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
Prof. Fateman CS 164 Lecture 281 Virtual Machine Structure Lecture 28.
Programming Languages
More on MIPS programs n SPIM does not support everything supported by a general MIPS assembler. For example, –.end doesn’t work Use j $ra –.macro doesn’t.
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
Programming Languages and Paradigms Activation Records in Java.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 18: Code Safety and Virtual Machines
1ADS Lecture 11 Stacks contd.. ADS Lecture 113 Singly Linked list-based Stack Top of stack is head of list (can insert elements at head in constant.
What is a program? A sequence of steps
UNDER THE HOOD: THE JAVA VIRTUAL MACHINE II CS2110 Fall 200 Lecture 25 1.
RealTimeSystems Lab Jong-Koo, Lim
1 cs205: engineering software university of virginia fall 2006 Running Untrustworthy Code Project team requests: extended until 11pm tonight.
Computer Architecture Instruction Set Architecture
The Java Virtual Machine (JVM)
A Closer Look at Instruction Set Architectures
The Stack.
CS216: Program and Data Representation
Stacks.
Java package classes Java package classes.
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
CS 153: Concepts of Compiler Design November 2 Class Meeting
Chapter 10 The Stack.
CS 11 C track: lecture 8 Last week: hash tables, C preprocessor
CS216: Program and Data Representation
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Lecture 4: MIPS Instruction Set
Security in Java Real or Decaf? cs205: engineering software
CSc 453 Interpreters & Interpretation
Lecture 19: 0xCAFEBABE (Java Byte Codes) CS201j: Engineering Software
Memory Allocation CS 217.
Processor Organization and Architecture
September 5 Fang-Yi’s Office Hours Friday 10am  12pm (and another TBD) Programming Language Issues (JAVA vs. C, Pointers vs. Arrays) Representations Instructions.
Byte Code Verification
ECEG-3202 Computer Architecture and Organization
Classification of instructions
ECEG-3202 Computer Architecture and Organization
Lecture 18: Deep C Garbage Collection CS201j: Engineering Software
CMPE 152: Compiler Design April 11 Class Meeting
8051 ASSEMBLY LANGUAGE PROGRAMMING
CSc 453 Interpreters & Interpretation
August 31 addresses Drop box Questions? 31 August 2004
Presentation transcript:

Java Byte Codes (0xCAFEBABE) cs205: engineering software university of virginia fall 2006 Java Byte Codes (0xCAFEBABE)

Program Execution Reference Monitor Monitor Program Speakers Network SuperSoaker 2000 Monitor Reference Monitor Program Disk Memory Network

Java Bytecode Verifier malcode.class JVML Object Code Trusted Computing Base Java Bytecode Verifier Invalid Alice User “Okay” STOP JavaVM resource

Java Virtual Machine

Java Virtual Machine Small and simple to implement All VMs will run all programs the same way Secure

Implementing the JavaVM load class into memory set the instruction pointer to point to the beginning of main do { fetch the next instruction execute that instruction } while (there is more to do); Some other issues we will talk about later... (e.g., Garbage collection – need to reclaim unused storage)

Java Byte Codes Stack-based virtual machine Small instruction set: 202 instructions (all are 1 byte opcode + operands) Intel x86: ~280 instructions (1 to 17 bytes long!) Memory is typed (but imprecisely) Every Java class file begins with magic number 3405691582 = 0xCAFEBABE in base 16

Stack-Based Computation push – put something on the top of the stack pop – get and remove the top of the stack Stack push 2 2 5 push 3 3 add Does 2 pops, pushes sum

Some Java Instructions Opcode Mnemonic Description nop Does nothing 1 aconst_null Push null on the stack 3 iconst_0 Push int 0 on the stack 4 iconst_1 Push int 1 on the stack …

Some Java Instructions Opcode Mnemonic Description 18 ldc <value> Push a one-word (4 bytes) constant onto the stack Constant may be an int, float or String ldc “Hello” ldc 205 The String is really a reference to an entry in the string constant table! The strange String semantics should make more sense now.

Arithmetic Opcode Mnemonic Description 96 iadd Pops two integers from the stack and pushes their sum iconst_2 iconst_3 iadd

Arithmetic Opcode Mnemonic Description 96 iadd 97 ladd … 106 fmul 119 Pops two integers from the stack and pushes their sum 97 ladd Pops two long integers from the stack and pushes their sum … 106 fmul Pops two floats from the stack and pushes their product 119 dneg Pops a double from the stack, and pushes its negation

Java Byte Code Instructions 0: nop 1-20: putting constants on the stack 96-119: arithmetic on ints, longs, floats, doubles What other kinds of instructions do we need?

Other Instruction Classes Control Flow (~20 instructions) if, goto, return Method Calls (4 instructions) Loading and Storing Variables (65 instructions) Creating objects (1 instruction) Using object fields (4 instructions) Arrays (3 instructions)

Charge Project ideas: I will get back to you by next class (or sooner) Monday: Quiz 4 Will cover through Friday’s lecture on the Java bytecode verifier