Download presentation
Presentation is loading. Please wait.
1
2.1. Compilers and Interpreters
2
Compile-Link Process Next topic
3
Compilers and Interpreters
4
Compilers vs Interpreters
5
High-level View of a Compiler
6
Compilation
7
Interpretation
8
Language Implementation
9
Cross Compilation
10
Calling conventions
11
Static & Dynamic Allocation
12
Parameter Passing Mechanism
13
Call by Value
14
Call by Value Result
15
Call by Reference
16
Java Programming Environment
Java compiler produces an intermediate code known as byte code for a machine, known as JVM. It exists only inside the computer memory. Machine code is generated by the java interpreter by acting as an intermediary between the virtual machine and real machine. Java Program Java Compiler Virtual Machine Bytecode Java Interpreter Machine Code 16
17
Java Programming Environment
Compile-time environment Run-time environment A.java B.java C.java Java compiler A.class B.class C.class Your program’s source files Your program’s class files Your program’s class files A.class B.class C.class Your class files move locally or through a network Java Virtual Machine Java Interpreter Object.class String.class Java API’s class files
18
What is ‘Java Virtual Machine’ …?
The abstract specification A concrete implementation A run-time instance ByteCode (class files) JVM Linux Win Mac Compiled Java Program Java Virtual Machine H/W Platform & OS
19
Java Virtual Machine Architecture
A.java A.class Java Compiler Compile source code Java Virtual Machine Loader Network B.class Verifier Linker Bytecode Interpreter
20
Basic Block Diagram of JVM
Java Virtual Machine Your program’s class files Java API’s class files Class Loader ByteCodes Execution Engine Native method invocation Host Operating System RealTimeSystems Lab
21
Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU
Primary Memory . Disk Editor Compiler Class Loader Program is created in an editor and stored on disk in a file ending with .java. Compiler creates bytecodes and stores them on disk in a file ending with .class. Class loader reads .class files containing bytecodes from disk and puts those bytecodes in memory. Phase 1 Phase 2 Phase 3 Bytecode Verifier Bytecode verifier confirms that all bytecodes are valid and do not violate Java’s security restrictions. Phase 4 Interpreter Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes. Phase 5 JVM Md. Samsuzzaman ,Lecturer Faculty of CSE, PSTU 05/07/ Mosarratj Jahan, Dept. of CSE, DU 21
22
.NET Compilation and Execution
Also called Assembly (.EXE or .DLL file) Source Code Language Compiler Code MSIL Metadata Before installation or the first time each method is called Execution Native Code JIT Compiler
23
The Common Language Runtime Compilation and Execution
Source code written in Visual C#, Visual Basic .NET or another language that targets the CLR is first transformed into MSIL by the appropriate language compiler. Before execution, this MSIL is compiled by the Just-in-Time (JIT) complier into native code for the processor on which the code will operate.
24
The Common Language Runtime Compilation and Execution
The default is to JIT compile each method when it is first called, but it is also possible to “preJIT” MSIL code to native code at assembly install-time. With this option, all methods are compiled before the application is loaded so as to avoid the overhead of JIT compilation on each initial method call.
25
The Common Language Runtime Compilation and Execution
You use the Native Image Generator (Ngen.exe) to create a native image from a managed assembly and install it into the native image cache. Once the code is compiled and cached, the CLR does not need to re-compile the MSIL code until the assembly is updated, the Just-In-Time compiled code is removed from the cache, or the machine is restarted.
26
summary
27
Interpreters
28
Compiler vs. Interpreter
29
Compiler vs. Interpreter
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.