1 Ralf Scheidhauer PS Lab, DFKI May 18, 1999 Design, Implementierung und Evaluierung einer virtuellen Maschine für Oz.

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
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.
Henk Corporaal TUEindhoven 2011
Semantic Analysis Chapter 6. Two Flavors  Static (done during compile time) –C –Ada  Dynamic (done during run time) –LISP –Smalltalk  Optimization.
1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
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.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
Functional Programming. Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends.
Recursion vs. Iteration The original Lisp language was truly a functional language: –Everything was expressed as functions –No local variables –No iteration.
Names and Bindings.
Functions Functions and Parameters. History A function call needs to save the registers in use The called function will use the registers The registers.
Computer System Overview
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Lecture: Algorithmic complexity
Compiler Construction
Intermediate code generation. Code Generation Create linear representation of program Result can be machine code, assembly code, code for an abstract.
Cse321, Programming Languages and Compilers 1 6/12/2015 Lecture #17, March 12, 2007 Procedure Abstraction, Name Spaces, Scoping Rules, Activation Records,
1 Chapter 7: Runtime Environments. int * larger (int a, int b) { if (a > b) return &a; //wrong else return &b; //wrong } int * larger (int *a, int *b)
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
Memory Allocation. Three kinds of memory Fixed memory Stack memory Heap memory.
November 29, 2005Christopher Tuttle1 Linear Scan Register Allocation Massimiliano Poletto (MIT) and Vivek Sarkar (IBM Watson)
CS 312 Spring 2004 Lecture 18 Environment Model. Substitution Model Represents computation as doing substitutions for bound variables at reduction of.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Chapter 10 Storage Management Implementation details beyond programmer’s control Storage/CPU time trade-off Binding times to storage.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
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.
FUNCTIONAL PROGRAMMING IN ERLANG ID1218 Lecture Christian Schulte Software and Computer Systems School of Information and.
Linear Scan Register Allocation POLETTO ET AL. PRESENTED BY MUHAMMAD HUZAIFA (MOST) SLIDES BORROWED FROM CHRISTOPHER TUTTLE 1.
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.
CENG 311 Machine Representation/Numbers
Compiler Construction Lecture 17 Mapping Variables to Memory.
Runtime Environments What is in the memory? Runtime Environment2 Outline Memory organization during program execution Static runtime environments.
Fast, Effective Code Generation in a Just-In-Time Java Compiler Rejin P. James & Roshan C. Subudhi CSE Department USC, Columbia.
Lecture 17 Today’s Lecture –Instruction formats Little versus big endian Internal storage in the CPU: stacks vs. registers Number of operands and instruction.
Instruction Set Architecture
Mastering STACKS AN INTRODUCTION TO STACKS Data Structures.
Keneequa Brown Chris Duzan Navaid Khalfay. Originally developed in 1986 by Joe Armstrong as a proprietary language within Ericsson Released as open source.
Lecture 10 : Introduction to Java Virtual Machine
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Threads and Processes.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
Compiler Chapter# 5 Intermediate code generation.
Pointers OVERVIEW.
1 Records Record aggregate of data elements –Possibly heterogeneous –Elements/slots are identified by names –Elements in same fixed order in all records.
Functional Programming With examples in F#. Pure Functional Programming Functional programming involves evaluating expressions rather than executing commands.
Chapter Fifteen: Functional Programming Languages Lesson 12.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Prolog Program Style (ch. 8) Many style issues are applicable to any program in any language. Many style issues are applicable to any program in any language.
Lecture by: Prof. Pooja Vaishnav.  Language Processor implementations are highly influenced by the kind of storage structure used for program variables.
Programming Languages
CSC 8505 Compiler Construction Runtime Environments.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
Programming Languages and Paradigms Activation Records in Java.
Error Example - 65/4; ! Toplevel input: ! 65/4; ! ^^ ! Type clash: expression of type ! int ! cannot have type ! real.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Embedded Real-Time Systems
A Single Intermediate Language That Supports Multiple Implemtntation of Exceptions Delvin Defoe Washington University in Saint Louis Department of Computer.
Chapter 14 Functions.
Type Checking and Type Inference
Processes and threads.
PROGRAMMING LANGUAGES
Understanding Program Address Space
Closure Representations in Higher-Order Programming Languages
Declarative Computation Model Single assignment store (VRH 2
Course Overview PART I: overview material PART II: inside a compiler
EE 345S Real-Time Digital Signal Processing Lab Spring 2009
Dynamic Binary Translators and Instrumenters
Presentation transcript:

1 Ralf Scheidhauer PS Lab, DFKI May 18, 1999 Design, Implementierung und Evaluierung einer virtuellen Maschine für Oz

2 Oz q Developed at DFKI since 1991 q DFKI Oz 1.0 (1995), DFKI Oz 2.0 (1998) q Mozart 1.0 (1999) m lines of C++ m lines of Oz m lines documentation q Since 1996 collaboration with SICS and UCL q Application strength system: multi agents (DFKI, SICS), computer-bus scheduling (Daimler), gate scheduling (Singapore), NL (SFB), comp. biology (LMU),...

3 Related Work q LP, CLP [Warren 77], [Jaffer Lassez 86] q Concurrency [Saraswat 93] q AKL [Janson Haridi 90, Janson 94] q FP [Appel 92]

4 Overview q Language L q Virtual machine q Implementation q Evaluation

5 The Language L q Core language of Oz q Presentation as extension of a sub language of SML m Logic variables m Threads m Synchronization m Dynamic type system  Extensions via predefined functions lvar() logic variable unify(x,y) unification spawn(f) thread creation

6 Graph Model q Integers q Tuples q Functions q Cells (references) q Constructors TUPLE INT/3TUPLECELL INT/5 CON q Strict evaluation of expressions e 0  e 1 ...

7 Why Logic Variables? q Programming techniques: backpatching, difference lists,... q Cyclic data structures  Tail recursive definition of many functions ( append, map,...) q Synchronization of threads q Search

8 Logic Variables: Creation and Representation let val x = lvar() in (4,x,23) end TUPLE INT/4VARINT/23

9 Logic Variables: Unification TUPLE unify(, ) TUPLE INT/3VARINT/2 INT/3INT/5VAR TUPLE INT/3INT/2 INT/3INT/5

10 Threads  Creation spawn(f) e1e1 thread 1 enen thread n... f() thread n+1  Synchronization: logic variables (x+y) q Fairness store

11 Virtual Machine

12 Model scheduler threads heap code... move Y3 X0 move G5 X1 apply G2 2 return... stack X-regs

13 V-Addressing q Address toplevel variables via V-registers q Loader builds data on the heap  code contains direct references into heap  Example fun f(l,u) = map(fn(x)=>h(x)+g(x)+u, l)  h and g in V-register  reduced memory consumption

14 Dynamic Code Specialization fastApply V 3 apply V 3 2 specApply V 3 2

15 Unification in the Machine Model TUPLE unify(, ) TUPLE INT/3VARINT/2 INT/3INT/5VAR TUPLE INT/3REFINT/2 INT/3INT/5REF

16 Synchronization = Suspension + Wakeup thread (x+y) VARx: VARy: suspension...

17 Synchronization = Suspension + Wakeup  Wakeup: unify(x,23) thread REFx: VARy: (x+y) to the scheduler INT/23

18 Implementation

19 Emulator vs. Native Code virtual machine native code emulator implementation q portable q flexible q fast (?)

20 Threads q X registers: once per machine, not per thread m Save live X registers upon preemption/suspension: pessimistic guess per function m Exact determination during GC by code interpretation

21 Representation of the Graph: Naiv type registerheap... INT 23

22 Representation of the Graph: Optimized register 23 INT PTR type... heap

23 Representation of the Graph: Logic Variables registerheap 23 INT PTR VAR... PTR REF...

24 REF WAM Logic Variables: Optimized registerheap 23 INT REF... VAR PTR type... register

25 Moving More Tags registerheap 23 INT REF... PTR type... TPL...

26 Evaluation

27 Comparison with Emulators q Mozart is one of the fastest emulators q Competitive with OCAML and Java q Significantly faster than Moscow ML q Twice as fast as Sicstus Prolog and Erlang

28 Comparison with Native Code Systems q Few memory accesses (i.e. arithmetics)  Mozart is easily one order of magnitude slower q Memory intensive (symbolic computation) m Difference only approx. factor 2-3 m Mozart in single cases faster than native ML or C++

29 Threads q Threads in Mozart are very light weight q Leading position both for creation and communication q Up to nearly 2 orders of magnitude faster than Java (creation)

30 Summary q Extended sub language of SML by logic variables and threads q Machine model m V - registers m Dynamic code specialization m Synchronization q Implementation m Efficient implementation of threads m Tagging scheme q Evaluation m Mozart is one of the fastest emulators m Compares well with native code systems on its target applications m Mozart has very light weight threads

31 Backup Slides for the Discussion

32 Logic Variables vs. Functions q Runtime fibonaccitakeushi speedup q Memory (large scale applications) m Use approx. 18 % of heap memory m Approx. twice as much as objects m Approx. as much as records

33 Memory Profile

34 Mandelbrot (Floats) /1.11 1/1.58 1/8.77 1/ /39.24

35 Quicksort with Lists /2.59 1/3.69 1/2.99 1/3.46

36 Quicksort with Arrays /1.48 1/4.01 1/7.92 1/1.52 1/20.86

37 Naiv Reverse /

38 Threads: Creation

39 Threads: fib(20) /

40 Tagging Scheme of Mozart q 4 bit tag, but only 2 bit loss for address space (=1GB): align structures on word boundaries q Lists, tuples: no need to unmask before type test  REF - tag m no unmask before test necessary m no unmask before deref

41 Threads X PC L G task thread move Y3 X0 move G5 X1 apply G2 2...

42 Emulators: Optimization Techniques q Threaded code q Instruction collapsing q Register access q Specialization  Example move Y 5 X 3 move Y 6 X (SPARC)

43 Address Modes (Registers) nameliveness notation usage Xthread X i temp. values, parameters localfct-body L i local variables globalfunction G i free variables virtualprogram V i constants

44 Threads q Fairness: status-register check on every function call (and return) GC IO PRE....

45 L e ::=x variable |ninteger | (e 1,...,e n ) tuple | fn (x 1,...,x n ) => efunction | e 0 (e 1,...,e n )application | let val x = e in e end variable declaration | let con x in e end constructor declaration | case e of p 1 => e 1 |... | p n => e n pattern matching lvar: () ->  logic variable unify:    -> () unification spawn: (() ->  ) -> () thread creation Operators

46 Tagged Xi = X[*(PC+1)]; 2 0 (2) DEREF(Xi); 20 if (isInt(getTag(Xi))) { 1+20 Tagged Xk = X[*(PC+2)]; 22 DEREF(Xk); 20 if (isInt(getTag(Xk))) { int aux = intValue(Xi)+intValue(Xk); XPC(3) = oz_int(aux); ovflw+shifttag+store (2) DISPATCH(4); 33 } } 277(11) no derefs 23 no type tests 17 overflow 6 add X i X k X n

47 Java: JIT vs. Emulator speedup quicksort (array)18.8 fib (int)14.2 fib (float)4.9 queens6.1 nrev 2.0 quicksort (list)2.3 fib (thread)1.1 mandelbrot5.4 deriv (virtual)1.9