- Applet java appaiono di frequente nelle pagine web - Come funziona l'interprete contenuto in ogni browser di un certo livello? - Per approfondire



Similar documents
Lecture 32: The Java Virtual Machine. The Java Virtual Machine

02 B The Java Virtual Machine

picojava TM : A Hardware Implementation of the Java Virtual Machine

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

Chapter 7D The Java Virtual Machine

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Habanero Extreme Scale Software Research Project

Under the Hood: The Java Virtual Machine. Lecture 24 CS 2110 Fall 2011

1 The Java Virtual Machine

General Introduction

The Java Virtual Machine (JVM) Pat Morin COMP 3002

C Compiler Targeting the Java Virtual Machine

Programming the Android Platform. Logistics

University of Twente. A simulation of the Java Virtual Machine using graph grammars

The Hotspot Java Virtual Machine: Memory and Architecture

Inside the Java Virtual Machine

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Real-time Java Processor for Monitoring and Test

Restraining Execution Environments

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Prototyping Faithful Execution in a Java Virtual Machine

Java and Java Virtual Machine Security

CSCI E 98: Managed Environments for the Execution of Programs

Hardware/Software Co-Design of a Java Virtual Machine

CSC 8505 Handout : JVM & Jasmin

Java Virtual Machine, JVM

System Structures. Services Interface Structure

Security Architecture and Verification of Java Bytecode

Structural Typing on the Java Virtual. Machine with invokedynamic

Roos Instruments, Inc.

An Overview of Java. overview-1

HOTPATH VM. An Effective JIT Compiler for Resource-constrained Devices

Cloud Computing. Up until now

Crash Course in Java

Security Issues of the Sandbox inside Java Virtual Machine (JVM) Mohammad Shouaib Hashemi

Lecture 1 Introduction to Android

Code Sharing among Virtual Machines

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

Garbage Collection in the Java HotSpot Virtual Machine

Replication on Virtual Machines

Tool - 1: Health Center

Virtual Machines. Case Study: JVM. Virtual Machine, Intermediate Language. JVM Case Study. JVM: Java Byte-Code. JVM: Type System

Introduction to Java

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Instruction Folding in a Hardware-Translation Based Java Virtual Machine

Checking Access to Protected Members in the Java Virtual Machine

The Java Virtual Machine Specification

Online Recruitment System 1. INTRODUCTION

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Java and Real Time Storage Applications

Introduction to Programming

Java Interview Questions and Answers

Java Crash Course Part I

2 Introduction to Java. Introduction to Programming 1 1

Java Virtual Machine Locks

Jonathan Worthington Scarborough Linux User Group

Fundamentals of Java Programming

Chapter 4 Lecture 5 The Microarchitecture Level Integer JAVA Virtual Machine

Experimental Evaluation of Distributed Middleware with a Virtualized Java Environment

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

1. Overview of the Java Language

Chapter 3: Operating-System Structures. Common System Components

Developing Embedded Software in Java Part 1: Technology and Architecture

Stack Allocation. Run-Time Data Structures. Static Structures

An evaluation of the Java Card environment

Java Obfuscation Salah Malik BSc Computer Science 2001/2002

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Programming Languages

Multi-core Programming System Overview

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

Development of Java ME

Java Card. Smartcards. Demos. . p.1/30

Java's garbage-collected heap

IBM SDK, Java Technology Edition Version 1. IBM JVM messages IBM

JavaCard. Java Card - old vs new

Java and Java Virtual Machine security vulnerabilities and their exploitation techniques

Smart Cards a(s) Safety Critical Systems

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Introduction. Application Security. Reasons For Reverse Engineering. This lecture. Java Byte Code

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

Armed E-Bunny: A Selective Dynamic Compiler for Embedded Java Virtual Machine Targeting ARM Processors

WebSphere Architect (Performance and Monitoring) 2011 IBM Corporation

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Reach 4 million Unity developers

A JAVA VIRTUAL MACHINE FOR THE ARM PROCESSOR

How To Safely Insert In Joie (Java)

EXTENDING JAVA VIRTUAL MACHINE TO IMPROVE PERFORMANCE OF DYNAMICALLY-TYPED LANGUAGES. Yutaka Oiwa. A Senior Thesis

Using jvmstat and visualgc to Solve Memory Management Problems

Can You Trust Your JVM Diagnostic Tools?

Instruction Folding in a Hardware-Translation Based Java Virtual Machine

Java Programming Fundamentals

Caching and the Java Virtual Machine

Java Card TM Open Platform for Smart Cards

Performance Improvement In Java Application

VisualJVM: A Visual Tool for Teaching Java Technology

Briki: a Flexible Java Compiler

Transcription:

- Applet java appaiono di frequente nelle pagine web - Come funziona l'interprete contenuto in ogni browser di un certo livello? - Per approfondire il funzionamento della Java Virtual Machine (JVM): - "The Java Virtual Machine Specification" di Tim Lindholm e Frank Yellin disponibile on line su http://java.sun.com 1

Funzionamento di Java A differenza degli altri linguaggi di programmazione per Java lo scopo fondamentale e' funzionare su ogni tipo di hadware che possegga un implementazione della Java Virtual Machine (JVM). Il.class che otteniamo dalla compilazione non e' codificato per il linguaggio macchina Ad eseguire il.class non sara', quindi, il processore ma un programma che interpreta i bytecode e trasmette i comandi corrispondenti al processore. 2

The Java Virtual Machine Java Architecture Java Programming Language Java Virtual Machine (JVM) Java API 3

Reference The content of this lecture is based on Inside the Java 2 Virtual Machine by Bill Venners Chapter 1 Introduction to Java's Architecture» http://www.artima.com/insidejvm/ed2/introarchp.html Chapter 5 The Java Virtual Machine» http://www.artima.com/insidejvm/ed2/jvmp.html Interactive Illustrations» http://www.artima.com/insidejvm/applets/index.html 4

The Java Programming Environment 5

The Java Platform The byte code generated by the Java front-end is an intermediate form Compact Platform-independent 6

The Class File Java class file contains Byte code for data and methods (intermediate form, platform independent) Symbolic references from one class file to another Class names in text strings Decompiling/reverse engineering quite easy Field names and descriptors (type info) Method names and descriptors (num args, arg types) Symbolic refs to other class methods/fields, own methods/fields 7

Bytecode Basics Bytecodes are the machine language of the Java virtual machine. A method's bytecode stream is a sequence of instructions for the Java virtual machine. Each instruction consists of a one-byte opcode followed by zero or more operands. The opcode indicates the action to take. Each type of opcode has a mnemonic. In the typical assembly language style, streams of Java bytecodes can be represented by their mnemonics followed by any operand values. 8

Bytecode Basics ctd. // Bytecode stream: 03 3b 84 00 01 1a 05 68 3b a7 ff f9 // Disassembly: iconst_0 // 03 istore_0 // 3b iinc 0, 1 // 84 00 01 iload_0 // 1a iconst_2 // 05... 9

The Role of the Virtual Machine Local or Remote 10

Class Loaders Bootstrap (default) loader (in the JVM) User-defined (custom) loaders 11

Dynamic Class Loading You don't have to know at compile-time all the classes that may ultimately take part in a running Java application. User-defined class loaders enable you to dynamically extend a Java app at run-time As it runs, your app can determine what extra classes it needs and load them Custom loaders can download classes across a network (applets), get them out of some kind of database, or even calculate them on the fly. 12

The Execution Engine Back-end transformation and execution Simple JVM byte code interpretation Just-in-time compiler Method byte codes are compiled into machine code the first time they are invoked The machine code is cached for subsequent invocation It requires more memory Adaptive optimization The interpreter monitors the activity of the program, compiling the heavily used part of the program into machine code It is much faster than simple interpretation, a little more memory The memory requirement is only slightly larger due to the 20%/80% rule of program execution (In general, 20% of the code is responsible for 80% of the execution) 13

The Java Virtual Machine 14

Shared Data Areas Each JVM has one of each: Method area: byte code and class (static) data storage Heap: object storage 15

Thread Data Areas Frame in Execution 16

Stack Frames Stack frames have three parts Local variables Operand stack Frame data 17

Stack Frame Local Variables class Example3a { public static int runclassmethod(int i, long l, float f, double d, Object o, byte b) { } return 0; public int runinstancemethod(char c, double d, short s, boolean b) { } } return 0; 18

Stack Frame Operand Stack Adding 2 numbers iload_0 iload_1 Iadd istore_2 Compiler can tell how many slots the op stack will need for a method 19

Stack Frame Frame Data The stack frame also supports Constant pool resolution Normal method return Exception dispatch 20

Stack Frame Frame Allocation in a Heap class Example3c { public static void addandprint() { double result = addtwotypes(1, 88.88); System.out.println(result) ; } public static double addtwotypes(int i, double d) { } } return i + d; 21

Stack Frame Native Method A simulated stack of the target language (e.g. C) is created for JNI 22

The Heap Class instances (objects) and arrays are stored in a single, shared heap Each Java application has its own heap Isolation But a JVM crash will break this isolation JVM heaps always implement garbage collection mechanisms 23

Heap Monolithic Object Representation 24

The Heap Split Object Representation 25

The Heap Memory/Speed Tradeoff 26

The Heap Arrays as Objects 27

Examples HeapOfFish http://www.artima.com/insidejvm/applets/heapoffish.html Object allocation illustration Eternal Math Example http://www.artima.com/insidejvm/applets/eternalmath.html JVM execution, operand stack, illustration 28